/* 家庭待办 (spec §38): the list page (td-), its sheets, and 我的待办 on the child's iPad home (tdk-).
   §12: side-by-side tiles, options and buttons share one class and equal grid cells (minmax(0, 1fr),
   equal rows); long words are cut, never stretch a cell. Colours are the design tokens; the category
   colours below are made of them, one value for light and one for dark. */

/* ---------- Tokens (light / dark) ---------- */
:root {
  --td-shopping: var(--coral);
  --td-chores: var(--leaf);
  --td-bills: var(--pineapple-deep);
  --td-travel: var(--sky);
  --td-study: var(--mangosteen);
  --td-other: color-mix(in srgb, var(--text) 52%, var(--surface));
  --td-tile-ink: var(--text-on-brand);
  --td-alert-glass: color-mix(in srgb, var(--coral) 34%, transparent);
  --td-max: 760px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --td-chores: var(--positive);
    --td-bills: var(--pineapple);
    --td-study: var(--accent);
    --td-other: color-mix(in srgb, var(--text) 62%, var(--surface));
    --td-tile-ink: var(--bg);
  }
}
.td-cat--shopping { --td-cat: var(--td-shopping); }
.td-cat--chores { --td-cat: var(--td-chores); }
.td-cat--bills { --td-cat: var(--td-bills); }
.td-cat--travel { --td-cat: var(--td-travel); }
.td-cat--study { --td-cat: var(--td-study); }
.td-cat--other { --td-cat: var(--td-other); }

/* The category tile: its icon on its colour. Sizes: 36 (lists), sm 32 (pickers), xs 18 (in a line). */
.td-tile {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 36px; height: 36px;
  border-radius: 12px;
  background: var(--td-cat);
  color: var(--td-tile-ink);
}
.td-tile svg { width: 60%; height: 60%; stroke-width: 2.1; }
.td-tile--sm { width: 32px; height: 32px; border-radius: 10px; }
.td-tile--xs { width: 18px; height: 18px; border-radius: 6px; }
.td-tile--xs svg { width: 13px; height: 13px; stroke-width: 2.4; }

/* ---------- Page: one content width on big screens, the header's words start where the cards start ---------- */
.page--todo .page-body { width: 100%; max-width: calc(var(--td-max) + 2 * var(--gutter)); margin-left: auto; margin-right: auto; }
.page--todo .hero {
  padding-left: max(var(--gutter), var(--safe-left), calc((100% - var(--td-max)) / 2));
  padding-right: max(var(--gutter), var(--safe-right), calc((100% - var(--td-max)) / 2));
}

