:root {
  color-scheme: light;
  --blue: #2158df;
  --blue-soft: #edf2ff;
  --ink: #172c49;
  --muted: #66748a;
  --line: #e2e7ee;
  --bg: #fafbfd;
  --green: #23745c;
  --orange: #97600d;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 300px; }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { cursor: pointer; color: inherit; }
button:disabled { cursor: default; }
a { color: inherit; }
button, a, input, select { outline-offset: 4px; }
:focus-visible { outline: 3px solid #779eff; }
[hidden] { display: none !important; }
h1, h2, p { margin-top: 0; }
button, a, select { transition: background-color .18s, border-color .18s, color .18s, box-shadow .18s; }
.site-header {
  max-width: 1168px; margin: auto; padding: 24px 36px;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; font-size: 15px; font-weight: 650; letter-spacing: -.2px; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: var(--blue); color: white; font-size: 26px; font-weight: 500; box-shadow: 0 3px 8px #2158df1a; }
.brand small { display: block; margin-top: 3px; font-size: 11px; color: var(--muted); font-weight: 500; letter-spacing: .1px; }
.header-link { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: white; font-size: 13px; font-weight: 550; text-decoration: none; }
.header-link svg { width: 17px; height: 17px; flex: none; color: var(--muted); }
.header-link:hover { border-color: #bdcef5; background: var(--blue-soft); color: var(--blue); }
main { max-width: 1120px; margin: 0 auto; padding: 34px 36px 32px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; padding: 13px 22px; border: 1px solid transparent; border-radius: 10px; font-size: 14px; font-weight: 600; line-height: 1.4; }
.button.primary { color: white; background: var(--blue); box-shadow: 0 3px 7px #2158df1a; }
.button.primary:hover:not(:disabled) { background: #194bc8; box-shadow: 0 5px 12px #2158df26; }
.button.primary:active:not(:disabled) { background: #1643b5; box-shadow: none; }
.button.primary:disabled { background: #e9edf5; color: var(--muted); box-shadow: none; }
.button svg { width: 19px; height: 19px; flex: none; }

/* Start with the word, then offer a few small, useful starting points. */
.home-view { max-width: 960px; margin: auto; }
.intro { max-width: 720px; margin: 12px auto 30px; text-align: center; }
.eyebrow { display: inline-block; padding: 6px 12px; border: 1px solid #dfe8fc; border-radius: 20px; background: #f0f4ff; color: var(--blue); font-size: 10px; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase; line-height: 1.8; }
.intro h1 { margin: 20px 0 17px; font-size: clamp(40px, 4.6vw, 56px); line-height: 1.08; font-weight: 650; letter-spacing: -2.3px; }
.intro h1 span { color: var(--blue); }
.intro p { margin: 0 auto; color: var(--muted); font-size: 15px; line-height: 1.75; text-wrap: balance; }
.word-form { max-width: 560px; margin: 0 auto; padding: 24px; border: 1px solid #dce4f1; border-radius: 20px; background: white; box-shadow: 0 12px 36px #172c4907, 0 2px 6px #172c4903; }
.word-form label { display: block; margin-bottom: 14px; font-size: 13px; font-weight: 600; }
.input-row { display: flex; flex-direction: column; gap: 14px; }
.input-row input { width: 100%; min-width: 0; padding: 17px 16px; border: 1px solid #d6dfec; border-radius: 10px; background: #fcfdff; color: var(--ink); font-size: 30px; line-height: 1.4; text-align: center; transition: border-color .18s, box-shadow .18s; }
.input-row input::placeholder { color: #a2afc3; }
.input-row input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px #2158df10; outline: none; }
.input-row .button { width: 100%; }
.input-row .button svg { margin-left: auto; }
.input-row .button::before { content: ''; width: 19px; margin-right: auto; }
.input-details { display: flex; justify-content: space-between; gap: 10px; margin-top: 13px; color: var(--muted); font-size: 11px; line-height: 1.5; }
#input-count { white-space: nowrap; font-variant-numeric: tabular-nums; }
.input-error { margin: 14px 0 0; color: #ac3737; font-size: 13px; line-height: 1.6; }
.quick-section { max-width: 560px; margin: 24px auto 0; text-align: center; }
.quick-section h2 { margin: 0 0 11px; color: var(--muted); font-size: 12px; font-weight: 500; }
.quick-characters { display: flex; justify-content: center; gap: 8px; }
.quick-characters button { flex: 0 1 46px; min-width: 0; min-height: 46px; padding: 6px 0; border: 1px solid var(--line); border-radius: 10px; background: white; font-size: 20px; }
.quick-characters button:hover { background: var(--blue-soft); border-color: #b9cdf8; color: var(--blue); }
.starter-section { margin-top: 60px; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-heading h2 { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -.4px; }
.section-heading > span { font-size: 12px; color: var(--muted); }
.starter-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.word-card { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 7px; min-width: 0; padding: 23px 24px 20px; border: 1px solid var(--line); border-radius: 14px; background: white; text-align: left; }
.word-card::after { content: ''; position: absolute; right: 22px; bottom: 21px; width: 16px; height: 16px; background: #96a4b8; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12h14m-6-6 6 6-6 6' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat; }
.word-card:hover { border-color: #a8c0f6; background: #fcfdff; box-shadow: 0 4px 14px #2158df08; }
.word-card:hover::after { background: var(--blue); }
.word-card strong { font-size: 26px; font-weight: 500; letter-spacing: .2px; line-height: 1.5; }
.word-card span { font-size: 13px; color: var(--muted); }
.word-card small { margin-top: 17px; color: var(--muted); font-size: 11px; }
.home-note { display: flex; align-items: center; gap: 15px; margin-top: 30px; padding: 22px 0 0; border-top: 1px solid var(--line); }
.note-icon { display: grid; place-items: center; width: 40px; height: 44px; color: var(--blue); flex: none; }
.note-icon svg { width: 26px; height: 26px; }
.home-note p { margin: 0; font-size: 13px; line-height: 1.8; font-weight: 600; }
.home-note p span { font-weight: 400; color: var(--muted); }

/* A continuous practice page: guide, trace, recall, then paper. */
body[data-view=writing] main { padding-top: 22px; }
.lesson-heading { margin-bottom: 12px; padding-bottom: 22px; }
.back-link { display: inline-flex; align-items: center; gap: 7px; min-height: 32px; margin-bottom: 20px; color: var(--muted); font-size: 12px; text-decoration: none; }
.back-link::before { content: '←'; font-size: 17px; }
.back-link:hover { color: var(--blue); }
.lesson-heading h1 { margin: 0 0 10px; font-size: 40px; line-height: 1.3; font-weight: 600; letter-spacing: -1px; overflow-wrap: anywhere; }
#word-title { font-size: 46px; font-weight: 500; letter-spacing: 1px; }
#word-title:focus { outline: none; }
.lesson-heading p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.lesson-steps, .lesson-step { min-width: 0; }
.lesson-step { padding: 28px 0 30px; border-top: 1px solid var(--line); }
.step-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 40px; }
.step-label { display: flex; align-items: center; gap: 12px; min-width: 0; }
.step-label h2 { margin: 0; font-size: 21px; font-weight: 600; line-height: 1.4; letter-spacing: -.4px; }
.step-badge { display: grid; place-items: center; width: 29px; height: 29px; flex: none; border-radius: 9px; background: var(--blue-soft); color: var(--blue); font-size: 13px; font-weight: 650; }
.step-progress { color: var(--muted); font-size: 12px; line-height: 1.5; white-space: nowrap; font-variant-numeric: tabular-nums; }
.step-intro { margin: 7px 0 19px; color: var(--muted); font-size: 13px; line-height: 1.65; }
.guide-sequence, .practice-sequence { display: flex; flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; scrollbar-color: #c6d2e4 transparent; max-width: 100%; scroll-padding: 5px; outline-offset: -2px; }
.guide-sequence { gap: 12px; padding: 0 0 6px; }
.guide-character { position: relative; flex: 0 0 80px; padding: 0 0 8px; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; }
.guide-character:hover { border-bottom-color: #bed0f6; }
.guide-character.active { border-bottom-color: var(--blue); }
.guide-character svg { display: block; width: 80px; height: 80px; }
.guide-character > span { display: block; color: var(--muted); font-size: 10px; line-height: 1.8; text-align: center; font-variant-numeric: tabular-nums; }
.guide-character.active > span { color: var(--blue); font-weight: 650; }
.guide-controls { display: flex; align-items: center; gap: 18px; margin-top: 15px; }
.playback-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.playback-button { display: grid; place-items: center; width: 44px; height: 44px; flex: none; padding: 11px; border: 1px solid var(--line); border-radius: 50%; background: white; color: var(--ink); }
.playback-button svg { display: block; width: 20px; height: 20px; }
#play-button { background: var(--blue); border-color: var(--blue); color: white; box-shadow: 0 3px 8px #2158df16; }
.playback-button:hover:not(:disabled) { border-color: #adc4f6; background: var(--blue-soft); color: var(--blue); }
#play-button:hover { background: #194bc8; border-color: #194bc8; color: white; }
.playback-button:disabled { opacity: .35; }
#watch-position { color: var(--muted); font-size: 12px; line-height: 1.6; }
.practice-sequence { gap: 16px; margin: -4px -5px 0; max-width: calc(100% + 10px); padding: 5px 5px 13px; }
.practice-card { position: relative; flex: 0 0 214px; min-width: 0; overflow: hidden; border: 1px solid #dce3ee; border-radius: 14px; background: white; box-shadow: 0 2px 4px #172c4903; }
.practice-card.active { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue), 0 0 0 4px #2158df0b; }
.practice-card.complete { border-color: #b9d9cc; }
.practice-card.waiting .character-board { opacity: .72; }
.character-board { display: block; width: 100%; height: auto; aspect-ratio: 1; user-select: none; touch-action: pan-x pan-y; }
.practice-card.active .character-board { touch-action: none; cursor: crosshair; }
.word-start { margin-left: 16px; }
.reset-button { display: grid; place-items: center; width: 44px; height: 44px; flex: none; padding: 12px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); }
.reset-button:hover:not(:disabled) { background: var(--blue-soft); color: var(--blue); }
.reset-button:disabled { opacity: .35; }
.reset-button svg { display: block; width: 19px; height: 19px; }
.completion-mark { position: absolute; top: 10px; right: 10px; display: grid; place-items: center; width: 27px; height: 27px; border-radius: 50%; background: #eaf6ef; color: var(--green); pointer-events: none; }
.completion-mark svg, .step-progress.finished svg { display: block; width: 20px; height: 20px; }
.step-progress.finished { color: var(--green); }
.practice-card.retry { border-color: #ba761b; box-shadow: 0 0 0 1px #ba761b, 0 0 0 4px #ba761b0b; }
#recall-step[data-locked=true] .step-badge { background: #eceff4; color: var(--muted); }
#recall-step[data-locked=true] .practice-card { border-color: #e6eaf0; box-shadow: none; }
.worksheet-options { display: flex; justify-content: flex-end; margin: 0 0 20px; }
.worksheet-options label { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; }
.worksheet-options select { min-height: 44px; padding: 10px 14px; border: 1px solid #d6dfec; border-radius: 9px; background: white; color: var(--ink); font-size: 13px; }
.worksheet-preview { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 24px; align-items: start; padding: 24px; border-radius: 16px; background: #eef1f6; }
.worksheet-page { display: block; width: 100%; height: auto; max-width: 660px; margin: 0 auto; border: 1px solid #e0e5ed; background: white; box-shadow: 0 4px 12px #172c4909; }
.worksheet-download-area { display: flex; flex-direction: column; align-items: center; gap: 13px; margin-top: 24px; }
.worksheet-download-area .button { min-width: 200px; }
.worksheet-status { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; text-align: center; }
.worksheet-status:empty { display: none; }

/* The alphabet uses the same quiet, paper-like surfaces. */
.letter-groups { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.letter-groups button { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 10px 15px; border: 1px solid var(--line); border-radius: 9px; background: white; color: var(--muted); font-size: 13px; font-weight: 550; }
.letter-groups button[aria-pressed=true] { border-color: #bdd0fa; background: var(--blue-soft); color: var(--blue); }
.letter-groups button:hover { border-color: #adc4f6; }
.letter-picker { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; padding: 3px; }
.letter-tab { position: relative; display: flex; flex-direction: column; align-items: center; gap: 12px; min-width: 0; padding: 23px 10px 18px; border: 1px solid var(--line); border-radius: 12px; background: white; text-align: center; }
.letter-tab:hover { border-color: #adc4f6; background: #fcfdff; }
.letter-tab svg { width: 50px; height: 50px; flex: none; }
.tab-name { display: block; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.alphabet-completed { position: absolute; right: 9px; top: 6px; color: var(--green); font-size: 14px; }
footer { display: flex; justify-content: space-between; gap: 20px; max-width: 1120px; margin: auto; padding: 14px 36px 30px; color: var(--muted); font-size: 11px; line-height: 1.6; }
footer a { text-decoration: none; }
footer a:hover { color: var(--blue); text-decoration: underline; text-underline-offset: 3px; }
body[data-view=writing] > footer { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 900px) {
  .word-form { padding: 22px; }
  .quick-characters { gap: 5px; }
  .letter-picker { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .site-header { padding: 20px 24px; }
  main { padding: 26px 24px; }
  .home-view { display: block; max-width: 540px; margin: auto; }
  .intro { margin: 8px auto 28px; }
  .intro h1 { font-size: 46px; letter-spacing: -1.8px; }
  .intro p { max-width: none; font-size: 15px; }
  .quick-section { margin-top: 22px; }
  .quick-characters { gap: 8px; }
  .starter-section { margin-top: 42px; }
  .starter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .word-card { padding: 20px; }
  .word-card strong { font-size: 24px; }
  .section-heading > span { display: none; }
  .practice-card { flex-basis: 226px; }
  .worksheet-preview { padding: 18px; }
  footer { padding: 16px 24px 28px; }
}
@media (max-width: 520px) {
  .site-header { gap: 14px; padding: 16px 18px; }
  .brand { gap: 9px; font-size: 13px; }
  .brand-mark { width: 36px; height: 36px; border-radius: 11px; font-size: 23px; }
  .brand small { font-size: 10px; }
  .header-link { gap: 0; padding: 5px 0 5px 8px; border: 0; background: transparent; max-width: 86px; text-align: right; font-size: 11px; line-height: 1.5; }
  .header-link svg { display: none; }
  main { padding: 24px 18px; }
  .intro { margin-top: 8px; }
  .eyebrow { padding: 5px 10px; font-size: 9px; letter-spacing: .9px; }
  .intro h1 { margin: 18px 0 15px; font-size: 38px; letter-spacing: -1.5px; }
  .intro p { max-width: 310px; font-size: 14px; line-height: 1.7; }
  .word-form { padding: 20px; border-radius: 15px; }
  .input-row input { font-size: 28px; padding: 16px 14px; }
  .input-details { font-size: 10px; gap: 5px; }
  .quick-characters { gap: 5px; }
  .quick-characters button { font-size: 19px; border-radius: 8px; }
  .section-heading { margin-bottom: 15px; }
  .section-heading h2 { font-size: 18px; }
  .starter-grid { gap: 10px; }
  .word-card { padding: 18px 14px; border-radius: 12px; }
  .word-card strong { font-size: 23px; }
  .word-card span { font-size: 12px; }
  .word-card small { margin-top: 12px; font-size: 10px; }
  .word-card::after { right: 14px; bottom: 17px; width: 14px; height: 14px; }
  .home-note { gap: 9px; margin-top: 25px; }
  .home-note p { font-size: 12px; }
  body[data-view=writing] main { padding-top: 12px; }
  .lesson-heading { margin-bottom: 0; padding-bottom: 22px; }
  .back-link { margin-bottom: 12px; }
  .lesson-heading h1 { font-size: 32px; }
  #word-title { font-size: 36px; }
  .lesson-heading p { font-size: 12px; }
  .lesson-step { padding: 22px 0; }
  .step-heading { gap: 8px; }
  .step-label { gap: 8px; }
  .step-label h2 { font-size: 18px; letter-spacing: -.35px; }
  .step-badge { width: 26px; height: 26px; border-radius: 8px; font-size: 12px; }
  .step-progress { font-size: 11px; }
  .step-intro { margin: 5px 0 16px; font-size: 12px; }
  .guide-sequence { gap: 7px; }
  .guide-character { flex-basis: 60px; }
  .guide-character svg { width: 60px; height: 60px; }
  .guide-controls { gap: 15px; margin-top: 13px; }
  .playback-actions { gap: 6px; }
  #watch-position { font-size: 11px; }
  .practice-sequence { gap: 14px; }
  .reset-button { width: 40px; padding: 10px; }
  .worksheet-options { justify-content: flex-start; margin-bottom: 16px; }
  .worksheet-preview { gap: 16px; padding: 12px; border-radius: 12px; }
  .worksheet-download-area .button { width: 100%; }
  .letter-groups { gap: 7px; margin-bottom: 18px; }
  .letter-groups button { padding: 9px 11px; font-size: 12px; }
  .letter-picker { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
  .letter-tab { padding: 18px 7px 15px; }
  .letter-tab svg { width: 44px; height: 44px; }
  footer { padding: 10px 18px 24px; font-size: 10px; }
}
@media (max-width: 370px) {
  .intro h1 { font-size: 34px; }
  .word-form { padding: 16px; }
  .word-card strong { font-size: 20px; }
  .step-label { gap: 6px; }
  .step-label h2 { font-size: 16px; }
  .step-badge { width: 24px; height: 24px; }
  .reset-button { width: 36px; padding: 8px; }
  .step-progress { font-size: 10px; }
  .guide-controls { gap: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
