
:root {
  color-scheme: dark;
  --passepartout: #202123;
  --canvas: #0d0e10;
  --surface-raised: #111214;
  --surface-soft: #15171a;
  --surface-input: #0b0c0e;
  --border: #2c2f32;
  --border-strong: #3d4145;
  --text: #e2e1dc;
  --muted: #74777b;
  --muted-strong: #aaa9a4;
  --accent: #2997ff;
  --accent-soft: rgba(41, 151, 255, 0.10);
  --positive: #20e3a2;
  --negative: #ff4d67;
  --warning: #e2ad68;
  --focus-ring: rgba(41, 151, 255, 0.82);
  --bg: var(--canvas);
  --panel: var(--surface-raised);
  --line: var(--border);
  --warn: var(--warning);
  --bad: var(--negative);
  --good: var(--positive);
}

* { box-sizing: border-box; }

html { background: var(--canvas); }

body,
body.help-page {
  margin: 0;
  min-width: 0;
  overflow-x: hidden;
  color: var(--text);
  background-color: var(--canvas);
  background-image:
    linear-gradient(rgba(255,255,255,.012) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.012) 1px, transparent 1px);
  background-size: 24px 24px;
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.5;
  letter-spacing: 0;
}

button,
input,
select,
textarea { font: inherit; }

a,
.nav-link,
.watch-link {
  color: var(--accent);
  text-decoration: none;
}

a:hover { color: #71baff; }

a:focus-visible,
button:focus-visible,
.info:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

header,
.help-page header {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  min-height: 116px;
  padding: 24px 32px 22px;
  border: 0;
  border-bottom: 1px dashed var(--border-strong);
  background: rgba(13, 14, 16, .96);
}

header::after {
  content: "SYS-168 / LOCAL-01";
  position: absolute;
  top: 14px;
  right: 32px;
  color: #45484c;
  font-size: 9px;
}

.brand-block { min-width: 0; }

.eyebrow {
  margin-bottom: 5px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
.help-page h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(22px, 2.4vw, 34px);
  font-weight: 700;
  line-height: 1.1;
}

.header-subtitle {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  padding-top: 18px;
}

.nav-link {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.nav-link:hover,
.nav-link.active { color: var(--accent); }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border: 1px dashed var(--border-strong);
  border-radius: 1px;
  color: var(--muted-strong);
  background: transparent;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.badge::before {
  content: "";
  width: 5px;
  height: 5px;
  margin-right: 6px;
  background: var(--positive);
  box-shadow: 0 0 8px rgba(32, 227, 162, .42);
}

.badge.strong { color: var(--positive); background: rgba(32, 227, 162, .06); border-color: rgba(32, 227, 162, .48); }
.badge.watch { color: var(--warning); background: rgba(226, 173, 104, .06); border-color: rgba(226, 173, 104, .48); }
.badge.risk { color: var(--negative); background: rgba(255, 77, 103, .06); border-color: rgba(255, 77, 103, .48); }
.badge.strong::before, .badge.watch::before, .badge.risk::before { display: none; }

main {
  display: grid;
  grid-template-columns: 294px minmax(0, 1fr);
  min-height: calc(100vh - 116px);
}

aside {
  position: sticky;
  top: 0;
  align-self: start;
  max-height: calc(100vh - 1px);
  overflow: auto;
  border: 0;
  border-right: 1px dashed var(--border-strong);
  background: rgba(13, 14, 16, .88);
}

.aside-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 13px;
  border-bottom: 1px dashed var(--border);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
}

.aside-heading small {
  color: var(--muted);
  font-size: 8px;
}

.video-list {
  display: grid;
  gap: 0;
  background: transparent;
}

.video-button {
  position: relative;
  appearance: none;
  width: 100%;
  padding: 15px 18px;
  border: 0;
  border-bottom: 1px dashed var(--border);
  color: var(--muted-strong);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.video-button::before {
  content: ">";
  position: absolute;
  left: 7px;
  color: transparent;
}

.video-button:hover {
  color: var(--text);
  background: var(--surface-raised);
}

.video-button.active {
  color: var(--text);
  background: var(--accent-soft);
  box-shadow: inset 2px 0 0 var(--accent);
}

.video-button.active::before { color: var(--accent); }

.video-title {
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.video-meta {
  margin-top: 7px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
  text-transform: uppercase;
}

.content {
  min-width: 0;
  padding: 26px 28px 56px;
  overflow: visible;
}

#detail:not(.empty) {
  position: relative;
  max-width: 1680px;
  margin: 0 auto;
  padding: 22px;
  border: 1px dashed var(--border-strong);
  animation: terminal-reveal 280ms ease-out both;
}

#detail:not(.empty)::before,
#detail:not(.empty)::after,
.panel::before,
.metric::after {
  content: "";
  position: absolute;
  width: 13px;
  height: 13px;
  pointer-events: none;
}

#detail:not(.empty)::before {
  top: -1px;
  left: -1px;
  border-top: 1px solid var(--accent);
  border-left: 1px solid var(--accent);
}

#detail:not(.empty)::after {
  right: -1px;
  bottom: -1px;
  border-right: 1px solid var(--accent);
  border-bottom: 1px solid var(--accent);
}

