/* =========================================================================
   How AI Works — interactive educational tool
   Dark TechTools house style (indigo / violet / electric cyan).
   Mobile-first. No framework. Shares the rag-vectors shell + adds widgets:
   timeline, gradient-descent, artificial neuron, n-gram predictor, tokenizer.
   ========================================================================= */

:root {
    /* Seed the shared navbar height (published live by tt-navbar.js) */
    --tt-topnav-h: 64px;

    --bg:        #07070b;
    --bg-2:      #0e0e15;
    --panel:     #14141d;
    --panel-2:   #1a1a26;
    --inset:     #101019;
    --border:    rgba(255, 255, 255, 0.09);
    --border-2:  rgba(255, 255, 255, 0.14);

    --text:      #f3f4f8;
    --text-2:    rgba(243, 244, 248, 0.72);
    --text-3:    rgba(243, 244, 248, 0.48);

    --indigo:    #6366f1;
    --violet:    #8b5cf6;
    --green:     #22c55e;
    --amber:     #f59e0b;
    --cyan:      #06b6d4;
    --pink:      #d946ef;
    --red:       #f87171;
    --sky:       #38bdf8;

    /* per-era accents (history timeline) */
    --era-birth:  #38bdf8;
    --era-rise:   #a78bfa;
    --era-winter: #64748b;
    --era-ml:     #f59e0b;
    --era-deep:   #22c55e;
    --era-llm:    #e879f9;

    --grad:      linear-gradient(135deg, #818cf8 0%, #22d3ee 52%, #c084fc 100%);
    --grad-acc:  linear-gradient(135deg, var(--indigo), var(--violet));

    --r-sm: 8px;
    --r-md: 14px;
    --r-lg: 20px;
    --r-xl: 26px;

    --sp: 1rem;
    --maxw: 1080px;

    --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    --shadow: 0 18px 50px -20px rgba(0, 0, 0, 0.7);
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--tt-topnav-h) + 64px); }

body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background:
        radial-gradient(1100px 620px at 80% -8%, rgba(34, 211, 238, 0.12), transparent 60%),
        radial-gradient(900px 560px at 6% 2%, rgba(99, 102, 241, 0.14), transparent 58%),
        radial-gradient(1000px 700px at 50% 120%, rgba(139, 92, 246, 0.10), transparent 60%),
        var(--bg);
    color: var(--text);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overflow-x: clip; /* never break position:sticky (navbar-v2 lesson) */
}

h1, h2, h3, h4 { line-height: 1.2; margin: 0; letter-spacing: -0.02em; }
p { margin: 0; }
a { color: inherit; }
code { font-family: var(--mono); font-size: 0.88em; }
.grad {
    background: var(--grad);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
}
.nowrap { white-space: nowrap; }

/* ===================== HERO ===================== */
.hero {
    position: relative;
    padding: clamp(2.6rem, 7vw, 5.2rem) 1.1rem clamp(1.4rem, 4vw, 2.4rem);
    text-align: center;
    overflow: hidden;
}
.hero-inner { max-width: 880px; margin: 0 auto; position: relative; z-index: 1; }
.hero-eyebrow {
    display: inline-flex; align-items: center; gap: 0.5rem;
    font-size: 0.78rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
    color: #a5f3fc;
    padding: 0.4rem 0.9rem; border-radius: 999px;
    background: rgba(34, 211, 238, 0.10);
    border: 1px solid rgba(34, 211, 238, 0.30);
}
.hero-title {
    font-size: clamp(2.15rem, 7.6vw, 4rem);
    font-weight: 900; margin: 1.1rem 0 0.9rem;
}
.hero-sub {
    font-size: clamp(1rem, 2.6vw, 1.2rem);
    color: var(--text-2); max-width: 680px; margin: 0 auto;
}
.hero-chips {
    list-style: none; padding: 0; margin: 1.6rem 0 0;
    display: flex; flex-wrap: wrap; gap: 0.55rem; justify-content: center;
}
.hero-chips li {
    display: inline-flex; align-items: center; gap: 0.45rem;
    font-size: 0.86rem; font-weight: 600; color: var(--text-2);
    padding: 0.45rem 0.85rem; border-radius: 999px;
    background: var(--panel); border: 1px solid var(--border);
}
.hero-chips i { color: var(--cyan); }
.hero-hint {
    margin-top: 1.6rem; font-size: 0.92rem; color: var(--text-3);
    display: inline-flex; align-items: center; gap: 0.5rem;
}
.hero-hint i { color: var(--amber); }

