:root {
    --navy: #2C3E50;
    --ink: var(--navy);
    --ink-light: color-mix(in oklch, var(--navy), white 45%);
    --muted: color-mix(in oklch, var(--navy), white 65%);
    --border: oklch(84% 0.02 205);
    --bg: oklch(98.5% 0.006 200);
    --surface: oklch(100% 0 0);
    --surface-alt: oklch(99.2% 0.005 200);
    --hairline: color-mix(in oklch, var(--border), var(--navy) 12%);
    --teal-dark: oklch(50% 0.10 175);
    --teal: oklch(60% 0.12 175);
    --teal-soft: oklch(96% 0.02 175);
    --orange: oklch(72% 0.16 50);
    --orange-soft: oklch(97% 0.04 50);
    --amber: oklch(75% 0.16 85);
    --radius: 16px;
    --shadow-sm: 0 1px 2px 0 rgba(44, 62, 80, 0.08);
    --shadow-md: 0 10px 20px -5px rgba(44, 62, 80, 0.10), 0 4px 6px -4px rgba(44, 62, 80, 0.05);
    --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.gallery-shell,
.gallery-shell * {
    box-sizing: border-box;
}

.gallery-shell {
    font-family: var(--font-sans);
    color: var(--ink);
    background-color: var(--bg);
    background-image: radial-gradient(circle at 50% 0%, oklch(97.5% 0.01 190) 0%, var(--bg) 60%);
    min-height: 100vh;
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.text-right {
    text-align: right;
}

.text-ox {
    color: color-mix(in oklch, var(--orange), var(--ink) 10%);
}

.global-warning-btn,
.status-pill,
.btn-pill,
.quota-pill.mini {
    flex: 0 0 auto;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    border-radius: 99px;
    font-weight: 750;
    font-size: 11px;
}

.status-pill {
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    background: var(--surface);
    padding: 0 12px;
    border: 1px solid var(--border);
}

    .status-pill .dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: var(--border);
    }

    .status-pill.ready .dot {
        background: var(--teal);
        box-shadow: 0 0 0 2px var(--teal-soft);
    }

.btn-pill {
    gap: 8px;
    padding: 0 12px;
    border: 1px solid var(--hairline);
    background: var(--surface);
    color: var(--ink-light);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 850;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    user-select: none;
    transition: background .2s ease, border-color .2s ease, color .2s ease, transform .08s ease, opacity .2s ease;
}

    .btn-pill:hover:not(:disabled) {
        border-color: color-mix(in oklch, var(--hairline), var(--teal) 22%);
        color: var(--teal-dark);
        background: color-mix(in oklch, var(--surface), var(--teal-soft) 40%);
    }

    .btn-pill:disabled {
        opacity: 0.55;
        cursor: not-allowed;
    }

.btn-link {
    background: none;
    border: none;
    padding: 0;
    color: var(--ink-light);
    font-weight: 650;
    cursor: pointer;
    font-size: 11px;
    white-space: nowrap;
    transition: color 0.2s ease;
}

    .btn-link:hover {
        color: var(--teal-dark);
        text-decoration: underline;
        text-decoration-color: color-mix(in oklch, var(--teal-soft), white 35%);
        text-underline-offset: 4px;
    }

.quota-pill.mini {
    gap: 6px;
    background: var(--surface);
    padding: 2px 8px;
    border: 1px solid var(--hairline);
}

.quota-info {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--hairline);
    display: flex;
    flex-direction: column;
}

.quota-meter {
    width: 24px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.quota-meter-fill {
    display: block;
    height: 100%;
    background: var(--teal);
}

.quota-count {
    font-weight: 650;
    color: var(--ink);
}

.filename {
    font-weight: 650;
    font-size: 13px;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--ink);
}

.config-section {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.divider-text {
    font-size: 11px;
    font-weight: 850;
    color: var(--muted);
    text-transform: uppercase;
    margin-bottom: 12px;
}

.form-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form-group label {
    display: block;
    font-size: 11px;
    font-weight: 750;
    color: var(--ink-light);
    margin-bottom: 4px;
}

.gallery-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--hairline);
    border-radius: 8px;
    background: var(--surface-alt);
    font-size: 13px;
    outline: none;
    transition: background .2s ease, border-color .2s ease, box-shadow .2s ease, opacity .2s ease;
    color: var(--ink);
}

    .gallery-input:focus {
        border-color: color-mix(in oklch, var(--border), var(--teal) 35%);
        background: var(--surface);
        box-shadow: 0 0 0 3px color-mix(in oklch, var(--surface), var(--teal-soft) 50%);
    }

