/* ==========================================================================
   AlNajdi — Admin dashboards
   ========================================================================== */

.admin-nav {
    direction: ltr;
}
.admin-nav .top-nav-inner {
    grid-template-columns: auto auto 1fr;
    max-width: 1480px;
}
.admin-nav .top-nav-right {
    justify-content: flex-end;
    min-width: 0;
}
.admin-nav .top-nav-links,
.admin-nav .brand-name {
    unicode-bidi: isolate;
}
[dir="rtl"] .admin-nav .top-nav-link,
[dir="rtl"] .admin-nav .brand-name {
    direction: rtl;
}
.admin-phone-pill {
    max-width: 180px;
}
.admin-page {
    text-align: start;
}
.admin-page .page-head {
    text-align: start;
}
.admin-search-input {
    text-align: start;
    unicode-bidi: plaintext;
}

/* Shared admin file controls: visible actions and readable selection state. */
.admin-file-picker {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-width: 0;
    padding: 16px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    background: var(--bg-elev-2);
}
.admin-file-picker-details { display: flex; align-items: center; gap: 12px; min-width: 0; }
.admin-file-picker-icon {
    display: grid;
    place-items: center;
    flex: 0 0 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--bg-elev);
    color: var(--text-soft);
}
.admin-file-picker.has-file .admin-file-picker-icon { color: var(--ok); }
.admin-file-picker-copy { min-width: 0; }
.admin-file-picker-name { overflow-wrap: anywhere; font-size: .875rem; font-weight: 650; color: var(--text); }
.admin-file-picker-hint { margin: 3px 0 0; font-size: .75rem; color: var(--text-mute); }
.admin-upload-button {
    flex-shrink: 0;
    min-height: 44px;
    padding: 10px 16px;
    font-size: .875rem;
    white-space: normal;
}
.admin-upload-button:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.admin-file-picker:has(input:disabled) { opacity: .65; }
.admin-file-picker.is-compact { display: inline-flex; padding: 0; border: 0; background: transparent; }
.admin-import-divider { display: flex; align-items: center; gap: 12px; margin: 20px 0 12px; color: var(--text-mute); }
.admin-import-divider::before,
.admin-import-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.admin-import-media-slot { margin-block: 12px 20px; }
.admin-media-url { display: block; margin-top: 10px; }
@media (max-width: 520px) {
    .admin-file-picker { align-items: stretch; flex-direction: column; gap: 12px; padding: 14px; }
    .admin-file-picker .admin-upload-button { width: 100%; }
    .admin-file-picker.is-compact { flex-direction: row; }
}

/* Creator: 3-pane layout */
.creator-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: calc(100vh - 64px);
    max-width: 1480px;
    margin: 0 auto;
    direction: ltr;
}
[dir="rtl"] .creator-rail,
[dir="rtl"] .creator-main,
[dir="rtl"] .creator-layout > .modal-back {
    direction: rtl;
}
@media (max-width: 900px) {
    .creator-layout { grid-template-columns: 1fr; }
    /* Stacked rail: a normal block above the editor, not a full-height sticky column */
    .creator-rail {
        position: static;
        max-height: none;
        border-inline-end: 0;
        border-bottom: 1px solid var(--border);
        padding: 14px 16px;
    }
    /* Subjects become a horizontal scroller to save vertical space */
    .creator-rail > div { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
    .rail-item { width: auto; flex: 0 0 auto; margin-bottom: 0; max-width: 220px; }
    .rail-add { margin-top: 0; }
    .rail-h { margin-bottom: 8px; }
    .creator-pane { padding: 18px 16px; }
}
@media (max-width: 600px) {
    .subject-banner { height: 150px; }
    .subject-banner-overlay { padding: 16px 18px; }
    .subject-banner-overlay h2 { font-size: 22px !important; }
    /* Pricing table scrolls horizontally rather than overflowing the page */
    .price-table { display: block; overflow-x: auto; white-space: nowrap; }
    .price-table th, .price-table td { padding: 10px 12px; }
    .chip-row { padding: 10px; }
    .q-row { padding: 10px 12px; gap: 8px; }
}

.creator-rail {
    border-inline-end: 1px solid var(--border);
    background: var(--bg-elev);
    padding: 24px 16px;
    overflow-y: auto;
    max-height: calc(100vh - 64px);
    position: sticky;
    top: 64px;
}
.creator-main {
    min-width: 0;
}
.creator-content { display: grid; grid-template-rows: auto 1fr; }
.creator-pane { padding: 28px 32px; }
.creator-pane-chapter {
    border-top: 1px solid var(--border);
    background: var(--bg);
    scroll-margin-top: 12px;
}
.creator-pane-settings { border-top: 1px solid var(--border); }

.rail-h {
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 800;
    color: var(--text-mute);
    text-transform: uppercase;
    letter-spacing: .08em;
    margin: 0 0 12px;
    padding-inline-start: 8px;
}
.rail-item {
    display: flex; align-items: center; gap: 12px;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: 1.5px solid transparent;
    border-radius: var(--r-md);
    cursor: pointer;
    color: inherit;
    font: inherit;
    text-align: start;
    margin-bottom: 4px;
}
.rail-item:hover { background: var(--bg); }
.rail-item.active {
    background: var(--brand-50);
    border-color: var(--brand-200);
}
.rail-thumb {
    width: 40px; height: 40px;
    border-radius: var(--r-sm);
    background: var(--brand-200) center / cover no-repeat;
    flex-shrink: 0;
}
.rail-add {
    justify-content: center;
    color: var(--brand-700);
    font-weight: 700;
    border-style: dashed;
    border-color: var(--border);
    margin-top: 8px;
}
[data-theme="dark"] .rail-add { color: var(--brand-300); }

/* Rail reordering (creator dashboard) */
.rail-row {
    display: flex;
    align-items: center;
    gap: 6px;
    border-radius: var(--r-md);
    will-change: transform;
}
.rail-row .rail-item { flex: 1; min-width: 0; margin-bottom: 0; }
.rail-row.is-dragging {
    position: relative;
    z-index: 20;
    background: var(--bg-elev);
    box-shadow: 0 18px 44px rgba(0, 0, 0, .22);
    cursor: grabbing;
}
.rail-drag-handle {
    width: 32px;
    min-width: 32px;
    height: 48px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--text-soft);
    cursor: grab;
    touch-action: none;
    flex-shrink: 0;
}
.rail-drag-handle:hover { border-color: var(--border); background: var(--bg-elev-2); color: var(--text); }
.rail-drag-handle:active { cursor: grabbing; }
.rail-drag-handle:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }
.rail-grip-dots {
    display: grid;
    grid-template-columns: repeat(2, 4px);
    gap: 4px;
}
.rail-grip-dots > span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: currentColor;
}

/* Subject banner header */
.subject-banner {
    position: relative;
    height: 180px;
    border-radius: var(--r-xl);
    overflow: hidden;
    margin-bottom: 24px;
}
.subject-banner-overlay {
    position: absolute;
    inset: 0;
    padding: 24px 28px;
    background: linear-gradient(180deg, transparent 30%, rgba(0,0,0,.65));
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}
.subject-banner-actions {
    position: absolute;
    top: 16px; inset-inline-end: 16px;
    display: flex; gap: 8px;
}

/* Thumbnail preview in modal */
.thumb-preview {
    width: 100%;
    aspect-ratio: 16/9;
    background: var(--bg-elev-2) center / cover no-repeat;
    border-radius: var(--r-md);
    border: 1.5px dashed var(--border);
    display: grid; place-items: center;
    margin-bottom: 10px;
}
.thumb-placeholder { color: var(--text-mute); font-size: 13px; }

/* Cover cropper */
.crop-back { z-index: 1200; }
.crop-stage {
    position: relative;
    width: 100%;
    height: 320px;
    margin-bottom: 12px;
    overflow: hidden;
    border-radius: var(--r-md);
    background: #0b1220;
}
.crop-zoom {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-soft);
}
.crop-zoom input[type="range"] { flex: 1; }
@media (max-width: 600px) {
    .crop-stage { height: 240px; }
}

/* Chip row */
.chip-row {
    display: flex; flex-wrap: wrap; gap: 8px;
    padding: 12px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
}
.admin-bank-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.admin-bank-heading .section-h { margin-bottom: 10px; }
.admin-bank-share { margin-bottom: 8px; white-space: nowrap; }
.chip {
    background: var(--bg-elev-2);
    border: 1px solid transparent;
    border-radius: var(--r-full);
    padding: 6px 14px;
    font-weight: 600;
    cursor: pointer;
    color: inherit;
    font: inherit;
    font-size: 13px;
}
.chip:hover { background: var(--border); }
.chip.active {
    background: var(--brand-500); color: var(--on-brand);
}
.chip.chip-add {
    background: transparent;
    border: 1px dashed var(--border-strong);
    color: var(--text-soft);
}

