:root {
  --bg: #0e1113;
  --panel: #151a1d;
  --panel-2: #1b2125;
  --line: #2a3237;
  --line-2: #3a454b;
  --text: #eaeef0;
  --muted: #a1acb3;
  --accent: #c8f33a;
  --accent-ink: #11160a;

  --c-todo: #7cc4ff;
  --c-in-progress: #ffc857;
  --c-blocked: #ff7d6e;
  --c-done: #62e3a4;

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: "Helvetica Neue", "Segoe UI", Roboto, Arial, sans-serif;
  --rail: 280px;
  --detail: 460px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

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

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

.skip {
  position: absolute; left: 8px; top: -60px; z-index: 100;
  background: var(--accent); color: var(--accent-ink);
  padding: 8px 12px; border-radius: 3px; font-weight: 700;
}
.skip:focus { top: 8px; }

/* ---------- layout ---------- */
.app { display: block; min-height: 100vh; }
.workspace {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  min-height: 100vh;
}
.app.has-detail .workspace {
  margin-right: var(--detail);
}

/* ---------- rail ---------- */
.rail {
  position: sticky; top: 0; align-self: start;
  height: 100vh; overflow-y: auto;
  padding: 28px 24px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 28px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 38px; height: 38px; color: var(--accent); flex: none; }
.brand-name { font-weight: 800; font-size: 22px; letter-spacing: -0.03em; line-height: 1.1; }
.brand-sub { font-family: var(--mono); font-size: 12px; color: var(--muted); letter-spacing: .02em; }

.controls { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
label, .rail-label {
  font-family: var(--mono); font-size: 12px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}
input[type="search"], select {
  width: 100%; min-height: 44px;
  background: var(--bg); border: 1px solid var(--line-2); border-radius: 3px;
  padding: 8px 12px; color: var(--text);
}
input[type="search"]::placeholder { color: #7f8b92; }
select {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  padding-right: 38px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 52%, calc(100% - 15px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
input[type="search"]:hover, select:hover { border-color: #55646c; }
input[type="search"]:focus-visible, select:focus-visible { outline-offset: 0; border-color: var(--accent); }

.views ul { margin-top: 10px; display: flex; flex-direction: column; gap: 2px; }
.view-btn {
  width: 100%; min-height: 40px; display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; background: transparent; border: 1px solid transparent;
  border-radius: 3px; cursor: pointer; text-align: left; color: var(--text);
}
.view-btn:hover { background: var(--panel-2); }
.view-btn .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--muted)); flex: none; }
.view-btn .n { margin-left: auto; font-family: var(--mono); font-size: 13px; color: var(--muted); }
.view-btn[aria-pressed="true"] { background: var(--panel-2); border-color: var(--line-2); font-weight: 700; }
.view-btn[aria-pressed="true"] .n { color: var(--text); }

.tally { margin-top: auto; }
.bar { display: flex; height: 12px; margin-top: 10px; gap: 2px; background: var(--bg); }
.bar span { background: var(--c); min-width: 0; transition: flex-grow .3s; }
.tally-text { margin-top: 10px; font-family: var(--mono); font-size: 13px; color: var(--muted); }
.tally-text b { color: var(--text); }

/* ---------- main ---------- */
.main { padding: 40px 48px 80px; min-width: 0; max-width: 1080px; }
.main-head { margin-bottom: 28px; }
.eyebrow { font-family: var(--mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
h1 { font-size: clamp(40px, 5vw, 64px); line-height: 1; letter-spacing: -0.045em; font-weight: 800; margin-top: 8px; }
h1:focus { outline: none; }
.count { margin-top: 12px; font-family: var(--mono); font-size: 13px; color: var(--muted); }

.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  position: relative;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 24px;
  padding: 16px 20px 16px 24px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 3px;
}
.item::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px;
  background: var(--c);
}
.item:hover { background: var(--panel-2); border-color: var(--line-2); }
.item.is-open { border-color: var(--accent); background: var(--panel-2); }
.item.flash { animation: flash 1.4s ease-out; }
@keyframes flash {
  0% { background: color-mix(in srgb, var(--c) 28%, var(--panel)); }
  100% { background: var(--panel); }
}
.item h3 { font-size: 18px; line-height: 1.3; font-weight: 700; letter-spacing: -0.01em; }
.open {
  all: unset; cursor: pointer; display: inline; color: var(--text);
}
.open::after { content: ""; position: absolute; inset: 0; }
.open:focus-visible { outline: none; }
.open:focus-visible::after { outline: 2px solid var(--accent); outline-offset: 2px; }
.item:hover .open { text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 4px; }
.summary {
  margin-top: 4px; color: var(--muted); font-size: 15px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.meta { margin-top: 10px; font-family: var(--mono); font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 14px; }
.meta b { color: var(--text); font-weight: 600; }
.side { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; padding-top: 2px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  font-family: var(--mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--c); border: 1px solid color-mix(in srgb, var(--c) 55%, transparent);
  background: color-mix(in srgb, var(--c) 10%, transparent);
  padding: 3px 10px 3px 8px; border-radius: 99px;
}
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.prio { display: inline-flex; align-items: center; gap: 3px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.prio i { display: block; width: 4px; height: 12px; background: var(--line-2); }
.prio[data-p="low"] i:nth-child(-n+1),
.prio[data-p="medium"] i:nth-child(-n+2),
.prio[data-p="high"] i:nth-child(-n+3) { background: var(--text); }
.prio span { margin-left: 5px; }
.cmt { font-family: var(--mono); font-size: 12px; color: var(--muted); }

[data-status="todo"] { --c: var(--c-todo); }
[data-status="in-progress"] { --c: var(--c-in-progress); }
[data-status="blocked"] { --c: var(--c-blocked); }
[data-status="done"] { --c: var(--c-done); }

/* ---------- empty ---------- */
.empty {
  border: 1px dashed var(--line-2); border-radius: 3px; padding: 56px 24px;
  text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.empty-mark { font-size: 56px; line-height: 1; color: var(--accent); font-family: var(--mono); }
.empty h2 { font-size: 24px; letter-spacing: -0.02em; }
.empty p:not(.empty-mark) { color: var(--muted); max-width: 40ch; }
.btn {
  min-height: 44px; padding: 8px 18px; margin-top: 10px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-weight: 700;
  border: 0; border-radius: 3px;
}
.btn:hover { filter: brightness(1.08); }

/* ---------- detail ---------- */
.detail {
  position: fixed; top: 0; right: 0; bottom: 0; width: var(--detail); z-index: 40;
  background: var(--panel); border-left: 1px solid var(--line-2);
  display: flex; flex-direction: column;
}
.detail-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 24px; border-bottom: 1px solid var(--line); flex: none;
}
.detail-id { font-family: var(--mono); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.close {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 14px;
  background: transparent; border: 1px solid var(--line-2); border-radius: 3px; cursor: pointer;
}
.close:hover { background: var(--panel-2); border-color: #55646c; }
.close svg { width: 16px; height: 16px; }
.detail-scroll { overflow-y: auto; padding: 28px 24px 48px; flex: 1; }
.detail h2 { font-size: 30px; line-height: 1.12; letter-spacing: -0.03em; font-weight: 800; overflow-wrap: anywhere; }
.detail h2:focus { outline: none; }

.status-box {
  margin-top: 24px; padding: 16px; border: 1px solid var(--line-2); border-left: 5px solid var(--c);
  border-radius: 3px; background: var(--bg);
}
.status-box select { border-color: var(--c); }
.saved { margin-top: 10px; min-height: 20px; font-family: var(--mono); font-size: 13px; color: var(--c); }
.note {
  margin-top: 12px; padding: 10px 12px; font-size: 14px; color: var(--text);
  background: color-mix(in srgb, var(--accent) 10%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); border-radius: 3px;
}
.link {
  background: none; border: 0; padding: 4px 2px; cursor: pointer; font-weight: 700;
  color: var(--accent); text-decoration: underline; text-underline-offset: 3px; min-height: 32px;
}
.body { margin-top: 28px; white-space: pre-line; font-size: 17px; line-height: 1.6; color: #dbe1e4; max-width: 62ch; }

.facts { margin-top: 32px; 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: 11.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin-top: 2px; font-weight: 600; }
.tags { margin-top: 20px; display: flex; flex-wrap: wrap; gap: 8px; }
.tags li { font-family: var(--mono); font-size: 12.5px; padding: 3px 10px; border: 1px solid var(--line-2); border-radius: 3px; color: var(--muted); }

.scrim { position: fixed; inset: 0; background: rgba(4, 6, 7, .66); z-index: 30; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 90;
  transform: translate(-50%, 24px); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 14px; max-width: min(560px, calc(100vw - 24px));
  background: var(--text); color: #11161a; padding: 12px 16px; border-radius: 3px;
  box-shadow: 0 10px 40px rgba(0,0,0,.5); font-size: 15px; font-weight: 600;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast .link { color: #11161a; }
.toast:not(.show) .link { visibility: hidden; }

/* ---------- overlay mode (narrower than docked) ---------- */
@media (max-width: 1180px) {
  .app.has-detail .workspace { margin-right: 0; }
  .detail { width: min(540px, 100%); box-shadow: -20px 0 60px rgba(0,0,0,.5); }
  .main { padding: 32px 32px 80px; }
}

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  .workspace { display: block; }
  .rail {
    position: static; height: auto; overflow: visible; gap: 16px;
    padding: 16px 16px 14px; border-right: 0; border-bottom: 1px solid var(--line);
  }
  .brand-mark { width: 30px; height: 30px; }
  .brand-name { font-size: 19px; }
  .controls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .controls .field:first-child { grid-column: 1 / -1; }
  .views { order: 3; }
  .views ul { flex-direction: row; overflow-x: auto; gap: 6px; margin: 8px -16px 0; padding: 2px 16px 6px; scrollbar-width: thin; }
  .view-btn { width: auto; flex: none; border: 1px solid var(--line-2); border-radius: 99px; min-height: 44px; padding: 6px 14px; }
  .tally { order: 4; margin-top: 0; }
  .main { padding: 24px 16px 96px; }
  .main-head { margin-bottom: 20px; }
  .item { grid-template-columns: 1fr; padding: 14px 14px 14px 20px; }
  .item h3 { font-size: 17px; }
  .side { flex-direction: row; align-items: center; flex-wrap: wrap; justify-content: flex-start; gap: 8px 14px; order: 2; }
  .detail { width: 100%; border-left: 0; }
  .detail-bar { padding: 8px 16px; }
  .detail-scroll { padding: 20px 16px 48px; }
  .detail h2 { font-size: 26px; }
  .body { font-size: 16px; }
  .scrim { display: none; }
  .toast { bottom: 12px; }
}

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