/* Headroom — shares the "tasks" design language: Plus Jakarta Sans, cyan accent,
   dark sidebar, soft off-white grounds, 10px radius. Desktop = sidebar + list +
   centred detail dialog. Mobile (<=780px) = drawer sidebar + two-line rows +
   bottom-sheet detail + FAB. */

@font-face {
  font-family: 'Plus Jakarta Sans';
  src: url(/brand/pjs.woff2) format('woff2');
  font-weight: 200 800;
  font-display: swap;
}

/* ============ tokens: light ============ */
:root {
  --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  --bg: #EDEFF3;
  --bg-main: #FAFBFC;
  --bg-card: #FFFFFF;
  --bg-input: #F1F4F8;
  --bg-subtle: #EBEFF5;
  --bg-hover: rgba(25, 26, 31, .05);
  --bg-sel: var(--accent-soft);

  --text: #1C2028;
  --text-soft: #4A505E;
  --text-faint: #6B7280;
  --line: #E1E5EC;
  --line-strong: #C9CFDA;

  --accent: #0089C7;
  --accent-bright: #00B3FF;
  --accent-soft: rgba(0, 179, 255, .13);
  --accent-ink: #FFFFFF;

  /* dark sidebar in BOTH themes */
  --bg-sidebar: #191920;
  --side-ink: #B8BCC8;
  --side-ink-hi: #FFFFFF;
  --side-hover: rgba(255, 255, 255, .07);
  --side-sel: rgba(0, 179, 255, .18);
  --side-line: rgba(255, 255, 255, .12);
  --side-label: #7C8194;

  /* status / priority (from tasks) */
  --urgent: #B42318; --urgent-bg: rgba(180, 35, 24, .10);
  --high: #934F0C;   --high-bg: rgba(147, 79, 12, .10);
  --normal: #0173A5; --normal-bg: rgba(1, 115, 165, .10);
  --low: #5B616E;
  --done: #067647;   --done-bg: rgba(6, 118, 71, .10);
  --purple: #6E3FC7; --purple-bg: rgba(110, 63, 199, .10);
  --neutral-bg: rgba(25, 26, 31, .06);
  --star: #E8A400;

  /* category palette */
  --cat-blue: #0089C7; --cat-green: #067647; --cat-purple: #6E3FC7; --cat-amber: #B7791F;
  --cat-red: #B42318; --cat-teal: #0E7C86; --cat-pink: #C026A6; --cat-slate: #5B616E;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(25, 26, 31, .05), 0 4px 16px rgba(25, 26, 31, .10);
  --shadow-lg: 0 8px 34px rgba(25, 26, 31, .18);
  --nav-w: 244px;
  --fab-size: 56px;
}

