:root {
  --bg: #0d1015;
  --rail: #090b0f;
  --surface: #161a21;
  --surface-2: #1e232c;
  --line: #2b323d;
  --line-strong: #3d4757;
  --text: #eaeef3;
  --muted: #a1abba;
  --todo: #8db6ff;
  --in-progress: #ffc95c;
  --blocked: #ff7a7a;
  --done: #62d6a0;
  --focus: #ffffff;
  --sans: "Avenir Next", "Segoe UI", "Helvetica Neue", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --rail-w: 240px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
[data-status="todo"] { --c: var(--todo); }
[data-status="in-progress"] { --c: var(--in-progress); }
[data-status="blocked"] { --c: var(--blocked); }
[data-status="done"] { --c: var(--done); }

html { background: var(--bg); }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }
button, input, select { font: inherit; color: inherit; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--text); color: var(--bg); padding: 8px 14px; font-weight: 700;
}
.skip:focus { top: 12px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: 100vh; }

.rail {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 32px;
  padding: 28px 20px;
  background: var(--rail);
  border-right: 1px solid var(--line);
}
.brand { display: flex; gap: 12px; align-items: center; color: var(--text); }
.brand-mark { color: var(--in-progress); flex: none; }
.brand-name { font-weight: 800; font-size: 20px; letter-spacing: -0.02em; line-height: 1.1; }
.brand-sub { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-top: 3px; }

.rail-label, .eyebrow, .field label {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.rail-label { margin-bottom: 10px; }

.lanes-nav ul { display: grid; gap: 4px; }
.lane-btn {
  width: 100%; display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 10px;
  min-height: 44px; padding: 0 12px;
  background: transparent; border: 1px solid transparent; border-left: 3px solid var(--c, var(--line));
  text-align: left; cursor: pointer;
}
.lane-btn:hover { background: var(--surface); }
.lane-btn[aria-pressed="true"] { background: var(--surface-2); border-color: var(--line-strong); border-left-color: var(--c); }
.lane-btn .n { font-family: var(--mono); font-size: 15px; font-weight: 700; color: var(--c, var(--text)); }
.lane-btn .lbl { font-weight: 600; font-size: 15px; }

.rail-note { margin-top: auto; font-size: 13px; color: var(--muted); line-height: 1.5; border-top: 1px solid var(--line); padding-top: 16px; max-width: 26ch; }

.main { padding: 36px 36px 64px; min-width: 0; }

/* ---------- header ---------- */
.head { max-width: 1200px; }
.title {
  font-size: clamp(56px, 8vw, 104px); line-height: 0.9; font-weight: 800; letter-spacing: -0.05em;
  margin: 10px 0 24px;
}
.eyebrow { display: flex; align-items: center; gap: 8px; }
.eyebrow::before { content: ""; width: 24px; height: 2px; background: var(--in-progress); }

.spectrum { display: flex; height: 14px; gap: 3px; }
.spectrum span { display: block; background: var(--c); min-width: 6px; transition: flex-grow .35s ease; }
.spectrum-key { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-top: 10px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.spectrum-key li { display: flex; align-items: center; gap: 7px; }
.spectrum-key i { width: 10px; height: 10px; background: var(--c); display: block; }
.spectrum-key b { color: var(--text); font-weight: 700; }

/* ---------- toolbar ---------- */
.toolbar {
  display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap;
  margin: 32px 0 24px; padding: 16px 0;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.field { display: grid; gap: 6px; }
.field.grow { flex: 1 1 280px; max-width: 520px; }
.field input, .field select {
  height: 46px; padding: 0 14px; min-width: 190px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 2px;
}
.field input { width: 100%; }
.field input::placeholder { color: #8591a2; }
.field select { appearance: none; padding-right: 40px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text) 50%), linear-gradient(135deg, var(--text) 50%, transparent 50%);
  background-position: calc(100% - 20px) 20px, calc(100% - 15px) 20px; background-size: 5px 5px; background-repeat: no-repeat;
}
.field input:hover, .field select:hover { border-color: var(--muted); }
.result-count { margin-left: auto; font-family: var(--mono); font-size: 13px; color: var(--muted); padding-bottom: 12px; }

/* ---------- board ---------- */
.board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; align-items: start; outline: none; }
.board.single { grid-template-columns: minmax(0, 1fr); }
.board.single .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }

