/* ---------- theme tokens ---------- */
:root {
  --bg: #ffffff; --bg-soft: #f7f7f8; --bg-hover: #efeff1; --line: #e7e7ea; --line-strong: #d4d4d8;
  --text: #18181b; --muted: #5f5f68; --faint: #9a9aa3;
  --accent: #2a78d6; --accent-soft: rgba(42,120,214,.10); --danger: #d63b3a; --warn: #b86e00; --ok: #199e70;
  --series: #2a78d6; --critical: #e34948;
  --shadow: 0 8px 30px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.06);
  --side-w: 236px; --drawer-w: 440px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px; color: var(--text); color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #18181b; --bg-soft: #1f1f23; --bg-hover: #2a2a2e; --line: #2e2e33; --line-strong: #3f3f46;
    --text: #f4f4f5; --muted: #b4b4bc; --faint: #7c7c86; --accent: #3987e5; --accent-soft: rgba(57,135,229,.16);
    --danger: #f07070; --warn: #f0b04a; --series: #3987e5; --critical: #e66767; --shadow: 0 8px 30px rgba(0,0,0,.5); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #18181b; --bg-soft: #1f1f23; --bg-hover: #2a2a2e; --line: #2e2e33; --line-strong: #3f3f46;
  --text: #f4f4f5; --muted: #b4b4bc; --faint: #7c7c86; --accent: #3987e5; --accent-soft: rgba(57,135,229,.16);
  --danger: #f07070; --warn: #f0b04a; --series: #3987e5; --critical: #e66767; --shadow: 0 8px 30px rgba(0,0,0,.5); color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
input, select, textarea { background: transparent; border: 1px solid transparent; border-radius: 6px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: none; }
select option { background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
.muted { color: var(--faint); } .small { font-size: 12px; } .pad { padding: 12px 8px; } .grow { flex: 1; } .right { text-align: right; margin-top: 6px; }
.hidden-picker { position: fixed; opacity: 0; left: 50%; top: 30%; width: 1px; height: 1px; pointer-events: none; }

#app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }
#mobilebar, #scrim { display: none; }

/* ---------- sidebar ---------- */
#sidebar { width: var(--side-w); flex: none; background: var(--bg-soft); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px 10px; }
.brand-row { display: flex; align-items: center; justify-content: space-between; padding: 0 0 12px 10px; }
.brand { font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.kbd-hint { font-size: 13px; display: flex; gap: 6px; align-items: center; }
.nav-link, #project-list a { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 6px; color: var(--muted); }
.nav-link:hover, #project-list a:hover { background: var(--bg-hover); color: var(--text); }
.nav-link.active, #project-list a.active { background: var(--bg-hover); color: var(--text); font-weight: 500; }
.nav-link .count { margin-left: auto; font-size: 12px; color: var(--faint); }
.ico { width: 14px; text-align: center; }
.side-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); padding: 18px 10px 6px; }
#project-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
#project-list .dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
#project-list .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#project-list .count { font-size: 12px; color: var(--faint); }
#project-list .count.overdue { color: var(--danger); font-weight: 600; }
#project-list li.archived a { opacity: .55; }
.arch-toggle button { font-size: 12px; color: var(--faint); padding: 8px 10px 4px; }
#new-project input { width: 100%; padding: 6px 10px; color: var(--muted); }
#new-project input:focus { background: var(--bg); color: var(--text); }
.side-foot { display: flex; align-items: center; gap: 4px; border-top: 1px solid var(--line); padding-top: 10px; margin-top: 8px; }
.me { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 6px; border-radius: 6px; text-align: left; overflow: hidden; white-space: nowrap; }
.me:hover, .icon-btn:hover { background: var(--bg-hover); }
.icon-btn { padding: 6px 8px; border-radius: 6px; color: var(--muted); font-size: 15px; line-height: 1; display: inline-flex; align-items: center; }
.icon-btn.sm { padding: 3px 5px; font-size: 13px; }

