/* AI Classifier: TechTools dark theme, mobile-first.
   House tokens (SPZ set) + the result tokens from the build spec. */
:root {
    --primary-bg: #0a0a0f;
    --secondary-bg: #141419;
    --card-bg: #1a1a24;
    --border-color: rgba(255, 255, 255, 0.1);
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.5);
    --ok: #22c55e;
    --warn: #f59e0b;
    --err: #ef4444;
    /* results */
    --verdict: #a5b4fc;
    --track: rgba(255, 255, 255, 0.10);
    --seg-muted: rgba(255, 255, 255, 0.22);
    --unsure: #f59e0b;
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 1rem;
    --transition-base: 0.3s ease;
    --tt-topnav-h: 64px; /* seeded; tt-navbar.js publishes the exact value */
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* The hidden attribute must ALWAYS win: classes below set display:flex/grid. */
[hidden] { display: none !important; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--primary-bg);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: clip; /* never overflow-x:hidden, it breaks position:sticky */
    -webkit-text-size-adjust: 100%;
}

.app {
    max-width: 1180px;
    margin: 0 auto;
    padding: var(--spacing-lg) 16px 64px;
    overflow-x: clip;
}

a { color: #a78bfa; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

[id] { scroll-margin-top: calc(var(--tt-topnav-h, 64px) + 12px); }

/* ============ hero ============ */
.hero { margin-bottom: var(--spacing-lg); }

.eyebrow {
    color: var(--accent-secondary);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.hero h1 {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin-bottom: 10px;
}

.hero-sub {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.55;
    max-width: 62ch;
}

/* ============ examples ============ */
.examples { margin-bottom: var(--spacing-lg); }

.ex-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 6px;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    mask-image: linear-gradient(to right, #000 92%, transparent 100%);
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex: none;
    min-height: 44px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--secondary-bg);
    color: var(--text-secondary);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.chip i { color: var(--accent-secondary); font-size: 13px; }
.chip:hover { border-color: rgba(255, 255, 255, 0.25); color: var(--text-primary); }
.chip[aria-pressed="true"] {
    background: var(--accent-gradient);
    border-color: transparent;
    color: #fff;
}
.chip[aria-pressed="true"] i { color: #fff; }

/* ============ workspace ============ */
.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--spacing-lg);
    align-items: start;
}

.panel { min-width: 0; }

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-sm);
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.panel-title {
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.panel-title .sep, .sep { color: var(--text-muted); }
#qCount { color: var(--text-secondary); font-weight: 500; }

.panel-actions { display: flex; gap: 6px; }

/* ---- text panel ---- */
.text-area {
    width: 100%;
    min-height: 190px;
    max-height: 60vh;
    resize: vertical;
    padding: 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 16px; /* 16px stops iOS focus zoom */
    line-height: 1.55;
}

.text-area:focus { border-color: var(--accent-primary); outline: none; }
/* Keyboard focus must stay visible: the border tint alone is too quiet. */
.text-area:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 2px; }

.text-under {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--spacing-sm);
    margin-top: 6px;
    min-height: 20px;
}

.text-count {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}
.text-count.warn { color: var(--warn); }
.text-count.over { color: var(--err); font-weight: 700; }

.linkish {
    display: inline-flex;
    align-items: center;
    min-height: 44px;   /* tap target, even for a text-styled control */
    background: none;
    border: 0;
    padding: 0;
    color: #a78bfa;
    font: inherit;
    font-size: 13px;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
    text-align: left;
}

.hint {
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.5;
    margin-top: 8px;
}

.hint-warn { color: var(--warn); }
.hint-warn i { margin-right: 4px; }

.privacy-line {
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.5;
    margin-top: 10px;
}
.privacy-line i { color: var(--text-secondary); margin-right: 4px; }

/* ============ buttons ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 44px;
    padding: 0.6rem 1.1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--secondary-bg);
    color: var(--text-primary);
    font: inherit;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: filter var(--transition-base), transform 0.1s ease;
}
.btn:hover { filter: brightness(1.25); }
.btn:active { transform: scale(0.99); }
.btn-primary { background: var(--accent-gradient); border-color: transparent; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-sm { font-size: 13px; padding: 0.4rem 0.7rem; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; filter: none; }
.btn-danger { color: var(--err); }
.btn-danger:hover, .btn-danger:focus-visible { border-color: var(--err); }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex: none;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.06); color: var(--text-primary); }
.icon-btn.danger:hover, .icon-btn.danger:focus-visible { color: var(--err); }

.btn-add { width: 100%; margin-top: var(--spacing-md); border-style: dashed; }

/* ============ question cards ============ */
.q-list { display: grid; gap: 10px; }

