:root {
  color-scheme: dark;
  --bg: #000; --panel: #141414; --panel2: #202020;
  --ink: #f5f5f5; --muted: #b1b1b1; --faint: #929292;
  --line: #292929; --accent: #ff318c; --accent-ink: #fff;
  --accent-solid: #df0064; --active: #2b0717;
  --blue: #d6d6d6; --gold: #e6bd73; --shadow: 0 24px 70px #0008;
  --head: 64px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 88px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.75 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body[data-theme=light] { color-scheme: light; --bg: #f7f7f7; --panel: #fff; --panel2: #f0f0f0; --ink: #171717; --muted: #555; --faint: #666; --line: #dedede; --accent: #b90052; --accent-solid: #c30058; --active: #fce8f1; --blue: #444; --gold: #86611b; --shadow: 0 24px 70px #0002; }
button, input { font: inherit; }
button { cursor: pointer; color: var(--ink); background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 9px 14px; font-size: 12px; font-weight: 600; line-height: 1.35; }
button:hover { border-color: var(--faint); background: var(--panel); }
button, a { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
a { color: var(--ink); text-underline-offset: 4px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { line-height: 1.25; letter-spacing: -.025em; }
h2 { font-size: 26px; font-weight: 650; margin-bottom: 15px; }
h3 { font-size: 18px; font-weight: 650; margin: 27px 0 12px; }
p { margin-bottom: 17px; }
strong { font-weight: 650; }
small, .small { font-size: 12px; color: var(--muted); }
[hidden] { display: none !important; }
.skip-link { position: fixed; left: 16px; top: -100px; z-index: 100; background: var(--accent-solid); color: #fff; padding: 8px 16px; }
.skip-link:focus { top: 15px; }
.topbar { height: var(--head); position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 0 28px; background: var(--bg); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-size: 18px; font-weight: 750; letter-spacing: -.025em; color: var(--ink); }
.brand small { display: block; font-size: 9px; letter-spacing: .12em; color: var(--muted); font-weight: 500; line-height: 1.5; }
.brand-mark { width: 32px; height: 32px; display: grid; place-items: center; background: var(--active); border: 1px solid #6d1339; border-radius: 6px; font-size: 22px; color: var(--accent); }
.top-actions { display: flex; align-items: center; gap: 12px; }
.desktop-meta { font-size: 10px; letter-spacing: .1em; color: var(--faint); }
#menu-toggle { display: none; }
.reading-progress { position: fixed; top: 0; left: 0; width: 100%; height: 2px; z-index: 30; pointer-events: none; }
.reading-progress span { display: block; height: 100%; background: var(--accent-solid); width: 0; }
.layout { max-width: 1440px; margin: auto; display: grid; grid-template-columns: 232px minmax(0,1fr); }
.sidebar { position: sticky; top: var(--head); height: calc(100dvh - var(--head)); padding: 26px 17px 20px; border-right: 1px solid var(--line); overflow-y: auto; scrollbar-width: thin; }
.sidebar h2 { font-size: 17px; margin-bottom: 20px; }
.sidebar nav { display: grid; gap: 2px; }
.sidebar nav a { display: block; padding: 6px 10px; border-radius: 5px; color: var(--muted); text-decoration: none; font-size: 12px; line-height: 1.55; }
.sidebar nav a:hover { color: var(--ink); background: var(--panel); }
.sidebar nav a.active { color: var(--accent); background: var(--active); font-weight: 600; }
.sidebar-foot { padding: 20px 10px; margin-top: 20px; border-top: 1px solid var(--line); font-size: 10px; color: var(--muted); }
main { min-width: 0; padding: 26px 36px 0; }
.hero { padding: 27px 28px 0; margin-bottom: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.hero-kicker { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; color: var(--faint); font-size: 9px; letter-spacing: .1em; }
.pill { background: var(--panel2); border: 1px solid var(--line); border-radius: 20px; padding: 4px 10px; color: var(--muted); }
h1 { font-size: clamp(30px,3.3vw,43px); font-weight: 650; margin: 19px 0 13px; }
h1 span { color: var(--ink); }
.hero-lead { font-size: 16px; max-width: 690px; color: var(--muted); line-height: 1.7; margin-bottom: 22px; }
.hero-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; }
.primary { display: inline-flex; gap: 26px; align-items: center; padding: 10px 19px; border-radius: 24px; background: linear-gradient(105deg,#e60064,#dd1c83); color: #fff; text-decoration: none; font-size: 13px; font-weight: 650; }
.primary:hover { color: #fff; filter: brightness(1.12); }
.secondary { padding: 9px 14px; border: 1px solid var(--line); border-radius: 6px; font-size: 12px; text-decoration: none; background: var(--panel2); }
.hero-bottom { margin-top: 24px; padding: 14px 0; border-top: 1px solid var(--line); display: flex; gap: 22px; flex-wrap: wrap; font-size: 9px; letter-spacing: .08em; color: var(--faint); }
.hero-bottom strong { color: var(--ink); }
.intro-strip { padding: 0 4px 24px; }
.intro-strip > p:first-child { font-size: 13px; max-width: 760px; margin-bottom: 11px; color: var(--muted); }
.intro-strip .small { font-size: 11px; margin: 12px 0 0; color: var(--faint); }
.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 10px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 5px; height: 5px; border-radius: 50%; display: inline-block; }
.obs { background: #b8b8b8; }.theory { background: var(--gold); }.interface { background: var(--accent); }
.eyebrow { font-size: 9px; line-height: 1.5; letter-spacing: .12em; color: var(--faint); font-weight: 600; margin-bottom: 12px; }
.lesson { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 28px; margin-bottom: 20px; scroll-margin-top: 88px; }
.lead { font-size: 16px; color: var(--muted); line-height: 1.65; margin-bottom: 22px; }
.section-heading { display: flex; gap: 14px; align-items: flex-start; }
.section-heading .eyebrow { margin-bottom: 6px; }
.section-heading h2 { margin-bottom: 16px; }
.chapter-number { flex: 0 0 32px; height: 32px; display: grid; place-items: center; margin-top: 2px; border: 1px solid var(--line); border-radius: 6px; color: var(--accent); font-size: 12px; font-variant-numeric: tabular-nums; background: var(--panel2); }
.two-col { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 22px; }
.three-col { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 22px; }
.two-col h3, .three-col h3 { margin-top: 5px; }
.two-col p, .three-col p { font-size: 14px; color: var(--muted); }
.stat-row { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; margin: 22px 0; }
.stat-row a { display: block; padding: 16px; text-decoration: none; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; }
.stat-row span { display: block; color: var(--faint); font-size: 9px; letter-spacing: .1em; }
.stat-row strong { display: block; font-size: 28px; letter-spacing: -.035em; font-weight: 550; line-height: 1.5; }
.stat-row small { font-size: 14px; margin-left: 3px; }
.stat-row a:hover { border-color: var(--accent); }
.table-wrap { overflow-x: auto; margin: 22px 0; border: 1px solid var(--line); border-radius: 6px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; line-height: 1.65; }
th { text-align: left; font-size: 9px; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); background: var(--panel2); padding: 12px 15px; }
td { padding: 10px 15px; border-top: 1px solid var(--line); color: var(--muted); }
td:first-child { color: var(--ink); font-weight: 550; }
.inline-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 20px 0; }
.note { padding: 18px 20px; margin: 22px 0; border: 1px solid var(--line); border-left: 2px solid #777; border-radius: 6px; background: var(--bg); }
.note .label { display: block; text-transform: uppercase; color: var(--faint); font-size: 8px; font-weight: 650; letter-spacing: .1em; margin-bottom: 7px; }
.note > strong { display: block; font-size: 15px; margin-bottom: 6px; }
.note p { font-size: 13px; color: var(--muted); margin: 0; }
.note.unverified-theory { border-left-color: var(--gold); }.note.unverified-theory .label { color: var(--gold); }
.note.observed-interface { border-left-color: var(--accent); }.note.observed-interface .label { color: var(--accent); }
/* Screenshots are reference figures. Intrinsic width and a preview height ceiling
   keep small interface captures from becoming full-width illustrations. */
figure.screenshot { margin: 23px 0; min-width: 0; }
.shot { display: flex; position: relative; align-items: center; justify-content: center; width: 100%; padding: 16px; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: #090909; }
.shot:hover { border-color: #666; background: #090909; }
.shot img { display: block; width: auto; height: auto; max-width: 100%; max-height: 420px; object-fit: contain; border-radius: 3px; }
.screenshot-portrait .shot img { max-height: 390px; }
.screenshot-controls .shot img { max-height: 420px; }
.screenshot-menu { width: min(100%,292px); }
.screenshot-menu .shot { padding: 0; width: 100%; }
.screenshot-menu .shot img { max-height: 434px; }
.zoom-hint { position: absolute; bottom: 8px; right: 8px; padding: 4px 7px; background: #111e; color: #d4d4d4; border: 1px solid #444; border-radius: 4px; font-size: 9px; font-weight: 500; opacity: 0; transition: opacity .15s; }
.shot:hover .zoom-hint, .shot:focus-visible .zoom-hint { opacity: 1; }
figcaption { display: block; padding: 10px 2px 0; font-size: 11px; line-height: 1.6; color: var(--faint); }
figcaption strong { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.structure-example { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,292px); gap: 28px; align-items: start; margin-top: 27px; padding-top: 24px; border-top: 1px solid var(--line); }
.structure-copy h3 { margin-top: 0; }
.structure-example figure.screenshot { margin: 0; }
.structure-copy > p { color: var(--muted); font-size: 14px; }
.structure-copy .small { font-size: 11px; }
.word-pair { align-items: start; gap: 16px; }
.word-pair figure.screenshot { margin-top: 0; }
.range-card { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); margin: 23px 0; border: 1px solid var(--line); border-radius: 6px; background: var(--panel2); }
.range-card > div { display: flex; gap: 14px; align-items: center; justify-content: space-between; padding: 18px; }
.range-card > div + div { border-left: 1px solid var(--line); }
.range-card span { font-size: 12px; color: var(--muted); }
.range-card strong { font-size: 24px; font-weight: 550; white-space: nowrap; }
.range-card > div:last-child strong { color: var(--accent); }
.source-line { font-size: 11px; color: var(--faint); padding-top: 13px; border-top: 1px solid var(--line); margin-top: 21px; }
.mini-label { font-size: 9px; letter-spacing: .1em; color: var(--faint); }
.tab-list { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; border: 1px solid var(--line); border-radius: 6px; margin-top: 23px; background: var(--bg); }
.tab-list button { flex: 1 1 auto; background: transparent; border-color: transparent; color: var(--muted); }
.tab-list button[aria-selected=true] { background: var(--panel2); border-color: var(--line); color: var(--ink); }
[role=tabpanel] { padding-top: 18px; }
[role=tabpanel] > p { font-size: 13px; color: var(--muted); }
.copy-box { padding: 17px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
.copy-box > button { display: block; margin-left: auto; }
.copy-box pre { white-space: pre-wrap; overflow-wrap: anywhere; font-family: inherit; font-size: 14px; line-height: 1.85; margin: 15px 0 0; }
.audio-status { display: flex; gap: 12px; padding: 18px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
.audio-status strong { font-size: 14px; }
.audio-status p { font-size: 12px; color: var(--muted); margin: 5px 0 0; }
.status-dot { width: 5px; height: 5px; display: inline-block; background: var(--accent); border-radius: 50%; flex-shrink: 0; margin-right: 5px; }
.audio-status .status-dot { margin-top: 11px; }
.gallery { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 22px; }
.gallery figure.screenshot { margin: 0; width: 100%; }
.gallery .shot { height: 190px; padding: 12px; }
.gallery .shot img { width: auto; height: auto; max-width: 100%; max-height: 164px; }
.next-chapters { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 20px; margin: 25px 0; }
.next-chapters > div { padding-top: 14px; border-top: 1px solid var(--line); }
.next-chapters span { font-size: 9px; color: var(--faint); letter-spacing: .08em; }
.next-chapters h3 { margin: 12px 0 10px; }
.next-chapters p { font-size: 13px; color: var(--muted); }
.lesson > p:last-child { margin-bottom: 0; }
footer { padding: 20px 4px 40px; }
footer .brand { font-size: 15px; margin-bottom: 15px; }
footer p { max-width: 670px; font-size: 11px; color: var(--faint); }
footer > a:last-child { font-size: 11px; }
dialog { width: 1100px; max-width: min(1100px,94vw); max-height: 94dvh; overflow: auto; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 20px; box-shadow: var(--shadow); }
dialog::backdrop { background: #000c; backdrop-filter: blur(4px); }
.dialog-top { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.dialog-top h2 { font-size: 18px; margin: 0; }
.dialog-top button { white-space: nowrap; }
#dialog-image { display: block; width: auto; height: auto; max-width: 100%; max-height: 72dvh; object-fit: contain; margin: auto; }
#image-caption { margin: 17px 0 7px; font-size: 12px; color: var(--muted); }
#original-image { font-size: 11px; }
#toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%,20px); background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 6px; font-size: 12px; z-index: 50; opacity: 0; pointer-events: none; transition: opacity .2s,transform .2s; }
#toast.visible { opacity: 1; transform: translate(-50%,0); }
@media (min-width:1300px) { main { padding-left: 48px; padding-right: 48px; } }
@media (max-width:1080px) {
  .layout { grid-template-columns: 210px minmax(0,1fr); }
  main { padding: 22px 24px 0; }.lesson { padding: 24px; }.hero { padding: 24px 24px 0; }
  .structure-example { grid-template-columns: minmax(0,1fr) minmax(0,240px); gap: 22px; }
  .range-card > div { flex-direction: column; align-items: flex-start; gap: 6px; }
  .stat-row { gap: 8px; }.stat-row a { padding: 13px; }.stat-row strong { font-size: 25px; }
}
@media (max-width:850px) {
  .layout { display: block; }.sidebar { display: none; }
  .sidebar.open { display: block; position: fixed; top: var(--head); left: 0; bottom: 0; width: min(320px,90vw); z-index: 19; background: var(--bg); box-shadow: var(--shadow); }
  #menu-toggle { display: block; }.desktop-meta { display: none; }
  main { max-width: 800px; margin: auto; }.topbar { padding: 0 20px; }
  .structure-example { grid-template-columns: minmax(0,1fr) minmax(0,260px); }
}
@media (max-width:600px) {
  body { font-size: 14px; }.topbar { padding: 0 14px; }.brand { font-size: 16px; }.brand small { font-size: 8px; }.brand-mark { width: 29px; height: 29px; }
  .top-actions { gap: 6px; }.top-actions button { padding: 8px 9px; font-size: 10px; }
  main { padding: 16px 12px 0; }.hero { padding: 21px 19px 0; }.lesson { padding: 21px 19px; margin-bottom: 14px; }
  h1 { font-size: 31px; }h2 { font-size: 23px; }h3 { font-size: 17px; }.hero-lead, .lead { font-size: 15px; }
  .hero-bottom { gap: 12px; font-size: 8px; letter-spacing: .03em; }.hero-actions { gap: 10px; }
  .legend { gap: 10px; }.legend span { font-size: 9px; }.intro-strip { padding: 0 5px 20px; }
  .section-heading { gap: 10px; }.section-heading .eyebrow { font-size: 8px; }.chapter-number { flex-basis: 28px; height: 28px; }
  .two-col, .three-col, .next-chapters { grid-template-columns: 1fr; gap: 13px; }
  .stat-row { grid-template-columns: repeat(2,minmax(0,1fr)); }.stat-row a { padding: 15px; }.stat-row strong { font-size: 28px; }
  .structure-example { grid-template-columns: 1fr; gap: 14px; }.structure-example figure.screenshot { width: min(100%,240px); justify-self: start; }
  .word-pair { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
  .shot { padding: 9px; }.shot img, .screenshot-controls .shot img { max-height: 330px; }.screenshot-portrait .shot img { max-height: 270px; }
  .screenshot-menu .shot img { max-height: 434px; }.word-pair figcaption { font-size: 10px; }.word-pair figcaption strong { font-size: 11px; }
  .range-card > div { padding: 15px; }.range-card strong { font-size: 22px; }.range-card span { font-size: 11px; }
  table { min-width: 290px; font-size: 11px; }td, th { padding: 9px 11px; }
  .note { padding: 15px 16px; }.gallery { grid-template-columns: 1fr; gap: 18px; }.gallery .shot { height: 180px; }.gallery .shot img { max-height: 154px; }
  .tab-list { gap: 3px; }.tab-list button { font-size: 10px; padding: 8px; }.copy-box { padding: 14px; }.copy-box pre { font-size: 12px; }
  dialog { padding: 14px; }.dialog-top h2 { font-size: 16px; }.dialog-top button { font-size: 10px; }
}
@media (hover:none) { .zoom-hint { opacity: 1; } }
@media (prefers-reduced-motion:reduce) { html { scroll-behavior: auto; }*,*::before,*::after { transition: none !important; } }
@media print {
  :root, body[data-theme=light] { --bg: #fff; --panel: #fff; --panel2: #f4f4f4; --ink: #111; --muted: #444; --faint: #555; --line: #ddd; --accent: #9c0044; color-scheme: light; }
  body { font-size: 10pt; line-height: 1.5; }.topbar,.sidebar,.reading-progress,.hero-actions,.inline-actions,.tab-list,.copy,.zoom-hint,#toast,dialog { display: none !important; }
  .layout { display: block; }main { padding: 0; }.hero { padding: 15px; }.lesson { padding: 18px 0; border: 0; border-bottom: 1px solid #ddd; border-radius: 0; }
  h1 { font-size: 27pt; }h2 { font-size: 20pt; }.lead { font-size: 12pt; }
  [role=tabpanel][hidden] { display: block !important; }.note, figure { break-inside: avoid; }.shot { background: transparent; border: 0; }
  .shot img { max-height: 300px; }.screenshot-menu .shot img { max-height: 300px; }.gallery,#gallery { display: none; }
  .copy-box { border: 0; padding: 0; }.copy-box pre { font-size: 10pt; }.table-wrap { overflow: visible; }.range-card strong { font-size: 18pt; }footer { padding: 20px 0; }
}
