/* 「今天」—— 界面规范
 *
 * 三条铁律，改样式前先读：
 *   1) 未完成一律**中性灰**。不用红色、不用红叉、不用感叹号。
 *      灰色是"还没到"，红色是"你失败了"——对一个每天要看它的孩子，这两件事天差地别。
 *   2) 触控目标够大：主按钮 ≥80px，语音按钮 ≥96px，且**位置固定不移动**。
 *   3) 字号由 --scale 控制，跟着 setting.ui_scale 走。孩子长大了调小，不改代码。
 */

:root {
  --scale: 1;
  --bg: #faf7f4;
  --surface: #ffffff;
  --surface2: #f4f1ee;
  --ink: #23242a;
  --muted: #6b7280;
  --faint: #9aa1ac;
  --line: #e6e2de;

  --accent: #c2410c;          /* 暖橙：完成、当前 */
  --accent-soft: #fdece1;
  --violet: #6d28d9;          /* 紫：语音、复盘 */
  --violet-soft: #f1eafe;
  --teal: #0f766e;
  --teal-soft: #e2f2f0;

  /* 未完成 = 中性灰，绝不是红色 */
  --neutral: #b8bcc4;
  --neutral-soft: #eeecea;

  --radius: 16px;
  --shadow: 0 1px 3px rgba(30, 25, 20, .07), 0 6px 20px rgba(30, 25, 20, .05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16161a; --surface: #1e1f24; --surface2: #26272d;
    --ink: #e8e6e3; --muted: #9ba1ab; --faint: #757b86; --line: #31333a;
    --accent: #fb923c; --accent-soft: #2e1b0f;
    --violet: #a78bfa; --violet-soft: #221b35;
    --teal: #5eead4; --teal-soft: #0f2725;
    --neutral: #565b64; --neutral-soft: #26272d;
    --shadow: 0 1px 3px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--ink);
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: calc(17px * var(--scale));
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

#app { max-width: 560px; margin: 0 auto; padding: 0 16px calc(40px + env(safe-area-inset-bottom)); }
#app.loading { padding-top: 40vh; text-align: center; color: var(--faint); }

/* ── 通用 ── */
h1 { font-size: 1.5em; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 1.15em; margin: 28px 0 10px; }
p { margin: 0 0 12px; }
a { color: var(--accent); }
.muted { color: var(--muted); font-size: .88em; }
.faint { color: var(--faint); font-size: .82em; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.hide { display: none !important; }

header.top {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; padding: calc(18px + env(safe-area-inset-top)) 0 10px;
}
header.top .name { font-size: 1.35em; font-weight: 700; }
header.top .date { color: var(--faint); font-size: .82em; }

/* ── 按钮 ── */
button, .btn {
  font: inherit; font-weight: 600; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 16px; cursor: pointer;
  min-height: 48px; transition: transform .08s ease, background .15s ease;
}
button:active, .btn:active { transform: scale(.97); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.violet { background: var(--violet); border-color: var(--violet); color: #fff; }
button.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
button.plain { background: none; border: none; color: var(--muted); min-height: 0; padding: 6px 8px; }
button:disabled { opacity: .45; }
button.full { width: 100%; }
button.sm { min-height: 38px; padding: 7px 12px; font-size: .88em; }

input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px;
  min-height: 46px; width: 100%;
}
label.field { display: block; margin: 0 0 14px; }
label.field span { display: block; font-size: .84em; color: var(--muted); margin-bottom: 5px; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin: 12px 0; box-shadow: var(--shadow);
}

.pill {
  display: inline-block; font-size: .72em; font-weight: 700;
  padding: 3px 9px; border-radius: 20px; background: var(--neutral-soft); color: var(--muted);
}
.pill.ontime { background: var(--accent-soft); color: var(--accent); }
.pill.late   { background: var(--surface2); color: var(--muted); }
.pill.makeup { background: var(--violet-soft); color: var(--violet); }
.pill.excused{ background: var(--teal-soft); color: var(--teal); }
.pill.missed { background: var(--neutral-soft); color: var(--faint); }

/* ── 当前时段大卡（孩子端首屏的唯一焦点）── */
.now-card {
  background: var(--surface); border: 2px solid var(--accent);
  border-radius: 22px; padding: 22px 18px; margin: 14px 0 18px;
  box-shadow: var(--shadow); text-align: center;
}
.now-card .label { color: var(--accent); font-size: .78em; font-weight: 700; letter-spacing: .1em; }
.now-card .title { font-size: 1.7em; font-weight: 700; margin: 6px 0 2px; }
.now-card .time { color: var(--muted); font-size: .9em; margin-bottom: 18px; }

/* 主按钮 ≥80px，位置固定 */
.big-btn {
  width: 100%; min-height: 84px; font-size: 1.25em; font-weight: 700;
  border-radius: 18px; background: var(--accent); color: #fff; border: none;
}
.big-btn.done { background: var(--teal); }
.big-btn.violet { background: var(--violet); }

/* ── 时间轴 ── */
.timeline { margin: 8px 0 0; }
.tl-item {
  display: flex; gap: 12px; align-items: center;
  padding: 11px 12px; border-radius: 12px; margin-bottom: 7px;
  background: var(--surface); border: 1px solid var(--line);
}
.tl-item.buffer { background: transparent; border: none; padding: 4px 12px; opacity: .6; }
.tl-item.buffer .dot { background: transparent; border: 1px dashed var(--neutral); }
.tl-item.current { border-color: var(--accent); border-width: 2px; }
.tl-item .dot {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  background: var(--neutral-soft); border: 2px solid var(--neutral);
  display: grid; place-items: center; font-size: 14px; color: #fff;
}
.tl-item.done .dot { background: var(--accent); border-color: var(--accent); }
.tl-item.done.makeup .dot { background: var(--violet); border-color: var(--violet); }
.tl-item.done.excused .dot { background: var(--teal); border-color: var(--teal); }
/* missed 也是中性灰，不是红叉 */
.tl-item.missed .dot { background: var(--neutral-soft); border-color: var(--neutral); }
.tl-item .tl-name { font-weight: 600; }
.tl-item .tl-time { color: var(--faint); font-size: .78em; }
.tl-item.missed .tl-name { color: var(--faint); }

/* ── 语音 ── */
.prompt-card {
  background: var(--violet-soft); border-radius: 14px; padding: 14px 16px; margin: 0 0 16px;
}
.prompt-card ol { margin: 0; padding-left: 1.2em; }
.prompt-card li { margin: 5px 0; }
.prompt-card .src { color: var(--faint); font-size: .74em; margin-top: 8px; }

.retell-cards { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; }
.retell-cards .rc {
  flex: none; padding: 8px 12px; border-radius: 10px; font-size: .82em;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
  min-width: 92px; text-align: center;
}
.retell-cards .rc.on { background: var(--violet); border-color: var(--violet); color: #fff; }

.bubbles { display: flex; flex-direction: column; gap: 8px; margin: 14px 0; }
.bubble {
  display: flex; align-items: center; gap: 10px;
  background: var(--violet-soft); border-radius: 14px; padding: 10px 12px;
}
.bubble.linked { margin-top: -6px; border-top-left-radius: 4px; }
.bubble .secs { font-weight: 700; color: var(--violet); font-variant-numeric: tabular-nums; }
.bubble .bar { flex: 1; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.bubble .bar i { display: block; height: 100%; background: var(--violet); }

/* 录音按钮：≥96px，位置绝不移动、绝不变灰 */
.rec-wrap { text-align: center; margin: 18px 0 8px; }
.rec-btn {
  width: 112px; height: 112px; border-radius: 50%; border: none;
  background: var(--violet); color: #fff; font-size: 1.05em; font-weight: 700;
  box-shadow: 0 6px 22px rgba(109, 40, 217, .3);
  touch-action: none; user-select: none;
}
.rec-btn.recording { background: #dc2626; box-shadow: 0 0 0 12px rgba(220, 38, 38, .13); }
.rec-hint { color: var(--muted); font-size: .86em; margin-top: 10px; min-height: 1.6em; }
.level { height: 4px; width: 140px; margin: 10px auto 0; background: var(--line); border-radius: 2px; overflow: hidden; }
.level i { display: block; height: 100%; background: var(--violet); width: 0; transition: width .06s linear; }

/* ── 拍照 ── */
.shot { text-align: center; }
.shot video, .shot img { width: 100%; border-radius: 14px; background: #000; }
.shutter {
  width: 78px; height: 78px; border-radius: 50%; border: 5px solid var(--line);
  background: var(--accent); margin: 16px auto 0; display: block;
}
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.thumbs img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }

.upload-state { font-size: .78em; color: var(--faint); }
.upload-state.pending { color: var(--muted); }
.upload-state.failed { color: var(--accent); }

/* ── 选择格（学科 / 错因 / 心情）── */
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.choices.two { grid-template-columns: repeat(2, 1fr); }
.choices button { min-height: 62px; font-size: .95em; }
.choices button.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.moods { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; }
.moods button { flex: 1; font-size: 1.7em; min-height: 62px; padding: 0; }
.moods button.on { background: var(--accent-soft); border-color: var(--accent); }

/* ── 睡前三件事 ── */
.three { display: flex; flex-direction: column; gap: 12px; }
.three .item { display: flex; align-items: center; gap: 12px; }
.three .item .grow { min-width: 0; }
.three .item .nm { font-weight: 700; }
.three .item.done .nm { color: var(--faint); text-decoration: line-through; }

/* ── 家长端 ── */
nav.tabs {
  display: flex; gap: 4px; overflow-x: auto; padding: 10px 0 4px; margin-bottom: 6px;
}
nav.tabs button {
  flex: none; min-height: 40px; padding: 8px 14px; font-size: .9em;
  border-radius: 20px; background: transparent; border: 1px solid var(--line); color: var(--muted);
}
nav.tabs button.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.matrix { overflow-x: auto; }
.matrix table { border-collapse: collapse; font-size: .8em; min-width: 100%; }
.matrix th, .matrix td { padding: 5px 4px; text-align: center; }
.matrix th { color: var(--faint); font-weight: 600; }
.matrix td.lbl { text-align: left; white-space: nowrap; padding-right: 10px; font-weight: 600; }
.matrix .cell { width: 22px; height: 22px; border-radius: 6px; display: inline-block; background: var(--neutral-soft); }
.matrix .cell.ontime { background: var(--accent); }
.matrix .cell.late { background: #f9c98b; }
.matrix .cell.makeup { background: var(--violet); }
.matrix .cell.excused { background: var(--teal-soft); border: 1px solid var(--teal); }
.matrix .cell.missed { background: var(--neutral-soft); }

.stat-row { display: flex; gap: 10px; flex-wrap: wrap; }
.stat-box { flex: 1; min-width: 120px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.stat-box b { display: block; font-size: 1.5em; color: var(--accent); font-variant-numeric: tabular-nums; }
.stat-box span { font-size: .76em; color: var(--muted); }

.slot-editor { display: flex; flex-direction: column; gap: 8px; }
.slot-row {
  display: flex; gap: 8px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px;
}
.slot-row input[type=text] { min-height: 40px; padding: 8px 10px; }
.slot-row input[type=number] { min-height: 40px; padding: 8px; width: 66px; text-align: center; }
.slot-row .handle { color: var(--faint); cursor: grab; padding: 0 4px; font-size: 1.2em; }
.slot-row .cam { min-height: 40px; padding: 8px 10px; font-size: .8em; }
.slot-row .cam.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.weekbar { display: flex; gap: 5px; margin-bottom: 12px; }
.weekbar button { flex: 1; min-height: 44px; padding: 8px 2px; font-size: .84em; border-radius: 10px; }
.weekbar button.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.weekbar button.hasdiff::after { content: '·'; color: var(--accent); font-weight: 900; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 11px 18px; border-radius: 24px; font-size: .88em; z-index: 99;
  box-shadow: var(--shadow); max-width: 88vw; text-align: center;
}

.sheet-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 90;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--bg); width: 100%; max-width: 560px;
  border-radius: 22px 22px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  max-height: 88vh; overflow-y: auto;
}

.week-dots { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 10px 0; }
.week-dots .d { aspect-ratio: 1; border-radius: 9px; background: var(--neutral-soft); display: grid; place-items: center; font-size: .68em; color: var(--faint); }
.week-dots .d.on { background: var(--accent); color: #fff; }
.week-dots .d.part { background: var(--accent-soft); color: var(--accent); }

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