/* Todo — mobile-first stylesheet. No inline styles anywhere (strict CSP):
   dynamic values are set via CSS custom properties from JS (CSSOM). */

:root {
  color-scheme: light dark;
  --bg: #f5f5f2;
  --surface: #ffffff;
  --surface-2: #efefea;
  --surface-3: #e6e6e0;
  --text: #1b1b1f;
  --muted: #66666e;
  --border: #e0e0d9;
  --accent: #2b62d9;
  --accent-contrast: #ffffff;
  --accent-soft: #e4ecfd;
  --danger: #c93636;
  --danger-soft: #fbe7e7;
  --warn: #9a6200;
  --warn-soft: #fdf1dc;
  --ok: #23804b;
  --ok-soft: #e1f3e8;
  --q1: #d93d3d;
  --q2: #2b62d9;
  --q3: #c27a0e;
  --q4: #7a7b85;
  --q1-soft: #fbe9e9;
  --q2-soft: #e6edfc;
  --q3-soft: #fbf0dd;
  --q4-soft: #eeeef0;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 16px rgb(0 0 0 / 6%);
  --radius: 14px;
  --radius-sm: 10px;
  --tap: 44px;
  --tabbar-h: 56px;
  --qa-h: 64px;
  --side-w: 264px;
  --kb: 0px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --gutter-l: max(14px, var(--sal));
  --gutter-r: max(14px, var(--sar));
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131316;
    --surface: #1c1c20;
    --surface-2: #26262b;
    --surface-3: #303036;
    --text: #ececf0;
    --muted: #a0a0aa;
    --border: #2f2f35;
    --accent: #7aa2ff;
    --accent-contrast: #0d1424;
    --accent-soft: #1f2a44;
    --danger: #ff7b7b;
    --danger-soft: #3a1d1f;
    --warn: #f3b955;
    --warn-soft: #3a2c14;
    --ok: #6fd69a;
    --ok-soft: #173123;
    --q1: #ff7272;
    --q2: #7aa2ff;
    --q3: #f3b955;
    --q4: #a3a4ae;
    --q1-soft: #3a1d1f;
    --q2-soft: #1d2740;
    --q3-soft: #372a14;
    --q4-soft: #2a2a30;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 4px 16px rgb(0 0 0 / 30%);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

a { color: var(--accent); }

h1, h2, h3 { line-height: 1.25; margin: 0; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75em; }
p:last-child { margin-bottom: 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.icon {
  width: 1.25em;
  height: 1.25em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.25em;
}

/* ------------------------------------------------------------------ boot */

.boot {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.noscript { padding: 24px; text-align: center; }

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.06); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger); filter: brightness(1.06); }
.btn-danger-text { border-color: transparent; background: transparent; color: var(--danger); }
.btn-danger-text:hover { background: var(--danger-soft); }
.btn-link { border-color: transparent; background: transparent; color: var(--accent); font-weight: 500; }
.btn-link:hover { background: var(--accent-soft); }
.btn-block { display: flex; width: 100%; }
.btn-lg { min-height: 52px; font-size: 1.05rem; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .92rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  touch-action: manipulation;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:disabled { opacity: .35; cursor: default; background: transparent; }

/* ----------------------------------------------------------------- forms */

input, select, textarea, button { font: inherit; color: inherit; }

input[type=text], input[type=password], input[type=search], input[type=date], input[type=time],
input[type=datetime-local], input[type=number], select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 16px; /* avoids zoom on iOS */
  -webkit-appearance: none;
  appearance: none;
}
input[type=date], input[type=time], input[type=datetime-local] {
  display: flex;
  align-items: center;
  min-width: 0;
}
select {
  padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
textarea { resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .85; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input:disabled, select:disabled { opacity: .6; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label { font-size: .9rem; font-weight: 600; color: var(--muted); }
.hint { font-size: .86rem; color: var(--muted); margin: 4px 0 8px; }
.center { text-align: center; }
.strong { font-weight: 650; }
.stack { display: flex; flex-direction: column; gap: 4px; }
.stack > .btn { margin-top: 6px; }

.form-error {
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: .94rem;
}

.notice {
  margin: 8px 0 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  font-size: .95rem;
}
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.steps { margin: 8px 0 0; padding-left: 1.3em; }
.steps li { margin: 4px 0; }

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 8px;
  color: var(--muted);
  font-size: .85rem;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.inline-group { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.inline-group > input, .inline-group > select { flex: 1 1 0; }
.inline-field { display: flex; align-items: center; gap: 8px; margin: -6px 0 10px; color: var(--muted); }
.num-input { width: 90px !important; flex: none; }

.switch-label { display: inline-flex; align-items: center; gap: 10px; min-height: var(--tap); cursor: pointer; }
input.switch {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  width: 46px;
  height: 28px;
  flex: none;
  margin: 0;
  border-radius: 14px;
  background: var(--surface-3);
  cursor: pointer;
  transition: background .15s;
}
input.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 30%);
  transition: transform .15s;
}
input.switch:checked { background: var(--accent); }
input.switch:checked::after { transform: translateX(18px); }

/* ---------------------------------------------------------------- layout */

.content { min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: calc(52px + var(--sat));
  padding: var(--sat) var(--gutter-r) 0 var(--gutter-l);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.topbar-title {
  flex: 1;
  min-width: 0;
  font-size: 1.2rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-actions { display: flex; align-items: center; gap: 2px; }
.back-btn { margin-left: -10px; color: var(--accent); }

.view {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px var(--gutter-r) calc(var(--tabbar-h) + var(--qa-h) + var(--sab) + 32px) var(--gutter-l);
  outline: none;
}
.view[aria-busy="true"] > * { opacity: .75; transition: opacity .2s .15s; }
.view-error { padding: 32px 0; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  height: calc(var(--tabbar-h) + var(--sab));
  padding: 0 var(--sar) var(--sab) var(--sal);
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: var(--tap);
  color: var(--muted);
  font-size: 11px;
  font-weight: 550;
  text-decoration: none;
}
.tab .icon { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--accent); }

.sidebar { display: none; }

/* -------------------------------------------------------------- quick add */

.quickadd {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--tabbar-h) + var(--sab));
  z-index: 31;
  padding: 8px var(--gutter-r) 8px var(--gutter-l);
  background: var(--bg);
  border-top: 1px solid var(--border);
}
body.qa-focus .tabbar { display: none; }
body.qa-focus .quickadd { bottom: var(--kb); padding-bottom: calc(8px + var(--sab)); }
@media (min-width: 900px) {
  body.qa-focus .quickadd { padding-bottom: calc(10px + var(--sab)); }
}

.qa-form { display: flex; align-items: center; gap: 6px; max-width: 1100px; margin: 0 auto; }
.qa-input { flex: 1; border-radius: 22px !important; padding-left: 16px !important; background: var(--surface) !important; }
.qa-submit {
  display: grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  flex: none;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  cursor: pointer;
}
.qa-submit .icon { width: 22px; height: 22px; stroke-width: 2.4; }
.qa-submit:disabled { opacity: .6; }
.qa-help { width: 38px; }
.qa-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 1100px;
  margin: 0 auto 8px;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  padding: 2px 10px;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  font-size: .85rem;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip.warn { background: var(--warn-soft); color: var(--warn); white-space: normal; }
.chip.overdue { background: var(--danger-soft); color: var(--danger); }
.chip-ok { background: var(--ok-soft); color: var(--ok); margin-left: 6px; min-height: 22px; font-size: .78rem; }
.chip-btn { min-height: 36px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.chip-btn:hover { background: var(--surface-2); }
.chip-tag { padding-right: 2px; }
.chip-x {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin: -4px 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.chip-x .icon { width: 16px; height: 16px; }

.qbadge {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: .78rem;
  font-weight: 650;
  background: var(--qs, var(--surface-2));
  color: var(--qc, var(--muted));
}

.q1 { --qc: var(--q1); --qs: var(--q1-soft); }
.q2 { --qc: var(--q2); --qs: var(--q2-soft); }
.q3 { --qc: var(--q3); --qs: var(--q3-soft); }
.q4 { --qc: var(--q4); --qs: var(--q4-soft); }

/* ----------------------------------------------------------------- matrix */

.matrix { display: grid; grid-template-columns: 1fr; gap: 14px; }

.quadrant {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--qc);
  border-radius: var(--radius);
  overflow: hidden;
  transition: background .15s, box-shadow .15s;
}
.quadrant.drop-target { background: var(--qs); box-shadow: 0 0 0 2px var(--qc) inset; }
.quadrant.collapsed > :not(.q-head) { display: none; }

.q-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  padding: 8px 8px 8px 14px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.q-num {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 8px;
  background: var(--qs);
  color: var(--qc);
  font-weight: 750;
  font-size: .9rem;
}
.q-titles { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.q-name { font-weight: 700; font-size: 1.02rem; }
.q-hint { color: var(--muted); font-size: .8rem; }
.q-count { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.q-chevron { color: var(--muted); transition: transform .15s; margin-right: 6px; }
.quadrant.collapsed .q-chevron { transform: rotate(-90deg); }

/* ------------------------------------------------------------------ tasks */

.tasks { list-style: none; margin: 0; padding: 0; }
.tasks.card, .rows.card, .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card.pad { padding: 14px; margin-bottom: 12px; overflow: visible; }
.tasks.card + .group-title, .tasks.card { margin-bottom: 8px; }

.task {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 54px;
  padding-right: 2px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.tasks > .task:first-child { border-top: 0; }
.quadrant .tasks > .task:first-child { border-top: 1px solid var(--border); }
.task.dragging { opacity: .45; }
.task[draggable="true"] { cursor: grab; }
.task.completing .task-title { text-decoration: line-through; color: var(--muted); }
.task.completing .box { background: var(--qc, var(--accent)); border-color: var(--qc, var(--accent)); color: #fff; }

.check {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: none;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
}
.box {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 2px solid var(--qc, var(--muted));
  border-radius: 50%;
  color: transparent;
  transition: background .15s, color .15s;
}
.box .icon { width: 14px; height: 14px; stroke-width: 3; }
.check:hover .box { color: var(--qc, var(--muted)); }
.task.done .box { background: var(--muted); border-color: var(--muted); color: var(--surface); }

.task-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 0;
  color: inherit;
  text-decoration: none;
}
.task-title { overflow-wrap: anywhere; }
.task.done .task-title { text-decoration: line-through; color: var(--muted); }
.task-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 10px;
  color: var(--muted);
  font-size: .82rem;
}
.task-meta > span { display: inline-flex; align-items: center; gap: 4px; }
.task-meta .icon { width: 14px; height: 14px; }
.meta-due.today { color: var(--accent); font-weight: 600; }
.meta-due.overdue, .overdue { color: var(--danger); font-weight: 650; }
.meta-tag { color: var(--accent); }
.more { color: var(--muted); }

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  flex: none;
  border-radius: 50%;
  background: var(--surface-3);
}
.dot.has-color { background: var(--c); }
.dot-lg { width: 14px; height: 14px; }

.empty { padding: 18px 16px; margin: 0; color: var(--muted); font-size: .92rem; text-align: center; }

/* ------------------------------------------------------------------ lists */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 12px;
}
.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 12px;
  background: var(--surface-2);
}
.seg-btn {
  min-height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: .9rem;
  cursor: pointer;
}
.seg-btn[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.list-sub { display: flex; align-items: center; gap: 8px; color: var(--muted); margin-bottom: 10px; }
.group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 4px 8px;
  color: var(--muted);
  font-size: .85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.group-title .q-num { width: 22px; height: 22px; font-size: .78rem; }
.group-title:first-child { margin-top: 4px; }

.search-box { position: sticky; top: calc(53px + var(--sat)); z-index: 5; padding: 2px 0 10px; background: var(--bg); }
.search-input { border-radius: 22px !important; padding-left: 16px !important; }

.rows { list-style: none; margin: 0 0 10px; padding: 0; }
.rows.muted { opacity: .75; }
.row { display: flex; align-items: center; min-height: 52px; padding-right: 4px; border-top: 1px solid var(--border); }
.row:first-child { border-top: 0; }
.row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 8px 8px 8px 14px;
  color: inherit;
  text-decoration: none;
}
.row-main > .icon { color: var(--muted); }
.row-name { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 550; }
.row-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.row-text .row-name { display: flex; flex-wrap: wrap; align-items: center; }
.row-sub { color: var(--muted); font-size: .82rem; }
.count { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }

.block { margin-bottom: 26px; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 2px 10px; }
.block-head h2 { display: flex; align-items: center; gap: 8px; }
.block-head h2 .icon { color: var(--muted); }
.block-body { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.block-body .rows.card { margin: 10px 0; }
.block-body .inline-group { margin-top: 12px; }

.swatches { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; padding: 0; border: 0; }
.swatches legend { font-size: .9rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; padding: 0; }
.swatch-label { position: relative; display: grid; place-items: center; width: var(--tap); height: var(--tap); cursor: pointer; }
.swatch-label input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--c, var(--surface-3));
  box-shadow: 0 0 0 1px var(--border);
}
.swatch-none { background: linear-gradient(135deg, transparent 45%, var(--danger) 45%, var(--danger) 55%, transparent 55%), var(--surface); }
.swatch-label input:checked + .swatch { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.swatch-label input:focus-visible + .swatch { outline: 2px solid var(--accent); outline-offset: 4px; }

/* ------------------------------------------------------------ task detail */

.task-detail { max-width: 720px; margin: 0 auto; }
.parent-link { display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap); margin-bottom: 4px; text-decoration: none; font-size: .92rem; }
.task-head { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.title-input {
  min-height: 52px !important;
  padding: 8px 10px !important;
  border-color: transparent !important;
  background: transparent !important;
  font-size: 1.3rem !important;
  font-weight: 700;
  resize: none !important;
  field-sizing: content;
}
.title-input:focus { background: var(--surface) !important; }
.task-head-actions { display: flex; align-items: center; gap: 12px; }
.save-status { color: var(--muted); font-size: .85rem; }
.done-info { color: var(--ok); font-weight: 600; margin: -4px 0 12px; }
.label { display: flex; align-items: center; gap: 6px; margin: 0 0 8px; color: var(--muted); font-size: .85rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.label .icon { width: 16px; height: 16px; }
.card.pad .field > label { text-transform: uppercase; font-size: .85rem; letter-spacing: .03em; font-weight: 700; }
.card.pad > .field:last-child { margin-bottom: 0; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.row-between .label { margin: 0; }
.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}
.toggle[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.toggle[aria-pressed="true"] .icon { fill: currentColor; }
.notes-input { min-height: 120px; }
.tag-input { margin-top: 2px; }
.subtasks .tasks { margin: -6px -14px 8px; }
.subtasks .task:first-child { border-top: 0; }
.sub-add { display: flex; gap: 6px; align-items: center; }
.task-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.task-dates { margin: 0; }

/* ------------------------------------------------------------------- auth */

body.mode-auth .sidebar,
body.mode-auth .tabbar,
body.mode-auth .quickadd,
body.mode-auth .topbar { display: none !important; }
body.mode-auth .content { margin-left: 0 !important; }
body.mode-auth .view { max-width: none; padding: 0; }

.auth-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(24px + var(--sat)) var(--gutter-r) calc(24px + var(--sab)) var(--gutter-l);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 24px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.auth-card h2 { margin-bottom: 12px; font-size: 1.25rem; }
.auth-card > p { color: var(--text); }
.auth-logo { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 20px; }
.auth-logo h1 { font-size: 1.5rem; }
.auth-logo img { border-radius: 14px; }
.otp-flow { margin-top: 8px; }
.otp-input { font-size: 1.5rem !important; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- dialogs */

dialog.dlg {
  width: min(520px, calc(100vw - 32px));
  max-width: 100vw;
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 10px 40px rgb(0 0 0 / 30%);
  overflow: auto;
  overscroll-behavior: contain;
}
dialog.dlg::backdrop { background: rgb(0 0 0 / 45%); }
.dlg-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 6px 6px 18px;
  background: var(--surface);
}
.dlg-title { flex: 1; min-width: 0; font-size: 1.1rem; overflow-wrap: anywhere; }
.dlg-body { padding: 4px 18px 18px; }
.dlg-text { margin: 0 0 14px; }
.dlg-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.dlg-actions .btn-danger-text { margin-right: auto; }

@media (max-width: 899px) {
  dialog.dlg {
    width: 100%;
    max-width: 100%;
    margin: auto 0 0;
    border-radius: 18px 18px 0 0;
    padding-bottom: var(--sab);
    max-height: calc(100dvh - var(--sat) - 24px);
  }
}

.sheet-actions { display: flex; flex-direction: column; margin: 0 -8px; }
.sheet-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 50px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 1rem;
  text-align: left;
  cursor: pointer;
}
.sheet-btn:hover { background: var(--surface-2); }
.sheet-btn span { flex: 1; }
.sheet-btn.q1, .sheet-btn.q2, .sheet-btn.q3, .sheet-btn.q4 { color: var(--qc); font-weight: 600; }
.sheet-btn.current { opacity: 1; background: var(--qs); cursor: default; }
.sheet-btn.danger { color: var(--danger); }
.sheet-btn .icon { color: inherit; }

.syntax { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 12px; }
.syntax dt { margin: 0; }
.syntax dd { margin: 0; color: var(--muted); }
.syntax code { padding: 1px 6px; border-radius: 6px; background: var(--surface-2); white-space: nowrap; }

/* ----------------------------------------------------------------- toasts */

.toasts {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--tabbar-h) + var(--qa-h) + var(--sab) + 8px);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 var(--gutter-r) 0 var(--gutter-l);
  pointer-events: none;
}
body.mode-auth .toasts { bottom: calc(16px + var(--sab)); }
.toast {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  max-width: 480px;
  min-height: 48px;
  padding: 4px 4px 4px 16px;
  border-radius: 14px;
  background: #24242a;
  color: #f2f2f5;
  box-shadow: 0 6px 24px rgb(0 0 0 / 25%);
  pointer-events: auto;
  animation: toast-in .18s ease-out;
}
.toast-text { flex: 1; min-width: 0; font-size: .94rem; overflow-wrap: anywhere; }
.toast-error { background: #8f2424; }
.toast-warn { background: #6b4a0a; }
.toast-action {
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #9fc0ff;
  font-weight: 700;
  cursor: pointer;
}
.toast-close {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #c6c6cc;
  cursor: pointer;
}
.toast-out { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.offline-banner {
  position: fixed;
  top: var(--sat);
  left: 50%;
  z-index: 90;
  transform: translateX(-50%);
  max-width: calc(100vw - 24px);
  margin-top: 6px;
  padding: 6px 14px;
  border-radius: 16px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: .82rem;
  font-weight: 600;
  text-align: center;
  box-shadow: var(--shadow);
  pointer-events: none;
}
body.is-offline .qa-submit { opacity: .5; }

/* ---------------------------------------------------------------- desktop */

@media (min-width: 900px) {
  .tabbar { display: none; }
  .content { margin-left: var(--side-w); }
  .view { padding-bottom: calc(var(--qa-h) + var(--sab) + 40px); padding-top: 20px; }
  .topbar { padding-left: 24px; padding-right: 24px; }
  .back-btn { margin-left: -12px; }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 25;
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: var(--side-w);
    padding: calc(14px + var(--sat)) 12px 14px max(12px, var(--sal));
    overflow-y: auto;
    background: var(--surface);
    border-right: 1px solid var(--border);
  }
  .side-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px 14px;
    color: var(--text);
    font-weight: 750;
    font-size: 1.15rem;
    text-decoration: none;
  }
  .side-brand img { border-radius: 7px; }
  .side-link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    padding: 0 10px;
    border-radius: 9px;
    color: var(--text);
    text-decoration: none;
    font-size: .95rem;
  }
  .side-link:hover { background: var(--surface-2); }
  .side-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
  .side-link .icon { color: var(--muted); width: 18px; height: 18px; }
  .side-link[aria-current="page"] .icon { color: var(--accent); }
  .side-link .dot { margin: 0 4px; }
  .side-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .side-head { margin: 16px 10px 4px; color: var(--muted); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
  .side-lists { display: flex; flex-direction: column; gap: 2px; }
  .side-bottom { margin-top: auto; padding-top: 14px; display: flex; flex-direction: column; gap: 2px; }

  .quickadd { left: var(--side-w); bottom: 0; padding: 10px 24px calc(10px + var(--sab)); }
  body.qa-focus .quickadd { bottom: 0; }
  .toasts { bottom: calc(var(--qa-h) + var(--sab) + 12px); left: var(--side-w); }

  .matrix { grid-template-columns: 1fr 1fr; gap: 16px; }
  .quadrant { min-height: 220px; }
  .search-box { top: 53px; }
  .toggles { max-width: 420px; }
}

@media (hover: none) {
  /* No sticky hover states after a tap on touch screens. */
  .btn:hover, .chip-btn:hover { background: var(--surface); }
  .btn-primary:hover { background: var(--accent); filter: none; }
  .btn-danger:hover { background: var(--danger); filter: none; }
  .btn-danger-text:hover, .btn-link:hover, .sheet-btn:hover { background: transparent; }
  .sheet-btn.current:hover { background: var(--qs); }
  .icon-btn:hover { background: transparent; color: var(--muted); }
  .back-btn:hover { color: var(--accent); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