/* ============ tokens: dark ============ */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) { color-scheme: dark; }
}
:root[data-theme='dark'] { color-scheme: dark; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #141419; --bg-main: #1A1A21; --bg-card: #23232C; --bg-input: #2A2A34; --bg-subtle: #20202A;
    --bg-hover: rgba(255, 255, 255, .06); --bg-sel: rgba(0, 179, 255, .16);
    --text: #E9EBF0; --text-soft: #B8BCC8; --text-faint: #8B90A0; --line: #2E2E38; --line-strong: #3A3A46;
    --accent: #4EC5F5; --accent-soft: rgba(0, 179, 255, .16); --accent-ink: #06222E;
    --bg-sidebar: #101015;
    --urgent: #EE7E74; --urgent-bg: rgba(238, 126, 116, .14);
    --high: #E0A45C; --high-bg: rgba(224, 164, 92, .14);
    --normal: #63B7D2; --normal-bg: rgba(99, 183, 210, .14);
    --low: #9BA1AF;
    --done: #5BBE8B; --done-bg: rgba(91, 190, 139, .14);
    --purple: #A995F2; --purple-bg: rgba(169, 149, 242, .14);
    --neutral-bg: rgba(255, 255, 255, .08); --star: #F3C24B;
    --cat-blue: #4EC5F5; --cat-green: #5BBE8B; --cat-purple: #A995F2; --cat-amber: #E0A45C;
    --cat-red: #EE7E74; --cat-teal: #52C4CE; --cat-pink: #E879C9; --cat-slate: #9BA1AF;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .4);
    --shadow-lg: 0 8px 34px rgba(0, 0, 0, .55);
  }
}
:root[data-theme='dark'] {
  --bg: #141419; --bg-main: #1A1A21; --bg-card: #23232C; --bg-input: #2A2A34; --bg-subtle: #20202A;
  --bg-hover: rgba(255, 255, 255, .06); --bg-sel: rgba(0, 179, 255, .16);
  --text: #E9EBF0; --text-soft: #B8BCC8; --text-faint: #8B90A0; --line: #2E2E38; --line-strong: #3A3A46;
  --accent: #4EC5F5; --accent-soft: rgba(0, 179, 255, .16); --accent-ink: #06222E;
  --bg-sidebar: #101015;
  --urgent: #EE7E74; --urgent-bg: rgba(238, 126, 116, .14);
  --high: #E0A45C; --high-bg: rgba(224, 164, 92, .14);
  --normal: #63B7D2; --normal-bg: rgba(99, 183, 210, .14);
  --low: #9BA1AF;
  --done: #5BBE8B; --done-bg: rgba(91, 190, 139, .14);
  --purple: #A995F2; --purple-bg: rgba(169, 149, 242, .14);
  --neutral-bg: rgba(255, 255, 255, .08); --star: #F3C24B;
  --cat-blue: #4EC5F5; --cat-green: #5BBE8B; --cat-purple: #A995F2; --cat-amber: #E0A45C;
  --cat-red: #EE7E74; --cat-teal: #52C4CE; --cat-pink: #E879C9; --cat-slate: #9BA1AF;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .4);
  --shadow-lg: 0 8px 34px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); background: var(--bg); color: var(--text);
  font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; overscroll-behavior: none;
}
button, input, textarea, select { font-family: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hidden { display: none !important; }
.cat-dot { width: 9px; height: 9px; border-radius: 3px; flex: none; background: var(--cat, var(--text-faint)); }

/* ============ app shell ============ */
#app {
  display: grid;
  grid-template-columns: var(--nav-w) 1fr;
  height: 100vh; height: 100dvh;
  overflow: hidden;
}

