/* =========================================================================
   Optics Lab / Optická dílna — interactive telescope explainer
   Dark TechTools house style (indigo / violet / electric cyan), mobile-first,
   no framework. Shares the Education-tool shell (hero, sticky section-nav,
   .doc sections) with quantization / how-ai-works; adds the lab stage.
   ========================================================================= */

: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;

    /* scene colours (also used by the SVG) */
    --ray:       #fbbf24;      /* light: warm amber, reads as "light" on dark */
    --ray-ghost: #22d3ee;
    --ray-block: #f87171;
    --glass:     rgba(56, 189, 248, 0.22);
    --glass-edge:#bae6fd;
    --mirror:    #e2e8f0;
    --axis:      rgba(243, 244, 248, 0.32);

    --grad:      linear-gradient(135deg, #818cf8 0%, #22d3ee 52%, #fbbf24 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 82% -8%, rgba(251, 191, 36, 0.09), transparent 60%),
        radial-gradient(900px 560px at 4% 2%, rgba(99, 102, 241, 0.14), transparent 58%),
        radial-gradient(1000px 700px at 50% 120%, rgba(34, 211, 238, 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; }
button { font-family: inherit; }
.grad {
    background: var(--grad);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
}
[hidden] { display: none !important; }

/* Dark-theme <option>s never inherit the select background — set explicitly
   (literal hex). Recurring white-on-white bug; do NOT remove. */
select option { background-color: #1a1a24; color: #ffffff; }

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

/* ===================== 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-grid {
    position: absolute; inset: 0; z-index: 0; pointer-events: none; opacity: 0.5;
    background-image:
        linear-gradient(rgba(99, 102, 241, 0.10) 1px, transparent 1px),
        linear-gradient(90deg, rgba(251, 191, 36, 0.08) 1px, transparent 1px);
    background-size: 34px 34px;
    -webkit-mask-image: radial-gradient(closest-side at 50% 30%, #000 35%, transparent 78%);
    mask-image: radial-gradient(closest-side at 50% 30%, #000 35%, transparent 78%);
}
.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: #fde68a;
    padding: 0.4rem 0.9rem; border-radius: 999px;
    background: rgba(251, 191, 36, 0.10);
    border: 1px solid rgba(251, 191, 36, 0.30);
}
.hero-title { font-size: clamp(2.05rem, 7.2vw, 3.9rem); 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: 760px; 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(--ray); }
.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); }

/* ===================== 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.55rem 0.9rem; min-height: 44px; display: inline-flex; align-items: center;
    border-radius: 999px; border: 1px solid transparent;
    transition: background .2s, color .2s, border-color .2s;
}
.sec-chip:hover { color: var(--text); background: var(--panel); }
.sec-chip.active { color: #fff; background: var(--panel-2); border-color: var(--border-2); }

/* ===================== DOC SHELL ===================== */
.doc { max-width: var(--maxw); margin: 0 auto; padding: 0 1rem 4rem; }
.sec { padding: clamp(2rem, 5vw, 3.4rem) 0; border-bottom: 1px solid var(--border); }
.sec:last-of-type { border-bottom: 0; }
.sec-head { margin-bottom: 1.1rem; }
.sec-kicker {
    display: inline-block; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
    color: var(--sky); margin-bottom: 0.5rem;
}
.sec-head h2 { font-size: clamp(1.5rem, 4.2vw, 2.25rem); font-weight: 800; }
.sub-h { font-size: 1.15rem; font-weight: 700; margin: 2rem 0 0.7rem; }
.prose { color: var(--text-2); font-size: 1.02rem; max-width: 820px; }
.prose p + p { margin-top: 0.9rem; }
.prose strong { color: var(--text); font-weight: 700; }
.prose em { color: #fde68a; font-style: normal; font-weight: 600; }
.prose a { color: var(--sky); }
.prose h3 { color: var(--text); font-size: 1.12rem; margin: 1.6rem 0 0.5rem; }
.phys sub { font-size: 0.72em; }

/* ===================== LAB SHELL ===================== */
.lab-shell {
    margin-top: 1.4rem;
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-xl);
    padding: 1rem; box-shadow: var(--shadow);
}
.type-tabs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
.type-tab {
    display: flex; flex-direction: column; align-items: flex-start; gap: 0.15rem;
    min-height: 56px; padding: 0.6rem 0.8rem; text-align: left;
    background: var(--inset); color: var(--text-2); border: 1px solid var(--border); border-radius: var(--r-md);
    cursor: pointer; font-size: 0.95rem; font-weight: 700; transition: border-color .2s, background .2s, color .2s;
}
.type-tab i { color: var(--sky); margin-right: 0.35rem; }
.type-tab small { font-weight: 500; font-size: 0.76rem; color: var(--text-3); }
.type-tab:hover { border-color: var(--border-2); color: var(--text); }
.type-tab[aria-selected="true"] { background: rgba(99, 102, 241, 0.16); border-color: rgba(129, 140, 248, 0.6); color: #fff; }
.type-short { margin: 0.8rem 0 0.4rem; color: var(--text-2); font-size: 0.95rem; }

/* stage */
.stage-wrap { margin-top: 0.8rem; }
.stage-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.9rem; margin-bottom: 0.5rem; }
.tb-group { display: inline-flex; align-items: center; gap: 0.3rem; flex-wrap: wrap; }
.tb-label { font-size: 0.8rem; color: var(--text-3); margin-right: 0.15rem; }
.tb-btn {
    min-width: 44px; min-height: 44px; padding: 0 0.7rem;
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
    background: var(--inset); color: var(--text-2); border: 1px solid var(--border); border-radius: var(--r-sm);
    cursor: pointer; font-size: 0.85rem; font-weight: 600;
}
.tb-btn:hover { color: var(--text); border-color: var(--border-2); }
.tb-btn.active { color: #fff; border-color: rgba(129, 140, 248, 0.6); background: rgba(99, 102, 241, 0.16); }
.tb-readout { font-family: var(--mono); font-size: 0.85rem; color: var(--text-2); min-width: 3.2em; text-align: center; }
.tb-note { width: 100%; font-size: 0.78rem; color: var(--text-3); }

.stage {
    position: relative;
    background:
        radial-gradient(700px 300px at 50% 50%, rgba(99, 102, 241, 0.08), transparent 70%),
        var(--inset);
    border: 1px solid var(--border); border-radius: var(--r-lg);
    overflow: hidden;
}
.scene { display: block; width: 100%; height: 440px; touch-action: none; user-select: none; -webkit-user-select: none; }
.scene.zoomed { cursor: grab; }
.scene.dragging { cursor: grabbing; }
.stage-empty {
    position: absolute; inset: auto 1rem 1rem 1rem;
    background: rgba(248, 113, 113, 0.12); border: 1px solid rgba(248, 113, 113, 0.5); border-radius: var(--r-md);
    padding: 0.7rem 0.9rem; font-size: 0.9rem; color: #fecaca;
}

/* SVG parts (classes set by the renderer) */
.scene text { fill: var(--text); font-family: 'Inter', sans-serif; font-size: 12px; pointer-events: none; }
.scene .lbl-small { font-size: 11px; fill: var(--text-2); }
.scene .lbl-strong { font-weight: 700; }
.scene .axis { stroke: var(--axis); stroke-width: 1; stroke-dasharray: 6 5; }
.scene .tube { fill: rgba(255, 255, 255, 0.025); stroke: rgba(255, 255, 255, 0.16); stroke-width: 1; }
.scene .lens { fill: var(--glass); stroke: var(--glass-edge); stroke-width: 1.4; }
.scene .lens.absent { fill: none; stroke-dasharray: 4 4; opacity: 0.35; }
.scene .mirror { fill: none; stroke: var(--mirror); stroke-width: 3; stroke-linecap: round; }
.scene .mirror-back { fill: none; stroke: rgba(226, 232, 240, 0.28); stroke-width: 8; stroke-linecap: round; }
.scene .ray { fill: none; stroke: var(--ray); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.scene .ray-ghost { fill: none; stroke: var(--ray-ghost); stroke-width: 1.6; stroke-dasharray: 5 5; }
.scene .ray-blocked { fill: none; stroke: var(--ray-block); stroke-width: 1.8; stroke-dasharray: 3 4; }
.scene .ray-vignetted { fill: none; stroke: var(--ray-block); stroke-width: 1.6; stroke-dasharray: 2 5; opacity: 0.85; }
.scene .blocked-mark { fill: none; stroke: var(--ray-block); stroke-width: 1.6; }
.scene .arrow { fill: var(--ray); }
.scene .arrow.ghost { fill: var(--ray-ghost); }
.scene .focus-mark { fill: none; stroke: var(--ray-ghost); stroke-width: 1.6; }
.scene .focus-mark.real { stroke: #fde68a; }
.scene .focal-plane { stroke: rgba(34, 211, 238, 0.5); stroke-width: 1; stroke-dasharray: 2 4; }
.scene .dim { fill: none; stroke: rgba(243, 244, 248, 0.45); stroke-width: 1; }
.scene .eye { fill: none; stroke: var(--text-2); stroke-width: 1.5; }
.scene .eye-pupil { fill: var(--text-2); }
.scene .pulse { fill: #fff; stroke: var(--ray); stroke-width: 1.5; }
.scene .elem { cursor: pointer; }
.scene .elem .hit { fill: transparent; stroke: transparent; }
.scene .elem:hover .lens, .scene .elem:focus .lens, .scene .elem:focus-visible .lens { fill: rgba(56, 189, 248, 0.42); stroke-width: 2.2; }
.scene .elem:hover .mirror, .scene .elem:focus .mirror { stroke: #fff; stroke-width: 4; }
.scene .elem:focus { outline: none; }
.scene .elem:focus-visible .hit { stroke: var(--sky); stroke-width: 2; stroke-dasharray: 4 3; }
.scene .elem-label { font-size: 12px; font-weight: 700; fill: #e0f2fe; }
.scene .elem-tip { font-size: 10px; fill: var(--sky); }

.legend { display: flex; flex-wrap: wrap; gap: 0.6rem 1.1rem; margin-top: 0.6rem; font-size: 0.82rem; color: var(--text-2); }
.lg { display: inline-flex; align-items: center; gap: 0.5rem; }
.sw { display: inline-block; width: 26px; height: 0; border-top: 2px solid var(--ray); }
.sw-ghost { border-top-style: dashed; border-color: var(--ray-ghost); }
.sw-blocked { border-top-style: dotted; border-color: var(--ray-block); }
.sw-axis { border-top-style: dashed; border-color: var(--axis); }
.sw-arrow { width: 0; height: 0; border-top: 6px solid transparent; border-bottom: 6px solid transparent; border-left: 12px solid var(--ray); }

.part-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-top: 0.7rem; }
.part-btn {
    min-height: 44px; padding: 0 0.9rem; display: inline-flex; align-items: center; gap: 0.45rem;
    background: var(--inset); color: var(--text-2); border: 1px solid var(--border); border-radius: 999px;
    cursor: pointer; font-size: 0.86rem; font-weight: 600;
}
.part-btn:hover { color: var(--text); border-color: var(--border-2); }
.part-btn i { color: var(--sky); }

/* controls */
.controls { display: grid; grid-template-columns: 1fr; gap: 0.8rem; margin-top: 1rem; }
.ctl-group { border: 1px solid var(--border); border-radius: var(--r-md); padding: 0.7rem 0.9rem 0.9rem; margin: 0; min-width: 0; background: var(--inset); }
.ctl-group legend { font-size: 0.76rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); padding: 0 0.4rem; }
.ctl + .ctl { margin-top: 0.8rem; }
.ctl-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.6rem; font-size: 0.9rem; font-weight: 600; }
.ctl-head label { color: var(--text); }
.ctl-val { font-family: var(--mono); font-size: 0.85rem; color: var(--text-2); white-space: nowrap; }
.ctl-val b { color: #fde68a; font-weight: 600; }
.ctl-sub { font-size: 0.8rem; color: var(--text-3); margin-top: 0.35rem; }
.rng { width: 100%; margin: 0.45rem 0 0; accent-color: var(--indigo); height: 44px; cursor: pointer; background: transparent; }
.sel {
    width: 100%; margin-top: 0.45rem; min-height: 44px; padding: 0.5rem 0.7rem;
    background: var(--panel-2); color: var(--text); border: 1px solid var(--border-2); border-radius: var(--r-sm);
    font-family: inherit; font-size: 0.95rem;
}
.ctl-row { display: block; }
.switch { display: flex; align-items: center; gap: 0.7rem; min-height: 44px; cursor: pointer; font-size: 0.92rem; font-weight: 600; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { flex: 0 0 auto; width: 44px; height: 26px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--border-2); position: relative; transition: background .2s; }
.switch-dot { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--text-2); transition: transform .2s, background .2s; }
.switch input:checked + .switch-track { background: rgba(99, 102, 241, 0.5); border-color: rgba(129, 140, 248, 0.7); }
.switch input:checked + .switch-track .switch-dot { transform: translateX(18px); background: #fff; }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--sky); outline-offset: 2px; }
.play-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.btn-primary, .btn-ghost {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    min-height: 44px; padding: 0 1.1rem; border-radius: 999px; text-decoration: none;
    font-size: 0.92rem; font-weight: 700; cursor: pointer; border: 1px solid transparent;
}
.btn-primary { background: var(--grad-acc); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--inset); color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--border-2); }
.btn-ghost:disabled, .btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

/* readouts */
.readouts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.5rem; margin-top: 1rem; }
.ro { background: var(--inset); border: 1px solid var(--border); border-radius: var(--r-md); padding: 0.6rem 0.75rem; min-width: 0; }
.ro-k { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); }
.ro-v { font-family: var(--mono); font-size: 1.15rem; font-weight: 600; color: #fde68a; margin-top: 0.15rem; word-break: break-word; }
.ro-v.bad { color: var(--red); }
.ro-s { font-size: 0.78rem; color: var(--text-3); margin-top: 0.1rem; }
.status { margin-top: 0.7rem; font-size: 0.92rem; color: var(--text-2); }
.status.warn { color: #fde68a; }
.status.error { color: #fecaca; }

/* steps */
.steps { margin-top: 1.2rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.steps-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem; }
.step-chips { display: flex; gap: 0.35rem; }
.step-chip {
    width: 44px; height: 44px; border-radius: 50%; font-weight: 800; font-size: 1rem;
    background: var(--inset); color: var(--text-2); border: 1px solid var(--border); cursor: pointer;
}
.step-chip:hover { color: var(--text); border-color: var(--border-2); }
.step-chip.active { background: var(--grad-acc); color: #fff; border-color: transparent; }
.step-box { margin-top: 0.8rem; background: var(--inset); border: 1px solid var(--border); border-radius: var(--r-md); padding: 0.9rem 1rem; }
.step-box h3 { font-size: 1.02rem; }
.step-box p { margin-top: 0.4rem; color: var(--text-2); font-size: 0.95rem; }

/* detail */
.detail { margin-top: 1.2rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.detail-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem; }
.detail-head h3 { font-size: 1.15rem; }
.detail-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; margin-top: 0.8rem; }
.detail-stage { background: var(--inset); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 0.6rem; }
.detail-svg { height: 320px; touch-action: auto; }
.detail-ctl { margin-top: 0.4rem; }
.detail-readouts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.45rem; margin-bottom: 0.8rem; }
.detail-svg .glass { fill: var(--glass); stroke: var(--glass-edge); stroke-width: 1.5; }
.detail-svg .normal { stroke: #f0abfc; stroke-width: 1; stroke-dasharray: 4 3; }
.detail-svg .cc { fill: #f0abfc; }
.detail-svg .ray { fill: none; stroke: var(--ray); stroke-width: 1.4; opacity: 0.55; }
.detail-svg .ray.hi { opacity: 1; stroke-width: 2.4; }
.detail-svg .arc { fill: none; stroke: #fde68a; stroke-width: 1.4; }
.detail-svg .arc2 { fill: none; stroke: #86efac; stroke-width: 1.4; }
.detail-svg .ang { font-size: 11px; fill: #fde68a; font-weight: 700; }
.detail-svg .ang2 { font-size: 11px; fill: #86efac; font-weight: 700; }
.detail-svg .mirror { fill: none; stroke: var(--mirror); stroke-width: 3.5; stroke-linecap: round; }
.detail-svg .mirror-back { fill: rgba(226, 232, 240, 0.12); stroke: none; }
.detail-svg .fmark { fill: none; stroke: #fde68a; stroke-width: 1.5; }
.detail-svg .vmark { fill: none; stroke: var(--ray-ghost); stroke-width: 1.5; stroke-dasharray: 3 3; }
.detail-svg .lbl { font-size: 11px; fill: var(--text-2); }
.detail-svg .medium { fill: rgba(56, 189, 248, 0.05); }

/* ===================== TYPES ===================== */
.types-grid { display: grid; grid-template-columns: 1fr; gap: 0.7rem; margin-top: 1.2rem; }
.type-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 1rem 1.1rem; }
.type-card h3 { font-size: 1.08rem; display: flex; align-items: center; gap: 0.5rem; }
.type-card h3 i { color: var(--sky); }
.type-card p { color: var(--text-2); font-size: 0.93rem; margin-top: 0.5rem; }
.type-card .tc-meta { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.7rem; }
.type-card .tc-meta span { font-size: 0.76rem; padding: 0.25rem 0.6rem; border-radius: 999px; background: var(--inset); border: 1px solid var(--border); color: var(--text-2); }
.type-card .tc-meta span.erect { color: #86efac; border-color: rgba(34, 197, 94, 0.4); }
.type-card .tc-meta span.inverted { color: #fdba74; border-color: rgba(245, 158, 11, 0.4); }
.type-card button { margin-top: 0.8rem; }
.table-wrap { overflow-x: auto; margin-top: 1.2rem; -webkit-overflow-scrolling: touch; }
.cmp { width: 100%; border-collapse: collapse; font-size: 0.86rem; min-width: 640px; }
.cmp th, .cmp td { text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.cmp th { color: var(--text-3); font-weight: 700; font-size: 0.74rem; letter-spacing: 0.08em; text-transform: uppercase; }
.cmp td:first-child { color: var(--text-3); font-weight: 600; white-space: nowrap; }
.cmp td code { color: #fde68a; }

/* ===================== GALILEO ===================== */
.gal-intro { display: grid; grid-template-columns: 1fr; gap: 1.2rem; align-items: start; margin-top: 0.4rem; }
.gal-portrait { margin: 0; background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 0.6rem; }
.gal-portrait img { width: 100%; height: auto; display: block; border-radius: var(--r-md); cursor: zoom-in; }
.gal-portrait figcaption { font-size: 0.8rem; color: var(--text-3); margin-top: 0.5rem; }
.gal-portrait .kind { display: inline-block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #fde68a; margin-bottom: 0.25rem; }
.chapters { display: grid; grid-template-columns: 1fr; gap: 0.8rem; }
.chapter-list { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.ch-btn {
    min-height: 44px; padding: 0 0.9rem; border-radius: 999px; font-size: 0.86rem; font-weight: 600; cursor: pointer;
    background: var(--inset); color: var(--text-2); border: 1px solid var(--border); display: inline-flex; align-items: center; gap: 0.4rem;
}
.ch-btn:hover { color: var(--text); border-color: var(--border-2); }
.ch-btn.active { background: rgba(99, 102, 241, 0.16); border-color: rgba(129, 140, 248, 0.6); color: #fff; }
.chapter-panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 1rem 1.1rem; }
.chapter-panel h3 { font-size: 1.12rem; }
.chapter-panel p { color: var(--text-2); margin-top: 0.5rem; }
.chapter-panel figure { margin: 0.8rem 0 0; }
.chapter-panel figure img { width: 100%; max-width: 520px; height: auto; border-radius: var(--r-md); display: block; cursor: zoom-in; }
.chapter-panel figcaption { font-size: 0.78rem; color: var(--text-3); margin-top: 0.35rem; }
.chapter-panel .btn-primary { margin-top: 0.9rem; }
.timeline { list-style: none; padding: 0; margin: 0.6rem 0 0; border-left: 2px solid var(--border-2); }
.tl-item { position: relative; padding: 0.15rem 0 0.15rem 1.1rem; }
.tl-item::before { content: ''; position: absolute; left: -6px; top: 1.1rem; width: 10px; height: 10px; border-radius: 50%; background: var(--panel); border: 2px solid var(--sky); }
.tl-item.open::before { background: var(--sky); }
.tl-btn { width: 100%; text-align: left; background: none; border: 0; color: var(--text); padding: 0.55rem 0.4rem; min-height: 44px; cursor: pointer; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.3rem 0.8rem; border-radius: var(--r-sm); }
.tl-btn:hover { background: var(--panel); }
.tl-date { font-family: var(--mono); font-size: 0.78rem; color: #fde68a; min-width: 8.5em; }
.tl-title { font-weight: 700; font-size: 0.95rem; }
.tl-text { color: var(--text-2); font-size: 0.92rem; padding: 0 0.4rem 0.6rem 0.4rem; }
.instruments { display: grid; grid-template-columns: 1fr; gap: 0.7rem; margin-top: 0.6rem; }
.inst { background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 0.9rem 1rem; display: grid; grid-template-columns: 1fr; gap: 0.7rem; }
.inst img { width: 100%; height: auto; border-radius: var(--r-md); display: block; cursor: zoom-in; }
.inst h4 { font-size: 1rem; }
.inst .specs { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.5rem; }
.inst .specs span { font-family: var(--mono); font-size: 0.76rem; padding: 0.22rem 0.55rem; border-radius: 999px; background: var(--inset); border: 1px solid var(--border); color: var(--text-2); }
.inst p { color: var(--text-2); font-size: 0.9rem; margin-top: 0.5rem; }
.inst .btn-primary { margin-top: 0.7rem; }

/* ===================== GALLERY ===================== */
.gallery { display: grid; grid-template-columns: 1fr; gap: 0.8rem; margin-top: 1.2rem; }
.gfig { margin: 0; background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.gfig button { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.gfig img { display: block; width: 100%; height: 220px; object-fit: cover; }
.gfig figcaption { padding: 0.7rem 0.9rem 0.9rem; }
.gfig .gt { font-weight: 700; font-size: 0.95rem; }
.gfig .gc { color: var(--text-2); font-size: 0.86rem; margin-top: 0.3rem; }
.gfig .gcr { color: var(--text-3); font-size: 0.75rem; margin-top: 0.4rem; }
.gfig .gcr a { color: var(--sky); }
.gfig .kind { display: inline-block; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #fde68a; margin-right: 0.4rem; }

.lightbox { position: fixed; inset: 0; z-index: calc(var(--tt-z-modal, 1000) + 10); background: rgba(3, 3, 6, 0.94); display: flex; flex-direction: column; }
.lb-scroll { flex: 1; overflow: auto; display: flex; align-items: center; justify-content: center; padding: 0.5rem; }
.lb-scroll img { max-width: 100%; max-height: 100%; object-fit: contain; transition: transform .2s; }
.lightbox.zoomed .lb-scroll { align-items: flex-start; justify-content: flex-start; }
.lightbox.zoomed .lb-scroll img { max-width: none; max-height: none; width: 200%; }
.lb-close { position: absolute; top: 0.6rem; right: 0.6rem; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border-2); background: var(--panel); color: #fff; font-size: 1.1rem; cursor: pointer; }
.lb-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem; padding: 0.6rem 0.9rem; border-top: 1px solid var(--border); background: var(--bg-2); }
.lb-caption { font-size: 0.85rem; color: var(--text-2); flex: 1 1 260px; }

/* ===================== FAQ ===================== */
.faq-list { margin-top: 1rem; display: grid; gap: 0.5rem; max-width: 860px; }
.faq-item { background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-md); padding: 0 1rem; }
.faq-item summary { cursor: pointer; font-weight: 700; padding: 0.85rem 0; min-height: 44px; display: flex; align-items: center; list-style: none; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::before { content: '+'; font-family: var(--mono); color: var(--sky); margin-right: 0.7rem; font-weight: 700; width: 1em; }
.faq-item[open] summary::before { content: '−'; }
.faq-item p { color: var(--text-2); padding: 0 0 1rem 1.7em; font-size: 0.95rem; }

/* ===================== API ===================== */
.api-pre { margin: 1rem 0 0; padding: 0.9rem 1rem; background: var(--inset); border: 1px solid var(--border); border-radius: var(--r-md); overflow-x: auto; font-family: var(--mono); font-size: 0.8rem; color: #e0f2fe; line-height: 1.6; }
.api-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.recap-cta { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.4rem; }

.doc-foot { padding: 2rem 0 0; color: var(--text-3); font-size: 0.85rem; }
.doc-foot a { color: var(--sky); }
.credits { margin-top: 1rem; display: grid; gap: 0.25rem; font-size: 0.78rem; }
.credits a { color: var(--sky); }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 480px) {
    .scene { height: 360px; }
    .type-tab { font-size: 0.88rem; }
    .gfig img { height: 190px; }
}
@media (min-width: 640px) {
    .type-tabs { grid-template-columns: repeat(4, 1fr); }
    .readouts { grid-template-columns: repeat(3, 1fr); }
    .gallery { grid-template-columns: repeat(2, 1fr); }
    .instruments { grid-template-columns: repeat(3, 1fr); }
    .types-grid { grid-template-columns: repeat(2, 1fr); }
    .detail-readouts { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 900px) {
    .controls { grid-template-columns: 1.3fr 1fr 0.9fr; }
    .readouts { grid-template-columns: repeat(4, 1fr); }
    .scene { height: 480px; }
    .detail-grid { grid-template-columns: 1.25fr 1fr; }
    .gal-intro { grid-template-columns: 300px 1fr; }
    .chapters { grid-template-columns: 240px 1fr; }
    .chapter-list { flex-direction: column; align-items: stretch; }
    .ch-btn { justify-content: flex-start; }
    .gallery { grid-template-columns: repeat(3, 1fr); }
    .types-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    * { transition: none !important; }
}
