:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --sunken: #efefea;
  --line: #e2e2dc;
  --text: #1f2328;
  --muted: #6b6f76;
  --faint: #9a9ea5;
  --accent: #2f62d8;
  --accent-soft: #e6edfc;
  --ok: #23905d;
  --ok-soft: #e3f3ea;
  --warn: #b7791f;
  --warn-soft: #fbf0dc;
  --danger: #cc3a43;
  --danger-soft: #fbe7e8;
  --shadow: 0 1px 2px rgb(20 20 10 / 5%), 0 8px 24px rgb(20 20 10 / 6%);
  --radius: 12px;
  --sidebar: 248px;
  --detail: 440px;
  color-scheme: light;
  font: 15px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}
/* Dark palette: chosen explicitly in the user menu, or by the system when the
   theme is left on "auto" (no data-theme attribute). */
:root[data-theme=dark] {
  --bg: #16181b; --surface: #1e2125; --sunken: #23272c; --line: #30353c;
  --text: #e6e8eb; --muted: #a0a6ae; --faint: #6f757d;
  --accent: #7ea2ff; --accent-soft: #233154;
  --ok: #4cc38a; --ok-soft: #1c3a2c; --warn: #e2b04a; --warn-soft: #3d321b;
  --danger: #ff7b82; --danger-soft: #45242a;
  --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 8px 24px rgb(0 0 0 / 30%);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #16181b; --surface: #1e2125; --sunken: #23272c; --line: #30353c;
    --text: #e6e8eb; --muted: #a0a6ae; --faint: #6f757d;
    --accent: #7ea2ff; --accent-soft: #233154;
    --ok: #4cc38a; --ok-soft: #1c3a2c; --warn: #e2b04a; --warn-soft: #3d321b;
    --danger: #ff7b82; --danger-soft: #45242a;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 8px 24px rgb(0 0 0 / 30%);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; margin: 4px 0; }

input, select, textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; width: 100%; min-width: 0;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
label { display: grid; gap: 4px; align-content: start; font-size: 13px; color: var(--muted); }

.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 14px; font-weight: 550; white-space: nowrap; }
.btn:hover { background: var(--sunken); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--sunken); color: var(--text); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.wide { width: 100%; padding: 11px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: 0; background: transparent; width: 32px; height: 32px; border-radius: 8px; font-size: 18px; line-height: 1; color: var(--muted); }
.icon-btn:hover { background: var(--sunken); color: var(--text); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 32px; box-shadow: var(--shadow); display: grid; gap: 14px; }
.login-card h1 { margin: 6px 0 0; font-size: 28px; line-height: 1.15; letter-spacing: -.03em; }
.login-card p { margin: 0; }
/* Wordmark as in the original task_hub: bold "task", light accent "hub", spaced caption. */
.wordmark { display: inline-block; font-size: 30px; font-weight: 750; letter-spacing: -1.6px; color: var(--text); line-height: 1; }
.wordmark span { color: var(--accent); font-weight: 400; }
.wordmark small { display: block; letter-spacing: 3px; font-size: 10px; margin-top: 8px; font-weight: 500; color: var(--muted); }
a.wordmark:hover { text-decoration: none; }
.wordmark.small { font-size: 25px; padding: 4px 10px 6px; }

/* Layout */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.app.with-detail { grid-template-columns: var(--sidebar) 1fr var(--detail); }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 18px; background: var(--bg); }
.nav { display: grid; gap: 1px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--text); border: 0; background: transparent; text-align: left; width: 100%; font-size: 14.5px; }
.nav-link:hover { background: var(--sunken); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-link .ico { width: 18px; text-align: center; color: var(--faint); }
.nav-link.active .ico { color: var(--accent); }
.nav-link .count { margin-left: auto; font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.nav-link .count.alert { color: var(--danger); font-weight: 650; }
.nav-link .dot { width: 9px; height: 9px; border-radius: 50%; margin: 0 4px; flex: none; }
.nav-link .fdot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none; }
.nav-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 4px 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }
.nav-bottom { margin-top: auto; display: grid; gap: 1px; }

