:root {
    --page-max: 960px;
    --gap: 1rem;
    --card-bg: #fff;
    --card-border: #ddd;
    --muted: #555;
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    margin: 0;
    background: #f6f6f6;
}

.page {
    max-width: var(--page-max);
    margin: 0 auto;
    padding: 1rem;
}

.top-container {
    max-width: 500px;
    margin: 0 auto;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem .75rem;
    /*justify-content: space-between;*/
    /*align-items: center;*/
    margin-bottom: .75rem;
}

    .controls button, .controls label.btn {
        padding: .45rem .75rem;
        border-radius: 8px;
        border: 1px solid #bbb;
        background: #fff;
        cursor: pointer;
    }

        .controls button:hover, .controls label.btn:hover {
            background: #f0f0f0;
        }

.clear-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px; /* space between icon and text */
    padding: .45rem .75rem;
    background: #fff;
    cursor: pointer;
}

    .clear-btn svg {
        pointer-events: none; /* avoid accidental clicks on icon */
    }

.file-area {
    flex: 1 1 100%;
    border: 2px dashed #aaa;
    border-radius: 10px;
    padding: 1rem;
    text-align: center;
    background: #fff;
    color: #444;
    cursor: pointer;
    /*margin-bottom: 0.75rem;*/
    transition: background-color 0.2s, border-color 0.2s;
}

    .file-area p {
        margin: 0;
        font-size: 0.95rem;
    }

    .file-area:hover {
        /*background-color: #f0faff;*/
        border-color: #00bcd4;
    }

    .file-area.dragover {
        background-color: #f0faff;
        border-color: #00bcd4;
    }

    .file-area svg {
        /*color: #0078D7;*/
        color: #555;
        margin: 0 auto 0.4rem auto;
        pointer-events: none; /* avoid accidental clicks on icon */
    }

/* Problems list */
#problems {
    display: flex;
    flex-direction: column;
    gap: var(--gap);
}

/* Card layout */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: var(--gap);
    align-items: flex-start;
}

.left-col {
    flex: 0 0 230px;
    min-width: 0;     /* allow shrinking */
    max-width: 230px;
}

.right-col {
    flex: 1 1 280px;
    min-width: 220px;
    align-self: flex-start;
}

/* Meta & text blocks */
.meta {
    /*color: var(--muted);*/
    font-size: .9rem;
    margin-bottom: .5rem;
    line-height: 1.2;
    white-space: pre-line;
}

.p2w-diagram {
    margin-bottom: .5rem;
}

.stipulation {
    font-size: .9rem;
}

.twins {
    font-size: .9rem;
    white-space: pre-line;
}

/* Solution widget */
.solution {
    white-space: pre-line;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    text-align: left;
    background: #f7f7f7;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: .6rem .7rem;
    min-height: 0; /* allow auto height */
}

.helpman-link-wrapper {
    margin: .5rem 0;
}

.helpman-link {
    font-size: 1rem;
}

.extra-info-wrapper {
    margin: .5rem 0;
}
.share-links {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.share-link-item {
    display: flex;
    align-items: center;
    background: #f9f9f9;
    border: 1px solid #ddd;
    padding: 6px 10px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

    .share-link-item a {
        flex: 1;
        margin-right: 8px;
        color: #0366d6;
        text-decoration: none;
        /*font-size: 0.95em;*/
        font-size: 0.85rem;
        word-break: break-all;
    }

        .share-link-item a:hover {
            text-decoration: underline;
        }

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    margin-left: 4px;
    border-radius: 4px;
    /*display: flex;*/
    display: inline;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: background 0.2s, color 0.2s;
}

    .icon-btn:hover {
        background: #eee;
        color: #000;
    }

    .icon-btn svg {
        width: 16px;
        height: 16px;
        fill: currentColor;
    }

.icon-btn-container {
    text-align: right;
}

/* Responsive adjustments */
@media (max-width: 400px) {
    .card {
        flex-direction: column;
    }

    .left-col, .right-col {
        flex: 1 1 auto;
        min-width: 100%;
        max-width: 100%;
    }

    .right-col {
        padding-top: 0;
    }
}

.fen-output {
    white-space: pre-wrap;
    word-break: break-all; /* wrap at any character */
    font-size: 0.8rem;
    margin: .5rem 0;
}

#loadingIndicator {
    display: none; /* hidden by default */
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #eee;
    color: #333;
    text-align: center;
    padding: 0.5em;
    font-style: italic;
    border-top: 1px solid #ccc;
    z-index: 9999;
    /*display: flex; *//* layout when shown */
    align-items: center;
    justify-content: center;
    gap: 0.5em;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #ccc;
    border-top: 2px solid #333;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}


/* Footer */
.footer {
    text-align: center;
    font-size: 0.85rem;
    color: var(--muted);
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid #ddd;
}

    .footer a {
        color: inherit;
        text-decoration: underline;
    }

        .footer a:hover {
            color: #000;
        }
