/* 哥哥的作业 (spec §16, §17): leaf-green theme, task cards, paste sheet, calendar, stats, the review flow
   (status chips, 打回 | 通过, 打回 sheet, 检查设置), and 哥哥's iPad (.hwk panel) plus the read-aloud spinner (tts.js).
   §12: side-by-side groups share one class and use minmax(0, 1fr) columns; skeletons keep the real heights. */

/* ---------- Status colours (calendar dots, rows, bars, heatmap) ---------- */
:root {
  --hw-done: #2E9A5E;
  --hw-partial: #F0A500;
  --hw-none: #B5ABBF;
  --hw-rest: #D3CADB; /* the not-done part of a bar */
  --hw-heat-empty: #EFE8EF;
}
@media (prefers-color-scheme: dark) {
  :root {
    --hw-done: #4CD38A;
    --hw-partial: #FFC233;
    --hw-none: rgba(247, 239, 255, 0.36);
    --hw-rest: rgba(247, 239, 255, 0.22);
    --hw-heat-empty: rgba(247, 239, 255, 0.07);
  }
}
.hw-cal-day, .hw-day-row, .hw-col, .hw-heat-cell, .hw-legend-dot { --st: transparent; }
:is(.hw-cal-day, .hw-day-row, .hw-col, .hw-heat-cell, .hw-legend-dot)[data-status="done"] { --st: var(--hw-done); }
:is(.hw-cal-day, .hw-day-row, .hw-col, .hw-heat-cell, .hw-legend-dot)[data-status="partial"] { --st: var(--hw-partial); }
:is(.hw-cal-day, .hw-day-row, .hw-col, .hw-heat-cell, .hw-legend-dot)[data-status="none"] { --st: var(--hw-none); }

