/* ── Tasks ─────────────────────────────────────────────────────────── */
:root {
  --bg: #f4f5f9;
  --surface: #ffffff;
  --surface-2: #eef0f6;
  --surface-3: #e4e7f0;
  --border: #e1e4ee;
  --border-strong: #cfd3e0;
  --text: #1b1f2e;
  --muted: #6c7389;
  --accent: #4f5bd5;
  --accent-ink: #ffffff;
  --accent-soft: #e9ebff;
  --accent-soft-ink: #3a44b5;
  --danger: #d64545;
  --danger-soft: #fde8e8;
  --ok: #2f9e6b;
  --warn: #c97c12;
  --warn-soft: #fff3df;
  --shadow: 0 1px 2px rgba(20, 24, 40, .05), 0 10px 30px -14px rgba(20, 24, 40, .22);
  --shadow-pop: 0 2px 6px rgba(20, 24, 40, .08), 0 18px 48px -16px rgba(20, 24, 40, .35);
  --radius: 12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --topbar-h: 56px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121421; --surface: #1a1d2e; --surface-2: #222639; --surface-3: #2b3047;
    --border: #2b3047; --border-strong: #3a4060; --text: #e8eaf4; --muted: #9aa1b8;
    --accent: #7d87ff; --accent-ink: #0f1230; --accent-soft: #2a2f5a; --accent-soft-ink: #c3c8ff;
    --danger: #f06d6d; --danger-soft: #3a2026; --ok: #4cc38a; --warn: #e5a04a; --warn-soft: #3a2f1c;
    --shadow: 0 1px 2px rgba(0,0,0,.35), 0 10px 30px -14px rgba(0,0,0,.6);
    --shadow-pop: 0 2px 6px rgba(0,0,0,.4), 0 18px 48px -16px rgba(0,0,0,.7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121421; --surface: #1a1d2e; --surface-2: #222639; --surface-3: #2b3047;
  --border: #2b3047; --border-strong: #3a4060; --text: #e8eaf4; --muted: #9aa1b8;
  --accent: #7d87ff; --accent-ink: #0f1230; --accent-soft: #2a2f5a; --accent-soft-ink: #c3c8ff;
  --danger: #f06d6d; --danger-soft: #3a2026; --ok: #4cc38a; --warn: #e5a04a; --warn-soft: #3a2f1c;
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 10px 30px -14px rgba(0,0,0,.6);
  --shadow-pop: 0 2px 6px rgba(0,0,0,.4), 0 18px 48px -16px rgba(0,0,0,.7);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); min-height: 100dvh; -webkit-font-smoothing: antialiased; }