/* ============ sidebar ============ */
#sidebar {
  background: var(--bg-sidebar);
  color: var(--side-ink);
  display: flex; flex-direction: column;
  min-width: 0; overflow: hidden;
  padding-top: env(safe-area-inset-top);
}
.brand {
  display: flex; align-items: center; gap: 9px;
  padding: 16px 16px 12px; color: var(--side-ink-hi);
  font-size: 19px; font-weight: 700; letter-spacing: -0.01em;
}
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent-bright); box-shadow: 0 0 0 3px rgba(255, 255, 255, .18); }
.side-scroll { flex: 1; overflow-y: auto; padding: 4px 10px 10px; }
.nav-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700;
  color: var(--side-label); padding: 14px 8px 6px; display: flex; align-items: center; justify-content: space-between;
}
.nav-label button { border: none; background: none; color: var(--side-label); font-size: 17px; line-height: 1; padding: 0 4px; border-radius: 5px; }
.nav-label button:hover { color: var(--side-ink-hi); background: var(--side-hover); }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px; cursor: pointer; color: var(--side-ink);
  font-size: 14.5px; user-select: none;
}
.nav-item:hover { background: var(--side-hover); color: var(--side-ink-hi); }
.nav-item.active { background: var(--side-sel); color: #fff; font-weight: 600; }
.nav-item .ico { width: 20px; text-align: center; flex: none; opacity: .9; }
.nav-item .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .cnt { font-size: 12px; color: var(--side-label); font-variant-numeric: tabular-nums; background: var(--side-hover); padding: 1px 8px; border-radius: 10px; }
.nav-item.active .cnt { color: #fff; background: rgba(255, 255, 255, .18); }
.nav-item .row-menu { opacity: 0; border: none; background: none; color: var(--side-ink); font-size: 16px; padding: 0 2px; border-radius: 5px; }
.nav-item:hover .row-menu { opacity: .8; }
.nav-item .row-menu:hover { opacity: 1; background: var(--side-hover); }
.cat-empty { color: var(--side-label); font-size: 13px; padding: 4px 10px 8px; }
.side-footer { border-top: 1px solid var(--side-line); padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); display: flex; gap: 6px; align-items: center; }
.side-footer button { flex: 1; border: none; background: var(--side-hover); color: var(--side-ink); border-radius: 8px; padding: 9px; font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 6px; }
.side-footer button:hover { color: var(--side-ink-hi); background: rgba(255, 255, 255, .12); }

/* ============ main ============ */
#main { display: flex; flex-direction: column; min-width: 0; background: var(--bg-main); overflow: hidden; }
#toolbar {
  flex: none; display: flex; align-items: center; gap: 12px;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
  padding-top: max(14px, env(safe-area-inset-top));
}
.nav-burger { display: none; border: none; background: var(--bg-hover); color: var(--text); width: 40px; height: 40px; border-radius: 9px; font-size: 18px; }
.crumb { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.crumb .title { font-size: 21px; font-weight: 800; letter-spacing: -0.01em; display: flex; align-items: center; gap: 9px; overflow: hidden; }
.crumb .title .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb .sub { font-size: 12.5px; color: var(--text-faint); }
.toolbar-ctrls { display: flex; align-items: center; gap: 8px; }
.ctrl { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-faint); }
.ctrl select {
  border: 1px solid var(--line); background: var(--bg-card); color: var(--text);
  border-radius: 8px; padding: 7px 8px; font-size: 13px; font-weight: 600;
}
.icon-btn { border: none; background: var(--bg-hover); color: var(--text-soft); width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center; font-size: 16px; }
.icon-btn:hover { color: var(--text); background: var(--line); }
.icon-btn.on { color: var(--accent); background: var(--accent-soft); }
.btn-primary { border: none; background: var(--accent); color: var(--accent-ink); border-radius: 9px; padding: 9px 16px; font-size: 14px; font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
.btn-primary:hover { filter: brightness(1.05); }

/* quick add */
.quick { flex: none; padding: 12px 22px; border-bottom: 1px solid var(--line); }
.quick-box { display: flex; align-items: center; gap: 8px; background: var(--bg-input); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 4px 4px 12px; }
.quick-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.quick-box input.q { flex: 1; border: none; background: transparent; color: var(--text); font-size: 15px; padding: 9px 0; min-width: 0; }
.quick-box input.q:focus { outline: none; }
.quick-box input.q::placeholder { color: var(--text-faint); }
.quick-date { border: none; background: transparent; color: var(--text-faint); font-size: 17px; padding: 6px 8px; border-radius: 8px; }
.quick-date.set { color: var(--accent); }
.quick-add-btn { border: none; background: var(--accent); color: var(--accent-ink); width: 40px; height: 40px; border-radius: 8px; font-size: 22px; display: grid; place-items: center; }
.quick-add-btn:disabled { opacity: .4; }
.quick-extra { display: none; margin-top: 8px; gap: 8px; flex-wrap: wrap; align-items: center; }
.quick-extra.show { display: flex; }
.quick-extra input[type=date] { border: 1px solid var(--line); background: var(--bg-input); color: var(--text); border-radius: 8px; padding: 7px 9px; font-size: 14px; }

/* ============ list ============ */
#listScroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding-bottom: 120px; }
.group-head {
  display: flex; align-items: center; gap: 9px; padding: 16px 22px 7px;
  font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-faint);
}
.group-head .n { font-weight: 700; }
.group-head.g-overdue { color: var(--urgent); }
.group-head.g-today { color: var(--normal); }
.group-head .cat-dot { width: 10px; height: 10px; }

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 116px 120px 130px;
  gap: 10px; align-items: center;
  padding: 0 22px; min-height: 46px;
  border-top: 1px solid var(--line);
  position: relative; cursor: pointer;
  background: var(--bg-main);
}
.row:hover { background: var(--bg-subtle); }
.row.is-today { background: color-mix(in srgb, var(--normal) 6%, var(--bg-main)); }
.row::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--cat, transparent); opacity: .0; }
.row.has-cat::before { opacity: .9; }
.row.completed .row-name .txt { text-decoration: line-through; color: var(--text-faint); }
.row.completed .pill, .row.completed .due-cell, .row.completed .cat-dot { opacity: .55; }

