/* ---------- 英语听写 · 儿童友好 UI ---------- */
:root {
  --blue: #4f7cff;
  --blue-deep: #3560d8;
  --green: #22b573;
  --orange: #f5a623;
  --red: #e74c3c;
  --purple: #8b5cf6;
  --bg: #f2f6ff;
  --card: #ffffff;
  --ink: #1c2d50;
  --muted: #7a89a8;
  --line: #e3eaf8;
  --radius: 20px;
  --shadow: 0 6px 24px rgba(53, 96, 216, 0.10);
  font-size: 17px;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "HarmonyOS Sans SC", "MiSans", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  overscroll-behavior: none;
}

#app { min-height: 100vh; }

/* ---------- 布局 ---------- */
.page { max-width: 900px; margin: 0 auto; padding: 12px 18px 48px; display: flex; flex-direction: column; gap: 14px; }
.page.dictation-page { max-width: none; padding: 0; gap: 0; height: 100vh; height: 100dvh; }

.row { display: flex; align-items: center; }
.row.gap { gap: 12px; }
.row.gap-s { gap: 8px; }
.row.between { justify-content: space-between; }
.row.around { justify-content: space-around; }
.row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.center { align-items: center; }
.gap-s { display: flex; flex-direction: column; gap: 6px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.mono { font-family: "JetBrains Mono", Consolas, "Courier New", monospace; }

h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.25rem; margin: 0; }
h3 { font-size: 1.05rem; margin: 0 0 4px; }
p { margin: 4px 0; }

/* ---------- 按钮 ---------- */
.btn {
  border: none;
  border-radius: 16px;
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 600;
  background: #e8eefb;
  color: var(--ink);
  cursor: pointer;
  min-height: 48px;
  transition: transform 0.08s ease, filter 0.15s;
  font-family: inherit;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.5; }