.q-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 12px;
    min-width: 0;
}
.q-card.open { border-color: rgba(139, 92, 246, 0.55); }
.q-card.collapsed { cursor: pointer; }
.q-card.stale .ans { opacity: 0.45; }
.q-card.stale { border-style: dashed; }
.q-card.invalid { border-color: rgba(239, 68, 68, 0.6); }

.q-head {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: space-between;
}

.q-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary);
    min-width: 0;
}
.q-badge i { color: var(--accent-secondary); font-size: 13px; }

.q-actions { display: flex; gap: 2px; flex: none; }

.q-text {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    margin-top: 8px;
    overflow-wrap: anywhere;
}
.q-text.placeholder { color: var(--text-muted); font-weight: 500; }

.q-summary { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

.slot {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 56px;
    margin-top: 10px;
    padding: 10px 12px;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 14px;
}
.slot i { color: var(--text-muted); }
.slot.loading { animation: shimmer 1.1s ease-in-out infinite; }
@keyframes shimmer { 0%, 100% { opacity: 0.4; } 50% { opacity: 0.85; } }

/* ---- segmented type control ---- */
.seg {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    margin-top: 10px;
    padding: 4px;
    background: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.seg-opt {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 6px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    min-width: 0;
}
.seg-opt i { font-size: 13px; }
.seg-opt span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seg-opt[aria-checked="true"] { background: var(--accent-gradient); color: #fff; }

.seg-help { color: var(--text-muted); font-size: 13px; margin-top: 6px; }

/* ---- editor fields ---- */
.field-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 12px 0 4px;
}
.field-count { color: var(--text-muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.field-count.over { color: var(--err); }

.inp, .q-input {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--secondary-bg);
    color: var(--text-primary);
    font: inherit;
    font-size: 16px;
    line-height: 1.45;
}
.inp:focus, .q-input:focus { border-color: var(--accent-primary); outline: none; }
.inp:focus-visible, .q-input:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 2px; }
/* The sticky run button must never hide the field being typed in. */
.q-card, .inp, .q-input, .text-area { scroll-margin-bottom: 96px; }
.inp[aria-invalid="true"], .q-input[aria-invalid="true"] { border-color: var(--err); }

.q-input { resize: none; overflow: hidden; }

.err-msg { color: var(--err); font-size: 13px; margin-top: 4px; }

.rules-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    background: none;
    border: 0;
    padding: 0;
    color: #a78bfa;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.row-list { display: grid; gap: 8px; margin-top: 4px; }

.opt-row, .lvl-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    gap: 6px;
    align-items: start;
}
.opt-row .opt-fields { display: grid; gap: 6px; min-width: 0; }

.lvl-row { grid-template-columns: 22px minmax(0, 1fr) 44px 44px 44px; align-items: center; }
.lvl-num { color: var(--text-muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.presets { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.preset-label { color: var(--text-muted); font-size: 13px; }

.card-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
}

/* ============ results ============ */
.ans { margin-top: 12px; }

.ans-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.verdict {
    font-size: 24px;
    font-weight: 800;
    color: var(--verdict);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    overflow-wrap: anywhere;
}
.verdict.unsure { color: var(--unsure); }
.verdict-sm { font-size: 18px; font-weight: 800; color: var(--verdict); }

.figure { font-family: 'JetBrains Mono', monospace; font-size: 14px; color: var(--text-muted); }

.conf-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    flex: none;
}
.conf-chip i { color: var(--accent-primary); }
.conf-chip.low i { color: var(--unsure); }

.conf-pop {
    margin-top: 8px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--secondary-bg);
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.55;
}

.bar {
    position: relative;
    height: 10px;
    border-radius: 5px;
    background: var(--track);
    overflow: hidden;
    margin-top: 10px;
    display: flex;
}
.bar-seg { height: 100%; transform-origin: left center; }
.bar-win { background: var(--accent-gradient); }
.bar-lose { background: var(--seg-muted); }
.bar-tick {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(255, 255, 255, 0.45);
}

.bar-legend {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.rows { display: grid; gap: 8px; margin-top: 10px; }

.opt-line {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}
.opt-name {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary);
    overflow-wrap: anywhere;
}
.row-win .opt-name { font-size: 18px; font-weight: 800; color: var(--verdict); }
.row-win .opt-name i { color: var(--verdict); margin-right: 6px; }
.opt-pct { font-size: 14px; font-variant-numeric: tabular-nums; color: var(--text-secondary); flex: none; }
.row-win .opt-pct { color: var(--verdict); font-weight: 700; }

.mini-bar {
    height: 6px;
    border-radius: 3px;
    background: var(--track);
    overflow: hidden;
    margin-top: 5px;
}
.mini-fill { height: 100%; background: var(--seg-muted); transform-origin: left center; }
.row-win .mini-fill { background: var(--accent-gradient); }

.track-wrap { margin-top: 14px; }
.track {
    position: relative;
    height: 10px;
    border-radius: 5px;
    background: var(--track);
}
.track-fill {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    border-radius: 5px;
    background: var(--accent-gradient);
    transform-origin: left center;
}
.track-tick {
    position: absolute;
    top: 50%;
    width: 6px;
    height: 6px;
    margin-left: -3px;
    margin-top: -3px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
}
.track-tick.on { width: 10px; height: 10px; margin-left: -5px; margin-top: -5px; background: var(--accent-secondary); }
.marker {
    position: absolute;
    top: 50%;
    width: 16px;
    height: 16px;
    margin-left: -8px;
    margin-top: -8px;
    border-radius: 50%;
    background: var(--accent-primary);
    border: 3px solid #fff;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}

.track-labels {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 12px;
}
.track-labels span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ans-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.muted-line { color: var(--text-muted); font-size: 13px; margin-top: 6px; line-height: 1.5; }
.warn-line { color: var(--warn); font-size: 13px; margin-top: 6px; line-height: 1.5; }

.chip-note {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--warn);
    border: 1px solid rgba(245, 158, 11, 0.4);
    border-radius: 999px;
    padding: 3px 9px;
    margin-top: 8px;
}
.chip-note.neutral { color: var(--text-secondary); border-color: var(--border-color); }

/* ============ run button, banners, quota ============ */
.run-error, .stale-banner, .link-banner {
    margin-top: var(--spacing-md);
    padding: 12px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--secondary-bg);
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.55;
}
.run-error { border-color: rgba(239, 68, 68, 0.5); color: #fecaca; }
.stale-banner { border-color: rgba(245, 158, 11, 0.4); color: #fde68a; }
.banner-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.run-wrap {
    position: sticky;
    /* --run-lift is set at runtime to clear a bottom-pinned overlay (the AdSense
       anchor unit on phones would otherwise sit on top of the primary button). */
    bottom: calc(12px + env(safe-area-inset-bottom) + var(--run-lift, 0px));
    /* No z-index on purpose: a positioned element already paints above the
       non-positioned cards, and any literal value here fails check-navbar E5
       (this is in-panel chrome that must stay UNDER the navbar, not an overlay). */
    margin-top: var(--spacing-md);
    /* The button floats over the answer cards: fade them out behind it so
       nothing reads through the rounded corners. */
    padding: 14px 0 6px;
    background: linear-gradient(to bottom, rgba(10, 10, 15, 0) 0%, var(--primary-bg) 40%);
}
.run-wrap.kb-open { display: none; }

.btn-run {
    width: 100%;
    min-height: 56px;
    font-size: 16px;
    box-shadow: 0 8px 24px rgba(10, 10, 15, 0.75);
}
/* The run button is sticky, so the shared .btn[disabled] opacity would let the
   cards scroll straight through it. Keep it opaque and say "disabled" in colour. */
.btn-run[disabled] {
    opacity: 1;
    background: #20202c;
    border-color: var(--border-color);
    color: var(--text-muted);
}
.btn-run[disabled] i { color: var(--text-muted); }
.kbd {
    display: none;
    margin-left: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 500;
    opacity: 0.8;
}

.quota-line {
    min-height: 20px;
    margin-top: 10px;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.5;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

/* ============ result footer ============ */
.result-footer { margin-top: var(--spacing-md); }
.result-meta { color: var(--text-muted); font-size: 13px; margin-bottom: 8px; }
.footer-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.hint-ps { font-size: 12px; }

.raw-details { margin-top: 10px; }
.raw-details summary {
    cursor: pointer;
    min-height: 44px;
    display: flex;
    align-items: center;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
}
.raw-details pre { margin-top: 8px; }

.api-code {
    background: #0d0d14;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    overflow-x: auto;
    max-width: 100%;
}
.api-code code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    line-height: 1.55;
    color: #c9d1e3;
    white-space: pre;
}

/* ============ facts ============ */
.facts {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--spacing-md);
    margin-top: 56px;
}
.fact {
    background: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: var(--spacing-lg);
}
.fact i { color: var(--accent-primary); font-size: 1.3rem; margin-bottom: 0.6rem; display: block; }
.fact p { color: var(--text-secondary); font-size: 14px; line-height: 1.6; }
.fact strong { color: var(--text-primary); display: block; margin-bottom: 4px; }

/* ============ long-form sections ============ */
.content-section { margin-top: 56px; }
.content-section h2 { font-size: 24px; font-weight: 700; margin-bottom: 10px; }
.content-section h2 i { color: var(--accent-primary); margin-right: 6px; }
.content-section > p { color: #a1a1aa; font-size: 15px; line-height: 1.7; }
.content-section a { color: #a78bfa; text-decoration: underline; text-underline-offset: 2px; }
.content-section a:hover { color: #c4b5fd; }
.content-section code {
    background: rgba(139, 92, 246, 0.15);
    color: #c4b5fd;
    padding: 2px 6px;
    border-radius: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85em;
}

.steps {
    list-style: none;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    margin-top: 20px;
}
.step {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
}
.step-num {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--accent-gradient);
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 12px;
}
.step h3 { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.step p { font-size: 14px; color: #a1a1aa; line-height: 1.6; }

.two-lists {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    margin-top: 16px;
}
.list-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 18px;
}
.list-card h3 { font-size: 15px; font-weight: 700; margin-bottom: 10px; }
.list-card h3 i { color: var(--accent-primary); margin-right: 6px; }
.list-card:last-child h3 i { color: var(--warn); }

.plain-list { list-style: none; display: grid; gap: 8px; }
.plain-list li {
    position: relative;
    padding-left: 18px;
    color: #a1a1aa;
    font-size: 14px;
    line-height: 1.6;
}
.plain-list li::before {
    content: '';
    position: absolute;
    left: 0; top: 9px;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--accent-gradient);
}

/* ============ API section ============ */
.api-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
}
.api-title { font-size: 22px; display: flex; align-items: center; gap: 0.5rem; }
.api-title i { color: var(--accent-primary); }
.api-intro { color: var(--text-secondary); font-size: 14px; line-height: 1.6; margin-bottom: var(--spacing-lg); }

.api-key-panel {
    background: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}
.key-line {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: var(--spacing-md);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.key-line:last-child { margin-bottom: 0; }
.key-prefix {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    color: var(--text-primary);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.15rem 0.4rem;
    word-break: break-all;
}
.key-box {
    display: flex; align-items: center; gap: var(--spacing-md); flex-wrap: wrap;
    background: rgba(99, 102, 241, 0.08);
    border: 1px dashed var(--accent-primary);
    border-radius: var(--radius-md);
    padding: 0.7rem 1rem;
    margin-bottom: var(--spacing-md);
}
.key-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    word-break: break-all;
    flex: 1;
    min-width: 160px;
}
.key-meta { color: var(--text-muted); font-size: 13px; margin-bottom: var(--spacing-md); }
.key-meta b { color: var(--text-primary); }
.key-warn { color: var(--warn); font-size: 13px; margin-bottom: var(--spacing-md); line-height: 1.55; }
.key-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.api-docs h4 { margin: var(--spacing-lg) 0 var(--spacing-sm); font-size: 14px; display: flex; align-items: center; gap: 0.5rem; }
.api-step {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border-radius: 50%; flex: none;
    background: var(--accent-gradient); font-size: 12px; font-weight: 700;
}
.api-errors { list-style: none; }
.api-errors li { color: var(--text-secondary); font-size: 13px; padding: 0.25rem 0; line-height: 1.5; }
.api-errors code, .api-note code {
    background: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.1rem 0.35rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
}
.api-note { color: var(--text-secondary); font-size: 14px; line-height: 1.6; margin-top: var(--spacing-md); }
/* Standalone link, not inline prose: keep it a real 44px tap target. */
.api-note a { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; }

/* ============ FAQ ============ */
.faq-list { display: grid; gap: 10px; margin-top: 16px; }
.faq-item {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    overflow: hidden;
}
.faq-item summary {
    list-style: none;
    cursor: pointer;
    min-height: 52px;
    padding: 14px 48px 14px 18px;
    display: flex;
    align-items: center;
    position: relative;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.4;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
    content: '+';
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: #a78bfa;
    font-size: 22px;
    line-height: 1;
}
.faq-item[open] summary::after { content: '\2212'; }
.faq-answer { padding: 0 18px 16px; }
.faq-answer p { color: #a1a1aa; font-size: 14px; line-height: 1.7; }

/* ============ toasts ============ */
.toasts {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
    pointer-events: none;
    z-index: calc(var(--tt-z-toast, 1100) + 10);
}
.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 440px;
    width: 100%;
    pointer-events: auto;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--accent-primary);
    border-radius: var(--radius-md);
    padding: 0.7rem 1rem;
    font-size: 14px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
    animation: toast-in 0.25s ease;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
.toast span { flex: 1; min-width: 0; }
.toast button {
    flex: none;
    min-height: 44px;
    padding: 0 10px;
    background: none;
    border: 0;
    color: #a78bfa;
    font: inherit;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ============ dialogs (top layer: no z-index needed) ============ */
.aic-dialog {
    border: 0;
    padding: 0;
    color: var(--text-primary);
    background: var(--card-bg);
    width: 100%;
    max-width: 100%;
    max-height: 85dvh;
    margin: auto auto 0;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.6);
}
.aic-dialog::backdrop { background: rgba(5, 5, 10, 0.72); }
.aic-dialog[open] { display: flex; flex-direction: column; }

.dlg-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 14px 12px 10px 18px;
    border-bottom: 1px solid var(--border-color);
}
.dlg-head h2 { font-size: 17px; font-weight: 700; }
.dlg-body { padding: 16px 18px; overflow-y: auto; }
.dlg-foot {
    display: flex;
    gap: 8px;
    padding: 12px 18px calc(16px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
}
.dlg-foot-split { justify-content: space-between; align-items: center; }

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
}
.check-row input { width: 20px; height: 20px; accent-color: var(--accent-primary); }

.share-field {
    width: 100%;
    min-height: 44px;
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--secondary-bg);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
}

