:root {
  color-scheme: dark;
  --bg: #0d0e11;
  --side: #111216;
  --panel: #16171c;
  --panel-2: #1c1d23;
  --hover: #1f2027;
  --line: #25262d;
  --line-2: #2e3038;
  --ink: #ececef;
  --ink-2: #b4b5bd;
  --muted: #7d7f89;
  --faint: #5a5c66;
  --accent: #e3a008;
  --accent-ink: #1c1400;

  /* priority (ordinal) */
  --p-critical: #f2555a;
  --p-high: #f08a4b;
  --p-medium: #d8b04a;
  --p-low: #6f7480;

  /* completed type (categorical slots 1–3, dark steps) */
  --t-feature: #3987e5;
  --t-improvement: #199e70;
  --t-security: #d95926;

  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

.app { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }

/* ---------- sidebar ---------- */
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--side); border-right: 1px solid var(--line); padding: 16px 10px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.logo {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 7px;
  background: var(--accent); color: var(--accent-ink); font-size: 15px; line-height: 1;
}
.logo { background: none; overflow: hidden; }
.logo svg { display: block; }
.brand-name { font-weight: 650; font-size: 15px; letter-spacing: -.01em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 7px;
  color: var(--ink-2); white-space: nowrap;
}
.nav-item:hover { background: var(--hover); color: var(--ink); }
.nav-item.is-on { background: var(--panel-2); color: var(--ink); }
.nav-ico { width: 16px; text-align: center; font-size: 12px; color: var(--muted); }
.ico-issue { color: var(--p-critical); font-size: 10px; }
.ico-idea { color: #9085e9; }
.ico-done { color: var(--t-improvement); }
.nav-label { flex: 1; }
.nav-count { font: 12px var(--mono); color: var(--muted); }
.side-foot {
  margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 8px;
  font-size: 12px; color: var(--muted); white-space: nowrap;
}
.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--t-improvement); box-shadow: 0 0 0 3px color-mix(in srgb, var(--t-improvement) 25%, transparent); }

/* ---------- top bar ---------- */
.main { min-width: 0; padding: 0 28px 40px; }
.bar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: 56px; margin: 0 -28px 20px; padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
h1 { margin: 0; font-size: 15px; font-weight: 600; white-space: nowrap; }
.bar-tools { display: flex; align-items: center; gap: 12px; min-width: 0; }
.search { position: relative; display: flex; align-items: center; }
.search input {
  width: 240px; background: var(--panel); border: 1px solid var(--line); border-radius: 7px;
  padding: 5px 30px 5px 10px; outline: none; font-size: 13px;
}
.search input:focus { border-color: var(--line-2); background: var(--panel-2); }
.search kbd { position: absolute; right: 7px; }
kbd {
  display: inline-block; min-width: 17px; padding: 0 4px; border: 1px solid var(--line-2); border-radius: 4px;
  background: var(--panel-2); color: var(--muted); font: 11px/16px var(--mono); text-align: center;
}
.chips { display: flex; gap: 4px; }
.me {
  display: inline-flex; align-items: center; gap: 7px; max-width: 200px; padding: 3px 10px 3px 8px;
  border: 1px solid var(--line); border-radius: 999px; font-size: 12px; color: var(--ink-2); white-space: nowrap;
}
.me-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
.me-name { overflow: hidden; text-overflow: ellipsis; }
button.me { background: transparent; cursor: pointer; }
button.me:hover:not(:disabled) { border-color: var(--line-2); color: var(--ink); background: var(--panel); }
button.me:focus-visible { outline: 2px solid var(--line-2); outline-offset: 1px; }
button.me:disabled { cursor: default; }

