/* RIS Lab. Material 3 look shared with guodongsun.com: same blue / slate / purple scheme,
   Google Sans Flex + Roboto Flex, a navigation rail and rounded tonal panes.
   Colours carry meaning everywhere (as in the figures on the site):
   --true  (tertiary purple) RIS / reflected path / "with RIS"
   --bs    (primary blue)    base stations and the densification route
   --wrong (outline grey)    baseline: direct path / "without RIS"
   --gamma (amber)           thresholds and break-even values (rho*, the SINR threshold)
   --danger(error red)       blockage, costs that bite
   --accent(primary)         UI accents */

:root {
  --bg: #ECEEF3; --pane: #F7F9FF; --surface: #F1F3F9; --surface-2: #E6E8EE; --surface-3: #E0E2E8;
  --text: #181C20; --muted: #42474E; --faint: #72777F; --border: #C2C7CF; --grid: #E0E2E8;
  --accent: #2F628C; --accent-soft: #CEE5FF; --on-accent: #FFFFFF; --on-accent-soft: #0F4A73;
  --secondary: #51606F; --secondary-soft: #D5E4F7; --on-secondary-soft: #3A4857;
  --true: #68587A; --true-soft: #EFDBFF; --on-true-soft: #504061; --wrong: #72777F; --wrong-soft: #E6E8EE;
  --bs: #2F628C; --bs-soft: #CEE5FF; --danger: #BA1A1A; --danger-soft: #FFDAD6;
  --gamma: #7A5900; --gamma-soft: #FFDEA1; --tie: #006B5F;
  --live-0: #E0E2E8; --live-1: #CDD2DA; --live-e: #ECEEF3;
  --t-research: #68587A; --t-industry: #B5560B; --t-etsi: #2F628C; --t-3gpp: #006B5F; --t-itu: #7A5900;
  --t-author: #B3265E; --t-greenerwave: #0B7FA8;
  --shadow-rgb: 0 0 0;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  --bg: #1C2024; --pane: #101418; --surface: #181C20; --surface-2: #272A2F; --surface-3: #323539;
  --text: #E0E2E8; --muted: #C2C7CF; --faint: #8C9198; --border: #42474E; --grid: #272A2F;
  --accent: #9BCBFB; --accent-soft: #0F4A73; --on-accent: #003353; --on-accent-soft: #CEE5FF;
  --secondary: #B9C8DA; --secondary-soft: #3A4857; --on-secondary-soft: #D5E4F7;
  --true: #D3BFE6; --true-soft: #504061; --on-true-soft: #EFDBFF; --wrong: #8C9198; --wrong-soft: #272A2F;
  --bs: #9BCBFB; --bs-soft: #0F4A73; --danger: #FFB4AB; --danger-soft: #93000A;
  --gamma: #F1C04D; --gamma-soft: #5C4300; --tie: #53DBC9;
  --live-0: #2A2E33; --live-1: #383C42; --live-e: #1C2024;
  --t-research: #D3BFE6; --t-industry: #FFB680; --t-etsi: #9BCBFB; --t-3gpp: #53DBC9; --t-itu: #F1C04D;
  --t-author: #FFB1C8; --t-greenerwave: #7DD0F2;
  color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1C2024; --pane: #101418; --surface: #181C20; --surface-2: #272A2F; --surface-3: #323539;
  --text: #E0E2E8; --muted: #C2C7CF; --faint: #8C9198; --border: #42474E; --grid: #272A2F;
  --accent: #9BCBFB; --accent-soft: #0F4A73; --on-accent: #003353; --on-accent-soft: #CEE5FF;
  --secondary: #B9C8DA; --secondary-soft: #3A4857; --on-secondary-soft: #D5E4F7;
  --true: #D3BFE6; --true-soft: #504061; --on-true-soft: #EFDBFF; --wrong: #8C9198; --wrong-soft: #272A2F;
  --bs: #9BCBFB; --bs-soft: #0F4A73; --danger: #FFB4AB; --danger-soft: #93000A;
  --gamma: #F1C04D; --gamma-soft: #5C4300; --tie: #53DBC9;
  --live-0: #2A2E33; --live-1: #383C42; --live-e: #1C2024;
  --t-research: #D3BFE6; --t-industry: #FFB680; --t-etsi: #9BCBFB; --t-3gpp: #53DBC9; --t-itu: #F1C04D;
  --t-author: #FFB1C8; --t-greenerwave: #7DD0F2;
  color-scheme: dark;
}