/* Header: three equal glass tiles. */
.td-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  gap: var(--gap);
  margin-top: 14px;
}
.td-stat {
  display: grid;
  grid-template-rows: auto auto auto;
  justify-items: center;
  align-content: center;
  gap: 2px;
  height: 100%;
  min-height: 96px;
  min-width: 0;
  padding: 10px 6px;
  border-radius: var(--r-m);
  background: var(--hero-glass);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  text-align: center;
  transition: background-color var(--dur-2);
}
.td-stat-art { display: grid; place-items: center; width: 26px; height: 26px; color: var(--pineapple); }
.td-stat-art svg { width: 22px; height: 22px; }
.td-stat-value { font-family: var(--font-rounded); font-size: 28px; font-weight: 800; line-height: 1.1; color: var(--hero-text); }
.td-stat-label { max-width: 100%; font-size: 13px; color: var(--hero-text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.td-stat.is-alert { background: var(--td-alert-glass); }
.page--todo-kid .td-stat { min-height: 112px; }
.page--todo-kid .td-stat-value { font-size: 36px; }
.page--todo-kid .td-stat-label { font-size: 15px; }

/* Quick add (parents): one line, 加上, ⚙. */
.td-add { padding: 10px; }
.td-quick { display: grid; grid-template-columns: minmax(0, 1fr) 48px 48px; align-items: center; gap: 8px; }
.td-quick-input { min-width: 0; }
.td-quick-btn { width: 48px; height: 48px; border-radius: 16px; background: var(--surface-3); color: var(--text-2); }
.td-quick-btn--add { background: var(--accent); color: var(--surface); }
.td-quick-btn svg { width: 24px; height: 24px; }
.td-quick-btn--add svg { stroke-width: 2.4; }
.td-quick-btn { position: relative; }
.td-quick-btn.is-busy svg { opacity: 0.35; }
.td-quick-btn.is-busy .spinner, .td-check.is-busy .spinner { position: absolute; left: 50%; top: 50%; margin: -10px 0 0 -10px; }
/* A child: one big button and what is left for today. */
.td-add--kid { display: grid; gap: 8px; padding: var(--card-pad); }
.td-add-left { min-height: 1.45em; font-size: 15px; color: var(--text-2); text-align: center; }

/* Filter and 「只看我的」 */
.td-filter { margin-top: var(--gap); }
.td-filter .seg-item { padding: 0 2px; font-size: 14px; }
@media (min-width: 420px) { .td-filter .seg-item { font-size: 15px; } }
.td-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; margin: 6px 4px 0; }
.td-count { min-width: 0; font-size: 14px; font-weight: 600; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.td-mine { display: inline-flex; align-items: center; gap: 10px; flex-shrink: 0; min-height: 44px; font-size: 15px; font-weight: 600; color: var(--text-2); }
.td-mine-words { display: inline-flex; align-items: center; min-height: 44px; cursor: pointer; user-select: none; -webkit-user-select: none; }

/* ---------- Sections and rows ---------- */
.td-section-label { margin: 18px 4px 10px; }
.td-section:first-child .td-section-label { margin-top: 4px; }
.td-section[data-key="overdue"] .td-section-label { color: var(--danger); }
.td-section[data-key="pending"] .td-section-label { color: var(--warning-text); }
.td-section-count {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 22px;
  padding: 0 7px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 700;
}
.td-list { display: grid; gap: 10px; }

.td-item {
  border-radius: var(--r-l);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  transition: background-color var(--dur-2), box-shadow var(--dur-2);
}
.td-item.is-pending { box-shadow: 0 0 0 2px color-mix(in srgb, var(--pineapple) 70%, transparent), var(--shadow-1); }
.td-item.is-done { background: color-mix(in srgb, var(--surface-2) 70%, var(--surface)); box-shadow: none; }
.td-item.is-fresh { animation: td-fresh 1200ms var(--ease-out); }
@keyframes td-fresh { from { box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-1); } }
.td-item-main {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: start;
  column-gap: 6px;
  padding: 8px 4px 8px 8px;
}
.td-item.no-side .td-item-main { grid-template-columns: 44px minmax(0, 1fr); padding-right: var(--card-pad); }

/* The check: a circle; done = green tick, waiting for a parent = hourglass. Dashed: not yours to tick. */
.td-check { position: relative; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: none; color: inherit; }
.td-check:disabled { cursor: default; }
.td-check-box {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
  color: transparent;
  transition: background-color var(--dur-2), border-color var(--dur-2), color var(--dur-2), transform var(--dur-1) var(--ease-out);
}
.td-check-box svg { width: 18px; height: 18px; stroke-width: 3; }
.td-check:not(:disabled):active .td-check-box { transform: scale(0.88); }
.td-check:not(:disabled):hover .td-check-box { border-color: var(--accent); }
.td-item.is-overdue .td-check-box { border-color: color-mix(in srgb, var(--danger) 55%, transparent); }
.td-item.is-open .td-check:disabled .td-check-box { border-style: dashed; opacity: 0.55; }
.td-item.is-pending .td-check-box { border-color: transparent; background: var(--warning-soft); color: var(--warning-text); }
.td-item.is-pending .td-check-box svg { stroke-width: 2.2; }
.td-item.is-done .td-check-box { border-color: transparent; background: var(--positive); color: var(--surface); }
.td-item.is-done .td-check:disabled .td-check-box { opacity: 0.6; }
.td-check.is-busy .td-check-box { opacity: 0.4; }

.td-item-body {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px 0 4px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
}
button.td-item-body { cursor: pointer; transition: opacity var(--dur-1); }
button.td-item-body:active { opacity: 0.6; }
.td-item-title {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.35;
}
.td-item.is-done .td-item-title { color: var(--text-2); text-decoration: line-through; text-decoration-thickness: 1.5px; text-decoration-color: color-mix(in srgb, var(--text-3) 80%, transparent); }
.td-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; min-width: 0; font-size: 13px; color: var(--text-3); }
.td-meta-item { display: inline-flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%; height: 22px; white-space: nowrap; }
.td-meta-item > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.td-meta-item > svg { width: 15px; height: 15px; }
.td-meta-cat { color: var(--text-2); font-weight: 600; }
.td-meta-due.is-today { color: var(--warning-text); font-weight: 700; }
.td-meta-due.is-overdue { color: var(--danger); font-weight: 700; }
.td-meta-kid, .td-meta-idea { padding: 0 8px; border-radius: var(--r-pill); font-weight: 700; }
.td-meta-kid { background: var(--pineapple-soft); color: var(--warning-text); }
.td-meta-idea { background: var(--warning-soft); color: var(--warning-text); }
.td-meta-idea > svg { width: 14px; height: 14px; }
.td-meta-coin { color: var(--warning-text); font-weight: 700; }
.td-meta-coin.is-paid { color: var(--positive); }
.td-item-note, .td-item-reason {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.45;
}
.td-item-note { color: var(--text-2); }
.td-item-reason { font-weight: 700; color: var(--danger); }
.td-item-done { font-size: 13px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.td-side-btn { width: 44px; height: 44px; color: var(--text-3); }
.td-side-btn svg { width: 20px; height: 20px; }
.td-speak { color: var(--accent); }
.td-speak svg { width: 24px; height: 24px; }
.td-item-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 0 var(--card-pad) var(--card-pad); }
.td-act { width: 100%; min-width: 0; padding: 0 12px; }
.td-act--wide { grid-column: 1 / -1; }
.td-act span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.td-item--skeleton .td-check-box { border-color: var(--surface-3); }
.td-skel { display: block; height: 16px; border-radius: 7px; }
.td-skel--title { width: 70%; margin-top: 2px; }
.td-skel--meta { width: 45%; height: 12px; margin: 5px 0 6px; }

