:root {
  --bg: #0d1117; --panel: #161b22; --panel2: #1c2129; --line: #2a313c;
  --fg: #e6edf3; --muted: #8b949e; --accent: #4493f8; --accent2: #316dca;
  --ok: #3fb950; --warn: #d29922; --bad: #f85149; --purple: #a371f7;
  --radius: 8px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 14px/1.5 ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }
.err { color: var(--bad); min-height: 1.2em; }
a { color: var(--accent); }

input, select, textarea, button {
  font: inherit; color: var(--fg); background: var(--panel2);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px;
}
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; resize: vertical; width: 100%; }
button { cursor: pointer; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent2); border-color: var(--accent2); color: #fff; }
button.primary:hover { background: var(--accent); }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
label input, label select, label textarea { color: var(--fg); }
.chk { flex-direction: row; align-items: center; gap: 6px; }

/* ---------- auth ---------- */
.gate { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.auth { width: 340px; display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px; }
.auth h1 { margin: 0; font-size: 20px; }

/* ---------- top bar ---------- */
header#top {
  /* flex-wrap because #top is already a non-wrapping row holding a brand, a 260px search, three
     selects, a checkbox and four buttons — the project switcher is what pushes it over. */
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 14px;
  border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5;
}
.brand { margin-right: 6px; white-space: nowrap; }
#q { width: 260px; }
#fProject { font-weight: 600; }
.spacer { flex: 1 1 40px; }

/* ---------- board ---------- */
.board { display: flex; gap: 10px; padding: 14px; overflow-x: auto; align-items: flex-start; min-height: calc(100vh - 60px); }
.col { flex: 0 0 300px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 90px); }
.col > h2 { margin: 0; padding: 10px 12px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; }
.col.over { outline: 2px dashed var(--accent); outline-offset: -2px; }
.col .stack { padding: 8px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }

.cardItem { background: var(--panel2); border: 1px solid var(--line); border-left: 3px solid var(--line); border-radius: 6px; padding: 9px 10px; cursor: grab; }
.cardItem:hover { border-color: var(--muted); }
.cardItem.dragging { opacity: .4; }
.cardItem .t { display: block; margin: 4px 0 6px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.cardItem .meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 11px; color: var(--muted); }
.cardItem[data-p="highest"], .cardItem[data-p="high"] { border-left-color: var(--bad); }
.cardItem[data-p="medium"] { border-left-color: var(--warn); }
.cardItem[data-p="low"], .cardItem[data-p="lowest"] { border-left-color: var(--muted); }

.k { font-family: ui-monospace, monospace; font-size: 11px; color: var(--accent); text-decoration: none; }
.chip { border: 1px solid var(--line); border-radius: 99px; padding: 1px 7px; font-size: 11px; background: var(--panel); }
.chip.epic { color: var(--purple); border-color: #4b3a6e; }
.chip.blocked { color: var(--bad); border-color: #5c2b28; }
.chip.pr { color: var(--ok); border-color: #26492e; }
.chip.agent { color: var(--purple); border-color: #4b3a6e; text-transform: uppercase; letter-spacing: .06em; font-size: 10px; }
/* A live lease reads as "someone is on this"; a stale one as "you may take it". */
.chip.claimed { color: var(--accent); border-color: #24405f; background: #14243a; }
.chip.claimed.stale { color: var(--warn); border-color: #4a3a17; background: #2a2213; }
.avatar { width: 20px; height: 20px; border-radius: 99px; background: var(--accent2); color: #fff; display: grid; place-items: center; font-size: 10px; }
.type { font-size: 13px; }

/* ---------- sheets ---------- */
.sheet { width: min(860px, 94vw); max-height: 92vh; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--fg); }
.sheet::backdrop { background: #000a; }
.sheetHead { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
.sheetHead h2 { margin: 0; font-size: 16px; flex: 1; }
.sheetBody { padding: 18px; overflow-y: auto; max-height: calc(92vh - 130px); display: flex; flex-direction: column; gap: 14px; }
.sheetFoot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.x { background: none; border: none; font-size: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 .full { grid-column: 1 / -1; }
.row { display: flex; gap: 8px; }
.plain { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.plain li { display: flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; }
h3 { margin: 6px 0 0; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

/* ---------- detail ---------- */
.md { line-height: 1.65; overflow-wrap: anywhere; }
.md h1, .md h2, .md h3 { margin: 1em 0 .4em; }
.md code { background: var(--panel2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.md pre { background: var(--panel2); padding: 12px; border-radius: 6px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md img { max-width: 100%; border-radius: 6px; }
.md blockquote { margin: 0; padding-left: 12px; border-left: 3px solid var(--line); color: var(--muted); }
.md table { border-collapse: collapse; }
.md td, .md th { border: 1px solid var(--line); padding: 4px 8px; }
.facts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.comment { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--panel2); }
.comment .who { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.evt { font-size: 12px; color: var(--muted); border-left: 2px solid var(--line); padding-left: 10px; }
.drop { border: 1px dashed var(--line); border-radius: 8px; padding: 14px; text-align: center; color: var(--muted); }
.drop.over { border-color: var(--accent); color: var(--accent); }
pre#tokOut { background: var(--panel2); padding: 10px; border-radius: 6px; overflow-x: auto; user-select: all; }

/* ---------- bulk triage + shortcuts ---------- */
.cardItem .pick { width: 13px; height: 13px; margin: 0 2px 0 0; accent-color: var(--accent); opacity: 0; }
.cardItem:hover .pick, .cardItem.picked .pick { opacity: 1; }
.cardItem.picked { border-color: var(--accent); background: #1b2942; }
.bulkBar {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 20;
  display: flex; gap: 8px; align-items: center; padding: 10px 14px;
  background: var(--panel); border: 1px solid var(--accent); border-radius: 10px;
  box-shadow: 0 8px 28px #000a;
}
.help {
  position: fixed; bottom: 16px; right: 16px; z-index: 20; font-size: 12px; color: var(--muted);
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px;
}
.help b { color: var(--fg); font-family: ui-monospace, monospace; }