.row-name { display: flex; align-items: center; gap: 11px; min-width: 0; }
.check {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--line-strong); background: transparent;
  display: grid; place-items: center; color: #fff; font-size: 13px; transition: background .12s, border-color .12s;
}
.check:hover { border-color: var(--accent); }
.check.st-InProgress { border-color: var(--normal); }
.check.st-Waiting { border-color: var(--high); }
.check.done, .check.st-Done { background: var(--done); border-color: var(--done); }
.row-name .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.row-badges { display: inline-flex; align-items: center; gap: 8px; flex: none; }
.badge { font-size: 12px; color: var(--text-faint); display: inline-flex; align-items: center; gap: 3px; font-variant-numeric: tabular-nums; }
.star-btn { border: none; background: none; color: var(--text-faint); font-size: 17px; padding: 0 2px; line-height: 1; }
.star-btn.on { color: var(--star); }

.due-cell { font-size: 13px; color: var(--text-faint); font-weight: 600; font-variant-numeric: tabular-nums; }
.due-cell.overdue { color: var(--urgent); }
.due-cell.soon { color: var(--normal); }
.cell-right { display: flex; justify-content: flex-start; }

/* pills */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 20px; white-space: nowrap; }
.pill .flag { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.prio-Urgent { color: var(--urgent); } .prio-Urgent .flag { background: var(--urgent); }
.prio-High { color: var(--high); } .prio-High .flag { background: var(--high); }
.prio-Normal { color: var(--normal); } .prio-Normal .flag { background: var(--normal); }
.prio-Low { color: var(--low); } .prio-Low .flag { background: var(--low); }
.prio-None { color: var(--text-faint); } .prio-None .flag { background: transparent; border: 1px solid var(--text-faint); }

.status-pill { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 20px; display: inline-block; }
.st-ToDo { background: var(--neutral-bg); color: var(--text-soft); }
.st-InProgress { background: var(--normal-bg); color: var(--normal); }
.st-Waiting { background: var(--high-bg); color: var(--high); }
.st-Done { background: var(--done-bg); color: var(--done); }

.row-meta { display: none; }

/* empty state */
.empty { text-align: center; color: var(--text-faint); padding: 70px 30px; }
.empty .big { font-size: 46px; margin-bottom: 12px; }
.empty h2 { font-size: 18px; color: var(--text-soft); margin: 0 0 6px; font-weight: 700; }
.empty p { margin: 0; font-size: 14px; }

/* FAB (mobile) */
.fab { display: none; position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 40; width: var(--fab-size); height: var(--fab-size); border-radius: 50%; background: var(--accent); color: var(--accent-ink); border: none; font-size: 30px; box-shadow: var(--shadow-lg); display: none; place-items: center; }

/* ============ detail overlay ============ */
.overlay { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 30px; pointer-events: none; }
.scrim { position: absolute; inset: 0; background: rgba(10, 12, 20, .5); opacity: 0; transition: opacity .18s; }
.overlay.open { pointer-events: auto; }
.overlay.open .scrim { opacity: 1; }
.sheet {
  position: relative; width: min(880px, 100%); max-height: 100%; height: 100%;
  background: var(--bg-card); border-radius: 16px; box-shadow: var(--shadow-lg);
  display: none; flex-direction: column; opacity: 0; transform: translateY(10px) scale(.99);
  transition: opacity .18s, transform .18s;
}
.overlay.open .sheet { display: flex; opacity: 1; transform: none; }
.sheet-grab { display: none; }
.detail-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex: none; }
.status-btn { border: 1px solid var(--line); background: var(--bg-input); border-radius: 8px; padding: 6px 10px; font-size: 13px; font-weight: 600; color: var(--text); display: inline-flex; align-items: center; gap: 7px; }
.status-btn .sdot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-faint); }
.status-btn.st-InProgress .sdot { background: var(--normal); }
.status-btn.st-Waiting .sdot { background: var(--high); }
.status-btn.st-Done .sdot { background: var(--done); }
.complete-btn { border: 1px solid var(--line); background: var(--bg-input); color: var(--text-soft); border-radius: 8px; padding: 6px 12px; font-size: 13px; font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
.complete-btn.done { background: var(--done-bg); color: var(--done); border-color: transparent; }
.detail-head .sp { flex: 1; }
.detail-body { flex: 1; overflow-y: auto; padding: 4px 22px 26px; }
.parent-crumb { font-size: 13px; color: var(--accent); padding: 12px 0 2px; cursor: pointer; }
.detail-title { width: 100%; border: none; background: transparent; color: var(--text); font-family: inherit; font-size: 22px; font-weight: 700; resize: none; padding: 12px 0 8px; line-height: 1.3; overflow: hidden; min-height: 46px; }
.detail-title:focus { outline: none; }
.detail-meta { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; padding: 6px 0 14px; border-bottom: 1px solid var(--line); }
.meta-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.meta-field label { font-size: 11px; text-transform: uppercase; letter-spacing: .03em; font-weight: 700; color: var(--text-faint); }
.meta-field select, .meta-field input[type=date] { border: 1px solid var(--line); background: var(--bg-input); color: var(--text); border-radius: 8px; padding: 9px 8px; font-size: 14px; width: 100%; }
.meta-field select:focus, .meta-field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.detail-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; padding-top: 16px; }
.pane-label { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; font-weight: 700; color: var(--text-faint); margin: 0 0 8px; display: flex; align-items: center; gap: 7px; }
.pane-label .cnt { background: var(--bg-hover); color: var(--text-faint); border-radius: 10px; padding: 0 7px; font-size: 11px; }
.desc-area { width: 100%; border: 1px solid var(--line); background: var(--bg-input); color: var(--text); border-radius: var(--radius); padding: 11px; font-size: 14.5px; min-height: 90px; resize: vertical; line-height: 1.5; }
.desc-area:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* subtasks */
.subtasks { margin-top: 22px; }
.subtask { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 8px; cursor: pointer; }
.subtask:hover { background: var(--bg-hover); }
.subtask .check { width: 20px; height: 20px; }
.subtask .txt { flex: 1; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subtask.done .txt { text-decoration: line-through; color: var(--text-faint); }
.subtask-del { border: none; background: none; color: var(--text-faint); font-size: 15px; opacity: 0; padding: 2px 5px; }
.subtask:hover .subtask-del { opacity: .7; }
.add-inline { display: flex; gap: 8px; margin-top: 8px; }
.add-inline input { flex: 1; border: 1px solid var(--line); background: var(--bg-input); color: var(--text); border-radius: 8px; padding: 9px 11px; font-size: 14px; }
.add-inline input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.add-inline button { border: none; background: var(--bg-hover); color: var(--text-soft); border-radius: 8px; padding: 0 14px; font-weight: 700; font-size: 14px; }

/* updates / comments */
.composer { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.composer textarea { width: 100%; border: 1px solid var(--line); background: var(--bg-input); color: var(--text); border-radius: var(--radius); padding: 10px 11px; font-size: 14px; min-height: 56px; resize: vertical; }
.composer textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer .row2 { display: flex; justify-content: flex-end; }
.composer button { border: none; background: var(--accent); color: var(--accent-ink); border-radius: 8px; padding: 8px 14px; font-weight: 700; font-size: 13px; }
.composer button:disabled { opacity: .45; }
.update { padding: 11px 0; border-top: 1px solid var(--line); }
.update:first-of-type { border-top: none; }
.update .body { font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.update .meta { display: flex; align-items: center; gap: 10px; margin-top: 5px; font-size: 12px; color: var(--text-faint); }
.update .when { font-weight: 700; font-variant-numeric: tabular-nums; }
.update .del { border: none; background: none; color: var(--text-faint); font-size: 12px; opacity: .7; }
.update .del:hover { color: var(--urgent); opacity: 1; }

/* ============ popover + menu ============ */
.pop { position: fixed; z-index: 200; background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 5px; min-width: 180px; }
.pop button { display: flex; width: 100%; align-items: center; gap: 9px; border: none; background: none; color: var(--text); padding: 9px 10px; border-radius: 7px; font-size: 14px; text-align: left; }
.pop button:hover { background: var(--bg-hover); }
.pop button .tick { margin-left: auto; color: var(--accent); }
.pop .sep { height: 1px; background: var(--line); margin: 4px 0; }
.pop .swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 6px; }
.pop .swatches button { width: 30px; height: 30px; border-radius: 8px; padding: 0; display: grid; place-items: center; }
.pop .swatches .sw { width: 20px; height: 20px; border-radius: 6px; }

/* ============ toast ============ */
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg-main); padding: 11px 16px; border-radius: 999px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: .2s; z-index: 300; display: flex; align-items: center; gap: 14px; max-width: 92vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast button { border: none; background: none; color: var(--accent-bright); font-weight: 800; font-size: 14px; }

.nav-backdrop { display: none; }

/* ============ login ============ */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 360px; background: var(--bg-card); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 30px 26px; text-align: center; }
.login-card .dot-lg { width: 46px; height: 46px; border-radius: 14px; background: var(--accent); margin: 0 auto 14px; display: grid; place-items: center; }
.login-card .dot-lg span { width: 16px; height: 16px; border-radius: 50%; background: var(--accent-bright); box-shadow: 0 0 0 4px rgba(255, 255, 255, .25); }
.login-card h1 { font-size: 22px; margin: 0 0 4px; }
.login-card p { color: var(--text-faint); font-size: 14px; margin: 0 0 20px; }
.login-card input { width: 100%; border: 1px solid var(--line); background: var(--bg-input); color: var(--text); border-radius: var(--radius); padding: 13px; font-size: 16px; }
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-card button { width: 100%; margin-top: 12px; border: none; background: var(--accent); color: var(--accent-ink); border-radius: var(--radius); padding: 13px; font-size: 15px; font-weight: 700; }
.login-err { color: var(--urgent); font-size: 13.5px; margin-top: 12px; min-height: 18px; }