.hist-list { display: grid; gap: 10px; }
.hist-row {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    background: var(--secondary-bg);
}
.hist-when { color: var(--text-muted); font-size: 12px; }
.hist-text { font-size: 14px; margin-top: 4px; overflow-wrap: anywhere; }
.hist-chips { color: var(--verdict); font-size: 13px; margin-top: 6px; overflow-wrap: anywhere; }
.hist-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

/* ============ 600px and up ============ */
@media (min-width: 600px) {
    .app { padding: var(--spacing-xl) 24px 72px; }
    .chips { flex-wrap: wrap; overflow: visible; mask-image: none; }
    .opt-row .opt-fields { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .steps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .two-lists { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .aic-dialog {
        max-width: 560px;
        margin: auto;
        border-radius: 18px;
    }
    .dlg-side { max-width: 420px; }
}

/* ============ 960px and up ============ */
@media (min-width: 960px) {
    .hero { text-align: center; }
    .hero h1 { font-size: 36px; }
    .hero-sub { margin: 0 auto; }
    .examples { text-align: center; }
    .chips { justify-content: center; }
    .workspace { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; }
    .text-panel { position: sticky; top: calc(var(--tt-topnav-h, 64px) + 16px); }
    .text-area { min-height: 320px; }
    .kbd { display: inline; }
}

/* ============ motion ============ */
@media (prefers-reduced-motion: no-preference) {
    .bar-seg, .mini-fill, .track-fill {
        animation: grow-x 420ms cubic-bezier(.2, .8, .2, 1) both;
    }
    .marker { animation: slide-in 420ms cubic-bezier(.2, .8, .2, 1) both; }
    @keyframes grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }
    @keyframes slide-in { from { left: 0; } }
    html { scroll-behavior: smooth; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
    .slot.loading { opacity: 0.5; }
    html { scroll-behavior: auto; }
}

/* If a <select> is ever added here, the dark-theme option fix must come with it:
   select option { background-color: #1a1a24; color: #ffffff; } */

/* ---- pieces rendered by script.js ---- */
.editor { margin-top: 4px; }
.rules-body { margin-top: 4px; }
.conf-wrap { flex: none; max-width: 100%; }
.lint-tip { margin-top: 6px; }
.opt-row-res { min-width: 0; }
.ans-host { min-width: 0; }

/* Rating labels: every label at 960px+ when there are 5 or fewer, ends only below that. */
@media (max-width: 959px) {
    .track-labels.all span:not(:first-child):not(:last-child) { display: none; }
}
@media (min-width: 960px) {
    .track-labels.all span { flex: 1 1 0; text-align: center; min-width: 0; }
    .track-labels.all span:first-child { text-align: left; }
    .track-labels.all span:last-child { text-align: right; }
}

/* .content-section code paints an inline chip; code inside a <pre> block must stay plain. */
.api-code code {
    background: none;
    border: 0;
    padding: 0;
    color: #c9d1e3;
    border-radius: 0;
}
