:root {
  --ink: #18251f;
  --muted: #6c7771;
  --line: #dce4df;
  --surface: #ffffff;
  --background: #f4f7f2;
  --green: #16785f;
  --green-dark: #105d49;
  --green-soft: #e3f1eb;
  --blue: #31749b;
  --blue-soft: #e7f1f6;
  --red: #aa493f;
  --red-soft: #f5e7e4;
  --amber: #8a5c17;
  --amber-soft: #f7eed9;
  --shadow: 0 18px 50px rgba(33, 56, 46, 0.08);
}

* { box-sizing: border-box; }

html { background: var(--background); }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--background);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button, input { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  display: flex;
  width: 224px;
  flex-direction: column;
  padding: 28px 20px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 34px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  font-size: 23px;
  font-weight: 800;
}

.brand-name { font-size: 20px; font-weight: 800; }
.brand-subtitle { margin-top: 2px; color: var(--muted); font-size: 12px; }

.nav-list { display: grid; gap: 8px; }

.nav-item {
  position: relative;
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border: 0;
  border-radius: 7px;
  color: #526059;
  background: transparent;
  text-align: left;
  font-weight: 650;
}

.nav-item:hover { background: #f0f4f1; }
.nav-item.is-active { color: var(--green-dark); background: var(--green-soft); }
.nav-icon { font-size: 19px; text-align: center; }

.nav-badge {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 12px;
  line-height: 22px;
  text-align: center;
}

.sidebar-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 16px 8px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }

.main-content {
  min-height: 100vh;
  margin-left: 224px;
  padding: 54px clamp(28px, 6vw, 84px) 72px;
}

.view { display: none; width: min(960px, 100%); margin: 0 auto; }
.view.is-visible { display: block; animation: reveal 180ms ease-out; }

@keyframes reveal {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-header, .study-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.eyebrow { margin: 0 0 8px; color: var(--muted); font-size: 13px; font-weight: 650; }
h1 { margin: 0; font-size: clamp(32px, 4vw, 46px); line-height: 1.16; }
h2 { margin: 0; font-size: 20px; }

.streak-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 13px;
  border: 1px solid #cbd9d1;
  border-radius: 6px;
  color: var(--green-dark);
  background: #fff;
  font-size: 13px;
}

.today-layout { width: min(720px, 100%); margin-top: 42px; }