.lane { min-width: 0; }
.lane-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  padding: 0 0 10px; margin-bottom: 12px; border-bottom: 3px solid var(--c);
}
.lane-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 800; letter-spacing: 0.02em; text-transform: uppercase; }
.lane-title svg { color: var(--c); }
.lane-count { font-family: var(--mono); font-size: 28px; line-height: 1; font-weight: 700; color: var(--c); }
.cards { display: grid; gap: 10px; }

.card {
  position: relative; display: grid; gap: 8px;
  padding: 14px 14px 12px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 2px;
}
.card::before { content: ""; position: absolute; left: -1px; top: -1px; bottom: -1px; width: 4px; background: var(--c); }
.card:hover { background: var(--surface-2); border-color: var(--line-strong); }
.card:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.card.pulse { animation: pulse 1.4s ease-out; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 var(--c); } 30% { box-shadow: 0 0 0 4px var(--c); } 100% { box-shadow: 0 0 0 0 transparent; } }

.card-top { display: flex; justify-content: space-between; align-items: center; font-family: var(--mono); font-size: 12px; color: var(--muted); letter-spacing: 0.04em; }
.prio { display: inline-flex; align-items: center; gap: 6px; text-transform: uppercase; }
.prio .bars { display: inline-flex; gap: 2px; align-items: flex-end; height: 12px; }
.prio .bars i { width: 4px; background: var(--line-strong); display: block; }
.prio .bars i:nth-child(1) { height: 5px; }
.prio .bars i:nth-child(2) { height: 8px; }
.prio .bars i:nth-child(3) { height: 12px; }
.prio[data-p="low"] .bars i:nth-child(-n+1),
.prio[data-p="medium"] .bars i:nth-child(-n+2),
.prio[data-p="high"] .bars i { background: var(--text); }
.prio[data-p="high"] { color: var(--text); }

