:root {
  --paper: #131316;
  --rail: #222127;
  --panel: #222127;
  --hover: #2d2d34;
  --ink: #f5f4f4;
  --muted: #a09fad;
  --line: rgba(245, 244, 244, 0.1);
  --line-strong: rgba(245, 244, 244, 0.18);
  --accent: #bdb3ff;
  --accent-strong: #9e8fff;
  --accent-soft: rgba(158, 143, 255, 0.16);
  --focus: #6047ff;
  --up: #94fabc;
  --down: #ffb0a4;
  --heat: #f0c36a;
  --quiet: #bebdc7;
  --shadow: none;
  --sans: -apple-system, "system-ui", "Segoe UI", Roboto, Oxygen, Ubuntu, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.45;
}

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

button, input { font: inherit; color: inherit; }

.app {
  display: grid;
  grid-template-columns: 272px 1fr;
  min-height: 100%;
}

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 18px 24px;
  border-right: 1px solid var(--line);
  background: var(--rail);
  overflow: auto;
}

.mark {
  margin: 0 8px 4px;
  font-size: 13px;
  letter-spacing: 0.08em;
  font-weight: 500;
}

.cluster {
  margin: 0 8px 22px;
  color: var(--muted);
  font-size: 12px;
}

.group { margin: 0 0 18px; }

.group-label,
.subgroup-label {
  margin: 0 8px 6px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  font-weight: 500;
  text-transform: uppercase;
}

.subgroup-label {
  margin-top: 10px;
  letter-spacing: 0.04em;
  font-size: 10px;
}

.fold-block { margin: 0 0 4px; }

.fold-block.nested { margin: 0 0 2px 8px; }

.fold {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  margin: 0;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.fold:hover,
.fold[aria-expanded="true"] {
  background: var(--hover);
  border-color: var(--line);
}

.fold.branch .fold-name { color: var(--accent); }

.fold-block.nested .fold {
  padding: 7px 10px;
  color: var(--muted);
  font-size: 13px;
}

.fold-name { font-weight: 500; }

.chev {
  width: 7px;
  height: 7px;
  margin-right: 2px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.32s ease;
  flex: none;
}

.fold[aria-expanded="true"] .chev { transform: rotate(45deg); }

.drawer {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.38s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.drawer.open { grid-template-rows: 1fr; }

.drawer-inner {
  min-height: 0;
  overflow: hidden;
}

.drawer.open .drawer-inner > * {
  animation: rise 0.32s ease both;
}

.drawer.open .drawer-inner > *:nth-child(2) { animation-delay: 0.03s; }
.drawer.open .drawer-inner > *:nth-child(3) { animation-delay: 0.06s; }
.drawer.open .drawer-inner > *:nth-child(4) { animation-delay: 0.09s; }
.drawer.open .drawer-inner > *:nth-child(5) { animation-delay: 0.12s; }

@keyframes rise {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.nav-button {
  display: block;
  width: calc(100% - 8px);
  margin: 2px 0 2px 8px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.nav-button:hover {
  background: var(--hover);
  border-color: var(--line);
  transform: translateX(4px);
}

.nav-button[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

.main {
  padding: 32px 40px 64px;
  max-width: 1080px;
}

.main.wide { max-width: 1480px; }

.kicker {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
  font-weight: 500;
}

h1 {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.question {
  margin: 0 0 22px;
  max-width: 68ch;
  color: var(--muted);
}

.path {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 22px;
}

.path-step {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.path-step span {
  display: block;
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
}

.path-step p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.card, .sheet {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.card { padding: 16px 16px 8px; }

.card.lead { grid-column: 1 / -1; }

.card h2 {
  margin: 0 8px 4px;
  font-size: 13px;
  letter-spacing: 0.04em;
  font-weight: 500;
}

.blurb, .tally {
  margin: 0 8px 4px;
  color: var(--muted);
  font-size: 13px;
}

.tally { margin-bottom: 8px; font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; }

.feature-link {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin: 0 0 6px;
  padding: 10px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.feature-link:hover,
.sort-option:hover { background: var(--hover); }

.feature-link strong { font-weight: 500; }

.status {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.03em;
}

.status.pass { color: var(--up); }
.status.fail { color: var(--down); }
.status.empty { color: var(--quiet); }

.sheet { padding: 16px 18px 8px; }

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
}

.meta code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  padding: 8px 10px;
  border-radius: 999px;
  background: var(--paper);
  font-size: 13px;
}

.check.pass { color: var(--up); }
.check.fail { color: var(--down); }

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

th {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-align: left;
  text-transform: uppercase;
}

td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

th.num, td.num { text-align: right; }

th.band-label {
  text-align: center;
  color: var(--ink);
  letter-spacing: 0.04em;
  background: var(--paper);
}

td.entity { font-weight: 500; white-space: nowrap; }
td.time { white-space: nowrap; }

tbody tr.band td { border-top: 2px solid var(--line-strong); }
tbody tr:first-child td { border-top-width: 0; }

.board th:first-child,
.board td:first-child {
  position: sticky;
  left: 0;
  background: var(--panel);
  z-index: 1;
}

td.evidence {
  white-space: nowrap;
  color: var(--muted);
  font-size: 13px;
}

.up { color: var(--up); }
.down { color: var(--down); }

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(245, 244, 244, 0.06);
  font-size: 12px;
  letter-spacing: 0.04em;
  font-weight: 500;
}

.pill.HEATING, .pill.BUSY { color: var(--heat); }
.pill.SURGE, .pill.IMBALANCED, .pill.FLAG_REVIEW { color: var(--down); }
.pill.QUIET { color: var(--quiet); }

.empty {
  margin: 8px 0 16px;
  color: var(--muted);
}

.meter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.meter strong { color: var(--ink); font-weight: 500; }

.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 99px;
  background: var(--up);
}

.live-dot.down { background: var(--down); }
.live-dot.held { background: var(--heat); }

.tape-title {
  margin: 18px 0 8px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  font-weight: 500;
  text-transform: uppercase;
}

td.kind {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sort-menu { max-width: 280px; margin: 0 0 12px; }

.sort-option {
  display: block;
  width: 100%;
  margin: 0;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.sort-option[aria-current="true"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

.sort-head {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 500;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}

th.num .sort-head { float: right; }

.sort-head.active { color: var(--ink); }

.sort-mark {
  display: inline-block;
  width: 0.8em;
  text-align: center;
}

tbody.settling { animation: settle 0.28s ease; }

@keyframes settle {
  from { opacity: 0.4; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .drawer,
  .chev,
  .nav-button,
  .fold,
  tbody.settling {
    transition: none;
    animation: none;
  }
  .drawer.open .drawer-inner > * { animation: none; }
  .nav-button:hover { transform: none; }
}

@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .rail {
    position: sticky;
    top: 0;
    z-index: 2;
    height: auto;
    max-height: 42vh;
    padding: 14px 12px 8px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .rail-groups { display: block; }
  .main { padding: 20px 16px 48px; }
  .summary, .path { grid-template-columns: 1fr; }
  h1 { font-size: 26px; }
}
