/* OpenPuzzle Manager — functional, dense, quiet. Colours: the data-viz
   reference palette (chrome, status, and an ordinal blue ramp for stages),
   validated light and dark. */

:root {
  color-scheme: light;
  --page: #f3f3f0;
  --surface: #fcfcfb;
  --surface-2: #f6f6f3;
  --surface-3: #ecebe6;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6c6b66;
  --line: rgba(11, 11, 11, 0.10);
  --line-2: rgba(11, 11, 11, 0.18);
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-soft: rgba(42, 120, 214, 0.12);
  --on-accent: #ffffff;
  --hl: #eb6834;
  --good: #0ca30c;
  --good-ink: #006300;
  --good-soft: rgba(12, 163, 12, 0.14);
  --warn: #fab219;
  --warn-ink: #7a5200;
  --warn-soft: rgba(250, 178, 25, 0.24);
  --critical: #d03b3b;
  --critical-ink: #b02a2a;
  --critical-soft: rgba(208, 59, 59, 0.12);
  --stage-idea: #c3c2b7;
  --stage-building: #86b6ef;
  --stage-playtesting: #5598e7;
  --stage-ready: #256abf;
  --stage-public: #104281;
  --stage-parked: #c3c2b7;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.10);
  --radius: 8px;
  --topbar-h: 52px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #151514;
    --surface-3: #2c2c2a;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #a3a29b;
    --line: rgba(255, 255, 255, 0.10);
    --line-2: rgba(255, 255, 255, 0.18);
    --grid: #2c2c2a;
    --axis: #4a4a46;
    --accent: #3987e5;
    --accent-ink: #86b6ef;
    --accent-soft: rgba(57, 135, 229, 0.20);
    --hl: #d95926;
    --good-ink: #2fc42f;
    --good-soft: rgba(12, 163, 12, 0.22);
    --warn-ink: #fab219;
    --warn-soft: rgba(250, 178, 25, 0.16);
    --critical-ink: #ec7a7a;
    --critical-soft: rgba(208, 59, 59, 0.22);
    --stage-idea: #4a4a46;
    --stage-building: #184f95;
    --stage-playtesting: #256abf;
    --stage-ready: #5598e7;
    --stage-public: #9ec5f4;
    --stage-parked: #4a4a46;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #151514;
  --surface-3: #2c2c2a;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #a3a29b;
  --line: rgba(255, 255, 255, 0.10);
  --line-2: rgba(255, 255, 255, 0.18);
  --grid: #2c2c2a;
  --axis: #4a4a46;
  --accent: #3987e5;
  --accent-ink: #86b6ef;
  --accent-soft: rgba(57, 135, 229, 0.20);
  --hl: #d95926;
  --good-ink: #2fc42f;
  --good-soft: rgba(12, 163, 12, 0.22);
  --warn-ink: #fab219;
  --warn-soft: rgba(250, 178, 25, 0.16);
  --critical-ink: #ec7a7a;
  --critical-soft: rgba(208, 59, 59, 0.22);
  --stage-idea: #4a4a46;
  --stage-building: #184f95;
  --stage-playtesting: #256abf;
  --stage-ready: #5598e7;
  --stage-public: #9ec5f4;
  --stage-parked: #4a4a46;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* ── base ───────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); }
h1, h2, h3, h4, h5 { margin: 0; line-height: 1.25; }
h1 { font-size: 20px; font-weight: 650; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 650; }
p { margin: 0 0 8px; }
code { font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-3); padding: 1px 4px; border-radius: 4px; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
.grow { flex: 1; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ── controls ───────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border: 1px solid var(--line-2); border-radius: 6px;
  background: var(--surface); color: var(--ink);
  font-size: 13px; font-weight: 550; text-decoration: none; white-space: nowrap;
  cursor: pointer;
}
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-sm { height: 26px; padding: 0 8px; font-size: 12px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
:root[data-theme="dark"] .btn-primary:hover { color: #0b0b0b; }
.btn-danger { background: var(--critical); border-color: var(--critical); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--accent-ink); }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-block { width: 100%; height: 38px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px; flex: none;
  border: 0; border-radius: 6px; background: transparent; color: var(--ink-2); cursor: pointer; font-size: 15px;
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.icon-btn-sm { width: 22px; height: 22px; font-size: 12px; }
.link { border: 0; background: none; padding: 0; color: var(--accent-ink); cursor: pointer; text-align: left; }
.link:hover { text-decoration: underline; }

.input, .select {
  height: 32px; padding: 0 8px;
  border: 1px solid var(--line-2); border-radius: 6px;
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 13px; min-width: 0;
}
textarea.input { height: auto; padding: 6px 8px; resize: vertical; line-height: 1.4; }
.select { padding-right: 4px; }
.select-sm { height: 26px; font-size: 12px; }
.input:focus, .select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.input-date { width: 140px; }
.input-abbr { width: 64px; text-align: center; }
.search { width: 200px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 550; color: var(--ink-2); margin-bottom: 10px; }
.field .input, .field .select { font-weight: 400; }
.inline-field { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }
.row { display: flex; gap: 8px; align-items: flex-end; }
.row .field { margin-bottom: 10px; }
.row-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 7px; overflow: hidden; background: var(--surface); flex-wrap: wrap; }
.seg-btn {
  display: inline-flex; align-items: center; gap: 5px;
  height: 28px; padding: 0 10px; border: 0; border-right: 1px solid var(--line);
  background: transparent; font-size: 12px; color: var(--ink-2); cursor: pointer; white-space: nowrap;
}
.seg-btn:last-child { border-right: 0; }
.seg-btn:hover { background: var(--surface-3); }
.seg-btn.on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.seg-full { display: flex; width: 100%; }
.seg-full .seg-btn { flex: 1; justify-content: center; }
.seg-btn.seg-done.on { background: var(--good-soft); color: var(--good-ink); }
.seg-btn.seg-doing.on { background: var(--warn-soft); color: var(--warn-ink); }
.seg-btn.seg-skip.on { background: var(--surface-3); color: var(--ink-2); }

.chip {
  display: inline-flex; align-items: center; gap: 3px; max-width: 100%;
  padding: 0 6px; height: 20px; border-radius: 10px;
  background: var(--surface-3); color: var(--ink-2); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip-obj { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.chip-warn { background: var(--warn-soft); color: var(--warn-ink); }
.chip-btn { border: 0; background: none; padding: 0; cursor: pointer; }
.badge { font-size: 11px; color: var(--ink-2); white-space: nowrap; }
.badge-overdue { color: var(--critical-ink); font-weight: 600; }
.overdue { color: var(--critical-ink); }

/* stage colours */
.stage-idea { --stage: var(--stage-idea); }
.stage-building { --stage: var(--stage-building); }
.stage-playtesting { --stage: var(--stage-playtesting); }
.stage-ready { --stage: var(--stage-ready); }
.stage-public { --stage: var(--stage-public); }
.stage-parked { --stage: var(--stage-parked); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--stage, var(--axis)); flex: none; }
.stage-chip {
  display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px 0 6px;
  border: 1px solid var(--line-2); border-radius: 10px; font-size: 11px; font-weight: 600; color: var(--ink-2); white-space: nowrap; background: var(--surface);
}
.stage-chip::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--stage); }

.avatar {
  display: inline-grid; place-items: center; flex: none;
  border-radius: 50%; background: var(--av, var(--axis)); color: #fff;
  font-weight: 700; line-height: 1; letter-spacing: -0.02em;
  box-shadow: 0 0 0 1.5px var(--surface);
}
.avatar-empty { background: transparent; border: 1px dashed var(--axis); box-shadow: none; }
.avatar-sys { width: 22px; height: 22px; background: var(--surface-3); color: var(--ink-2); font-size: 12px; }
.pz-icon { flex: none; }

/* ── shell ──────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h); display: flex; align-items: center; gap: 12px;
  padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-weight: 700; white-space: nowrap; }
.brand-mark { font-size: 20px; }
.brand-sub { font-weight: 400; color: var(--muted); }
.tabs { display: flex; gap: 2px; margin-left: 8px; overflow-x: auto; }
.tab { padding: 6px 10px; border-radius: 6px; color: var(--ink-2); text-decoration: none; font-weight: 550; white-space: nowrap; }
.tab:hover { background: var(--surface-3); color: var(--ink); }
.tab.on { background: var(--accent-soft); color: var(--accent-ink); }
.jump-wrap { position: relative; }
.jump { width: 220px; }
.jump-list {
  position: absolute; top: 36px; right: 0; width: 300px; z-index: 40;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: var(--shadow); padding: 4px;
}
.jump-item { display: block; width: 100%; padding: 6px 8px; border: 0; background: none; text-align: left; border-radius: 5px; cursor: pointer; }
.jump-item.on, .jump-item:hover { background: var(--accent-soft); }
.jump-empty { padding: 6px 8px; }
.user-btn { border: 0; background: none; padding: 0; cursor: pointer; border-radius: 50%; display: grid; }

.body { display: flex; align-items: flex-start; min-height: calc(100vh - var(--topbar-h)); }
.main { flex: 1; min-width: 0; padding: 16px 20px 48px; outline: none; }

.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.view-sub { color: var(--muted); margin: 2px 0 0; font-size: 13px; }
.view-head-right { display: flex; gap: 8px; align-items: center; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.legend { display: flex; gap: 6px 16px; align-items: center; flex-wrap: wrap; margin: 0 0 10px; font-size: 12px; color: var(--ink-2); }
.legend-group { display: inline-flex; gap: 4px 12px; align-items: center; flex-wrap: wrap; }
.legend-title { font-weight: 650; color: var(--ink); }
.legend-item { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.legend-note { flex-basis: 100%; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }

/* ── board ──────────────────────────────────────────────────────────── */
.board { display: flex; gap: 10px; align-items: flex-start; overflow-x: auto; padding-bottom: 8px; }
.col {
  flex: 0 0 268px; display: flex; flex-direction: column;
  max-height: calc(100vh - var(--topbar-h) - 150px);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
}
.col-task { flex-basis: 280px; }
.col.drop-target { border-color: var(--accent); background: var(--accent-soft); }
.col-head { display: flex; align-items: center; gap: 7px; padding: 9px 10px 6px; font-weight: 650; font-size: 13px; }
.col-title { flex: 1; }
.col-count { color: var(--muted); font-weight: 500; font-size: 12px; }
.col-list { display: flex; flex-direction: column; gap: 6px; padding: 2px 6px 6px; overflow-y: auto; min-height: 36px; }
.drop-marker { height: 3px; border-radius: 2px; background: var(--accent); flex: none; }
.quick-add { padding: 4px 6px 8px; }
.quick-add .input { width: 100%; }
.quick-add-btn { width: 100%; justify-content: flex-start; color: var(--muted); }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; cursor: grab; flex: none;
}
.card:hover { border-color: var(--line-2); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06); }
.card:active { cursor: grabbing; }
.card.dragging { opacity: .35; }
.card.archived { opacity: .55; }
.card-title { display: flex; gap: 6px; align-items: baseline; font-weight: 600; line-height: 1.3; }
.card-meta { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 3px; font-size: 11.5px; color: var(--muted); }
.card-foot { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 11.5px; }
.card-foot:empty { display: none; }
.obj-strip { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 6px; }
.obj-pill {
  min-width: 23px; height: 17px; padding: 0 3px; border-radius: 4px;
  display: inline-grid; place-items: center;
  border: 1px solid var(--line-2); color: var(--muted);
  font-size: 10px; font-weight: 650; letter-spacing: .01em;
}
.obj-pill.st-done { background: var(--good-soft); border-color: transparent; color: var(--good-ink); }
.obj-pill.st-doing { background: var(--warn-soft); border-color: transparent; color: var(--warn-ink); }
.obj-pill.st-skip { border-style: dashed; opacity: .55; text-decoration: line-through; }