.btn.primary { background: var(--blue); color: #fff; box-shadow: 0 4px 14px rgba(79, 124, 255, 0.4); }
.btn.accent { background: var(--orange); color: #fff; box-shadow: 0 4px 14px rgba(245, 166, 35, 0.35); }
.btn.ghost { background: transparent; border: 2px solid var(--line); }
.btn.danger { background: var(--red); color: #fff; }
.btn.link { background: none; color: var(--blue); min-height: 36px; padding: 6px 10px; font-size: 0.9rem; }
.btn.xl { font-size: 1.3rem; padding: 16px 36px; border-radius: 22px; }
.btn.lg { font-size: 1.1rem; }
.btn.mini { min-height: 36px; padding: 4px 12px; font-size: 0.85rem; border-radius: 12px; }
.btn.icon-btn { min-width: 48px; padding: 10px 14px; }
.btn.tool { background: #fff; border: 2px solid var(--line); font-size: 1.2rem; }
.btn.tool.active { border-color: var(--blue); background: #e8efff; }
.danger-ghost { background: #fdeceb; color: var(--red); }

/* ---------- 首页 ---------- */
.home-header { display: flex; justify-content: space-between; align-items: center; padding: 18px 4px 4px; }
.app-brand { display: flex; gap: 12px; align-items: center; }
.app-logo { font-size: 2.4rem; }
.app-brand p { margin: 0; font-size: 0.9rem; }
.child-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.child-card { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 26px 16px; font-size: 1.2rem; font-weight: 700; color: var(--ink); cursor: pointer; }
.child-avatar { font-size: 3.4rem; line-height: 1; }
.task-chip { font-size: 0.85rem; font-weight: 500; padding: 4px 14px; border-radius: 999px; }
.task-chip.todo { background: #e8f0ff; color: var(--blue-deep); }
.task-chip.done { background: #e3f8ee; color: var(--green); }
.task-chip.none { background: #f1f3f8; color: var(--muted); }
.section-title { margin: 10px 4px 0; }
.home-empty { text-align: center; padding: 48px 24px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.big-emoji { font-size: 3.6rem; line-height: 1.2; }

/* ---------- 顶栏 ---------- */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 2px 4px; }
.bar-title { display: flex; align-items: center; gap: 8px; font-size: 1.15rem; font-weight: 700; }
.bar-avatar { font-size: 1.8rem; }

/* ---------- 孩子主页 ---------- */
.today-card { display: flex; flex-direction: column; gap: 14px; padding: 22px; }
.today-card .done-line { font-size: 1.3rem; font-weight: 700; color: var(--green); margin-top: 6px; }
.today-card .todo-line { font-size: 1.3rem; font-weight: 700; color: var(--blue-deep); margin-top: 6px; }
.today-card.empty { align-items: center; text-align: center; padding: 36px 20px; }
.done-emoji { font-size: 3rem; }
.quick-actions { margin-top: -4px; }
.card-btn { background: var(--card); box-shadow: var(--shadow); font-size: 1.05rem; }
.card-btn.accent { color: #b96a00; background: #fff6e6; }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 8px; background: none; border: none; border-bottom: 1px solid var(--line); width: 100%; font-size: 1rem; color: var(--ink); cursor: pointer; font-family: inherit; text-align: left; }
.list-row:last-child { border-bottom: none; }
.list-row.tap { border-radius: var(--radius); box-shadow: var(--shadow); background: var(--card); border-bottom: none; padding: 16px 18px; margin-bottom: 0; }
.banner { border-radius: 14px; padding: 10px 14px; font-size: 0.9rem; line-height: 1.5; }
.banner.warn { background: #fff4e3; color: #a05e00; }
.banner.info { background: #e8f0ff; color: var(--blue-deep); }

/* ---------- 听写页 ---------- */
.dict-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; background: var(--card); box-shadow: 0 2px 10px rgba(53,96,216,0.08); }
.dict-center { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.dict-right { display: flex; align-items: center; gap: 8px; }
.dict-status { font-size: 0.95rem; color: var(--muted); }
.dict-counter { font-size: 1.1rem; font-weight: 700; color: var(--ink); white-space: nowrap; }
.progress-dots { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; max-width: 46vw; }
.progress-dots .dot { width: 12px; height: 12px; border-radius: 50%; background: #d9e3f8; transition: all 0.2s; }
.progress-dots .dot.cur { background: var(--blue); transform: scale(1.35); box-shadow: 0 0 0 4px rgba(79,124,255,0.2); }
.progress-dots .dot.done { background: var(--green); }

.board-wrap { flex: 1; position: relative; margin: 10px; border-radius: 24px; overflow: hidden; background: #fff; box-shadow: inset 0 2px 12px rgba(53,96,216,0.08); min-height: 200px; }
.write-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

.board-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 14px calc(10px + env(safe-area-inset-bottom)); background: var(--card); }
.board-hint { font-size: 0.9rem; }

.timer-ring .ring-bg { fill: #eef2fc; stroke: #e3eaf8; stroke-width: 6; }
.timer-ring .ring-fg { fill: none; stroke: var(--blue); stroke-width: 6; stroke-linecap: round; transition: stroke 0.3s; }
.timer-ring .ring-fg.warn { stroke: var(--orange); }
.timer-ring .ring-num { font-size: 22px; font-weight: 800; fill: var(--ink); }

.dict-overlay { position: fixed; inset: 0; background: rgba(28, 45, 80, 0.45); display: flex; align-items: center; justify-content: center; z-index: 60; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.dict-overlay.show { opacity: 1; pointer-events: auto; }
.overlay-card { background: var(--card); border-radius: 28px; padding: 36px 48px; display: flex; flex-direction: column; align-items: center; gap: 12px; box-shadow: 0 20px 60px rgba(20, 40, 90, 0.35); max-width: 90vw; }
.overlay-card.small { padding: 22px 40px; gap: 4px; }
.overlay-num { font-size: 4rem; font-weight: 900; color: var(--blue); line-height: 1.1; }

/* ---------- 成绩页 ---------- */
.score-card { display: flex; flex-direction: column; gap: 12px; }
.score-num { font-size: 3.6rem; font-weight: 900; line-height: 1; }
.score-unit { font-size: 1.4rem; font-weight: 700; margin-left: 4px; }
.score-card .actions { margin-top: 4px; }
.result-list { display: flex; flex-direction: column; gap: 12px; }
.result-item { padding: 16px 18px; }
.result-item.wrong { border-left: 6px solid var(--red); }
.result-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.result-idx { color: var(--muted); margin-right: 8px; }
.result-target { font-size: 1.3rem; font-weight: 700; }
.result-meaning { margin-left: 8px; }
.result-img { max-width: 100%; max-height: 180px; margin: 10px auto 4px; display: block; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.result-img.empty { padding: 22px; color: var(--muted); text-align: center; font-size: 0.9rem; }
.result-meta { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.correct-answer { color: var(--green); font-weight: 600; }
.fix-btn { margin-top: 6px; }
.badge { padding: 4px 12px; border-radius: 999px; font-weight: 700; font-size: 0.9rem; white-space: nowrap; }
.badge.ok { background: #e3f8ee; color: var(--green); }
.badge.bad { background: #fdeceb; color: var(--red); }
.badge.unsure { background: #fff4e3; color: #a05e00; }
.badge.pending { background: #eef2fc; color: var(--muted); }

.stars .star { color: #dfe6f5; font-size: 1.2em; }
.stars .star.on { color: var(--orange); }

/* ---------- 历史页 ---------- */
.stat-row { padding: 18px 8px; }
.stat { text-align: center; }
.stat-num { font-size: 1.7rem; font-weight: 800; color: var(--blue-deep); }

/* ---------- 家长中心 ---------- */
.tab-bar { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0; }
.tab-btn { border: none; background: #e8eefb; border-radius: 14px; padding: 10px 16px; font-size: 0.95rem; font-weight: 600; color: var(--muted); white-space: nowrap; cursor: pointer; font-family: inherit; }
.tab-btn.active { background: var(--blue); color: #fff; }
.tab-body { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.95rem; }
.field.row { flex-direction: row; align-items: center; justify-content: space-between; }
.chip { border: 2px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 18px; font-size: 1rem; font-weight: 700; color: var(--ink); cursor: pointer; font-family: inherit; }
.chip.on { border-color: var(--blue); background: #e8efff; color: var(--blue-deep); }
.preview-row { padding: 8px 4px; border-bottom: 1px dashed var(--line); }
.preview-row:last-child { border-bottom: none; }
.word-pick-list { max-height: 55vh; overflow-y: auto; }
.help-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; line-height: 1.6; color: var(--ink); }
.save-bar { padding-bottom: 20px; }

input.input, select.input, textarea.input {
  border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px; font-size: 1rem; font-family: inherit; background: #fff; color: var(--ink); width: 100%;
}
input.input:focus, select.input:focus, textarea.input:focus { outline: none; border-color: var(--blue); }
input[type="range"] { accent-color: var(--blue); min-width: 160px; }
input[type="checkbox"] { width: 26px; height: 26px; accent-color: var(--blue); }
input[type="date"] { min-height: 48px; }

/* ---------- 弹层 ---------- */
.sheet-mask { position: fixed; inset: 0; background: rgba(28, 45, 80, 0.5); z-index: 80; display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity 0.22s; }
.sheet-mask.open { opacity: 1; }
.sheet { background: var(--card); width: min(680px, 100%); max-height: 88vh; overflow-y: auto; border-radius: 26px 26px 0 0; padding: 20px 22px calc(24px + env(safe-area-inset-bottom)); transform: translateY(40px); transition: transform 0.22s; }
.sheet-mask.open .sheet { transform: translateY(0); }
.sheet-title { font-size: 1.15rem; font-weight: 800; margin-bottom: 12px; }
.confirm-msg { font-size: 1.02rem; line-height: 1.6; }

/* ---------- PIN ---------- */
.pin-dots { display: flex; gap: 14px; margin: 8px 0; }
.pin-dot { width: 18px; height: 18px; border-radius: 50%; border: 3px solid #cbd7f2; transition: all 0.15s; }
.pin-dot.on { background: var(--blue); border-color: var(--blue); }
.pin-sub { color: var(--muted); font-size: 0.92rem; min-height: 1.3em; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 12px; justify-content: center; margin-top: 10px; }
.pin-key { border: none; background: #eef2fc; border-radius: 18px; font-size: 1.5rem; font-weight: 700; padding: 16px 0; cursor: pointer; color: var(--ink); font-family: inherit; min-height: 64px; }
.pin-key:active { background: #dfe7fb; }
.pin-key.fn { background: transparent; font-size: 1rem; color: var(--muted); }

/* ---------- 头像选择 ---------- */
.avatar-picker { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; }
.avatar-btn { border: 2px solid var(--line); background: #fff; border-radius: 14px; font-size: 1.7rem; padding: 8px 0; cursor: pointer; }
.avatar-btn.sel { border-color: var(--blue); background: #e8efff; }

/* ---------- 通用 ---------- */
.toast { position: fixed; left: 50%; bottom: 10vh; transform: translateX(-50%) translateY(20px); background: rgba(28, 45, 80, 0.92); color: #fff; padding: 12px 22px; border-radius: 999px; font-size: 0.95rem; opacity: 0; transition: all 0.25s; z-index: 100; pointer-events: none; max-width: 86vw; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.spinner-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 20px; color: var(--muted); }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 5px solid #dfe7fb; border-top-color: var(--blue); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 纸屑 ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 90; overflow: hidden; }
.confetti i { position: absolute; top: -4vh; display: block; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ---------- 窄屏 / 竖屏 ---------- */
@media (max-width: 640px) {
  :root { font-size: 16px; }
  .page { padding: 10px 12px 40px; }
  .child-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .dict-bar { flex-wrap: nowrap; }
  .progress-dots { max-width: 34vw; }
  .board-tools { flex-wrap: wrap; justify-content: center; }
  .avatar-picker { grid-template-columns: repeat(6, 1fr); }
}
@media (orientation: portrait) and (max-width: 640px) {
  .board-wrap { margin: 8px; }
}