.hint-pill.warning {
    background: var(--orange-soft);
    color: var(--orange);
    border: 1px solid oklch(95% 0.05 50);
    font-size: 10px;
    padding: 4px 8px;
    border-radius: 99px;
    display: inline-block;
    margin-top: 8px;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: oklch(20% 0.05 220 / 0.40);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

.modal-card {
    background: var(--surface);
    width: 100%;
    max-width: 400px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--hairline);
}

    .modal-card.modal-wide {
        max-width: 980px;
        width: min(980px, 96vw);
        max-height: 86vh;
    }

.modal-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--hairline);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface-alt);
    flex-shrink: 0;
}

.modal-title {
    font-weight: 850;
    color: var(--ink);
    letter-spacing: 0.02em;
}

.modal-body {
    padding: 0;
    max-height: 300px;
    overflow-y: auto;
}

.modal-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--hairline);
    background: var(--surface-alt);
    text-align: right;
    flex-shrink: 0;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: grid;
    place-items: center;
    transition: background .2s ease, color .2s ease, transform .08s ease, opacity .2s ease;
}

    .modal-close:hover {
        background: color-mix(in oklch, var(--surface), var(--teal-soft) 35%);
        color: var(--teal-dark);
    }

.btn-ghost {
    background: var(--surface);
    border: 1px solid var(--hairline);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 650;
    color: var(--ink-light);
    cursor: pointer;
    transition: background .2s ease, border-color .2s ease, color .2s ease, transform .08s ease, opacity .2s ease;
}

    .btn-ghost:hover {
        border-color: color-mix(in oklch, var(--hairline), var(--teal) 22%);
        color: var(--teal-dark);
        background: color-mix(in oklch, var(--surface), var(--teal-soft) 30%);
    }

.json-viewer {
    padding: 12px 16px 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.json-help {
    font-size: 11px;
    color: var(--muted);
}

.json-wrapper {
    display: grid;
    width: 100%;
    min-width: 0;
}

.json-block {
    flex: 1 1 auto;
    min-height: 240px;
    max-height: 68vh;
    overflow: auto;
    white-space: pre;
    background: var(--navy);
    color: oklch(94% 0.02 200);
    padding: 12px;
    border-radius: 10px;
    font-size: 11px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    border: 1px solid color-mix(in oklch, var(--navy), white 15%);
    scrollbar-width: thin;
    scrollbar-color: color-mix(in oklch, var(--navy), white 35%) transparent;
    user-select: text;
    contain: layout paint;
    scrollbar-gutter: stable both-edges;
}

.error-banner {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid oklch(92% 0.05 25);
    background: oklch(97% 0.03 25);
    color: oklch(35% 0.08 25);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    font-weight: 650;
}

.error-icon {
    font-size: 14px;
}

.spinner-tiny {
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--teal);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.tech-details {
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding-top: 12px;
    padding-right: 4px;
}

    .tech-details summary {
        font-size: 11px;
        color: var(--ink-light);
        cursor: pointer;
        font-weight: 750;
        outline: none;
        margin-bottom: 8px;
        user-select: none;
        transition: color 0.2s ease;
    }

        .tech-details summary:hover {
            color: var(--teal-dark);
        }

.btn-pill:focus-visible,
.data-grid .toolbar-icon:focus-visible,
.data-grid .toolbar-tabs .tab-btn:focus-visible,
.btn-link:focus-visible,
.global-warning-btn:focus-visible,
.modal-close:focus-visible,
.btn-ghost:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in oklch, var(--surface), var(--teal-soft) 55%), 0 0 0 5px color-mix(in oklch, var(--teal), white 70%);
}

@media (min-width: 850px) {
    .card {
        height: 100%;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .error-banner {
        flex-shrink: 0;
    }
}