/* Pricing table */
.price-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    overflow: hidden;
    margin-top: 8px;
}
.price-table th, .price-table td {
    padding: 12px 16px;
    text-align: start;
    border-bottom: 1px solid var(--border);
}
.price-table th {
    background: var(--bg);
    font-size: 12px;
    font-weight: 700;
    color: var(--text-mute);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.price-table tr:last-child td { border-bottom: 0; }
.chapter-action-cell {
    width: 48px;
    text-align: center;
}
.chapter-delete-btn {
    color: var(--bad);
}

/* Switch toggle */
.switch {
    width: 40px; height: 22px;
    border-radius: 999px;
    background: var(--border);
    border: 0;
    position: relative;
    cursor: pointer;
    transition: background .15s;
    flex-shrink: 0;
}
.switch::after {
    content: "";
    position: absolute;
    top: 3px; left: 3px;
    width: 16px; height: 16px;
    background: #fff;  /* white knob in both states — high contrast on track */
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,.3);
    transition: transform .15s, left .15s, right .15s, background .15s;
}
/* Green when ON, theme-aware: --ok is #16a34a (light) / #22c55e (dark). The
   brand colour is monochrome (near-black light / near-white dark), so it made
   the "on" toggle a black/white pill — green reads as "enabled" and the white
   knob has strong contrast on it in both themes. */
.switch.on { background: var(--ok); }
.switch.on::after { transform: translateX(18px); }
/* RTL: knob STARTS on the right and slides left. Without resetting the base
   position it kept left:3px and slid 18px further left — off the edge (that's
   why the "free" toggle looked broken in Arabic). */
[dir="rtl"] .switch::after { left: auto; right: 3px; }
[dir="rtl"] .switch.on::after { transform: translateX(-18px); }

/* Question rows */
.q-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    margin-bottom: 8px;
    animation: question-batch-enter .22s ease-out both;
}
.q-row-text { flex: 1; min-width: 0; font-weight: 500; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-type-tag { flex-shrink: 0; text-transform: uppercase; }

/* Moderator card grid */
.card-grid { display: flex; flex-direction: column; gap: 12px; }

/* Subscriptions chooser */
.sub-block {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 12px 14px;
    margin-bottom: 10px;
}
.chap-checks {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 4px 12px;
}
.chap-check {
    display: flex; align-items: center; gap: 8px;
    padding: 4px;
    cursor: pointer;
    font-size: 14px;
}
.chap-check input { width: 16px; height: 16px; accent-color: var(--brand-500); flex-shrink: 0; }
.chap-check input:disabled + span { opacity: .5; }

/* Logs list */
.logs-list {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    overflow: hidden;
}
.log-row {
    display: grid;
    grid-template-columns: 120px 160px 1fr auto;
    gap: 14px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    align-items: center;
    font-size: 14px;
}
.log-row:last-child { border-bottom: 0; }
.log-row:hover { background: var(--bg); }
.log-phone { font-family: var(--font-mono); font-size: 13px; }
.log-time { text-align: end; font-size: 12px; }
@media (max-width: 720px) {
    .log-row { grid-template-columns: auto 1fr; }
    .log-time { grid-column: 1 / -1; }
}

/* Color picker */
.color-picker { }
.swatch-row {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
    margin-bottom: 4px;
}
.swatch {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
    transition: transform .12s, border-color .12s;
    position: relative;
}
.swatch:hover { transform: scale(1.08); }
.swatch.selected {
    border-color: var(--text);
    box-shadow: 0 0 0 2px var(--bg-elev), 0 0 0 4px var(--text);
}
.swatch.selected::after {
    content: "✓";
    position: absolute;
    inset: 0;
    color: white;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 14px;
    text-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.swatch-input {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 13px;
}

.modal-actions { display: flex; }

@media (max-width: 600px) {
    .modal-actions { position: sticky; bottom: -1px; padding-top: 10px; background: var(--bg-elev); }
    .modal-actions .btn { flex: 1; }
}

/* ─── TTS admin panel ──────────────────────────────────────────────
   Embedded inside the ChapterPane in AdminCreator. The collapsed
   header shows a one-line summary; the expanded body has engine
   status, coverage, action buttons, and live job progress.

   Aesthetic note: we lean into a "control surface" look — flat
   surfaces, monochrome with a single brand accent, and an emphatic
   running indicator (the pulsing green dot) because watching a batch
   job run is most of what the admin will do here. */
.tts-panel {
    margin-top: 16px;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--bg-elev);
    overflow: hidden;
}
.tts-panel-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: linear-gradient(180deg, var(--bg-elev-2), var(--bg-elev));
    border-bottom: 1px solid var(--border);
    user-select: none;
}
.tts-panel-head:hover { background: var(--bg-elev-2); }
.tts-panel-title { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.tts-panel-chevron { display: inline-block; min-width: 12px; color: var(--text-soft); }
.tts-panel-coverage { display: flex; align-items: center; gap: 10px; }
.tts-generate-changed { min-height: 36px; white-space: nowrap; }
.tts-mini-bar {
    width: 120px; height: 6px;
    background: var(--bg-elev-2); border-radius: var(--r-full);
    overflow: hidden;
}
.tts-mini-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #34d399);
    transition: width .25s ease-out;
}