/* ── checklist (matrix) ─────────────────────────────────────────────── */
.table-wrap {
  overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  max-height: calc(100vh - var(--topbar-h) - 190px);
}
.matrix { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
.matrix th, .matrix td { border-bottom: 1px solid var(--line); padding: 0 8px; height: 36px; white-space: nowrap; text-align: left; }
.matrix thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); height: 46px; font-weight: 600; vertical-align: bottom; padding-bottom: 5px; }
.matrix .col-name { position: sticky; left: 0; z-index: 1; background: var(--surface); min-width: 200px; max-width: 260px; border-right: 1px solid var(--line); }
.matrix thead .col-name { z-index: 3; background: var(--surface-2); }
.matrix tbody tr:hover > * { background-color: var(--surface-2); }
.matrix tbody tr:hover > .cell.st-done { background-color: var(--good-soft); }
.matrix tr.archived { opacity: .55; }
.th-sort { border: 0; background: none; padding: 0; font-weight: 600; font-size: 12px; color: var(--ink-2); cursor: pointer; display: inline-flex; gap: 3px; }
.th-sort.on { color: var(--ink); }
.th-count { font-size: 11px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.col-obj { text-align: center !important; }
.matrix .cell { padding: 0; border-left: 1px solid var(--line); text-align: center; }
.cell-btn {
  position: relative; width: 100%; min-width: 74px; height: 35px;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  border: 0; background: transparent; cursor: pointer; font-size: 12px;
}
.cell-btn:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
.cell.st-done { background: var(--good-soft); color: var(--good-ink); }
.cell.st-doing { background: var(--warn-soft); color: var(--warn-ink); }
.cell.st-skip { color: var(--muted); background: repeating-linear-gradient(135deg, transparent 0 5px, var(--line) 5px 6px); }
.cell.st-todo .cell-btn:hover .cell-glyph::after { content: "+"; color: var(--muted); }
.cell-glyph { font-weight: 700; font-size: 13px; }
.cell-date { font-variant-numeric: tabular-nums; }
.cell-note { position: absolute; top: 0; right: 0; border-style: solid; border-width: 0 7px 7px 0; border-color: transparent var(--ink-2) transparent transparent; opacity: .5; }
.cell-swatch { display: inline-grid; place-items: center; width: 22px; height: 18px; border-radius: 4px; border: 1px solid var(--line); font-weight: 700; font-size: 11px; }
.cell-swatch.st-done { background: var(--good-soft); color: var(--good-ink); }
.cell-swatch.st-doing { background: var(--warn-soft); color: var(--warn-ink); }
.cell-swatch.st-skip { background: repeating-linear-gradient(135deg, transparent 0 4px, var(--line-2) 4px 5px); color: var(--muted); }
.row-link { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 0; cursor: pointer; font-weight: 600; max-width: 220px; }
.row-link .pz-name { overflow: hidden; text-overflow: ellipsis; }
.row-link:hover .pz-name { text-decoration: underline; }
.matrix .col-name .avatar { margin-left: 6px; vertical-align: middle; }
.col-date { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.col-progress { min-width: 110px; }
.progress { display: inline-block; width: 60px; height: 6px; border-radius: 3px; background: var(--surface-3); vertical-align: middle; overflow: hidden; }
.progress-bar { height: 100%; background: var(--good); border-radius: 3px; }
.progress-num { margin-left: 6px; font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.list-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.list-table th, .list-table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.list-table thead th { font-size: 12px; color: var(--ink-2); background: var(--surface-2); position: sticky; top: 0; }
.list-table .month-row th { background: var(--surface-2); font-size: 12px; color: var(--ink); position: static; }
.list-table tr.archived { opacity: .55; }

/* ── popovers, menus, modals ────────────────────────────────────────── */
.popover {
  position: absolute; z-index: 60; min-width: 180px; max-width: min(360px, calc(100vw - 16px));
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow);
}
.popover-cell { width: 400px; }
.cell-editor { padding: 12px; }
.ce-head { margin-bottom: 4px; }
.ce-desc { font-size: 12px; }
.cell-editor .seg { margin: 6px 0 10px; }
.cell-editor .seg-btn { padding: 0 6px; }
.ce-meta { font-size: 11px; }
.ce-foot { display: flex; justify-content: flex-end; }
.menu { padding: 4px; display: flex; flex-direction: column; }
.menu-item { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 0; background: none; border-radius: 6px; text-align: left; cursor: pointer; font-size: 13px; white-space: nowrap; }
.menu-item:hover { background: var(--surface-3); }
.menu-item.active { font-weight: 650; }
.menu-item.danger { color: var(--critical-ink); }
.menu-icon { width: 18px; display: inline-grid; place-items: center; }
.menu-sep { height: 1px; background: var(--line); margin: 4px 0; }
.modal-backdrop { position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, 0.35); display: grid; place-items: start center; padding: 10vh 16px 16px; overflow: auto; }
.modal { width: min(480px, 100%); background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.modal-wide { width: min(720px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px; }
.modal-body { padding: 4px 16px 8px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 16px 14px; border-top: 1px solid var(--line); }
.form .field .input, .form .field .select { width: 100%; }

#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; background: var(--ink); color: var(--surface); padding: 8px 14px; border-radius: 8px; font-size: 13px; box-shadow: var(--shadow); max-width: 90vw; transition: opacity .4s; }
.toast-error { background: var(--critical); color: #fff; }
.toast.out { opacity: 0; }

.lightbox { position: fixed; inset: 0; z-index: 95; background: rgba(0, 0, 0, 0.85); display: grid; place-items: center; padding: 24px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 80px); border-radius: 4px; background: #fff; }
.lightbox-open { position: absolute; bottom: 16px; right: 20px; color: #fff; }

/* ── drawer ─────────────────────────────────────────────────────────── */
.drawer { display: none; }
body.drawer-open .drawer {
  display: block; flex: none; position: sticky; top: var(--topbar-h);
  width: min(620px, 46vw); height: calc(100vh - var(--topbar-h));
  background: var(--surface); border-left: 1px solid var(--line);
}
.drawer-backdrop { display: none; }
.drawer-inner { display: flex; flex-direction: column; height: 100%; }
.drawer-head { display: flex; align-items: flex-start; gap: 8px; padding: 12px 12px 10px 16px; border-bottom: 1px solid var(--line); }
.drawer-title { flex: 1; min-width: 0; }
.title-input { width: 100%; border: 1px solid transparent; border-radius: 6px; background: transparent; font: inherit; font-size: 18px; font-weight: 650; padding: 2px 6px; margin-left: -6px; color: var(--ink); }
.title-input:hover { border-color: var(--line); }
.title-input:focus { border-color: var(--accent); outline: none; background: var(--surface); }
.drawer-sub { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); margin-top: 2px; align-items: center; }
.icon-pick { font-size: 26px; line-height: 1; border: 1px solid transparent; background: none; border-radius: 8px; padding: 4px; cursor: pointer; }
.icon-pick:hover { border-color: var(--line-2); }
.big-check { width: 20px; height: 20px; margin: 8px 4px 0 0; accent-color: var(--good); }
.drawer-scroll { flex: 1; overflow-y: auto; padding: 6px 16px 48px; }
.d-props { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; padding: 10px 0 6px; }
.d-prop { display: flex; flex-direction: column; gap: 3px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.d-prop > :not(.d-prop-label) { text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 13px; color: var(--ink); }
.stage-pick { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.d-section { border-top: 1px solid var(--line); padding: 12px 0 6px; margin-top: 8px; }
.d-section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; min-height: 26px; }
.d-section-head h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); }
.d-section-right { font-size: 12px; }
.obj-list { display: flex; flex-direction: column; gap: 2px; }
.obj-row {
  display: grid; grid-template-columns: 32px 1fr auto 20px; align-items: center; gap: 4px 10px;
  width: 100%; padding: 5px 8px; border: 0; border-radius: 6px; background: transparent; text-align: left; cursor: pointer;
}
.obj-row:hover { background: var(--surface-3); }
.obj-label { font-weight: 550; }
.obj-state { font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.obj-row.st-done .obj-state { color: var(--good-ink); }
.obj-row.st-doing .obj-state { color: var(--warn-ink); }
.obj-note { grid-column: 2 / -1; font-size: 12px; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.links .link-list { list-style: none; padding: 0; margin: 0 0 6px; display: flex; flex-direction: column; gap: 2px; }
.link-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.link-list a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-form { display: grid; grid-template-columns: 1fr 1.6fr auto auto; gap: 6px; }
.task-list { list-style: none; margin: 0 0 8px; padding: 0; }
.quick-task { width: 100%; }
.task-row { display: flex; align-items: center; gap: 8px; padding: 4px 2px; border-bottom: 1px solid var(--line); font-size: 13px; }
.task-row input { accent-color: var(--good); }
.task-title { flex: 1; min-width: 0; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-row.done .task-title { color: var(--muted); text-decoration: line-through; }
.history { list-style: none; margin: 0 0 6px; padding: 0; }
.history li { display: flex; gap: 10px; align-items: center; padding: 3px 0; font-size: 13px; }
.history-date { width: 100px; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.history-edit-row { display: flex; gap: 6px; margin-bottom: 6px; align-items: center; }
.hint { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px; margin: 8px 0; background: var(--warn-soft); border-radius: 8px; font-size: 13px; }

/* discussion */
.comment { display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.comment-main { min-width: 0; }
.comment-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; }
.comment-menu { margin-left: auto; }
.comment-body { margin-top: 2px; }
.composer { margin-top: 10px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); }
.composer.dragover { border-color: var(--accent); background: var(--accent-soft); }
.composer-input { display: block; width: 100%; border: 0; border-radius: 8px 8px 0 0; padding: 8px 10px; resize: none; font: inherit; font-size: 13.5px; background: transparent; color: var(--ink); min-height: 60px; }
.composer-input:focus { outline: none; }
.composer:focus-within { border-color: var(--accent); }
.composer-preview { padding: 8px 10px; min-height: 60px; }
.composer-bar { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.composer-hint { margin-left: auto; font-size: 11px; color: var(--muted); }

/* markdown */
.md { overflow-wrap: anywhere; font-size: 13.5px; }
.md p { margin: 0 0 6px; }
.md p:last-child { margin-bottom: 0; }
.md ul, .md ol { margin: 0 0 6px; padding-left: 20px; }
.md blockquote { margin: 0 0 6px; padding-left: 10px; border-left: 3px solid var(--line-2); color: var(--ink-2); }
.md pre { background: var(--surface-3); padding: 8px; border-radius: 6px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md h3, .md h4, .md h5 { margin: 8px 0 4px; font-size: 14px; }
.md-img { display: block; max-width: 100%; max-height: 360px; margin: 6px 0; border-radius: 6px; border: 1px solid var(--line); cursor: zoom-in; background: #fff; }
.mention { color: var(--accent-ink); font-weight: 600; }

/* ── activity ───────────────────────────────────────────────────────── */
.ev-feed { max-width: 860px; }
.ev-day { font-size: 12px; color: var(--muted); margin: 16px 0 4px; text-transform: uppercase; letter-spacing: .04em; }
.ev-list { list-style: none; margin: 0; padding: 0; }
.ev { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: start; padding: 6px 0; border-bottom: 1px solid var(--line); }
.ev-line { font-size: 13px; }
.ev-ref { font-weight: 550; }
.ev-excerpt { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; padding-left: 8px; border-left: 2px solid var(--line-2); }
.ev-time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.ev-compact .ev { padding: 4px 0; }

/* ── timeline ───────────────────────────────────────────────────────── */
.tl { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.tl-head { position: sticky; top: var(--topbar-h); z-index: 3; display: grid; grid-template-columns: var(--label-w) 1fr; background: var(--surface); border-bottom: 1px solid var(--line); border-radius: 10px 10px 0 0; }
.tl-corner { border-right: 1px solid var(--line); }
.tl-main { display: grid; grid-template-columns: var(--label-w) 1fr; }
.tl-labels { border-right: 1px solid var(--line); min-width: 0; }
.tl-label { display: flex; align-items: center; gap: 6px; width: 100%; padding: 0 10px; border: 0; background: none; font-size: 12.5px; color: var(--ink); cursor: pointer; text-align: left; white-space: nowrap; overflow: hidden; }
.tl-label .pz-name { overflow: hidden; text-overflow: ellipsis; }
.tl-label:hover { background: var(--surface-3); }
.tl-chart, .tl-head svg { display: block; overflow: hidden; }
.tl svg { display: block; }
.tl-tick { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.tl-tickline, .tl-grid { stroke: var(--grid); stroke-width: 1; }
.tl-today { stroke: var(--ink-2); stroke-width: 1; }
.tl-today-label { fill: var(--ink-2); font-size: 10px; font-weight: 650; font-family: var(--font); }
.tl-row { cursor: pointer; }
.tl-row-bg { fill: transparent; }
.tl-row:hover .tl-row-bg { fill: var(--surface-3); opacity: .6; }
.tl-band { fill: var(--stage); }
.tl-thin { stroke: var(--axis); stroke-width: 1.5; }
.tl-hit { fill: transparent; }
.tl-marker-shape { fill: var(--surface); stroke: var(--ink-2); stroke-width: 1.25; }
.tl-marker-text { fill: var(--ink); font-size: 9px; font-weight: 700; font-family: var(--font); pointer-events: none; }
.tl-marker.hl .tl-marker-shape { fill: var(--hl); stroke: var(--hl); }
.tl-marker.hl .tl-marker-text { fill: #fff; }
.tl-flag line { stroke: var(--ink); stroke-width: 1.5; }
.tl-flag path { fill: var(--ink); }
.tl-flag.hl line { stroke: var(--hl); stroke-width: 2; }
.tl-flag.hl path { fill: var(--hl); }
/* Dimmed marks change colour, not opacity: the marker fill must stay opaque over the band. */
.tl-marker.dim .tl-marker-shape { stroke: var(--axis); }
.tl-marker.dim .tl-marker-text { fill: var(--axis); }
.tl-flag.dim line { stroke: var(--axis); }
.tl-flag.dim path { fill: var(--axis); }
.tl-tip { position: absolute; z-index: 10; pointer-events: none; max-width: 300px; padding: 6px 9px; border-radius: 6px; background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow); font-size: 12px; line-height: 1.5; }
.band-swatch { display: inline-block; width: 18px; height: 8px; border-radius: 2px; background: var(--stage); }
.marker-swatch { display: inline-grid; place-items: center; min-width: 20px; height: 16px; padding: 0 3px; border-radius: 8px; border: 1.25px solid var(--ink-2); background: var(--surface); color: var(--ink); font-size: 9px; font-weight: 700; }
.flag-swatch { font-size: 13px; }

/* ── settings ───────────────────────────────────────────────────────── */
.settings-body { max-width: 880px; }
.card-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.card-panel h3 { margin: 16px 0 8px; }
.profile-head { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; }
.swatches { display: flex; gap: 6px; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--surface); background: var(--sw); box-shadow: 0 0 0 1px var(--line-2); cursor: pointer; }
.swatch.on { box-shadow: 0 0 0 2px var(--ink); }
.user-cell { display: flex; gap: 8px; align-items: center; }
.obj-table .input { width: 100%; }
.cell-arrows { white-space: nowrap; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 12px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; }

/* ── login ──────────────────────────────────────────────────────────── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-form { width: min(360px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 24px; box-shadow: var(--shadow); }
.login-form .input { width: 100%; height: 36px; }
.login-brand { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; font-size: 18px; }
.login-brand .brand-mark { font-size: 30px; }
.login-brand span:not(.brand-mark) { display: block; color: var(--muted); font-size: 13px; }
.form-error { color: var(--critical-ink); font-size: 13px; }

/* ── narrow screens ─────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  body.drawer-open .drawer { position: fixed; top: var(--topbar-h); right: 0; bottom: 0; z-index: 50; width: min(620px, 100vw); height: auto; box-shadow: var(--shadow); }
  body.drawer-open .drawer-backdrop { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 45; background: rgba(0, 0, 0, 0.25); }
}
@media (max-width: 760px) {
  .topbar { gap: 8px; padding: 0 10px; }
  .brand-text, .jump-wrap { display: none; }
  .tabs { margin-left: 0; }
  .tab { padding: 6px 7px; font-size: 13px; }
  .main { padding: 12px 12px 40px; }
  .search { width: 100%; }
  .d-props { grid-template-columns: 1fr; }
  .link-form { grid-template-columns: 1fr; }
  .col { flex-basis: 82vw; }
}
@media print {
  .topbar, .drawer, .filters, .legend { display: none !important; }
  .table-wrap { max-height: none; overflow: visible; }
}