body.has-modal { overflow: hidden; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
.noscript { padding: 40px; text-align: center; }

/* ── Top bar ──────────────────────────────────────────────────────── */
/* The header never overflows: the nav can shrink (and scroll), the buttons lose their labels on a narrower window. */
.topbar { position: sticky; top: 0; z-index: 20; height: var(--topbar-h); display: flex; align-items: center; gap: 10px; padding: 0 16px; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); min-width: 0; }
.topbar > * { flex: none; }
.topbar .nav { flex: 0 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.topbar .nav::-webkit-scrollbar { display: none; }
.export-btn .ico, .sched-btn .ico { font-size: 13px; }
@media (max-width: 1240px) { .export-btn .lbl, .sched-btn .lbl { display: none; } .export-btn, .sched-btn { padding: 5px 9px; } }
@media (max-width: 980px) { .brand-name { display: none; } }
.brand { display: flex; align-items: center; gap: 9px; color: var(--text); font-weight: 700; font-size: 17px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 16px; font-weight: 800; }
.nav { display: flex; gap: 2px; margin-left: 12px; }
.nav-tab { display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border-radius: 9px; color: var(--muted); font-weight: 550; position: relative; white-space: nowrap; }
.nav-tab:hover { background: var(--surface-2); color: var(--text); }
.nav-tab.active { background: var(--accent-soft); color: var(--accent-soft-ink); }
.nav-icon { font-size: 15px; width: 16px; text-align: center; }
.nav-badge { background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 999px; min-width: 18px; text-align: center; }
.export-btn { margin-left: auto; }
.export-btn.hidden ~ .sched-btn { margin-left: auto; }   /* the first button on the right keeps the gap */
.sched-btn { margin-left: 0; }
.data-btn { font-size: 20px; }
/* During a PNG / PDF shot the grid and the tray show everything they hold. */
body.exporting .tg-wrap { max-height: none; overflow: visible; }
body.exporting .cal-tray { position: static; max-height: none; overflow: visible; }
body.exporting .cal-day.other { background: var(--surface-2); }       /* html2canvas cannot read color-mix() */
body.exporting .tg-add, body.exporting .tg-hash, body.exporting .add-link, body.exporting .tg-new, body.exporting .cal-add, body.exporting .access-at { visibility: hidden; }

/* ── Layout ───────────────────────────────────────────────────────── */
.main { max-width: 1180px; margin: 0 auto; padding: 22px 20px 60px; }
/* The three views use the whole window — the same bar at the same place on each; People and the others stay narrow. */
.main[data-page="list"], .main[data-page="table"], .main[data-page="calendar"] { max-width: none; }
.page-narrow { max-width: 760px; margin: 0 auto; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-sub { color: var(--muted); font-size: 13px; }
.hint-kbd { font-variant-numeric: tabular-nums; }
.notice { background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); color: var(--text); border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 16px; font-size: 14px; }

/* ── Controls ─────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 550; line-height: 1.2; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); background: var(--accent); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, transparent); }
.btn.danger:not(.ghost) { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.active { background: var(--accent-soft); border-color: transparent; color: var(--accent-soft-ink); }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--muted); font-size: 15px; line-height: 1; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.tiny { width: 24px; height: 24px; font-size: 13px; }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 550; cursor: pointer; }
.linkish:hover { text-decoration: underline; }
.input { width: 100%; padding: 9px 12px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); outline: none; transition: border-color .12s, box-shadow .12s; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--muted); }
textarea.input { resize: vertical; min-height: 44px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.check-label { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check-label input { width: 17px; height: 17px; accent-color: var(--accent); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.caret { color: var(--muted); font-size: 11px; margin-left: 2px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; gap: 2px; }
.seg-btn { border: 0; background: transparent; padding: 5px 11px; border-radius: 7px; color: var(--muted); font-weight: 550; font-size: 13.5px; display: inline-flex; align-items: center; gap: 6px; }
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.seg.small .seg-btn { padding: 3px 9px; font-size: 12.5px; }
.count-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 20px; padding: 0 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-soft-ink); font-size: 12px; font-weight: 700; border: 0; }
.count-badge.zero { background: var(--surface-2); color: var(--muted); }
button.count-badge { cursor: pointer; }
button.count-badge:hover { filter: brightness(.95); }
.tag-me { display: inline-block; margin-left: 6px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 1px 6px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); vertical-align: middle; }

/* Chips & avatars */
.avatar { display: inline-grid; place-items: center; border-radius: 50%; color: #fff; font-weight: 700; flex: none; letter-spacing: .02em; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 4px; border-radius: 999px; background: var(--surface-2); font-size: 13px; line-height: 1.2; max-width: 100%; }
.chip.small { font-size: 12px; padding: 2px 7px 2px 3px; }
.chip-topic { padding-left: 8px; background: var(--accent-soft); color: var(--accent-soft-ink); }
.chip-hash { color: var(--accent); font-weight: 700; opacity: .9; }
.chip-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-x { border: 0; background: transparent; color: inherit; opacity: .6; font-size: 11px; padding: 0 0 0 2px; line-height: 1; }
.chip-x:hover { opacity: 1; }
.task-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.meta-people { display: inline-flex; }
.meta-people .avatar { margin-right: -5px; box-shadow: 0 0 0 2px var(--surface); }
.meta-people .avatar:last-child { margin-right: 4px; }
.meta-when { font-size: 12.5px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.meta-when.overdue { color: var(--danger); font-weight: 600; }
.meta-time { font-variant-numeric: tabular-nums; }

/* ── Popover & menu ───────────────────────────────────────────────── */
.pop { position: fixed; z-index: 60; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-pop); padding: 6px; max-width: calc(100vw - 16px); animation: pop-in .12s ease-out; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.menu { display: flex; flex-direction: column; min-width: 180px; }
.menu-item { display: flex; align-items: center; gap: 8px; text-align: left; border: 0; background: transparent; padding: 9px 10px; border-radius: 8px; color: var(--text); }
.menu-item:hover { background: var(--surface-2); }
.menu-item.danger { color: var(--danger); }
.menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.menu-note { font-size: 13px; color: var(--muted); padding: 8px 10px 10px; line-height: 1.4; }
.menu-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 10px; font-size: 13.5px; }

/* Suggestions under the title */
.sug-list { display: flex; flex-direction: column; }
.sug-row { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 8px; border: 0; background: transparent; text-align: left; color: var(--text); }
.sug-row.active, .sug-row:hover { background: var(--surface-2); }
.sug-row.create { color: var(--accent); font-weight: 550; }
.sug-label { flex: none; }
.sug-sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sug-key { margin-left: auto; font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; border: 1px solid var(--border-strong); border-radius: 4px; padding: 0 5px; color: var(--muted); }

/* ── Modal ────────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; z-index: 50; background: rgba(12, 14, 26, .45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; overflow: auto; animation: fade .14s ease-out; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-pop); width: 100%; max-width: 560px; max-height: calc(100dvh - 40px); display: flex; flex-direction: column; animation: rise .16s ease-out; }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-sm { max-width: 420px; }
.modal-lg { max-width: 720px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px 0; }
.modal-head-bare { padding: 10px 10px 0; justify-content: flex-end; }
.modal-title { flex: 1; }
.modal-body { padding: 14px 18px 18px; overflow: auto; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 0 18px 18px; }
.confirm-msg { color: var(--text); margin-bottom: 12px; line-height: 1.5; }

/* ── Toasts ───────────────────────────────────────────────────────── */
.toast-host { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 14px; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-pop); font-size: 14px; animation: rise .18s ease-out; }
.toast.warn { background: var(--warn); color: #1b1f2e; }
.toast.out { opacity: 0; transition: opacity .25s; }
.toast-action { border: 0; background: transparent; color: var(--accent-soft); font-weight: 700; padding: 0; }
.toast.warn .toast-action { color: #1b1f2e; }

/* ── Empty state ──────────────────────────────────────────────────── */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty-icon { font-size: 34px; opacity: .6; }
.empty-title { color: var(--text); font-weight: 650; font-size: 17px; }
.empty-hint { max-width: 380px; }
.empty .btn { margin-top: 10px; }

/* ── People ───────────────────────────────────────────────────────── */
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.people-grid .empty { grid-column: 1 / -1; }
.person-card { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.person-card.is-me { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.person-body { flex: 1; min-width: 0; }
.person-name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-counts { font-size: 13px; margin-top: 4px; }
.person-card .icon-btn { align-self: flex-start; }
.person-access { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 5px; font-size: 12.5px; }
.tag-invited { display: inline-block; margin-left: 6px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 1px 6px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); vertical-align: middle; }
.invite-row { display: flex; gap: 8px; align-items: center; }
.invite-link { font-size: 13px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.small-note { font-size: 13px; line-height: 1.45; }
.claim-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; }
.claim-who { display: flex; align-items: center; gap: 12px; }

/* ── Topics outliner ──────────────────────────────────────────────── */
.outline { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 8px; box-shadow: var(--shadow); }
.outline-row { display: flex; align-items: center; gap: 4px; padding-left: calc(var(--depth) * 26px); min-height: 36px; border-radius: 8px; position: relative; }
.outline-row:hover { background: var(--surface-2); }
.outline-row:focus-within { background: var(--accent-soft); }
.chev { width: 30px; height: 30px; border: 0; background: transparent; color: var(--muted); font-size: 17px; display: grid; place-items: center; transition: transform .12s; flex: none; border-radius: 8px; cursor: pointer; }
.chev:hover { color: var(--text); background: var(--surface-3); }
.chev.closed { transform: rotate(-90deg); }
.chev.none { visibility: hidden; }
.bullet { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: none; margin: 0 6px; }
.outline-input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 7px 6px; outline: none; font-size: 15px; }
.outline-row:focus-within .outline-input { color: var(--text); }
.outline-actions { display: none; gap: 2px; margin-right: 4px; }
.outline-row:hover .outline-actions, .outline-row:focus-within .outline-actions { display: inline-flex; }
.outline-row .count-badge { margin-right: 6px; }
.outline-add { margin-top: 10px; border: 1px dashed var(--border-strong); background: transparent; color: var(--muted); border-radius: 9px; padding: 8px 14px; width: 100%; text-align: left; }
.outline-add:hover { color: var(--text); background: var(--surface); }

/* ── To-do shell ──────────────────────────────────────────────────── */
.view-seg .seg-btn { padding: 6px 12px; }
.seg-icon { font-size: 13px; }
.filter-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.token-field { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 4px 10px; min-height: 38px; flex: 1 1 260px; max-width: 620px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); cursor: text; transition: border-color .12s, box-shadow .12s; }
.token-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.token-icon { color: var(--muted); font-size: 15px; }
.token-input { flex: 1 1 140px; min-width: 100px; border: 0; background: transparent; outline: none; padding: 4px 2px; }
.token-input::placeholder { color: var(--muted); }
.filter-count { font-size: 13px; }
.ghosted { visibility: hidden; pointer-events: none; }                /* keeps its place in the bar */
.filter-count { min-width: 64px; }
.tool-right { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; flex: none; }   /* switch + add: together, at the right, whatever wraps */
.filter-bar .token-field { flex: 1 1 200px; }
.tool-slot { display: inline-flex; align-items: center; }
.tool-slot:empty { display: none; }
.tool-slot.add { display: inline-flex; width: 124px; flex: none; justify-content: stretch; }   /* reserved, so the grouping switch stays put */
.tool-slot.add .btn, .tool-slot.add .tool-input { width: 100%; justify-content: center; }
.tool-input { padding: 6px 8px; }
.todo-body { min-height: 200px; }

/* List */
.list-group { margin-bottom: 18px; }
.group-head { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 0 4px 8px; }
.list-group.today .group-head { color: var(--accent); }
.list-group.overdue .group-head { color: var(--danger); }
.group-count { background: var(--surface-3); color: var(--muted); font-size: 11px; border-radius: 999px; padding: 1px 7px; }
.task-row { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 6px; cursor: pointer; transition: border-color .12s, transform .08s; }
.task-row:hover { border-color: var(--border-strong); }
.task-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.task-check { display: grid; place-items: center; }
.task-check input, .tt-check input, .cal-pill input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; margin: 0; }
/* One line per task: the title, then its tags; a long title ellipsises rather than wrapping. */
.task-body { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.task-row.add-row .task-body { display: block; }
.task-title { font-weight: 400; flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }   /* topics are bold; tasks are not */
.task-body > .task-meta { margin-top: 0; flex: none; flex-wrap: nowrap; }
.task-notes { color: var(--muted); font-size: 13px; margin-top: 2px; white-space: pre-wrap; overflow-wrap: anywhere; }
.task-row.done .task-title, tr.done .tt-title, .cal-pill.done .cal-pill-title { text-decoration: line-through; color: var(--muted); }
.task-row.done { opacity: .75; }

/* Table: topics across, days down */
.tt-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; font-size: 13px; }
.tt-name-input { font: inherit; font-weight: 650; border: 0; border-bottom: 2px solid var(--accent); background: transparent; outline: none; padding: 2px 4px; min-width: 140px; color: var(--text); }
.tt-topic-input { max-width: 440px; }
/* The wrapper is the scroll box, both ways, so the day column and the headings stay put while the grid moves under them. */
.tg-wrap { overflow: auto; max-height: calc(100dvh - var(--topbar-h) - 130px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.tg { border-collapse: separate; border-spacing: 0; width: 100%; table-layout: fixed; font-size: 14px; }   /* equal columns; min-width is set per column count */
.tg th, .tg td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); vertical-align: top; text-align: left; }
.tg tr > :last-child { border-right: 0; }
.tg tbody tr:last-child > * { border-bottom: 0; }
.tg th { background: var(--surface-2); font-weight: 650; padding: 8px 10px; }
.tg thead th { position: sticky; top: 0; z-index: 2; }
.tg-leaf { min-width: 0; }
/* The heading: the title takes the free width and wraps rather than ellipsises; in a narrow column the small
   controls flow onto a second line under it. */
.tg-head { display: flex; align-items: center; gap: 2px 6px; min-width: 0; flex-wrap: wrap; }
.tg-head .icon-btn { opacity: 0; }
.tg-col:hover .icon-btn, .tg-col:focus-within .icon-btn { opacity: 1; }
.tg-own, .tg-none { font-weight: 550; }
.tg-own .tg-name, .tg-none .tg-name { font-weight: 550; margin-right: 6px; }
.tg-cell { padding: 6px; min-height: 160px; height: 160px; }
.tg-cell .cal-pill-time.overdue { color: var(--danger); }
.inline-when { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
.inline-when .inline-date { flex: 1 1 120px; }
.inline-when .inline-time { flex: 0 1 96px; }
.tg-cell .cal-pill { margin-bottom: 3px; cursor: pointer; }
.tg-add { opacity: 0; width: 100%; border: 1px dashed transparent; background: transparent; color: var(--muted); border-radius: 6px; padding: 1px; font-size: 14px; line-height: 1.2; cursor: pointer; }
.tg-cell:hover .tg-add, .tg-add:focus-visible { opacity: 1; border-color: var(--border-strong); }
.tg-cell.adding { background: var(--accent-soft); }
.tg-group.sub { margin-top: 6px; padding-left: 8px; border-left: 2px solid var(--border); }
.tg-group.sub .tg-group.sub { margin-top: 4px; }
.chev.small { width: 22px; height: 22px; font-size: 13px; border-radius: 6px; margin-left: -4px; }
.tg-group.closed .tg-group-head { margin-bottom: 0; }
.tg-group-head { display: flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 2px 0 3px; }
.tg-group-head .chip-hash { font-size: 11px; }
.tg-group-n { font-weight: 600; margin-left: 2px; }
.tg-group .tg-add { margin-bottom: 2px; }
.tg-adds { display: flex; gap: 4px; align-items: stretch; }
.tg-adds .tg-add { flex: 1; }
.tg-hash { opacity: 0; flex: none; width: 26px; border: 1px dashed transparent; background: transparent; color: var(--accent); border-radius: 6px; font-weight: 700; font-size: 13px; cursor: pointer; }
.tg-cell:hover .tg-hash, .tg-hash:focus-visible { opacity: 1; border-color: var(--border-strong); }
.tg-group-name { font-weight: 700; }
.tg-group-head .tt-name-input { font-size: 12px; min-width: 100px; }

/* List: topic outline with checkbox tasks */
.lo { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; box-shadow: var(--shadow); }
/* A section's tasks in columns; its add links span them all. */
.lo-tasks.cols-2, .lo-tasks.cols-3, .lo-tasks.cols-4 { display: grid; gap: 4px 10px; align-items: start; }
.lo-tasks.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.lo-tasks.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.lo-tasks.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.lo-tasks[class*="cols-"]:not(.cols-1) > .task-row { margin-bottom: 0; }
.lo-tasks[class*="cols-"]:not(.cols-1) > .lo-adds { grid-column: 1 / -1; }
.lo-tools { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 8px; }
.lo-node { margin: 2px 0; }
.lo-head { display: flex; align-items: center; gap: 6px; min-height: 36px; padding: 2px 4px; border-radius: 8px; }
.lo-head:hover { background: var(--surface-2); }
.lo-name { font-weight: 650; }
.lo-head .btn, .lo-head .icon-btn { opacity: 0; }
.lo-head:hover .btn, .lo-head:hover .icon-btn, .lo-head:focus-within .btn, .lo-head:focus-within .icon-btn { opacity: 1; }
.lo-tasks { margin: 2px 0 6px 52px; }
/* The name is the button that opens a topic or person alone. */
.lo-open { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; border: 0; background: transparent; padding: 2px 8px; margin-left: -6px; border-radius: 8px; font: inherit; color: var(--text); cursor: pointer; min-width: 0; }
.lo-open:hover { background: var(--accent-soft); color: var(--accent-soft-ink); }
.lo-open .lo-name { font-weight: 650; white-space: normal; overflow-wrap: anywhere; text-align: left; }
.lo-open-arrow { color: var(--accent); font-size: 18px; line-height: 1; font-weight: 700; }
.lo-open:hover .lo-open-arrow { color: inherit; }
.lo-head .tg-rename { opacity: 0; }
.lo-head:hover .tg-rename, .lo-head .tg-rename:focus-visible { opacity: 1; }
.lo-head > .chev { width: 36px; height: 36px; font-size: 21px; }
.lo-crumbs { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; margin-right: 6px; flex-wrap: wrap; }
.lo-tasks .task-row { padding: 8px 10px; margin-bottom: 4px; }
.lo-tasks .add-link { display: block; padding: 4px 6px; }
.lo-children { margin-left: 16px; padding-left: 10px; border-left: 1px solid var(--border); }
.qa-line { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.qa-line .inline-title { flex: 1 1 200px; }

/* Calendar */
.cal-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.cal-nav { display: flex; align-items: center; gap: 4px; }
.cal-title { margin-left: 8px; font-size: 17px; min-width: 160px; }
.cal-arrange { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; }
.cal-wrap { display: grid; grid-template-columns: 1fr 240px; gap: 14px; align-items: start; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.cal-wd { background: var(--surface-2); color: var(--muted); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 7px 8px; text-align: center; }
.cal-day { background: var(--surface); min-height: 108px; padding: 6px; display: flex; flex-direction: column; gap: 4px; position: relative; cursor: pointer; }
.cal-day.other { background: color-mix(in srgb, var(--surface) 55%, var(--bg)); }
.cal-day.other .cal-day-num { color: var(--muted); opacity: .6; }
.cal-day.drop { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--accent-soft); }
.cal-day-head { display: flex; align-items: center; gap: 6px; }
.cal-day-num { font-size: 13px; font-weight: 650; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; }
.cal-day.today .cal-day-num { background: var(--accent); color: var(--accent-ink); }
.cal-day-full { display: none; }
.cal-add { margin-left: auto; opacity: 0; }
.cal-day:hover .cal-add { opacity: 1; }
.cal-items { display: flex; flex-direction: column; gap: 3px; min-height: 10px; flex: 1; }
.cal-group-head { display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .04em; overflow: hidden; }
.cal-group-head > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-group-head:first-child { margin-top: 0; }
.cal-pill { display: flex; align-items: center; flex-wrap: wrap; gap: 3px 5px; background: var(--accent-soft); color: var(--accent-soft-ink); border-radius: 6px; padding: 3px 6px; font-size: 12.5px; line-height: 1.3; cursor: grab; min-width: 0; }
.cal-pill input { width: 13px; height: 13px; flex: none; }
.cal-pill:hover { filter: brightness(.96); }
.cal-pill.dragging { opacity: .5; }
.cal-pill.overdue { background: var(--danger-soft); color: var(--danger); }
.cal-pill.done { background: var(--surface-2); color: var(--muted); }
.cal-pill-time { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 11.5px; flex: none; }
.cal-pill-title { flex: 1 1 70px; min-width: 0; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cal-pill-people { display: inline-flex; flex: none; margin-left: auto; }
.cal-pill-people .avatar { margin-left: -3px; box-shadow: 0 0 0 1.5px var(--surface); }
.cal-grid.cal-week .cal-day { min-height: 340px; }
.cal-grid.cal-week .cal-day-head { flex-wrap: wrap; row-gap: 0; }
.cal-grid.cal-week .cal-day-full { display: block; font-size: 11.5px; color: var(--muted); }
.cal-grid.cal-week .cal-add { margin-left: auto; }
.cal-tray { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 8px; position: sticky; top: calc(var(--topbar-h) + 14px); max-height: calc(100dvh - var(--topbar-h) - 30px); overflow: auto; }
.cal-tray.drop { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal-tray-head { display: flex; align-items: center; gap: 8px; }
.cal-tray-hint { color: var(--muted); font-size: 13px; }

/* ── Phone width ──────────────────────────────────────────────────── */
@media (max-width: 760px) {
  .topbar { padding: 0 12px; gap: 8px; }
  .brand-name { display: inline; }
  /* No backdrop-filter here: it would make the header the containing block of the fixed nav below, pinning the tabs to the header instead of the screen. */
  .topbar { backdrop-filter: none; background: var(--surface); }
  .export-btn { padding: 5px 8px; }
  /* The tabs become a bottom bar — a phone's thumb lives there, and four labelled tabs never fit beside the brand. */
  .nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; margin: 0; gap: 0; display: grid; grid-template-columns: repeat(5, 1fr); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-top: 1px solid var(--border); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
  .nav-tab { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: 11.5px; border-radius: 10px; justify-content: center; }
  .nav-icon { font-size: 19px; width: auto; }
  .nav-badge { position: absolute; top: 2px; right: calc(50% - 26px); }
  .main { padding: 16px 16px calc(84px + env(safe-area-inset-bottom)); }
  .toast-host { bottom: calc(80px + env(safe-area-inset-bottom)); }
  .page-head { gap: 10px; }
  .page-head h1 { font-size: 20px; }
  .hint-kbd { display: none; }
  .filter-search { width: 100%; }
  .seg-label { display: none; }
  .view-seg .seg-btn { padding: 6px 10px; }
  .token-field { max-width: none; }
  .input-date, .input-time { min-width: 0; }
  .outline-actions { display: inline-flex; }
  .outline-actions .icon-btn:not(:first-child):not(:last-child) { display: none; }
  .cal-wrap { grid-template-columns: 1fr; }
  .cal-tray { position: static; max-height: none; }
  /* The month becomes an agenda: only days with something on them, plus today. */
  .cal-grid { grid-template-columns: 1fr; }
  .cal-wd { display: none; }
  .cal-day:not(.has-items):not(.today) { display: none; }
  .cal-day.other { display: none; }
  .cal-grid.cal-week .cal-day { display: flex; min-height: 0; }
  .cal-day { min-height: 0; flex-direction: row; align-items: flex-start; gap: 10px; padding: 10px; }
  .cal-day-head { flex-direction: column; align-items: flex-start; gap: 0; width: 86px; flex: none; }
  .cal-day-full { display: block; font-size: 11.5px; color: var(--muted); }
  .cal-add { margin: 4px 0 0; opacity: 1; }
  .cal-pill { font-size: 13.5px; padding: 5px 8px; }
  .tg-add, .tg-hash, .tg-head .icon-btn, .tg-rename, .lo-head .btn, .lo-head .icon-btn, .grip, .access-at { opacity: 1 !important; }
  .tg-wrap { max-height: calc(100dvh - 200px); }
  .lo-tasks { margin-left: 22px; }
  .lo-tasks.cols-2, .lo-tasks.cols-3, .lo-tasks.cols-4 { grid-template-columns: 1fr; }   /* a phone has one column */
  .lo-tools .spacer ~ * { display: none; }   /* a phone has one column; Expand / Collapse all stay */
  .lo-children { margin-left: 8px; padding-left: 6px; }
  .modal-overlay { padding: 12px; align-items: flex-end; }
  .modal { max-height: calc(100dvh - 24px); }
}

/* ── Inline add rows (list group, table row, calendar day) ─────────── */
.add-link { background: none; border: 0; padding: 6px 4px; color: var(--muted); font-size: 13px; cursor: pointer; text-align: left; border-radius: 6px; }
.add-link:hover { color: var(--accent); }
.inline-title { width: 100%; border: 0; background: transparent; outline: none; padding: 4px 0; font: inherit; color: var(--text); min-width: 0; }
.inline-title::placeholder { color: var(--muted); }
.inline-chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.inline-chips:empty { display: none; }
.inline-chips-row { display: flex; flex-wrap: wrap; gap: 4px; }
.inline-stack { display: flex; flex-direction: column; gap: 4px; }
.inline-date, .inline-time { padding: 4px 6px; font-size: 13px; width: auto; max-width: 100%; }
.task-row.add-row { cursor: default; border-style: dashed; background: var(--surface); }
.task-row.add-row:focus-within { border-style: solid; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.add-plus { color: var(--muted); font-size: 17px; line-height: 1; width: 18px; text-align: center; padding-top: 3px; }
.list-group .add-link { margin: 0 0 6px 2px; }
.tt tbody tr.tt-add.open td { background: var(--accent-soft); vertical-align: middle; cursor: default; }
.tt tbody tr.tt-add.open:hover td { background: var(--accent-soft); }
.tt-name-input { font: inherit; font-weight: 650; border: 0; border-bottom: 2px solid var(--accent); background: transparent; outline: none; padding: 2px 4px; min-width: 160px; color: var(--text); }
.tt-topic-input { max-width: 440px; }
.cal-add-row { background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 6px; padding: 3px 6px; margin-top: 2px; }
.cal-add-row:focus-within { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }
.cal-add-row .inline-title { font-size: 12.5px; padding: 2px 0; }

/* Table: one level at a time */
.tg-crumbs { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; margin-right: 6px; flex-wrap: wrap; }
.tg-crumb-sep { color: var(--muted); }
.tg-crumb-here { color: var(--text); }
.name-click { cursor: text; border-radius: 4px; padding: 0 3px; margin: 0 -3px; }
.name-click:hover { background: var(--accent-soft); }
.access-ctl { display: inline-flex; align-items: center; }
.access-btn { display: inline-flex; align-items: center; gap: 3px; border: 0; background: transparent; padding: 1px 4px; border-radius: 999px; cursor: pointer; color: var(--muted); font-size: 12px; font-weight: 700; }
.access-btn:hover { background: var(--accent-soft); color: var(--accent-soft-ink); }
.access-avatars { display: inline-flex; align-items: center; }
.access-avatars .avatar { margin-right: -5px; box-shadow: 0 0 0 1.5px var(--surface); }
.access-avatars .avatar:last-child { margin-right: 2px; }
.access-more { font-size: 10.5px; color: var(--muted); margin-left: 4px; }
.access-at { opacity: .55; }
.access-topics { display: inline-flex; align-items: center; gap: 3px; }
.crumb-tools { display: inline-flex; align-items: center; gap: 2px; margin-left: 4px; }
.crumb-tools .tg-rename, .crumb-tools .access-at { opacity: .8 !important; }     /* always there on the breadcrumb */
.crumb-tools .access-btn { border: 1px solid var(--border-strong); padding: 2px 7px; }
.lo-head .access-btn .access-at, .tg-head .access-btn .access-at, .tg-group-head .access-btn .access-at { opacity: 0; }
.lo-head:hover .access-at, .tg-col:hover .access-at, .tg-group-head:hover .access-at, .access-btn:focus-visible .access-at { opacity: .8; }
.picker { display: flex; flex-direction: column; gap: 6px; }
.picker-search { padding: 7px 10px; }
.picker-list { max-height: 300px; overflow: auto; display: flex; flex-direction: column; }
.picker-row { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.picker-row:hover { background: var(--surface-2); }
.picker-row input { accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.picker-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-sub { color: var(--muted); font-size: 12px; white-space: nowrap; }
.picker-create, .picker-foot { display: flex; justify-content: flex-end; padding: 8px 4px 2px; border-top: 1px solid var(--line); margin-top: 6px; }
.picker-empty { padding: 8px 10px; border-radius: 8px; text-align: left; border: 0; background: transparent; color: var(--accent); font-weight: 550; }
.picker-create:hover { background: var(--accent-soft); }
.picker-empty { color: var(--muted); font-size: 13px; }
.picker-note { font-size: 12.5px; padding: 4px 6px 0; }
/* A column's heading is the button that opens its topic as a page; the ✎ beside it renames. */
.tg-open { display: inline-flex; align-items: center; gap: 8px; min-height: 30px; min-width: 0; flex: 1 1 auto; text-align: left; border: 0; background: transparent; padding: 2px 8px; margin-left: -4px; border-radius: 8px; font: inherit; font-weight: 650; color: var(--text); cursor: pointer; }
.tg-open:hover { background: var(--accent-soft); color: var(--accent-soft-ink); }
.tg-open .tg-name { white-space: normal; overflow-wrap: anywhere; min-width: 0; flex: 1 1 auto; }
.tg-kids { font-size: 13px; font-weight: 700; color: var(--accent); white-space: nowrap; }
.tg-kids.muted { color: var(--muted); }
.tg-open:hover .tg-kids { color: inherit; }
.tg-rename { opacity: 0; }
.tg-col:hover .tg-rename, .tg-rename:focus-visible { opacity: 1; }

/* ── Editing in place: the add row, pre-filled ─────────────────────── */
.task-row.add-row.editing { border-style: solid; border-color: var(--accent); cursor: default; }
.cal-add-row.editing { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }
.inline-line { display: flex; align-items: center; gap: 4px; }
.inline-line .inline-title { flex: 1; }
.inline-del { flex: none; opacity: .7; }
.inline-del:hover { opacity: 1; }

/* ── Dragging in the List ──────────────────────────────────────────── */
.grip { color: var(--border-strong); font-size: 11px; letter-spacing: -2px; width: 12px; flex: none; cursor: grab; user-select: none; }
.lo-head .grip { opacity: 0; }
.lo-head:hover .grip { opacity: 1; }
.task-row .grip { align-self: center; opacity: 0; margin-right: -4px; }
.task-row:hover .grip { opacity: 1; }
.dragging { opacity: .45; }
.task-row.drop-before { box-shadow: 0 -3px 0 0 var(--accent); }
.task-row.drop-after { box-shadow: 0 3px 0 0 var(--accent); }
.lo-head.drop-before { box-shadow: inset 0 3px 0 0 var(--accent); }
.lo-head.drop-after { box-shadow: inset 0 -3px 0 0 var(--accent); }
.lo-head.drop-inside, .lo-tasks.drop-inside { background: var(--accent-soft); border-radius: 8px; }
.lo-adds { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.lo-adds .task-row.add-row { flex: 1 1 100%; }
.lo-adds.root { margin: 4px 0 4px 52px; }
.hash-link { color: var(--accent); }
.hash-link:hover { text-decoration: underline; }
.tg-col.tg-new, .tg-cell.tg-new { width: 56px; background: var(--surface-2); }
.tg-cell.tg-new { background: transparent; }
.tg-new-btn { width: 100%; height: 100%; min-height: 28px; border: 1px dashed var(--border-strong); background: transparent; color: var(--muted); border-radius: 6px; font-size: 16px; cursor: pointer; }
.tg-new-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.tg-col.past .tg-name { color: var(--danger); }
.tg-col.today .tg-name { color: var(--accent); }
.tg-head.col { flex-direction: column; align-items: flex-start; gap: 0; }
.tg-day-sub { display: block; font-size: 11.5px; color: var(--muted); font-weight: 450; }
.lo-head .avatar { flex: none; }
.lo-head.past .lo-name { color: var(--danger); }
.lo-head.today .lo-name { color: var(--accent); }
.lo-day-sub { margin-left: 8px; font-size: 12px; font-weight: 450; color: var(--muted); }
.lo-head .tag-me { margin-left: 6px; }
.tg-groupby { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; }
.tg-group.past .tg-group-head { color: var(--danger); }
.tg-group.today .tg-group-head { color: var(--accent); }
.tg-group-head .avatar { flex: none; }

/* ── Forms ─────────────────────────────────────────────────────────── */
.chip-form { background: var(--warn-soft); color: var(--warn); cursor: pointer; }
.chip-form .chip-hash { color: var(--warn); }
.chip-n { background: var(--warn); color: #fff; font-size: 10.5px; font-weight: 700; border-radius: 999px; padding: 0 5px; margin-left: 2px; }
.chip-form.complete { background: #e3f6ec; color: var(--ok); }
.chip-form.complete .chip-hash { color: var(--ok); }
.chip-form.complete .chip-n { background: var(--ok); }
.submit-rule { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12.5px; padding: 2px 6px; border-radius: 8px; border: 1px dashed transparent; }
.chip-open { background: var(--surface-2); color: var(--muted); font-style: italic; padding-left: 8px; }
.chip-group { background: #e6f1fb; color: #1f5f99; padding-left: 7px; }
.group-mark { font-size: 12px; }
.group-mark-lg { background: #e6f1fb; color: #1f5f99; font-size: 22px; }
.picker-group { background: #e6f1fb33; }
.picker-sep { height: 1px; background: var(--border); margin: 4px 6px; }
.groups { margin-top: 28px; }
.muted.ok { color: var(--ok); font-weight: 600; }
.submit-rule.shake { animation: shake .35s; }
input[type=checkbox]:disabled { opacity: .55; cursor: not-allowed; }
.form-mark { width: 46px; height: 46px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); display: grid; place-items: center; font-size: 28px; font-weight: 800; flex: none; }
.form-mark-sm { font-size: 22px; font-weight: 800; color: var(--warn); }
.form-title-input { font: inherit; font-size: 22px; font-weight: 650; border: 0; border-bottom: 2px solid transparent; background: transparent; padding: 2px 4px; min-width: 200px; flex: 1 1 200px; color: var(--text); outline: none; }
.form-title-input:hover, .form-title-input:focus { border-bottom-color: var(--accent); }
.form-tabs { margin-bottom: 16px; }
.form-tabs .seg-btn { text-decoration: none; }
.fields { display: flex; flex-direction: column; gap: 8px; }
.field-row { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.field-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.field-n { width: 18px; text-align: right; font-size: 12px; }
.field-label-in { flex: 1 1 220px; }
.field-type { width: 160px; flex: none; }
.field-req { font-size: 13px; white-space: nowrap; }
.field-actions { display: inline-flex; gap: 2px; margin-left: auto; }
.field-extra { padding-left: 26px; }
.field-options { font-size: 13px; }
.subs-wrap { overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.subs { border-collapse: collapse; width: 100%; font-size: 14px; }
.subs th, .subs td { border-bottom: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
.subs th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
.subs-when { white-space: nowrap; }
.filter-chips { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.filter-chips .chip-x { text-decoration: none; }
.att-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.att-img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); }
.att-link { display: inline-flex; align-items: center; gap: 4px; }
.att-audio { height: 36px; max-width: 260px; }
.stars-ro { color: var(--warn); letter-spacing: 1px; }
.mini-sheet { border-collapse: collapse; font-size: 13px; }
.mini-sheet th, .mini-sheet td { border: 1px solid var(--border); padding: 3px 6px; text-align: left; }
.mini-sheet th { background: var(--surface-2); font-weight: 650; }
.fill { display: flex; flex-direction: column; gap: 14px; }
.fill-field { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.fill-field.missing { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.fill-field .req { color: var(--danger); }
.fill-foot { display: flex; justify-content: flex-end; gap: 8px; }
.opts { display: flex; flex-wrap: wrap; gap: 6px; }
.opt { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 999px; padding: 6px 12px; cursor: pointer; }
.opt.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.stars { display: inline-flex; gap: 2px; }
.star { border: 0; background: transparent; font-size: 28px; line-height: 1; color: var(--border-strong); cursor: pointer; padding: 0 2px; }
.star.on { color: var(--warn); }
.sheet { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.sheet-in { padding: 4px 6px; font-size: 13px; min-width: 110px; }
.voice { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.file-in { font-size: 13px; }

/* ── Comments & notifications ──────────────────────────────────────── */
.comment-btn { display: inline-flex; align-items: center; gap: 3px; border: 0; background: transparent; padding: 1px 5px; border-radius: 999px; cursor: pointer; font-size: 12px; color: var(--muted); opacity: .35; }
.comment-btn.has { opacity: 1; color: var(--accent); background: var(--accent-soft); }
.task-row:hover .comment-btn, .cal-pill:hover .comment-btn, .tg-task:hover .comment-btn, .comment-btn:focus-visible { opacity: 1; }
.comment-n { font-weight: 700; }
.modal .comment-btn { display: none; }     /* the popup is the thread; no 💬 inside it */
.cal-pill .comment-btn { padding: 0 3px; font-size: 11px; }
.thread { max-height: 40vh; overflow: auto; display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.comment { display: flex; gap: 10px; align-items: flex-start; }
.comment-body { flex: 1; min-width: 0; background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.comment-head { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.comment-head .icon-btn { margin-left: auto; opacity: .5; }
.comment-text { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 2px; }
.comment-compose { display: flex; gap: 8px; align-items: flex-end; }
.comment-in { flex: 1; }
.bell-btn { position: relative; font-size: 17px; }
.bell-badge { position: absolute; top: -2px; right: -4px; font-size: 10.5px; min-width: 16px; padding: 0 4px; }
.notif-menu { min-width: 320px; }
.notif-head { display: flex; align-items: center; gap: 8px; padding: 6px 10px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.notif-list { max-height: 60vh; overflow: auto; display: flex; flex-direction: column; }
.notif { display: flex; gap: 10px; align-items: flex-start; text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 8px; color: var(--text); font-size: 13.5px; cursor: pointer; }
.notif:hover { background: var(--surface-2); }
.notif.unread { background: var(--accent-soft); }
.notif.unread:hover { background: var(--accent-soft); filter: brightness(.97); }
.notif-body { flex: 1; min-width: 0; }
.notif-quote { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.notif-icon { width: 26px; text-align: center; color: var(--muted); }
.small { font-size: 12px; }

/* ── Schedulers ────────────────────────────────────────────────────── */
.sched { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow); }
.sched-row { display: flex; align-items: center; gap: 8px; }
.sched-row.wrap { flex-wrap: wrap; }
.sched-icon { font-size: 18px; }
.sched-title { font-size: 15px; border: 1px solid var(--border-strong); border-radius: 9px; padding: 8px 10px; }
.sched-title:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sched-rule { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sched-n { width: 70px; padding: 5px 8px; }
.sched-unit { width: auto; padding: 5px 8px; }
.weekdays { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.weekdays .opt { padding: 4px 9px; font-size: 13px; }
.sched-next { font-size: 13px; }
.sched-times { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.sched-lead { display: inline-flex; align-items: center; gap: 8px; }
.sched-time { display: inline-flex; align-items: center; gap: 2px; }

/* ── Messages ──────────────────────────────────────────────────────── */
.main[data-page="messages"] { max-width: none; }
.msgs { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 14px; height: calc(100dvh - var(--topbar-h) - 44px); min-height: 420px; }
.room-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.room-list-head { display: flex; flex-direction: column; gap: 8px; padding: 6px 6px 10px; }
.room-search { width: 100%; }
.room-rows { display: flex; flex-direction: column; gap: 2px; flex: 1; min-height: 0; overflow: auto; }
.room-list-foot { padding: 10px 2px 2px; border-top: 1px solid var(--border); margin-top: 6px; background: var(--surface); }
.search-sec { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 12px 10px 4px; }
.hit-snip { font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
mark { background: var(--warn-soft); color: inherit; border-radius: 3px; padding: 0 2px; }
.list-add { margin: 0 4px 8px; }
.room-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: var(--text); text-decoration: none; }
.room-row:hover { background: var(--surface-2); }
.room-row.active { background: var(--accent-soft); }
.room-row.unread .room-row-name { font-weight: 700; }
.room-row-body { flex: 1; min-width: 0; }
.room-row-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-row-last { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-avatar { width: 36px; height: 36px; font-size: 18px; border-radius: 50%; }
.room { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 0; }
.room-empty { align-items: center; justify-content: center; }
.room-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.room-back { display: none; }
.room-head-body { min-width: 0; }
.room-thread { flex: 1; min-height: 0; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.room-hint { text-align: center; margin: auto; }
.room-day { align-self: center; font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 6px 0 2px; }
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 78%; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg-body { min-width: 0; }
.bubble { background: var(--surface-2); border-radius: 14px 14px 14px 4px; padding: 8px 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.mine .bubble { background: var(--accent); color: var(--accent-ink); border-radius: 14px 14px 4px 14px; }
.msg-meta { margin-top: 2px; display: flex; align-items: center; gap: 4px; }
.msg.mine .msg-meta { justify-content: flex-end; }
.msg-meta .icon-btn { opacity: 0; }
.msg:hover .msg-meta .icon-btn { opacity: .7; }
.card-msg { display: flex; gap: 10px; align-items: flex-start; background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); border-radius: 12px; padding: 10px 12px; }
.msg.mine .card-msg { background: var(--accent-soft); border-color: transparent; }
.card-ico { font-size: 16px; width: 20px; text-align: center; color: var(--warn); flex: none; }
.msg.mine .card-ico { color: var(--accent); }
.card-body { min-width: 0; }
.card-title { font-weight: 600; }
.msg-quote { display: block; border: 0; background: transparent; padding: 0 6px; font-size: 12.5px; color: var(--muted); text-align: left; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.msg-quote:hover:not(:disabled) { color: var(--text); text-decoration: underline; }
.msg-quote:disabled { cursor: default; }
.msg.mine .msg-quote { text-align: right; }
.card-task { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.room-add { margin: 0 14px 10px; }
.msg-hit .bubble, .msg-hit .card-msg, .msg-hit .msg-atts { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 12px; }
.msg-stack { display: flex; flex-direction: column; gap: 6px; }
.msg.mine .msg-stack { align-items: flex-end; }
.msg-atts { display: flex; flex-wrap: wrap; gap: 6px; }
.msg-img { display: block; max-width: 260px; max-height: 260px; border-radius: 12px; }
.msg-img-link { display: block; line-height: 0; }
.msg .att-link { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border-radius: 10px; padding: 8px 12px; color: var(--text); text-decoration: none; font-weight: 600; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg.mine .att-link { background: var(--accent-soft); color: var(--accent-soft-ink); }
.msg .att-audio { max-width: 260px; height: 36px; }
.room-compose { display: flex; flex-direction: column; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--border); }
.compose-seg { flex: none; align-self: center; }
.compose-seg .ico { font-size: 13px; }
.task-row.add-row.compose-task { flex: 1; min-width: 0; margin: 0; padding: 6px 10px; }
.compose-row { display: flex; gap: 8px; align-items: flex-end; }
.compose-tools { display: inline-flex; gap: 2px; align-self: center; }
.compose-tool { font-size: 18px; width: 34px; height: 34px; }
.compose-tool.rec { color: var(--danger); animation: rec-pulse 1s ease-in-out infinite; }
@keyframes rec-pulse { 50% { opacity: .45; } }
.rec-status { font-size: 12.5px; color: var(--danger); font-weight: 600; }
.compose-staged { display: flex; flex-wrap: wrap; gap: 6px; }
.staged { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border-radius: 10px; padding: 4px 6px 4px 8px; font-size: 13px; max-width: 100%; }
.staged > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.staged img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; display: block; }
.msg-in { flex: 1; resize: none; }
/* The floating ＋: a new task from anywhere — above the phone's bottom bar, never in an export. */
.fab { position: fixed; right: 22px; bottom: 22px; width: 54px; height: 54px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); font-size: 30px; line-height: 1; display: grid; place-items: center; cursor: pointer; box-shadow: 0 8px 24px rgba(0, 0, 0, .22); z-index: 25; transition: transform .12s ease, box-shadow .12s ease; }
.fab:hover { transform: translateY(-1px) scale(1.04); box-shadow: 0 10px 28px rgba(0, 0, 0, .26); }
.fab.hidden { display: none; }
.quick-add { margin: 0 0 12px; background: var(--surface); border: 1px dashed var(--accent); border-radius: var(--radius); padding: 8px 12px; }
body.exporting .fab, body.exporting .quick-add { display: none !important; }
@media (max-width: 760px) {
  .msgs { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .msgs.in-room .room-list { display: none; }
  .msgs:not(.in-room) .room { display: none; }
  .room { height: calc(100dvh - var(--topbar-h) - 120px); }
  .fab { right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); }
  .compose-seg .lbl { display: none; }        /* icons only: the box needs the width */
  .compose-seg .seg-btn { padding: 4px 7px; }
  .room-list { overflow: visible; }
  .room-rows { overflow: visible; }
  .room-list-foot { position: sticky; bottom: calc(72px + env(safe-area-inset-bottom)); }
  .room-back { display: inline-grid; }
  .msg { max-width: 92%; }
}
