:root {
  color-scheme: dark;
  --bg: #111614;
  --header: #141a17;
  --surface: #1b221f;
  --inset: #222c27;
  --hover: #2b3931;
  --ink: #f3f3e9;
  --muted: #b0bdb2;
  --subtle: #94a398;
  --line: #354139;
  --accent: #c9e8b6;
  --accent-ink: #192b1d;
  --warm: #edaf82;
  --ring: #f3b67b;
  --display: "Hedvig Letters Serif", "Songti SC", "STSong", "Noto Serif CJK SC", Georgia, serif;
  font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f6ef;
  --header: #fafbf5;
  --surface: #fdfef9;
  --inset: #edf2e9;
  --hover: #e3ecdf;
  --ink: #202d25;
  --muted: #4d6053;
  --subtle: #58695e;
  --line: #ced9cd;
  --accent: #345c3e;
  --accent-ink: #fff;
  --warm: #864522;
  --ring: #90521b;
}
* { box-sizing: border-box; }
html { scroll-padding-top: 1rem; }
body { margin: 0; }
[hidden], .icon-library { display: none !important; }
button, input, select, textarea { font: inherit; }
button, .upload, input, select, textarea { color: var(--ink); background: var(--inset); border: 1px solid var(--line); border-radius: 11px; }
button, .upload { min-height: 44px; padding: .5rem .92rem; cursor: pointer; }
button:hover:not(:disabled), .upload:hover { border-color: var(--subtle); background-color: var(--hover); }
button:disabled { cursor: default; opacity: .48; }
button.primary { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); font-weight: 700; }
button.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
:is(button, a, summary, input, select, textarea, [tabindex]):focus-visible, .upload:focus-within { outline: 3px solid var(--ring); outline-offset: 3px; }
button, a, summary { -webkit-tap-highlight-color: transparent; }
input, select, textarea { padding: .52rem .75rem; min-height: 44px; }
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3, h4 { line-height: 1.3; }
h1, h2, h3 { text-wrap: pretty; }
p + p { margin-top: .6rem; }
a { color: var(--accent); }
.frame { width: min(calc(100% - 80px), 1120px); margin-inline: auto; }
.icon { display: block; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.skip-link { position: absolute; top: -100px; left: 12px; padding: 12px; background: var(--surface); z-index: 12; }
.skip-link:focus { top: 6px; }
.site-header { background: var(--header); border-bottom: 1px solid var(--line); }
.masthead { display: flex; gap: clamp(20px, 5vw, 68px); align-items: center; min-height: 74px; }
.brand, .main-nav button, .theme-toggle, .text-link, .tool-link { border: 0; background: transparent; }
.brand { padding: 0; display: flex; gap: 11px; align-items: center; font-size: 1.26rem; font-weight: 750; color: var(--ink); }
.brand:hover:not(:disabled), .tool-link:hover:not(:disabled) { background: transparent; }
.brand-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; color: #263121; background: #c9e8b6; }
.brand-icon .icon { width: 25px; height: 25px; stroke-width: 2; }
.main-nav { display: flex; align-items: center; gap: 5px; }
.main-nav button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; color: var(--muted); font-size: .92rem; padding: .5rem .9rem; }
.main-nav button[aria-current="page"] { color: var(--accent); background: var(--inset); font-weight: 700; }
.main-nav .icon { width: 17px; height: 17px; }
.theme-toggle { width: 44px; padding: 0; display: grid; place-items: center; margin-inline-start: auto; color: var(--muted); }
main { padding: clamp(28px, 3.2vw, 50px) 0 64px; }
.page-title { margin-bottom: clamp(17px, 2.4vw, 27px); }
.page-title h1 { font: 650 clamp(2.15rem, 4vw, 3.25rem)/1.15 var(--display); letter-spacing: -.045em; }
.page-title > p { margin-top: 9px; color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: clamp(19px, 2.6vw, 30px); min-width: 0; }
.muted { color: var(--muted); font-size: .91rem; }
.kicker { margin: 0 0 8px; font-size: .81rem; letter-spacing: .07em; font-weight: 670; color: var(--accent); }
.feature { position: relative; isolation: isolate; overflow: hidden; border: 1px solid #4d5b44; border-radius: 23px; background: #27382e; color: #fff8e8; }
.feature::before { content: ""; position: absolute; inset: 0; z-index: -1; background: radial-gradient(ellipse at 56% 20%, #43513c 0, transparent 58%), linear-gradient(105deg,#26372f 6%,#354638 56%,#576046); }
.feature-copy { position: relative; width: 67%; z-index: 2; padding: clamp(28px, 4vw, 54px) clamp(24px, 4.8vw, 62px); padding-right: 8%; }
.feature-meta { display: flex; align-items: center; gap: 9px; color: #d6e6c5; font-size: .82rem; font-weight: 650; letter-spacing: .055em; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #c9e8b6; }
.feature h2 { margin-top: 15px; font: 600 clamp(2.1rem, 4.5vw, 3.9rem)/1.17 var(--display); letter-spacing: -.035em; text-wrap: balance; overflow-wrap: anywhere; }
.feature-goal { color: #e0e9db; margin: 14px 0 23px; line-height: 1.7; }
button.feature-action { background: #d5edbd; border-color: #d5edbd; color: #192d1c; padding: .65rem 1.2rem; min-height: 46px; border-radius: 11px; }
.feature-action::after { content: "→"; margin-left: .85rem; }
button.feature-action:hover:not(:disabled) { background: #e6face; }
.sound-print { position: absolute; overflow: hidden; isolation: isolate; inset: 0 0 0 auto; width: 39%; background: #df9d72; border-left: 1px solid #6d765f; color: #323c31; }
.grooves { position: absolute; width: 130%; aspect-ratio: 1; top: 50%; left: 52%; transform: translate(-44%,-50%); border-radius: 50%; background: repeating-radial-gradient(circle at 50% 50%,#2c433a 0 1.25px,transparent 1.8px 6.5px); }
.grooves::after { content: ""; position: absolute; inset: 40%; background: #d4946d; border-radius: 50%; border: 1px solid #33473b; }
.print-grid { position: absolute; inset: 0; background-image: linear-gradient(90deg,transparent calc(100% - 1px),#50463336 0),linear-gradient(0deg,transparent calc(100% - 1px),#50463336 0); background-size: 42px 42px; opacity: .7; }
.print-symbol { position: absolute; inset: 0; display: grid; place-items: center; color: #23392e; font: italic 500 clamp(3.6rem,8vw,6.8rem)/1 Georgia, "Times New Roman", serif; letter-spacing: -.07em; text-shadow: .025em .015em 0 #e7ac81, -.025em -.015em 0 #e7ac81; }
.print-wave { position: absolute; bottom: 17px; left: 15px; width: 54px; height: 7px; background: repeating-linear-gradient(90deg,#334436 0 1px,transparent 1px 5px); }
.home-columns { display: grid; grid-template-columns: 1.14fr 1fr; gap: 17px; margin-top: 18px; }
.section-heading { display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.section-heading h2, .review-intro h2 { font-size: 1.18rem; letter-spacing: .015em; }
.text-link { min-height: 36px; padding: 4px 2px 4px 8px; color: var(--accent); font-size: .87rem; }
.text-link span { margin-left: .2em; }
.stat-row { display: grid; grid-template-columns: 1fr 1fr 1fr; margin: 19px 0 20px; }
.stat-row > div { padding-inline: 15px 5px; border-inline-start: 1px solid var(--line); }
.stat-row > div:first-child { border: none; padding-inline-start: 0; }
.stat-row strong { display: block; font: 550 clamp(1.55rem,3.3vw,2.5rem)/1.15 "Instrument Sans", -apple-system,sans-serif; font-variant-numeric: tabular-nums; }
.stat-row span, .track-head { color: var(--muted); font-size: .83rem; }
.stat-row span { display: block; margin-top: 5px; }
.track-head { display: flex; justify-content: space-between; align-items: center; }
progress { width: 100%; height: 6px; border: 0; vertical-align: middle; overflow: hidden; border-radius: 20px; appearance: none; background: var(--inset); }
progress::-webkit-progress-bar { background: var(--inset); border-radius: 20px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 20px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 20px; }
.home-shortcuts .section-heading { min-height: 36px; }
.tool-link { display: flex; align-items: center; text-align: start; gap: 12px; width: 100%; padding: 13px 0; border-radius: 0; }
.tool-link + .tool-link { border-top: 1px solid var(--line); }
.tool-link:last-child { padding-bottom: 0; }
.tool-icon { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 12px; }
.tool-icon.amber { background: #604735; color: #f6caa4; }
.tool-icon.jade { background: #365340; color: #d9eec7; }
:root[data-theme="light"] .tool-icon.amber { background: #f5e2ce; color: #75401f; }
:root[data-theme="light"] .tool-icon.jade { background: #dfebd9; color: #345239; }
.tool-link strong, .tool-link small { display: block; }
.tool-link strong { font-size: .98rem; }
.tool-link small { font-size: .83rem; color: var(--muted); margin-top: 1px; }
.tool-arrow { margin-inline-start: auto; color: var(--muted); }
.tool-link:hover .tool-arrow, .tool-link:hover strong { color: var(--accent); }
.course-layout { display: grid; grid-template-columns: minmax(195px,260px) minmax(0,1fr); align-items: start; gap: 18px; }
.sidebar { display: grid; gap: 13px; }
.course-index, .road-card { padding: 18px; }
summary { cursor: pointer; font-weight: 680; overflow-wrap: anywhere; }
summary::marker { color: var(--subtle); }
#menu { display: grid; gap: 5px; margin-top: 13px; }
.menu-entry { width: 100%; text-align: left; font-size: .88rem; background: transparent; border-color: transparent; color: var(--muted); }
.menu-entry[aria-current="true"] { color: var(--accent); background: var(--inset); border-color: var(--line); font-weight: 700; }
.lesson { padding: clamp(19px, 3.2vw, 39px); }
.lesson-heading { padding-bottom: 19px; border-bottom: 1px solid var(--line); }
.lesson-heading h2 { font: 650 clamp(1.7rem,3.3vw,2.55rem)/1.25 var(--display); letter-spacing: -.025em; margin: 7px 0 10px; }
.lesson-heading p:not(.kicker) { color: var(--muted); }
.lesson-block { margin-top: 1.65rem; }
.lesson-block h3 { font-size: 1.09rem; margin-bottom: .7rem; }
.sounds { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,190px),1fr)); gap: 11px; }
.sound { border: 1px solid var(--line); background: var(--inset); padding: 16px; border-radius: 13px; }
.sound > p { margin: 7px 0 12px; color: var(--muted); font-size: .93rem; }
.ipa { line-height: 1.25; font: 550 2rem/1.2 Georgia,"Times New Roman",serif; color: var(--warm); }
.choices, .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.sound button, .quiz button, .actions button, .actions .upload { font-size: .93rem; }
.sound button { background: var(--surface); }
.quiz { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.quiz > p:first-child { font-weight: 600; }
.quiz .choices { margin-top: 9px; }
.quiz button[data-hear] { margin-top: 7px; }
.quiz [role="status"], [data-finish-note] { color: var(--accent); font-size: .9rem; margin: 8px 0 0; }
.quiz [role="status"]:empty, [data-finish-note]:empty, .notice:empty, .panel-content:empty { display: none; }
.notice { border-inline-start: 3px solid var(--accent); color: var(--accent); padding: 8px 12px; margin-bottom: 14px; background: var(--inset); }
.lesson li { margin-block: 5px; }
ul, ol { padding-inline-start: 1.25rem; }
.panel-content { display: grid; gap: 14px; }
.panel-content > :where(section, article, .lesson-block) { min-width: 0; }
.panel-content > :where(section, article):not(.card) { padding: clamp(17px, 2.6vw, 30px); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; }
.panel-content h2 { font-size: 1.2rem; }
.panel-content h3 { font-size: 1.03rem; }
.panel-content p, .settings p { margin-block: .65rem; }
.panel-content .actions { margin-block: 8px; }
.panel-content :is(select, input, textarea) { max-width: 100%; }
.review-intro { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.review-intro .primary { margin-inline-start: auto; }
.review-intro .muted { margin-top: 4px; }
.settings .actions { margin-block: 12px; }
.settings label[for] { display: block; font-weight: 650; margin-top: 14px; }
#pair-code { width: min(100%,260px); }
.upload { display: inline-flex; align-items: center; }
.upload input { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; opacity: 0; }
.data-settings { margin-top: 14px; }
#road .lesson-block { margin-top: 15px; }
#road p { font-size: .87rem; margin-bottom: 5px; }
@media (min-width: 1000px) {
  .course-index #menu { max-height: 61vh; overflow-y: auto; scrollbar-width: thin; }
}
@media (max-width: 800px) {
  .frame { width: calc(100% - 38px); }
  .masthead { gap: 20px; }
  .main-nav { gap: 1px; }
  .main-nav button { padding-inline: .63rem; }
  .course-layout { grid-template-columns: minmax(170px,205px) minmax(0,1fr); gap: 12px; }
  .home-columns { grid-template-columns: 1.07fr 1fr; gap: 12px; }
}
@media (max-width: 680px) {
  .frame { width: calc(100% - 32px); }
  .masthead { min-height: 59px; gap: 10px; }
  .brand { font-size: 1.08rem; gap: 8px; }
  .brand-icon { width: 32px; height: 32px; border-radius: 9px; }
  .brand-icon .icon { width: 21px; height: 21px; }
  .main-nav { position: fixed; z-index: 9; inset: auto 0 0; padding: 6px max(8px,env(safe-area-inset-right)) calc(5px + env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left)); background: var(--header); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 2px; }
  .main-nav button { flex-direction: column; gap: 2px; min-height: 48px; font-size: .72rem; padding: 3px 0; }
  .main-nav .icon { width: 19px; height: 19px; }
  main { padding: 25px 0 calc(90px + env(safe-area-inset-bottom)); }
  .page-title { margin-bottom: 15px; }
  .page-title h1 { font-size: 2rem; }
  .page-title > p { font-size: .93rem; }
  .feature { border-radius: 17px; }
  .feature-copy { width: 73%; padding: 24px 17px 24px 21px; }
  .feature h2 { font-size: clamp(1.75rem,6vw,2.25rem); margin-top: 11px; text-wrap: pretty; }
  .feature-meta { font-size: .71rem; gap: 6px; }
  .feature-goal { font-size: .86rem; margin: 10px 0 15px; }
  .sound-print { width: 26%; }
  .grooves { width: 340%; left: 54%; transform: translate(-50%,-50%); }
  .print-symbol { font-size: clamp(1.8rem,8vw,3.3rem); }
  .print-wave { width: 30px; bottom: 10px; left: 8px; }
  .home-columns, .course-layout { grid-template-columns: 1fr; gap: 12px; }
  .home-columns { margin-top: 12px; }
  .card { border-radius: 15px; }
  .stat-row { margin: 15px 0; }
  .stat-row strong { font-size: 1.8rem; }
  .stat-row > div { padding-inline-start: 12px; }
  .sidebar { gap: 8px; }
  .course-index, .road-card { padding: 13px 16px; }
  #directory[open] #menu { max-height: 33vh; overflow-y: auto; }
  .lesson-heading { padding-bottom: 14px; }
  .review-intro { flex-wrap: wrap; }
  .review-intro .primary { margin-inline-start: 0; }
  html { scroll-padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
}
@media (max-width: 365px) {
  .frame { width: calc(100% - 24px); }
  .feature-copy { width: 76%; padding-inline-start: 15px; }
  .sound-print { width: 23%; }
  .sound-print .print-symbol { font-size: 1.65rem; }
  .stat-row span { font-size: .76rem; }
}
@media (prefers-reduced-motion: no-preference) {
  button, .upload { transition: background-color .14s ease, border-color .14s ease, color .14s ease; }
}
