:root {
  --bg-0: #07111f;
  --bg-1: #0b1b31;
  --bg-2: #102442;
  --line: #1e3a62;
  --line-strong: #355a8a;
  --text-0: #f8fbff;
  --text-1: #c9d6e5;
  --text-2: #91a4bd;
  --red-0: #e21b2d;
  --red-1: #ff4b5c;
  --red-2: #8f111d;
  --white: #ffffff;
  --white-2: #f4f7fb;
  --white-3: #e6edf5;
  --focus: #ffffff;
  --shadow: rgba(0, 0, 0, 0.35);
  --scale: 1;
  --radius: 18px;
  --panel: rgba(11, 27, 49, 0.88);
  --panel-strong: rgba(16, 36, 66, 0.98);
  --status-done: #2cd4a6;
  --status-progress: #ffbd2e;
  --status-blocked: #ff5c74;
  --status-planned: #90a4c7;
  --status-needs: #ff7c4a;
  --status-review: #b88cff;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--text-0);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(226, 27, 45, 0.15), transparent 25%),
    radial-gradient(circle at top right, rgba(53, 90, 138, 0.18), transparent 22%),
    linear-gradient(180deg, #07111f 0%, #081422 46%, #060d18 100%);
  min-height: 100vh;
}

button, input { font: inherit; }
button { cursor: pointer; }

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 1000;
  background: var(--white);
  color: #081422;
  padding: 8px 12px;
  border-radius: 10px;
}
.skip-link:focus { left: 12px; top: 12px; }

.topbar {
  display: grid;
  grid-template-columns: minmax(250px, 1.1fr) minmax(420px, 1.9fr);
  gap: 20px;
  padding: 22px 22px 14px;
  position: relative;
  z-index: 30;
  backdrop-filter: blur(18px);
  background: linear-gradient(180deg, rgba(7,17,31,0.96) 0%, rgba(7,17,31,0.78) 100%);
  border-bottom: 1px solid rgba(150, 180, 220, 0.16);
}

.brand h1 { margin: 0; font-size: clamp(28px, 3vw, 38px); line-height: 1.05; }
.brand p { margin: 8px 0 0; color: var(--text-1); max-width: 58ch; }
.brand__kicker {
  color: var(--white-2);
  text-transform: uppercase;
  letter-spacing: .18em;
  font-size: 12px;
  margin-bottom: 10px;
  opacity: .84;
}

.controls {
  display: grid;
  gap: 10px;
  align-content: start;
}
.controls input[type="search"] {
  width: 100%;
  border: 1px solid rgba(191, 210, 235, 0.18);
  border-radius: 14px;
  padding: 14px 16px;
  color: var(--text-0);
  background: rgba(5, 12, 23, 0.82);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}
.controls input[type="search"]::placeholder { color: var(--text-2); }
.controls input[type="search"]:focus { outline: 2px solid var(--focus); outline-offset: 2px; }

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  border: 1px solid rgba(191, 210, 235, 0.18);
  background: rgba(12, 27, 49, 0.9);
  color: var(--text-1);
  border-radius: 999px;
  padding: 8px 12px;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.chip:hover { transform: translateY(-1px); border-color: rgba(255,255,255,.3); }
.chip[aria-pressed="true"] {
  background: linear-gradient(180deg, rgba(226,27,45,.24), rgba(14,31,57,.92));
  color: var(--text-0);
  border-color: rgba(255,91,107,.6);
}
.chip__count {
  font-size: 12px;
  color: var(--text-2);
}
.chip[aria-pressed="true"] .chip__count { color: rgba(255,255,255,0.72); }

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.btn {
  border: 1px solid rgba(191, 210, 235, 0.18);
  background: linear-gradient(180deg, rgba(17, 35, 62, 0.96), rgba(10, 22, 40, 0.96));
  color: var(--text-0);
  border-radius: 12px;
  padding: 10px 14px;
  min-height: 40px;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.btn:hover { transform: translateY(-1px); border-color: rgba(255,255,255,.34); }
.btn:focus-visible, .chip:focus-visible, .node:focus-visible, .stage__toggle:focus-visible, .direction-toggle:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.btn--ghost { background: rgba(10, 22, 40, 0.56); }
.btn--small { padding: 8px 12px; min-height: 36px; font-size: 13px; }

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  padding: 18px 22px 28px;
  align-items: start;
}

