:root {
  --ink: #17233f;
  --muted: #66728a;
  --line: #dce3ee;
  --paper: #ffffff;
  --canvas: #f5f7fb;
  --blue: #3157d5;
  --blue-dark: #2542a7;
  --blue-soft: #eaf0ff;
  --orange: #f47e49;
  --orange-soft: #fff0e9;
  --green: #168b79;
  --green-soft: #e4f7f2;
  --shadow: 0 18px 45px rgba(42, 61, 96, .10);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 90% 0%, rgba(49, 87, 213, .10), transparent 30%),
    linear-gradient(140deg, #f5f7fb 0%, #fbfcff 55%, #f4faf8 100%);
}
body.is-typing { background: linear-gradient(145deg, #f5f7fb, #fff9f5 60%, #f6f9ff); }
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(49, 87, 213, .28); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(20px, 3vw, 31px); letter-spacing: -.03em; line-height: 1.1; }
h2 { font-size: clamp(28px, 5vw, 45px); letter-spacing: -.045em; line-height: 1.05; }
h3 { font-size: clamp(20px, 3vw, 28px); letter-spacing: -.03em; line-height: 1.1; }
[hidden] { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 45px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 15px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid rgba(23, 35, 63, .10);
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(18px);
}
.brand { min-width: 0; }
.brand h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eyebrow {
  color: var(--blue);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.brand .eyebrow { margin-bottom: 6px; }
.icon-button {
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 14px;
}
.home-button { width: 45px; height: 45px; color: #fff; background: var(--blue); font-size: 25px; font-weight: 950; }
.header-meta {
  padding: 9px 13px;
  border-radius: 999px;
  color: var(--blue-dark);
  background: var(--blue-soft);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

main { width: min(1180px, 100%); margin: 0 auto; padding: 22px clamp(16px, 3.4vw, 38px) 42px; }
.home-intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 30px;
  align-items: end;
  padding: clamp(24px, 5vw, 52px);
  border-radius: 30px;
  color: #fff;
  background: linear-gradient(132deg, #213a98 0%, #3157d5 52%, #6884e8 100%);
  box-shadow: 0 22px 55px rgba(49, 87, 213, .22);
  overflow: hidden;
}
.home-intro::after {
  content: "";
  width: 330px;
  height: 330px;
  position: absolute;
  margin: -140px -80px 0 0;
  right: 0;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 50%;
  box-shadow: 0 0 0 30px rgba(255,255,255,.05), 0 0 0 60px rgba(255,255,255,.035);
  pointer-events: none;
}
.home-intro { position: relative; }
.home-intro .eyebrow { color: #c9d5ff; }
.home-intro h2 { max-width: 720px; margin-top: 10px; }
.intro-copy > p:not(.eyebrow) { max-width: 680px; margin-top: 18px; color: #e8edff; font-size: 16px; line-height: 1.75; }
.intro-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.intro-chips span { padding: 7px 10px; border: 1px solid rgba(255,255,255,.24); border-radius: 999px; color: #f4f6ff; background: rgba(255,255,255,.10); font-size: 12px; font-weight: 800; }
.intro-stat-card { position: relative; z-index: 1; display: grid; gap: 8px; padding: 22px; border: 1px solid rgba(255,255,255,.24); border-radius: 22px; background: rgba(255,255,255,.12); }
.intro-stat-card span { color: #dce5ff; font-size: 13px; font-weight: 750; line-height: 1.45; }
.intro-stat-card strong { font-size: 55px; letter-spacing: -.08em; line-height: .9; }
.stat-kicker { color: #fff !important; font-size: 12px !important; font-weight: 900 !important; letter-spacing: .10em; text-transform: uppercase; }

.overview-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; margin: 15px 0 36px; border: 1px solid var(--line); border-radius: 18px; background: var(--line); overflow: hidden; }
.overview-strip div { display: grid; gap: 5px; padding: 17px; background: rgba(255,255,255,.76); }
.overview-strip strong { color: var(--blue); font-size: 25px; letter-spacing: -.04em; }
.overview-strip span { color: var(--muted); font-size: 12px; font-weight: 800; }
.selector-section, .sentence-section { margin-top: 32px; }
.section-heading { display: flex; justify-content: space-between; gap: 14px; align-items: end; margin-bottom: 16px; }
.section-heading h2 { margin-top: 7px; font-size: clamp(25px, 4vw, 35px); }
.section-note { max-width: 320px; color: var(--muted); font-size: 13px; font-weight: 700; line-height: 1.5; text-align: right; }
.day-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.day-card, .unit-card, .sentence-card { border: 1px solid var(--line); border-radius: 20px; background: var(--paper); box-shadow: 0 12px 30px rgba(42,61,96,.07); }
.day-card { position: relative; display: grid; gap: 14px; min-height: 152px; padding: 19px; color: var(--ink); text-align: left; overflow: hidden; transition: transform .18s ease, box-shadow .18s ease; }
.day-card::after { content: ""; position: absolute; right: -35px; bottom: -58px; width: 150px; height: 150px; border: 25px solid rgba(49,87,213,.08); border-radius: 50%; }
.day-card:hover, .unit-card:hover, .sentence-card:hover { transform: translateY(-3px); box-shadow: 0 18px 35px rgba(42,61,96,.12); }
.day-card:nth-child(2n) { background: linear-gradient(140deg, #fff, #fff8ef); }
.day-card:nth-child(3n) { background: linear-gradient(140deg, #fff, #f0f4ff); }
.day-label { color: var(--orange); font-size: 12px; font-weight: 950; letter-spacing: .08em; text-transform: uppercase; }
.day-card strong { max-width: 230px; font-size: 20px; line-height: 1.13; }
.day-card small { color: var(--muted); font-size: 13px; font-weight: 750; }
.arrow { position: absolute; right: 17px; top: 18px; color: var(--blue); font-size: 22px; font-weight: 900; }
.unit-picker { margin-top: 18px; padding: 18px; border: 1px solid var(--line); border-radius: 23px; background: rgba(255,255,255,.65); }
.picker-heading { display: flex; gap: 20px; align-items: center; margin-bottom: 15px; }
.picker-heading h3 { margin-top: 5px; font-size: 22px; }
.text-button { border: 0; padding: 0; color: var(--blue); background: transparent; font-size: 13px; font-weight: 900; }
.text-button:hover { color: var(--blue-dark); text-decoration: underline; }
.unit-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.unit-card { display: grid; gap: 10px; min-height: 108px; padding: 16px; color: var(--ink); text-align: left; transition: transform .18s ease, box-shadow .18s ease; }
.unit-card strong { font-size: 17px; line-height: 1.2; }
.unit-card small { color: var(--muted); font-size: 12px; font-weight: 750; line-height: 1.4; }
.unit-card .unit-play { align-self: end; color: var(--green); font-size: 12px; font-weight: 900; }
.sentence-section { padding-top: 8px; }
.sentence-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; }
.sentence-card { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 15px; }
.sentence-card strong { font-size: 14px; line-height: 1.25; }
.sentence-card small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; font-weight: 700; }
.sentence-card button { flex: 0 0 auto; width: 37px; height: 37px; border: 0; border-radius: 12px; color: #fff; background: var(--green); font-weight: 900; }

.unit-banner { display: flex; justify-content: space-between; gap: 26px; align-items: end; padding: 22px 24px; border: 1px solid var(--line); border-radius: 24px; background: rgba(255,255,255,.86); box-shadow: var(--shadow); }
.unit-banner .text-button { display: inline-block; margin-bottom: 21px; }
.unit-title { margin-top: 7px; }
.unit-description { max-width: 690px; margin-top: 11px; color: var(--muted); font-size: 13px; font-weight: 700; line-height: 1.5; }
.unit-banner-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.primary-button, .secondary-button, .accent-button { min-height: 42px; border: 0; border-radius: 12px; padding: 0 14px; font-size: 13px; font-weight: 900; transition: filter .15s ease, transform .15s ease; }
.primary-button { color: #fff; background: var(--blue); }
.secondary-button { color: var(--ink); background: #edf1f7; }
.accent-button { color: #a64a22; background: var(--orange-soft); }
.primary-button:hover, .secondary-button:hover, .accent-button:hover { filter: brightness(.97); transform: translateY(-1px); }
.view-tabs { display: flex; gap: 5px; margin: 18px 0 12px; padding: 5px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.8); width: fit-content; }
.tab-button { min-height: 35px; border: 0; border-radius: 9px; padding: 0 14px; color: var(--muted); background: transparent; font-size: 13px; font-weight: 900; }
.tab-button.is-active { color: var(--blue-dark); background: var(--blue-soft); }
.controls-card { display: grid; grid-template-columns: minmax(220px, 1fr) auto; gap: 13px; align-items: end; margin-bottom: 15px; padding: 14px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.77); }
.search-box { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 900; }
input[type="search"], input[type="text"], .typing-form input { min-width: 0; height: 43px; border: 1px solid #cbd5e6; border-radius: 12px; padding: 0 13px; color: var(--ink); background: #fcfdff; font-size: 15px; }
.control-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.audio-mode-note { display: inline-flex; min-height: 42px; flex-direction: column; justify-content: center; gap: 2px; padding: 0 12px; border: 1px solid #cfe7df; border-radius: 12px; color: var(--green); background: var(--green-soft); font-size: 10px; font-weight: 800; line-height: 1.1; }
.audio-mode-note strong { font-size: 12px; letter-spacing: .01em; }
.word-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.word-card { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 12px; min-height: 132px; padding: 15px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.95); box-shadow: 0 9px 24px rgba(42,61,96,.06); }
.word-card.is-playing { border-color: var(--green); box-shadow: 0 0 0 3px rgba(22,139,121,.15); }
.play-button, .round-play-button { width: 44px; height: 44px; border: 0; border-radius: 14px; color: #fff; background: var(--green); font-weight: 950; }
.word-main { min-width: 0; }
.word-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.word-no { color: var(--orange); font-size: 11px; font-weight: 950; }
.word-text { min-width: 0; border: 0; padding: 0; color: var(--ink); background: transparent; font-size: 22px; font-weight: 950; line-height: 1.12; text-align: left; overflow-wrap: anywhere; }
.word-text:hover { color: var(--blue); }
.phonetic { flex: 0 1 auto; color: var(--green); font-size: 12px; font-weight: 800; line-height: 1.25; overflow-wrap: anywhere; }
.star-button { flex: 0 0 auto; width: 34px; height: 34px; border: 0; border-radius: 10px; color: #9aa5b7; background: #f0f3f7; font-size: 21px; font-weight: 950; line-height: 1; }
.star-button[aria-pressed="true"] { color: #fff; background: var(--orange); }
.meaning { margin-top: 9px; color: #41506b; font-size: 15px; font-weight: 750; line-height: 1.45; }
.example { margin-top: 7px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.audio-status { min-height: 17px; margin-top: 7px; color: #b35424; font-size: 11px; font-weight: 750; }
body.hide-chinese .chinese { display: none; }
.empty-state { grid-column: 1 / -1; padding: 38px 18px; border: 1px dashed #c7d2e3; border-radius: 18px; color: var(--muted); background: rgba(255,255,255,.74); text-align: center; }

.typing-view { margin-top: 5px; }
.typing-layout { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 14px; align-items: start; }
.typing-card, .typing-side-card { border: 1px solid var(--line); border-radius: 25px; background: rgba(255,255,255,.92); box-shadow: var(--shadow); }
.typing-card { min-height: 480px; padding: clamp(20px, 4vw, 38px); }
.typing-card-top { display: flex; justify-content: space-between; align-items: start; }
.typing-progress { margin-top: 6px; color: var(--ink); font-size: 16px; font-weight: 950; }
.round-play-button { width: 52px; height: 52px; border-radius: 17px; background: var(--orange); font-size: 18px; }
.typing-prompt { display: grid; justify-items: center; gap: 10px; margin: 50px auto 31px; text-align: center; }
.prompt-label { color: var(--orange); font-size: 12px; font-weight: 950; letter-spacing: .16em; }
.typing-prompt h3 { font-size: clamp(24px, 4vw, 37px); }
.typing-hint-row { display: flex; min-height: 35px; justify-content: center; align-items: center; gap: 8px; flex-wrap: wrap; }
.typing-hint { color: var(--muted); font-size: 16px; font-weight: 750; line-height: 1.45; }
.hint-button { min-height: 34px; border: 1px solid #cbd5e6; border-radius: 999px; padding: 0 12px; color: var(--blue-dark); background: #f5f7fb; font-size: 12px; font-weight: 900; }
.hint-button:hover { border-color: #9eafd0; background: var(--blue-soft); }
.hint-button[aria-pressed="true"] { border-color: #b7dcd3; color: var(--green); background: var(--green-soft); }
.hint-button:disabled { cursor: not-allowed; opacity: .55; }
.typing-form { display: grid; gap: 7px; width: min(650px, 100%); margin: 0 auto; }
.typing-form label { color: var(--muted); font-size: 12px; font-weight: 900; }
.typing-input-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.typing-form input { height: 54px; border-width: 2px; font-size: 20px; }
.typing-form input:focus { border-color: var(--blue); }
.typing-input-row .primary-button { min-height: 54px; padding-inline: 20px; }
.typing-result { width: min(650px, 100%); min-height: 28px; margin: 15px auto 0; text-align: center; font-size: 16px; font-weight: 950; }
.typing-result.correct { color: var(--green); }
.typing-result.wrong { color: #bc592a; }
.typing-answer { width: min(650px, 100%); margin: 6px auto 0; padding: 12px 15px; border-radius: 13px; color: var(--ink); background: var(--orange-soft); font-size: 15px; font-weight: 850; text-align: center; }
.typing-actions { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 24px; }
.typing-side-card { display: grid; gap: 14px; padding: 19px; }
.side-score { display: grid; gap: 4px; padding-bottom: 5px; }
.side-score span, .score-row span, .typing-side-card > p { color: var(--muted); font-size: 12px; font-weight: 800; }
.side-score strong { color: var(--blue); font-size: 38px; letter-spacing: -.06em; }
.score-row { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.score-row strong { font-size: 18px; }
.typing-side-card hr { width: 100%; margin: 1px 0; border: 0; border-top: 1px solid var(--line); }
.shortcut { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12px; font-weight: 750; }
kbd { display: inline-grid; place-items: center; min-width: 25px; height: 24px; border: 1px solid #cbd5e6; border-bottom-width: 2px; border-radius: 6px; color: var(--ink); background: #f5f7fb; font-size: 11px; font-weight: 950; }
.typing-side-card .text-button { margin-top: 4px; text-align: left; }
.footer-note { padding: 0 16px 28px; color: #8792a4; font-size: 11px; font-weight: 700; text-align: center; }

@media (max-width: 900px) {
  .home-intro { grid-template-columns: 1fr; }
  .intro-stat-card { width: min(260px, 100%); }
  .unit-banner { display: grid; align-items: start; }
  .unit-banner-actions { justify-content: flex-start; }
  .typing-layout { grid-template-columns: 1fr; }
  .typing-side-card { grid-template-columns: repeat(4, 1fr); align-items: center; }
  .side-score { grid-column: 1 / -1; }
  .typing-side-card hr, .typing-side-card > p { display: none; }
  .shortcut { display: none; }
  .typing-side-card .text-button { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .topbar { grid-template-columns: 42px minmax(0, 1fr); }
  .home-button { width: 42px; height: 42px; }
  .header-meta { grid-column: 2; width: fit-content; }
  .day-grid, .unit-grid, .sentence-grid, .word-grid { grid-template-columns: 1fr; }
  .overview-strip strong { font-size: 21px; }
  .overview-strip div { padding: 13px 11px; }
  .section-heading { display: grid; align-items: start; }
  .section-note { text-align: left; }
  .controls-card { grid-template-columns: 1fr; }
  .control-actions { justify-content: flex-start; }
  .word-card { grid-template-columns: 40px minmax(0, 1fr); }
  .play-button { width: 40px; height: 40px; }
  .typing-card { min-height: 0; padding: 22px 16px 26px; }
  .typing-prompt { margin-top: 38px; }
  .typing-input-row { grid-template-columns: 1fr; }
  .typing-input-row .primary-button { width: 100%; }
  .typing-side-card { grid-template-columns: repeat(2, 1fr); }
  .picker-heading { display: grid; align-items: start; gap: 10px; }
}
