:root {
  --bg: #f5f4ef;
  --surface: #fffefa;
  --ink: #1f1f1c;
  --muted: #6d6c65;
  --line: #dddbd2;
  --floor: #fffefa;
  --grid: #ecebe3;
  --wall: #34342f;
  --opening: #fffefa;
  --window: #cfe6f2;
  --glass: #4a8db3;
  --door: #8a6b47;
  --swing: rgba(138, 107, 71, 0.08);
  --chair: #e6dccb;
  --chair-line: #b9a888;
  --tv: #1f1f1c;
  --ls50: #2f6dbd;
  --q3: #c4552a;
  --sight: #8c8b83;
  --treat: #2f9468;
  --keep: #c44545;
  --ac: #dde3e7;
  --ac-line: #8a979f;
  --accent: #1f1f1c;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151513;
    --surface: #1d1d1a;
    --ink: #ecebe4;
    --muted: #9d9b92;
    --line: #34332e;
    --floor: #1d1d1a;
    --grid: #282824;
    --wall: #c9c8c0;
    --opening: #1d1d1a;
    --window: #1f4356;
    --glass: #7fc0e4;
    --door: #c9a57a;
    --swing: rgba(201, 165, 122, 0.1);
    --chair: #463d31;
    --chair-line: #7c6c55;
    --tv: #ecebe4;
    --ls50: #6fa6ee;
    --q3: #ee8b5f;
    --sight: #77756d;
    --treat: #54c290;
    --keep: #e26b6b;
    --ac: #2e3438;
    --ac-line: #7d8b93;
    --accent: #ecebe4;
  }
}

:root[data-theme="dark"] {
  --bg: #151513;
  --surface: #1d1d1a;
  --ink: #ecebe4;
  --muted: #9d9b92;
  --line: #34332e;
  --floor: #1d1d1a;
  --grid: #282824;
  --wall: #c9c8c0;
  --opening: #1d1d1a;
  --window: #1f4356;
  --glass: #7fc0e4;
  --door: #c9a57a;
  --swing: rgba(201, 165, 122, 0.1);
  --chair: #463d31;
  --chair-line: #7c6c55;
  --tv: #ecebe4;
  --ls50: #6fa6ee;
  --q3: #ee8b5f;
  --sight: #77756d;
  --treat: #54c290;
  --keep: #e26b6b;
  --ac: #2e3438;
  --ac-line: #7d8b93;
  --accent: #ecebe4;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  padding-inline: 20px;
}

.page { max-width: 1180px; margin: 0 auto; padding-block: 40px 80px; }

.topnav { display: flex; gap: 4px; margin-bottom: 28px; }
.topnav a {
  color: var(--muted); text-decoration: none; font-size: 14px;
  padding: 6px 14px; border-radius: 999px; border: 1px solid transparent;
}
.topnav a:hover { color: var(--ink); border-color: var(--line); }
.topnav a[aria-current="page"] { color: var(--ink); background: var(--surface); border-color: var(--line); font-weight: 600; }

.compare th[scope="row"] { width: 170px; }
.compare td.win { color: var(--ink); font-weight: 600; }
.compare td { color: var(--muted); }

.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: 13px; letter-spacing: 0.02em; }
h1 { margin: 0; font-size: 34px; line-height: 1.15; letter-spacing: -0.02em; }
h2 { font-size: 19px; margin: 0 0 14px; letter-spacing: -0.01em; }
h3 { font-size: 15px; margin: 0 0 6px; }
.lede { max-width: 62ch; color: var(--muted); margin: 10px 0 0; font-size: 16px; }

section { margin-top: 48px; }
.masthead + section { margin-top: 32px; }

.plan-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.plan-head h2 { margin: 0; }