/* ---------- main ---------- */
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.head { display: flex; align-items: center; gap: 10px; padding: 16px 28px 0; flex-wrap: wrap; }
.head.flush { padding: 16px 0 0; }
.head h1 { font-size: 20px; margin: 0; font-weight: 650; letter-spacing: -.02em; padding: 2px 6px; margin-left: -6px; border-radius: 6px; outline: none; }
.head h1[contenteditable]:hover { background: var(--bg-hover); }
.head .spacer { flex: 1; }
.pdot { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.tabs { display: flex; gap: 2px; background: var(--bg-soft); padding: 3px; border-radius: 8px; border: 1px solid var(--line); width: fit-content; }
.tabs button { padding: 4px 12px; border-radius: 6px; color: var(--muted); font-size: 13px; }
.tabs button.on { background: var(--bg); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.tabs.small { margin-bottom: 8px; }
.search { width: 170px; padding: 5px 10px; border: 1px solid var(--line); }
.sort { padding: 5px 6px; border: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; cursor: pointer; user-select: none; }
.toggle select, .toggle input[type=time] { border: 1px solid var(--line); padding: 3px 6px; }
.view-tools { display: flex; gap: 12px; align-items: center; margin: 4px 0 12px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }

/* quick add */
.quick { margin: 14px 28px 0; position: relative; }
.quick input { width: 100%; padding: 10px 14px 10px 38px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-soft); font-size: 14px; }
.quick input:focus { background: var(--bg); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.quick::before { content: "+"; position: absolute; left: 15px; top: 8px; font-size: 18px; color: var(--faint); pointer-events: none; }
.quick-line { display: flex; gap: 8px; }
.quick-line input { flex: 1; }
.quick-line select { border: 1px solid var(--line); border-radius: 10px; padding: 0 10px; max-width: 200px; }
.quick-preview { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-height: 22px; padding: 6px 2px 0; font-size: 12px; color: var(--faint); }
.quick-preview code, .help code { background: var(--bg-hover); padding: 1px 5px; border-radius: 4px; color: var(--muted); }
.inline-add { width: 100%; padding: 6px 10px; color: var(--muted); border: 1px dashed transparent; }
.inline-add:hover { border-color: var(--line); }
.inline-add:focus { border: 1px solid var(--accent); color: var(--text); background: var(--bg); }
.add-section { margin-top: 22px; font-weight: 600; }

/* filters */
.filterbar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 6px 28px 0; }
.filter-btn { font-size: 12px; color: var(--muted); padding: 3px 9px; border: 1px solid var(--line); border-radius: 99px; }
.filter-btn:hover { background: var(--bg-hover); }
.filter-btn.on { border-color: var(--accent); color: var(--accent); }
.filter-chip { background: var(--accent-soft); color: var(--text); }
.filter-chip button { margin-left: 2px; opacity: .6; }

.body { flex: 1; overflow: auto; padding: 8px 28px 80px; }

/* chips */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 99px; font-size: 12px; line-height: 18px; background: var(--bg-hover); color: var(--muted); white-space: nowrap; }
.chip.ghost { background: transparent; padding: 0 2px; }
.chip.tag { background: color-mix(in srgb, var(--c) 14%, transparent); color: color-mix(in srgb, var(--c) 75%, var(--text)); }
.chip.prio { background: transparent; color: var(--c); font-weight: 600; padding: 0 2px; }
.chip.proj i, .dot-i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); display: inline-block; flex: none; }
.dot-i.sm { width: 7px; height: 7px; }
.chip.due.overdue { background: color-mix(in srgb, var(--critical) 16%, transparent); color: var(--danger); font-weight: 500; }
.chip.due.today { background: color-mix(in srgb, #e2a100 20%, transparent); color: var(--warn); }
.chip.blocked { background: transparent; color: var(--warn); padding: 0 2px; }
.chip.notice { margin: 0 8px 8px; padding: 3px 8px; width: fit-content; }
.prio-flag { color: var(--c); }
.avatar { width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 10px; font-weight: 600; color: #fff; flex: none; background: var(--c, #888); }
.avatars { display: inline-flex; }
.avatars .avatar { margin-left: -5px; box-shadow: 0 0 0 2px var(--bg); }
.avatars .avatar:first-child { margin-left: 0; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
.status-pill:hover { background: var(--bg-hover); }
.status-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }

/* ---------- list view ---------- */
.section { margin-top: 18px; }
.section-head { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line); margin-bottom: 2px; }
.section-head.od .sec-name { color: var(--danger); }
.caret { color: var(--faint); width: 16px; font-size: 10px; transition: transform .15s; display: inline-block; }
.section.collapsed > .section-head .caret, .caret.shut { transform: rotate(-90deg); }
.section.collapsed .rows, .section.collapsed .inline-add, .section.collapsed .completed { display: none; }
.sec-name { font-weight: 600; padding: 2px 4px; flex: 1; }
.section-head input { font-weight: 600; padding: 2px 4px; flex: 1; min-width: 0; }
.section-head .n { color: var(--faint); font-size: 12px; }
.section-head .icon-btn { visibility: hidden; font-size: 13px; }
.section-head:hover .icon-btn { visibility: visible; }
.rows { min-height: 6px; }
.row { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 6px; cursor: pointer; position: relative; }
.row:hover { background: var(--bg-soft); }
.row.selected { background: var(--accent-soft); }
.row.picked, .card.picked { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.row.cursor, .card.cursor { outline: 1px solid var(--accent); outline-offset: -1px; }
.row .grip { position: absolute; left: -16px; color: var(--faint); cursor: grab; opacity: 0; font-size: 12px; }
.row:hover .grip { opacity: 1; }
.grip.static { position: static; opacity: 1; cursor: grab; color: var(--faint); }
.row .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { display: flex; align-items: center; gap: 6px; flex: none; }
.row.done .title { color: var(--faint); text-decoration: line-through; }
.check { width: 17px; height: 17px; border-radius: 50%; border: 1.5px solid var(--pc, var(--line-strong)); background: color-mix(in srgb, var(--pc, transparent) 10%, transparent);
  flex: none; display: grid; place-items: center; color: transparent; font-size: 11px; transition: all .12s; }
.check:hover { border-color: var(--ok); color: var(--ok); }
.done .check, .check.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.check.big { width: 20px; height: 20px; margin-top: 10px; }
.completed { margin: 4px 0 0; }
.completed-toggle { font-size: 12px; color: var(--faint); padding: 4px 8px; display: flex; gap: 4px; align-items: center; }
.completed-toggle:hover { color: var(--text); }
.sortable-ghost { opacity: .35; }
.sortable-drag { box-shadow: var(--shadow); background: var(--bg); }
.empty { color: var(--faint); text-align: center; padding: 50px 0; }
.empty.small { padding: 18px 0; font-size: 13px; }
.empty b { color: var(--muted); }
kbd { font: 11px ui-monospace, monospace; padding: 1px 5px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; color: var(--muted); }

/* ---------- board view ---------- */
.board { display: flex; gap: 14px; align-items: flex-start; }
.col { width: 280px; flex: none; background: var(--bg-soft); border-radius: 10px; display: flex; flex-direction: column; }
.col-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 6px; font-weight: 600; font-size: 13px; }
.col-head i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.col-head .n { color: var(--faint); font-weight: 400; }
.cards { padding: 4px 8px 8px; min-height: 40px; display: flex; flex-direction: column; gap: 6px; }
.card { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; cursor: grab; display: flex; flex-direction: column; gap: 7px; }
.card:hover { border-color: var(--line-strong); }
.card.done .card-title { color: var(--faint); text-decoration: line-through; }
.card-meta { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
.card-meta .avatars { margin-left: auto; }
.col .inline-add { margin: 0 8px 8px; width: auto; }
.lanes { display: flex; flex-direction: column; gap: 10px; width: max-content; }
.lane-row { display: flex; gap: 10px; align-items: stretch; }
.lane-heads { position: sticky; top: -8px; z-index: 2; background: var(--bg); padding-top: 4px; }
.lane-label { width: 140px; flex: none; font-weight: 600; padding: 10px 4px; display: flex; gap: 6px; align-items: flex-start; }
.lane-label .n { color: var(--faint); font-weight: 400; font-size: 12px; }
.lane-col { width: 260px; flex: none; }
.lane-heads .lane-col { padding: 6px 12px; }

/* ---------- timeline ---------- */
.tl { position: relative; display: grid; grid-template-columns: 240px 1fr; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.tl-left { border-right: 1px solid var(--line); background: var(--bg); z-index: 2; min-width: 0; }
.tl-left .tl-cell { padding: 0 12px; display: flex; align-items: center; gap: 8px; white-space: nowrap; overflow: hidden; cursor: pointer; }
.tl-left .tl-cell:hover { background: var(--bg-soft); }
.tl-left .tl-cell.done .tl-title { text-decoration: line-through; color: var(--faint); }
.tl-title { overflow: hidden; text-overflow: ellipsis; }
.tl-right { overflow-x: auto; position: relative; }
.tl-grid { position: relative; min-width: 100%; }
.tl-cell, .tl-row { height: 34px; border-bottom: 1px solid var(--line); }
.tl-row { position: relative; }
.tl-empty { display: flex; align-items: center; padding-left: 16px; color: var(--faint); font-size: 13px; position: sticky; left: 0; }
.tl-head { height: 44px; border-bottom: 1px solid var(--line); background: var(--bg-soft); }
.tl-left .tl-head { display: flex; align-items: flex-end; padding: 0 12px 6px; font-size: 12px; color: var(--faint); }
.tl-days { display: flex; height: 44px; border-bottom: 1px solid var(--line); background: var(--bg-soft); }
.tl-day { flex: none; border-right: 1px solid color-mix(in srgb, var(--line) 70%, transparent); font-size: 11px; color: var(--faint); display: flex; flex-direction: column; justify-content: flex-end; align-items: center; padding-bottom: 5px; overflow: visible; white-space: nowrap; }
.tl-day.weekend { background: color-mix(in srgb, var(--bg-hover) 60%, transparent); }
.tl-day.m1 { border-left: 1px solid var(--line-strong); }
.tl-day .m { font-weight: 600; color: var(--muted); }
.tl-day.today { color: var(--accent); font-weight: 700; }
.tl-col-bg { position: absolute; top: 44px; bottom: 0; }
.tl-col-bg.weekend { background: color-mix(in srgb, var(--bg-hover) 40%, transparent); }
.tl-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); opacity: .6; z-index: 1; }
.tl-drop { position: absolute; top: 44px; bottom: 0; background: var(--accent-soft); border: 1px dashed var(--accent); z-index: 1; pointer-events: none; }
.tl-bar { position: absolute; top: 0; height: 22px; margin-top: 6px; border-radius: 6px; background: var(--c); color: #fff; font-size: 12px; padding: 0 8px; display: flex; align-items: center; white-space: nowrap; overflow: hidden; cursor: grab; z-index: 2; box-shadow: 0 0 0 2px var(--bg); user-select: none; touch-action: none; }
.tl-bar.done { opacity: .45; }
.tl-bar.picked { outline: 2px solid var(--accent); outline-offset: 1px; }
.tl-bar .rz { position: absolute; top: 0; bottom: 0; width: 8px; cursor: ew-resize; }
.tl-bar .rz.l { left: 0; } .tl-bar .rz.r { right: 0; }
.tl-label { position: absolute; top: 0; line-height: 34px; font-size: 12px; color: var(--muted); white-space: nowrap; pointer-events: none; z-index: 2; }
.tl-arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; overflow: visible; }
.tl-unscheduled { margin-top: 18px; }
.tl-unscheduled h3 { font-size: 13px; color: var(--muted); font-weight: 600; margin: 0 0 6px; }
.tl-unscheduled .row { cursor: grab; }

/* ---------- dashboard ---------- */
.banner { display: flex; align-items: center; gap: 12px; margin-top: 18px; border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; }
.banner span { flex: 1; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 18px 0 26px; }
.stat { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.stat .v { font-size: 26px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: 12px; margin-top: 2px; }
.stat.danger .v { color: var(--danger); }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr); gap: 28px; }
.dash-col { display: flex; flex-direction: column; gap: 28px; min-width: 0; }
.dash-grid h2 { font-size: 14px; font-weight: 600; margin: 0 0 10px; color: var(--muted); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c); margin-right: 5px; }
.pcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.pcard { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; cursor: pointer; display: flex; flex-direction: column; gap: 10px; }
.pcard:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.pcard-top { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; }
.pcard-top .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.pc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard-body { display: flex; align-items: center; gap: 16px; }
.donut { width: 96px; height: 96px; flex: none; }
.donut .seg { cursor: default; }
.donut .seg:hover { opacity: .85; }
.donut-v { font-size: 15px; font-weight: 650; fill: var(--text); }
.donut-l { font-size: 9px; fill: var(--faint); }
.pnums { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; font-size: 12px; color: var(--muted); }
.pnums b { color: var(--text); font-size: 15px; display: block; font-variant-numeric: tabular-nums; }
.pnums .od b { color: var(--danger); }
.chart-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.panel { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.hero { margin: -4px 0 8px; color: var(--muted); font-size: 12px; }
.hero b { font-size: 22px; color: var(--text); font-weight: 650; margin-right: 2px; }
.chart { width: 100%; height: auto; display: block; }
.chart .axis { stroke: var(--line-strong); stroke-width: 1; }
.chart .bar { fill: color-mix(in srgb, var(--series) 55%, var(--bg)); }
.chart .bar.current { fill: var(--series); }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: color-mix(in srgb, var(--text) 5%, transparent); }
.chart .tick { font-size: 10px; fill: var(--faint); }
.chart .val { font-size: 11px; font-weight: 600; fill: var(--text); }
.workload { display: flex; flex-direction: column; gap: 8px; }
.wl-row { display: grid; grid-template-columns: 110px 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.wl-name { display: flex; align-items: center; gap: 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.wl-bar { display: flex; gap: 2px; height: 10px; }
.wl-bar span { height: 100%; border-radius: 3px; }
.wl-od { background: var(--critical); }
.wl-open { background: var(--series); }
.wl-num { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.wl-num b { color: var(--text); }
.wl-num .od { color: var(--danger); }
.due-list .row { padding: 6px 8px; }
.due-group { font-size: 12px; color: var(--faint); margin: 12px 0 2px 8px; text-transform: uppercase; letter-spacing: .05em; }
.due-group.od { color: var(--danger); }
.pname { font-size: 12px; color: var(--faint); }
.feed { display: flex; flex-direction: column; }
.act { display: flex; gap: 10px; padding: 7px 8px; border-radius: 6px; font-size: 13px; line-height: 1.45; color: var(--muted); }
.feed .act { cursor: pointer; } .feed .act:hover { background: var(--bg-soft); }
.act b { color: var(--text); font-weight: 600; }
.act-task { color: var(--text); }
#tip { position: fixed; z-index: 70; pointer-events: none; background: var(--text); color: var(--bg); font-size: 12px; padding: 6px 9px; border-radius: 6px; box-shadow: var(--shadow); max-width: 280px; }

/* ---------- drawer ---------- */
#drawer { width: var(--drawer-w); flex: none; border-left: 1px solid var(--line); background: var(--bg); overflow-y: auto; display: flex; flex-direction: column; }
#drawer.dropping { box-shadow: inset 0 0 0 2px var(--accent); background: var(--accent-soft); }
.dr-top { display: flex; align-items: center; gap: 6px; padding: 12px 14px 4px; color: var(--faint); font-size: 12px; position: sticky; top: 0; background: var(--bg); z-index: 3; }
.dr-top .spacer { flex: 1; }
.dr-title-row { display: flex; gap: 6px; align-items: flex-start; }
.dr-title { font-size: 18px; font-weight: 600; width: 100%; padding: 6px 8px; resize: none; overflow: hidden; line-height: 1.35; letter-spacing: -.01em; }
.dr-body { padding: 0 14px 30px; display: flex; flex-direction: column; gap: 2px; }
.field { display: grid; grid-template-columns: 96px 1fr; align-items: center; min-height: 34px; gap: 6px; }
.field > label { color: var(--muted); font-size: 13px; padding-left: 8px; }
.field select, .field input[type=date], .field input[type=time] { padding: 5px 6px; }
.field select:hover, .field input:hover { background: var(--bg-hover); }
.date-pair { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.link-btn { color: var(--faint); font-size: 12px; padding: 4px 6px; border-radius: 5px; }
.link-btn:hover { background: var(--bg-hover); color: var(--text); }
.chips-input { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 4px 6px; border-radius: 6px; min-height: 32px; cursor: text; }
.chips-input:hover { background: var(--bg-hover); }
.chips-input input { flex: 1; min-width: 70px; padding: 2px; border: 0; }
.chips-input .chip button { color: inherit; opacity: .6; font-size: 13px; line-height: 1; margin-left: 2px; }
.chips-input .chip button:hover { opacity: 1; }
.dep-list { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; }
.dep { display: flex; align-items: center; gap: 8px; padding: 3px 6px; border-radius: 6px; font-size: 13px; align-self: stretch; }
.dep:hover { background: var(--bg-hover); }
.dep .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.dep.done .t { text-decoration: line-through; color: var(--faint); }
.dep button { color: var(--faint); visibility: hidden; }
.dep:hover button { visibility: visible; }
.dr-block { margin-top: 16px; }
.dr-block-head { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--muted); padding: 0 8px 6px; }
.dr-block-head .n { font-weight: 400; color: var(--faint); }
.dr-block-head .link-btn { margin-left: auto; font-weight: 400; }
.progress { height: 4px; border-radius: 2px; background: var(--bg-hover); margin: 0 8px 6px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--ok); border-radius: 2px; }
.cl-item { display: flex; align-items: center; gap: 6px; padding: 1px 4px; border-radius: 6px; }
.cl-item:hover { background: var(--bg-soft); }
.cl-item .grip { color: var(--faint); cursor: grab; font-size: 12px; opacity: 0; }
.cl-item:hover .grip, .cl-item:hover .icon-btn { opacity: 1; }
.cl-item .icon-btn { opacity: 0; }
.cl-item input[type=checkbox] { accent-color: var(--ok); width: 15px; height: 15px; }
.cl-text { flex: 1; padding: 4px 6px; min-width: 0; }
.cl-item.done .cl-text { text-decoration: line-through; color: var(--faint); }
.dr-desc { width: 100%; min-height: 140px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; resize: vertical; line-height: 1.5; }
.md { padding: 6px 10px; border-radius: 8px; line-height: 1.6; cursor: text; overflow-wrap: anywhere; }
.md:hover { background: var(--bg-soft); }
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md a { color: var(--accent); text-decoration: underline; }
.md code { background: var(--bg-hover); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.md pre { background: var(--bg-soft); padding: 10px; border-radius: 6px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md blockquote { margin: 0; padding-left: 12px; border-left: 3px solid var(--line-strong); color: var(--muted); }
.md ul, .md ol { padding-left: 22px; }
.md table { border-collapse: collapse; } .md td, .md th { border: 1px solid var(--line); padding: 4px 8px; }
.md h1, .md h2, .md h3 { font-size: 15px; margin: 12px 0 6px; }
.att-list { display: flex; flex-direction: column; gap: 4px; }
.att { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 6px; font-size: 13px; }
.att:hover { background: var(--bg-soft); }
.att-thumb { width: 36px; height: 36px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); }
.att-ico { width: 36px; text-align: center; font-size: 18px; }
.att-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-name:hover { text-decoration: underline; }
.comment { display: flex; gap: 10px; padding: 8px; }
.c-body { flex: 1; min-width: 0; }
.c-head { display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
.c-head .link-btn { margin-left: auto; padding: 0 4px; }
.c-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; margin-top: 2px; }
.c-input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; resize: vertical; margin-top: 6px; }
.dr-meta { color: var(--faint); font-size: 12px; padding: 18px 8px 0; line-height: 1.7; }
.danger-btn { color: var(--danger) !important; }

/* ---------- bulk bar ---------- */
#bulkbar { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 45; background: var(--bg); border: 1px solid var(--line-strong); box-shadow: var(--shadow);
  border-radius: 12px; padding: 8px 10px 8px 16px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; max-width: calc(100vw - 32px); }
#bulkbar b { margin-right: 6px; font-size: 13px; }

/* ---------- popup / modal / toast ---------- */
#popup { position: fixed; z-index: 80; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 4px; min-width: 180px; max-height: 320px; overflow-y: auto; }
.popup-search { width: 100%; padding: 6px 8px; margin-bottom: 4px; border: 1px solid var(--line) !important; }
.opt { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 5px; cursor: pointer; white-space: nowrap; }
.opt-label { overflow: hidden; text-overflow: ellipsis; }
.opt:hover, .opt.hl { background: var(--bg-hover); }
.opt .hint { margin-left: auto; padding-left: 12px; color: var(--faint); font-size: 12px; }
.opt.danger { color: var(--danger); }
.opt.muted { cursor: default; color: var(--faint); }
.sep { height: 1px; background: var(--line); margin: 4px 0; }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.3); display: grid; place-items: center; z-index: 60; backdrop-filter: blur(2px); }
.modal { background: var(--bg); border-radius: 12px; box-shadow: var(--shadow); width: min(580px, 94vw); max-height: 88vh; overflow-y: auto; padding: 22px 24px; }
.modal-head { display: flex; align-items: center; } .modal-head h2 { flex: 1; }
.modal h2 { margin: 0 0 4px; font-size: 18px; }
.modal h3 { font-size: 13px; color: var(--muted); margin: 22px 0 8px; font-weight: 600; }
.modal p { color: var(--muted); margin: 0 0 14px; }
.modal .row { cursor: default; padding: 4px 6px; gap: 8px; }
.modal .row.wrap { flex-wrap: wrap; }
.modal .row:hover { background: none; }
.modal input[type=text] { border: 1px solid var(--line); padding: 7px 10px; }
.modal .row input[type=text] { border-color: transparent; padding: 3px 6px; flex: 1; }
.modal .row input[type=text]:hover { border-color: var(--line); }
.stack-form { display: flex; flex-direction: column; gap: 12px; }
.palette { align-self: start; margin-top: 12vh; padding: 0; width: min(620px, 94vw); overflow: hidden; display: flex; flex-direction: column; }
.pal-input { width: 100%; padding: 16px 18px !important; font-size: 16px; border: 0 !important; border-bottom: 1px solid var(--line) !important; border-radius: 0 !important; }
.pal-list { max-height: 50vh; overflow-y: auto; padding: 6px; }
.pal-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); padding: 8px 10px 4px; }
.pal-ico { width: 18px; text-align: center; color: var(--faint); display: inline-flex; justify-content: center; }
input[type=color] { width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; overflow: hidden; cursor: pointer; flex: none; }
input[type=color]::-webkit-color-swatch-wrapper { padding: 0; } input[type=color]::-webkit-color-swatch { border: 0; border-radius: 50%; }
.btn { padding: 7px 14px; border-radius: 7px; border: 1px solid var(--line-strong); font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn:hover { background: var(--bg-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.people-pick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.people-pick button { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border: 1px solid var(--line); border-radius: 99px; }
.people-pick button:hover { border-color: var(--accent); }
.form-line { display: flex; gap: 8px; }
.form-line input { flex: 1; }
.help { font-size: 12px; color: var(--faint); line-height: 1.9; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 8px; font-size: 13px; z-index: 90; display: flex; gap: 14px; align-items: center; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
#toast button { color: #8ab8f0; font-weight: 600; }
#bulkbar:not([hidden]) ~ #toast { bottom: 80px; }

/* ---------- mobile ---------- */
@media (max-width: 800px) {
  #app { flex-direction: column; }
  #mobilebar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--bg-soft); }
  #sidebar { position: fixed; inset: 0 auto 0 0; z-index: 50; width: min(280px, 85vw); transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow); }
  #sidebar.open { transform: none; }
  #scrim:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 49; background: rgba(0,0,0,.35); }
  #drawer { position: fixed; inset: 0; width: 100%; z-index: 30; }
  .head, .body, .filterbar { padding-left: 16px; padding-right: 16px; } .quick { margin-left: 16px; margin-right: 16px; }
  .search { width: 120px; }
  .row .meta .chip.tag, .row .meta .chip.ghost { display: none; }
  .dash-grid { grid-template-columns: 1fr; }
  .tl { grid-template-columns: 140px 1fr; }
  .kbd-hint kbd { display: none; }
}
@media (max-width: 1100px) and (min-width: 801px) { .dash-grid { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- sign-in, account & admin ---------- */
#app.locked { filter: blur(3px); pointer-events: none; user-select: none; }
.auth { display: flex; flex-direction: column; gap: 14px; max-width: 360px; margin: 0 auto; padding: 8px 0; }
.auth-brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 16px; color: var(--muted); }
.auth-brand img { width: 26px; height: 26px; }
.auth h2 { margin: 0; }
.lbl { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.modal input[type=email], .modal input[type=password], .code-input { border: 1px solid var(--line-strong); padding: 8px 10px; }
.code-input { font-size: 20px; letter-spacing: .2em; text-align: center; }
.btn.wide { width: 100%; justify-content: center; padding: 9px 14px; }
.btn:disabled { opacity: .6; cursor: default; }
.center { text-align: center; }
.form-error { color: var(--danger) !important; margin: 0 !important; font-size: 13px; }
.form-ok { color: var(--ok) !important; margin: 0 !important; font-size: 13px; }
.modal.wide { width: min(760px, 96vw); }
.qr { width: 200px; height: 200px; display: block; margin: 0 auto; border-radius: 8px; }
code.secret { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; word-break: break-all; user-select: all; }
pre.codes { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; columns: 2; margin: 0; }
.notice-box { border: 1px solid var(--accent); background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; margin: 12px 0; }
.notice-box p { margin: 0 0 8px; color: var(--text); }
.chip.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.chip.warn { background: color-mix(in srgb, #e2a100 18%, transparent); color: var(--warn); }
.chip.bad { background: color-mix(in srgb, var(--critical) 16%, transparent); color: var(--danger); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.user-list .row.disabled { opacity: .6; }
.row.audit { font-size: 13px; align-items: baseline; }
.row.audit.bad b { color: var(--danger); }
.nowrap { white-space: nowrap; }
.modal select { border: 1px solid var(--line); padding: 4px 6px; }
.team { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; margin-bottom: 10px; }
.chips-wrap { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 6px 6px; align-items: center; }
.chip.member { padding-left: 2px; }
.chip.member .avatar { width: 18px; height: 18px; font-size: 9px; }
.chip.member button { color: var(--faint); padding: 0 2px; } .chip.member button:hover { color: var(--text); }
.share-btn .avatars { margin-right: 2px; }
fieldset.dr-fields { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.dr-fields:disabled select, fieldset.dr-fields:disabled input { opacity: 1; color: var(--text); }
.check:disabled, .status-pill:disabled { cursor: default; }

/* ---------- mentions & inbox ---------- */
.mention { color: color-mix(in srgb, var(--c) 70%, var(--text)); background: color-mix(in srgb, var(--c) 12%, transparent); border-radius: 4px; padding: 0 3px; font-weight: 500; }
.mention.me { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); }
.nav-link .count.unread { color: #fff; background: var(--accent); border-radius: 99px; padding: 0 7px; font-weight: 600; }
.inbox { max-width: 760px; }
.inbox-item { align-items: flex-start; padding: 10px 8px; border-bottom: 1px solid var(--line); border-radius: 0; }
.inbox-item.unread { background: var(--accent-soft); }
.inbox-item .snippet { color: var(--muted); font-size: 13px; margin: 3px 0; }
.unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; margin-top: 6px; }

/* ---------- icons (icons.js, drawn by icon()) ---------- */
.icon { width: 1.1em; height: 1.1em; stroke-width: 1.75; flex: none; vertical-align: -0.18em; }
.icon-btn .icon { width: 16px; height: 16px; }
.icon-btn.sm .icon { width: 14px; height: 14px; }
.ico .icon, .pal-ico .icon { width: 16px; height: 16px; }
.ico { display: inline-flex; justify-content: center; width: 16px; }
.chip .icon { width: 12px; height: 12px; stroke-width: 2; }
.chip.ghost { gap: 3px; }
.check .icon { width: 11px; height: 11px; stroke-width: 3; }
.check.big .icon { width: 13px; height: 13px; }
.caret { display: inline-flex; align-items: center; justify-content: center; }
.caret .icon { width: 14px; height: 14px; }
.grip .icon { width: 14px; height: 14px; }
.prio-flag { display: inline-flex; align-items: center; }
.card-title .prio-flag { margin-right: 4px; vertical-align: -2px; }
.att-ico { display: inline-flex; justify-content: center; color: var(--faint); }
.att-ico .icon { width: 20px; height: 20px; }
.btn .icon, .filter-btn .icon { width: 14px; height: 14px; }
.filter-btn { display: inline-flex; align-items: center; gap: 3px; }
.arch-toggle button { display: inline-flex; align-items: center; gap: 4px; }
.kbd-hint .icon { width: 15px; height: 15px; }
.banner > .icon { width: 20px; height: 20px; color: var(--accent); }
.hint .icon { width: 14px; height: 14px; color: var(--accent); }
.chips-input .chip button .icon, .filter-chip button .icon, .chip.member button .icon { width: 11px; height: 11px; stroke-width: 2.25; }
.chip.member button { display: inline-flex; }
.status-line { display: flex; align-items: center; gap: 6px; }
.status-line.ok .icon { color: var(--ok); } .status-line.bad .icon { color: var(--danger); }
.empty .icon { color: var(--faint); }
#btn-theme .icon { width: 16px; height: 16px; }

/* ---------- view tabs ---------- */
.view-tabs button { display: inline-flex; align-items: center; gap: 5px; }
.view-tabs .icon { width: 14px; height: 14px; }
@media (max-width: 1100px) { .view-tabs button span { display: none; } .view-tabs button { padding: 5px 9px; } }

/* ---------- calendar ---------- */
.cal-tools { gap: 8px; }
.cal-title-main { font-size: 15px; color: var(--text); margin: 0 8px 0 4px; }
.cal-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 16px; align-items: start; }
.cal { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; user-select: none; }
.cal-head { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--bg-soft); border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.cal-head div { padding: 6px 8px; }
.cal-week { --lane-h: 22px; --num-h: 26px; position: relative; border-bottom: 1px solid var(--line); min-height: max(104px, calc(var(--num-h) + var(--lanes) * var(--lane-h) + 22px)); }
.cal-week:last-child { border-bottom: 0; }
.week-mode .cal-week { min-height: max(420px, calc(var(--num-h) + var(--lanes) * var(--lane-h) + 40px)); }
.cal-days { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-day { position: relative; padding: 4px 6px; border-right: 1px solid var(--line); cursor: cell; min-width: 0; }
.cal-day:last-child { border-right: 0; }
.cal-day.weekend { background: color-mix(in srgb, var(--bg-soft) 70%, transparent); }
.cal-day.other { background: var(--bg-soft); }
.cal-day.other .cal-num { color: var(--faint); }
.cal-day.drop { background: var(--accent-soft); }
.cal-num { font-size: 12px; color: var(--muted); line-height: 18px; display: inline-block; padding: 0 5px; border-radius: 99px; font-variant-numeric: tabular-nums; }
.cal-day.today .cal-num { background: var(--accent); color: #fff; font-weight: 600; }
.cal-more { position: absolute; left: 4px; bottom: 3px; font-size: 11px; color: var(--muted); padding: 0 5px; border-radius: 4px; }
.cal-more:hover { background: var(--bg-hover); color: var(--text); }
.cal-bars { position: absolute; left: 0; right: 0; top: var(--num-h); pointer-events: none; }
/* Bars fill whole day columns; --pl/--pr inset the true start/end, so a bar that continues into the next week runs to the edge. */
.cal-bar { --pl: 3px; --pr: 3px; position: absolute; pointer-events: auto; top: calc(var(--lane) * var(--lane-h));
  left: calc(var(--col) / 7 * 100% + var(--pl)); width: calc(var(--len) / 7 * 100% - var(--pl) - var(--pr)); height: calc(var(--lane-h) - 3px);
  display: flex; align-items: center; gap: 4px; padding: 0 6px; font-size: 12px; color: var(--text); white-space: nowrap; overflow: hidden;
  background: color-mix(in srgb, var(--c) 20%, var(--bg)); border-radius: 4px; cursor: pointer; touch-action: none; }
.cal-bar.seg-start { border-left: 3px solid var(--c); }
.cal-bar:not(.seg-start) { --pl: 0px; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.cal-bar:not(.seg-end) { --pr: 0px; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.cal-bar:hover { background: color-mix(in srgb, var(--c) 30%, var(--bg)); }
.cal-bar.editable { cursor: grab; }
.cal-bar.dragging { opacity: .55; cursor: grabbing; }
.cal-bar.done { opacity: .5; } .cal-bar.done .cal-title { text-decoration: line-through; }
.cal-bar .rz { position: absolute; top: 0; bottom: 0; width: 7px; cursor: ew-resize; }
.cal-bar .rz.l { left: 0; } .cal-bar .rz.r { right: 0; }
.cal-time { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; flex: none; }
.cal-title { overflow: hidden; text-overflow: ellipsis; }
.cal-add { position: absolute; left: 4px; right: 4px; top: 24px; z-index: 5; }
.cal-add input { width: 100%; font-size: 12px; padding: 4px 6px; background: var(--bg); border: 1px solid var(--accent); box-shadow: var(--shadow); }
.cal-side { border: 1px solid var(--line); border-radius: 10px; padding: 10px; max-height: 75vh; overflow-y: auto; }
.cal-side h3 { font-size: 13px; color: var(--muted); margin: 2px 4px 8px; font-weight: 600; }
.cal-side p { margin: 6px 4px; }
.cal-uns { display: flex; align-items: center; gap: 7px; padding: 5px 6px; border-radius: 6px; font-size: 13px; cursor: pointer; }
.cal-uns[draggable] { cursor: grab; }
.cal-uns:hover { background: var(--bg-hover); }
.cal-uns-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 900px) {
  .cal-wrap { grid-template-columns: 1fr; }
  .cal-tools .help { display: none; }
  .cal-week { --lane-h: 18px; }
  .cal-bar { font-size: 11px; padding: 0 3px; }
}

/* ---------- project overview ---------- */
.overview .stats { margin-top: 4px; }
.stat .v .icon { width: 20px; height: 20px; vertical-align: -2px; }
.ov-status { display: flex; align-items: center; gap: 18px; }
.ov-legend { flex: 1; display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); min-width: 0; }
.ov-legend div { display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: center; }
.ov-legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.ov-legend b { color: var(--text); font-variant-numeric: tabular-nums; }
.hbars, .ov-sections { display: flex; flex-direction: column; gap: 9px; }
.hbar-row, .ov-sec { display: grid; grid-template-columns: 120px 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.hbar-l, .ov-sec-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.hbar { height: 10px; }
.hbar span { display: block; height: 100%; background: var(--series); border-radius: 0 3px 3px 0; }
.ov-sec .progress { margin: 0; height: 8px; border-radius: 3px; }
