* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  color-scheme: light;
  --bg: #f2f4f7; --surface: #fff; --surface-soft: #f1f3f4;
  --text: #1c2333; --muted: #667085; --subtle: #8892a3; --border: #ccd2dd;
  --divider: #e7e9ee; --primary: #1a73e8; --primary-soft: #e8f0fe;
  --shadow: 0 1px 3px rgba(0,0,0,.08); --focus: #1a73e8;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #10151f; --surface: #1a2230; --surface-soft: #242e3d;
  --text: #edf2f8; --muted: #abb6c6; --subtle: #929fb2; --border: #3b485b;
  --divider: #303b4b; --primary: #6ba8ff; --primary-soft: #243b5d;
  --shadow: 0 2px 8px rgba(0,0,0,.28); --focus: #7cb2ff;
}
:root[data-theme="dark"] .banner { background: #342d18; border-color: #685b2c; color: #f2d77d; }
:root[data-theme="dark"] .lesson-status.open,
:root[data-theme="dark"] .option.correct,
:root[data-theme="dark"] .feedback.ok { background: #183726; color: #7ee2a1; }
:root[data-theme="dark"] .lesson-status.future { background: #2b3543; color: #c1cad7; }
:root[data-theme="dark"] .lesson-status.closed,
:root[data-theme="dark"] .option.wrong,
:root[data-theme="dark"] .feedback.bad { background: #402321; color: #ff9c95; }
:root[data-theme="dark"] .review-label { background: #3a3016; color: #f2d477; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
}
.app { max-width: 560px; margin: 0 auto; padding: 12px 14px 40px; }
.view { padding-top: 8px; }
.hidden { display: none !important; }

.card {
  background: var(--surface);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
h1 { font-size: 24px; margin: 6px 0 2px; text-align: center; }
.sub { text-align: center; color: var(--muted); margin: 4px 0 16px; font-size: 14px; }
h2 { font-size: 18px; margin: 10px 0 6px; }
.sec-title { font-size: 15px; color: var(--muted); margin: 18px 4px 8px; }

.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.top-actions { display: flex; gap: 4px; }
.hello { font-size: 18px; font-weight: 600; }
.sync { font-size: 13px; color: var(--muted); }

.banner { background: #fff7e0; border: 1px solid #f0d98c; color: #7a5b00; border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.field input {
  width: 100%; padding: 13px 12px; font-size: 17px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text);
}
.field input:focus { outline: 2px solid var(--focus); border-color: var(--focus); }

.btn {
  display: block; width: 100%; padding: 13px; margin: 8px 0;
  border: none; border-radius: 10px; font-size: 17px; cursor: pointer;
  background: var(--surface-soft); color: var(--text); text-align: center;
}
.btn.primary { background: #1a73e8; color: #fff; }
.btn.secondary { background: var(--primary-soft); color: var(--primary); }
.btn.danger { background: #d93025; color: #fff; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.big { padding: 15px; font-size: 18px; }
.btn.small { width: auto; padding: 7px 12px; font-size: 14px; display: inline-block; }
.btn:active { opacity: .8; }
.btn:disabled { opacity: .5; }

.error { color: #d93025; font-size: 14px; }
.hint { color: var(--subtle); font-size: 13px; text-align: center; margin: 10px 0 0; }
.hint.left { text-align: left; }
.plan-note { margin: 6px 0 10px; color: var(--muted); text-align: center; font-size: 14px; }
.setting-label { display: block; margin: 16px 0 6px; color: var(--text); font-weight: 600; }
.setting-select { width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font-size: 17px; }
.form-message { border-radius: 9px; padding: 9px 11px; margin: 8px 0; font-size: 14px; }
.form-message.success { color: #63d58a; background: rgba(30,142,62,.16); }
.download-progress { height: 9px; overflow: hidden; border-radius: 5px; background: var(--surface-soft); margin: 10px 0; }
.download-progress > div { width: 0; height: 100%; background: var(--primary); transition: width .15s linear; }

.row { display: flex; justify-content: space-around; text-align: center; margin-bottom: 8px; }
.stat .num { font-size: 26px; font-weight: 700; color: #1a73e8; }
.stat .lbl { font-size: 13px; color: var(--muted); }

.lesson-card { display: flex; align-items: center; padding: 12px 4px; border-bottom: 1px solid var(--divider); }
.lesson-card:last-child { border-bottom: none; }
.lesson-info { flex: 1; }
.lesson-title { font-size: 16px; font-weight: 600; }
.lesson-meta { font-size: 13px; color: var(--muted); }
.lesson-status { font-size: 13px; padding: 3px 10px; border-radius: 20px; white-space: nowrap; }
.lesson-status.open { background: #e6f4ea; color: #1e8e3e; }
.lesson-status.future { background: #f1f3f4; color: #667; }
.lesson-status.closed { background: #fce8e6; color: #c5221f; }
.bar { height: 6px; background: var(--surface-soft); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.bar > div { height: 100%; background: #1a73e8; border-radius: 3px; }

/* 学习页 */
.prompt { font-size: 15px; color: var(--muted); margin-bottom: 4px; }
.question { font-size: 26px; font-weight: 700; margin: 6px 0 16px; word-break: break-all; }
.option {
  display: block; width: 100%; text-align: left;
  padding: 14px 14px; margin: 8px 0; font-size: 18px;
  border: 1.5px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); cursor: pointer;
}
.option:active { background: var(--primary-soft); }
.option.correct { border-color: #1e8e3e; background: #e6f4ea; }
.option.wrong { border-color: #c5221f; background: #fce8e6; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chip {
  padding: 12px 16px; font-size: 18px; border-radius: 10px;
  background: var(--primary-soft); color: var(--text); border: 1.5px solid #5d87bd; cursor: pointer;
}
.chip.used { opacity: .35; pointer-events: none; }
.answer-slot {
  min-height: 52px; border: 2px dashed #aecbfa; border-radius: 10px;
  padding: 8px; margin: 8px 0; display: flex; flex-wrap: wrap; gap: 6px;
}
.answer-slot .slot-chip { padding: 10px 14px; background: var(--surface); color: var(--text); border: 1.5px solid var(--primary); border-radius: 8px; font-size: 17px; }

.learn-jp { font-size: 30px; font-weight: 700; text-align: center; margin: 10px 0 4px; }
.pronunciation-row { display: flex; justify-content: center; align-items: center; gap: 9px; min-height: 38px; margin: 3px 0 5px; }
.learn-kana { font-size: 20px; color: var(--muted); text-align: center; }
.tone-badge { display: inline-flex; align-items: center; min-height: 29px; padding: 2px 9px; border-radius: 16px; background: var(--primary-soft); color: var(--primary); font-size: 18px; font-weight: 700; }
.tone-badge.missing { color: var(--subtle); background: var(--surface-soft); font-size: 12px; font-weight: 500; }
.word-tts-btn { width: 36px; height: 36px; padding: 0; margin: 0; border: 0; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-size: 19px; cursor: pointer; }
.word-tts-btn:active { opacity: .75; }
.learn-zh { font-size: 22px; text-align: center; margin: 6px 0 14px; }
.learn-phrases { font-size: 14px; color: var(--muted); text-align: center; }
.learn-examples { margin-top: 14px; text-align: left; }
.examples-title { color: var(--muted); font-size: 14px; margin-bottom: 5px; }
.example-reading { padding: 11px 0; border-top: 1px solid var(--divider); }
.example-reading:first-of-type { border-top: 0; }
.example-jp { font-size: 17px; font-weight: 600; line-height: 1.55; }
.example-zh { color: var(--muted); font-size: 14px; margin-top: 2px; }
.example-actions { display: flex; gap: 8px; margin-top: 8px; }
.example-actions .btn { flex: 1; margin: 0; white-space: nowrap; }
.reading-panel { margin-top: 10px; padding: 12px; border-radius: 10px; background: var(--surface-soft); }
.reading-sentence { margin: 0 0 8px; font-size: 15px; }
.reading-audio { display: block; width: 100%; height: 42px; margin: 8px 0; }
.reading-status { padding: 7px 9px; border-radius: 8px; font-size: 14px; }
.reading-status.ok { color: #1e8e3e; background: rgba(30,142,62,.12); }
.reading-board-title { font-size: 15px; margin: 14px 0 6px; }
.reading-entry { padding: 9px 0; border-top: 1px solid var(--divider); }
.reading-entry-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; }
.like-btn { border: 0; border-radius: 18px; padding: 6px 10px; background: var(--primary-soft); color: var(--primary); cursor: pointer; }
.like-btn:disabled { opacity: .7; }
.feedback { padding: 10px 12px; border-radius: 10px; margin: 8px 0; font-size: 15px; }
.feedback.ok { background: #e6f4ea; color: #1e8e3e; }
.feedback.bad { background: #fce8e6; color: #c5221f; }
.next-row { display: flex; gap: 8px; }
.next-row .btn { flex: 1; margin: 0; }
.review-label { display: inline-block; background: #fff4d6; color: #7a5600; border-radius: 20px; padding: 3px 10px; margin-bottom: 8px; font-size: 13px; }

/* 统计页 */
.sum-line { font-size: 15px; margin: 4px 0; color: var(--text); }
.mastery-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--divider); }
.mastery-row span { min-width: 0; overflow-wrap: anywhere; }
.mastery-row .btn { flex: 0 0 auto; margin: 0; }
.table-wrap { overflow-x: auto; margin-top: 12px; }
.leaderboard-table { width: 100%; border-collapse: collapse; min-width: 520px; font-size: 14px; }
.leaderboard-table th, .leaderboard-table td { padding: 9px 7px; border-bottom: 1px solid var(--divider); text-align: left; white-space: nowrap; }
.leaderboard-table th { color: var(--muted); font-weight: 600; }
.leaderboard-table tr.is-me { background: var(--primary-soft); font-weight: 600; }

@media (max-width: 420px) {
  .app { padding-left: 10px; padding-right: 10px; }
  .topbar { align-items: flex-start; gap: 8px; }
  .top-actions { flex-wrap: wrap; justify-content: flex-end; }
  .top-actions .btn { margin: 0; }
  .example-actions { flex-direction: column; }
}

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