.seg { display: inline-flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg-label { font-size: 12px; color: var(--muted); padding: 0 8px 0 10px; }
.seg button {
  font: inherit; font-size: 13px; color: var(--ink); background: transparent;
  border: 0; border-radius: 999px; padding: 5px 14px; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.seg button:focus-visible { outline: 2px solid var(--ls50); outline-offset: 2px; }

.plan-grid { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .plan-grid { grid-template-columns: minmax(0, 1fr); } }

.plan-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
#plan { min-width: 680px; padding: 8px; }
#plan svg { display: block; width: 100%; height: auto; }

.stats { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 6px 16px; }
.stats dl { margin: 0; }
.stat { padding: 10px 0; border-bottom: 1px solid var(--line); }
.stat:last-child { border-bottom: 0; }
.stat dt { font-size: 12px; color: var(--muted); }
.stat dd { margin: 2px 0 0; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.stat dd span { display: block; font-size: 12.5px; font-weight: 400; color: var(--muted); letter-spacing: 0; }

.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 0; margin: 12px 0 0; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 18px; height: 0; border-top: 2px solid; vertical-align: middle; margin-right: 7px; }
.legend .k-q3 { border-color: var(--q3); }
.legend .k-ls50 { border-color: var(--ls50); }
.legend .k-tv { border-top-style: dashed; border-color: var(--sight); }
.legend .k-aim { border-top-style: dotted; border-color: var(--muted); }
.legend .k-treat { border-top-width: 6px; border-color: var(--treat); opacity: 0.7; }
.legend .k-keep { border-top-width: 6px; border-color: var(--keep); opacity: 0.5; }
.legend .k-window { border-top-width: 6px; border-color: var(--window); }
.legend .k-sill { border-top-width: 4px; border-color: var(--muted); opacity: 0.5; }
.legend .k-grid { width: 12px; height: 12px; border: 1px solid var(--line); background: var(--surface); }

.note { color: var(--muted); font-size: 13px; margin: 10px 0 0; max-width: 80ch; }

.steps { margin: 0; padding-left: 22px; max-width: 80ch; }
.steps li { margin-bottom: 8px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.card p { margin: 0; font-size: 14px; color: var(--muted); }
.card p strong { color: var(--ink); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child th, tr:last-child td { border-bottom: 0; }
tbody th { width: 110px; color: var(--muted); font-weight: 500; }
.data thead th { font-size: 12px; color: var(--muted); font-weight: 500; }
.data td:nth-child(n+2):nth-child(-n+4) { text-align: right; width: 60px; }
.data th:nth-child(n+2):nth-child(-n+4) { text-align: right; }

.open { margin: 0; padding-left: 20px; columns: 2 260px; }
.open li { margin-bottom: 6px; break-inside: avoid; }

/* ---- SVG plan ---- */
#plan svg text { font-family: system-ui, -apple-system, sans-serif; font-size: 3.1px; fill: var(--ink); }
.grid-line { fill: none; stroke: var(--grid); stroke-width: 0.35; }
.hatch-line { stroke: var(--keep); stroke-width: 0.5; opacity: 0.55; }
.wall { fill: var(--wall); }
.floor { fill: var(--floor); }
.opening { fill: var(--opening); }
.window { fill: var(--window); }
.glass { stroke: var(--glass); stroke-width: 0.5; }
.jamb { stroke: var(--wall); stroke-width: 0.6; }
.keepclear { fill: url(#hatch); stroke: var(--keep); stroke-width: 0.4; stroke-dasharray: 1.2 0.8; }
.swing { fill: var(--swing); }
.swing-arc { fill: none; stroke: var(--door); stroke-width: 0.4; stroke-dasharray: 1.2 0.8; }
.leaf { stroke: var(--door); stroke-width: 1.2; stroke-linecap: round; }
.leaf-shut { fill: var(--door); }
.treat { fill: var(--treat); opacity: 0.6; }
.sight { stroke-width: 0.45; opacity: 0.85; }
.sight.tv-sight { stroke: var(--sight); stroke-dasharray: 1.6 1.2; }
.sight.ls50 { stroke: var(--ls50); }
.sight.q3 { stroke: var(--q3); }
.aim { stroke-width: 0.35; stroke-dasharray: 0.5 0.8; stroke-linecap: round; opacity: 0.9; }
.aim.ls50 { stroke: var(--ls50); }
.aim.q3 { stroke: var(--q3); }
.refl { stroke: var(--surface); stroke-width: 0.5; }
.refl.ls50 { fill: var(--ls50); }
.refl.q3 { fill: var(--q3); }
.chair rect { fill: var(--chair); stroke: var(--chair-line); stroke-width: 0.5; }
.chair line { stroke: var(--chair-line); stroke-width: 0.4; }
.sill { fill: var(--line); stroke: var(--muted); stroke-width: 0.25; }
.shelf { fill: var(--chair); stroke: var(--chair-line); stroke-width: 0.5; }
.shelf-stacked { fill: var(--chair-line); opacity: 0.3; }
.shelf-dash { stroke: var(--chair-line); stroke-width: 0.5; stroke-dasharray: 1.2 0.9; }
.ac { fill: var(--ac); stroke: var(--ac-line); stroke-width: 0.5; }
.hose { fill: none; stroke: var(--ac-line); stroke-width: 1.4; stroke-linecap: round; opacity: 0.7; }
.tv { fill: var(--tv); }
.arm { stroke: var(--muted); stroke-width: 0.8; stroke-dasharray: 2 1; }
.plate { fill: var(--muted); }
.spk rect { stroke-width: 0.5; }
.spk.ls50 rect { fill: var(--ls50); stroke: var(--ls50); fill-opacity: 0.25; }
.spk.q3 rect { fill: var(--q3); stroke: var(--q3); fill-opacity: 0.25; }
.spk .baffle { stroke-width: 1.1; }
.spk.ls50 .baffle { stroke: var(--ls50); }
.spk.q3 .baffle { stroke: var(--q3); }
.mlp { fill: var(--ink); }
.mlp-ring { fill: none; stroke: var(--ink); stroke-width: 0.45; }
.eth { fill: var(--ls50); }

#plan svg .lbl { paint-order: stroke; stroke: var(--floor); stroke-width: 1.1px; stroke-linejoin: round; }
#plan svg .lbl.small { font-size: 2.5px; fill: var(--muted); }
#plan svg .lbl.feat { font-size: 2.5px; fill: var(--muted); }
#plan svg .lbl.warn { font-size: 2.5px; fill: var(--keep); }
#plan svg .lbl.mlp-lbl { font-weight: 700; }
#plan svg .spk-in { font-size: 2.4px; font-weight: 700; }
#plan svg .spk-in.ls50 { fill: var(--ls50); }
#plan svg .spk-in.q3 { fill: var(--q3); }

.dim line { stroke: var(--muted); stroke-width: 0.3; }
.dim .tick { stroke-width: 0.45; }
#plan svg .dim text { font-size: 2.8px; fill: var(--ink); }
#plan svg .dim.minor text { font-size: 2.5px; fill: var(--muted); }
#plan svg .dim.tiny text { font-size: 2px; fill: var(--muted); }
.ext { stroke: var(--muted); stroke-width: 0.2; stroke-dasharray: 0.8 0.8; opacity: 0.6; }
/* ---- Audio rack page ---- */
.controls { display: flex; flex-wrap: wrap; gap: 8px; }
.rk { min-width: 640px; padding: 8px; }
.rk svg { display: block; width: 100%; height: auto; }
.rk svg text { font-family: system-ui, -apple-system, sans-serif; }
.rk-floor { stroke: var(--muted); stroke-width: 0.15; }
.rk-post { fill: var(--chair-line); opacity: 0.6; }
.rk-glass { fill: var(--window); stroke: var(--glass); stroke-width: 0.06; }
.rk-item { stroke-width: 0.12; }
.rk-item.spk { fill: var(--q3); fill-opacity: 0.2; stroke: var(--q3); }
.rk-item.line { fill: var(--ls50); fill-opacity: 0.18; stroke: var(--ls50); }
.rk-item.ctl { fill: var(--muted); fill-opacity: 0.22; stroke: var(--muted); }
.rk-item.rear { stroke-dasharray: 0.45 0.3; fill-opacity: 0.08; }
.rk-heat { stroke: var(--keep); stroke-width: 0.3; stroke-linecap: round; }
.rk-limit { stroke: var(--q3); stroke-width: 0.12; stroke-dasharray: 0.8 0.5; }
.rk-center { fill: var(--treat); fill-opacity: 0.08; stroke: var(--treat); stroke-width: 0.15; stroke-dasharray: 0.7 0.45; }
.rk-leader { stroke: var(--muted); stroke-width: 0.06; stroke-dasharray: 0.25 0.25; }
.rk svg .rk-lbl { font-size: 0.85px; fill: var(--ink); }
.rk svg .rk-lbl.muted { fill: var(--muted); }
.rk svg .rk-lbl.q3 { fill: var(--q3); }
.rk svg .rk-lbl.center { fill: var(--treat); }
.wl-wall { fill: var(--surface); }
.wl-rack { fill: none; stroke: var(--chair-line); stroke-width: 0.3; }
.wl-shelf { stroke: var(--glass); stroke-width: 0.35; }
.wl-item { stroke: none; }
.wl-item.spk { fill: var(--q3); opacity: 0.25; }
.wl-item.line { fill: var(--ls50); opacity: 0.25; }
.wl-item.ctl { fill: var(--muted); opacity: 0.3; }
.wl-stand { fill: var(--muted); opacity: 0.6; }
.wl-spk { stroke-width: 0.35; }
.wl-spk.q3 { fill: var(--q3); fill-opacity: 0.22; stroke: var(--q3); }
.wl-spk.ls50 { fill: var(--ls50); fill-opacity: 0.22; stroke: var(--ls50); }
.wl-drv { fill: none; stroke-width: 0.3; }
.wl-drv.q3 { stroke: var(--q3); }
.wl-drv.ls50 { stroke: var(--ls50); }
.wl-tv { fill: var(--tv); }
.rk svg .wl-tvlbl { font-size: 2.2px; fill: var(--bg); font-weight: 600; }
.wl-ref { stroke-width: 0.2; stroke-dasharray: 1 0.7; }
.wl-ref.ears { stroke: var(--ink); }
.wl-ref.rack { stroke: var(--chair-line); }
.wl-ref.q3 { stroke: var(--q3); }
.wl-ref.tv { stroke: var(--muted); }
.rk svg .wl-lbl { font-size: 1.7px; fill: var(--muted); paint-order: stroke; stroke: var(--surface); stroke-width: 0.5px; stroke-linejoin: round; }
.rk svg .wl-lbl.ears { fill: var(--ink); }
.rk svg .wl-lbl.q3 { fill: var(--q3); }
.legend .k-ctl { border-color: var(--muted); }
.legend .k-rear { border-top-style: dashed; border-color: var(--muted); }
.legend .k-heat { border-top-width: 3px; border-color: var(--keep); }
.legend .k-center { border-top-style: dashed; border-color: var(--treat); }
.rk-notes { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 6px; max-width: 90ch; font-size: 14px; }
.rk-notes li { padding-left: 22px; position: relative; color: var(--muted); }
.rk-notes li::before { position: absolute; left: 0; top: 0; font-weight: 700; }
.rk-notes li.info::before { content: "✓"; color: var(--treat); }
.rk-notes li.warn::before { content: "!"; color: var(--q3); left: 5px; }
.rk-notes li.bad { color: var(--ink); }
.rk-notes li.bad::before { content: "✕"; color: var(--keep); }

.compass path { fill: var(--ink); }
#plan svg .compass text { font-size: 3.4px; font-weight: 700; }