/* 已完成: folded under the list. */
.td-done { margin-top: 20px; }
.td-done-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--r-m);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 15px;
  font-weight: 700;
  transition: transform var(--dur-1) var(--ease-out);
}
.td-done-toggle:active { transform: scale(0.98); }
.td-done-toggle svg { width: 20px; height: 20px; }
.td-done-icon { color: var(--positive); }
.td-done-chevron { margin-left: auto; }
.td-list--done { margin-top: 10px; }
.td-done-note { margin: 12px 4px 0; font-size: 13px; color: var(--text-3); text-align: center; }

.td-empty { margin-top: 4px; }
.td-empty-icon { color: var(--accent); background: var(--accent-soft); }

/* A child's list on the iPad: bigger words, checks and buttons (spec §24.3: kindergarten to first grade). */
.page--todo-kid .td-item-main { grid-template-columns: 52px minmax(0, 1fr) 52px; padding: 10px 6px 10px 10px; }
.page--todo-kid .td-item.no-side .td-item-main { grid-template-columns: 52px minmax(0, 1fr); }
.page--todo-kid .td-check, .page--todo-kid .td-side-btn { width: 52px; height: 52px; }
.page--todo-kid .td-check-box { width: 36px; height: 36px; }
.page--todo-kid .td-check-box svg { width: 22px; height: 22px; }
.page--todo-kid .td-side-btn svg { width: 26px; height: 26px; }
.page--todo-kid .td-item-title { font-size: 20px; }
.page--todo-kid .td-meta, .page--todo-kid .td-item-note, .page--todo-kid .td-item-reason { font-size: 15px; }
.page--todo-kid .td-meta-item { height: 26px; }
.page--todo-kid .td-filter .seg-item { min-height: 52px; font-size: 17px; }
.page--todo-kid .td-count, .page--todo-kid .td-mine, .page--todo-kid .td-section-label, .page--todo-kid .td-done-toggle { font-size: 17px; }