.focus-panel {
  position: relative;
  display: grid;
  min-height: 260px;
  grid-template-columns: 1fr 280px;
  overflow: hidden;
  border: 1px solid #cfdcd5;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.focus-copy { z-index: 1; padding: 42px 46px; }
.focus-kicker { margin: 0 0 12px; color: var(--green-dark); font-size: 14px; font-weight: 750; }
.focus-number { font-size: 88px; font-weight: 850; line-height: 0.95; }
.focus-label { margin: 12px 0 0; font-size: 22px; font-weight: 700; }
.focus-time { margin: 12px 0 0; color: var(--muted); font-size: 14px; }

.focus-visual {
  position: relative;
  min-height: 260px;
  overflow: hidden;
  background: #e6f1ec;
}

.orbit { position: absolute; border: 1px solid rgba(22, 120, 95, 0.24); border-radius: 50%; }
.orbit-one { width: 250px; height: 250px; top: -40px; right: -30px; }
.orbit-two { width: 170px; height: 170px; right: 42px; bottom: -52px; }

.word-tile {
  position: absolute;
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border: 1px solid rgba(20, 94, 73, 0.15);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 30px rgba(20, 70, 53, 0.12);
  color: var(--green-dark);
  font-size: 28px;
  font-weight: 800;
}

.tile-one { top: 46px; left: 38px; transform: rotate(-8deg); }
.tile-two { top: 94px; right: 36px; transform: rotate(6deg); }
.tile-three { bottom: 38px; left: 84px; color: #aa6b1d; transform: rotate(4deg); }

.task-breakdown {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 22px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.task-stat { display: flex; align-items: center; gap: 12px; padding: 22px 24px; }
.task-stat + .task-stat { border-left: 1px solid var(--line); }
.task-stat div { display: flex; flex-direction: column; gap: 3px; }
.task-stat strong { font-size: 25px; }
.task-stat span:last-child { color: var(--muted); font-size: 12px; }
.stat-dot { width: 10px; height: 10px; border-radius: 50%; }
.stat-dot.new { background: var(--green); }
.stat-dot.review { background: var(--blue); }
.stat-dot.weak { background: var(--red); }

.button {
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-weight: 720;
}

.primary-button { color: #fff; background: var(--green); }
.primary-button:hover { background: var(--green-dark); }
.wide-button { width: 100%; min-height: 54px; font-size: 16px; }
.wide-button span { margin-left: 8px; }
.secondary-button { border-color: #bdcbc3; color: var(--green-dark); background: #fff; }
.text-button { padding-inline: 8px; color: var(--muted); background: transparent; }
.danger-soft { color: var(--red); background: var(--red-soft); }
.warning-soft { color: var(--amber); background: var(--amber-soft); }
.helper-text { margin: 14px 0 0; color: var(--muted); font-size: 12px; text-align: center; }

.progress-label { color: var(--muted); font-size: 14px; }
.progress-track { height: 7px; margin-top: 22px; overflow: hidden; border-radius: 4px; background: #dde5e0; }
.progress-fill { width: 0; height: 100%; border-radius: 4px; background: var(--green); transition: width 180ms ease; }

.study-card { margin-top: 28px; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: var(--shadow); }
.word-meta { display: flex; justify-content: space-between; padding: 22px 30px 0; color: var(--muted); font-size: 12px; }
.word-display { padding: 40px 30px 0; font-size: clamp(58px, 9vw, 92px); font-weight: 850; line-height: 1; text-align: center; overflow-wrap: anywhere; }
.phonetic { margin-top: 16px; color: var(--muted); font-size: 21px; text-align: center; }

.speech-actions { display: flex; justify-content: center; gap: 12px; margin-top: 30px; }
.icon-button { border: 0; }
.speech-button { display: inline-flex; min-height: 44px; align-items: center; gap: 8px; padding: 0 17px; border-radius: 7px; font-weight: 700; }
.english-speech { color: var(--green-dark); background: var(--green-soft); }
.chinese-speech { color: #80571d; background: var(--amber-soft); }
.sound-icon { font-size: 12px; }

.meaning { margin-top: 34px; font-size: 28px; font-weight: 800; text-align: center; }
.example-block { padding: 17px 30px 30px; color: #34433c; text-align: center; }
.example-block p { margin: 5px 0; }
.example-block p:last-child { color: var(--muted); font-size: 14px; }

.pronunciation-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 110px;
  padding: 20px 24px;
  border-top: 1px solid var(--line);
  background: #fafcfa;
}

.mic-button {
  display: grid;
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-size: 18px;
}

.mic-button.is-listening { animation: pulse 1.1s infinite; background: #7f322c; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(170, 73, 63, 0.14); } }
.pronunciation-zone strong { display: block; font-size: 15px; }
.pronunciation-zone p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.pronunciation-zone.is-good { background: #edf7f2; }
.pronunciation-zone.is-retry { background: #fbf0ee; }

.answer-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 20px 24px 24px; border-top: 1px solid var(--line); }
.study-empty, .empty-list { padding: 100px 24px; text-align: center; }
.study-empty p, .empty-list p { max-width: 480px; margin: 12px auto 28px; color: var(--muted); line-height: 1.7; }
.finish-check { display: grid; width: 76px; height: 76px; place-items: center; margin: 0 auto 24px; border-radius: 50%; color: #fff; background: var(--green); font-size: 38px; }

.section-line { height: 1px; margin-top: 32px; background: var(--line); }
.weak-list { margin-top: 12px; }
.weak-row { display: grid; grid-template-columns: 1fr 1fr 100px; align-items: center; min-height: 88px; border-bottom: 1px solid var(--line); }
.weak-word strong { display: block; font-size: 22px; }
.weak-word span, .weak-reason small { color: var(--muted); font-size: 12px; }
.weak-reason { text-align: right; }
.weak-reason strong { display: block; color: var(--red); font-size: 13px; }
.weak-play { justify-self: end; width: 42px; height: 42px; border: 1px solid #cbd7d0; border-radius: 50%; color: var(--green); background: #fff; }
.empty-symbol { color: var(--green); font-size: 72px; line-height: 1; }

.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 40px; border: 1px solid var(--line); border-radius: 8px; background: #fff; overflow: hidden; }
.summary-cell { display: flex; min-height: 112px; flex-direction: column; justify-content: center; padding: 22px 26px; }
.summary-cell + .summary-cell { border-left: 1px solid var(--line); }
.summary-cell strong { font-size: 36px; }
.summary-cell span { margin-top: 7px; color: var(--muted); font-size: 12px; }
.summary-cell.mastered strong { color: var(--green); }
.summary-cell.weak strong { color: var(--red); }

.parent-section { margin-top: 38px; padding-top: 28px; border-top: 1px solid var(--line); }
.week-chart { display: grid; grid-template-columns: repeat(7, 1fr); gap: 12px; margin-top: 24px; }
.week-day { text-align: center; }
.week-dot { display: grid; width: 46px; height: 46px; place-items: center; margin: 0 auto; border: 1px solid #d1dbd5; border-radius: 50%; color: transparent; background: #fff; }
.week-dot.done { border-color: var(--green); color: #fff; background: var(--green); }
.week-label { margin-top: 8px; color: var(--muted); font-size: 11px; }

.settings-section { display: grid; gap: 0; }
.setting-row { position: relative; display: flex; align-items: center; justify-content: space-between; min-height: 84px; border-bottom: 1px solid var(--line); }
.setting-row span { display: flex; flex-direction: column; gap: 5px; }
.setting-row strong { font-size: 15px; }
.setting-row small { color: var(--muted); }
.setting-row input[type="time"] { padding: 8px 10px; border: 1px solid #c9d5ce; border-radius: 6px; color: var(--green-dark); background: #fff; }
.range-setting { padding-bottom: 24px; }
.range-setting input[type="range"] { position: absolute; right: 0; bottom: 5px; width: min(340px, 48%); accent-color: var(--green); }
.range-setting output { color: var(--green-dark); font-weight: 700; }

.section-heading-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.section-heading-row p { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.word-count-pill { padding: 8px 11px; border-radius: 6px; color: var(--green-dark); background: var(--green-soft); font-size: 12px; }
.import-actions { display: flex; align-items: center; gap: 12px; margin-top: 24px; }
.file-button { display: inline-grid; place-items: center; cursor: pointer; }
.import-status { margin: 14px 0 0; color: var(--muted); font-size: 12px; }
.import-status.success { color: var(--green-dark); }
.import-status.error { color: var(--red); }
.reset-button { margin-top: 46px; padding-inline: 0; color: var(--red); background: transparent; }

.toast {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: 30px;
  max-width: calc(100vw - 32px);
  padding: 11px 16px;
  border-radius: 6px;
  color: #fff;
  background: #24362e;
  box-shadow: 0 12px 30px rgba(20, 40, 31, 0.2);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: 160ms ease;
  font-size: 13px;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
  .sidebar {
    inset: auto 0 0;
    width: 100%;
    height: 70px;
    padding: 7px max(8px, env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    border-top: 1px solid var(--line);
    border-right: 0;
  }
  .brand, .sidebar-note { display: none; }
  .nav-list { grid-template-columns: repeat(4, 1fr); gap: 4px; }
  .nav-item { display: flex; min-height: 54px; flex-direction: column; justify-content: center; gap: 2px; padding: 0 2px; font-size: 11px; text-align: center; }
  .nav-icon { font-size: 17px; }
  .nav-badge { position: absolute; top: 3px; left: calc(50% + 9px); }
  .main-content { margin-left: 0; padding: 30px 18px calc(100px + env(safe-area-inset-bottom)); }
  .page-header, .study-header { align-items: flex-start; }
  h1 { font-size: 33px; }
  .streak-pill { margin-top: 4px; white-space: nowrap; }
  .today-layout { margin-top: 28px; }
  .focus-panel { min-height: 230px; grid-template-columns: 1fr 145px; }
  .focus-copy { padding: 32px 25px; }
  .focus-number { font-size: 72px; }
  .focus-visual { min-height: 230px; }
  .word-tile { width: 52px; height: 52px; font-size: 22px; }
  .tile-one { top: 36px; left: 16px; }
  .tile-two { top: 95px; right: 14px; }
  .tile-three { bottom: 26px; left: 38px; }
  .task-stat { gap: 8px; padding: 18px 12px; }
  .task-stat strong { font-size: 22px; }
  .study-card { margin-top: 22px; }
  .word-meta { padding: 18px 20px 0; }
  .word-display { padding-top: 32px; font-size: 62px; }
  .meaning { margin-top: 28px; }
  .pronunciation-zone { justify-content: flex-start; }
  .answer-actions { gap: 7px; padding: 15px; }
  .answer-actions .button { min-height: 48px; padding: 0 6px; font-size: 13px; }
  .weak-row { grid-template-columns: 1fr 1fr 48px; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .summary-cell:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .summary-cell:nth-child(4) { border-top: 1px solid var(--line); }
  .summary-cell { min-height: 96px; }
  .week-chart { gap: 4px; }
  .week-dot { width: 39px; height: 39px; }
  .range-setting { display: grid; grid-template-columns: 1fr auto; }
  .range-setting input[type="range"] { position: static; grid-column: 1 / -1; width: 100%; margin-top: 14px; }
}

@media (max-width: 430px) {
  #view-today .page-header { flex-direction: column; align-items: flex-start; gap: 14px; }
  .focus-panel { grid-template-columns: 1fr 112px; }
  .focus-copy { padding: 30px 20px; }
  .focus-label { font-size: 18px; }
  .task-breakdown { grid-template-columns: 1fr; }
  .task-stat + .task-stat { border-top: 1px solid var(--line); border-left: 0; }
  .speech-actions { gap: 8px; }
  .speech-button { padding: 0 12px; font-size: 13px; }
  .page-header .primary-button { padding: 0 12px; }
}

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

[hidden] { display: none !important; }

.auth-screen {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(420px, 0.9fr) minmax(420px, 1.1fr);
  background: #fff;
}

.login-panel {
  display: flex;
  width: min(520px, 100%);
  flex-direction: column;
  justify-content: center;
  padding: 48px clamp(34px, 6vw, 88px);
}

.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 72px; }
.login-brand img { width: 58px; height: 58px; border-radius: 12px; object-fit: cover; }
.login-brand-name { font-size: 23px; font-weight: 820; }
.login-brand-copy { margin-top: 4px; color: var(--muted); font-size: 13px; }
.login-heading h1 { font-size: 38px; }
.login-form { display: grid; gap: 20px; margin-top: 34px; }
.login-form label, .child-form label { display: grid; gap: 8px; color: #4f5d56; font-size: 13px; font-weight: 680; }
.login-form input, .child-form input {
  width: 100%;
  height: 48px;
  padding: 0 13px;
  border: 1px solid #cbd6d0;
  border-radius: 7px;
  outline: none;
  color: var(--ink);
  background: #fff;
}
.login-form input:focus, .child-form input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(22, 120, 95, 0.12); }
.login-button { min-height: 50px; margin-top: 4px; font-size: 16px; }
.login-button:disabled { cursor: wait; opacity: 0.65; }
.login-error { min-height: 20px; margin: -5px 0 0; color: var(--red); font-size: 13px; }
.login-help { margin: 20px 0 0; color: var(--muted); font-size: 12px; line-height: 1.7; }

.login-visual {
  position: relative;
  display: grid;
  overflow: hidden;
  place-items: center;
  background: #dfeee8;
}
.login-visual::before, .login-visual::after {
  position: absolute;
  width: 460px;
  height: 460px;
  border: 1px solid rgba(22, 120, 95, 0.24);
  border-radius: 50%;
  content: "";
}
.login-visual::after { width: 650px; height: 650px; }
.login-visual-content { z-index: 1; display: grid; grid-template-columns: repeat(3, 112px); gap: 18px; }
.login-visual-content span {
  display: grid;
  width: 112px;
  height: 112px;
  place-items: center;
  border: 1px solid rgba(22, 120, 95, 0.16);
  border-radius: 8px;
  color: var(--green-dark);
  background: #fff;
  box-shadow: 0 16px 40px rgba(24, 73, 55, 0.1);
  font-size: 17px;
  font-weight: 800;
}

.brand-avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 8px;
  object-fit: cover;
}
.sidebar-note img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.account-copy { display: flex; min-width: 0; flex: 1; flex-direction: column; gap: 2px; }
.account-copy strong { overflow: hidden; color: var(--ink); text-overflow: ellipsis; white-space: nowrap; }
.account-copy small { color: var(--muted); font-size: 10px; }
.logout-button { width: 30px; height: 30px; padding: 0; border: 0; color: var(--muted); background: transparent; font-size: 18px; }
.logout-button:hover { color: var(--red); }

.child-form {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  align-items: end;
  gap: 12px;
  margin-top: 24px;
}
.child-form .button { height: 48px; white-space: nowrap; }
.account-status { min-height: 18px; margin: 14px 0 0; color: var(--muted); font-size: 12px; }
.account-status.error { color: var(--red); }
.account-status.success { color: var(--green-dark); }
.children-list { margin-top: 10px; }
.child-row {
  display: grid;
  grid-template-columns: minmax(140px, 1.2fr) repeat(4, minmax(70px, 0.7fr)) auto;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  border-bottom: 1px solid var(--line);
}
.child-identity strong { display: block; }
.child-identity small, .child-metric span { color: var(--muted); font-size: 11px; }
.child-metric { display: flex; flex-direction: column; gap: 3px; text-align: center; }
.child-metric strong { font-size: 19px; }
.password-button { min-height: 36px; padding: 0 10px; border: 1px solid #cbd6d0; color: var(--green-dark); background: #fff; font-size: 12px; }

@media (max-width: 900px) and (min-width: 761px) {
  .auth-screen { grid-template-columns: 1fr 0.8fr; }
  .login-visual-content { grid-template-columns: repeat(2, 96px); }
  .login-visual-content span { width: 96px; height: 96px; }
  .child-form { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  .auth-screen { display: block; min-height: 100vh; }
  .login-panel { width: 100%; min-height: 100vh; justify-content: flex-start; padding: 32px 24px 48px; }
  .login-brand { margin-bottom: 64px; }
  .login-visual { display: none; }
  .child-form { grid-template-columns: 1fr; }
  .child-row { grid-template-columns: 1fr 1fr; padding: 14px 0; }
  .child-identity { grid-column: 1 / -1; }
  .password-button { grid-column: 1 / -1; }
}