/* ============ MOBILE (<=780px) ============ */
@media (max-width: 780px) {
  #app { grid-template-columns: 1fr; }
  #sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 286px; max-width: 86vw;
    transform: translateX(-100%); transition: transform .22s ease; z-index: 120;
  }
  #app.nav-open #sidebar { transform: translateX(0); box-shadow: 10px 0 40px rgba(0, 0, 0, .5); }
  .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 110; opacity: 0; pointer-events: none; transition: opacity .2s; }
  #app.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }

  .nav-burger { display: grid; place-items: center; }
  #toolbar { padding: 10px 12px; gap: 8px; position: sticky; top: 0; background: var(--bg-sidebar); z-index: 5; border-bottom: none; }
  #toolbar .crumb .title { color: var(--side-ink-hi); font-size: 19px; }
  #toolbar .crumb .sub { color: var(--side-label); }
  #toolbar .nav-burger { background: var(--side-hover); color: var(--side-ink-hi); }
  .toolbar-ctrls .desktop-only { display: none !important; }
  .toolbar-ctrls .icon-btn { background: var(--side-hover); color: var(--side-ink-hi); }

  .quick { padding: 10px 12px; }
  .quick-controls { display: flex; gap: 8px; padding: 8px 12px 0; overflow-x: auto; }

  /* rows collapse to two lines */
  .row { display: flex; flex-direction: column; align-items: stretch; gap: 3px; grid-template-columns: none; min-height: 54px; padding: 9px 14px; }
  .row > .cell-right, .row > .due-cell { display: none; }
  .row-name .txt { font-size: 15px; font-weight: 600; }
  .row-meta { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--text-soft); padding-left: 33px; white-space: nowrap; overflow: hidden; }
  .row-meta .pill, .row-meta .status-pill { padding: 1px 0; background: none !important; }
  .row-meta .m-due.overdue { color: var(--urgent); font-weight: 600; }
  .row-meta .m-due.soon { color: var(--normal); font-weight: 600; }
  .group-head, .quick, .empty { padding-left: 14px; padding-right: 14px; }

  .fab { display: grid; }

  /* detail becomes a bottom sheet */
  .overlay { padding: 0; place-items: end stretch; }
  .sheet { width: 100%; max-height: 93dvh; height: 93dvh; border-radius: 18px 18px 0 0; transform: translateY(100%); transition: transform .26s cubic-bezier(.32,.72,0,1), opacity .18s; }
  .overlay.open .sheet { transform: translateY(0); }
  .sheet.dragging { transition: none; }
  .sheet-grab { display: flex; align-items: center; justify-content: center; height: 22px; touch-action: none; cursor: grab; }
  .sheet-grab i { width: 40px; height: 4px; border-radius: 3px; background: var(--line-strong); display: block; }
  .detail-close { display: none; }
  .detail-cols { grid-template-columns: 1fr; gap: 22px; }
  .detail-meta { grid-template-columns: 1fr 1fr; }
}

@media (pointer: coarse) {
  .quick-box input.q, .meta-field select, .meta-field input, .desc-area, .composer textarea, .add-inline input { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