/* ---------- Sheets ---------- */
.td-form { display: grid; gap: 16px; }
.td-form .field + .field { margin-top: 0; }
.td-form .form-error { margin-top: -4px; }
.td-field-row { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.td-cat-grid, .td-who-grid, .td-due-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 8px; }
.td-reason-grid { display: grid; grid-template-columns: minmax(0, 1fr); grid-auto-rows: 1fr; gap: 8px; }
@media (min-width: 420px) { .td-reason-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.td-option {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  min-height: 48px;
  padding: 6px;
  border: 1.5px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 15px;
  font-weight: 600;
  transition: transform var(--dur-1) var(--ease-out), background-color var(--dur-2), border-color var(--dur-2), color var(--dur-2);
}
.td-option:active { transform: scale(0.96); }
.td-option[aria-checked="true"], .td-option[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.td-option-label { min-width: 0; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.td-cat-grid .td-option { flex-direction: column; gap: 4px; min-height: 76px; }
.td-cat-grid--large .td-option { min-height: 108px; gap: 8px; border-radius: 20px; font-size: 20px; font-weight: 800; }
.td-cat-grid--large .td-tile { width: 52px; height: 52px; border-radius: 16px; }
.td-due-grid { margin-bottom: 8px; }
.td-due-inputs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.td-due-inputs .input { min-width: 0; }
.td-time:disabled { opacity: 0.45; }
.td-note-input { min-height: 76px; padding: 12px 16px; line-height: 1.45; resize: none; }
.td-batch-text { min-height: 180px; padding: 12px 16px; line-height: 1.5; resize: none; }
.td-batch-count { padding: 0 4px; font-size: 13px; color: var(--text-3); }
.td-batch-count.is-over { color: var(--danger); font-weight: 600; }
.td-kid-input { min-height: 64px; font-size: 22px; font-weight: 700; }
.td-form--kid .field-label { font-size: 17px; }
.td-kid-left { font-size: 16px; color: var(--text-2); text-align: center; }
.td-sheet--kid .sheet-foot .btn-cta { min-height: 64px; font-size: 22px; }
.td-ask { display: grid; gap: 12px; }
.td-ask-title { font-size: 20px; font-weight: 800; line-height: 1.3; overflow-wrap: anywhere; }
.td-ask-lead { font-size: 15px; line-height: 1.5; color: var(--text-2); }
.td-idea-count { display: grid; justify-items: center; padding: 8px 0 4px; }

/* ======================= 我的待办 on the child's iPad (views/todo-panel.js) =======================
   The homework panel's look (homework.css .hwk): radius, padding, shadow, head row; titles ≥ 22px,
   buttons ≥ 64px. Sized by its own width (container queries). */
.tdk {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  padding: var(--kid-pad, 18px);
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow-2);
}
.tdk-head { display: grid; grid-template-columns: var(--kid-icon, 52px) minmax(0, 1fr) auto; align-items: center; gap: 14px; }
/* Its colour is app.css .badge-icon--mangosteen (the tool's tile): the header's --hero-* tokens are near
   the panel's own colour in dark mode. */
.tdk-head-icon {
  display: grid;
  place-items: center;
  width: var(--kid-icon, 52px); height: var(--kid-icon, 52px);
  border-radius: 16px;
  color: var(--hero-text);
}
.tdk-head-icon svg { width: 60%; height: 60%; }
.tdk-add { min-height: 56px; padding: 0 18px; border-radius: 18px; font-size: 18px; font-weight: 800; }
.tdk-add svg { width: 24px; height: 24px; stroke-width: 2.4; }
.tdk[data-tone="done"] .tdk-head-sub { color: var(--positive); }
.tdk[data-tone="wait"] .tdk-head-sub { color: var(--warning-text); }
.tdk-list { display: grid; gap: 12px; }

.tdk-item {
  --tdk-tile: 56px;
  --hwk-speak: 52px;
  --sub-ink: var(--td-cat);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  border: 2px solid transparent;
  border-radius: var(--r-l);
  background: color-mix(in srgb, var(--td-cat) 12%, var(--surface-2));
  transition: background-color var(--dur-2), border-color var(--dur-2);
}
@media (prefers-color-scheme: dark) { .tdk-item { background: color-mix(in srgb, var(--td-cat) 10%, var(--surface-2)); } }
@container (max-width: 400px) { .tdk-item { --tdk-tile: 46px; --hwk-speak: 44px; gap: 12px; padding: 12px; } }
@container (min-width: 480px) { .tdk-item { --tdk-tile: 64px; --hwk-speak: 56px; padding: 18px; } }
.tdk-main {
  display: grid;
  grid-template-columns: var(--tdk-tile) minmax(0, 1fr) var(--hwk-speak);
  grid-template-areas: "tile top top" "tile text speak";
  align-items: center;
  column-gap: 14px;
  row-gap: 2px;
}
.tdk-tile {
  grid-area: tile;
  align-self: start;
  display: grid;
  place-items: center;
  width: var(--tdk-tile); height: var(--tdk-tile);
  border-radius: 18px;
  background: var(--td-cat);
  color: var(--td-tile-ink);
}
.tdk-tile svg { width: 58%; height: 58%; stroke-width: 2.2; }
.tdk-top { grid-area: top; display: flex; align-items: center; gap: 8px; min-width: 0; height: 32px; }
.tdk-cat { flex-shrink: 0; font-size: 17px; font-weight: 800; color: var(--text-2); }
.tdk-due {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text-2);
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
}
.tdk-due svg { width: 16px; height: 16px; flex-shrink: 0; }
.tdk-due > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tdk-due.is-today { background: var(--warning-soft); color: var(--warning-text); }
.tdk-due.is-overdue { background: var(--danger-soft); color: var(--danger); }
.tdk-badge-slot { display: flex; flex-shrink: 0; margin-left: auto; }
.tdk-badge-slot:empty { display: none; }
.tdk-badge { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 12px; border-radius: var(--r-pill); font-size: 15px; font-weight: 800; white-space: nowrap; }
.tdk-badge svg { flex-shrink: 0; width: 18px; height: 18px; stroke-width: 2.4; }
.tdk-badge[data-tone="done"] { background: var(--positive-soft); color: var(--positive); }
.tdk-badge[data-tone="wait"] { background: var(--warning-soft); color: var(--warning-text); }
.tdk-badge[data-tone="coin"] { background: var(--pineapple-soft); color: var(--warning-text); }
/* Narrow: the reward's words would push the badge off; the coin and 「+3」 say it. */
.tdk-badge-short { display: none; }
@container (max-width: 400px) { .tdk-badge-long { display: none; } .tdk-badge-short { display: inline; } }
.tdk-text { grid-area: text; display: grid; gap: 2px; min-width: 0; }
.tdk-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.3;
}
@container (min-width: 480px) { .tdk-title { font-size: 24px; } }
.tdk-note {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  font-size: 16px;
  line-height: 1.45;
  color: var(--text-2);
}
.tdk-speak { grid-area: speak; }
span.tdk-speak { width: var(--hwk-speak); height: var(--hwk-speak); }
.tdk-reason {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 18px;
  background: var(--danger-soft);
  color: var(--danger);
}
.tdk-reason-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--surface); }
.tdk-reason-icon svg { width: 22px; height: 22px; stroke-width: 2.2; }
.tdk-reason-body { display: grid; gap: 1px; min-width: 0; }
.tdk-reason-body strong { font-size: 15px; font-weight: 800; }
.tdk-reason-body span { overflow-wrap: anywhere; font-size: 20px; font-weight: 800; line-height: 1.35; color: var(--text); }
.tdk-main-btn { width: 100%; min-width: 0; min-height: 64px; padding: 0 16px; border-radius: 20px; font-size: 22px; }
.tdk-main-btn svg { width: 28px; height: 28px; stroke-width: 2.6; }
.tdk-main-btn span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tdk-undo { align-self: center; margin: -8px 0 -6px; color: var(--text-3); font-size: 16px; }
.tdk-item.is-pending { border-color: color-mix(in srgb, var(--pineapple) 60%, transparent); }
.tdk-item.is-done { background: var(--surface-2); }
.tdk-item.is-done .tdk-tile, .tdk-item.is-done .tdk-cat, .tdk-item.is-done .tdk-title, .tdk-item.is-done .tdk-note, .tdk-item.is-done .tdk-speak { opacity: 0.5; }