.card-title { font-size: 17px; line-height: 1.3; font-weight: 700; letter-spacing: -0.01em; }
.open {
  all: unset; cursor: pointer;
}
.open::after { content: ""; position: absolute; inset: 0; }
.open:focus-visible { outline: none; }
.card-project { font-size: 13px; color: var(--muted); }
.card-foot { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); padding-top: 8px; border-top: 1px dashed var(--line); }
.avatar {
  display: grid; place-items: center; width: 24px; height: 24px; flex: none; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--text);
  font-family: var(--mono); font-size: 10px; font-weight: 700;
}
.card-foot .who { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.card-foot .sp { margin-left: auto; white-space: nowrap; font-family: var(--mono); font-size: 12px; }

.lane-empty { padding: 18px 14px; border: 1px dashed var(--line-strong); color: var(--muted); font-size: 14px; }

/* ---------- empty ---------- */
.empty { max-width: 520px; margin: 48px 0; padding: 32px; border: 1px dashed var(--line-strong); display: grid; gap: 12px; justify-items: start; }
.empty-glyph { font-family: var(--mono); font-size: 40px; color: var(--blocked); letter-spacing: 0.1em; line-height: 1; }
.empty h2 { font-size: 24px; letter-spacing: -0.02em; }
.empty p { color: var(--muted); }

.btn {
  min-height: 44px; padding: 0 18px; cursor: pointer;
  background: var(--text); color: var(--bg); border: 0; border-radius: 2px; font-weight: 700;
}
.btn:hover { background: #fff; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line-strong); }
.btn.ghost:hover { background: var(--surface-2); }

/* ---------- detail ---------- */
.scrim { position: fixed; inset: 0; background: rgba(4, 6, 9, 0.66); z-index: 40; }
.detail {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
  width: min(560px, 100vw);
  display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--line-strong);
  box-shadow: -24px 0 60px rgba(0, 0, 0, 0.5);
}
.detail::before { content: ""; height: 6px; background: var(--c); flex: none; }
.detail-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 24px; border-bottom: 1px solid var(--line); flex: none; }
.detail-id { font-family: var(--mono); font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.detail-scroll { flex: 1; overflow-y: auto; padding: 24px 24px 40px; display: grid; gap: 24px; align-content: start; }
.detail-title { font-size: clamp(26px, 3.4vw, 34px); line-height: 1.12; letter-spacing: -0.03em; font-weight: 800; }

.status-box { display: grid; gap: 8px; padding: 16px; background: var(--bg); border: 1px solid var(--line-strong); border-left: 4px solid var(--c); }
.status-box label { font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.status-box select {
  height: 48px; padding: 0 40px 0 14px; width: 100%; cursor: pointer; appearance: none;
  background-color: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 2px; font-weight: 700; font-size: 17px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text) 50%), linear-gradient(135deg, var(--text) 50%, transparent 50%);
  background-position: calc(100% - 20px) 21px, calc(100% - 15px) 21px; background-size: 5px 5px; background-repeat: no-repeat;
}
.status-msg { min-height: 22px; font-size: 14px; color: var(--c); font-weight: 600; display: flex; align-items: center; gap: 8px; }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border-top: 1px solid var(--line); }
.facts div { padding: 12px 0; border-bottom: 1px solid var(--line); }
.facts dt { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 600; }
.facts .wide { grid-column: 1 / -1; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.tags span { font-family: var(--mono); font-size: 12px; padding: 2px 8px; border: 1px solid var(--line-strong); font-weight: 400; }

.body-copy { display: grid; gap: 14px; max-width: 60ch; }
.body-copy p { font-size: 17px; line-height: 1.6; }
.body-copy .outcome { padding: 14px 16px; background: var(--bg); border-left: 3px solid var(--text); }
.body-copy .outcome strong { display: block; font-family: var(--mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; font-weight: 400; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 80; transform: translate(-50%, 24px);
  display: flex; align-items: center; gap: 10px;
  max-width: calc(100vw - 32px); padding: 12px 18px;
  background: var(--text); color: var(--bg); font-weight: 600; font-size: 15px;
  border-left: 6px solid var(--c, var(--done));
  opacity: 0; pointer-events: none; visibility: hidden;
}
.toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: no-preference) {
  .toast { transition: opacity .2s, transform .2s, visibility .2s; }
  .detail { animation: slide .22s ease-out; }
  .scrim { animation: fade .22s ease-out; }
  @keyframes slide { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
  @keyframes fade { from { opacity: 0; } to { opacity: 1; } }
}
@media (prefers-reduced-motion: reduce) {
  .card.pulse { animation: none; outline: 2px solid var(--c); }
  .spectrum span { transition: none; }
}

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .board { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 16px; }
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .rail {
    position: static; height: auto; flex-direction: column; gap: 14px;
    padding: 16px 16px 14px; border-right: 0; border-bottom: 1px solid var(--line);
  }
  .rail-note { display: none; }
  .lanes-nav .rail-label { display: none; }
  .lanes-nav ul { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
  .lane-btn { width: auto; flex: none; grid-template-columns: auto auto; min-height: 44px; padding: 0 12px; gap: 8px; border: 1px solid var(--line); border-top: 3px solid var(--c); }
  .lane-btn svg, .lane-btn > span:empty { display: none; }
  .lane-btn[aria-pressed="true"] { border-color: var(--line-strong); border-top-color: var(--c); }
  .main { padding: 22px 16px 80px; }
  .title { font-size: 64px; margin-bottom: 18px; }
  .toolbar { margin: 22px 0 18px; gap: 12px; }
  .field.grow { flex-basis: 100%; max-width: none; }
  .field:not(.grow) { flex: 1; }
  .field select { width: 100%; min-width: 0; }
  .result-count { margin-left: 0; padding-bottom: 12px; }
  .board { grid-template-columns: 1fr; }
  .board.single .cards { grid-template-columns: 1fr; }
  .detail { width: 100vw; border-left: 0; }
  .detail-bar { padding: 10px 16px; }
  .detail-scroll { padding: 20px 16px 40px; }
  .facts { grid-template-columns: 1fr 1fr; }
  .toast { bottom: 16px; }
}