.tts-badge {
    display: inline-flex; align-items: center;
    padding: 2px 8px;
    border-radius: var(--r-full);
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.04em;
    background: var(--bg-elev-2); color: var(--text-soft);
    border: 1px solid var(--border);
}
.tts-badge.ok    { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.tts-badge.warn  { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.tts-badge.bad   { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }

.tts-panel-body {
    padding: 16px;
    display: flex; flex-direction: column; gap: 14px;
}

.tts-warning {
    padding: 12px 14px;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: var(--r-md);
}
.tts-warning strong { color: #92400e; }

.tts-engines {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 14px;
}
.tts-engine-row {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 10px;
    background: var(--bg-elev-2);
    border-radius: var(--r-md);
    font-size: 13px;
}
/* Translucent tint so the row works in both light and dark themes. */
.tts-engine-row.ok { background: rgba(16, 185, 129, .10); }
.tts-engine-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.tts-engine-label { font-weight: 600; }
.tts-engine-name { margin-inline-start: auto; font-family: var(--font-mono); }
.tts-engine-err { cursor: help; }

.tts-coverage-section {
    display: flex; flex-direction: column; gap: 10px;
}
.tts-coverage-stats { display: flex; gap: 16px; }
.tts-cov-stat {
    display: flex; flex-direction: column; gap: 2px;
    padding: 8px 14px;
    background: var(--bg-elev-2);
    border-radius: var(--r-md);
    min-width: 80px;
}
.tts-cov-stat .rs-num { font-size: 18px; font-weight: 800; line-height: 1; }
.tts-cov-stat .rs-label {
    font-size: 11px; color: var(--text-soft);
    text-transform: uppercase; letter-spacing: 0.05em;
}
.tts-cov-bar {
    height: 8px;
    background: var(--bg-elev-2);
    border-radius: var(--r-full);
    overflow: hidden;
}
.tts-cov-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--brand-500), var(--brand-700, var(--brand-500)));
    transition: width .25s ease-out;
}
.tts-cov-dots {
    display: flex; flex-wrap: wrap; gap: 3px;
    padding: 6px;
    background: var(--bg-elev-2);
    border-radius: var(--r-md);
}
.tts-cov-dot {
    width: 10px; height: 10px;
    border-radius: 3px;
    background: #cbd5e1;
}
.tts-cov-dot.ready { background: #10b981; }
.tts-cov-dot.missing { background: #d1d5db; }

.tts-action-stack { display: flex; flex-direction: column; gap: 8px; }
.tts-action-row { display: flex; flex-wrap: wrap; gap: 8px; }
.tts-runtime-line { display: flex; align-items: center; gap: 6px; }
.tts-repair-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px;
    border: 1px dashed var(--border);
    border-radius: var(--r-md);
    background: var(--bg-elev-2);
}
.tts-repair-label {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.tts-repair-btn {
    background: var(--bg-elev);
    border-color: var(--border);
}

.tts-job-card {
    padding: 12px 14px;
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    display: flex; flex-direction: column; gap: 8px;
}
.tts-job-card.ok   { border-color: #6ee7b7; background: rgba(16, 185, 129, .10); }
.tts-job-card.bad  { border-color: #fca5a5; background: rgba(248, 113, 113, .10); }
.tts-job-card.warn { border-color: #fcd34d; background: rgba(245, 158, 11, .10); }
.tts-job-head { display: flex; align-items: center; gap: 10px; }
.tts-job-status { margin-inline-start: auto; font-size: 12px; color: var(--text-soft); }
.tts-job-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: #94a3b8;
    flex-shrink: 0;
}
.tts-job-dot.running {
    background: #10b981;
    animation: tts-pulse 1s infinite;
}
@keyframes tts-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.3); }
}
.tts-job-bar {
    height: 6px;
    background: rgba(0,0,0,0.07);
    border-radius: var(--r-full);
    overflow: hidden;
}
.tts-job-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--brand-500), #10b981);
    transition: width .25s ease-out;
}
.tts-job-meta { font-size: 11px; }
.tts-job-current {
    margin: 0;
    padding: 6px 10px;
    background: rgba(0,0,0,0.04);
    border-radius: var(--r-sm);
    font-size: 12px;
}
.tts-job-current-text { font-family: var(--font-mono); }
.tts-job-errors summary { cursor: pointer; font-size: 12px; color: #991b1b; }
.tts-job-errors ul { margin: 6px 0 0; padding-inline-start: 18px; }
.tts-job-errors li { font-family: var(--font-mono); color: #991b1b; }

.tts-recent-jobs summary { cursor: pointer; font-size: 12px; color: var(--text-soft); }
.tts-recent-row {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}
.tts-recent-row:last-child { border-bottom: 0; }

/* ─── Local TTS devices ──────────────────────────────────────────── */
.tts-devices-section {
    display: flex; flex-direction: column; gap: 10px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--bg-elev-2);
}
.tts-devices-head { display: flex; align-items: center; gap: 8px; }
.tts-devices-head .muted { margin-inline-start: auto; }
.tts-device-list { display: flex; flex-direction: column; gap: 6px; }
.tts-device-row {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 10px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    font-size: 13px;
}
.tts-device-row.working { border-color: #6ee7b7; }
.tts-device-dot {
    width: 8px; height: 8px; flex-shrink: 0;
    border-radius: 50%;
    background: #cbd5e1;
}
.tts-device-row.online .tts-device-dot { background: #10b981; }
.tts-device-row.working .tts-device-dot { animation: tts-pulse 1s infinite; }
.tts-device-name { font-weight: 600; min-width: 0; }
.tts-gpu.gpu-nvidia { background: #dcfce7; color: #166534; border-color: #86efac; }
.tts-gpu.gpu-mps    { background: #e0e7ff; color: #3730a3; border-color: #a5b4fc; }
.tts-gpu.gpu-cpu    { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }
.tts-device-primary {
    font-size: 10px; font-weight: 800;
    text-transform: uppercase; letter-spacing: .05em;
    color: var(--brand-700, var(--brand-500));
}
.tts-device-state { margin-inline-start: auto; font-size: 12px; color: var(--text-soft); }
.tts-device-state.ok { color: #047857; }
.tts-device-state.working { color: #047857; font-weight: 700; }
.tts-device-state.off { color: #b91c1c; }
.tts-device-jobs { display: flex; flex-direction: column; gap: 8px; }
.tts-device-job {
    display: flex; flex-direction: column; gap: 6px;
    padding: 8px 10px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
}
.tts-device-job-head { display: flex; align-items: center; gap: 8px; }
.tts-device-job-label { font-size: 13px; font-weight: 600; min-width: 0; }
.tts-device-actions { display: flex; flex-wrap: wrap; gap: 8px; }

@media (max-width: 720px) {
    .tts-panel-head { align-items: flex-start; flex-direction: column; }
    .tts-panel-title, .tts-panel-coverage { width: 100%; flex-wrap: wrap; }
    .tts-panel-coverage .tts-generate-changed { min-height: 44px; margin-inline-start: auto; }
    .tts-mini-bar { flex: 1 1 90px; }
}

/* ─── Creator-level synthesis queue ──────────────────────────────── */
.tts-queue-toolbar {
    position: sticky;
    top: 64px;
    z-index: 8;
    display: flex;
    justify-content: flex-end;
    padding: 10px 18px;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
    backdrop-filter: blur(12px);
}
.tts-queue-trigger { position: relative; box-shadow: var(--shadow-xs); }
.tts-queue-trigger.active { border-color: #6ee7b7; background: #ecfdf5; color: #065f46; }
.tts-queue-count {
    display: inline-grid;
    min-width: 18px;
    height: 18px;
    place-items: center;
    padding: 0 4px;
    border-radius: var(--r-full);
    background: #047857;
    color: white;
    font-size: 11px;
    font-weight: 800;
}
.tts-queue-paused { font-size: 11px; font-weight: 800; color: #92400e; }
.tts-queue-dialog {
    width: min(760px, calc(100vw - 32px));
    max-width: 760px;
    max-height: min(760px, calc(100vh - 32px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border);
}
.tts-queue-dialog-head, .tts-queue-dialog-actions, .tts-queue-job-actions, .tts-queue-job-title, .tts-queue-job-names { display: flex; align-items: center; }
.tts-queue-dialog-head { justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.tts-queue-dialog-head .eyebrow { margin-bottom: 4px; }
.tts-queue-dialog-head .modal-title { margin: 0; }
.tts-queue-dialog-actions { flex-shrink: 0; gap: 4px; }
.tts-queue-dialog-actions .btn { min-width: 44px; min-height: 44px; }
.tts-queue-close { border-radius: var(--r-full); }
.tts-queue-list { display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow: auto; padding-inline-end: 3px; }
.tts-queue-job {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 18px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: color-mix(in srgb, var(--bg-elev-2) 74%, var(--bg-elev));
}
.tts-queue-job > .rail-drag-handle { grid-column: 3; grid-row: 1; width: 44px; min-width: 44px; }
.tts-queue-job > .rail-drag-handle:disabled { cursor: default; opacity: .35; }
.tts-queue-job.is-dragging { position: relative; z-index: 20; user-select: none; box-shadow: var(--shadow-lg); }
.tts-queue-priority-hint { margin: 0 0 12px; }
.tts-queue-job.running { border-inline-start: 3px solid #10b981; }
.tts-queue-job.paused { border-color: #fcd34d; background: rgba(245, 158, 11, .10); }
.tts-queue-job-main { min-width: 0; flex: 1; }
.tts-queue-job-title { gap: 10px; min-width: 0; }
.tts-queue-job-names { min-width: 0; gap: 8px; flex: 1; }
.tts-queue-job-names strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tts-queue-separator { color: var(--text-mute); }
.tts-queue-status {
    flex-shrink: 0;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--r-full);
    color: var(--text-soft);
    font-size: 11px;
    font-weight: 800;
}
.tts-queue-status.running { border-color: color-mix(in srgb, #10b981 35%, var(--border)); color: #047857; }
.tts-queue-status.paused { border-color: color-mix(in srgb, #f59e0b 40%, var(--border)); color: #92400e; }
[data-theme="dark"] .tts-queue-status.running { color: #6ee7b7; }
[data-theme="dark"] .tts-queue-status.paused { color: #fcd34d; }
.tts-queue-job-id { margin: 7px 0 12px; font-family: var(--font-mono); }
.tts-queue-progress-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 7px; color: var(--text-soft); font-size: 12px; }
.tts-queue-progress-meta strong { color: var(--text); font-family: var(--font-mono); font-size: 12px; }
.tts-queue-job-actions { flex-direction: column; align-self: center; gap: 7px; }
.tts-queue-job-action { width: 142px; min-height: 38px; }
.tts-queue-error { margin: 0 0 12px; color: #991b1b; font-size: 13px; }
.tts-queue-empty { min-height: 160px; }
.tts-queue-device {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    margin-bottom: 14px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: color-mix(in srgb, var(--bg-elev-2) 74%, var(--bg-elev));
    color: var(--text);
    font-size: 13px;
}
/* State is carried by the dot + a faint border tint; never a light background. */
.tts-queue-device.online { border-color: color-mix(in srgb, #10b981 35%, var(--border)); }
.tts-queue-device.offline { border-color: color-mix(in srgb, #f87171 35%, var(--border)); }
.tts-queue-device.online .tts-device-dot { background: #10b981; }
.tts-queue-device.offline .tts-device-dot { background: #f87171; }
.tts-queue-device.working .tts-device-dot { animation: tts-pulse 1s infinite; }
.tts-queue-device-copy { min-width: 0; display: flex; align-items: baseline; gap: 9px; }
.tts-queue-device-label { flex-shrink: 0; color: var(--text-soft); font-size: 12px; font-weight: 700; }
.tts-queue-device-name { min-width: 0; max-width: 240px; color: var(--text); font-size: 14px; font-weight: 700; }
.tts-queue-device-more { grid-column: 2 / -1; grid-row: 2; }
.tts-queue-device-state { padding-inline-start: 4px; font-size: 12px; color: var(--text-soft); white-space: nowrap; }
.tts-queue-device-state.ok { color: #047857; }
.tts-queue-device-state.working { color: #047857; font-weight: 700; }
.tts-queue-device-state.off { color: #b91c1c; }
[data-theme="dark"] .tts-queue-device-state.ok,
[data-theme="dark"] .tts-queue-device-state.working { color: #6ee7b7; }
[data-theme="dark"] .tts-queue-device-state.off { color: #fca5a5; }
.tts-queue-device-hint { grid-column: 2 / -1; }

/* ─── TTS audio browser ────────────────────────────────────────────
   Per-question playback inside the admin panel. Each question is a
   collapsible row that expands to show its segments. Active playback
   (whether of a single segment or "play all") is reflected with a
   subtle highlight + animated play button. */
.tts-audio-browser {
    margin-top: 8px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--bg-elev-2);
    overflow: hidden;
}
.tts-audio-browser > summary {
    list-style: none;
    cursor: pointer;
    padding: 10px 14px;
    display: flex; align-items: center; gap: 10px;
    background: linear-gradient(180deg, transparent, rgba(0,0,0,.02));
    border-bottom: 1px solid transparent;
}
.tts-audio-browser > summary::-webkit-details-marker { display: none; }
.tts-audio-browser[open] > summary { border-bottom-color: var(--border); }
.tts-audio-browser > summary:hover { background: rgba(0,0,0,.03); }
.tts-browser-icon { font-size: 16px; }
.tts-browser-list {
    max-height: 480px;
    overflow-y: auto;
    padding: 4px;
}

/* Question row */
.tts-question-row {
    background: var(--bg-elev);
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    margin: 4px;
    transition: border-color .15s, background .15s;
}
.tts-question-row.active {
    border-color: var(--brand-500);
    background: var(--brand-50);
}
[data-theme="dark"] .tts-question-row.active {
    border-color: #d4d4d8;
    background: #18181b;
}
.tts-question-row.incomplete .tts-question-num { opacity: .5; }
.tts-question-head {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    user-select: none;
}
.tts-question-head:hover { background: rgba(0,0,0,.02); }
.tts-question-num {
    min-width: 36px;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 12px;
    color: #1d4ed8;
    background: #dbeafe;
    border-radius: var(--r-sm);
    padding: 2px 6px;
    text-align: center;
}
.tts-question-row.active .tts-question-num {
    background: #2563eb;
    color: #fff;
}
[data-theme="dark"] .tts-question-num {
    color: #bfdbfe;
    background: #1e3a8a;
}
[data-theme="dark"] .tts-question-row.active .tts-question-num {
    color: #0f172a;
    background: #bfdbfe;
}
.tts-question-type {
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--bg-elev-2);
    color: var(--text-soft);
}
.tts-question-preview {
    flex: 1;
    font-size: 13px;
    color: var(--text);
    line-height: 1.4;
}
.tts-row-actions {
    display: flex; align-items: center; gap: 8px;
    flex-shrink: 0;
}
.tts-question-chevron {
    color: var(--text-soft);
    font-size: 11px;
    width: 14px;
    text-align: center;
}

/* Play / stop buttons — square-ish pill with a single glyph */
.tts-play-btn {
    display: inline-flex; align-items: center; gap: 4px;
    border: 1px solid var(--border);
    background: var(--bg-elev);
    color: var(--brand-700);
    border-radius: var(--r-full);
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background .12s, border-color .12s, transform .08s;
}
.tts-play-btn:hover:not(:disabled) {
    background: var(--brand-50);
    border-color: var(--brand-500);
}
.tts-play-btn:active:not(:disabled) { transform: scale(.96); }
.tts-play-btn:disabled {
    opacity: .35;
    cursor: not-allowed;
}
.tts-play-btn.small { padding: 2px 8px; font-size: 11px; }
.tts-regenerate-btn {
    color: var(--text-soft);
    background: var(--bg-elev-2);
}
.tts-regenerate-btn:hover:not(:disabled) {
    color: var(--text);
    border-color: var(--border-strong);
}
.tts-play-btn.stop {
    background: #fee2e2;
    color: #b91c1c;
    border-color: #fca5a5;
    animation: tts-pulse-soft 1s ease-in-out infinite;
}
@keyframes tts-pulse-soft {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, .35); }
    50%      { box-shadow: 0 0 0 4px rgba(220, 38, 38, 0); }
}

/* Segment list inside an expanded question */
.tts-segment-list {
    padding: 4px 12px 10px 36px;
    display: flex; flex-direction: column; gap: 4px;
    border-top: 1px dashed var(--border);
}
.tts-segment-row {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 8px;
    border-radius: var(--r-sm);
    transition: background .12s;
}
.tts-segment-row:hover { background: rgba(0,0,0,.025); }
.tts-segment-row.active {
    background: var(--brand-50);
}
.tts-segment-row.incomplete .tts-segment-text {
    opacity: .55;
    text-decoration: line-through dashed var(--text-soft);
}
.tts-segment-id {
    min-width: 100px;
    text-align: center;
    background: var(--bg-elev-2);
    color: var(--text-soft);
    text-transform: none !important;
    letter-spacing: 0 !important;
    font-weight: 600;
    flex-shrink: 0;
}
.tts-segment-text {
    flex: 1;
    font-size: 13.5px;
    color: var(--text);
    line-height: 1.5;
    /* Allow wrapping on long prompts, but keep single line wrap-friendly */
    word-break: break-word;
}

/* ─── Segmented control (bank type / weighting) ──────────────────── */
.seg { display: inline-flex; gap: 4px; background: var(--bg-elev-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 3px; flex-wrap: wrap; max-width: 100%; }
.seg-btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 0; background: transparent; color: var(--text-soft); border-radius: calc(var(--r-md) - 2px); cursor: pointer; font-weight: 600; font-size: 13px; }
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--brand-500); color: var(--on-brand); }

/* ─── Composite-exam builder (Midterm / Final) ───────────────────── */
.bank-identity-fields { display: grid; gap: 0; }
.exam-builder { margin: 14px 0; border: 1px solid var(--border); border-radius: var(--r-md); padding: 14px; background: var(--bg-elev); }
.exam-builder-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-weight: 700; font-size: 14px; margin-bottom: 12px; color: var(--text); }
.exam-controls { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 12px; margin-bottom: 14px; }
.exam-controls .field { min-width: 0; margin: 0; }
.exam-total-control { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.exam-total-control .input { min-width: 0; }
.exam-weight-seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
.exam-weight-seg .seg-btn { justify-content: center; min-width: 0; padding-inline: 8px; }
.exam-source-heading { margin: 2px 0 8px; color: var(--text-soft); font-size: 12px; font-weight: 800; }
.exam-sources { display: flex; flex-direction: column; gap: 6px; }
.exam-source { display: flex; align-items: center; gap: 10px; width: 100%; text-align: start; padding: 9px 11px; border: 1px solid var(--border); background: var(--bg-elev-2); border-radius: var(--r-md); color: var(--text); }
.exam-source:hover:not(.disabled) { border-color: var(--border-strong); }
.exam-source.active { border-color: var(--brand-500); background: var(--brand-50); }
.exam-source.disabled { opacity: .5; }
.exam-source-main { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; padding: 0; border: 0; background: transparent; color: inherit; cursor: pointer; font: inherit; text-align: start; }
.exam-source-main:disabled { cursor: not-allowed; }
.exam-check { width: 18px; height: 18px; border: 1.5px solid var(--border-strong); border-radius: 5px; display: grid; place-items: center; flex: none; color: var(--on-brand); }
.exam-check.on { background: var(--brand-500); border-color: var(--brand-500); }
.exam-source-title { font-weight: 600; font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exam-take { color: var(--brand-700); font-weight: 700; font-size: 13px; min-width: 40px; text-align: end; }
.exam-pct { display: inline-flex; align-items: center; gap: 3px; color: var(--text-soft); font-size: 13px; }
.exam-pct .input { width: 58px; padding: 6px 8px; text-align: end; }
.exam-preview { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.exam-note { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-soft); }
.exam-note.warn { color: var(--warn); }

/* Chips carry an optional leading icon (bank type) — keep icon + label inline. */
.chip { display: inline-flex; align-items: center; gap: 5px; }

/* Exam builder + segmented controls on small screens. */
@media (max-width: 600px) {
    .seg { width: 100%; }
    .seg-btn { flex: 1 1 auto; justify-content: center; }
    .bank-editor-modal {
        max-height: calc(100dvh - 8px);
        padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
        scroll-padding-block: 14px 84px;
    }
    .bank-type-seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .bank-type-seg .seg-btn { min-height: 52px; flex-direction: column; gap: 4px; padding: 7px 5px; }
    .bank-editor-modal .modal-actions { z-index: 4; border-top: 1px solid var(--border); }
    .exam-builder { padding: 13px; border-radius: var(--r-lg); background: var(--bg-elev-2); }
    .exam-builder-head > .muted { width: 100%; margin-inline-start: 23px !important; }
    .exam-controls { grid-template-columns: 1fr; gap: 11px; }
    .exam-source {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 7px 9px;
        min-height: 52px;
        padding: 10px;
    }
    .exam-source-main { min-height: 30px; }
    .exam-pct { grid-column: 1 / 3; justify-self: end; }
    .exam-take { grid-column: 2; }
    .exam-pct .input { width: 52px; }
    .modal .field .seg { width: 100%; }
}

/* Moderator tab buttons carry a leading icon. */
.tab-btn { display: inline-flex; align-items: center; gap: 6px; }

/* Final admin responsive overrides live after the base rules so they actually win. */
@media (max-width: 900px) {
    .admin-nav .top-nav-inner {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 12px 14px;
        padding: 14px 18px;
    }
    .admin-nav .brand {
        min-width: 0;
    }
    .admin-nav .top-nav-right {
        justify-self: end;
        gap: 7px;
    }
    .admin-nav .top-nav-links {
        grid-column: 1 / -1;
        order: initial;
        width: auto;
        justify-content: center;
        flex-wrap: wrap;
        gap: 8px;
    }
    .admin-phone-pill {
        max-width: 148px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .creator-layout {
        display: block;
        min-height: auto;
    }
    .creator-rail {
        position: static;
        top: auto;
        max-height: none;
        overflow: visible;
        border-inline-end: 0;
        border-bottom: 1px solid var(--border);
        padding: 18px 16px;
    }
    .creator-rail > div {
        display: flex;
        gap: 10px;
        overflow-x: auto;
        padding-bottom: 4px;
        scroll-snap-type: x proximity;
    }
    .rail-h {
        margin-bottom: 10px;
        padding-inline-start: 0;
    }
    .rail-item {
        width: auto;
        min-width: 210px;
        max-width: 260px;
        flex: 0 0 auto;
        margin-bottom: 0;
        scroll-snap-align: start;
    }
    .rail-add {
        min-width: 210px;
        margin-top: 0;
    }
    .creator-main {
        display: block;
    }
    .creator-content { display: block; }
    .creator-pane {
        padding: 22px 18px;
    }
    .creator-pane-chapter {
        min-height: 220px;
    }
}

@media (max-width: 640px) {
    .tts-queue-toolbar { top: 0; padding: 8px 14px; }
    .tts-queue-trigger { width: 100%; justify-content: center; }
    .tts-queue-dialog { width: min(100vw - 20px, 760px); padding: 18px; }
    .tts-queue-dialog-head { align-items: flex-start; margin-bottom: 16px; }
    .tts-queue-dialog-actions { gap: 2px; }
    .tts-queue-dialog-actions .btn { padding-inline: 10px; }
    .tts-queue-action-label { display: none; }
    .tts-queue-device { grid-template-columns: auto minmax(0, 1fr) auto; }
    .tts-queue-device-copy { align-items: flex-start; flex-direction: column; gap: 2px; }
    .tts-queue-device-name { max-width: none; }
    .tts-queue-device-state { grid-column: 2 / -1; justify-self: start; padding: 0; }
    .tts-queue-device-more { grid-column: 2 / -1; grid-row: auto; }
    .tts-queue-device-hint { grid-column: 2 / -1; }
    .tts-queue-job { grid-template-columns: minmax(0, 1fr) auto; align-items: stretch; gap: 14px; }
    .tts-queue-job > .rail-drag-handle { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
    .tts-queue-job-actions { grid-column: 1; }
    .tts-queue-job-names { flex-wrap: wrap; row-gap: 2px; }
    .tts-queue-job-names strong { white-space: normal; }
    .tts-queue-status { margin-inline-start: auto; }
    .tts-queue-job-actions { flex-direction: row; align-self: stretch; }
    .tts-queue-job-action { flex: 1; width: auto; min-height: 44px; }
}

@media (max-width: 720px) {
    .admin-nav .top-nav-inner {
        grid-template-columns: 1fr auto;
        padding: 14px 16px;
    }
    .admin-nav .brand-mark {
        width: 34px;
        height: 34px;
    }
    .admin-nav .brand-name {
        font-size: 17px;
    }
    .admin-nav .top-nav-right .icon-btn {
        width: 36px;
        height: 36px;
    }
    .admin-nav .top-nav-links {
        padding-top: 2px;
    }
    .admin-page {
        padding: 28px 18px 64px;
    }
    .admin-page .page-title {
        font-size: 34px;
    }
    .admin-page .tab-bar {
        justify-content: stretch;
        gap: 0;
    }
    .admin-page .tab-btn {
        flex: 1 1 0;
        justify-content: center;
        padding: 12px 8px;
    }
    .admin-page .toolbar {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .admin-page .toolbar .btn {
        width: 100%;
    }
    .row-card-head {
        align-items: stretch;
        flex-direction: column;
    }
    .log-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .log-time {
        grid-column: auto;
        text-align: start;
    }
}

@media (max-width: 520px) {
    .admin-nav .top-nav-inner {
        grid-template-columns: minmax(0, 1fr) auto;
    }
    .admin-nav .brand {
        grid-column: 1;
        grid-row: 1;
        justify-self: start;
        justify-content: flex-start;
    }
    .admin-nav .top-nav-right {
        grid-column: 2;
        grid-row: 1;
        justify-self: end;
        justify-content: flex-end;
    }
    .admin-nav .top-nav-links {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-self: stretch;
        justify-content: center;
    }
    .admin-phone-pill {
        max-width: 132px;
    }
    .rail-item,
    .rail-add {
        min-width: 0;
        max-width: none;
    }
    .creator-pane {
        padding: 18px 14px;
    }
    .subject-banner {
        height: 150px;
    }
    .subject-banner-actions {
        flex-wrap: wrap;
        max-width: calc(100% - 24px);
    }
    .price-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    .q-row {
        align-items: stretch;
        flex-wrap: wrap;
    }
    .q-row-text {
        flex-basis: 100%;
        white-space: normal;
    }
}

/* Phone-sized admin workspaces: use horizontal rails and card-like controls
   instead of squeezing desktop controls into narrow columns. */
.chapter-pane-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.chapter-pane-copy { min-width: 0; }
.chapter-pane-hint { max-width: 62ch; margin: 5px 0 0; }
.chapter-pane-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.original-files-dropzone {
    display: grid;
    width: 100%;
    font: inherit;
    justify-items: center;
    gap: 7px;
    margin-top: 16px;
    padding: 26px 18px;
    border: 2px dashed var(--border);
    border-radius: var(--r-lg);
    background: var(--bg-elev-2);
    color: var(--text-mute);
    text-align: center;
    cursor: pointer;
    transition: border-color .18s ease, background-color .18s ease, color .18s ease, transform .18s ease;
}
.original-files-dropzone:hover,
.original-files-dropzone:focus-visible,
.original-files-dropzone.dragging {
    border-color: var(--brand-500);
    background: color-mix(in srgb, var(--brand-500) 9%, var(--bg-elev));
    color: var(--brand-600);
    outline: none;
}
.original-files-dropzone.dragging { transform: scale(1.01); }
.original-files-dropzone:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.original-files-dropzone.disabled { cursor: wait; opacity: .65; }
.original-files-drop-title { margin: 2px 0 0; color: var(--text); font-weight: 800; }
.original-files-dropzone p { margin-block: 0; }
.original-files-selection { margin: 8px 2px 0; }

.extra-check-modal {
    width: min(1400px, calc(100vw - 32px));
    max-width: 1400px;
    height: min(860px, calc(100vh - 32px));
    max-height: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.extra-check-head,
.extra-check-pane-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.extra-check-head { margin-bottom: 14px; }
.extra-check-head .modal-title,
.extra-check-head p,
.extra-check-pane-head h3 { margin-block: 0; }
.extra-check-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 14px;
    min-height: 0;
    flex: 1;
    direction: ltr;
}
.extra-check-pane {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
    min-height: 0;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--bg-elev-2);
    direction: initial;
}
[dir="rtl"] .extra-check-pane { direction: rtl; }
.extra-check-preview {
    min-height: 0;
    flex: 1;
    overflow: auto;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--bg-elev);
}
.extra-check-preview.is-pdf {
    overflow: hidden;
    place-items: stretch;
}
.extra-check-answers {
    min-height: 0;
    flex: 1;
    margin: 0;
    padding: 0 4px;
    overflow: auto;
    list-style: none;
    counter-reset: none;
}
.extra-check-answer {
    margin-bottom: 10px;
    padding: 13px 14px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--bg-elev);
}
.extra-check-answer-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.extra-check-answer-editor {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 38px;
    margin-top: 9px;
}
.extra-check-answer-editor label { color: var(--muted); font-size: 12px; font-weight: 700; }
.extra-check-answer-select { width: 76px; min-height: 36px; padding-block: 5px; font-weight: 800; }
.extra-check-answer-saved { color: var(--ok); font-size: 12px; font-weight: 700; }
.extra-check-answer ul { margin: 9px 0 0; padding-inline-start: 22px; }
.extra-check-answer li { margin-block: 4px; line-height: 1.55; overflow-wrap: anywhere; }
.extra-check-answer p { margin: 9px 0 0; }
.pdf-answer-sheet {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    height: 100%;
}
.pdf-answer-sheet-controls {
    display: flex;
    align-items: end;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elev-2);
    flex-wrap: wrap;
}
.pdf-answer-sheet-controls > strong { align-self: center; margin-inline-end: auto; }
.pdf-answer-sheet-controls label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.pdf-answer-sheet-controls .input { width: 76px; min-height: 34px; padding: 5px 8px; }
.pdf-answer-sheet-pages {
    min-height: 0;
    flex: 1;
    overflow: auto;
    padding: 14px;
    background: #2f3136;
}
.pdf-answer-sheet-page {
    width: fit-content;
    max-width: 100%;
    margin: 0 auto 16px;
}
.pdf-answer-sheet-page:last-child { margin-bottom: 0; }
.pdf-answer-sheet-page figcaption {
    margin-bottom: 6px;
    color: #fff;
    font-size: 12px;
    text-align: center;
}
.pdf-answer-sheet-page-frame {
    display: grid;
    place-items: center;
    width: min(100%, 918px);
    max-width: 100%;
    min-height: 220px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 5px 18px rgb(0 0 0 / 30%);
}
.pdf-answer-sheet-page canvas {
    display: block;
    width: 100%;
    height: auto;
    direction: ltr;
}
.extra-check-media { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
.extra-check-audio { width: min(480px, calc(100% - 24px)); }
.extra-check-text-view {
    display: flex;
    flex: 1;
    min-width: 0;
    min-height: 0;
    flex-direction: column;
    align-self: stretch;
    justify-self: stretch;
}
.extra-check-text-encoding {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-size: 12px;
}
.extra-check-text-encoding .select { width: auto; min-height: 34px; padding-block: 5px; }
.extra-check-text {
    align-self: stretch;
    justify-self: stretch;
    min-width: 100%;
    min-height: 0;
    flex: 1;
    margin: 0;
    padding: 16px;
    overflow: auto;
    color: var(--text);
    font: 13px/1.7 "JetBrains Mono", "Cairo", ui-monospace, "SFMono-Regular", monospace;
    text-align: start;
    unicode-bidi: plaintext;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.extra-check-empty { align-self: stretch; justify-self: stretch; }

@media (prefers-reduced-motion: reduce) {
    .original-files-dropzone { transition: none; }
}

@media (max-width: 720px) {
    .admin-nav .top-nav-inner {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 10px 12px;
        padding: 11px 14px 12px;
    }
    .admin-nav .top-nav-links {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 4px;
        padding: 4px;
        border: 1px solid var(--border);
        border-radius: var(--r-md);
        background: var(--bg-elev-2);
    }
    .admin-nav .top-nav-link {
        justify-content: center;
        padding: 9px 8px;
        text-align: center;
    }
    .admin-nav .top-nav-link.active { background: var(--bg-elev); box-shadow: var(--shadow-xs); }

    .admin-page { padding: 22px 14px 52px; }
    .admin-page .page-head { margin-bottom: 18px; padding: 0 2px; }
    .admin-page .page-title { font-size: 28px; letter-spacing: -.03em; }
    .admin-page .tab-bar {
        justify-content: flex-start;
        gap: 8px;
        margin: 0 -14px 18px;
        padding: 0 14px 6px;
        border: 0;
        scrollbar-width: none;
    }
    .admin-page .tab-bar::-webkit-scrollbar { display: none; }
    .admin-page .tab-btn {
        flex: 0 0 auto;
        min-height: 42px;
        padding: 9px 13px;
        border: 1px solid var(--border);
        border-radius: var(--r-full);
        background: var(--bg-elev);
    }
    .admin-page .tab-btn.active { border-color: var(--brand-500); background: var(--brand-500); color: var(--on-brand); }
    .row-card { padding: 15px 16px; border-radius: var(--r-md); }
    .row-card-head .btn { align-self: flex-start; }

    .creator-rail {
        padding: 15px 14px 13px;
        background: var(--bg-elev);
        box-shadow: 0 8px 18px rgba(9, 9, 11, .035);
    }
    .creator-rail > div {
        gap: 8px;
        padding: 0 1px 4px;
        scroll-padding-inline: 14px;
    }
    .rail-item { min-height: 64px; padding: 10px; border-color: var(--border); background: var(--bg-elev); }
    .rail-item.active { box-shadow: var(--shadow-xs); }
    .rail-add { background: var(--bg-elev-2); }
    .creator-pane { padding: 22px 14px; }
    .creator-pane-chapter { padding-top: 24px; }
    .subject-banner { height: 174px; margin-bottom: 22px; border-radius: 20px; }
    .subject-banner-overlay { padding: 18px; }
    .subject-banner-overlay h2 { max-width: 82%; font-size: 23px !important; line-height: 1.25; }
    .subject-banner-actions { top: 12px; inset-inline-end: 12px; }
    .chip-row { flex-wrap: nowrap; overflow-x: auto; padding: 7px; border-radius: var(--r-lg); scrollbar-width: none; }
    .chip-row::-webkit-scrollbar { display: none; }
    .chip { flex: 0 0 auto; min-height: 38px; white-space: nowrap; }
    .chapter-pane-head {
        align-items: stretch;
        flex-direction: column;
        gap: 12px;
        padding: 14px;
        border: 1px solid var(--border);
        border-radius: var(--r-lg);
        background: var(--bg-elev);
        box-shadow: var(--shadow-xs);
    }
    .chapter-pane-copy { padding-inline: 2px; }
    .chapter-pane-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .chapter-pane-actions .btn { width: 100%; min-height: 46px; white-space: normal; }
    .chapter-pane-actions > .btn:nth-child(5) { grid-column: 1 / -1; }
    .q-row { min-height: 52px; padding: 12px; }
    .extra-check-modal {
        width: 100%;
        height: calc(100vh - 12px);
        height: calc(100dvh - 12px);
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    }
    .extra-check-grid { grid-template-columns: 1fr; overflow-y: auto; }
    .extra-check-pane { min-height: 520px; }
}

@media (max-width: 600px) {
    .price-table { display: block; overflow: visible; border: 0; background: transparent; margin-top: 8px; white-space: normal; }
    .price-table thead { display: none; }
    .price-table tbody { display: grid; gap: 8px; }
    .price-table tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 10px 14px;
        padding: 14px;
        border: 1px solid var(--border);
        border-radius: var(--r-md);
        background: var(--bg-elev);
        box-shadow: var(--shadow-xs);
    }
    .price-table td { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0; border: 0; text-align: start; }
    .price-table td:first-child { grid-column: 1 / -1; font-weight: 800; }
    .price-table td:not(:first-child)::before { content: attr(data-label); color: var(--text-mute); font-size: 12px; font-weight: 700; }
    .price-table td:nth-child(3) { grid-column: 1 / -1; }
    .price-table td:nth-child(3) .input { width: 100% !important; }
    .chapter-action-cell { width: auto; }
    .chapter-action-cell .btn { min-width: 38px; min-height: 38px; }
}
.course-lookup-ok { color: var(--success, #16803c); margin: 6px 0 0; }
.course-lookup-error { color: var(--danger, #c62828); margin: 6px 0 0; }
.course-lookup-scopes { display: flex; flex-wrap: wrap; gap: 8px; }
.course-lookup-scopes .chip { cursor: default; }

/* Subject ordering always follows one vertical column, including phones. */
.creator-rail .rail-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: visible;
    scroll-snap-type: none;
    padding: 0;
}
.creator-rail .rail-row { position: relative; min-width: 0; flex: 0 0 auto; }
.creator-rail .rail-item { width: 100%; min-width: 0; max-width: none; }
.creator-rail .rail-thumb { width: 40px; height: 40px; }
.creator-rail .rail-add { margin-top: 8px; min-height: 48px; }
.rail-row.is-dragging { user-select: none; }
.rail-row.is-dragging .rail-drag-handle { cursor: grabbing; }
@media (max-width: 900px) {
    .creator-rail.is-compact { max-height: 320px; overflow-y: auto; }
    .creator-rail .ellipsis { white-space: normal; overflow-wrap: anywhere; }
    .rail-drag-handle { width: 44px; min-width: 44px; }
}

/* The bank carousel may scroll, but its create action never does. */
.admin-bank-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: stretch;
    gap: 8px;
}
.admin-bank-controls .chip-row { min-width: 0; }
.admin-new-bank-btn { min-height: 42px; white-space: nowrap; }

/* TTS is an English technical control surface even inside the Arabic admin.
   Pinning it to LTR prevents punctuation and device metadata from reversing. */
.tts-panel {
    direction: ltr;
    text-align: left;
}
.tts-panel-toggle {
    display: flex;
    align-items: center;
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.tts-panel-toggle:focus-visible {
    outline: 2px solid var(--brand-500);
    outline-offset: 4px;
    border-radius: var(--r-sm);
}
.tts-panel-title { min-width: 0; flex-wrap: wrap; }
.tts-panel.is-expanded .tts-panel-head { justify-content: flex-start; }
.tts-coverage-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
    gap: 8px;
}
.tts-cov-stat {
    min-width: 0;
    align-items: center;
    padding: 11px 10px;
    text-align: center;
}
.tts-runtime-line { align-items: flex-start; line-height: 1.55; }

@media (max-width: 720px) {
    .admin-bank-controls { grid-template-columns: minmax(0, 1fr); }
    .admin-bank-controls .chip-row {
        flex-wrap: nowrap;
        overflow-x: auto;
    }
    .admin-new-bank-btn {
        width: 100%;
        min-height: 46px;
        justify-content: center;
        border-style: dashed;
    }

    .tts-panel { margin-top: 14px; border-radius: 18px; }
    .tts-panel-head { gap: 12px; padding: 14px; }
    .tts-panel-toggle { width: 100%; min-height: 30px; }
    .tts-panel-title { gap: 8px; }
    .tts-panel-coverage {
        display: grid;
        grid-template-columns: auto minmax(72px, 1fr);
        align-items: center;
        gap: 9px;
    }
    .tts-panel-coverage .tts-mini-bar { width: auto; }
    .tts-panel-coverage .tts-generate-changed {
        grid-column: 1 / -1;
        width: 100%;
        min-height: 46px;
        margin: 0;
        justify-content: center;
    }
    .tts-panel-body { gap: 12px; padding: 14px; }
    .tts-coverage-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tts-coverage-stats .tts-cov-stat:nth-child(3) { grid-column: 1 / -1; }
    .tts-action-row { display: grid; grid-template-columns: minmax(0, 1fr); }
    .tts-action-row .btn { width: 100%; min-height: 46px; justify-content: center; }
    .tts-devices-section { gap: 12px; padding: 13px; }
    .tts-devices-head {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        align-items: center;
    }
    .tts-devices-head .muted {
        grid-column: 2;
        margin: 0;
        line-height: 1.45;
    }
    .tts-device-row {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        gap: 7px 9px;
        padding: 11px;
    }
    .tts-device-row .tts-device-dot { grid-column: 1; grid-row: 1; }
    .tts-device-row .tts-device-name { grid-column: 2; grid-row: 1; }
    .tts-device-row .tts-device-state {
        grid-column: 3;
        grid-row: 1;
        margin: 0;
    }
    .tts-device-row .tts-gpu {
        grid-column: 2;
        grid-row: 2;
        justify-self: start;
    }
    .tts-device-row .tts-device-primary {
        grid-column: 3;
        grid-row: 2;
        align-self: center;
    }
}

/* Learning: quiet data rows with rings for individual completion. */
.learning-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.learning-heading h2, .learning-heading p { margin: 0 0 8px; }
.learning-heading > div, .learning-heading > span { min-width: 0; }
.learning-heading strong, .learning-title strong { overflow-wrap: anywhere; }
.learning-filter { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-weight: 600; }
.learning-filter .input { width: auto; max-width: 100%; min-width: 150px; }
.learning-status { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-block: 12px; }
.learning-status p { margin: 0; }
.learning-method { color: var(--text-mute); margin-block: 16px 24px; font-size: .875rem; }
.learning-method p { max-width: 90ch; line-height: 1.8; }
.learning-panel summary, .student-learning summary { cursor: pointer; list-style: none; }
.learning-panel summary::-webkit-details-marker, .student-learning summary::-webkit-details-marker { display: none; }
.learning-panel summary:focus-visible, .student-learning summary:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 3px; border-radius: 8px; }
.learning-panel summary svg, .student-learning summary > svg { flex-shrink: 0; }
.student-learning details[open] > summary > svg { transform: rotate(180deg); }
.learning-metrics { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; margin: 20px 0 0; }
.learning-metrics dt { font-size: .8rem; color: var(--text-mute); margin-bottom: 6px; }
.learning-metrics dd { margin: 0; font-size: 1.25rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.learning-set-body { padding-block: 4px 20px; }
.learning-table-wrap { overflow-x: auto; }
.learning-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.learning-table caption { text-align: start; padding-block: 12px; font-weight: 600; }
.learning-table th, .learning-table td { text-align: start; padding: 12px 8px; border-bottom: 1px solid var(--border); }
.learning-table thead { color: var(--text-mute); font-size: .85rem; }
.learning-open { margin-block: 12px 0; }
.student-learning { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 8px; }
.learning-subject + .learning-subject, .learning-set + .learning-set { border-top: 1px solid var(--border); }
.learning-summary { display: flex; gap: 14px; align-items: center; padding-block: 16px; }
.learning-title { display: grid; gap: 4px; min-width: 0; flex: 1; }
.learning-result { font-size: .875rem; color: var(--text-mute); }
.learning-ring { position: relative; width: 4.25rem; height: 4.25rem; flex-shrink: 0; display: grid; place-items: center; }
.learning-ring svg { width: 100%; height: 100%; }
.learning-ring > span { position: absolute; font-size: .8rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.learning-sets { margin-inline-start: 32px; padding-inline-start: 18px; border-inline-start: 1px solid var(--border); }
.learning-question-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 8px; }
.learning-question { min-height: 48px; border: 1px solid var(--border); background: var(--bg-elev-2); border-radius: 8px; color: var(--text-mute); font: inherit; display: flex; align-items: center; justify-content: center; gap: 5px; cursor: pointer; }
.learning-question.correct { color: color-mix(in srgb, var(--ok) 75%, var(--text)); border-color: var(--ok); }
.learning-question.incorrect { color: var(--bad); border-color: var(--bad); }
.learning-question.pending, .learning-question.partial, .learning-pending { color: color-mix(in srgb, var(--warn) 75%, var(--text)); }
.learning-question[aria-pressed="true"], .learning-question:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.learning-question-detail { margin-block: 18px; padding: 16px; background: var(--bg-elev-2); border: 1px solid var(--border); border-radius: 10px; overflow-wrap: anywhere; }
.learning-ratio { display: inline-flex; direction: ltr; gap: .2em; align-items: baseline; unicode-bidi: isolate; }
.learning-question-detail pre, .learning-question-detail code { direction: ltr; text-align: left; unicode-bidi: plaintext; }
.learning-question-detail pre { max-width: 100%; overflow-x: auto; white-space: pre-wrap; }
.learning-question-detail img { max-width: 100%; }
@media (max-width: 900px) {
    .learning-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
    .learning-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 12px; }
    .learning-sets { margin-inline-start: 8px; padding-inline-start: 12px; }
    .learning-ring { width: 3.75rem; height: 3.75rem; }
    .learning-summary { gap: 10px; }
    .learning-filter { width: 100%; }
    .learning-filter .input { width: 100%; min-width: 0; }
    .learning-table { font-size: .8rem; }
    .learning-table th, .learning-table td { padding: 10px 5px; }
}

/* Analytics keeps a single subject/set in view; the picker mirrors Creator. */
.website-analytics { margin-top: 22px; padding: 24px; border: 1px solid var(--border); border-radius: var(--r-lg); background: linear-gradient(145deg, color-mix(in srgb, var(--brand-500) 7%, var(--bg-elev)) 0%, var(--bg-elev) 42%); overflow: hidden; }
.website-analytics-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.website-analytics-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 10px; }
.analytics-toggle { display: inline-flex; align-items: center; gap: 6px; min-height: 42px; padding: 8px 13px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-elev-2); color: var(--text-mute); font: inherit; font-size: .78rem; font-weight: 650; cursor: pointer; }
.analytics-toggle:hover { color: var(--text); }
.analytics-toggle:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }
.analytics-toggle svg { transition: transform .2s ease; }
.website-analytics:not(.is-collapsed) .analytics-toggle svg { transform: rotate(180deg); }
.website-analytics-body[hidden] { display: none; }
.website-analytics-head h3, .learning-section-heading h3 { margin: 2px 0 7px; font-size: 1.35rem; }
.website-analytics-head p { margin-block: 0; }
.website-analytics-kicker { margin: 0; color: var(--brand-600); font-size: .72rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.analytics-range { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-elev-2); }
.analytics-range button { min-height: 34px; padding: 6px 11px; border: 0; border-radius: 8px; background: transparent; color: var(--text-mute); font: inherit; font-size: .78rem; font-weight: 650; cursor: pointer; }
.analytics-range button:hover { color: var(--text); }
.analytics-range button.is-active { background: var(--bg-elev); color: var(--text); box-shadow: 0 1px 4px color-mix(in srgb, var(--text) 14%, transparent); }
.analytics-range button:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }
.website-analytics-hosts { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-elev-2); }
.website-analytics-hosts button { min-height: 34px; padding: 6px 11px; border: 0; border-radius: 8px; background: transparent; color: var(--text-mute); font: inherit; font-size: .78rem; font-weight: 650; cursor: pointer; }
.website-analytics-hosts button:hover { color: var(--text); }
.website-analytics-hosts button.is-active { background: var(--bg-elev); color: var(--text); box-shadow: 0 1px 4px color-mix(in srgb, var(--text) 14%, transparent); }
.website-analytics-hosts button:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }
.website-metrics { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; margin: 24px 0; }
.website-metric { position: relative; min-width: 0; min-height: 106px; padding: 15px; border: 1px solid var(--border); border-radius: 14px; background: color-mix(in srgb, var(--bg-elev) 92%, transparent); }
.website-metric-icon { display: grid; place-items: center; width: 30px; height: 30px; margin-bottom: 13px; border-radius: 9px; background: color-mix(in srgb, var(--brand-500) 12%, var(--bg-elev)); color: var(--brand-600); }
.website-metric dt { min-height: 2.4em; color: var(--text-mute); font-size: .72rem; line-height: 1.2; }
.website-metric dd { margin: 5px 0 0; font-size: 1.12rem; font-weight: 720; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.website-metric-detail { display: block; margin-top: 5px; color: var(--text-mute); font-size: .72rem; font-weight: 500; }
.website-analytics-grid { display: grid; grid-template-columns: minmax(240px, .72fr) minmax(420px, 1.28fr); gap: 16px; }
.analytics-trend, .analytics-chapters { min-width: 0; padding: 18px; border: 1px solid var(--border); border-radius: 14px; background: var(--bg-elev); }
.analytics-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.analytics-section-head h4 { margin: 0; font-size: .92rem; }
.analytics-section-head > span { text-align: end; }
.analytics-bars { display: flex; align-items: flex-end; gap: 3px; height: 142px; padding-top: 8px; border-bottom: 1px solid var(--border); background: repeating-linear-gradient(to top, transparent 0 34px, color-mix(in srgb, var(--border) 55%, transparent) 34px 35px); }
.analytics-bar { display: flex; align-items: flex-end; flex: 1; height: 100%; min-width: 2px; padding: 0; border: 0; background: transparent; cursor: pointer; touch-action: manipulation; }
.analytics-bar > span { width: 100%; height: var(--bar-height); min-height: 2px; border-radius: 4px 4px 1px 1px; background: linear-gradient(to top, var(--brand-600), var(--brand-400)); transition: height .25s ease; }
.analytics-bar[aria-pressed="true"] > span { background: #2563eb; }
.analytics-bar:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 1px; }
.analytics-axis { display: flex; justify-content: space-between; padding-top: 8px; color: var(--text-mute); font-size: .7rem; }
.analytics-day-detail { margin-top: 14px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; overflow-wrap: anywhere; }
.analytics-day-detail > strong { font-size: .84rem; }
.analytics-day-detail p { margin: 0; }
.analytics-day-detail dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 12px 0 0; }
.analytics-day-detail dt { color: var(--text-mute); font-size: .72rem; }
.analytics-day-detail dd { margin: 3px 0 0; font-size: .9rem; font-variant-numeric: tabular-nums; }
.analytics-chapter-list { display: grid; gap: 4px; }
.analytics-chapter-row { display: grid; grid-template-columns: minmax(140px, 1.5fr) repeat(4, minmax(60px, .75fr)); align-items: center; gap: 12px; padding: 11px 4px; border-top: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.analytics-chapter-row:first-child { border-top: 0; }
.analytics-chapter-row > span { display: grid; gap: 3px; font-size: .84rem; }
.analytics-chapter-row small { color: var(--text-mute); font-size: .65rem; }
.analytics-chapter-title { min-width: 0; display: grid; gap: 8px; }
.analytics-chapter-title strong { font-size: .84rem; }
.analytics-chapter-track { display: block; width: 100%; height: 3px; overflow: hidden; border-radius: 4px; background: var(--border); }
.analytics-chapter-track > span { display: block; height: 100%; min-width: 2px; border-radius: inherit; background: var(--brand-500); }
.website-analytics-empty { margin: 20px 0; padding: 30px 18px; border: 1px dashed var(--border-strong); border-radius: 14px; text-align: center; color: var(--text-mute); }
.website-analytics-note { margin: 17px 0 0; max-width: 100ch; line-height: 1.6; }
.learning-section-heading { margin-top: 32px; padding-top: 28px; border-top: 1px solid var(--border); }
.learning-section-heading p, .learning-section-heading h3 { margin-inline: 0; }
@media (max-width: 1180px) {
    .website-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .website-analytics-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
    .website-analytics { padding: 18px 14px; }
    .website-analytics-head { display: grid; gap: 16px; }
    .website-analytics-actions { width: 100%; }
    .analytics-toggle { width: 100%; justify-content: center; }
    .website-analytics-hosts { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .website-analytics-hosts button { padding-inline: 4px; }
    .analytics-range { width: 100%; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .analytics-range button { padding-inline: 4px; }
    .website-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .website-metric { min-height: 98px; padding: 13px; }
    .website-metric:last-child { grid-column: 1 / -1; }
    .analytics-chapters { padding: 15px 12px; }
    .analytics-chapter-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 8px; }
    .analytics-chapter-title { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
    .analytics-bar > span { transition: none; }
    .analytics-toggle svg { transition: none; }
}
.learning-thumbnail { width: 48px; height: 48px; flex-shrink: 0; display: grid; place-items: center; overflow: hidden; border-radius: 10px; background: var(--bg-elev-2); color: var(--text-mute); border: 1px solid var(--border); }
.learning-thumbnail img { width: 100%; height: 100%; object-fit: cover; }
.learning-subject-name { display: flex; align-items: center; gap: 10px; }
.learning-subject-name .learning-thumbnail { width: 32px; height: 32px; border-radius: 6px; }
.analytics-refresh { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.analytics-workspace { scroll-margin-top: 80px; display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 24px; align-items: start; margin-top: 24px; }
.analytics-subject-nav { position: sticky; top: 88px; min-width: 0; }
.analytics-nav-title { margin: 0 10px 12px; font-size: .875rem; color: var(--text-mute); font-weight: 500; }
.analytics-subject-picker { display: flex; flex-direction: column; gap: 6px; max-height: calc(100dvh - 160px); overflow-y: auto; padding: 3px; }
.analytics-subject-option { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px; background: transparent; border: 1px solid transparent; border-radius: 12px; text-align: start; font: inherit; color: var(--text); cursor: pointer; }
.analytics-subject-option > span:last-child { display: grid; gap: 4px; min-width: 0; }
.analytics-subject-option strong { font-size: .875rem; overflow-wrap: anywhere; }
.analytics-subject-option[aria-current="true"] { border-color: var(--border-strong); background: var(--bg-elev-2); box-shadow: inset -3px 0 var(--brand-500); }
[dir="ltr"] .analytics-subject-option[aria-current="true"] { box-shadow: inset 3px 0 var(--brand-500); }
.analytics-subject-option:hover { background: var(--bg-elev-2); }
.analytics-picker-toggle { display: none; }
.analytics-detail { min-width: 0; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--bg-elev); }
.analytics-context { position: sticky; top: 64px; z-index: 3; padding: 22px 24px; border-radius: var(--r-lg) var(--r-lg) 0 0; border-bottom: 1px solid var(--border); background: var(--bg-elev); scroll-margin-top: 80px; }
.analytics-context:focus { outline: none; }
.analytics-detail-title { display: flex; align-items: center; gap: 16px; }
.analytics-detail-title > div { min-width: 0; }
.analytics-detail-title .learning-thumbnail { width: 64px; height: 64px; border-radius: 12px; }
.analytics-detail-title h3 { margin: 0; font-size: 1.375rem; overflow-wrap: anywhere; }
.analytics-detail-title p { margin: 5px 0 0; }
.analytics-back { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 0; margin-bottom: 16px; min-height: 32px; background: none; border: 0; color: var(--text); font: inherit; cursor: pointer; text-align: start; }
.analytics-back > span { overflow-wrap: anywhere; }
.analytics-back > svg { flex-shrink: 0; }
.analytics-detail-body { padding: 0 24px 20px; }
.analytics-detail .learning-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; margin-block: 24px; }
.analytics-detail .learning-metrics > div { min-width: 0; }
.analytics-detail .learning-metrics > div:nth-child(-n+3) dd { font-size: 1.875rem; }
.analytics-detail .learning-metrics > div:nth-child(n+4) { padding-top: 16px; border-top: 1px solid var(--border); }
.analytics-detail .learning-metrics > div:nth-child(n+4) dd { font-size: 1rem; }
.analytics-banks { border-top: 1px solid var(--border); padding-top: 20px; }
.analytics-banks h4 { font-size: 1rem; margin: 0 0 18px; }
.analytics-bank-columns, .analytics-bank-row { display: grid; grid-template-columns: minmax(140px, 2fr) repeat(3, minmax(70px, 1fr)) 18px; align-items: center; gap: 16px; }
.analytics-bank-columns { padding: 0 10px 12px; font-size: .75rem; color: var(--text-mute); }
.analytics-bank-row { width: 100%; padding: 18px 10px; background: transparent; border: 0; border-top: 1px solid var(--border); color: var(--text); font: inherit; text-align: start; cursor: pointer; }
.analytics-bank-row:hover { background: var(--bg-elev-2); }
.analytics-bank-name { display: grid; gap: 4px; min-width: 0; }
.analytics-bank-name strong { font-size: .9rem; overflow-wrap: anywhere; }
.analytics-bank-value { min-width: 0; font-variant-numeric: tabular-nums; }
.analytics-value-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.analytics-completion-track { display: block; width: 64px; max-width: 100%; height: 3px; border-radius: 3px; background: var(--border); margin-top: 8px; overflow: hidden; }
.analytics-completion-track > span { display: block; height: 100%; background: var(--brand-500); }
.analytics-subject-option:focus-visible, .analytics-bank-row:focus-visible, .analytics-back:focus-visible, .analytics-picker-toggle:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }
@media (max-width: 1100px) {
    .analytics-workspace { grid-template-columns: 200px minmax(0, 1fr); gap: 16px; }
    .analytics-bank-columns, .analytics-bank-row { grid-template-columns: minmax(100px, 1.6fr) repeat(3, minmax(55px, 1fr)) 16px; gap: 10px; }
}
@media (max-width: 800px) {
    .analytics-workspace { display: block; scroll-margin-top: 132px; }
    .analytics-subject-nav { position: static; margin-bottom: 16px; }
    .analytics-nav-title { display: none; }
    .analytics-picker-toggle { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px; background: var(--bg-elev); color: var(--text); border: 1px solid var(--border); border-radius: 12px; font: inherit; text-align: start; cursor: pointer; }
    .analytics-picker-toggle > span:nth-child(2) { display: grid; flex: 1; gap: 4px; min-width: 0; }
    .analytics-picker-toggle strong { overflow-wrap: anywhere; }
    .analytics-change { display: flex; align-items: center; gap: 4px; font-size: .8rem; flex-shrink: 0; }
    .analytics-subject-picker { display: none; max-height: none; }
    .analytics-subject-nav.is-open .analytics-subject-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding-top: 12px; }
    .analytics-subject-option { align-items: start; padding: 8px; gap: 8px; }
    .analytics-subject-option .learning-thumbnail { width: 36px; height: 36px; }
    .analytics-context { top: 120px; scroll-margin-top: 132px; }
}
@media (max-width: 520px) {
    .analytics-detail-body { padding: 0 16px 16px; }
    .analytics-context { padding: 16px; }
    .analytics-detail-title .learning-thumbnail { width: 48px; height: 48px; }
    .analytics-detail .learning-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 12px; }
    .analytics-detail .learning-metrics > div:nth-child(-n+3) dd { font-size: 1.375rem; }
    .analytics-detail .learning-metrics > div:nth-child(n+4) { border: 0; padding-top: 0; }
    .analytics-bank-columns { display: none; }
    .analytics-bank-row { grid-template-columns: repeat(3, minmax(0, 1fr)) 16px; padding-inline: 0; gap: 14px 8px; }
    .analytics-bank-name { grid-column: 1 / -1; }
    .analytics-value-label { display: block; position: static; width: auto; height: auto; clip-path: none; overflow: visible; white-space: normal; font-size: .7rem; color: var(--text-mute); margin-bottom: 6px; }
    .analytics-subject-nav.is-open .analytics-subject-picker { grid-template-columns: 1fr; }
    .analytics-subject-option { align-items: center; }
}

/* Saving forms keep their layout while native fieldsets lock all edits. */
fieldset.admin-save-form { min-inline-size: 0; margin: 0; }
.admin-save-status { min-height: 1.5em; margin: 8px 0; overflow-wrap: anywhere; }
.admin-save-status[role="alert"] { color: var(--danger, #b91c1c); }