/* ---------- Theme: set on <html> while a homework page is open (sheets included) ---------- */
html.theme-hw {
  --hero-1: #135036;
  --hero-2: #237A50;
  --hero-glow: rgba(140, 236, 180, 0.30);
  --accent: #1A7A46;
  --accent-soft: var(--leaf-soft);
  --focus: rgba(46, 154, 94, 0.45);
}
@media (prefers-color-scheme: dark) {
  html.theme-hw {
    --hero-1: #0B2619;
    --hero-2: #17533A;
    --hero-glow: rgba(90, 210, 145, 0.16);
    --accent: #4CD38A;
    --accent-soft: rgba(76, 211, 138, 0.16);
    --focus: rgba(76, 211, 138, 0.5);
  }
}
html.theme-hw .btn-primary {
  background: linear-gradient(135deg, #3DB373 0%, #23845A 55%, #17663F 100%);
  box-shadow: 0 1px 2px rgba(19, 80, 54, 0.2), 0 8px 20px rgba(35, 122, 80, 0.30), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
html.theme-hw .seg--glass .seg-item[aria-checked="true"],
html.theme-hw .seg--glass .seg-item[aria-selected="true"] { color: #134A31; }
html.theme-hw .hero::after { background: radial-gradient(circle at 50% 50%, rgba(255, 210, 90, 0.22), rgba(255, 210, 90, 0) 70%); }
@media (prefers-color-scheme: dark) {
  html.theme-hw .hero::after { background: radial-gradient(circle at 50% 50%, rgba(255, 210, 90, 0.10), rgba(255, 210, 90, 0) 70%); }
}
html.theme-hw .page.is-scrolled .topbar { box-shadow: 0 1px 0 var(--hero-line), 0 8px 24px rgba(8, 40, 24, 0.24); }
/* Skeletons that sit on the green hero */
.hero .skeleton { background: linear-gradient(90deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0.24) 50%, rgba(255, 255, 255, 0.12) 100%); background-size: 200% 100%; }

/* ---------- Subjects ---------- */
.hw-sub--math { --sub-ink: #2457C5; --sub-soft: #E2EBFF; }
.hw-sub--chinese { --sub-ink: #B5332B; --sub-soft: #FFE3DE; }
.hw-sub--english { --sub-ink: #6B2F8A; --sub-soft: #EFE3F6; }
.hw-sub--reading { --sub-ink: #0B7680; --sub-soft: #D5F1F1; }
.hw-sub--writing { --sub-ink: #9A5200; --sub-soft: #FFE9C7; }
.hw-sub--life { --sub-ink: #1A7A46; --sub-soft: #DDF3E6; }
.hw-sub--sport { --sub-ink: #B8326A; --sub-soft: #FFE0EC; }
.hw-sub--other { --sub-ink: #625870; --sub-soft: #EEE9F1; }
@media (prefers-color-scheme: dark) {
  .hw-sub--math { --sub-ink: #9DBBFF; --sub-soft: rgba(45, 108, 240, 0.20); }
  .hw-sub--chinese { --sub-ink: #FF9A8F; --sub-soft: rgba(232, 67, 63, 0.20); }
  .hw-sub--english { --sub-ink: #D2A8EE; --sub-soft: rgba(168, 110, 208, 0.20); }
  .hw-sub--reading { --sub-ink: #6FD8DF; --sub-soft: rgba(20, 163, 173, 0.20); }
  .hw-sub--writing { --sub-ink: #FFC861; --sub-soft: rgba(232, 155, 0, 0.20); }
  .hw-sub--life { --sub-ink: #6FE0A2; --sub-soft: rgba(59, 170, 110, 0.20); }
  .hw-sub--sport { --sub-ink: #FF9CC4; --sub-soft: rgba(224, 81, 140, 0.20); }
  .hw-sub--other { --sub-ink: #CFC6D8; --sub-soft: rgba(138, 127, 150, 0.22); }
}
.hw-tile {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 44px; height: 44px;
  border-radius: 14px;
  background: var(--sub-soft);
  color: var(--sub-ink);
}
.hw-tile svg { width: 24px; height: 24px; stroke-width: 2; }
.hw-tile--sm { width: 36px; height: 36px; border-radius: 12px; }
.hw-tile--sm svg { width: 20px; height: 20px; }
.hw-tile--xs { width: 26px; height: 26px; border-radius: 8px; }
.hw-tile--xs svg { width: 16px; height: 16px; }

.hw-page-tag {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  height: 20px;
  padding: 0 7px;
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

/* ---------- Hero: ‹ date › switcher and progress ---------- */
.page--hw .hero { padding-bottom: 46px; }
.hw-switch {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 4px;
  height: 52px;
  padding: 3px;
  border-radius: 18px;
}
.hw-switch--glass {
  margin-top: 14px;
  background: var(--hero-glass);
  border: 1px solid var(--hero-line);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.hw-switch--glass .icon-btn--glass { background: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; }
.hw-switch--glass .icon-btn--glass:active:not(:disabled) { background: var(--hero-glass-strong); }
.hw-switch .icon-btn:disabled { opacity: 0.3; }
.hw-switch-main {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  height: 44px;
  padding: 0 8px;
  border: 0;
  border-radius: 14px;
  background: none;
  color: inherit;
  font-size: 17px;
  font-weight: 700;
}
.hw-switch:not(.hw-switch--glass) { background: var(--surface-3); }
.hw-switch:not(.hw-switch--glass) .icon-btn--soft { background: transparent; }
.hw-switch-label { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hw-switch-icon { width: 18px; height: 18px; opacity: 0.8; }
.hw-switch-rel {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.22);
  font-size: 12.5px;
  font-weight: 700;
}
.hw-date-btn { transition: background-color var(--dur-2), transform var(--dur-1) var(--ease-out); }
.hw-date-btn:active { background: var(--hero-glass-strong); transform: scale(0.98); }

.hw-progress {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  min-height: 72px;
  margin-top: 14px;
}
.hw-ring { position: relative; width: 64px; height: 64px; }
.hw-ring-svg { width: 64px; height: 64px; }
.hw-ring-track { stroke: rgba(255, 255, 255, 0.2); }
.hw-ring-fill { stroke: #fff; transition: stroke-dashoffset 600ms var(--ease-out), stroke var(--dur-2); }
.hw-ring.is-empty .hw-ring-fill { stroke: transparent; }
.hw-ring.is-complete .hw-ring-fill { stroke: var(--pineapple); }
.hw-ring-label { position: absolute; inset: 0; display: grid; place-items: center; font-size: 16px; font-weight: 800; }
.hw-ring.is-long .hw-ring-label { font-size: 13px; letter-spacing: -0.02em; }
.hw-ring-label svg { width: 28px; height: 28px; stroke-width: 2.8; color: var(--pineapple); }
.hw-ring.is-empty .hw-ring-label svg { width: 26px; height: 26px; stroke-width: 2; color: var(--hero-text-2); }
.hw-progress-text { display: grid; gap: 2px; min-width: 0; }
.hw-progress-title { min-height: 1.25em; font-size: 22px; font-weight: 800; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hw-progress-sub { min-height: 1.45em; font-size: 14px; color: var(--hero-text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hw-skel-hero-title { display: inline-block; vertical-align: middle; width: 6.5em; height: 22px; border-radius: 8px; }
.hw-skel-hero-sub { display: inline-block; vertical-align: middle; width: 10em; height: 13px; border-radius: 6px; }
.hero.is-celebrating .hw-ring { animation: hw-ring-cheer 900ms var(--ease-spring); }
.hero.is-celebrating .hw-progress-title { animation: hw-title-cheer 700ms var(--ease-spring); }
@keyframes hw-ring-cheer { 30% { transform: scale(1.16) rotate(-6deg); } 60% { transform: scale(0.96) rotate(3deg); } }
@keyframes hw-title-cheer { 40% { transform: translateY(-3px) scale(1.04); } }

/* ---------- Task cards ---------- */
/* min-height = a one-line card (pad + 20 subject row + 3 + 23 title + 6 + 18 meta + 12), so skeletons match it.
   The article is the card; the label inside is the tap area (approve); 打回 | 通过 sits under it. */
.hw-list { --hw-task-min: calc(var(--card-pad) + 82px); display: grid; gap: var(--gap); }
.hw-task {
  position: relative;
  border-radius: var(--r-l);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  transition: opacity 220ms var(--ease-out), transform 220ms var(--ease-out), background-color var(--dur-2), box-shadow var(--dur-2);
}
.hw-task.is-removing { opacity: 0; transform: scale(0.96); }
.hw-task-main { position: relative; }
.hw-task-hit {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 34px;
  grid-template-areas: "tile body check" "tile meta .";
  align-items: center;
  gap: 6px 12px;
  min-height: var(--hw-task-min);
  padding: var(--card-pad) var(--card-pad) 12px;
  border-radius: var(--r-l);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: transform var(--dur-1) var(--ease-out);
}
.hw-task-hit:active { transform: scale(0.98); }
.hw-task-hit:has(.hw-task-input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.hw-task-hit > .hw-tile { grid-area: tile; align-self: start; }
.hw-task-body { grid-area: body; display: grid; gap: 3px; min-width: 0; }
.hw-task-top { display: flex; align-items: center; gap: 6px; min-width: 0; height: 20px; overflow: hidden; }
.hw-task-subject { flex-shrink: 0; font-size: 12.5px; font-weight: 700; color: var(--sub-ink); }
.hw-task-tags { display: flex; gap: 4px; min-width: 0; overflow: hidden; }
.hw-task-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;
  transition: color var(--dur-2);
}
.hw-task-detail {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text-2);
}
.hw-task-meta { grid-area: meta; min-width: 0; min-height: 18px; font-size: 12.5px; line-height: 18px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hw-check {
  grid-area: check;
  justify-self: end;
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  border-radius: 11px;
  border: 2px solid var(--line-strong);
  background: var(--surface);
  color: transparent;
  transition: background-color var(--dur-2), border-color var(--dur-2), color var(--dur-2);
}
.hw-check svg { width: 20px; height: 20px; stroke-width: 3; }
.hw-task-more { position: absolute; right: calc(var(--card-pad) - 5px); bottom: 0; color: var(--text-3); }
.hw-task-more svg { width: 20px; height: 20px; }
.hw-task.is-done { background: color-mix(in srgb, var(--leaf-soft) 45%, var(--surface)); box-shadow: var(--shadow-1); }
.hw-task.is-submitted { box-shadow: 0 0 0 2px color-mix(in srgb, var(--pineapple) 70%, transparent), var(--shadow-2); }

/* Review state on a parent's card (spec §17.2) */
.hw-status-chip {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  height: 20px;
  padding: 0 8px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}
.hw-status-chip[data-tone="pineapple"] { background: var(--warning-soft); color: #8A5600; }
.hw-status-chip[data-tone="coral"] { background: var(--danger-soft); color: var(--danger); }
@media (prefers-color-scheme: dark) { .hw-status-chip[data-tone="pineapple"] { color: #FFD06A; } }
.hw-task-reason {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
  color: var(--danger);
}
.hw-task-review {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 0 var(--card-pad) var(--card-pad);
}
.hw-review-btn { width: 100%; min-width: 0; padding: 0 12px; }
.hw-review-btn svg { width: 19px; height: 19px; }
.hw-review-btn span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.hw-task.is-done .hw-check { border-color: transparent; background: var(--hw-done); color: #fff; }
.hw-task.is-done .hw-task-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); }
.hw-task.is-popping .hw-check { animation: hw-check-pop 420ms var(--ease-spring); }
.hw-task.is-popping .hw-check svg { animation: hw-check-draw 320ms var(--ease-out); }
@keyframes hw-check-pop { 0% { transform: scale(0.7); } 60% { transform: scale(1.15); } 100% { transform: none; } }
@keyframes hw-check-draw { from { opacity: 0; transform: scale(0.4) rotate(-20deg); } }
@media (prefers-color-scheme: dark) {
  .hw-task.is-done .hw-check { color: #0E2B1C; }
  .hw-check { background: transparent; }
}

.hw-task--skeleton .hw-task-hit { cursor: default; }
.hw-task--skeleton .hw-tile { background: none; }
.hw-skel-line { display: block; width: 78%; height: 15px; border-radius: 7px; }
.hw-skel-line--short { width: 28%; height: 12px; margin: 4px 0; }
.hw-skel-line--meta { width: 42%; height: 11px; margin-top: 3px; }

/* ---------- Empty day, actions, 原话 ---------- */
.hw-empty { padding: 28px 20px 22px; }
.hw-empty-art { width: 132px; height: 108px; }
.hw-empty p { max-width: 290px; text-wrap: pretty; }
.hw-empty-actions { display: grid; gap: 10px; width: 100%; max-width: 360px; margin-top: 8px; }
.hw-empty-actions .btn { margin-top: 0; }
.hw-empty-actions .btn-lg svg { width: 24px; height: 24px; }

.hw-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); margin-top: calc(var(--gap) + 4px); }
.hw-action { min-width: 0; padding: 0 12px; font-size: 15.5px; }
.hw-action span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.hw-action svg { width: 20px; height: 20px; }

.hw-raws { margin-top: var(--gap); padding: 2px 16px; }
.hw-raw + .hw-raw { border-top: 1px solid var(--line); }
.hw-raws .entry-raw { border-top: 0; }
.hw-raws .entry-raw + .entry-raw { border-top: 1px solid var(--line); }
.hw-raw summary { justify-content: flex-start; gap: 8px; min-height: 48px; }
.hw-raw-title { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; color: var(--text); }
.hw-raw-title svg { width: 18px; height: 18px; color: var(--accent); }
.hw-raw-by { flex: 1; min-width: 0; text-align: right; font-weight: 500; font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hw-raw .entry-raw-text { margin-bottom: 12px; font: 14px/1.6 var(--font); }

/* ---------- Paste sheet ---------- */
.hw-paste { display: grid; gap: 10px; }
.hw-paste-lead { padding: 0 2px; font-size: 14px; color: var(--text-2); }
.hw-paste-text { min-height: 196px; padding: 12px 14px; font-size: 17px; line-height: 1.5; resize: none; }
.hw-paste-tools { display: flex; align-items: center; justify-content: space-between; margin: -4px -4px 0; }
.hw-paste-clear { color: var(--text-3); }
.hw-paste-hint { display: flex; align-items: flex-start; gap: 6px; min-height: 20px; padding: 0 2px; font-size: 13px; line-height: 1.5; color: var(--text-3); }
.hw-paste-hint svg { width: 16px; height: 16px; margin-top: 1px; flex-shrink: 0; }
.hw-paste-hint.is-ok { color: var(--positive); }
.hw-paste .form-error { margin-top: 0; }

.hw-confirm { display: grid; gap: 16px; }
.hw-confirm .field + .field { margin-top: 0; }
.hw-banner-host:empty { display: none; }
.hw-banner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 16px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.45;
}
.hw-banner svg { width: 20px; height: 20px; margin-top: 1px; }
.hw-banner--warn { background: var(--warning-soft); color: #7A4A00; }
.hw-banner--info { background: var(--leaf-soft); color: #17663F; }
@media (prefers-color-scheme: dark) {
  .hw-banner--warn { color: #FFD06A; }
  .hw-banner--info { color: #6FE0A2; }
}
.hw-date-wrap { position: relative; display: flex; align-items: center; }
.hw-date-input { padding-right: 112px; }
.hw-date-word { position: absolute; right: 16px; font-size: 14px; font-weight: 600; color: var(--text-3); pointer-events: none; white-space: nowrap; }
.hw-confirm-date.is-busy .hw-date-wrap { opacity: 0.55; pointer-events: none; }
.hw-list-block .sheet-section-title { margin: 0 2px 10px; }
.hw-rows { display: grid; gap: 10px; }
.hw-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 40px;
  align-items: center;
  gap: 8px;
  padding: 10px 6px 10px 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg);
}
.hw-row .input { min-height: 44px; padding: 0 12px; border-radius: 12px; font-size: 17px; }
.hw-row .hw-row-title { grid-column: 1 / -1; width: calc(100% - 4px); }
.hw-row-info { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; font-size: 12.5px; color: var(--text-2); }
.hw-row-detail { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hw-row-remove { width: 40px; color: var(--text-3); }
.hw-row-remove svg { width: 20px; height: 20px; }
.hw-row-src { grid-column: 1 / -1; padding: 0 6px 0 2px; font-size: 12.5px; line-height: 1.45; color: var(--text-3); overflow-wrap: anywhere; }
.hw-rows-empty { display: flex; align-items: center; gap: 6px; padding: 8px 2px; font-size: 14px; color: var(--text-3); }
.hw-rows-empty svg { width: 18px; height: 18px; }
.hw-add-row { margin-top: 4px; }
.hw-back { justify-self: start; color: var(--text-2); }
.hw-confirm .entry-raw { margin-top: -4px; }

.hw-sub-select { position: relative; display: flex; align-items: center; height: 44px; min-width: 0; border-radius: 12px; background: var(--sub-soft); color: var(--sub-ink); }
.hw-sub-select-input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 100%;
  padding: 0 26px 0 12px;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: inherit;
  font-size: 16px;
  font-weight: 700;
}
.hw-sub-select-chevron { position: absolute; right: 8px; width: 16px; height: 16px; pointer-events: none; }
.hw-sub-select:has(select:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- 手动加一项 / 修改 ---------- */
.hw-form { display: grid; gap: 16px; }
.hw-form .field + .field { margin-top: 0; }
.hw-form .form-error { margin-top: -4px; }
.hw-form-date { display: inline-flex; align-items: center; gap: 6px; padding: 0 4px; font-size: 14px; font-weight: 600; color: var(--text-2); }
.hw-form-date svg { width: 17px; height: 17px; color: var(--accent); }
.hw-detail-input { min-height: 76px; padding: 12px 16px; line-height: 1.45; resize: none; }
.hw-subject-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 8px; }
.hw-subject-option {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 4px;
  min-width: 0;
  min-height: 74px;
  padding: 8px 4px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 14px;
  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);
}
.hw-subject-option:active { transform: scale(0.95); }
.hw-subject-option[aria-checked="true"] { border-color: var(--sub-ink); background: var(--sub-soft); color: var(--sub-ink); }
.hw-subject-option[aria-checked="true"] .hw-tile { background: var(--surface); }
.hw-subject-option-label { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Calendar (记录 and the date sheet) ---------- */
.hw-date-sheet { display: grid; gap: 12px; }
.hw-date-sheet .hw-legend { margin-top: 0; }
.hw-cal { display: grid; gap: 6px; }
.hw-cal-head, .hw-cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.hw-cal-head span { text-align: center; font-size: 12px; font-weight: 600; color: var(--text-3); }
.hw-cal-grid { display: grid; gap: 2px; }
.hw-cal-cell { display: grid; place-items: center; min-width: 0; height: 48px; }
.hw-cal-day {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 4px;
  width: 100%;
  max-width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: none;
  color: var(--text);
  transition: background-color var(--dur-2), transform var(--dur-1) var(--ease-out);
}
.hw-cal-day:active:not(:disabled) { transform: scale(0.9); background: var(--surface-3); }
.hw-cal-day:disabled { cursor: default; }
.hw-cal-num { font-size: 16px; font-weight: 600; line-height: 1; }
.hw-cal-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--st); }
.hw-cal-day[data-status="empty"] .hw-cal-dot, .hw-cal-day[data-status="unknown"] .hw-cal-dot { background: transparent; }
.hw-cal-day.is-today { box-shadow: inset 0 0 0 2px var(--accent); }
.hw-cal-day.is-today .hw-cal-num { font-weight: 800; color: var(--accent); }
.hw-cal-day.is-selected { background: var(--accent-soft); }
.hw-cal-day.is-selected .hw-cal-num { font-weight: 800; }
.hw-cal-day.is-future .hw-cal-num { color: var(--text-3); }
.hw-cal-card { padding: 14px 12px 14px; }

.hw-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; margin-top: 12px; font-size: 12px; color: var(--text-2); }
.hw-legend-item { display: inline-flex; align-items: center; gap: 5px; }
.hw-legend-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--st); }
.hw-legend-dot[data-status="empty"] { box-shadow: inset 0 0 0 1.5px var(--line-strong); }

/* ---------- 记录 ---------- */
.page--hw-history .hero-sub { margin-top: 10px; }
.hw-month-sum { min-height: 1.45em; }
.hw-skel-sum { display: inline-block; vertical-align: middle; width: 12em; height: 14px; border-radius: 7px; }
.page--hw-history .section-label { margin-top: 24px; }
.hw-recent { padding: 4px 0; overflow: hidden; }
.hw-day-row {
  position: relative;
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) 56px 40px 18px;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 62px;
  padding: 8px 14px 8px 18px;
  border: 0;
  background: none;
  color: var(--text);
  text-align: left;
  transition: background-color var(--dur-2);
}
.hw-day-row + .hw-day-row::before { content: ""; position: absolute; top: 0; left: 38px; right: 0; height: 1px; background: var(--line); }
.hw-day-row:active { background: var(--surface-3); }
.hw-day-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--st); }
.hw-day-main { display: grid; gap: 1px; min-width: 0; }
.hw-day-date { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; }
.hw-day-rel { display: inline-flex; align-items: center; flex-shrink: 0; height: 20px; padding: 0 7px; border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; }
.hw-day-sub { font-size: 13px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hw-day-bar { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.hw-day-fill { display: block; width: calc(var(--p, 0) * 100%); height: 100%; border-radius: 0 4px 4px 0; background: var(--st); }
.hw-day-count { text-align: right; font-size: 14px; font-weight: 700; color: var(--text-2); }
.hw-day-row--skeleton { display: flex; padding: 8px 16px; }
.hw-skel-row { display: block; width: 100%; height: 20px; border-radius: 8px; }
.hw-recent-empty { padding: 20px 16px; text-align: center; font-size: 14px; color: var(--text-3); }

/* ---------- 统计 ---------- */
.hw-range { min-height: 1.4em; }
.page--hw-stats .hero-seg { margin-top: 12px; }
.hw-stats { display: grid; gap: var(--gap); transition: opacity var(--dur-2); }
.hw-stats.is-loading { opacity: 0.6; }
.hw-stats.is-skeleton { opacity: 1; }
.hw-stats > .card + .card { margin-top: 0; }

.hw-figures { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: stretch; gap: var(--gap); }
.hw-figure {
  display: grid;
  align-content: start;
  justify-items: start;
  gap: 6px;
  min-width: 0;
  padding: 14px 12px 12px;
  border-radius: var(--r-l);
  container-type: inline-size;
  background: var(--surface);
  box-shadow: var(--shadow-2);
}
.hw-figure-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 10px; background: var(--leaf-soft); color: #1A7A46; }
.hw-figure-icon svg { width: 18px; height: 18px; stroke-width: 2.1; }
.hw-figure--rate .hw-figure-icon { background: #E2EBFF; color: #2457C5; }
.hw-figure--streak .hw-figure-icon { background: var(--coral-soft); color: #B5332B; }
@media (prefers-color-scheme: dark) {
  .hw-figure-icon { color: #6FE0A2; }
  .hw-figure--rate .hw-figure-icon { background: rgba(45, 108, 240, 0.2); color: #9DBBFF; }
  .hw-figure--streak .hw-figure-icon { color: #FF9A8F; }
}
/* Sized by the card, so the three always share one size at 375 px. */
.hw-figure-value { max-width: 100%; font-size: 28px; font-size: min(28px, 27cqi); font-weight: 800; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hw-figure-value .skeleton-value { width: 2.2em; }
.hw-unit { margin-left: 2px; font-family: var(--font); font-size: 13px; font-weight: 700; color: var(--text-2); }
.hw-figure-label { max-width: 100%; font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.hw-minis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: 1fr; padding: 4px 0; }
@media (min-width: 600px) { .hw-minis { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.hw-mini { position: relative; display: grid; justify-items: center; align-content: center; gap: 2px; min-width: 0; padding: 12px 6px; text-align: center; }
.hw-mini:not(:nth-child(3n + 1))::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 1px; background: var(--line); }
.hw-mini:nth-child(n + 4)::after { content: ""; position: absolute; top: 0; left: 12px; right: 12px; height: 1px; background: var(--line); }
@media (min-width: 600px) {
  .hw-mini:nth-child(n + 2)::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 1px; background: var(--line); }
  .hw-mini:nth-child(n + 4)::after { content: none; }
}
.hw-mini-value { font-size: 22px; font-weight: 800; line-height: 1.2; }
.hw-mini-value .skeleton-value { width: 2em; }
.hw-mini-label { max-width: 100%; font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.hw-chart-card .card-head, .hw-subjects .card-head { margin-bottom: 6px; }
.hw-series-legend { display: flex; flex-shrink: 0; gap: 10px; font-size: 12px; color: var(--text-2); }
.hw-series-key { display: inline-flex; align-items: center; gap: 5px; }
.hw-swatch { width: 10px; height: 10px; border-radius: 3px; }
.hw-swatch--done { background: var(--hw-done); }
.hw-swatch--rest { background: var(--hw-rest); }
.hw-readout { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; margin-bottom: 6px; padding: 0 2px; font-size: 13.5px; color: var(--text-2); }
.hw-readout-text { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; min-width: 0; }
.hw-readout-text strong { font-size: 15px; color: var(--text); }
.hw-readout-hint { color: var(--text-3); }
.hw-readout-open { flex-shrink: 0; margin-right: -4px; }

.hw-daily { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); align-items: stretch; gap: 2px; height: 132px; border-bottom: 1px solid var(--line-strong); }
.hw-daily--week { gap: 10px; }
.hw-col { display: flex; align-items: flex-end; justify-content: center; min-width: 0; height: 100%; padding: 0; border: 0; border-radius: 6px 6px 0 0; background: none; transition: background-color var(--dur-2); }
.hw-col:disabled { cursor: default; }
.hw-col.is-selected { background: var(--surface-3); }
.hw-col-stack { display: flex; flex-direction: column; justify-content: flex-end; width: 100%; max-width: 28px; height: 100%; }
.hw-col-rest, .hw-col-done { flex-shrink: 0; height: calc(var(--h, 0) * 100%); }
.hw-col-rest { border-radius: 4px 4px 0 0; background: var(--hw-rest); }
.hw-col-done { background: var(--hw-done); }
.hw-col-stack.is-split .hw-col-done { border-top: 2px solid var(--surface); }
.hw-col-stack:not(.is-split) .hw-col-done { border-radius: 4px 4px 0 0; }
.hw-daily--month .hw-col-rest, .hw-daily--month .hw-col-stack:not(.is-split) .hw-col-done { border-radius: 2px 2px 0 0; }
.hw-daily-x { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 2px; min-height: 18px; margin-top: 6px; }
.hw-daily-x--week { gap: 10px; min-height: 34px; }
.hw-x { display: grid; justify-items: center; min-width: 0; font-size: 11px; line-height: 1.4; color: var(--text-3); white-space: nowrap; }
.hw-x-week { font-size: 13px; font-weight: 600; color: var(--text-2); }
.hw-x.is-today, .hw-x.is-today .hw-x-week { font-weight: 800; color: var(--accent); }

.hw-heat { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 12px; }
@media (min-width: 600px) { .hw-heat { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.hw-heat-month { display: grid; gap: 6px; min-width: 0; }
.hw-heat-label { font-size: 12.5px; font-weight: 700; color: var(--text-2); }
.hw-heat-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; cursor: pointer; }
.hw-heat-cell { display: block; aspect-ratio: 1; border-radius: 3px; background: var(--hw-heat-empty); }
.hw-heat-cell[data-status="done"], .hw-heat-cell[data-status="partial"], .hw-heat-cell[data-status="none"] { background: var(--st); }
.hw-heat-cell.is-blank, .hw-heat-cell[data-status="future"] { background: transparent; }
.hw-heat-cell[data-status="future"] { box-shadow: inset 0 0 0 1px var(--line); }
.hw-heat-cell.is-today { box-shadow: 0 0 0 1.5px var(--accent); }
.hw-heat-cell.is-selected { outline: 2px solid var(--text); outline-offset: 1px; }
.hw-legend--heat { margin-top: 14px; }
.hw-heat-key { width: 10px; height: 10px; aspect-ratio: auto; }

.hw-bars { display: grid; gap: 8px; }
.hw-bar-row { display: grid; grid-template-columns: 26px 32px minmax(0, 1fr) 54px; align-items: center; gap: 8px; min-height: 28px; }
.hw-bar-label { font-size: 14px; font-weight: 600; white-space: nowrap; }
.hw-bar-track { display: flex; height: 12px; border-radius: 4px; background: color-mix(in srgb, var(--surface-3) 70%, transparent); }
.hw-bar-done, .hw-bar-rest { flex-shrink: 0; height: 100%; width: calc(var(--w, 0) * 100%); }
.hw-bar-done { background: var(--hw-done); }
.hw-bar-rest { border-radius: 0 4px 4px 0; background: var(--hw-rest); }
.hw-bar-track.is-split .hw-bar-rest { border-left: 2px solid var(--surface); }
.hw-bar-track:not(.is-split) .hw-bar-done { border-radius: 0 4px 4px 0; }
.hw-bar-value { text-align: right; font-size: 13px; font-weight: 700; color: var(--text-2); }
.hw-bar-row.is-zero .hw-bar-label, .hw-bar-row.is-zero .hw-bar-value { color: var(--text-3); font-weight: 500; }
.hw-bar-row.is-zero .hw-tile { opacity: 0.5; }

/* ---------- 今天: other days waiting, the 今天 tab count, hero progress (spec §17.2, §17.3) ---------- */
.hw-wait-banner {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 20px;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  margin-bottom: var(--gap);
  padding: 10px 12px;
  border: 0;
  background: color-mix(in srgb, var(--warning-soft) 75%, var(--surface));
  color: var(--text);
  font: inherit;
  text-align: left;
  transition: transform var(--dur-1) var(--ease-out);
}
.hw-wait-banner:active { transform: scale(0.98); }
.hw-wait-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; background: linear-gradient(135deg, #FFD45C, #FFAA1F); color: #5A3500; }
.hw-wait-icon svg { width: 22px; height: 22px; }
.hw-wait-text { min-width: 0; font-size: 15.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hw-wait-chevron { width: 20px; height: 20px; color: var(--text-3); }
.hw-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--r-pill);
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}
.hw-hero-slot { margin-top: var(--gap); }

/* ---------- 打回 (reasons) and 检查设置 sheets ---------- */
.hw-return { display: grid; gap: 12px; }
.hw-return-task { display: grid; gap: 2px; }
.hw-return-label { font-size: 13px; color: var(--text-3); }
.hw-return-task strong { font-size: 18px; line-height: 1.35; overflow-wrap: anywhere; }
.hw-return-lead { font-size: 14px; line-height: 1.5; color: var(--text-2); }
.hw-return .form-error { margin-top: 0; }
.hw-reasons { display: grid; gap: 10px; }
.hw-reason-chips { display: grid; grid-template-columns: minmax(0, 1fr); grid-auto-rows: 1fr; gap: 8px; }
@media (min-width: 420px) { .hw-reason-chips { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.hw-reason-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 48px;
  padding: 0 10px;
  border: 1.5px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  transition: transform var(--dur-1) var(--ease-out), background-color var(--dur-2), border-color var(--dur-2), color var(--dur-2);
}
.hw-reason-chip span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hw-reason-chip:active { transform: scale(0.97); }
.hw-reason-chip[aria-pressed="true"] { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.hw-reasons--large .hw-reason-chip { min-height: 56px; font-size: 17px; }

.hw-settings { display: grid; gap: 14px; }
.hw-settings-block .section-label { margin: 0 2px 8px; }
.hw-settings-lead { margin-bottom: 12px; font-size: 14px; line-height: 1.5; color: var(--text-2); }
.hw-settings-skel { display: block; height: 44px; border-radius: 14px; }
.hw-settings-example { min-height: 1.5em; margin-top: 8px; text-align: center; font-size: 15px; font-weight: 700; color: var(--text-2); }
.hw-settings-tip { display: grid; grid-template-columns: 32px minmax(0, 1fr); align-items: center; gap: 10px; padding: 12px 14px; border-radius: 16px; background: var(--surface-3); font-size: 14px; line-height: 1.5; color: var(--text-2); }

/* ---------- 哥哥's iPad: the homework panel (spec §17.4, §24.3a) ----------
   Sized by its own width (container queries): a narrow column gets smaller tiles, the iPad's wide
   column the big ones. Titles ≥ 22px, buttons ≥ 64px. Every card has one structure (kid-card.js):
   tile | subject line with the status badge top right | title | note, 🔊 on the right; the reason
   when sent back; the big button only while there is something to do. */
.hwk {
  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);
}
.hwk-head { display: grid; grid-template-columns: var(--kid-icon, 52px) minmax(0, 1fr) 64px; align-items: center; gap: 14px; }
.hwk-head-icon { display: grid; place-items: center; width: var(--kid-icon, 52px); height: var(--kid-icon, 52px); border-radius: 16px; background: linear-gradient(135deg, #62CF90, #2B9A5C); color: #fff; }
.hwk-head-icon svg { width: 60%; height: 60%; }
.hwk-head-text { display: grid; gap: 2px; min-width: 0; }
.hwk-head-title { font-size: var(--kid-head-fs, 26px); font-weight: 800; line-height: 1.2; }
.hwk-head-sub { min-height: 1.4em; font-size: 18px; font-weight: 700; line-height: 1.4; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hwk[data-tone="done"] .hwk-head-sub { color: var(--positive); }
.hwk[data-tone="returned"] .hwk-head-sub { color: var(--danger); }
.hwk .hw-ring-track { stroke: var(--surface-3); }
.hwk .hw-ring-fill, .hwk .hw-ring.is-complete .hw-ring-fill { stroke: var(--hw-done); }
.hwk .hw-ring-label { font-size: 17px; color: var(--text); }
.hwk .hw-ring.is-long .hw-ring-label { font-size: 14px; }
.hwk .hw-ring-label svg { color: var(--hw-done); }
.hwk .hw-ring.is-empty .hw-ring-label svg { color: var(--text-3); }

.hwk-list, .hwk-older { display: grid; gap: 12px; }
.hwk-older-title { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 18px; font-weight: 800; color: var(--danger); }
.hwk-older-title svg { width: 22px; height: 22px; }

.hwk-task {
  --hwk-tile: 56px;
  --hwk-speak: 52px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  border: 2px solid transparent;
  border-radius: var(--r-l);
  background: color-mix(in srgb, var(--sub-soft) 38%, var(--surface-2));
  transition: background-color var(--dur-2), border-color var(--dur-2), opacity var(--dur-2);
}
/* Dark: a fainter subject tint, so the cards read as one family, not navy / maroon / plum (§24.3a #6). */
@media (prefers-color-scheme: dark) { .hwk-task { background: color-mix(in srgb, var(--sub-soft) 20%, var(--surface-2)); } }
@container (max-width: 400px) {
  .hwk-task { --hwk-tile: 46px; --hwk-speak: 44px; gap: 12px; padding: 12px; }
}
@container (min-width: 480px) {
  .hwk-task { --hwk-tile: 64px; --hwk-speak: 56px; padding: 18px; }
}
.hwk-main {
  display: grid;
  grid-template-columns: var(--hwk-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;
}
.hwk-tile {
  grid-area: tile;
  align-self: start;
  display: grid;
  place-items: center;
  width: var(--hwk-tile);
  height: var(--hwk-tile);
  border-radius: 18px;
  background: var(--sub-ink);
  color: #fff;
  box-shadow: 0 6px 14px color-mix(in srgb, var(--sub-ink) 24%, transparent);
}
.hwk-tile svg { width: 58%; height: 58%; stroke-width: 2.2; }
@media (prefers-color-scheme: dark) { .hwk-tile { color: var(--bg); box-shadow: none; } }
.hwk-top { grid-area: top; display: flex; align-items: center; gap: 8px; min-width: 0; height: 30px; }
.hwk-subject { flex-shrink: 0; font-size: 17px; font-weight: 800; color: var(--sub-ink); }
.hwk-date { display: inline-flex; align-items: center; flex-shrink: 0; height: 24px; padding: 0 9px; border-radius: var(--r-pill); background: var(--danger-soft); color: var(--danger); font-size: 14px; font-weight: 800; }
.hwk-tags { display: flex; gap: 6px; min-width: 0; overflow: hidden; }
.hwk-tag { display: inline-flex; align-items: center; flex-shrink: 0; height: 26px; padding: 0 9px; border-radius: 8px; background: var(--surface); color: var(--text); font-size: 16px; font-weight: 800; }
/* The status: small, top right, the same place on every card. */
.hwk-badge-slot { display: flex; flex-shrink: 0; margin-left: auto; }
.hwk-badge-slot:empty { display: none; }
.hwk-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;
}
.hwk-badge svg { flex-shrink: 0; width: 18px; height: 18px; stroke-width: 2.4; }
.hwk-badge-dot { opacity: 0.6; }
.hwk-badge[data-tone="done"] { background: var(--positive-soft); color: var(--positive); }
.hwk-badge[data-tone="wait"] { background: var(--warning-soft); color: #7A4A00; }
.hwk-badge[data-tone="back"] { background: var(--danger-soft); color: var(--danger); }
@media (prefers-color-scheme: dark) { .hwk-badge[data-tone="wait"] { color: #FFD06A; } }
.hwk-text { grid-area: text; display: grid; gap: 2px; min-width: 0; }
.hwk-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) { .hwk-title { font-size: 24px; } }
.hwk-detail {
  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);
}
.hwk-detail[hidden] { display: none; }
.hwk-speak {
  grid-area: speak;
  align-self: center;
  display: grid;
  place-items: center;
  width: var(--hwk-speak);
  height: var(--hwk-speak);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--sub-ink);
  box-shadow: var(--shadow-1);
  transition: transform var(--dur-1) var(--ease-out), background-color var(--dur-2), color var(--dur-2);
}
.hwk-speak[hidden] { display: none; }
.hwk-speak svg { width: 55%; height: 55%; stroke-width: 2.2; }
.hwk-speak:active { transform: scale(0.92); }
.hwk-speak.is-speaking { background: var(--sub-ink); color: var(--surface); animation: hwk-pulse 1.2s ease-in-out infinite; }
@keyframes hwk-pulse { 50% { box-shadow: 0 0 0 9px color-mix(in srgb, var(--sub-ink) 22%, transparent); } }
.hwk-speak--sm { grid-area: auto; width: 48px; height: 48px; color: var(--danger); --sub-ink: var(--danger); }

/* Done: dimmed, the badge says so. Waiting: no button. Sent back: red edge, the reason under the title. */
.hwk-task.is-approved { background: var(--surface-2); }
.hwk-task.is-approved .hwk-tile, .hwk-task.is-approved .hwk-subject, .hwk-task.is-approved .hwk-tags,
.hwk-task.is-approved .hwk-title, .hwk-task.is-approved .hwk-detail, .hwk-task.is-approved .hwk-speak { opacity: 0.5; }
.hwk-task.is-approved .hwk-tile { filter: saturate(0.5); box-shadow: none; }
.hwk-task.is-returned { border-color: color-mix(in srgb, var(--danger) 50%, transparent); }
.hwk-task.is-changing { animation: hwk-bump 460ms var(--ease-spring); }
@keyframes hwk-bump { 40% { transform: scale(1.02); } }

.hwk-reason {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 12px;
  padding: 10px 10px 10px 12px;
  border-radius: 18px;
  background: var(--danger-soft);
  color: var(--danger);
}
.hwk-reason[hidden] { display: none; }
.hwk-reason-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--surface); }
.hwk-reason-icon svg { width: 22px; height: 22px; stroke-width: 2.2; }
.hwk-reason-body { display: grid; gap: 1px; min-width: 0; }
.hwk-reason-body strong { font-size: 15px; font-weight: 800; }
.hwk-reason-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.35;
  color: var(--text);
}
.hwk-main-btn { width: 100%; min-width: 0; min-height: 64px; padding: 0 16px; border-radius: 20px; font-size: 22px; }
.hwk-main-btn[hidden] { display: none; }
.hwk-main-btn svg { width: 28px; height: 28px; stroke-width: 2.6; }
.hwk-main-btn span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.hwk-task--skeleton { background: var(--surface-2); }
.hwk-task--skeleton .hwk-tile, .hwk-task--skeleton .hwk-speak { background: var(--surface-3); box-shadow: none; }
.hwk-skel { display: block; width: 72%; height: 22px; border-radius: 8px; }
.hwk-skel--short { width: 30%; height: 16px; }
.hwk-title-skel { height: 24px; }
.hwk-skel--btn { width: 100%; height: 64px; border-radius: 20px; }
.hwk-skel--head { display: inline-block; width: 8em; height: 16px; vertical-align: middle; }

.hwk-empty { display: grid; place-content: center; justify-items: center; gap: 8px; min-height: 220px; padding: 20px; border-radius: var(--r-l); background: var(--surface-2); text-align: center; }
.hwk-empty .hw-empty-art { width: 150px; height: 122px; }
.hwk-empty strong { font-size: 24px; font-weight: 800; }
.hwk-empty span { font-size: 18px; color: var(--text-2); }
.hwk-retry { width: 100%; border: 0; font: inherit; color: inherit; transition: transform var(--dur-1) var(--ease-out); }
.hwk-retry:active { transform: scale(0.98); }
.hwk-retry-icon svg { width: 44px; height: 44px; color: var(--danger); }

/* ---------- Read-aloud buttons (tts.js, spec §24.4): a spinner while the line is made ---------- */
.tts-loading > svg { display: none; }
.tts-spin {
  display: inline-block;
  flex-shrink: 0;
  box-sizing: border-box;
  width: var(--tts-size, 1.2em);
  height: var(--tts-size, 1.2em);
  border: 3px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: tts-spin 0.8s linear infinite;
}
@keyframes tts-spin { to { transform: rotate(360deg); } }
.icon-btn.is-speaking, .btn.is-speaking { box-shadow: 0 0 0 4px var(--accent-soft); }

@media (prefers-reduced-motion: reduce) {
  .hero.is-celebrating .hw-ring, .hero.is-celebrating .hw-progress-title, .hw-task.is-popping .hw-check, .hw-task.is-popping .hw-check svg { animation: none; }
  .hwk-task.is-changing, .hwk-speak.is-speaking { animation: none; }
  .tts-spin { animation-duration: 2.4s; }
}