.legend-panel, .gaps-panel, .diagnostics, .drawer {
  background: var(--panel);
  border: 1px solid rgba(191, 210, 235, 0.16);
  border-radius: 22px;
  box-shadow: 0 18px 46px var(--shadow);
}
.legend-panel {
  grid-column: 1 / -1;
  margin: 0;
  padding: 14px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  align-items: center;
}
.legend-item { display:flex; align-items:center; gap:10px; color: var(--text-1); }
.legend-note { color: var(--text-2); flex: 1 1 280px; }
.dot { width: 12px; height: 12px; border-radius: 999px; display: inline-block; }
.dot--current { background: var(--line-strong); }
.dot--milestone { background: var(--red-0); }
.dot--target { background: var(--white-2); box-shadow: 0 0 0 2px rgba(7,17,31,.5) inset; }
.dot--blocked { background: var(--status-blocked); }

.board-shell {
  position: relative;
  background: linear-gradient(180deg, rgba(10, 22, 40, 0.55), rgba(7, 17, 31, 0.22));
  border: 1px solid rgba(191, 210, 235, 0.12);
  border-radius: 24px;
  overflow: hidden;
  min-height: 72vh;
}
.viewport {
  overflow: auto;
  position: relative;
  min-height: 72vh;
}
.board {
  position: relative;
  min-width: 1120px;
  padding: 18px 18px 44px;
  zoom: var(--scale);
  transform: none;
  transform-origin: top left;
}
.connectors {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  overflow: visible;
}
.direction-card {
  position: relative;
  z-index: 1;
  background: linear-gradient(180deg, rgba(10, 23, 42, 0.88), rgba(10, 20, 36, 0.96));
  border: 1px solid rgba(150, 180, 220, 0.18);
  border-radius: 24px;
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}
.direction-card.is-hidden { display: none; }
.direction-card__head {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: start;
}
.direction-card__priority {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--red-1);
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 12px;
  margin-bottom: 6px;
}
.direction-card__title { margin: 0; font-size: clamp(20px, 2vw, 28px); }
.direction-card__summary { margin: 10px 0 14px; color: var(--text-1); max-width: 94ch; }
.direction-card__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.direction-card.is-selected { box-shadow: 0 0 0 1px rgba(255,255,255,.18), 0 18px 40px rgba(0,0,0,.3); }

.direction-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.95fr) minmax(0, 1.7fr) minmax(220px, 0.95fr);
  gap: 14px;
  align-items: start;
}
.stages-column { min-width: 0; }
.direction-stage-list {
  display: grid;
  gap: 12px;
}

.node {
  position: relative;
  border-radius: 18px;
  padding: 16px;
  border: 1px solid rgba(191, 210, 235, 0.18);
  min-height: 100%;
  display: grid;
  gap: 10px;
  background: rgba(12, 27, 49, 0.88);
  color: var(--text-0);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}
