:root {
  color-scheme: light;
  --ink: #10284d;
  --muted: #60708b;
  --paper: #f7fbff;
  --panel: #ffffff;
  --blue: #1769e0;
  --blue-dark: #12315f;
  --cyan: #24c6d9;
  --yellow: #ffd84d;
  --orange: #ff8d3a;
  --green: #1aa56b;
  --red: #e74b52;
  --line: #d8e5f4;
  --shadow: 0 20px 55px rgba(25, 68, 122, 0.13);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 8%, rgba(36, 198, 217, 0.16), transparent 27rem),
    radial-gradient(circle at 92% 18%, rgba(255, 216, 77, 0.25), transparent 23rem),
    linear-gradient(180deg, #eef7ff 0%, #fbfdff 72%);
}

button, input { font: inherit; }
button { cursor: pointer; }

.app-shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }

.topbar {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  background: none;
  border: 0;
  padding: 8px 0;
  text-align: left;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  color: white;
  background: var(--blue-dark);
  border-radius: 14px;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.14);
  font: 800 17px/1 ui-monospace, monospace;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 20px; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 13px; }

.ghost-button, .primary-button, .secondary-button, .lesson-button, .danger-button {
  min-height: 44px;
  border-radius: 14px;
  border: 1px solid var(--line);
  padding: 10px 18px;
  font-weight: 700;
}