/* The child's own proposals: one line each, what the parents made of it on the right. */
.tdk-ideas { display: grid; gap: 8px; }
.tdk-ideas-title { margin: 2px 2px 0; font-size: 18px; font-weight: 800; color: var(--text-2); }
.tdk-idea { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 56px; padding: 8px 12px; border-radius: 16px; background: var(--surface-2); }
.tdk-idea-title { min-width: 0; font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tdk-idea-status { display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 10px; border-radius: var(--r-pill); background: var(--surface); color: var(--text-2); font-size: 15px; font-weight: 800; white-space: nowrap; }
.tdk-idea-status svg { width: 18px; height: 18px; }
.tdk-idea[data-tone="idea"] .tdk-idea-status { background: var(--pineapple-soft); color: var(--warning-text); }
.tdk-idea[data-tone="done"] .tdk-idea-status { background: var(--positive-soft); color: var(--positive); }

.tdk-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 56px;
  border-radius: 18px;
  background: var(--surface-3);
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
  text-decoration: none;
  transition: transform var(--dur-1) var(--ease-out);
}
.tdk-more:active { transform: scale(0.98); }
.tdk-more svg { width: 20px; height: 20px; }
.tdk-empty-icon { color: var(--accent); }
.tdk-empty-icon svg { width: 52px; height: 52px; }