.regime-banner {
  margin: 0 0 20px;
  padding: 10px 13px;
  border: 1px dashed rgba(41, 151, 255, .48);
  border-left: 2px solid var(--accent);
  border-radius: 1px;
  color: var(--muted-strong);
  background: var(--accent-soft);
  font-size: 10px;
}

.regime-banner strong { color: var(--accent); }
.regime-banner.mixed { border-color: rgba(226, 173, 104, .48); border-left-color: var(--warning); color: var(--muted-strong); background: rgba(226, 173, 104, .06); }
.regime-banner.mixed strong { color: var(--warning); }

.hero {
  display: grid;
  grid-template-columns: minmax(240px, 360px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  margin-bottom: 26px;
}

.thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 1px solid var(--border-strong);
  border-radius: 1px;
  background: var(--surface-soft);
  filter: saturate(.82) contrast(1.04);
}

.title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 13px;
  border-bottom: 1px dashed var(--border);
}

h2 {
  margin: 0;
  color: var(--text);
  font-size: 21px;
  line-height: 1.24;
}

.watch-link {
  padding: 5px 8px;
  border: 1px dashed var(--accent);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
}

.watch-link::before { content: "[ "; }
.watch-link::after { content: " ]"; }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(118px, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.metric,
.panel {
  position: relative;
  border: 1px dashed var(--border);
  border-radius: 1px;
  color: var(--text);
  background: rgba(17, 18, 20, .74);
  box-shadow: none;
}

.metric {
  min-height: 78px;
  padding: 11px 12px;
}

.metric:hover { border-color: var(--border-strong); background: var(--surface-raised); }

.metric::after {
  top: -1px;
  right: -1px;
  border-top: 1px solid var(--accent);
  border-right: 1px solid var(--accent);
}

.metric-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
}

.metric-value {
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.info {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  color: var(--muted-strong);
  background: var(--surface-input);
  font-size: 9px;
  font-weight: 700;
  cursor: help;
}

.info::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  width: min(280px, 75vw);
  padding: 9px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 1px;
  color: var(--text);
  background: #090a0b;
  box-shadow: 0 12px 28px rgba(0,0,0,.38);
  font-size: 10px;
  font-weight: 400;
  line-height: 1.45;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 3px);
  transition: opacity 100ms ease, transform 100ms ease;
  z-index: 30;
}

.info:hover::after,
.info:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }

.strategy-checks { white-space: normal; overflow-wrap: anywhere; }
.strategy-checks summary { cursor: pointer; color: var(--muted-strong); font-size: 11px; }
.strategy-checks p { font-size: 11px; line-height: 1.6; margin: 8px 0 0; }

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.42fr) minmax(410px, .78fr);
  gap: 14px;
  align-items: start;
}

.grid > div,
.panel { min-width: 0; }

.panel {
  margin-bottom: 14px;
  padding: 16px;
}

.panel::before {
  top: -1px;
  right: -1px;
  border-top: 1px solid var(--accent);
  border-right: 1px solid var(--accent);
}

.panel h3,
.panel h2 {
  margin: 0 0 15px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.4;
  text-transform: uppercase;
}

.panel h3::before,
.panel h2::before { content: "[ "; }
.panel h3::after,
.panel h2::after { content: " ]"; }

.panel h4 {
  margin: 16px 0 10px;
  color: var(--muted-strong);
  font-size: 10px;
  text-transform: uppercase;
}

.chart-wrap { position: relative; height: 410px; }

.table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  contain: inline-size;
}