:root {
  --brand: "Google Sans Flex", "Google Sans", "Roboto Flex", Roboto, system-ui, sans-serif;
  --font: "Roboto Flex", Roboto, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --mono: "Roboto Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --shape-xs: 4px;
  --shape-sm: 8px;
  --shape-md: 12px;
  --shape-lg: 16px;
  --shape-lg-inc: 20px;
  --shape-xl: 28px;
  --shape-full: 999px;
  --radius: var(--shape-lg-inc);
  --radius-sm: var(--shape-md);
  --elev-1: 0 1px 2px rgb(var(--shadow-rgb) / 0.3), 0 1px 3px 1px rgb(var(--shadow-rgb) / 0.15);
  --elev-2: 0 1px 2px rgb(var(--shadow-rgb) / 0.3), 0 2px 6px 2px rgb(var(--shadow-rgb) / 0.15);
  --elev-3: 0 1px 3px rgb(var(--shadow-rgb) / 0.3), 0 4px 8px 3px rgb(var(--shadow-rgb) / 0.15);
  --shadow: var(--elev-2);
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --ease-spring: cubic-bezier(0.34, 1.4, 0.64, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/20px var(--font);
  letter-spacing: 0.15px;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
sup, sub { line-height: 0; }
strong, b { font-weight: 600; }
h1, h2, h3, h4 { font-family: var(--brand); font-weight: 500; color: var(--text); letter-spacing: 0; }
.num, output { font-family: var(--font); font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--secondary); outline-offset: 2px; border-radius: var(--shape-sm); }

.msr {
  font-family: "Material Symbols Rounded";
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  direction: ltr;
  font-feature-settings: "liga";
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
  user-select: none;
  flex: none;
  width: 24px;
  overflow: hidden;
}

/* ------------------------------------------------------------------ layout */

.app {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 400px;
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: "top stage tutor";
  gap: 12px;
  padding: 12px 12px 12px 0;
  height: 100vh;
}
.app.tutor-hidden { grid-template-columns: 96px minmax(0, 1fr); grid-template-areas: "top stage"; }
.app.tutor-hidden .tutor { display: none; }

/* The top bar is the navigation rail. */
.topbar { grid-area: top; display: flex; min-width: 0; min-height: 0; }
.brand { display: flex; align-items: center; gap: 12px; flex: none; }
.brand-mark { width: 40px; height: 40px; border-radius: var(--shape-md); transition: border-radius 400ms var(--ease-spring); flex: none; }
.brand:hover .brand-mark { border-radius: 20px; }
.brand-mark rect.bm-bg { fill: var(--accent); }
.brand-mark g { fill: var(--on-accent); }
.brand-name { font-family: var(--brand); font-size: 22px; line-height: 28px; font-weight: 500; white-space: nowrap; }
.brand-sub { font-size: 12px; line-height: 16px; letter-spacing: 0.4px; color: var(--muted); }

.tabs { display: flex; gap: 2px; scrollbar-width: none; min-width: 0; min-height: 0; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button, .rail-btn {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 72px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-align: center;
  cursor: pointer;
}
.rail-icon {
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  width: 56px;
  height: 32px;
  border-radius: var(--shape-full);
  transition: background-color 200ms var(--ease);
}
.rail-icon::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--text);
  opacity: 0;
  transition: opacity 150ms linear;
  z-index: -1;
}
.tabs button:hover .rail-icon::after, .rail-btn:hover .rail-icon::after { opacity: 0.08; }
.tabs button:focus-visible, .rail-btn:focus-visible { outline: none; }
.tabs button:focus-visible .rail-icon, .rail-btn:focus-visible .rail-icon { outline: 3px solid var(--secondary); outline-offset: 2px; }
.tabs button[aria-selected="true"], .rail-btn[aria-pressed="true"] { color: var(--secondary); font-weight: 700; }
.tabs button[aria-selected="true"] .rail-icon, .rail-btn[aria-pressed="true"] .rail-icon { background: var(--secondary-soft); color: var(--on-secondary-soft); }
.tabs button[aria-selected="true"] .msr { font-variation-settings: "FILL" 1, "wght" 500, "GRAD" 0, "opsz" 24; }
.top-actions { display: flex; align-items: center; gap: 8px; flex: none; }

.tabs .tab-n { display: none; }
.stage {
  grid-area: stage;
  overflow-y: auto;
  padding: 28px 32px 48px;
  min-width: 0;
  background: var(--pane);
  border-radius: var(--shape-xl);
  container-type: inline-size;
}
.view { max-width: 1240px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }

@media (min-width: 761px) {
  .topbar { flex-direction: column; align-items: center; gap: 32px; padding: 8px 0; }
  .brand-mark { width: 48px; height: 48px; border-radius: var(--shape-lg); }
  .brand:hover .brand-mark { border-radius: 24px; }
  .brand > div { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .tabs { flex-direction: column; gap: 12px; overflow-y: auto; flex: 0 1 auto; }
  .tabs button, .rail-btn { width: 80px; min-width: 0; padding: 0; }
  .top-actions { flex-direction: column; gap: 12px; margin-top: auto; }
  .topbar .status { flex-direction: column; max-width: 84px; text-align: center; }
  .topbar .status:not(.err) #statusText { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
}

/* ------------------------------------------------------------------ controls */

.side-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 12px; align-items: start; }
.side-layout > .controls-card { position: sticky; top: 0; }
.main-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.ctl-group h2, .kicker { margin: 0 0 8px; font-family: var(--font); font-size: 14px; line-height: 20px; letter-spacing: 0.1px; color: var(--accent); font-weight: 600; }
.ctl-group + .ctl-group { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.ctl { display: block; margin-bottom: 10px; }
.ctl-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 1px; }
.ctl-label { color: var(--muted); font-size: 13px; }
.ctl output { font-size: 13px; font-weight: 500; color: var(--text); }
input[type="range"] { width: 100%; accent-color: var(--accent); height: 20px; margin: 0; cursor: pointer; }
input[type="checkbox"] { accent-color: var(--accent); }
input[type="number"] { width: 100%; background: transparent; border: 1px solid var(--faint); border-radius: var(--shape-sm); padding: 4px 8px; font-variant-numeric: tabular-nums; font-size: 13px; }
select { background: transparent; border: 1px solid var(--faint); border-radius: var(--shape-sm); padding: 4px 8px; cursor: pointer; }
select:hover, input[type="number"]:hover { border-color: var(--text); }
input[type="text"], input[type="search"] { background: transparent; border: 1px solid var(--faint); border-radius: var(--shape-sm); padding: 5px 10px; font-size: 13px; }
input[type="text"]::placeholder, input[type="search"]::placeholder { color: var(--faint); }

.seg { display: grid; grid-auto-columns: 1fr; grid-auto-flow: column; background: var(--surface-2); border-radius: var(--shape-full); padding: 3px; gap: 2px; margin-bottom: 10px; }
.seg button { border: 0; background: none; border-radius: var(--shape-full); padding: 5px 8px; font-weight: 500; font-size: 13px; letter-spacing: 0.1px; color: var(--muted); cursor: pointer; white-space: nowrap; transition: background-color 200ms var(--ease); }
.seg button:hover { color: var(--text); }
.seg button[aria-checked="true"] { background: var(--secondary-soft); color: var(--on-secondary-soft); }
.seg.inline { display: inline-grid; margin: 0; }

/* ------------------------------------------------------------------ buttons */

.btn {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  border: 0;
  background: var(--secondary-soft);
  color: var(--on-secondary-soft);
  border-radius: var(--shape-full);
  padding: 6px 18px;
  font-weight: 500;
  font-size: 14px;
  line-height: 20px;
  letter-spacing: 0.1px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-radius 300ms var(--ease-spring), box-shadow 200ms var(--ease);
}
.btn::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: currentColor;
  opacity: 0;
  transition: opacity 150ms linear;
  pointer-events: none;
  z-index: -1;
}
.btn:hover::after { opacity: 0.08; }
.btn:active::after { opacity: 0.12; }
.btn:active { border-radius: var(--shape-md); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn:disabled::after { display: none; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover { box-shadow: var(--elev-1); }
.btn.ghost { color: var(--accent); background: none; padding-inline: 12px; }
.btn.small { min-height: 28px; padding: 3px 12px; font-size: 13px; }
.icon-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--shape-full);
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 150ms linear;
}
.icon-btn:hover { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text); }

/* ------------------------------------------------------------------ headings, cards */