.tdk-item--skeleton { background: var(--surface-2); }
.tdk-item--skeleton .tdk-tile { background: var(--surface-3); }
.tdk-skel { display: block; height: 22px; border-radius: 8px; }
.tdk-skel--short { width: 30%; height: 16px; }
.tdk-skel--title { width: 72%; height: 24px; }

@media (prefers-reduced-motion: reduce) {
  .td-item.is-fresh { animation: none; }
}

/* ======================= 用语音加待办 (spec §42, todo/voice.js) =======================
   Talk buttons on the pages (the parents' 「按住说话」 bar, the child's 「说一说」 next to 「加一件」, the mic beside
   the child's add field; a child's are ≥ 64px) and the sheet that listens (tdv-). Side-by-side buttons share one
   class and equal columns (§12). */
/* A finger may rest on these: no scrolling, no selection, no iOS callout or magnifier. */
.tdv-talk { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.tdv-talk-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* Parents: one bar under the quick add (the field keeps its width). */
.tdv-talkbar { min-height: 48px; margin-top: 8px; border-radius: 16px; font-size: 16px; font-weight: 700; }
.tdv-talkbar svg { width: 22px; height: 22px; }

/* A child's add card on /todo: 说一说 | 加一件事, equal. */
.td-kid-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.td-kid-actions .btn { width: 100%; min-width: 0; min-height: 64px; padding: 0 12px; border-radius: 20px; font-size: 20px; font-weight: 800; }
.td-kid-actions .btn svg { width: 28px; height: 28px; stroke-width: 2.4; }
.td-kid-actions .btn span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* 我的待办 head: 说一说 | 加一件 (equal, 64px); under the title when the panel is narrow. */
.tdk-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tdk-actions .tdk-add { width: 100%; min-width: 0; min-height: 64px; padding: 0 16px; border-radius: 20px; font-size: 20px; }
.tdk-actions .tdk-add svg { width: 26px; height: 26px; }
.tdk-actions .tdk-add span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
@container (min-width: 561px) { .tdk-actions { width: 300px; } }
@container (max-width: 560px) {
  .tdk-head { grid-template-columns: var(--kid-icon, 52px) minmax(0, 1fr); }
  .tdk-actions { grid-column: 1 / -1; }
}

/* The child's add sheet: the field and a 64px mic of the same height. */
.td-kid-write { display: grid; grid-template-columns: minmax(0, 1fr) 64px; align-items: stretch; gap: 10px; }
.td-kid-talk { width: 64px; min-height: 64px; padding: 0; border-radius: 20px; }
.td-kid-talk svg { width: 30px; height: 30px; stroke-width: 2.3; }

/* ---------- The sheet ---------- */
.tdv { display: grid; gap: 14px; }
/* Room above the orb for its ring at full voice (the sheet's body scrolls and would cut it). */
.tdv-stage { display: grid; justify-items: center; gap: 10px; padding: 26px 0 4px; text-align: center; }
.tdv-orb {
  --level: 0;
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  width: 104px; height: 104px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  transition: background-color var(--dur-2), color var(--dur-2), transform var(--dur-1) var(--ease-out);
}
.tdv--kid .tdv-orb { width: 128px; height: 128px; }
.tdv-orb.is-live { background: var(--accent); color: var(--surface); }
.tdv-orb.is-live:active { transform: scale(0.95); }
.tdv-orb:disabled { cursor: default; }
.tdv-orb-icon { display: grid; place-items: center; }
.tdv-orb-icon svg { width: 44px; height: 44px; stroke-width: 2.1; }
.tdv--kid .tdv-orb-icon svg { width: 54px; height: 54px; }
.tdv-orb-icon .spinner { width: 34px; height: 34px; border-width: 3.5px; }
/* The ring grows with the voice. */
.tdv-orb-ring {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  opacity: 0;
  transform: scale(calc(1 + var(--level) * 0.3));
  transition: transform 90ms linear, opacity var(--dur-2);
}
.tdv-orb.is-live .tdv-orb-ring { opacity: 1; }

.tdv-meter { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); align-items: center; gap: 4px; width: min(100%, 320px); height: 58px; }
.tdv-bar { --v: 0; --i: 0; display: block; height: calc(6px + var(--v) * 52px); border-radius: 3px; background: var(--accent); opacity: calc(0.35 + var(--v) * 0.65); transition: height 70ms linear; }
/* No level yet (iOS starts the meter after the first tap ends): a calm wave says it is listening. */
.tdv-meter.is-calm .tdv-bar { animation: tdv-wave 1.4s ease-in-out infinite; animation-delay: calc(var(--i) * -70ms); }
@keyframes tdv-wave { 0%, 100% { height: 8px; opacity: 0.35; } 50% { height: 26px; opacity: 0.75; } }
.tdv-status { font-size: 20px; font-weight: 800; line-height: 1.35; }
.tdv--kid .tdv-status { font-size: 26px; }
.tdv-time { font-family: var(--font-rounded); font-size: 15px; font-weight: 700; color: var(--text-2); }
.tdv-hint { min-height: 1.45em; font-size: 15px; line-height: 1.45; color: var(--text-2); }
.tdv--kid .tdv-hint { font-size: 18px; }