table {
  width: 100%;
  border-collapse: collapse;
  color: var(--muted-strong);
  font-size: 10px;
}

th,
td {
  padding: 9px 8px;
  border-bottom: 1px dashed var(--border);
  vertical-align: top;
  text-align: left;
  overflow-wrap: anywhere;
}

th {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
}

tbody tr:hover { background: rgba(255,255,255,.018); }
tbody tr:last-child > * { border-bottom: 0; }

.strategy-table,
.checkpoint-table { min-width: 600px; table-layout: fixed; }

.strategy-table th,
.strategy-table td,
.checkpoint-table th,
.checkpoint-table td { font-size: 9px; }

.strategy-version {
  display: block;
  margin-top: 3px;
  color: var(--accent);
  font-size: 8px;
  font-weight: 400;
  text-transform: none;
}

.status-cell { color: var(--muted-strong); }

.v2-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 18px;
  margin-bottom: 14px;
}

.v2-stat {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 10px;
}

.v2-stat span { color: var(--muted); }
.v2-stat strong { color: var(--text); text-align: right; }

.bucket-list { display: grid; gap: 9px; }
.bucket-row { display: grid; grid-template-columns: 74px minmax(80px, 1fr) 38px; gap: 8px; align-items: center; font-size: 9px; }
.bucket-track { height: 5px; overflow: hidden; border: 1px solid var(--border); border-radius: 0; background: var(--surface-input); }
.bucket-fill { height: 100%; background: var(--accent); }
.bucket-probability { color: var(--muted); text-align: right; }

.empty {
  padding: 28px 16px;
  color: var(--muted);
  text-align: center;
  font-size: 10px;
}

pre,
code {
  color: var(--muted-strong);
  background: var(--surface-input);
  font-family: inherit;
}

pre {
  margin: 0;
  padding: 12px;
  overflow: auto;
  border: 1px dashed var(--border);
  border-radius: 1px;
  font-size: 10px;
}

/* Help is the same system rendered as a technical document. */
.help-page main {
  display: block;
  width: min(1180px, calc(100% - 40px));
  min-height: auto;
  margin: 0 auto;
  padding: 28px 0 56px;
}

.help-page .panel { padding: 20px; margin-bottom: 14px; }
.help-page .panel p { color: var(--muted-strong); font-size: 11px; }
.help-page .panel p strong { color: var(--text); }
.help-page .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

.help-page .strategy {
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: 1px;
  background: rgba(13, 14, 16, .72);
}

.help-page .strategy h3 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 11px;
  text-transform: none;
}

.help-page .strategy h3::before,
.help-page .strategy h3::after { content: none; }
.help-page ul { color: var(--muted); font-size: 10px; }

.help-page .term {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 18px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
  color: var(--muted-strong);
  font-size: 10px;
}

.help-page .term strong { color: var(--text); }
.help-page .note { color: var(--warning) !important; }

@keyframes terminal-reveal {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1400px) {
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  header,
  .help-page header { align-items: flex-start; min-height: 0; padding: 20px; }
  header::after { display: none; }
  main { grid-template-columns: 1fr; }
  aside { position: static; max-height: 238px; border-right: 0; border-bottom: 1px dashed var(--border-strong); }
  .content { padding: 18px; }
  #detail:not(.empty) { padding: 16px; }
  .hero { grid-template-columns: 1fr; }
  .thumb { max-width: 520px; }
  .help-page .grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  body,
  body.help-page { font-size: 12px; }
  header,
  .help-page header { display: block; padding: 16px; }
  h1,
  .help-page h1 { font-size: 22px; }
  .header-actions { justify-content: flex-start; gap: 12px; padding-top: 18px; }
  .content { padding: 10px; }
  #detail:not(.empty) { padding: 11px; }
  .regime-banner { margin-bottom: 14px; }
  .hero { gap: 15px; margin-bottom: 18px; }
  .title-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  h2 { font-size: 17px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { min-height: 72px; padding: 9px; }
  .metric-value { font-size: 14px; }
  .panel { padding: 12px; }
  .chart-wrap { height: 310px; }
  .v2-stats { grid-template-columns: 1fr; }
  .help-page main { width: calc(100% - 20px); padding: 10px 0 32px; }
  .help-page .panel { padding: 14px; }
  .help-page .term { grid-template-columns: 1fr; gap: 3px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