/* faint neural grid behind the hero */
.hero-bg {
    position: absolute; inset: 0; z-index: 0; pointer-events: none;
    opacity: 0.5;
    -webkit-mask-image: radial-gradient(closest-side at 50% 35%, #000 40%, transparent 78%);
    mask-image: radial-gradient(closest-side at 50% 35%, #000 40%, transparent 78%);
}

/* ===================== SECTION NAV ===================== */
.section-nav {
    position: sticky; top: var(--tt-topnav-h); z-index: 90;
    background: rgba(7, 7, 11, 0.84);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
.section-nav-inner {
    max-width: var(--maxw); margin: 0 auto;
    display: flex; gap: 0.4rem; padding: 0.6rem 0.8rem;
    overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none;
    scroll-snap-type: x proximity;
}
.section-nav-inner::-webkit-scrollbar { display: none; }
.sec-chip {
    flex: 0 0 auto; scroll-snap-align: start;
    text-decoration: none; white-space: nowrap;
    font-size: 0.85rem; font-weight: 600; color: var(--text-2);
    padding: 0.45rem 0.85rem; border-radius: 999px;
    border: 1px solid transparent;
    transition: color 0.18s, background 0.18s, border-color 0.18s;
}
.sec-chip:hover { color: var(--text); background: var(--panel); }
.sec-chip.active {
    color: #fff; background: rgba(34, 211, 238, 0.14);
    border-color: rgba(34, 211, 238, 0.45);
}

/* ===================== DOC LAYOUT ===================== */
.doc { max-width: var(--maxw); margin: 0 auto; padding: 1rem 1.1rem 4rem; }
.sec { padding: clamp(2.2rem, 6vw, 3.6rem) 0; border-bottom: 1px solid var(--border); }
.sec:last-of-type { border-bottom: none; }
.sec-head { margin-bottom: 1.4rem; }
.sec-kicker {
    display: inline-block; font-size: 0.74rem; font-weight: 700;
    letter-spacing: 0.12em; text-transform: uppercase; color: var(--cyan);
    margin-bottom: 0.5rem;
}
.sec-head h2 { font-size: clamp(1.5rem, 4.4vw, 2.15rem); font-weight: 800; }

.prose { font-size: 1.04rem; color: var(--text-2); max-width: 720px; }
.prose p + p { margin-top: 0.9rem; }
.prose strong, .prose-note strong, .mini-card strong, .recap-list strong { color: var(--text); font-weight: 700; }
.prose code, .prose-note code, .mini-card code, .info-card code, .recap-list code, .block-sub code, .formula-note code {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    padding: 0.08em 0.4em; border-radius: 6px; color: #cffafe;
}
.prose-note {
    margin-top: 1.3rem; font-size: 0.96rem; color: var(--text-2);
    padding: 0.9rem 1.1rem; border-left: 3px solid var(--cyan);
    background: rgba(34, 211, 238, 0.06); border-radius: 0 var(--r-sm) var(--r-sm) 0;
    max-width: 760px;
}
.block-h { font-size: 1.18rem; font-weight: 700; margin: 2rem 0 0.4rem; }
.block-sub { font-size: 0.98rem; color: var(--text-2); margin-bottom: 1.1rem; max-width: 740px; }

/* ===================== BIG IDEA ROW ===================== */
.bigidea {
    display: grid; grid-template-columns: 1fr; gap: 0.8rem;
    margin: 1.6rem 0 0;
}
.bigidea-arrow { display: none; color: var(--text-3); text-align: center; font-size: 1.2rem; }
.bigidea-step {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--r-md); padding: 1.2rem;
}
.bi-ico {
    width: 46px; height: 46px; border-radius: 12px;
    display: grid; place-items: center; font-size: 1.2rem; color: #fff;
    background: color-mix(in srgb, var(--c) 26%, transparent);
    border: 1px solid color-mix(in srgb, var(--c) 55%, transparent);
    margin-bottom: 0.8rem;
}
.bi-ico i { color: var(--c); }
.bigidea-step h3 { font-size: 1.02rem; margin-bottom: 0.3rem; }
.bigidea-step p { font-size: 0.92rem; color: var(--text-2); }

/* ===================== CARD GRID ===================== */
.card-grid { display: grid; grid-template-columns: 1fr; gap: 0.9rem; margin-top: 0.4rem; }
.info-card {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--r-md); padding: 1.2rem;
    transition: transform 0.2s var(--ease), border-color 0.2s, background 0.2s;
}
.info-card:hover { transform: translateY(-3px); border-color: var(--border-2); }
.info-card.accent {
    background: linear-gradient(160deg, rgba(34, 211, 238, 0.13), rgba(139, 92, 246, 0.06));
    border-color: rgba(34, 211, 238, 0.36);
}
.ic-ico {
    width: 42px; height: 42px; border-radius: 11px;
    display: grid; place-items: center; font-size: 1.05rem;
    background: rgba(99, 102, 241, 0.14); color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.3); margin-bottom: 0.75rem;
}
.ic-ico.c-sup { background: rgba(34,197,94,0.14); color: #86efac; border-color: rgba(34,197,94,0.3); }
.ic-ico.c-uns { background: rgba(34,211,238,0.14); color: #67e8f9; border-color: rgba(34,211,238,0.3); }
.ic-ico.c-rl  { background: rgba(245,158,11,0.14); color: #fcd34d; border-color: rgba(245,158,11,0.3); }
.info-card.accent .ic-ico { background: rgba(34, 211, 238, 0.2); color: #a5f3fc; }
.info-card h4 { font-size: 1.02rem; margin-bottom: 0.35rem; }
.info-card p { font-size: 0.92rem; color: var(--text-2); }
.info-card .eg { display: block; margin-top: 0.55rem; font-size: 0.84rem; color: var(--text-3); }
.info-card .eg b { color: var(--text-2); font-weight: 600; }

/* ===================== CALLOUT ===================== */
.callout {
    display: flex; gap: 1rem; align-items: flex-start;
    margin-top: 1.6rem; padding: 1.2rem 1.3rem;
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-md);
}
.callout.warn { background: rgba(245, 158, 11, 0.07); border-color: rgba(245, 158, 11, 0.32); }
.callout.tip  { background: rgba(34, 211, 238, 0.07); border-color: rgba(34, 211, 238, 0.30); }
.callout-ico { font-size: 1.3rem; color: var(--indigo); flex: 0 0 auto; margin-top: 0.15rem; }
.callout.warn .callout-ico { color: var(--amber); }
.callout.tip .callout-ico { color: var(--cyan); }
.callout h4 { font-size: 1.02rem; margin-bottom: 0.3rem; }
.callout p { font-size: 0.95rem; color: var(--text-2); }

/* ===================== TWO COLUMN ===================== */
.two-col { display: grid; grid-template-columns: 1fr; gap: 0.9rem; margin-top: 1.4rem; }
.mini-card {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--r-md); padding: 1.15rem 1.2rem;
}
.mini-card h4 { font-size: 1rem; margin-bottom: 0.45rem; display: flex; align-items: center; gap: 0.5rem; }
.mini-card h4 i { color: var(--cyan); }
.mini-card p { font-size: 0.94rem; color: var(--text-2); }
.mini-card em { color: #a5f3fc; font-style: italic; }

/* ===================== CODE BLOCK ===================== */
.code-block {
    margin: 1.2rem 0; border-radius: var(--r-md); overflow: hidden;
    border: 1px solid var(--border); background: #0c0c14;
}
.code-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.6rem 0.95rem; background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--border);
    font-family: var(--mono); font-size: 0.8rem; color: var(--text-2);
}
.code-head i { color: var(--cyan); }
.code-copy {
    background: transparent; border: 1px solid var(--border); color: var(--text-2);
    border-radius: 7px; padding: 0.3rem 0.55rem; cursor: pointer; font-size: 0.8rem;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.code-copy:hover { color: #fff; border-color: var(--border-2); background: rgba(255,255,255,0.05); }
.code-copy.copied { color: var(--green); border-color: rgba(34,197,94,0.4); }
.code-block pre { margin: 0; padding: 1.1rem 1.2rem; overflow-x: auto; }
.code-block code { font-family: var(--mono); font-size: 0.86rem; color: #d7def5; line-height: 1.7; white-space: pre; }

/* ===================== WIDGET SHELL ===================== */
.widget {
    margin: 1.2rem 0 0.4rem;
    background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 100%);
    border: 1px solid var(--border-2); border-radius: var(--r-lg);
    padding: 1.1rem; box-shadow: var(--shadow);
}
.widget-toolbar { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.widget-cap { font-size: 0.86rem; color: var(--text-3); margin-bottom: 0.9rem; display: flex; align-items: center; gap: 0.45rem; }
.widget-cap i { color: var(--amber); }
.seg {
    display: inline-flex; align-items: center; gap: 0.45rem;
    font-family: inherit; font-size: 0.88rem; font-weight: 600;
    color: var(--text-2); cursor: pointer;
    background: var(--inset); border: 1px solid var(--border);
    border-radius: 999px; padding: 0.5rem 0.95rem;
    transition: all 0.18s var(--ease); min-height: 44px;
}
.seg:hover { color: var(--text); border-color: var(--border-2); }
.seg.active { color: #fff; background: var(--grad-acc); border-color: transparent; box-shadow: 0 6px 18px -8px var(--indigo); }
.seg small { font-weight: 500; opacity: 0.7; font-size: 0.72rem; }
.btn-run, .btn-mini {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    font-family: inherit; font-weight: 600; cursor: pointer;
    border-radius: 999px; min-height: 44px;
    transition: transform 0.15s, box-shadow 0.2s, border-color 0.15s, background 0.15s, color 0.15s;
}
.btn-run {
    margin-top: 1rem; font-size: 0.9rem; color: #fff;
    background: var(--grad-acc); border: none; padding: 0.6rem 1.2rem;
    box-shadow: 0 8px 22px -10px var(--indigo);
}
.btn-run:hover { transform: translateY(-2px); }
.btn-run:active { transform: translateY(0); }
.btn-run[disabled] { opacity: 0.55; cursor: default; transform: none; }
.btn-mini {
    font-size: 0.84rem; color: var(--text-2);
    background: var(--inset); border: 1px solid var(--border); padding: 0.5rem 0.9rem;
}
.btn-mini:hover { color: #fff; border-color: var(--border-2); }
.btn-mini.primary { color: #fff; background: var(--grad-acc); border-color: transparent; box-shadow: 0 6px 18px -10px var(--indigo); }
.btn-mini.primary:hover { transform: translateY(-2px); }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }

/* ===================== TIMELINE ===================== */
.tl-legend { display: flex; flex-wrap: wrap; gap: 0.5rem 0.9rem; margin-bottom: 1rem; }
.tl-legend span { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.76rem; color: var(--text-2); }
.tl-legend i { width: 11px; height: 11px; border-radius: 50%; display: inline-block; background: var(--c); }
.tl-rail-wrap { position: relative; }
.tl-rail {
    display: flex; gap: 0.4rem; overflow-x: auto; padding: 1.4rem 0.2rem 0.7rem;
    scrollbar-width: none; -ms-overflow-style: none; scroll-snap-type: x proximity;
}
.tl-rail::-webkit-scrollbar { display: none; }
.tl-line { position: absolute; left: 0; right: 0; top: 1.85rem; height: 2px; background: linear-gradient(90deg, var(--era-birth), var(--era-rise), var(--era-winter), var(--era-ml), var(--era-deep), var(--era-llm)); opacity: 0.35; }
.tl-node {
    position: relative; flex: 0 0 auto; scroll-snap-align: center;
    display: flex; flex-direction: column; align-items: center; gap: 0.45rem;
    width: 78px; padding: 0.2rem; cursor: pointer; background: none; border: none;
    font-family: inherit; color: var(--text-3);
}
.tl-node .tl-year { font-family: var(--mono); font-size: 0.74rem; font-weight: 700; transition: color 0.18s; }
.tl-node .tl-dot {
    width: 16px; height: 16px; border-radius: 50%;
    background: var(--bg); border: 2px solid var(--c);
    transition: transform 0.18s var(--ease), box-shadow 0.18s, background 0.18s;
}
.tl-node .tl-tip { font-size: 0.68rem; text-align: center; line-height: 1.2; color: var(--text-3); max-width: 78px; }
.tl-node:hover .tl-dot { transform: scale(1.2); }
.tl-node:hover .tl-year { color: var(--text); }
.tl-node.active .tl-dot { background: var(--c); transform: scale(1.5); box-shadow: 0 0 0 5px color-mix(in srgb, var(--c) 22%, transparent); }
.tl-node.active .tl-year { color: #fff; }
.tl-node.active .tl-tip { color: var(--text-2); }
.tl-node:focus-visible { outline: none; }
.tl-node:focus-visible .tl-dot { box-shadow: 0 0 0 4px rgba(255,255,255,0.5); }
.tl-detail {
    margin-top: 0.9rem; padding: 1.3rem; border-radius: var(--r-md);
    background: var(--inset); border: 1px solid var(--border);
    border-left: 4px solid var(--c); min-height: 150px;
    display: grid; grid-template-columns: auto 1fr; gap: 0.6rem 1.1rem; align-items: start;
}
.tl-detail-ico {
    grid-row: span 2; width: 56px; height: 56px; border-radius: 14px;
    display: grid; place-items: center; font-size: 1.5rem; color: var(--c);
    background: color-mix(in srgb, var(--c) 18%, transparent);
    border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
}
.tl-detail-head { display: flex; align-items: baseline; gap: 0.7rem; flex-wrap: wrap; }
.tl-detail-year { font-family: var(--mono); font-size: 1.5rem; font-weight: 800; color: #fff; }
.tl-detail-era { font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--c); padding: 0.2rem 0.55rem; border-radius: 999px; background: color-mix(in srgb, var(--c) 16%, transparent); }
.tl-detail-title { grid-column: 2; font-size: 1.12rem; font-weight: 800; color: var(--text); margin-top: -0.2rem; }
.tl-detail-sig { grid-column: 2; font-size: 0.97rem; color: var(--text-2); }
.tl-controls { display: flex; align-items: center; justify-content: center; gap: 0.7rem; margin-top: 1rem; }
.tl-step { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; background: var(--inset); border: 1px solid var(--border); color: var(--text-2); transition: all 0.15s; }
.tl-step:hover { color: #fff; border-color: var(--border-2); }
.tl-counter { font-family: var(--mono); font-size: 0.82rem; color: var(--text-3); min-width: 3.4rem; text-align: center; }

/* ===================== GRADIENT DESCENT ===================== */
.gd-grid { display: grid; grid-template-columns: 1fr; gap: 1.1rem; }
.gd-stage { background: var(--inset); border: 1px solid var(--border); border-radius: var(--r-md); padding: 0.5rem; }
.gd-svg { width: 100%; height: auto; display: block; }
.gd-ball { transition: cx 0.45s var(--ease), cy 0.45s var(--ease); filter: drop-shadow(0 0 6px var(--amber)); }
.gd-panel { display: flex; flex-direction: column; }
.gd-readrow { display: flex; gap: 1.2rem; flex-wrap: wrap; margin-bottom: 0.9rem; }
.gd-stat { display: flex; flex-direction: column; }
.gd-stat .lbl { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-3); }
.gd-stat .val { font-family: var(--mono); font-size: 1.4rem; font-weight: 700; color: var(--text); }
.gd-lr-row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 0.4rem; }
.gd-lr-row .lbl { font-size: 0.82rem; color: var(--text-2); font-weight: 600; }
.gd-lr-val { font-family: var(--mono); font-weight: 700; color: var(--amber); }
.gd-slider, .nu-slider {
    -webkit-appearance: none; appearance: none; width: 100%; height: 8px; border-radius: 999px;
    background: linear-gradient(90deg, var(--cyan), var(--green) 45%, var(--amber) 75%, var(--red));
    outline: none;
}
.gd-slider::-webkit-slider-thumb, .nu-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 3px solid var(--violet); cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,0.4); }
.gd-slider::-moz-range-thumb, .nu-slider::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 3px solid var(--violet); cursor: pointer; }
.gd-slider:focus-visible, .nu-slider:focus-visible { outline: 2px solid var(--violet); outline-offset: 4px; }
.nu-slider { background: linear-gradient(90deg, var(--red), var(--text-3) 50%, var(--green)); }
.gd-verdict { font-size: 0.95rem; color: var(--text-2); margin: 0.9rem 0 0; min-height: 2.6em; padding: 0.7rem 0.9rem; border-radius: var(--r-sm); background: rgba(255,255,255,0.03); border: 1px solid var(--border); }
.gd-verdict b { color: var(--text); }
.gd-marks { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.7rem; }
.gd-mark { font-family: var(--mono); font-size: 0.78rem; font-weight: 600; cursor: pointer; color: var(--text-2); background: var(--inset); border: 1px solid var(--border); border-radius: 8px; padding: 0.4rem 0.7rem; min-height: 40px; transition: all 0.15s; }
.gd-mark:hover { color: #fff; border-color: var(--border-2); }

/* ===================== NEURON ===================== */
.nu-grid { display: grid; grid-template-columns: 1fr; gap: 1.1rem; align-items: center; }
.nu-inputs { display: flex; flex-direction: column; gap: 0.7rem; }
.nu-input {
    background: var(--inset); border: 1px solid var(--border); border-radius: var(--r-md);
    padding: 0.75rem 0.9rem;
}
.nu-input-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; margin-bottom: 0.5rem; }
.nu-toggle {
    display: inline-flex; align-items: center; gap: 0.5rem; cursor: pointer;
    font-size: 0.9rem; font-weight: 600; color: var(--text);
    background: none; border: none; font-family: inherit; padding: 0;
}
.nu-toggle .dot { width: 34px; height: 20px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--border-2); position: relative; transition: background 0.2s; flex: 0 0 auto; }
.nu-toggle .dot::after { content: ''; position: absolute; top: 1px; left: 1px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-3); transition: transform 0.2s, background 0.2s; }
.nu-toggle.on .dot { background: rgba(34,197,94,0.3); border-color: rgba(34,197,94,0.5); }
.nu-toggle.on .dot::after { transform: translateX(14px); background: var(--green); }
.nu-input .wlabel { font-family: var(--mono); font-size: 0.74rem; color: var(--text-3); }
.nu-input .wval { font-family: var(--mono); font-weight: 700; color: var(--violet); }
.nu-wrow { display: flex; align-items: center; gap: 0.7rem; }
.nu-wrow .nu-slider { flex: 1; }
.nu-contrib { font-family: var(--mono); font-size: 0.72rem; color: var(--text-3); margin-top: 0.35rem; }
.nu-core { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 0.7rem; }
.nu-svg { width: 100%; max-width: 280px; height: auto; }
.nu-sum { font-family: var(--mono); font-size: 0.92rem; color: var(--text-2); }
.nu-sum b { color: var(--text); font-size: 1.05rem; }
.nu-out {
    display: inline-flex; align-items: center; gap: 0.6rem;
    padding: 0.7rem 1.2rem; border-radius: 999px; font-weight: 700; font-size: 1rem;
    background: var(--inset); border: 1px solid var(--border); color: var(--text-3);
    transition: all 0.25s var(--ease);
}
.nu-out.fire { background: rgba(34,197,94,0.14); border-color: rgba(34,197,94,0.5); color: #86efac; box-shadow: 0 0 24px -6px rgba(34,197,94,0.6); }
.nu-out i { font-size: 1.1rem; }
.nu-thresh-row { display: flex; align-items: baseline; justify-content: space-between; width: 100%; max-width: 320px; margin-top: 0.3rem; }
.nu-thresh-row .lbl { font-size: 0.8rem; color: var(--text-2); }
.nu-thresh-val { font-family: var(--mono); font-weight: 700; color: var(--amber); }

/* ===================== N-GRAM PREDICTOR ===================== */
.ng-toolbar { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.4rem; }
.ng-info { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; font-family: var(--mono); font-size: 0.74rem; color: var(--text-3); margin: 0.3rem 0 1rem; }
.ng-info b { color: var(--text-2); }
.ng-context {
    background: var(--inset); border: 1px solid var(--border); border-radius: var(--r-md);
    padding: 1rem 1.1rem; font-size: 1.05rem; line-height: 1.8; min-height: 3.4em;
    color: var(--text); word-break: break-word;
}
.ng-context .w { transition: background 0.2s; }
.ng-context .ctx { background: rgba(34,211,238,0.18); border-radius: 4px; padding: 0 3px; box-shadow: inset 0 -2px 0 rgba(34,211,238,0.55); }
.ng-context .just { background: rgba(245,158,11,0.28); border-radius: 4px; padding: 0 3px; }
.ng-context .cursor { display: inline-block; width: 2px; height: 1.1em; vertical-align: text-bottom; background: var(--cyan); animation: blink 1s steps(2) infinite; margin-left: 2px; }
@keyframes blink { 50% { opacity: 0; } }
.ng-predict-label { font-size: 0.84rem; color: var(--text-3); margin: 1rem 0 0.6rem; display: flex; align-items: center; gap: 0.45rem; }
.ng-predict-label i { color: var(--cyan); }
.ng-bars { display: flex; flex-direction: column; gap: 0.4rem; }
.ng-bar {
    display: grid; grid-template-columns: minmax(74px, auto) 1fr auto; align-items: center; gap: 0.7rem;
    background: var(--inset); border: 1px solid var(--border); border-radius: var(--r-sm);
    padding: 0.45rem 0.7rem; cursor: pointer; font-family: inherit; color: var(--text);
    transition: border-color 0.15s, background 0.15s, transform 0.12s;
    text-align: left; width: 100%;
}
.ng-bar:hover { border-color: var(--border-2); transform: translateX(2px); }
.ng-bar.top { border-color: rgba(34,211,238,0.4); }
.ng-bar-word { font-family: var(--mono); font-weight: 700; font-size: 0.92rem; white-space: nowrap; }
.ng-bar.top .ng-bar-word { color: #67e8f9; }
.ng-bar-track { height: 9px; border-radius: 999px; background: rgba(255,255,255,0.07); overflow: hidden; }
.ng-bar-fill { height: 100%; border-radius: 999px; background: var(--grad-acc); width: 0; transition: width 0.4s var(--ease); }
.ng-bar.top .ng-bar-fill { background: linear-gradient(90deg, var(--cyan), var(--violet)); }
.ng-bar-pct { font-family: var(--mono); font-size: 0.78rem; color: var(--text-2); white-space: nowrap; }
.ng-empty { font-size: 0.92rem; color: var(--text-3); padding: 0.8rem 0.2rem; }
.ng-corpus-wrap { margin-top: 1.1rem; }
.ng-corpus-toggle { background: none; border: none; color: var(--text-2); font-family: inherit; font-size: 0.84rem; cursor: pointer; display: inline-flex; align-items: center; gap: 0.4rem; padding: 0; }
.ng-corpus-toggle:hover { color: #fff; }
.ng-corpus { margin-top: 0.6rem; font-size: 0.85rem; color: var(--text-3); line-height: 1.7; background: var(--inset); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 0.9rem 1rem; max-height: 200px; overflow-y: auto; }

/* ===================== TOKENIZER ===================== */
.tk-input {
    width: 100%; resize: vertical; min-height: 80px; font-family: inherit; font-size: 1rem;
    color: var(--text); background: var(--inset); border: 1px solid var(--border);
    border-radius: var(--r-md); padding: 0.9rem 1rem; line-height: 1.6;
}
.tk-input:focus { outline: none; border-color: rgba(34,211,238,0.5); }
.tk-stats { display: flex; flex-wrap: wrap; gap: 0.4rem 1.3rem; font-family: var(--mono); font-size: 0.78rem; color: var(--text-3); margin: 0.8rem 0; }
.tk-stats b { color: var(--cyan); font-size: 1.05rem; }
.tk-out { display: flex; flex-wrap: wrap; gap: 5px; min-height: 2.6em; }
.tk-tok {
    font-family: var(--mono); font-size: 0.86rem; padding: 0.28rem 0.5rem; border-radius: 6px;
    border: 1px solid transparent; white-space: pre;
}
.tk-tok.s { background: rgba(255,255,255,0.05); color: var(--text-3); }
.tk-tok-id { display: block; font-size: 0.6rem; text-align: center; color: var(--text-3); opacity: 0.7; margin-top: 2px; }
.tk-legend { font-size: 0.8rem; color: var(--text-3); margin-top: 0.8rem; }

/* ===================== "YOU PREDICT" MINI ===================== */
.guess-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.9rem; }
.guess-chip {
    font-family: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer;
    color: var(--text-2); background: var(--inset); border: 1px solid var(--border);
    border-radius: 999px; padding: 0.55rem 1rem; min-height: 44px; transition: all 0.15s;
}
.guess-chip:hover { color: #fff; border-color: var(--border-2); }
.guess-chip.right { background: rgba(34,197,94,0.16); border-color: rgba(34,197,94,0.5); color: #86efac; }
.guess-chip.wrong { background: rgba(248,113,113,0.14); border-color: rgba(248,113,113,0.45); color: #fca5a5; }
.guess-result { margin-top: 0.8rem; font-size: 0.94rem; color: var(--text-2); min-height: 1.6em; }
.guess-result b { color: var(--text); }

/* ===================== RECAP ===================== */
.recap-list { counter-reset: r; list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.7rem; }
.recap-list li {
    counter-increment: r; position: relative; padding: 0.85rem 1rem 0.85rem 3.2rem;
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-md);
    font-size: 0.98rem; color: var(--text-2);
}
.recap-list li::before {
    content: counter(r); position: absolute; left: 0.85rem; top: 0.85rem;
    width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
    font-family: var(--mono); font-weight: 700; font-size: 0.85rem; color: #fff;
    background: var(--grad-acc);
}
.next-cta {
    margin-top: 1.6rem; display: flex; gap: 1rem; align-items: center;
    background: linear-gradient(160deg, rgba(34,211,238,0.12), rgba(139,92,246,0.07));
    border: 1px solid rgba(34,211,238,0.32); border-radius: var(--r-md); padding: 1.2rem 1.3rem;
}
.next-cta .ic-ico { margin: 0; flex: 0 0 auto; }
.next-cta h4 { font-size: 1.05rem; margin-bottom: 0.2rem; }
.next-cta p { font-size: 0.92rem; color: var(--text-2); }
.next-cta a.more { color: #67e8f9; font-weight: 600; text-decoration: none; white-space: nowrap; }
.next-cta a.more:hover { text-decoration: underline; }

.recap-cta { display: flex; flex-wrap: wrap; gap: 0.7rem; margin-top: 1.6rem; }
.btn-primary, .btn-ghost {
    display: inline-flex; align-items: center; gap: 0.5rem; text-decoration: none;
    font-size: 0.92rem; font-weight: 600; padding: 0.65rem 1.2rem; border-radius: 999px;
    min-height: 44px; transition: transform 0.15s, border-color 0.15s, background 0.15s;
}
.btn-primary { color: #fff; background: var(--grad-acc); box-shadow: 0 8px 22px -10px var(--indigo); }
.btn-primary:hover { transform: translateY(-2px); }
.btn-ghost { color: var(--text-2); border: 1px solid var(--border); }
.btn-ghost:hover { color: #fff; border-color: var(--border-2); }

.doc-foot { margin-top: 2.4rem; padding-top: 1.4rem; border-top: 1px solid var(--border); }
.doc-foot p { font-size: 0.85rem; color: var(--text-3); max-width: 720px; }

/* ===================== RESPONSIVE ===================== */
@media (min-width: 720px) {
    .bigidea { grid-template-columns: 1fr auto 1fr auto 1fr; align-items: stretch; }
    .bigidea-arrow { display: grid; place-items: center; }
    .card-grid { grid-template-columns: repeat(3, 1fr); }
    .two-col { grid-template-columns: 1fr 1fr; }
    .gd-grid { grid-template-columns: 1.05fr 1fr; align-items: center; }
    .nu-grid { grid-template-columns: 1.1fr 1fr; align-items: center; }
}
@media (min-width: 1000px) {
    .quality-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Reduced motion / mobile perf */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