.ghost-button, .secondary-button { color: var(--ink); background: rgba(255,255,255,.72); }
.primary-button { color: white; background: var(--blue); border-color: var(--blue); box-shadow: 0 10px 24px rgba(23,105,224,.24); }
.primary-button:hover { background: #0f5dca; }
.ghost-button:hover, .secondary-button:hover { background: #fff; border-color: #9fb8d3; }
.danger-button { color: #b82d3b; background: #fff5f5; border-color: #f2c8cd; }
.danger-button:hover { background: #ffe9eb; }

button:focus-visible, input:focus-visible {
  outline: 4px solid rgba(23, 105, 224, .28);
  outline-offset: 3px;
}

.home-grid {
  display: grid;
  grid-template-columns: 1.08fr .92fr;
  gap: 24px;
  padding: 36px 0 64px;
}

.welcome-card, .path-card, .practice-card {
  border: 1px solid rgba(200, 219, 239, .9);
  background: rgba(255, 255, 255, .88);
  box-shadow: var(--shadow);
}

.welcome-card { padding: clamp(28px, 5vw, 56px); border-radius: 32px; }
.eyebrow { margin: 0 0 8px; color: var(--blue); font-size: 14px; font-weight: 800; letter-spacing: .08em; }
h1 { margin: 0; max-width: 10ch; font-size: clamp(38px, 6vw, 70px); line-height: 1.02; letter-spacing: -.04em; }
.lead { max-width: 31em; margin: 22px 0 28px; color: var(--muted); font-size: 18px; line-height: 1.8; }
.button-row { display: flex; flex-wrap: wrap; gap: 12px; }

.overall-progress { margin: 0 0 24px; }
.overall-progress > div:first-child { display: flex; justify-content: space-between; gap: 18px; margin-bottom: 8px; font-size: 14px; }
.overall-progress strong { font-size: 15px; }
.progress-track, .mini-track { height: 10px; overflow: hidden; border-radius: 999px; background: #e7eef7; }
.progress-track span, .mini-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--cyan)); }

.path-list { display: grid; gap: 18px; }
.path-card { padding: 24px; border-radius: 26px; }
.path-number { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; color: var(--blue-dark); background: var(--yellow); font-weight: 900; }
.path-card-pinyin .path-number { color: white; background: var(--orange); }
.path-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.path-progress { padding: 6px 10px; color: var(--muted); background: #f0f5fb; border-radius: 999px; font-size: 13px; font-weight: 800; }
.path-card h2 { margin: 16px 0 6px; font-size: 25px; }
.path-card p { margin: 0; color: var(--muted); line-height: 1.65; }
.mini-track { height: 7px; margin: 18px 0; }

.lesson-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.lesson-button {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 2px 9px;
  min-height: 68px;
  padding: 11px;
  text-align: left;
  color: var(--ink);
  background: #f8fbff;
  border-color: #dce8f4;
}
.lesson-button:hover { background: #eef7ff; border-color: #a9c8ea; transform: translateY(-1px); }
.lesson-button > span { grid-row: 1 / 3; display: grid; place-items: center; width: 30px; height: 30px; color: white; background: var(--blue-dark); border-radius: 10px; }
.lesson-button strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.lesson-button small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.lesson-button.complete { background: #effbf5; border-color: #b9e7d1; }
.lesson-button.complete > span { background: var(--green); }

.practice-wrap { padding: 24px 0 60px; }
.practice-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.practice-toolbar h1 { max-width: none; font-size: clamp(28px, 4vw, 44px); }
.practice-card { border-radius: 30px; padding: clamp(22px, 4vw, 42px); }
.tip-box { padding: 14px 18px; background: #eff8ff; border-left: 5px solid var(--cyan); border-radius: 12px; line-height: 1.6; }

.hanzi-prompt { margin: 28px 0 0; text-align: center; }
.hanzi-prompt span, .ime-target span { display: block; margin-bottom: 8px; color: var(--muted); font-size: 14px; font-weight: 700; }
.hanzi-prompt strong { font-size: clamp(25px, 4vw, 40px); letter-spacing: .08em; }

.target-line {
  min-height: 96px;
  margin: 30px 0 22px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: 800 clamp(28px, 5vw, 54px)/1.35 ui-monospace, "SFMono-Regular", monospace;
}

.target-char { min-width: .78em; text-align: center; color: #8fa0b7; border-bottom: 4px solid transparent; }
.target-char:has(+ .target-char) { margin-right: 1px; }
.target-char.done { color: var(--green); }
.target-char.current { color: var(--ink); border-bottom-color: var(--orange); transform: translateY(-3px); }

.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 20px 0; }
.stat { padding: 14px; text-align: center; background: #f4f8fd; border-radius: 16px; }
.stat strong { display: block; font-size: 23px; }
.stat span { color: var(--muted); font-size: 13px; }

.keyboard { padding: 14px; background: #dce8f5; border: 1px solid #c3d5e8; border-radius: 22px; box-shadow: inset 0 -5px 0 #c3d5e8; overflow-x: auto; }
.key-row { display: flex; justify-content: center; gap: 7px; min-width: 720px; margin: 7px 0; }
.key {
  flex: 0 0 48px;
  min-height: 48px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--ink);
  background: white;
  border: 1px solid #bdcee1;
  box-shadow: 0 4px 0 #afc2d8;
  font: 800 15px/1 ui-monospace, monospace;
  transition: transform .1s ease, background .1s ease;
}
.key.wide { flex-basis: 82px; }
.key.space { flex-basis: 310px; }
.key.active { color: #10284d; background: var(--yellow); border-color: #e6b500; box-shadow: 0 4px 0 #d3a600; transform: translateY(-3px); }
.finger-hint { min-height: 28px; margin: 16px 0 0; text-align: center; font-weight: 800; color: var(--blue); }

.feedback-line { min-height: 26px; margin: 14px 0 0; text-align: center; font-weight: 800; }
.feedback-line[data-tone="error"] { color: var(--red); }
.feedback-line[data-tone="success"] { color: var(--green); }
.feedback-line[data-tone="neutral"] { color: var(--muted); }

.ime-stage { max-width: 760px; margin: 30px auto 12px; }
.ime-target { padding: 26px; text-align: center; background: linear-gradient(135deg, #edf8ff, #fff8d7); border: 1px solid #cfe2f5; border-radius: 22px; }
.ime-target strong { display: block; font-size: clamp(30px, 5vw, 52px); line-height: 1.4; letter-spacing: .04em; }
.ime-target small { display: block; margin-top: 10px; color: var(--blue); font-size: 15px; font-weight: 800; }
.ime-label { display: block; margin: 22px 0 8px; font-weight: 800; }
.ime-input, .parent-input {
  width: 100%;
  border: 2px solid #b8cce3;
  border-radius: 16px;
  color: var(--ink);
  background: white;
}
.ime-input { min-height: 70px; padding: 12px 18px; font-size: 26px; }
.ime-input:focus { border-color: var(--blue); }
.ime-actions { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 12px; }
.ime-actions p { margin: 0; color: var(--muted); line-height: 1.6; }

.result-card { max-width: 780px; margin: 36px auto 0; text-align: center; }
.result-card h1 { max-width: none; margin: 10px 0; font-size: clamp(32px, 5vw, 50px); }
.result-stars { color: #ffb800; font-size: clamp(44px, 8vw, 72px); letter-spacing: .08em; }
.result-card .lead { margin-left: auto; margin-right: auto; }
.result-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 560px; margin: 24px auto; }
.result-metrics > div { padding: 16px; background: #f2f7fc; border-radius: 16px; }
.result-metrics strong, .result-metrics span { display: block; }
.result-metrics strong { font-size: 24px; }
.result-metrics span { margin-top: 3px; color: var(--muted); font-size: 13px; }
.result-actions { justify-content: center; }

.parent-dialog { width: min(620px, calc(100% - 30px)); padding: 0; border: 0; border-radius: 24px; box-shadow: var(--shadow); }
.parent-dialog::backdrop { background: rgba(14, 34, 63, .48); backdrop-filter: blur(4px); }
.parent-dialog form { padding: 26px; }
.dialog-head { display: flex; justify-content: space-between; gap: 20px; }
.dialog-head h2 { margin: 0; font-size: 28px; }
.icon-button { width: 42px; height: 42px; border: 0; border-radius: 50%; background: #eef4fb; font-size: 24px; }
.empty-note { padding: 24px; color: var(--muted); background: #f5f8fc; border-radius: 16px; line-height: 1.7; }

.profile-row { margin: 24px 0 10px; }
.profile-row label { display: block; margin-bottom: 8px; font-weight: 800; }
.parent-input { min-height: 48px; padding: 9px 13px; font-size: 17px; }
.parent-section { margin-top: 24px; }
.parent-section h3 { margin: 0 0 12px; font-size: 18px; }
.weak-keys { display: flex; flex-wrap: wrap; gap: 10px; }
.weak-keys > span { min-width: 72px; padding: 12px; text-align: center; background: #fff7e2; border: 1px solid #f1d898; border-radius: 14px; }
.weak-keys strong, .weak-keys small { display: block; }
.weak-keys strong { font: 900 20px/1 ui-monospace, monospace; }
.weak-keys small { margin-top: 6px; color: var(--muted); }
.result-list { display: grid; gap: 8px; }
.result-list > div { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 11px 13px; background: #f5f8fc; border-radius: 12px; }
.result-list span, .result-list strong, .result-list small { display: block; }
.result-list small { margin-top: 3px; color: #f0a400; letter-spacing: .08em; }
.result-list b { color: var(--green); }
.parent-controls { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line); }
.sound-toggle { font-weight: 700; }
.sound-toggle input { width: 18px; height: 18px; vertical-align: -3px; }

@media (max-width: 820px) {
  .home-grid { grid-template-columns: 1fr; padding-top: 16px; }
  .topbar { min-height: 74px; }
  .brand small { display: none; }
  .app-shell { width: min(100% - 20px, 680px); }
  .practice-toolbar { align-items: flex-start; }
  .stats-row { grid-template-columns: 1fr; }
  .lesson-grid { grid-template-columns: 1fr; }
  .ime-actions, .parent-controls { align-items: stretch; flex-direction: column; }
  .result-metrics { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .brand strong { font-size: 17px; }
  .ghost-button { padding-inline: 12px; }
  .welcome-card, .path-card, .practice-card { border-radius: 22px; }
  .welcome-card { padding: 26px 22px; }
  h1 { font-size: 38px; }
  .target-line { justify-content: flex-start; font-size: 29px; }
}

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