.tdv-content { display: grid; gap: 12px; }
.tdv-said { padding: 10px 14px; border-radius: 14px; background: var(--surface-3); color: var(--text-2); font-size: 15px; line-height: 1.5; overflow-wrap: anywhere; }
.tdv-count { padding: 0 4px; font-size: 15px; font-weight: 700; color: var(--text-2); }
.tdv-note-line { padding: 0 4px; font-size: 14px; color: var(--warning-text); }
.tdv-empty { padding: 12px; color: var(--text-2); text-align: center; }

/* A child: 「我听到了：」 in big letters. */
.tdv-heard-lead { font-size: 20px; font-weight: 800; color: var(--text-2); }
.tdv-heard { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.tdv-heard-item {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  min-height: 76px;
  padding: 12px 14px;
  border-radius: var(--r-l);
  background: color-mix(in srgb, var(--td-cat) 12%, var(--surface-2));
}
.tdv-heard-item .td-tile { width: 52px; height: 52px; border-radius: 16px; }
.tdv-heard-text { display: grid; gap: 4px; min-width: 0; }
.tdv-heard-text strong { font-size: 26px; font-weight: 800; line-height: 1.25; overflow-wrap: anywhere; }
.tdv-heard-due { display: inline-flex; align-items: center; gap: 4px; font-size: 17px; font-weight: 700; color: var(--text-2); }
.tdv-heard-due svg { width: 18px; height: 18px; }
.tdv-listen { justify-self: center; min-height: 56px; padding: 0 22px; border-radius: 18px; font-size: 18px; }

/* A parent: each draft can be changed or dropped. */
.tdv-edits { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.tdv-edit { display: grid; gap: 8px; padding: 12px; border-radius: var(--r-m); background: var(--surface); box-shadow: var(--shadow-1); }
.tdv-edit-top { display: grid; grid-template-columns: 32px minmax(0, 1fr) 44px; align-items: center; gap: 8px; }
.tdv-edit-tile { display: grid; place-items: center; }
.tdv-edit-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 8px; }
.tdv-edit .input { min-width: 0; min-height: 48px; font-size: 16px; }
.tdv-edit-title { font-weight: 700; }
.tdv-select-wrap { position: relative; display: grid; min-width: 0; }
.tdv-select { width: 100%; padding-right: 36px; text-overflow: ellipsis; }
.tdv-select-chevron { position: absolute; top: 50%; right: 12px; width: 18px; height: 18px; margin-top: -9px; color: var(--text-3); pointer-events: none; }
.tdv-time:disabled { opacity: 0.45; }
.tdv-drop { color: var(--text-3); }
.tdv-drop svg { width: 20px; height: 20px; }

/* The microphone or the server said no. */
.tdv-help { display: grid; justify-items: center; gap: 8px; padding: 12px 4px; text-align: center; }
.tdv-help-icon { display: grid; place-items: center; width: 72px; height: 72px; border-radius: 50%; background: var(--warning-soft); color: var(--warning-text); }
.tdv-help-icon svg { width: 36px; height: 36px; }
.tdv-help-title { font-size: 20px; font-weight: 800; line-height: 1.35; }
.tdv--kid .tdv-help-title { font-size: 24px; }
.tdv-help-line { max-width: 34em; font-size: 15px; line-height: 1.55; color: var(--text-2); }
.tdv--kid .tdv-help-line { font-size: 18px; }

/* Footer: the shown buttons share the width equally. */
.tdv-foot { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 10px; }
.tdv-foot-btn { width: 100%; min-width: 0; padding: 0 12px; }
.tdv-foot-btn > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tdv-action-icon { display: inline-grid; place-items: center; }
.tdv-action-icon:empty { display: none; }
.tdv-sheet--kid .tdv-foot-btn { min-height: 64px; border-radius: 20px; font-size: 22px; font-weight: 800; }
.tdv-sheet--kid .tdv-foot-btn svg { width: 28px; height: 28px; stroke-width: 2.4; }

@media (prefers-reduced-motion: reduce) {
  .tdv-bar, .tdv-orb-ring { transition: none; }
  .tdv-meter.is-calm .tdv-bar { animation: none; height: 14px; }
}