.main { min-width: 0; padding: 24px clamp(16px, 4vw, 48px) 96px; max-width: 1080px; width: 100%; justify-self: center; }
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.titles { flex: 1; min-width: 0; }
.eyebrow { margin: 0; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.title-line { display: flex; align-items: center; gap: 4px; min-width: 0; }
.top h1 { margin: 2px 0 0; font-size: 28px; letter-spacing: -.02em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title-tools { position: relative; flex: none; }
.project-menu { left: 0; right: auto; }
.menu-item.color-row { display: flex; align-items: center; justify-content: space-between; color: var(--text); font-size: 14px; }
.color-input { width: 44px; height: 28px; padding: 2px; }
.main.wide { max-width: 1400px; }
.search { width: min(260px, 30vw); position: relative; }
.search input { background: var(--sunken); border-color: transparent; padding-right: 30px; }
.search input::-webkit-search-cancel-button { display: none; }
.search-clear { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--muted); font-size: 18px; width: 26px; height: 26px; border-radius: 6px; padding: 0; }
.search-clear:hover { background: var(--line); color: var(--text); }
.add-buttons { display: flex; gap: 6px; flex: none; }

/* Quick line: pops up over the page on «Быстро» or the N key */
.quick { position: fixed; inset: 0; z-index: 60; background: rgb(0 0 0 / 25%); display: grid; justify-items: center; align-items: start; padding: 12vh 16px 16px; }
.quick-card { width: min(640px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 14px 16px; display: grid; gap: 10px; }
.quick-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 13px; }
.quick-line { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.quick-line input { padding: 10px 12px; font-size: 15.5px; }
.quick-hint { margin: 0; font-size: 12.5px; line-height: 1.7; }
.quick-hint code { background: var(--sunken); border-radius: 4px; padding: 0 4px; font-size: 12px; }

/* New task form */
.task-dialog { border: 1px solid var(--line); border-radius: 16px; padding: 0; width: min(620px, calc(100% - 24px)); max-height: calc(100% - 24px); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.task-dialog::backdrop { background: rgb(0 0 0 / 35%); }
.task-form { display: grid; gap: 14px; padding: 20px 22px; }
.ask-dialog { width: min(440px, calc(100% - 24px)); }
.ask-form { display: grid; gap: 12px; padding: 20px 22px 18px; }
.ask-form h2 { margin: 0; font-size: 18px; overflow-wrap: anywhere; }
.ask-form p { margin: 0; }
.ask-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.ask-choices { display: grid; gap: 2px; max-height: 50vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 4px; }
.ask-choice { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; font-size: 14px; cursor: pointer; }
.ask-choice:hover { background: var(--sunken); }
.ask-choice input { width: auto; margin: 0; }
.drop { position: relative; }
.drop-menu { display: none; position: absolute; left: 0; top: 100%; z-index: 30; min-width: 190px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.drop:hover .drop-menu, .drop:focus-within .drop-menu, .drop.open .drop-menu { display: grid; gap: 2px; }
.drop-menu .menu-item { text-decoration: none; }
.drop-menu .menu-item:hover, .drop-menu .menu-item:focus-visible { background: var(--sunken); }
.backups summary { cursor: pointer; font-size: 14px; }
.backup-list { margin: 8px 0 0; padding-left: 20px; font-size: 14px; color: var(--muted); display: grid; gap: 2px; }
.btn.primary.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog-head h2 { margin: 0; font-size: 20px; }
.dialog-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dialog-actions .spacer { flex: 1; }

/* Selection and bulk actions */
.pick { flex: none; width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); cursor: pointer; }
.row.picked { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.bulk { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 45; width: min(980px, calc(100vw - 24px)); background: var(--surface); border: 1px solid var(--accent); border-radius: 14px; box-shadow: var(--shadow); padding: 8px 12px 10px; display: grid; gap: 6px; }
.main.selecting { padding-bottom: 200px; } /* the last rows can scroll above the bar */
.bulk-head { display: flex; align-items: center; gap: 10px; }
.bulk-head .spacer { flex: 1; }
.bulk-actions { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.bulk-actions:disabled { opacity: .45; }
.bulk-actions select, .bulk-actions input { width: auto; padding: 4px 8px; font-size: 13px; }

/* User menu */
.user { position: relative; flex: none; }
.user-btn { display: flex; align-items: center; gap: 8px; border: 1px solid transparent; background: transparent; border-radius: 999px; padding: 3px 10px 3px 3px; }
.user-btn:hover, .user-btn[aria-expanded=true] { background: var(--sunken); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.user-name { font-size: 14px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caret { font-size: 11px; color: var(--muted); }
.user-menu { position: absolute; right: 0; top: calc(100% + 6px); width: 290px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px; z-index: 45; display: grid; gap: 4px; }
.user-card { display: grid; padding: 6px 8px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.user-card span { font-size: 12.5px; }
.menu-label { font-size: 12px; color: var(--faint); padding: 2px 8px; }
.user-menu .seg { display: flex; margin: 0 8px 6px; }
.user-menu .seg button { font-size: 12.5px; padding: 5px 8px; flex: 1; }
.menu-item { display: block; text-align: left; border: 0; background: transparent; padding: 8px; border-radius: 8px; color: var(--text); width: 100%; font-size: 14px; }
.menu-item:hover { background: var(--sunken); text-decoration: none; }
.menu-item.danger { color: var(--danger); }
.menu-foot { font-size: 11.5px; padding: 6px 8px 2px; border-top: 1px solid var(--line); margin-top: 4px; }

/* Today overview tiles */
.overview { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.tile { display: grid; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; color: var(--text); }
a.tile:hover { text-decoration: none; border-color: var(--accent); }
.tile-label { font-size: 12.5px; color: var(--muted); }
.tile strong { font-size: 24px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.tile strong.danger { color: var(--danger); }
.tile strong.accent { color: var(--accent); }

/* Sorting and filters */
.filters { display: grid; gap: 8px; margin-bottom: 14px; }
.filter-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.filter-label { font-size: 13px; color: var(--muted); }
.filter-row .spacer { flex: 1; }
.sort-select { width: auto; padding: 4px 8px; font-size: 13px; }
.sort-select.changed, .btn.changed { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.btn .badge { display: inline-block; min-width: 18px; margin-left: 6px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 11.5px; text-align: center; }
.btn.reset { color: var(--danger); }
.filter-chips .x { border: 0; background: transparent; color: inherit; padding: 0 0 0 2px; font-size: 14px; line-height: 1; }
.filter-panel { display: grid; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.filter-panel select, .filter-panel input { padding: 6px 8px; font-size: 13.5px; }
.toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.toggles button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 3px 11px; font-size: 13px; color: var(--muted); }
.toggles button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* Capture */
.preview:empty { display: none; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 12.5px; background: var(--sunken); color: var(--muted); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.danger { background: var(--danger-soft); color: var(--danger); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; }
a.chip:hover { text-decoration: none; filter: brightness(.97); }

/* Reminders */
.reminders { display: grid; gap: 8px; margin-bottom: 16px; }
.reminder { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 10px; background: var(--warn-soft); color: var(--text); }
.reminder strong { flex: 1; min-width: 0; font-weight: 550; cursor: pointer; }

/* Task list */
.group { margin: 22px 0 6px; display: flex; align-items: baseline; gap: 8px; font-size: 13px; font-weight: 650; color: var(--muted); }
.group:first-child { margin-top: 0; }
.group.danger { color: var(--danger); }
.group .n { font-weight: 500; color: var(--faint); }
.row { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; cursor: pointer; position: relative; }
.row + .row { border-top: 1px solid transparent; }
.row:hover { background: var(--surface); box-shadow: var(--shadow); }
.row.selected { background: var(--accent-soft); }
.row.done .row-title { color: var(--faint); text-decoration: line-through; }
.check { flex: none; width: 20px; height: 20px; margin-top: 1px; border-radius: 50%; border: 1.6px solid var(--faint); background: transparent; display: grid; place-items: center; font-size: 12px; color: transparent; padding: 0; }
.check:hover { border-color: var(--ok); color: var(--ok); }
.row.done .check { background: var(--ok); border-color: var(--ok); color: #fff; }
.row.p2 .check { border-color: var(--warn); }
.row.p3 .check { border-color: var(--danger); border-width: 2px; }
/* Low priority recedes below the ordinary grey: dashed circle, softer title
   (still darker than a done task, which is also struck through). */
.row.p0:not(.done) .check { border-style: dashed; }
.row.p0:not(.done) .row-title { color: var(--muted); }
.row-main { flex: 1; min-width: 0; display: grid; gap: 4px; }
.row-title { overflow-wrap: anywhere; }
.row-title .prio { color: var(--danger); font-weight: 700; margin-right: 4px; }
.row-title .prio.p2 { color: var(--warn); }
.row-meta:empty { display: none; }
.row-next { font-size: 13.5px; color: var(--text); overflow-wrap: anywhere; }
.row-next span { color: var(--accent); font-weight: 600; }
.row-outcome { color: var(--muted); }
.outcome-count { float: right; font-size: 12px; color: var(--faint); font-weight: normal; }
.chip.author { background: transparent; border: 1px solid var(--line); }
.chip.date { font-variant-numeric: tabular-nums; }
.title-count { font-size: 18px; font-weight: 600; color: var(--muted); letter-spacing: 0; margin-left: 6px; font-variant-numeric: tabular-nums; }
.title-count.filtered { color: var(--accent); }
.row-actions { display: none; gap: 2px; flex: none; }
.row:hover .row-actions { display: flex; }
.row-actions button { border: 0; background: transparent; color: var(--muted); font-size: 12.5px; padding: 3px 7px; border-radius: 6px; }
.row-actions button:hover { background: var(--sunken); color: var(--text); }
.working { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .big { font-size: 40px; display: block; margin-bottom: 8px; }
.more { text-align: center; margin-top: 12px; }

/* Detail panel */
.detail { position: sticky; top: 0; height: 100vh; overflow-y: auto; overflow-x: hidden; border-left: 1px solid var(--line); background: var(--surface); padding: 16px 20px 40px; display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: 14px; }
.detail-head { display: flex; align-items: center; gap: 8px; color: var(--faint); font-size: 13px; }
.detail-head .spacer { flex: 1; }
.title-input { font-size: 20px; font-weight: 650; border-color: transparent; padding: 6px 8px; margin: 0 -8px; background: transparent; resize: none; overflow: hidden; }
.title-input:hover { border-color: var(--line); }
.fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px 12px; }
.fields .full { grid-column: 1 / -1; }
.date-field { display: grid; grid-template-columns: 1fr auto; gap: 4px; }
.quick-dates { display: flex; gap: 4px; flex-wrap: wrap; }
.quick-dates button { font-size: 12px; padding: 2px 8px; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; color: var(--muted); }
.quick-dates button:hover { color: var(--text); background: var(--sunken); }
.section { display: grid; gap: 8px; }
.section h3 { margin: 6px 0 0; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 650; }
.checklist { display: grid; gap: 2px; }
.check-item { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.check-item input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--ok); flex: none; }
.check-item span { flex: 1; overflow-wrap: anywhere; }
.check-item.done span { color: var(--faint); text-decoration: line-through; }
.check-item .icon-btn { width: 24px; height: 24px; font-size: 14px; opacity: 0; }
.check-item:hover .icon-btn { opacity: 1; }
.inline-form { display: flex; gap: 6px; }
.link-row { display: flex; align-items: center; gap: 8px; }
.link-row a, .link-row span.ref { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-form { display: grid; grid-template-columns: 110px 1fr; gap: 6px; }
.link-form .full { grid-column: 1 / -1; }
.timeline { display: grid; gap: 10px; }
.event { display: grid; gap: 2px; font-size: 13.5px; }
.event .who { font-size: 12px; color: var(--faint); }
.event.comment .body { background: var(--sunken); padding: 8px 10px; border-radius: 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
.event.system .body { color: var(--muted); }
.notes-field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.md-hint { font-size: 12px; color: var(--faint); }
.md { color: var(--text); font-size: 14.5px; line-height: 1.5; border: 1px solid transparent; border-radius: 8px; padding: 6px 10px; margin: 0 -10px; cursor: text; overflow-wrap: anywhere; }
.md:hover, .md:focus-visible { border-color: var(--line); background: var(--surface); outline: none; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md pre, .md blockquote { margin: 0 0 8px; }
.md h4, .md h5, .md h6 { margin: 12px 0 6px; line-height: 1.3; }
.md h4 { font-size: 17px; }
.md h5 { font-size: 15.5px; }
.md h6 { font-size: 14.5px; color: var(--muted); }
.md ul, .md ol { padding-left: 22px; }
.md li > ul, .md li > ol { margin: 2px 0; }
.md li.task { list-style: none; margin-left: -20px; }
.md li.task > input[type=checkbox] { width: 15px; height: 15px; padding: 0; margin: 0 6px 0 0; vertical-align: -2px; accent-color: var(--ok); }
.md li.task > ul, .md li.task > ol { margin-left: 21px; }
.md code { font-family: ui-monospace, monospace; font-size: 12.5px; background: var(--sunken); border-radius: 4px; padding: 1px 4px; }
.md pre { background: var(--sunken); border-radius: 8px; padding: 8px 10px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md blockquote { border-left: 3px solid var(--line); padding-left: 10px; color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 10px 0; }
.md a { color: var(--accent); }
.note-actions { margin-left: 8px; }
.note-actions button { border: 0; background: transparent; color: var(--faint); font-size: 12px; padding: 0 4px; text-decoration: underline; text-underline-offset: 2px; }
.note-actions button:hover { color: var(--text); }
.note-edit { display: grid; gap: 6px; }
.note-tools { display: flex; gap: 6px; }
.work { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid; gap: 6px; font-size: 13.5px; }
.work .steps { display: grid; gap: 3px; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 14px; }
.detail-actions .spacer { flex: 1; }

/* Pages: stats, agents, trash */
.page { display: grid; gap: 22px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: grid; gap: 12px; }
.card h2 { margin: 0; font-size: 16px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.toolbar label { width: auto; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 7px 12px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 28px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: 13px; }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 140px; padding-top: 6px; }
.bar { flex: 1; display: flex; flex-direction: column-reverse; gap: 1px; min-width: 2px; height: 100%; justify-content: flex-start; position: relative; }
.bar i { display: block; border-radius: 3px 3px 0 0; }
.bar i.c { background: var(--ok); }
.bar i.n { background: var(--accent); opacity: .35; }
.bars-axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--faint); }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 550; font-size: 13px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
pre.snippet { background: var(--sunken); border-radius: 8px; padding: 10px 12px; overflow-x: auto; font-size: 12.5px; margin: 0; white-space: pre; }
.secret { display: grid; gap: 8px; padding: 12px; border-radius: 10px; background: var(--ok-soft); }
.secret-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.secret-row input { flex: 1 1 320px; min-width: 0; font-family: ui-monospace, monospace; font-size: 13px; }
.form-row { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 8px; align-items: end; }
.archive-row { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-top: 1px solid var(--line); }
.archive-row .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.archive-row a.row-title { color: var(--text); font-weight: 550; }
.archive-actions { display: flex; gap: 6px; flex: none; flex-wrap: wrap; justify-content: flex-end; }
.trash-bar { align-items: center; }
.trash-bar .spacer { flex: 1; }
.pick-all { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-right: 6px; cursor: pointer; }

/* Calendar */
.cal-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.cal-nav { display: flex; gap: 4px; }
.cal-title { flex: 1; font-size: 17px; }
.cal-wrap { display: grid; gap: 4px; }
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-head div { font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; padding: 0 6px; }
.cal-day { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 6px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-grid.week .cal-day { min-height: 260px; }
.cal-grid.month .cal-day { min-height: 112px; }
.cal-day.past { background: var(--bg); }
.cal-day.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.cal-day.other { opacity: .5; }
.cal-dayhead { display: flex; align-items: baseline; gap: 6px; padding: 0 2px 4px; font-size: 13px; color: var(--muted); }
.cal-dayhead strong { font-size: 17px; color: var(--text); }
.cal-dayhead .wd { display: none; } /* the column header already names the day; shown on phones */
.cal-date { align-self: flex-start; border: 0; background: transparent; padding: 0 4px; border-radius: 6px; font-weight: 650; font-size: 13px; color: var(--muted); }
.cal-date:hover { background: var(--sunken); color: var(--text); }
.cal-day.today .cal-date { color: var(--accent); }
.cal-item { display: block; width: 100%; text-align: left; border: 0; border-left: 3px solid var(--accent); background: var(--accent-soft); color: var(--text); border-radius: 5px; padding: 3px 6px; font-size: 12.5px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-grid.week .cal-item { white-space: normal; overflow-wrap: anywhere; }
.cal-item:hover { filter: brightness(.96); }
.cal-item.p2 { border-left-color: var(--warn); }
.cal-item.p3 { border-left-color: var(--danger); }
.cal-item.p0 { border-left-color: var(--faint); color: var(--muted); }
.cal-item.due { background: var(--warn-soft); }
.cal-item.overdue { background: var(--danger-soft); }
.cal-item.someday { background: transparent; border: 1px dashed var(--line); border-left: 3px solid var(--faint); color: var(--muted); }
.cal-item.done { background: var(--sunken); color: var(--faint); text-decoration: line-through; border-left-color: var(--ok); }
.cal-item .prio { color: var(--danger); font-weight: 700; margin-right: 3px; }
.cal-item .prio.p2 { color: var(--warn); }
.due-mark { font-size: 11px; font-weight: 650; color: var(--warn); margin-right: 4px; text-transform: uppercase; }
.cal-more { border: 0; background: transparent; color: var(--accent); font-size: 12px; text-align: left; padding: 0 4px; }
.cal-empty { color: var(--faint); font-size: 13px; padding: 0 4px; }
.cal-add { margin-top: auto; padding: 4px 6px; font-size: 12.5px; border-style: dashed; background: transparent; }
.cal-hint { margin: 0; font-size: 13px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); z-index: 50; display: flex; gap: 14px; align-items: center; max-width: calc(100vw - 32px); }
.toast button { background: transparent; border: 0; color: var(--accent); font-weight: 650; filter: brightness(1.4); }
.only-mobile { display: none; }
.scrim { position: fixed; inset: 0; background: rgb(0 0 0 / 35%); z-index: 30; }

@media (max-width: 1180px) {
  .app.with-detail { grid-template-columns: var(--sidebar) 1fr; }
  .app.with-detail .detail { position: fixed; right: 0; top: 0; bottom: 0; width: min(var(--detail), 100vw); z-index: 40; box-shadow: var(--shadow); }
}
@media (max-width: 760px) {
  .only-mobile { display: initial; }
  .app, .app.with-detail { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; z-index: 35; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .main { padding: 14px 14px 110px; }
  .top { gap: 8px; }
  .top h1 { font-size: 23px; }
  .top { flex-wrap: wrap; }
  .search { order: 5; width: 100%; }
  .user-name, .caret { display: none; }
  .user-btn { padding: 3px; }
  .overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cal-head { display: none; }
  .cal-dayhead .wd { display: inline; }
  .cal-grid.week { grid-template-columns: 1fr; }
  .cal-grid.week .cal-day { min-height: 0; }
  .cal-grid.month .cal-day { min-height: 64px; padding: 3px; }
  .cal-grid.month .cal-item { font-size: 0; height: 6px; padding: 0; border-left-width: 0; }
  .cal-grid.month .cal-item .prio, .cal-grid.month .cal-item .due-mark { display: none; }
  .add-buttons .label, .filter-label { display: none; }
  .add-buttons .btn { padding: 8px 11px; }
  .quick { padding-top: 8vh; }
  .bulk { bottom: calc(64px + env(safe-area-inset-bottom)); }
  .task-form .fields { grid-template-columns: minmax(0, 1fr); }
  .app.with-detail .detail { width: 100vw; padding-bottom: 100px; }
  .row-actions { display: none !important; }
  .trash-row, .archive-row { flex-wrap: wrap; }
  .trash-row .archive-actions, .archive-row .archive-actions { width: 100%; justify-content: flex-start; padding-left: 30px; }
  .trash-bar .spacer { flex-basis: 100%; }
  .fields { grid-template-columns: minmax(0, 1fr); }
  .detail-head .icon-btn { width: 40px; height: 40px; font-size: 22px; }
  .form-row { grid-template-columns: 1fr 1fr; }
  .tabbar { position: fixed; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 20; }
  .tabbar a { display: grid; justify-items: center; font-size: 11px; color: var(--muted); position: relative; padding: 2px 0; }
  .tabbar a span { font-size: 18px; line-height: 1.2; }
  .tabbar a.active { color: var(--accent); }
  .tabbar a b { position: absolute; top: 0; left: 58%; font-size: 10px; background: var(--accent); color: #fff; border-radius: 999px; padding: 0 5px; }
  .tabbar a b:empty { display: none; }
}