.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 4px; }
.panel-head h1 { margin: 0 0 6px; font-size: 28px; line-height: 36px; font-weight: 450; }
.lede { margin: 0; color: var(--muted); max-width: 820px; font-family: var(--brand); font-size: 16px; line-height: 24px; }
.lens-tags { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.lens { font-size: 12px; line-height: 16px; letter-spacing: 0.5px; border-radius: var(--shape-sm); padding: 4px 10px; font-weight: 600; }
.lens.sci { background: var(--true-soft); color: var(--on-true-soft); }
.lens.ind { background: var(--bs-soft); color: var(--on-accent-soft); }

.card { background: var(--surface); border-radius: var(--radius); padding: 16px 18px; position: relative; min-width: 0; }
.card h3 { margin: 0 0 8px; font-size: 16px; line-height: 24px; font-weight: 500; }
.card-title-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 6px; flex-wrap: wrap; }
.card-title-row h3 { margin: 0; }
.hint { color: var(--faint); font-family: var(--font); font-size: 12px; line-height: 16px; letter-spacing: 0.4px; font-weight: 400; }
.note { color: var(--muted); font-size: 13px; letter-spacing: 0.25px; }
.explain { font-size: 13px; letter-spacing: 0.25px; color: var(--muted); margin: 6px 0 0; }
.explain b { color: var(--text); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.spacer { flex: 1; }
.mini { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.badge { font-size: 12px; line-height: 16px; letter-spacing: 0.5px; border-radius: var(--shape-sm); padding: 2px 10px; font-weight: 600; white-space: nowrap; }
.badge.specified { background: var(--true-soft); color: var(--on-true-soft); }
.badge.proposed { background: var(--accent-soft); color: var(--on-accent-soft); }
.badge.open { background: var(--gamma-soft); color: var(--gamma); }
.badge.unchanged { background: var(--surface-2); color: var(--faint); }
.badge.high { background: var(--true-soft); color: var(--on-true-soft); }
.badge.medium { background: var(--gamma-soft); color: var(--gamma); }
.badge.low { background: var(--danger-soft); color: var(--danger); }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

canvas { display: block; width: 100%; }
.cv-md { height: 260px; }
.cv-sm { height: 210px; }
.cv-lg { height: 330px; }
.cv-map { height: 360px; cursor: crosshair; }
.plot-tip {
  position: absolute; pointer-events: none; z-index: 5; background: var(--surface-3); box-shadow: var(--elev-2);
  border-radius: var(--shape-md); padding: 8px 12px; font-size: 12px; line-height: 16px; letter-spacing: 0.4px; max-width: 300px; white-space: nowrap;
}
.plot-tip b { font-weight: 600; }
.legend-inline { display: inline-flex; gap: 6px 14px; font-size: 12px; line-height: 16px; letter-spacing: 0.4px; color: var(--muted); flex-wrap: wrap; }
.legend-inline i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }

.stat { background: var(--surface); border-radius: var(--radius); padding: 14px 18px 16px; }
.stat .s-label { color: var(--muted); font-size: 13px; letter-spacing: 0.25px; }
.stat .s-value { font-family: var(--brand); font-size: 26px; line-height: 34px; font-weight: 450; font-variant-numeric: tabular-nums; color: var(--accent); margin: 1px 0; white-space: nowrap; }
.stat .s-value small { font-family: var(--font); font-size: 13px; color: var(--muted); font-weight: 400; }
.stat .s-sub { color: var(--faint); font-size: 12px; line-height: 16px; letter-spacing: 0.4px; }
.stat.ris .s-value { color: var(--true); }
.stat.bs .s-value { color: var(--bs); }
.stat.warn .s-value { color: var(--gamma); }
.stat.bad .s-value { color: var(--danger); }

/* ------------------------------------------------------------------ technology */

.hero { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 12px; }
.scene { width: 100%; height: auto; display: block; }
.scene .ground { stroke: var(--border); stroke-width: 2; }
.scene .bld { fill: var(--surface-3); stroke: var(--border); }
.scene .bs-mast { stroke: var(--bs); stroke-width: 3; }
.scene .bs-head { fill: var(--bs); }
.scene .ris-panel { fill: var(--true); }
.scene .ris-cell { fill: var(--surface); opacity: 0.85; }
.scene .ue { fill: var(--text); }
.scene .ray-direct { stroke: var(--wrong); stroke-width: 2; stroke-dasharray: 6 5; fill: none; }
.scene .ray-ris { stroke: var(--true); stroke-width: 2.6; fill: none; }
.scene .ray-ctrl { stroke: var(--gamma); stroke-width: 1.6; stroke-dasharray: 3 4; fill: none; }
.scene .blocked { stroke: var(--danger); stroke-width: 3; }
.scene .lbl { fill: var(--muted); font: 12px var(--font); }
.scene .lbl.b { fill: var(--text); font-weight: 600; }
.scene .lbl.ris { fill: var(--true); font-weight: 600; }
.scene .lbl.ctrl { fill: var(--gamma); }
.scene .pulse { fill: var(--true); }
.lens-cards { display: grid; gap: 8px; }
.lens-card { border-radius: var(--radius); padding: 16px 18px; background: var(--surface); }
.lens-card h4 { margin: 0 0 6px; font-family: var(--font); font-size: 14px; line-height: 20px; font-weight: 600; letter-spacing: 0.1px; }
.lens-card.sci h4 { color: var(--true); }
.lens-card.ind h4 { color: var(--bs); }
.lens-card ul { margin: 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
.lens-card li { margin: 3px 0; }
.lens-card li b { color: var(--text); font-weight: 600; }
.compare-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.compare-table th, .compare-table td { border-bottom: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
.compare-table tr:last-child td { border-bottom: 0; }
.compare-table th { color: var(--text); font-weight: 600; font-size: 13px; border-bottom-color: var(--faint); }
.compare-table td:first-child { color: var(--muted); }
.compare-table .hl { background: var(--true-soft); color: var(--on-true-soft); }
.lb-grid { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 14px; align-items: start; }

/* ------------------------------------------------------------------ standards */

.tl-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.tl-chip { border: 1px solid var(--border); background: none; border-radius: var(--shape-sm); min-height: 32px; padding: 4px 14px 4px 10px; font-size: 14px; line-height: 20px; font-weight: 500; letter-spacing: 0.1px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.tl-chip i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.tl-chip[aria-pressed="true"] { color: var(--on-secondary-soft); background: var(--secondary-soft); border-color: transparent; }
.tl-wrap { overflow-x: auto; }
.timeline { display: block; min-width: 940px; width: 100%; height: auto; }
.timeline .lane-label { fill: var(--muted); font: 600 11.5px var(--font); }
.timeline .lane { fill: var(--surface-2); }
.timeline .year { fill: var(--faint); font: 11px var(--font); }
.timeline .yline { stroke: var(--grid); }
.timeline .now { stroke: var(--danger); stroke-dasharray: 3 3; }
.timeline .ev { cursor: pointer; transition: r 0.12s; }
.timeline .ev.dim { opacity: 0.18; }
.timeline .ev.sel { stroke: var(--text); stroke-width: 2.5; }
.timeline .ev.low { fill-opacity: 0.25; stroke-width: 1.5; }
.ev-detail { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
.ev-detail .date { font-variant-numeric: tabular-nums; font-weight: 500; color: var(--accent); }
.ev-list { max-height: 260px; overflow-y: auto; font-size: 13px; margin-top: 6px; }
.ev-list div { padding: 6px 0; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: 62px 1fr auto; gap: 8px; cursor: pointer; align-items: start; }
.ev-list div:hover { color: var(--accent); }
.ev-list .d { font-variant-numeric: tabular-nums; font-weight: 500; color: var(--accent); }
.stack-grid { display: grid; grid-template-columns: 70px repeat(3, minmax(0, 1fr)); gap: 4px; align-items: stretch; }
.stack-grid .hdr { text-align: center; font-weight: 600; font-size: 13px; padding: 4px; }
.stack-grid .hdr small { display: block; color: var(--faint); font-weight: 400; font-size: 12px; }
.stack-grid .lay { font: 600 12px var(--font); letter-spacing: 0.5px; color: var(--muted); display: flex; align-items: center; }
.cell { border-radius: var(--shape-sm); padding: 6px 8px; font-size: 12px; min-height: 32px; display: flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; }
.cell.std { background: var(--surface-2); color: var(--muted); }
.cell.none { background: repeating-linear-gradient(45deg, transparent, transparent 5px, var(--surface-2) 5px, var(--surface-2) 6px); color: var(--faint); }
.cell.split { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 0; background: none; }
.cell.split > span { border-radius: var(--shape-sm); display: flex; align-items: center; justify-content: center; padding: 6px 4px; }
.cell .x, .cell.x { cursor: pointer; }
.cell.specified, .cell .specified { background: var(--true-soft); color: var(--on-true-soft); font-weight: 600; }
.cell.proposed, .cell .proposed { background: var(--accent-soft); color: var(--on-accent-soft); font-weight: 600; }
.cell.open, .cell .open { background: var(--gamma-soft); color: var(--gamma); font-weight: 600; }
.cell.unchanged, .cell .unchanged { background: var(--surface-2); color: var(--faint); }
.cell.sel, .cell .sel { outline: 2px solid var(--text); }
.layer-detail { font-size: 14px; line-height: 22px; }
.layer-detail h4 { margin: 0 0 6px; display: flex; gap: 8px; align-items: center; font-size: 16px; line-height: 24px; }
.ladder { width: 100%; height: auto; display: block; }
.ladder .actor { fill: var(--surface-2); stroke: var(--border); }
.ladder .actor-t { fill: var(--text); font: 600 12.5px var(--font); }
.ladder .life { stroke: var(--border); stroke-dasharray: 4 4; }
.ladder .msg-line { stroke: var(--faint); stroke-width: 1.6; }
.ladder .msg-line.on { stroke: var(--accent); stroke-width: 2.2; }
.ladder .msg-t { fill: var(--muted); font: 12px var(--font); paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.ladder .msg-t.on { fill: var(--text); font-weight: 600; }
.ladder .step-n { fill: var(--faint); font: 11px var(--font); }
.ladder .arrow { fill: var(--faint); }
.ladder .arrow.on { fill: var(--accent); }
.ladder-note { min-height: 40px; font-size: 14px; color: var(--muted); }
.ladder-note b { color: var(--text); }

/* ------------------------------------------------------------------ geometry & economics */

.map-wrap { position: relative; }
.map-wrap canvas { border-radius: var(--shape-md); }
.map-legend { display: flex; align-items: center; gap: 8px; font-size: 12px; letter-spacing: 0.4px; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.map-legend .ramp { width: 140px; height: 9px; border-radius: var(--shape-full); }
.bars-list { display: grid; gap: 7px; font-size: 13px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 92px; align-items: center; gap: 8px; }
.bar-row .track { height: 12px; background: var(--surface-3); border-radius: var(--shape-full); overflow: hidden; position: relative; }
.bar-row .fill { height: 100%; border-radius: var(--shape-full); }
.bar-row .v { font-variant-numeric: tabular-nums; text-align: right; font-size: 12px; }
.stack-bar { display: flex; height: 28px; border-radius: var(--shape-sm); overflow: hidden; margin: 4px 0 2px; gap: 2px; }
.stack-bar span { display: block; line-height: 28px; text-align: center; font-size: 11px; font-weight: 500; color: var(--on-accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; padding: 0 3px; border-radius: 2px; }
.decision { border-radius: var(--shape-xl); padding: 20px 24px; display: grid; grid-template-columns: auto 1fr; gap: 4px 18px; align-items: center; }
.decision.ris { background: var(--true-soft); color: var(--on-true-soft); }
.decision.bs { background: var(--bs-soft); color: var(--on-accent-soft); }
.decision .big { font-family: var(--brand); font-size: 28px; line-height: 36px; font-weight: 500; grid-row: span 2; }
.decision p { margin: 0; font-size: 14px; }
.route-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.route { background: var(--surface-2); border-radius: var(--shape-lg); padding: 14px 16px; }
.route.win { box-shadow: inset 0 0 0 2px var(--true); }
.route h4 { margin: 0 0 6px; font-family: var(--font); font-size: 14px; line-height: 20px; font-weight: 600; letter-spacing: 0.1px; }
.route.bsr h4 { color: var(--bs); }
.route.risr h4 { color: var(--true); }
.route dl { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; font-size: 13px; }
.route dt { color: var(--muted); }
.route dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.cost-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 14px; }
.cost-form label { display: grid; grid-template-columns: 1fr 92px; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.cost-form h5 { grid-column: 1 / -1; margin: 10px 0 0; font-size: 14px; line-height: 20px; font-weight: 600; letter-spacing: 0.1px; color: var(--accent); }
details.fold > summary { cursor: pointer; font-family: var(--brand); font-weight: 500; font-size: 16px; line-height: 24px; list-style: none; display: flex; align-items: center; gap: 8px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: "▸"; color: var(--accent); transition: transform 0.15s; }
details.fold[open] > summary::before { transform: rotate(90deg); }
details.fold[open] > summary { margin-bottom: 8px; }

/* ------------------------------------------------------------------ prose (notes, about, copilot) */

.prose { font-size: 15px; line-height: 24px; max-width: 900px; }
.card.prose { padding: 24px 28px; }
.prose h1 { font-size: 28px; line-height: 36px; font-weight: 450; margin: 0 0 12px; }
.prose h2 { font-size: 22px; line-height: 28px; margin: 28px 0 8px; display: flex; align-items: center; gap: 10px; }
.prose h3 { font-size: 17px; line-height: 24px; margin: 18px 0 6px; }
.prose p { margin: 0 0 12px; }
.prose ul, .prose ol { margin: 0 0 12px; padding-left: 22px; }
.prose li { margin: 4px 0; }
.prose li::marker { color: var(--accent); }
.prose code { font-family: var(--mono); font-size: 0.9em; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
.prose pre { background: var(--surface-2); padding: 12px 16px; border-radius: var(--shape-lg); overflow-x: auto; }
.prose pre code { background: none; padding: 0; }
.prose table { border-collapse: collapse; margin: 8px 0 14px; font-size: 13px; line-height: 20px; display: block; overflow-x: auto; }
.prose th, .prose td { border-bottom: 1px solid var(--border); padding: 8px 12px; text-align: left; vertical-align: top; }
.prose th { color: var(--text); font-weight: 600; border-bottom-color: var(--faint); }
.prose a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
.prose a:hover { text-decoration-thickness: 2px; }
.prose blockquote { margin: 0 0 12px; padding: 12px 16px; background: var(--secondary-soft); color: var(--on-secondary-soft); border-radius: var(--shape-lg); }
.prose blockquote p:last-child { margin-bottom: 0; }
.prose .katex-display { overflow-x: auto; overflow-y: hidden; padding: 2px 0; }
.prose h2 .ask-sec { font-family: var(--font); font-size: 13px; font-weight: 500; }

.about-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 12px; align-items: start; }
.paper { background: var(--surface-2); border-radius: var(--shape-lg); padding: 12px 16px; margin-bottom: 8px; font-size: 14px; }
.paper b { display: block; font-family: var(--brand); font-weight: 500; font-size: 15px; line-height: 22px; }
.paper span { color: var(--muted); font-size: 13px; letter-spacing: 0.25px; }
.paper a { color: var(--accent); font-size: 13px; font-weight: 500; }
.check-list { margin: 0; padding: 0; list-style: none; font-size: 13px; }
.check-list li { padding: 4px 0 4px 22px; position: relative; color: var(--muted); }
.check-list li::before { content: "✓"; position: absolute; left: 2px; color: var(--accent); font-weight: 700; }
.check-list li b { color: var(--text); font-weight: 600; }

/* ------------------------------------------------------------------ copilot */

.tutor {
  grid-area: tutor;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--pane);
  border-radius: var(--shape-xl);
  overflow: hidden;
}
.tutor-head { display: flex; align-items: center; gap: 6px; padding: 14px 12px 10px 20px; }
.tutor-title { font-family: var(--brand); font-size: 22px; line-height: 28px; font-weight: 500; }
.tutor-sub { font-size: 12px; line-height: 16px; letter-spacing: 0.4px; color: var(--muted); }
.tutor-msgs { flex: 1; overflow-y: auto; padding: 12px 16px 6px; display: flex; flex-direction: column; gap: 12px; }
.tutor-empty { color: var(--muted); font-size: 14px; }
.tutor-empty .te-title { color: var(--text); font-family: var(--brand); font-weight: 500; font-size: 18px; line-height: 24px; margin: 4px 0 6px; }
.chips { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.chip {
  text-align: left;
  border: 1px solid var(--border);
  background: none;
  border-radius: var(--shape-sm);
  padding: 6px 14px;
  min-height: 32px;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  letter-spacing: 0.1px;
  cursor: pointer;
  color: var(--muted);
  transition: background-color 150ms linear;
}
.chip:hover { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text); }

.msg { display: flex; flex-direction: column; gap: 6px; }
.msg.user { align-items: flex-end; }
.msg .bubble { border-radius: var(--shape-lg-inc); padding: 10px 14px; max-width: 100%; font-size: 14px; line-height: 20px; overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--accent); color: var(--on-accent); border-bottom-right-radius: var(--shape-xs); max-width: 88%; white-space: pre-wrap; }
.msg.model .bubble { background: var(--surface-2); border-bottom-left-radius: var(--shape-xs); }
.msg.model .bubble.prose { padding: 10px 14px; max-width: none; font-size: 14px; line-height: 22px; }
.msg.model .bubble.prose p:last-child { margin-bottom: 0; }
.msg.model .bubble.prose h1, .msg.model .bubble.prose h2, .msg.model .bubble.prose h3 { font-size: 15px; line-height: 22px; margin: 10px 0 4px; }
.msg.model .bubble.prose code { background: var(--surface-3); }
.msg .err-text { color: var(--danger); font-size: 13px; }
.toolchip {
  align-self: flex-start;
  border: 1px solid var(--border);
  border-radius: var(--shape-md);
  font-size: 12px;
  line-height: 16px;
  max-width: 100%;
}
.toolchip summary { list-style: none; cursor: pointer; padding: 6px 12px; display: flex; gap: 7px; align-items: center; color: var(--muted); }
.toolchip summary::-webkit-details-marker { display: none; }
.toolchip summary .tc-icon { color: var(--accent); }
.toolchip.bad summary .tc-icon { color: var(--danger); }
.toolchip summary .tc-label { color: var(--text); font-weight: 500; }
.toolchip pre { margin: 0; padding: 8px 12px; border-top: 1px solid var(--border); max-height: 220px; overflow: auto; font: 11px/1.45 var(--mono); color: var(--muted); white-space: pre-wrap; word-break: break-all; }
.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: 0.2s; }
.typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.tutor-context { font-size: 12px; line-height: 16px; letter-spacing: 0.4px; color: var(--faint); padding: 4px 20px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 8px 12px 12px; }
.composer textarea {
  flex: 1;
  resize: none;
  border: 0;
  border-radius: var(--shape-lg-inc);
  padding: 10px 16px;
  background: var(--surface-2);
  max-height: 160px;
  line-height: 20px;
  font-size: 14px;
}
.composer textarea::placeholder { color: var(--faint); }
.composer textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.composer .btn { height: 40px; width: 40px; min-height: 0; padding: 0; }
.scrim { display: none; }

.audience { padding: 0 16px 10px 20px; display: flex; align-items: center; gap: 10px; font-size: 12px; letter-spacing: 0.4px; color: var(--muted); }
.audience .seg { margin: 0; flex: 1; }
.audience .seg button { font-size: 12px; padding: 5px 4px; }
.status { display: inline-flex; gap: 6px; align-items: center; font-size: 11px; line-height: 14px; letter-spacing: 0.4px; color: var(--muted); }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.status.ok .dot { background: var(--tie); }
.status.mock .dot { background: var(--gamma); }
.status.err .dot { background: var(--danger); }

/* ------------------------------------------------------------------ responsive */

@container (max-width: 980px) {
  .side-layout, .lb-grid, .hero, .about-grid { grid-template-columns: 1fr; }
  .side-layout > .controls-card { position: static; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@container (max-width: 700px) {
  .grid-2, .grid-3, .route-cards { grid-template-columns: 1fr; }
  .stack-grid { grid-template-columns: 52px repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1280px) {
  .app, .app.tutor-hidden { grid-template-columns: 96px minmax(0, 1fr); grid-template-areas: "top stage"; }
  .tutor { position: fixed; right: 12px; top: 12px; bottom: 12px; width: min(420px, calc(100vw - 24px)); z-index: 30; box-shadow: var(--elev-3); }
  .app:not(.tutor-open) .tutor { display: none; }
  .app.tutor-open .scrim { display: block; position: fixed; inset: 0; background: rgb(0 0 0 / 0.32); z-index: 25; }
}
@media (max-width: 760px) {
  body { background: var(--pane); }
  .app, .app.tutor-hidden { display: flex; flex-direction: column; gap: 0; padding: 0; height: auto; min-height: 100vh; }
  .topbar { flex-wrap: wrap; align-items: center; padding: 8px 12px 0; gap: 0 12px; }
  .brand { padding: 8px 4px 4px; }
  .tabs { order: 3; width: 100%; overflow-x: auto; padding: 6px 0 10px; }
  .tabs button { white-space: nowrap; }
  .top-actions { margin-left: auto; gap: 4px; }
  .top-actions .rail-label, .topbar #statusText { display: none; }
  .top-actions .rail-icon { width: 40px; height: 40px; }
  .stage { padding: 16px 16px 48px; overflow: visible; border-radius: 0; }
  .panel-head { flex-direction: column; }
  .panel-head h1 { font-size: 24px; line-height: 32px; }
  .tutor { inset: 0; width: 100vw; border-radius: 0; }
  .brand-sub { display: none; }
  .card.prose { padding: 20px; }
}

/* tables in copilot replies: scroll sideways rather than break words mid-way */
.msg.model .bubble.prose table { font-size: 12px; }
.msg.model .bubble.prose th, .msg.model .bubble.prose td { min-width: 110px; overflow-wrap: normal; word-break: normal; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