.node:hover { border-color: rgba(255,255,255,.3); }
.node--current { background: linear-gradient(180deg, rgba(14, 34, 63, 0.95), rgba(10, 24, 45, 0.96)); }
.node--target {
  background: linear-gradient(180deg, rgba(244,247,251,0.98), rgba(226,237,245,0.96));
  color: #081422;
  border-color: rgba(226, 27, 45, 0.3);
}
.node--target .node__text, .node--target .node__footer, .node--target .node__label { color: #334862; }
.node--blocked { border-style: dashed; border-color: rgba(255, 92, 116, 0.65); }
.node--milestone { background: linear-gradient(180deg, rgba(13, 26, 45, 0.96), rgba(8, 16, 29, 0.95)); }
.node--milestone::before,
.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid rgba(226,27,45,0.12);
  pointer-events: none;
}
.node__label {
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .1em;
  font-size: 11px;
}
.node__title { font-weight: 700; font-size: 17px; line-height: 1.2; }
.node__text { color: var(--text-1); font-size: 14px; line-height: 1.5; }
.node__footer { display:flex; flex-wrap:wrap; gap:8px; color: var(--text-2); font-size: 12px; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 10px;
  border: 1px solid rgba(191, 210, 235, 0.16);
  background: rgba(8, 16, 29, 0.6);
}
.badge--status-done { border-color: rgba(44, 212, 166, 0.55); color: #b8ffe9; }
.badge--status-in_progress { border-color: rgba(255, 189, 46, 0.6); color: #ffe6a6; }
.badge--status-blocked { border-color: rgba(255, 92, 116, 0.6); color: #ffb0bd; }
.badge--status-planned { border-color: rgba(144, 164, 199, 0.5); color: #d5e0f0; }
.badge--status-needs_data { border-color: rgba(255, 124, 74, 0.6); color: #ffd2c2; }
.badge--status-review_needed { border-color: rgba(184, 140, 255, 0.6); color: #e7d7ff; }
.badge--priority { text-transform: uppercase; letter-spacing: .12em; }

.stage {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(191, 210, 235, 0.15);
  background: rgba(9, 18, 32, 0.9);
}
.stage__toggle {
  position: relative;
  z-index: 1;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text-0);
  border: 0;
  padding: 14px 14px 12px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
}
.stage__title { font-weight: 700; }
.stage__meta { color: var(--text-2); font-size: 12px; }
.stage__body {
  padding: 0 14px 14px;
  display: grid;
  gap: 10px;
}
.stage.is-collapsed .stage__body { display: none; }
.stage.is-collapsed .stage__toggle { border-bottom: 0; }
.milestone {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(226,27,45,0.18);
  background: rgba(15, 28, 50, 0.76);
}
.milestone__head { display:flex; justify-content:space-between; gap: 10px; align-items: start; }
.milestone__title { font-weight: 700; }
.milestone__task { color: var(--text-1); font-size: 13px; line-height: 1.45; }
.milestone__meta { color: var(--text-2); font-size: 12px; }
.milestone__chiprow { display:flex; flex-wrap:wrap; gap:6px; }

.list { margin: 0; padding-left: 18px; color: var(--text-1); }
.list li + li { margin-top: 8px; }
.drawer {
  position: sticky;
  top: 18px;
  padding: 18px;
  max-height: calc(100vh - 192px);
  overflow: auto;
}
.drawer__empty { color: var(--text-1); }
.drawer__empty h2 { margin-top: 0; }
.drawer__content.hidden, .hidden { display: none !important; }
.drawer__head { display:flex; justify-content:space-between; gap: 12px; align-items:flex-start; }
.drawer__eyebrow { color: var(--red-1); text-transform: uppercase; letter-spacing: .12em; font-size: 11px; margin-bottom: 6px; }
.drawer__meta { display:flex; flex-wrap:wrap; gap:8px; margin: 14px 0; }
.drawer__summary { color: var(--text-1); margin: 0 0 16px; line-height: 1.55; }
.drawer__grid { display:grid; grid-template-columns: 1fr; gap: 12px; }
.drawer section { margin-top: 16px; }
.drawer h3 { margin: 0 0 8px; font-size: 16px; }
.drawer p { margin: 0; color: var(--text-1); line-height: 1.55; }
.drawer__actions { display:flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

.gaps-panel {
  margin: 0 22px 22px;
  padding: 16px;
}
.panel-head h2 { margin: 0; }
.panel-head p { margin: 6px 0 0; color: var(--text-1); }
.gaps-list { display:grid; gap: 12px; margin-top: 14px; }
.gap-card {
  border: 1px solid rgba(191, 210, 235, 0.15);
  border-radius: 18px;
  background: rgba(9, 18, 32, 0.82);
  padding: 14px;
  display: grid;
  gap: 8px;
}
.gap-card__head { display:flex; justify-content:space-between; gap: 10px; align-items:flex-start; }
.gap-card__title { font-weight: 700; }
.gap-card__summary { color: var(--text-1); line-height: 1.5; }
.gap-card__meta { color: var(--text-2); font-size: 12px; display:flex; flex-wrap:wrap; gap: 8px; }

.diagnostics {
  margin: 0 22px 22px;
  padding: 14px 16px;
  white-space: pre-wrap;
  color: var(--text-1);
}

@media (max-width: 1260px) {
  .topbar, .shell { grid-template-columns: 1fr; }
  .drawer { position: static; max-height: none; }
}

@media (max-width: 960px) {
  .direction-grid { grid-template-columns: 1fr; }
  .board { min-width: 0; }
  .shell { padding-inline: 14px; }
  .topbar { padding-inline: 14px; }
  .gaps-panel, .diagnostics { margin-inline: 14px; }
  .direction-card__head { flex-direction: column; }
}

@media (max-width: 720px) {
  .topbar { gap: 12px; padding-top: 16px; }
  .brand h1 { font-size: 30px; }
  .brand p { margin-top: 6px; }
  .controls { gap: 8px; }
  .toolbar-actions, .chip-row {
    gap: 6px;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 3px;
    scrollbar-width: none;
  }
  .toolbar-actions::-webkit-scrollbar, .chip-row::-webkit-scrollbar { display: none; }
  .btn, .chip { width: auto; flex: 0 0 auto; }
  .chip { padding: 7px 10px; }
  .btn { min-height: 38px; padding: 8px 12px; }
  .direction-card { padding: 14px; }
  .node, .stage, .milestone { border-radius: 16px; }
  .drawer { padding: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
