        /* =================================================================
           RESET & BASE
           ================================================================= */
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
            cursor: crosshair;
        }
        body {
            background: #030003;
            color: #fff;
            font-family: Consolas, 'Lucida Console', monospace;
            font-weight: 900;
            letter-spacing: 1.5px;
            text-transform: uppercase;
            height: 100vh;
            overflow: hidden;
            display: grid;
            grid-template-rows: 1fr auto;
            gap: 4px;
            padding: 6px;
            zoom: 1.09;
        }

        /* =================================================================
           MAIN GRID — 2 columns: dict/menu sidebar (280px) + map/flashcard
           ================================================================= */
        .main {
            display: grid;
            grid-template-columns: 280px 1fr;
            grid-template-rows: repeat(8, 1fr);
            gap: 4px;
            min-height: 0;
        }
        #panel-dict { grid-column: 1; grid-row: 1 / 9; }
        #panel-ocr  { grid-column: 2; grid-row: 1 / 9; }

        /* =================================================================
           BOTTOM BAR — ad strip + attribution
           ================================================================= */
        .bottom-bar {
            display: flex;
            flex-direction: row;
            gap: 4px;
            height: 96px;
            flex-shrink: 0;
        }

        /* =================================================================
           PANEL BASE
           ================================================================= */
        .panel {
            background: #050505;
            border: 2px solid;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            min-height: 0;
            position: relative;
        }
        .panel-label {
            font-size: 11px;
            padding: 3px 8px;
            font-weight: 900;
            color: #000;
            flex-shrink: 0;
            display: flex;
            align-items: center;
            gap: 8px;
            min-height: 22px;
            box-sizing: border-box;
        }
        .panel-label-title { flex: 1; }
        .panel-body {
            flex: 1;
            overflow: hidden;
            display: flex;
            flex-direction: column;
            min-height: 0;
        }
        .panel-scroll {
            flex: 1;
            overflow-y: auto;
            padding: 6px 8px;
            min-height: 0;
        }

        /* =================================================================
           PANEL COLORS
           ================================================================= */
        .panel-cyan   { border-color: #00bcd4; }
        .panel-green  { border-color: #76ff03; }
        .panel-amber  { border-color: #ffc107; }

        .label-green  { background: #76ff03; }
        .label-amber  { background: #ffc107; }

        /* =================================================================
           FLASHCARD MODE — fc-active reserves bottom row for back button
           ================================================================= */
        body.fc-active .main {
            grid-template-rows: repeat(7, 1fr) 44px !important;
        }
        body.fc-active #panel-dict {
            grid-row: 1 / 8;
        }
        body.fc-active #back-to-menu {
            grid-column: 1; grid-row: 8;
            position: static;
            display: flex;
            width: 100%; height: 44px;
        }

        /* Version readout — bottom-right corner of the WELCOME panel,
           barely-visible grey so deploys can be confirmed without intruding. */
        #app-version {
            display: none;
            position: absolute;
            bottom: 6px;
            right: 8px;
            font-size: 11px;
            color: #3a3a3a;
            letter-spacing: 1px;
            font-weight: 900;
            pointer-events: none;
            z-index: 1;
        }
        body.menu-active #app-version { display: block; }

        /* Back button — hidden by default, shown in fc-active via rule above */
        #back-to-menu {
            display: none;
            background: #0a0400; border: 2px solid #ef6c00;
            color: #fff; font-family: Consolas, 'Lucida Console', monospace;
            font-weight: 900; font-size: 11px; letter-spacing: 1.5px;
            text-transform: uppercase; cursor: crosshair;
            align-items: center; justify-content: center;
        }
        #back-to-menu:hover { background: #1a0800; border-color: #ff8c00; }

        /* Menu mode — hide flashcard children of #panel-ocr; the aviation
           canvas + cam panel + overlays opt back in below. */
        body.menu-active #panel-ocr > * { display: none !important; }
        body.menu-active #fc-controls { display: none !important; }

        /* Menu controls */
        #menu-controls { display: none; }
        body.menu-active #menu-controls {
            display: flex; flex-direction: column; height: 100%;
        }
        body.menu-active .menu-pillow-col .fc-pillow-btn {
            height: 44px;
        }
        .menu-pillow-col {
            display: flex; flex-direction: column;
            gap: 5px; padding: 10px;
        }

        /* Aviation radar canvas — fills panel-ocr in menu mode */
        #av-menu-canvas {
            position: absolute;
            inset: 0;
            width: 100%;
            height: 100%;
            display: none;
            cursor: crosshair;
        }
        /* Override the panel-ocr > * hide rule for the aviation canvas */
        body.menu-active #panel-ocr > #av-menu-canvas {
            display: block !important;
        }

        #cam-dot-canvas {
            position: absolute;
            inset: 0;
            width: 100%;
            height: 100%;
            display: none;
            pointer-events: none;
            z-index: 10;
        }
        body.menu-active #panel-ocr > #cam-dot-canvas {
            display: block !important;
        }

        /* Aviation overlay — two-column sidebar in bottom-right water area */
        #av-overlay {
            position: absolute;
            bottom: 14px;
            right: 14px;
            width: 340px;
            max-height: 21%;
            display: none;
            flex-direction: row;
            gap: 0;
            background: rgba(2,1,0,0.88);
            border: 1px solid #2a1800;
            font-family: Consolas, monospace;
            font-size: 11px;
            color: #ddd;
            overflow: hidden;
            pointer-events: none;
        }
        body.menu-active #panel-ocr > #av-overlay {
            display: flex !important;
        }

        /* =================================================================
           CAMERA ROUTE PANEL (mirror of #av-overlay, bottom-left corner)
           ================================================================= */
        #cam-panel {
            position: absolute;
            bottom: 14px;
            left: 14px;
            width: 220px;
            max-height: 21%;
            display: none;
            flex-direction: column;
            overflow: hidden;
            background: rgba(2,1,0,0.88);
            border: 1px solid #2a1800;
            font-family: Consolas, monospace;
            font-size: 11px;
            color: #ddd;
            pointer-events: auto;
            z-index: 500;
        }
        body.menu-active #panel-ocr > #cam-panel { display: flex !important; }
        .cam-screen {
            flex-shrink: 0; font-size: 9px; letter-spacing: .12em;
            color: #ffc107; background: #0a0600;
            padding: 4px 8px; border-bottom: 1px solid #1e1000;
        }
        .cam-body { overflow-y: auto; }
        .cam-bar { height: 2px; background: #0a0600; flex-shrink: 0; display: none; }
        .cam-bar-fill { height: 100%; width: 0%; background: #ffc107; transition: width 0.15s linear; }
        .cam-route-row {
            display: flex; align-items: center; padding: 3px 7px; gap: 5px;
            cursor: crosshair; border-bottom: 1px solid #0d0800; white-space: nowrap;
        }
        .cam-route-row:hover { background: #100800; }
        .cam-route-row.active { background: #1a0e00; }
        .cam-route-row.active .cam-route-name { color: #ffc107; }
        .cam-route-name { flex: 1; font-weight: 700; letter-spacing: .05em; }
        .cam-route-cnt { font-size: 9px; color: #886633; flex-shrink: 0; }

        /* Camera stills grid — fills the gap between #cam-panel and #av-overlay
           via symmetric 14px gutters; both corner boxes are 14px from the edges. */
        #cam-strip {
            position: absolute;
            bottom: 14px;
            left: 244px;       /* clear of #cam-panel (220 + 14 + 10) */
            right: 364px;      /* clear of #av-overlay (340 + 14 + 10) */
            max-height: 21%;
            display: none;
            flex-wrap: wrap;
            align-content: flex-start;
            gap: 3px;
            overflow-y: auto;
            scrollbar-width: thin;
            pointer-events: auto;
            z-index: 400;
        }
        body.menu-active #panel-ocr > #cam-strip { display: flex !important; }

        /* Shared amber scrollbar — strip + cam-panel inner scroll */
        #cam-strip::-webkit-scrollbar,
        #cam-panel ::-webkit-scrollbar { width: 12px; }
        #cam-strip::-webkit-scrollbar-track,
        #cam-panel ::-webkit-scrollbar-track {
            background: #050505; border-left: 2px solid #ffc107;
        }
        #cam-strip::-webkit-scrollbar-thumb,
        #cam-panel ::-webkit-scrollbar-thumb {
            background: #ffc107; border-left: 2px solid #ffc107;
        }
        #cam-strip::-webkit-scrollbar-thumb:hover,
        #cam-panel ::-webkit-scrollbar-thumb:hover { background: #ffd54f; }
        #cam-strip::-webkit-scrollbar-button,
        #cam-panel ::-webkit-scrollbar-button { display: none; height: 0; }
        #cam-strip, #cam-panel, #cam-panel * {
            scrollbar-width: thin;
            scrollbar-color: #ffc107 #050505;
        }
        #cam-strip .cam-still {
            position: relative;
            width: 150px;
            border: 1px solid #2a1800;
            background: rgba(2,1,0,0.92);
            flex-shrink: 0;
        }
        #cam-strip .cam-still img {
            width: 100%;
            display: block;
            background: #000;
            min-height: 30px;
        }
        #cam-strip .cam-still .cam-still-badge {
            position: absolute;
            top: 3px; left: 5px;
            color: #4caf50;
            font: 900 13px Consolas, monospace;
            pointer-events: none;
            text-shadow: 0 0 4px #000, 0 0 2px #000;
        }
        #cam-strip .cam-still .cam-still-lbl {
            font-size: 9px;
            color: #886633;
            padding: 2px 6px;
            letter-spacing: .04em;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        /* Left column — aircraft list */
        #av-list-col {
            pointer-events: auto;
            width: 140px;
            flex-shrink: 0;
            display: flex;
            flex-direction: column;
            border-right: 1px solid #1e1000;
            overflow: hidden;
        }
        #av-list-hdr {
            font-size: 9px;
            letter-spacing: .12em;
            color: #ffc107;
            background: #0a0600;
            padding: 4px 8px;
            flex-shrink: 0;
            border-bottom: 1px solid #1e1000;
        }
        #av-list-body {
            flex: 1;
            overflow-y: auto;
            scrollbar-width: none;
        }
        #av-list-body::-webkit-scrollbar { display: none; }
        .av-row {
            display: flex;
            align-items: center;
            padding: 3px 7px;
            gap: 5px;
            cursor: crosshair;
            border-bottom: 1px solid #0d0800;
            white-space: nowrap;
        }
        .av-row:hover { background: #100800; color: #fff; }
        .av-row.av-active { background: #1a0e00; color: #ffc107; }
        .av-row-icon { font-size: 7px; color: #886633; flex-shrink: 0; }
        .av-row.av-active .av-row-icon { color: #ffc107; }
        .av-row.av-ground .av-row-icon { color: #4488ff; }
        .av-row.av-ground .av-row-cs  { color: #4488ff; }
        .av-row.av-ground .av-row-alt { color: #336699; }
        .av-row.av-ground:hover .av-row-cs { color: #fff; }
        .av-row-cs { flex: 1; overflow: hidden; text-overflow: ellipsis; font-weight: 700; letter-spacing: .05em; }
        .av-row-alt { font-size: 9px; color: #bbb; flex-shrink: 0; }
        .av-row.av-active .av-row-alt { color: #a07000; }
        /* Right column — detail */
        #av-detail-col {
            pointer-events: auto;
            flex: 1;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            min-width: 0;
        }
        #av-detail-hdr {
            font-size: 9px;
            letter-spacing: .12em;
            color: #aaa;
            background: #0a0600;
            padding: 4px 8px;
            flex-shrink: 0;
            border-bottom: 1px solid #1e1000;
        }
        #av-detail-body {
            flex: 1;
            overflow-y: auto;
            padding: 5px 8px;
            scrollbar-width: none;
        }
        #av-detail-body::-webkit-scrollbar { display: none; }
        .av-field {
            display: flex;
            gap: 6px;
            padding: 2px 0;
            border-bottom: 1px solid #0d0800;
        }
        .av-fkey {
            width: 68px;
            flex-shrink: 0;
            color: #888;
            font-size: 9px;
            letter-spacing: .08em;
            padding-top: 1px;
        }
        .av-fval {
            flex: 1;
            color: #fff;
            font-weight: 700;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        #av-detail-none {
            color: #555;
            font-size: 10px;
            letter-spacing: .1em;
            padding: 10px 0;
            text-align: center;
        }

        .flashcard-container { display: none; }
        .flashcard-container.active { display: flex; flex-direction: column; height: 100%; min-height: 0; }

        /* =================================================================
           CARD SHELL
           ================================================================= */
        .flashcard-card {
            flex: 1; display: flex; flex-direction: column;
            min-height: 0; overflow: hidden; position: relative;
        }

        .fc-card-header { display: none; }

        .fc-body-top {
            flex: 0 0 auto; display: flex; flex-direction: row;
            min-height: 0; overflow: hidden;
        }

        .fc-char-zone {
            flex: 0 0 auto;
            display: flex; flex-direction: column;
            align-items: flex-start; justify-content: flex-start;
            padding: 18px 20px 12px 16px;
            position: relative;
        }

        .fc-char-row {
            display: flex; flex-wrap: nowrap; flex-direction: row;
            align-items: flex-start; gap: 0;
        }
        .fc-char-unit {
            --sz: 200px;
            display: flex; flex-direction: column;
            align-items: stretch; flex-shrink: 0;
            width: var(--sz); overflow: hidden;
        }
        /* Whole-word unit (Spanish etc.) — auto-width so the entire word
           shows; font-size uses ch units so long words shrink to fit
           without ever being clipped. The per-char 200px cap above is
           only correct for single CJK glyphs. */
        .fc-char-unit-word {
            width: auto; max-width: 100%;
            overflow: visible;
        }
        .fc-char-unit-word .fc-big-hz {
            font-size: clamp(48px, calc(1100px / max(var(--word-len, 4), 4)), 200px);
            white-space: nowrap;
        }
        body.fc-lang-rus .fc-char-unit-word .fc-big-hz {
            font-size: clamp(32px, calc(700px / max(var(--word-len, 4), 4)), 120px);
            letter-spacing: -1px;
        }
        body.fc-phonetics-on .fc-pillow-pinyin { visibility: visible; }

        /* ── Relations panel (synonyms/antonyms/derived/related) ── */
        #fc-relations { padding: 6px 16px 0; }
        #fc-relations:empty { display: none; }
        .fc-rel-row {
            display: flex; align-items: flex-start;
            gap: 8px; padding: 3px 0;
        }
        .fc-rel-label {
            font-size: 9px; letter-spacing: 1px;
            color: #00bcd4; min-width: 60px;
            text-transform: uppercase; font-weight: 900;
            padding-top: 3px; flex-shrink: 0;
        }
        .fc-rel-chips {
            display: flex; flex-wrap: wrap; gap: 4px;
        }
        .fc-rel-chip {
            font-size: 11px; color: #ffc107; font-weight: bold;
            background: #0c0c0c; border: 1px solid #1a1a1a;
            padding: 2px 6px; border-radius: 2px;
            font-family: 'KaiTi', Georgia, serif;
        }
        .fc-rel-chip:hover { border-color: #ffc107; }

        /* ── Variations panel (Spanish: conjugation + gender/number) ── */
        .fc-var-title {
            font-size: 11px; color: #ffc107; letter-spacing: 2px;
            padding: 0 0 6px; text-transform: uppercase;
            border-left: 2px solid #ffc107; padding-left: 6px;
        }
        .fc-var-irreg {
            font-size: 9px; color: #ff3d00; margin-left: 8px;
            padding: 1px 5px; border: 1px solid #ff3d00; border-radius: 2px;
        }
        .fc-var-table {
            border-collapse: collapse; font-family: inherit; font-size: 11px;
            color: #fff; margin-top: 2px;
        }
        .fc-var-table th, .fc-var-table td {
            padding: 3px 8px; text-align: left;
            border-bottom: 1px solid #1a1a1a; white-space: nowrap;
        }
        .fc-var-table thead th {
            color: #00bcd4; font-weight: normal;
            text-transform: uppercase; letter-spacing: 1px; font-size: 9px;
        }
        .fc-var-table .fc-var-tense {
            color: #ffc107; font-weight: bold;
            text-transform: uppercase; letter-spacing: 1px; font-size: 10px;
        }
        .fc-var-inflect {
            display: flex; flex-wrap: wrap; gap: 6px 14px;
            padding: 2px 0;
        }
        .fc-var-cell {
            display: flex; flex-direction: column; line-height: 1.2;
        }
        .fc-var-label {
            color: #00bcd4; font-size: 9px;
            text-transform: uppercase; letter-spacing: 1px;
        }
        .fc-var-form {
            color: #fff; font-size: 14px; font-weight: bold;
        }
        .fc-big-hz {
            color: #ffc107; font-family: 'KaiTi', 'KaiTi_GB2312', 'STKaiti', Georgia, serif;
            font-weight: bold; line-height: 1;
            font-size: var(--sz);
            text-transform: none; letter-spacing: 0;
        }
        /* Latin scripts: drop the Chinese-font-first stack so glyphs come
           from one consistent font instead of per-glyph fallback. */
        body.fc-lang-spa .fc-big-hz,
        body.fc-lang-spa .fc-pmi-chip-hz,
        body.fc-lang-spa .fc-family-hz {
            font-family: Georgia, 'Times New Roman', serif;
        }
        /* Persian — Vazirmatn, the modern Persian web standard. */
        body.fc-lang-fas .fc-big-hz,
        body.fc-lang-fas .fc-pmi-chip-hz,
        body.fc-lang-fas .fc-family-hz {
            font-family: 'Vazirmatn', Tahoma, 'Iranian Sans', sans-serif;
        }
        /* Hijazi Arabic — Amiri, classical Naskh fitting the
           Mecca/Medina / religious-register lean of the deck. */
        body.fc-lang-acw .fc-big-hz,
        body.fc-lang-acw .fc-pmi-chip-hz,
        body.fc-lang-acw .fc-family-hz,
        body.fc-lang-acw2 .fc-big-hz,
        body.fc-lang-acw2 .fc-pmi-chip-hz,
        body.fc-lang-acw2 .fc-family-hz {
            font-family: 'Amiri', 'Traditional Arabic', Tahoma, serif;
        }
        body.fc-lang-fas .flashcard-card,
        body.fc-lang-acw .flashcard-card,
        body.fc-lang-acw2 .flashcard-card {
            direction: rtl;
        }
        /* Arabic-script glyphs render vowel marks and descenders outside
           their line-box. Two-step fix:
             1) overflow:visible so the marks aren't clipped (not the
                position of the glyph — just the clipping rectangle).
             2) outer margin / gap on the surrounding containers so the
                overflowing marks have physical space and don't collide
                into the elements above/below or into sibling glyphs.
           The glyph itself is not moved, resized, padded, or
           re-line-heighted. Layout shifts only as much as necessary to
           keep the marks clear of neighbors. */
        body.fc-lang-fas .fc-char-unit,
        body.fc-lang-acw .fc-char-unit,
        body.fc-lang-acw2 .fc-char-unit,
        body.fc-lang-fas .fc-char-zone,
        body.fc-lang-acw .fc-char-zone,
        body.fc-lang-acw2 .fc-char-zone,
        body.fc-lang-fas .fc-body-top,
        body.fc-lang-acw .fc-body-top,
        body.fc-lang-acw2 .fc-body-top {
            overflow: visible;
        }
        body.fc-lang-fas .fc-char-zone,
        body.fc-lang-acw .fc-char-zone,
        body.fc-lang-acw2 .fc-char-zone {
            padding-bottom: 0.45em;
        }
        body.fc-lang-fas .fc-char-unit + .fc-char-unit,
        body.fc-lang-acw .fc-char-unit + .fc-char-unit,
        body.fc-lang-acw2 .fc-char-unit + .fc-char-unit {
            margin-inline-start: 0.08em;
        }
        body.fc-lang-fas .fc-pillow-col,
        body.fc-lang-acw .fc-pillow-col,
        body.fc-lang-acw2 .fc-pillow-col {
            gap: 9px;
        }
        /* HIJAZI 2 — hard bidi isolation per zone.
           Each <bdi> already carries a dir attribute; these rules add
           unicode-bidi:isolate so the browser treats each zone as its
           own paragraph and punctuation can never leak across. */
        body.fc-lang-acw2 .rb-row     { unicode-bidi: isolate; }
        body.fc-lang-acw2 .rb-letter,
        body.fc-lang-acw2 .rb-word    { unicode-bidi: isolate; direction: rtl; }
        body.fc-lang-acw2 .rb-phonetic,
        body.fc-lang-acw2 .rb-def     { unicode-bidi: isolate; direction: ltr; }

        /* Egyptian glyph cells: same overflow-relief as Arabic-script,
           because some hieroglyphs have aspect ratios outside the
           Latin/CJK bounding box (tall column-headers, wide ground-line
           signs). Glyph stays anchored to padding-top:18px; only the
           clipping rectangle is loosened so the rendered sign isn't
           sliced where it exceeds 200px in either dimension. */
        body.fc-lang-egy .fc-char-unit,
        body.fc-lang-egy .fc-char-zone,
        body.fc-lang-egy .fc-body-top {
            overflow: visible;
        }
        body.fc-lang-egy .fc-char-zone {
            padding-bottom: 0.3em;
        }
        body.fc-lang-egy .fc-pillow-col {
            gap: 7px;                /* room between pillow signs */
        }
        body.fc-lang-fas .flashcard-card .fc-pillow-pinyin,
        body.fc-lang-acw .flashcard-card .fc-pillow-pinyin,
        body.fc-lang-fas .flashcard-card .fc-cap-py,
        body.fc-lang-acw .flashcard-card .fc-cap-py {
            direction: ltr;  /* romanization stays LTR even in RTL cards */
        }
        /* Egyptian Hieroglyphs — Noto Sans Egyptian Hieroglyphs covers the
           full U+13000–U+1342F block. Force font-weight:normal because
           Google Fonts only ships weight 400; some browsers drop the font
           entirely when CSS asks for bold instead of synthesizing. */
        body.fc-lang-egy .fc-big-hz,
        body.fc-lang-egy .fc-pmi-chip-hz,
        body.fc-lang-egy .fc-family-hz,
        body.fc-lang-egy .fc-pillow-word,
        body.fc-lang-egy .fc-char-unit,
        body.fc-lang-egy #fc-char {
            font-family: 'Noto Sans Egyptian Hieroglyphs', 'Segoe UI Historic', 'Aegyptus', sans-serif !important;
            font-weight: normal !important;
            font-synthesis: weight;
        }
        /* Hijazi/Farsi pillow word — match the headline font (Amiri/Vazirmatn)
           rather than inheriting Mandarin's KaiTi which has no Arabic glyphs. */
        body.fc-lang-acw .fc-pillow-word {
            font-family: 'Amiri', 'Traditional Arabic', Tahoma, serif;
        }
        body.fc-lang-fas .fc-pillow-word {
            font-family: 'Vazirmatn', Tahoma, 'Iranian Sans', sans-serif;
        }
        /* Pillow phonetics — needs a font with full extended-Latin + IPA
           coverage for ẓ ā ʔ ʕ ḥ ṯ ḏ etc. Charis SIL is the IPA gold
           standard; Lucida Sans Unicode + Segoe UI fall through cleanly. */
        body.fc-lang-acw .fc-pillow-pinyin,
        body.fc-lang-fas .fc-pillow-pinyin {
            font-family: 'Charis SIL', 'Gentium Plus', 'Lucida Sans Unicode',
                         'Segoe UI', 'DejaVu Sans', sans-serif;
        }
        .fc-char-unit-cap {
            display: flex; flex-direction: column;
            align-items: flex-start; padding: 4px 0 0;
            overflow: hidden;
            opacity: 0; pointer-events: none;
            transition: opacity 0.15s;
        }
        .fc-char-row.caps-visible .fc-char-unit-cap {
            opacity: 1; pointer-events: auto;
        }
        .fc-cap-py  { font-size: 15px; color: #00bcd4; font-family: 'Courier New', monospace; text-transform: none; letter-spacing: 0; line-height: 1.3; }
        .fc-cap-def { font-size: 10px; color: #fff; font-family: sans-serif; text-transform: none; letter-spacing: 0; word-break: break-word; }
        /* Phonetic hint — wraps tricky letters (kh / gh / uvular q,
           Spanish j, glottal stop ', heavy h) in cap and pillow
           phonetics so an English reader doesn't gloss them. Visual
           cue only — underlying text is unchanged. */
        .fc-phon-fric    { color: #ff9800; font-weight: 700; }
        .fc-phon-glottal { color: #ff9800; font-style: italic; opacity: 0.85; }
        .fc-phon-heavyh  { color: #ff9800; font-style: italic; font-weight: 700; }

        /* Persistent legend — sits in the bottom-left corner of the
           flashcard, stays visible whether the card is in quiz or
           reveal state. Populated per-language by populatePhonLegend(). */
        .fc-phon-legend {
            position: absolute;
            left: 12px;
            bottom: 8px;
            z-index: 5;
            pointer-events: none;
            font-family: Consolas, monospace;
            font-size: 9px;
            letter-spacing: 0.6px;
            color: #555;
            line-height: 1.5;
            text-transform: none;
            display: none;     /* shown only when populatePhonLegend writes content */
            max-width: 220px;
        }
        .fc-phon-legend.populated { display: block; }
        .fc-phon-legend .key   { color: #ff9800; font-weight: 700; }
        .fc-phon-legend .key.italic { font-style: italic; }
        .fc-phon-legend .sep   { color: #2a2a2a; padding: 0 4px; }
        .fc-phon-legend .desc  { color: #666; }

        /* Shared-prefix neighbour list (Hijazi + Farsi reveal panel) */
        /* ── Cairo bottom-left label ────────────────────────────────────── */
        .fc-cairo-word {
            font-family: 'Cairo', sans-serif;
            font-size: 22px;
            color: #555;
            direction: rtl;
            line-height: 1;
        }

        /* ── Word Rainbow ───────────────────────────────────────────────── */
        #fc-rainbow { padding: 8px 16px 4px; border-bottom: 1px solid #0d0d0d; }
        .rb-title   { font-size: 21px; color: #fff; letter-spacing: 2px; padding-bottom: 6px;
                      text-transform: uppercase; border-left: 2px solid #ffc107; padding-left: 6px;
                      display: flex; align-items: center; gap: 10px; }
        .rb-decomp  { font-family: 'Cairo', sans-serif; font-size: 21px; letter-spacing: 0; color: #aaa; }
        .rb-decomp-letter { }
        .rb-row     { display: flex; align-items: baseline; gap: 10px; padding: 3px 0;
                      border-bottom: 1px solid #0d0d0d; }
        .rb-row:last-child { border-bottom: none; }
        .rb-letter  { font-family: 'Amiri', 'Vazirmatn', serif; font-size: 52px; font-weight: 700;
                      color: #ffc107; min-width: 28px; text-align: center; line-height: 1; }
        .rb-chips   { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
        .rb-chip    { display: flex; align-items: baseline; gap: 4px; font-size: 29px; }
        .rb-word    { font-family: 'Amiri', 'Vazirmatn', serif; font-size: 42px; color: #fff; font-weight: 600; }
        .rb-hi      { color: #ffc107; }
        .rb-phonetic { font-family: 'Courier New', monospace; font-size: 23px; color: #00bcd4; }
        .rb-def     { font-size: 23px; color: #888; }
        .rb-chip + .rb-chip::before { content: '·'; color: #333; margin-right: 2px; }

        .fc-roots-prefix { color: #ffc107; font-family: 'Amiri', 'Vazirmatn', 'Lucida Sans Unicode', serif; font-weight: 700; }
        .fc-roots-list   { display: flex; flex-direction: column; gap: 3px; padding: 4px 0 8px; }
        .fc-roots-row    { display: grid; grid-template-columns: minmax(60px, max-content) minmax(80px, max-content) 1fr;
                           gap: 12px; align-items: baseline;
                           padding: 2px 0; border-bottom: 1px solid #0d0d0d;
                           font-family: Consolas, monospace; font-size: 12px; }
        .fc-roots-row:last-child { border-bottom: none; }
        .fc-roots-word   { color: #ffc107; font-family: 'Amiri', 'Vazirmatn', 'Lucida Sans Unicode', serif;
                           font-size: 18px; font-weight: 700; }
        .fc-roots-py     { color: #00bcd4; font-family: 'Courier New', monospace; }
        .fc-roots-def    { color: #ddd; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

        .fc-trad-ghost {
            position: absolute; bottom: 12px; left: 14px;
            z-index: 1;
            font-size: 20px; color: #252525;
            font-family: Georgia, serif; font-weight: normal;
            text-transform: none; letter-spacing: 0; line-height: 1;
        }

        .fc-right-col {
            display: none; flex: 1; flex-direction: column;
            min-height: 0; overflow: hidden;
        }
        .fc-revealed .fc-right-col { display: flex; }

        .fc-def-list {
            flex: 1; overflow-y: auto; min-height: 0;
            padding: 12px 16px; display: flex; flex-direction: column; gap: 4px;
        }
        .fc-script-btns { display: flex; gap: 4px; }
        .fc-script-btn { background: #111; border: 1px solid #333; color: #888; font-family: 'Noto Sans', sans-serif;
                         font-size: 14px; padding: 1px 8px; cursor: pointer; border-radius: 2px; }
        .fc-script-btn.active { border-color: #ffc107; color: #ffc107; }
        .fc-def-header-pos { font-size: 10px; color: #888; letter-spacing: 1px; text-transform: uppercase; align-self: center; }
        .fc-def-header {
            display: flex; gap: 10px; align-items: baseline;
            padding-bottom: 8px; margin-bottom: 4px;
            border-bottom: 1px solid #1c1c1c; flex-shrink: 0;
        }
        .fc-def-header-py {
            font-size: 18px; color: #00bcd4; font-family: 'Courier New', monospace;
            text-transform: none; letter-spacing: 0; flex-shrink: 0;
        }
        .fc-def-header-romaji {
            font-size: 12px; color: #888; font-family: 'Courier New', monospace;
            text-transform: none; letter-spacing: 0; flex-shrink: 0; align-self: center;
        }
        .fc-def-header-text {
            font-size: 13px; color: #76ff03; font-family: 'Courier New', monospace;
            text-transform: none; letter-spacing: 0; line-height: 1.3; flex: 1;
        }
        .fc-def-header-trad {
            font-size: 16px; color: #ffc107; font-family: 'KaiTi', 'KaiTi_GB2312', Georgia, serif;
            font-weight: bold; text-transform: none; letter-spacing: 0;
            opacity: 0.5; flex-shrink: 0; margin-left: auto;
        }
        .fc-def-entry {
            display: flex; gap: 10px; align-items: baseline; line-height: 1.4;
        }
        .fc-def-pos {
            font-size: 9px; color: #ffc107; font-family: inherit;
            font-weight: 900; letter-spacing: 1.5px; text-transform: uppercase;
            flex-shrink: 0; min-width: 30px;
        }
        .fc-def-text {
            font-size: 12px; color: #fff;
            font-family: 'Courier New', monospace;
            text-transform: none; letter-spacing: 0;
        }

        .fc-side-nav {
            display: flex; gap: 4px; padding: 8px 12px;
            border-top: 1px solid #1a1a1a;
            border-bottom: 1px solid #1a1a1a;
            flex-shrink: 0;
        }
        .fc-side-btn {
            flex: 1; background: #0e0e0e; border: 1px solid #222;
            box-shadow: inset 1px 1px 0 rgba(255,255,255,0.05), inset -1px -1px 0 rgba(0,0,0,0.5);
            color: #777; font-family: inherit; font-weight: 900;
            font-size: 9px; padding: 7px 4px; cursor: pointer;
            letter-spacing: 1px; text-transform: uppercase; transition: all 0.1s;
        }
        .fc-side-btn:hover { color: #ffc107; border-color: #333; }
        .fc-side-btn.primary { color: #ffc107; border-color: #ffc107; }
        .fc-side-btn.primary:hover { background: #ffc107; color: #000; }

        .fc-pillow-col {
            display: flex; flex-direction: column;
            flex-shrink: 0; gap: 5px; padding: 10px 10px 6px;
            background: transparent;
        }
        .fc-pillow-btn {
            background: #0c0c0c;
            border: 1px solid #1a1a1a;
            box-shadow: inset 1px 1px 0 rgba(255,255,255,0.05), inset -1px -1px 0 rgba(0,0,0,0.5);
            color: #888; font-family: inherit;
            padding: 8px 12px; cursor: pointer; text-align: left;
            transition: background 0.1s, color 0.1s;
            display: flex; flex-direction: column; justify-content: center;
            height: 64px; flex-shrink: 0; overflow: hidden;
        }
        .fc-pillow-btn:hover { background: #111; border-color: #2a2a2a; }
        .fc-pillow-word {
            display: block; font-size: 18px; font-weight: bold;
            color: #ffc107; font-family: 'KaiTi', Georgia, serif;
            text-transform: none; letter-spacing: 0; line-height: 1.2;
            visibility: hidden;
        }
        .fc-pillow-pinyin {
            display: block; font-size: 11px;
            color: #00bcd4; line-height: 1.3;
            visibility: hidden;
        }
        .fc-pillow-def {
            display: block; font-size: 11px; font-weight: 900;
            color: #fff; text-transform: none; letter-spacing: 0; line-height: 1.3;
        }
        .fc-pillow-btn.correct-highlight { background: rgba(118,255,3,0.06); border-color: #76ff03; }
        .fc-pillow-btn.correct-highlight .fc-pillow-word,
        .fc-pillow-btn.correct-highlight .fc-pillow-pinyin,
        .fc-pillow-btn.correct-highlight .fc-pillow-def { color: #76ff03; }
        .fc-pillow-btn.wrong-highlight { background: rgba(255,61,0,0.05); border-color: #ff3d00; }
        .fc-pillow-btn.wrong-highlight .fc-pillow-word,
        .fc-pillow-btn.wrong-highlight .fc-pillow-pinyin,
        .fc-pillow-btn.wrong-highlight .fc-pillow-def { color: #ff3d00; }

        .fc-detail {
            flex: 0 0 0; overflow: hidden; min-height: 0;
        }
        .fc-revealed .fc-detail { flex: 1; overflow-y: auto; }

        .fc-family-sentences-row { display: flex; flex-direction: row; align-items: flex-start; flex-wrap: wrap; }
        #fc-family { flex: 0 0 auto; padding: 8px 16px 12px; }
        #fc-sentences {
            flex: 1 1 320px;
            padding: 8px 20px 16px 28px;
            border-left: 1px solid #1c1c1c;
        }

        .fc-sentences-title { font-size: 12px; color: #fff; letter-spacing: 2px; padding: 0 0 10px; text-transform: uppercase; border-left: 2px solid #00bcd4; padding-left: 6px; }
        .fc-sent-item {
            display: flex; flex-direction: column;
            padding: 0 0 16px; margin-bottom: 16px;
            border-bottom: 1px solid #151515;
        }
        .fc-sent-item:last-child { border-bottom: none; margin-bottom: 0; }
        .fc-sent-top {
            display: flex; flex-direction: column;
            align-items: flex-start; gap: 4px;
        }
        .fc-sent-zh {
            font-size: 26px; color: #ffc107;
            font-family: 'KaiTi', 'KaiTi_GB2312', Georgia, serif;
            font-weight: bold; text-transform: none; letter-spacing: 0;
            flex-shrink: 0;
        }
        .fc-sent-en {
            font-size: 17px; color: #fff; font-family: sans-serif;
            text-transform: none; letter-spacing: 0; font-style: italic;
            line-height: 1.3;
        }
        .fc-sent-py {
            font-size: 14px; color: #fff; font-family: 'Courier New', monospace;
            text-transform: none; letter-spacing: 0.3px; margin-top: 1px;
        }
        .fc-sent-target { color: #ff9100; }

        /* =================================================================
           PMI COLLOCATIONS
           ================================================================= */
        .fc-pmi { padding: 8px 16px 4px; border-bottom: 1px solid #0d0d0d; text-transform: none; letter-spacing: 0; }
        .fc-pmi-inner { display: inline-flex; flex-direction: column; }
        .fc-pmi-title { font-size: 8px; color: #fff; letter-spacing: 2px; padding-bottom: 8px; text-transform: uppercase; border-left: 2px solid #00bcd4; padding-left: 6px; }
        .fc-pmi-chips {
            display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 6px;
        }
        .fc-pmi-chip {
            display: flex; flex-direction: column; align-items: center;
            padding: 5px 8px; border: 1px solid #1c1c1c;
            background: #080808; min-width: 36px; cursor: default;
            transition: border-color 0.1s;
        }
        .fc-pmi-chip:hover { border-color: #00bcd4; }
        .fc-pmi-chip-hz  { font-size: 20px; color: #ffc107; font-family: 'KaiTi', Georgia, serif; font-weight: bold; line-height: 1.1; text-transform: none; letter-spacing: 0; }
        .fc-pmi-chip-py  { font-size: 9px; color: #00bcd4; font-family: 'Courier New', monospace; text-transform: none; letter-spacing: 0; line-height: 1.4; }
        .fc-pmi-chip-def { font-size: 9px; color: #fff; font-family: sans-serif; text-transform: none; letter-spacing: 0; max-width: 80px; text-align: center; line-height: 1.2; margin-top: 1px; }

        /* =================================================================
           WORD FAMILY CONSTELLATION
           ================================================================= */
        .fc-family { padding: 8px 16px 4px; border-bottom: 1px solid #0d0d0d; text-transform: none; letter-spacing: 0; }
        .fc-family-item {
            display: flex; align-items: baseline; gap: 6px;
            padding: 2px 0; border-bottom: 1px solid #0a0a0a;
        }
        .fc-family-item:last-child { border-bottom: none; }
        .fc-family-hz  { font-size: 23px; color: #ffc107; font-family: 'KaiTi', Georgia, serif; font-weight: bold; text-transform: none; letter-spacing: 0; flex-shrink: 0; }
        .fc-family-py  { font-size: 15px; color: #00bcd4; font-family: 'Courier New', monospace; text-transform: none; letter-spacing: 0; flex-shrink: 0; }
        .fc-family-def { font-size: 15px; color: #fff; font-family: sans-serif; text-transform: none; letter-spacing: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .fc-family-grid {
            display: grid;
            grid-template-columns: repeat(var(--fc-cols, 2), max-content);
            justify-content: start;
            gap: 0 32px;
            align-items: start;
        }
        .fc-family-col { min-width: 0; overflow: hidden; }
        .fc-family-subgroup + .fc-family-subgroup { margin-top: 4px; }
        .fc-family-hz-accent { color: #ff9100; }

        .fc-family-char-block { margin-bottom: 10px; }
        .fc-family-char-label {
            font-size: 20px; color: #ffc107; font-family: 'KaiTi', Georgia, serif;
            font-weight: bold; text-transform: none; letter-spacing: 0;
            margin-bottom: 4px; display: flex; align-items: baseline; gap: 8px;
        }
        .fc-family-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

        .fc-detail::-webkit-scrollbar,
        .fc-defs-scroll::-webkit-scrollbar { width: 4px; }
        .fc-detail::-webkit-scrollbar-track,
        .fc-defs-scroll::-webkit-scrollbar-track { background: #050505; }
        .fc-detail::-webkit-scrollbar-thumb,
        .fc-defs-scroll::-webkit-scrollbar-thumb { background: #1e1e1e; }
        .fc-detail::-webkit-scrollbar-thumb:hover,
        .fc-defs-scroll::-webkit-scrollbar-thumb:hover { background: #ffc107; }

        .fc-difficulty {
            padding: 10px 12px; display: flex; flex-direction: column;
            gap: 8px; overflow-y: auto; margin-top: auto;
            border-top: 1px solid #1a1a1a;
        }
        .fc-level-row {
            display: flex; align-items: center; gap: 8px;
        }
        .fc-level-label { font-size: 10px; color: #aaa; width: 60px; text-align: right; flex-shrink: 0; }

        /* Shared sizing for every control in a fc-level-row — selects,
           buttons, slider all match exactly so the column edges line up. */
        .fc-level-select,
        .fc-phon-btn,
        .fc-level-slider {
            flex: 1; box-sizing: border-box;
            height: 22px;
            background: #0a0a0a; border: 1px solid #333;
            color: #ffc107; font-family: inherit; font-weight: 900;
            font-size: 10px; letter-spacing: 1px;
            text-transform: uppercase;
            cursor: pointer;
            margin: 0;
        }
        .fc-level-select { padding: 0 6px; }
        .fc-level-select:focus { outline: none; border-color: #ffc107; }
        .fc-level-select option { background: #111; color: #ffc107; }

        .fc-phon-btn {
            padding: 0 6px; text-align: left;
            font-family: inherit;  /* override <button> default */
        }
        .fc-phon-btn:focus { outline: none; }
        .fc-phon-btn:hover { border-color: #ffc107; }
        body.fc-phonetics-on .fc-phon-btn {
            background: rgba(255,193,7,0.12); border-color: #ffc107;
        }

        /* ── LEVEL slider — dual-handle range, fits inside one row ── */
        .fc-level-slider {
            position: relative;
            padding: 0;
            display: block;
        }
        .fc-level-track {
            position: absolute; left: 6px; right: 30px;
            top: 50%; transform: translateY(-50%);
            height: 3px; background: #1a1a1a; border-radius: 2px;
            pointer-events: none;
        }
        .fc-level-fill {
            position: absolute;
            top: 50%; transform: translateY(-50%);
            height: 3px; background: #ffc107; border-radius: 2px;
            pointer-events: none;
            /* JS sets left/right at runtime relative to the slider container.
               The 6px/30px gutter on .fc-level-track means the visual
               will be slightly inset from the fill — acceptable v1 trade-off. */
            left: 6px; right: 30px;
        }
        .fc-level-slider input[type="range"] {
            position: absolute;
            top: 0; bottom: 0;
            left: 0; right: 24px;   /* leave room for the readout span */
            width: calc(100% - 24px); height: 100%;
            background: transparent;
            pointer-events: none;
            -webkit-appearance: none; appearance: none;
            margin: 0; padding: 0; border: none;
        }
        .fc-level-slider input[type="range"]:focus { outline: none; }
        .fc-level-slider input[type="range"]::-webkit-slider-runnable-track {
            background: transparent; border: none; height: 100%;
        }
        .fc-level-slider input[type="range"]::-moz-range-track {
            background: transparent; border: none; height: 100%;
        }
        .fc-level-slider input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none; appearance: none;
            pointer-events: auto;
            width: 12px; height: 12px;
            background: #ffc107; border: 1px solid #000;
            border-radius: 50%; cursor: grab;
            margin-top: 0;
        }
        .fc-level-slider input[type="range"]::-moz-range-thumb {
            pointer-events: auto;
            width: 10px; height: 10px;
            background: #ffc107; border: 1px solid #000;
            border-radius: 50%; cursor: grab;
        }
        .fc-level-slider input[type="range"]::-webkit-slider-thumb:active,
        .fc-level-slider input[type="range"]::-moz-range-thumb:active {
            cursor: grabbing;
        }
        .fc-level-readout {
            position: absolute;
            right: 6px; top: 50%; transform: translateY(-50%);
            color: #ffc107; font-size: 10px; font-weight: 900;
            letter-spacing: 1px; pointer-events: none;
            min-width: 22px; text-align: right;
        }

        .fc-stats {
            font-size: 10px; color: #555; text-align: center;
            padding: 4px; border-top: 1px solid #222;
        }

        /* =================================================================
           AD STRIP + ATTRIBUTION
           ================================================================= */
        .ad-panel {
            flex: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            overflow: hidden;
        }
        .ad-placeholder {
            font-size: 9px;
            color: #1e1e1e;
            letter-spacing: 2px;
        }
        .attr-panel {
            flex: 0 0 auto;
            width: 300px;
            display: flex;
            flex-direction: column;
            justify-content: center;
            padding: 6px 10px;
            gap: 4px;
        }
        .attr-line {
            font-size: 8px;
            color: #333;
            letter-spacing: 0.5px;
            text-transform: none;
            line-height: 1.5;
        }
        .attr-line a {
            color: #555;
            text-decoration: none;
            cursor: pointer;
        }
        .attr-line a:hover { color: #ffc107; }

        /* =================================================================
           COOKIE CONSENT BANNER
           ================================================================= */
        #cookie-banner {
            display: none;
            position: fixed;
            bottom: 106px;
            left: 0; right: 0;
            z-index: 200;
            background: #0d0d0d;
            border-top: 2px solid #ffc107;
            padding: 10px 20px;
            align-items: center;
            gap: 20px;
            font-size: 9px;
            color: #888;
            letter-spacing: 1px;
        }
        #cookie-banner.visible { display: flex; }
        .cookie-text { flex: 1; line-height: 1.6; text-transform: none; }
        .cookie-text a { color: #ffc107; text-decoration: none; }
        .cookie-accept {
            background: #ffc107; color: #000; border: none;
            font-family: inherit; font-weight: 900; font-size: 9px;
            padding: 6px 16px; cursor: pointer; letter-spacing: 1.5px;
            text-transform: uppercase; flex-shrink: 0;
        }
        .cookie-accept:hover { background: #ffe082; }

        /* ── Contact overlay ──────────────────────────────────── */
        #contact-overlay {
            position: absolute; inset: 0; z-index: 9998;
            background: transparent; overflow: hidden; display: none;
            pointer-events: auto;
            font-family: Consolas, monospace;
            font-size: calc((100vw - 280px) / 17.5);
            font-weight: 900; color: #76ff03;
            line-height: 1; white-space: pre;
            user-select: none;
        }
        body.contact-active #panel-ocr > #contact-overlay { display: block !important; }
        #btn-contact.contact-pressed { box-shadow: inset 0 3px 6px rgba(0,0,0,0.95) !important; transform: translateY(2px); }
        #btn-contact.contact-pressed .fc-pillow-def { color: #e74c3c !important; }