/* ---------- name popup ---------- */
.name-dlg {
  width: min(340px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line-2); border-radius: var(--radius);
  background: var(--panel); color: var(--ink); box-shadow: 0 16px 48px rgba(0, 0, 0, .55);
}
.name-dlg::backdrop { background: rgba(0, 0, 0, .5); }
.nd-form { display: flex; flex-direction: column; gap: 8px; padding: 16px; }
.nd-label { font-size: 13px; font-weight: 600; white-space: nowrap; }
.nd-input {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 7px;
  padding: 7px 10px; outline: none; font-size: 14px;
}
.nd-input:focus { border-color: var(--accent); }
.nd-hint { margin: 0; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nd-err { margin: 0; font-size: 12px; color: var(--p-critical); }
.nd-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.nd-btn {
  border: 1px solid var(--line-2); background: transparent; border-radius: 7px; padding: 5px 12px;
  font-size: 13px; color: var(--ink-2); cursor: pointer; white-space: nowrap;
}
.nd-btn:hover { color: var(--ink); background: var(--hover); }
.nd-save { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.nd-save:hover { background: var(--accent); color: var(--accent-ink); filter: brightness(1.08); }
.nd-save:disabled { opacity: .6; cursor: default; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: transparent;
  border-radius: 6px; padding: 3px 9px; cursor: pointer; font-size: 12px; color: var(--muted); white-space: nowrap;
}
.chip:hover { color: var(--ink); border-color: var(--line-2); }
.chip.is-on { background: var(--panel-2); border-color: var(--line-2); color: var(--ink); }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi {
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
}
.kpi-label { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-val { font: 600 26px/1.15 var(--mono); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- panels ---------- */
.grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 12px; margin-bottom: 12px; }
.grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.panel {
  position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; min-width: 0;
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel-head h2 { margin: 0; font-size: 13px; font-weight: 600; white-space: nowrap; }
.panel-note { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-link { font-size: 12px; color: var(--muted); white-space: nowrap; }
.panel-link:hover { color: var(--ink); }

/* chart */
.legend { display: flex; gap: 14px; margin: -4px 0 10px; font-size: 12px; color: var(--ink-2); }
.lg { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.sw { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.sw-feature { background: var(--t-feature); }
.sw-improvement { background: var(--t-improvement); }
.sw-security { background: var(--t-security); }
.chart { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 6px; height: 236px; }
.axis { position: relative; font: 11px var(--mono); color: var(--faint); }
.axis span { position: absolute; right: 0; transform: translateY(50%); }
.plot { position: relative; display: flex; flex-direction: column; min-width: 0; }
.bars {
  position: relative; flex: 1; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px;
  align-items: end; border-bottom: 1px solid var(--line-2);
}
.gridline { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--line); pointer-events: none; }
.col { position: relative; height: 100%; display: flex; flex-direction: column-reverse; align-items: center; cursor: default; }
.col:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); border-radius: 4px 4px 0 0; }
.stack { width: 62%; max-width: 22px; display: flex; flex-direction: column-reverse; gap: 2px; }
.seg { width: 100%; }
.stack .seg:last-child { border-radius: 4px 4px 0 0; }
.seg-feature { background: var(--t-feature); }
.seg-improvement { background: var(--t-improvement); }
.seg-security { background: var(--t-security); }
.xlabels { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; height: 20px; }
.xlabels span { text-align: center; font: 11px/20px var(--mono); color: var(--faint); white-space: nowrap; overflow: hidden; }
.xlabels span { display: flex; justify-content: center; overflow: visible; }
.xlabels span.x-today { justify-content: flex-end; }
@media (max-width: 360px) { .xlabels span.x-on:not(.x-6) { visibility: hidden; } }
.tip {
  position: absolute; z-index: 4; pointer-events: none; min-width: 150px;
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45); font-size: 12px;
}
.tip b { display: block; margin-bottom: 4px; font-weight: 600; }
.tip-row { display: flex; align-items: center; gap: 6px; color: var(--ink-2); white-space: nowrap; }
.tip-row em { margin-left: auto; padding-left: 12px; font: normal 12px var(--mono); color: var(--ink); }

/* next up */
.next { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.next li {
  display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); cursor: pointer;
}
.next li:hover { border-color: var(--line-2); }
.next li:first-child { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.n-rank { font: 12px var(--mono); color: var(--muted); text-align: center; }
.n-main { min-width: 0; }
.n-title { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.n-sub { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); white-space: nowrap; }

/* priority bars */
.pribars { display: flex; flex-direction: column; gap: 10px; }
.pb { display: grid; grid-template-columns: 76px minmax(0, 1fr) 54px; align-items: center; gap: 10px; font-size: 12px; }
.pb-label { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-2); white-space: nowrap; }
.pb-track { display: flex; gap: 2px; height: 10px; }
.pb-seg { height: 100%; border-radius: 2px; min-width: 3px; }
.pb-issue { background: var(--ink-2); }
.pb-idea { background: var(--faint); }
.pb-n { font: 12px var(--mono); color: var(--muted); text-align: right; white-space: nowrap; }
.pb-legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 2px; }
.pb-legend .sw.issue { background: var(--ink-2); }
.pb-legend .sw.idea { background: var(--faint); }

/* feed */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li .type { justify-self: start; }
.feed li {
  display: grid; grid-template-columns: 116px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 6px 0; border-bottom: 1px solid var(--line);
}
.feed li:last-child { border-bottom: 0; }
.f-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.f-date { font: 12px var(--mono); color: var(--muted); white-space: nowrap; }

/* ---------- dots, badges ---------- */
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot-critical { background: var(--p-critical); box-shadow: 0 0 0 3px color-mix(in srgb, var(--p-critical) 25%, transparent); }
.dot-high { background: var(--p-high); }
.dot-medium { background: var(--p-medium); }
.dot-low, .dot-none { background: var(--p-low); }
.type {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); white-space: nowrap;
  padding: 1px 8px 1px 6px; border: 1px solid var(--line-2); border-radius: 999px;
}
.type i { width: 7px; height: 7px; border-radius: 2px; flex: none; }
.type-feature i { background: var(--t-feature); }
.type-improvement i { background: var(--t-improvement); }
.type-security i { background: var(--t-security); }
.tag {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; line-height: 16px; color: var(--ink-2); white-space: nowrap;
  padding: 0 7px 0 5px; border: 1px solid var(--line-2); border-radius: 999px;
}
.tag i { width: 6px; height: 6px; border-radius: 2px; flex: none; background: var(--muted); }
.tag-feature i { background: var(--t-feature); }
.tag-follow-up i { background: #2bb5a6; }
.tag-research i { background: #9085e9; }
.tag-cleanup i, .tag-limitation i { background: #8b8e98; }
.tag-ops i { background: #3fc1d9; }
.tag-security i { background: var(--t-security); }
.tag-bug i { background: var(--p-critical); }
.tag-performance i { background: #e0a93a; }
.tag-ci i { background: #6b7ea3; }
.tag-docs i { background: #4fb26a; }
.tagsel { display: flex; }
.tagsel select {
  appearance: none; -webkit-appearance: none; border: 1px solid var(--line); border-radius: 6px;
  padding: 3px 22px 3px 9px; font-size: 12px; color: var(--muted); cursor: pointer; outline: none; white-space: nowrap;
  background: transparent linear-gradient(45deg, transparent 50%, currentColor 50%) no-repeat calc(100% - 11px) 50% / 4px 4px;
}
.tagsel select:hover, .tagsel select:focus-visible { color: var(--ink); border-color: var(--line-2); }
.tagsel select.is-on { background-color: var(--panel-2); border-color: var(--line-2); color: var(--ink); }
.tagsel option { background: var(--panel); color: var(--ink); }
.n-sub { overflow: hidden; }
.sec-flag {
  font: 10px/16px var(--mono); text-transform: uppercase; letter-spacing: .05em; color: var(--t-security);
  border: 1px solid color-mix(in srgb, var(--t-security) 50%, transparent); border-radius: 4px; padding: 0 5px; white-space: nowrap;
}
.busy {
  font: 10px/16px var(--mono); text-transform: uppercase; letter-spacing: .05em; color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 50%, transparent); border-radius: 4px; padding: 0 5px; white-space: nowrap;
}
.dot-busy { background: var(--accent); }
.busy.is-stale { color: var(--p-critical); border-color: color-mix(in srgb, var(--p-critical) 50%, transparent); }
.stale-note { color: var(--p-critical); }
.next-busy { margin: 10px 0 0; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.next-busy a { color: var(--accent); }
.next-busy a:hover { text-decoration: underline; }
.r-claim a.pr { color: var(--accent); }
.pr { font: 12px var(--mono); color: var(--muted); white-space: nowrap; }
.pr:hover { color: var(--ink); text-decoration: underline; }

/* ---------- list views ---------- */
.table { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table:empty { display: none; }
.group-head {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--panel-2);
  border-bottom: 1px solid var(--line); font-size: 12px; color: var(--ink-2); font-weight: 600; white-space: nowrap;
}
.group-head .g-n { font: 12px var(--mono); color: var(--muted); font-weight: 400; }
.row { border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row-line {
  display: grid; align-items: center; gap: 12px; padding: 8px 14px; cursor: pointer; min-height: 38px;
  grid-template-columns: 96px minmax(0, 1fr) auto 110px 80px;
}
.row[data-kind="done"] .row-line { grid-template-columns: 150px minmax(0, 1fr) auto 110px; }
.r-by { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-line:hover { background: var(--hover); }
.row-line:focus-visible { outline: 2px solid var(--line-2); outline-offset: -2px; }
.row-line .type { justify-self: start; }
.r-pri { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.pri-sel {
  appearance: none; -webkit-appearance: none; margin: 0 0 0 -5px; padding: 1px 5px; min-width: 0;
  background: transparent; border: 1px solid transparent; border-radius: 5px;
  font-size: 12px; color: var(--ink-2); cursor: pointer; outline: none;
}
.pri-sel:hover { background: var(--panel-2); border-color: var(--line-2); color: var(--ink); }
.pri-sel:focus-visible { border-color: var(--line-2); color: var(--ink); }
.pri-sel:disabled { opacity: .6; cursor: default; }
.pri-sel.is-err { border-color: var(--p-critical); color: var(--p-critical); }
.pri-sel option { background: var(--panel); color: var(--ink); }
.pri-sel option:disabled { color: var(--muted); }
.row.is-moved .row-line { background: color-mix(in srgb, var(--accent) 10%, transparent); transition: background .6s; }
.r-title { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.r-age { font: 12px var(--mono); color: var(--muted); text-align: right; white-space: nowrap; }
.r-age.is-old { color: var(--p-high); }
.r-extra { display: flex; align-items: center; gap: 8px; }
.r-body {
  display: none; padding: 2px 14px 14px 122px; color: var(--ink-2); font-size: 13.5px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.row[data-kind="done"] .r-body { padding-left: 176px; }
.row.is-open .r-body { display: block; }
.row.is-open .row-line { background: var(--hover); }
.r-body .r-meta { display: block; margin-top: 10px; font: 12px var(--mono); color: var(--muted); white-space: normal; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; margin: 0; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid, .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; align-items: center; padding: 8px 10px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0 8px 0 0; }
  .brand-name, .side-foot { display: none; }
  .nav { flex-direction: row; }
  .main { padding: 0 14px 32px; }
  .bar { margin: 0 -14px 14px; padding: 0 14px; height: auto; min-height: 52px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
  .bar-tools { width: 100%; }
  .chips { flex: 1; overflow-x: auto; scrollbar-width: none; }
  .search input { width: 130px; }
  .me { max-width: 120px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row-line { grid-template-columns: 14px minmax(0, 1fr) auto auto; }
  .row[data-kind="done"] .row-line { grid-template-columns: 24px minmax(0, 1fr) auto; }
  .row[data-kind="done"] .type { border: 0; padding: 0; }
  .r-pri-label, .row[data-kind="done"] .type span { display: none; }
  .row-line .r-extra .pr { display: none; }
  .row-line .tag { border: 0; padding: 0; }
  .row-line .tag span { display: none; }
  .row-line .r-by { display: none; }
  .r-body, .row[data-kind="done"] .r-body { padding-left: 14px; }
}
