:root {
  --bg: #f8f7f2; --surface: #fffefa; --text: #242d27; --muted: #657065; --line: #e5e7dd; --accent: #28533e;
  --tone-mid: #4b6b8a; --tone-low: #2f7d5b; --tone-falling: #b4462c; --tone-high: #8a4fb0; --tone-rising: #b07a12;
  --notice-bg: #fff4d6; --notice-text: #5c4400;
  /* 不加载 Google Fonts（中国大陆访问不稳定），先用各系统自带的泰文字体，后续可自托管 Noto Sans Thai。 */
  --thai: "Noto Sans Thai", "Thonburi", "Leelawadee UI", "Sarabun", "Tahoma", sans-serif;
  --sans: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  --bg: #121d18; --surface: #1b2921; --text: #e6ece1; --muted: #a4b2a6; --line: #35493c; --accent: #b2d199;
  --tone-mid: #8fb3d6; --tone-low: #6cc79c; --tone-falling: #ef8a69; --tone-high: #c79be6; --tone-rising: #e3b555; --notice-bg: #3a3014; --notice-text: #f2dc9b;
  color-scheme: dark;
}
}
:root[data-theme="dark"] {
  --bg: #121d18; --surface: #1b2921; --text: #e6ece1; --muted: #a4b2a6; --line: #35493c; --accent: #b2d199;
  --tone-mid: #8fb3d6; --tone-low: #6cc79c; --tone-falling: #ef8a69; --tone-high: #c79be6; --tone-rising: #e3b555; --notice-bg: #3a3014; --notice-text: #f2dc9b;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.65 var(--sans); }
[lang="th"] { font-family: var(--thai); line-height: 1.85; } /* 泰文上下标会叠在辅音上，行高要比中文大 */
a { color: var(--accent); }
.icon-btn, .btn { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 10px; padding: 8px 14px; font: inherit; cursor: pointer; text-decoration: none; display: inline-flex; flex-direction: column; align-items: center; }
.btn:hover, .icon-btn:hover { border-color: var(--accent); }
.btn.small { padding: 4px 10px; font-size: 14px; }
.link-btn { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; }
main { max-width: 1040px; margin: 0 auto; padding-block: 24px 48px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); outline: none; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
h1 small, h2 small { color: var(--muted); font-weight: 400; font-size: .6em; }
.lead { color: var(--muted); max-width: 68ch; }
.small { font-size: 14px; color: var(--muted); }
.notice { margin: 0; padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px)); background: var(--notice-bg); color: var(--notice-text); font-size: 14px; }
.hero h1 { font-size: clamp(26px, 5vw, 40px); margin: 8px 0; }
.today { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 12px; }
.grid.three { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid.words { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.tile { display: flex; flex-direction: column; gap: 6px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); text-decoration: none; }
.tile b { font-size: 26px; }
.tile span, .tile small { color: var(--muted); }
body:has(.video-catalog, .video-layout) #voice-notice { display: none; }
.video-catalog {
  --catalog-bg: #f1f5ee; --card-bg: #fff; --card-line: #cedbd0;
  --card-text: #1b3026; --card-muted: #496455; --card-accent: #326445;
  color: var(--card-text); background: var(--catalog-bg);
}
:root[data-theme="dark"] .video-catalog {
  --catalog-bg: #131f19; --card-bg: #1b2921; --card-line: #354b3d;
  --card-text: #eff4e9; --card-muted: #b6c5b8; --card-accent: #b5d59e;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .video-catalog {
    --catalog-bg: #131f19; --card-bg: #1b2921; --card-line: #354b3d;
    --card-text: #eff4e9; --card-muted: #b6c5b8; --card-accent: #b5d59e;
  }
}
body:has(main.video-catalog) { background: #f1f5ee; }
:root[data-theme="dark"] body:has(main.video-catalog) { background: #131f19; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body:has(main.video-catalog) { background: #131f19; }
}
.video-catalog h1 { margin: 0; }
.episode-catalog-head { display: flex; justify-content: space-between; align-items: start; gap: 18px; margin-bottom: 20px; }
.episode-catalog-head p { margin: 5px 0 0; color: var(--card-muted); font-size: 14px; }
.episode-catalog-head { align-items: end; padding-block: 10px 6px; }
.episode-catalog-head p.site-kicker { margin: 0 0 6px; color: var(--card-accent); font-size: 12px; }
.episode-series { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.episode-series a { padding: 8px 11px; border: 1px solid var(--card-line); border-radius: 9px; color: var(--card-text); background: var(--card-bg); font-size: 14px; font-weight: 650; text-decoration: none; }
.episode-series a span { margin-inline-start: 5px; font-weight: 400; }
.episode-series a[aria-current] { background: #294a37; border-color: #294a37; color: #f5f9eb; }
.episode-search { display: flex; min-width: 0; width: min(100%, 360px); border: 1px solid var(--card-line); border-radius: 10px; background: var(--card-bg); }
.episode-search input { min-width: 0; width: 100%; padding: 10px 12px; border: 0; border-radius: inherit; font: inherit; color: var(--card-text); background: transparent; }
.episode-search input::placeholder { color: var(--card-muted); }
.episode-search button { flex: none; border: 0; border-inline-start: 1px solid var(--card-line); border-radius: 0 9px 9px 0; padding-inline: 12px; font: inherit; color: var(--card-accent); background: transparent; cursor: pointer; }
.episode-topics { display: flex; flex-wrap: wrap; gap: 6px; }
.episode-topics a { padding: 8px 12px; border-radius: 8px; color: var(--card-muted); font-size: 14px; text-decoration: none; }
.episode-topics a:hover { background: var(--card-bg); }
.episode-topics a[aria-current] { background: #b5d59e; color: #182e20; }
.episode-filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 0 0 12px; }
.episode-filter-row .episode-series, .episode-filter-options { display: flex; flex: none; flex-wrap: nowrap; gap: 3px; }
.episode-filter-row .episode-series { flex-wrap: wrap; max-width: 100%; margin: 0; }
.episode-filter-options { margin-inline-start: auto; }
.episode-filter-row .episode-series a, .episode-filter-options select { min-height: 32px; padding: 5px 4px; border-radius: 7px; font-size: .75rem; line-height: 1.4; white-space: nowrap; }
.episode-filter-row .episode-series a { display: flex; align-items: center; }
.episode-filter-row .episode-series a span { margin-inline-start: 4px; }
.episode-filter-options select { max-inline-size: 8.5rem; border: 1px solid var(--card-line); font-family: inherit; color: var(--card-text); background: var(--card-bg); }
@media (max-width: 1230px) {
  .episode-filter-row .episode-series { flex-basis: 100%; }
  .episode-filter-options { margin-inline-start: 0; }
}
@media (max-width: 640px) {
  .episode-filter-row .episode-series { flex-wrap: nowrap; overflow-x: auto; padding: 3px; }
  .episode-filter-options { display: grid; flex-basis: 100%; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; }
  .episode-filter-options select { grid-column: span 2; width: 100%; max-inline-size: none; min-height: 40px; }
  .episode-filter-options select:nth-child(-n+2) { grid-column: span 3; }
  .episode-filter-row .episode-series a { flex: none; min-height: 36px; }
}
@media (max-width: 359px) {
  .episode-filter-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .episode-filter-options select, .episode-filter-options select:nth-child(-n+2) { grid-column: auto; }
}
.episode-empty { padding: 16px; background: var(--card-bg); border: 1px solid var(--card-line); border-radius: 10px; }
.episode-count { margin: 8px 0 20px; color: var(--card-muted); font-size: 14px; }
.episode-count::before { content: "•"; color: var(--card-accent); margin-inline-end: 8px; }
.episode-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(12px, 2vw, 28px); }
.episode-list > li { position: relative; min-width: 0; }
.episode-list > li > .bookmark { position: absolute; top: 8px; right: 8px; color: #eef8e6; background: #213c2e; border-color: #b5d59e; }
.episode-list.compact { grid-template-columns: minmax(0, 1fr); max-width: 920px; }
.episode-list.compact .episode-card { display: grid; grid-template-columns: clamp(92px, 24%, 200px) minmax(0, 1fr); }
.episode-list.compact .episode-cover { align-self: center; }
.episode-list.compact .episode-info { padding-inline-end: 55px; }
.episode-list.compact .episode-duration, .episode-list.compact .episode-watched { display: none; }
.episode-card { display: flex; flex-direction: column; height: 100%; overflow: hidden; border: 1px solid var(--card-line); border-radius: 16px; background: var(--card-bg); color: var(--card-text); text-decoration: none; transition: border-color .15s, transform .15s; }
.episode-card:hover, .episode-card:focus-visible { border-color: var(--card-accent); }
@media (hover: hover) and (prefers-reduced-motion: no-preference) { .episode-card:hover { transform: translateY(-3px); } }
.episode-cover { position: relative; aspect-ratio: 3 / 2; overflow: hidden; background: linear-gradient(145deg, #769277, #253f31); }
.episode-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.episode-duration, .episode-play, .episode-watched { position: absolute; background: #213c2e; color: #eef8e6; }
.episode-duration { inset: auto auto 10px 10px; padding: 3px 8px; border-radius: 7px; font-size: 12px; }
.episode-watched { inset: 8px auto auto 8px; padding: 3px 7px; border-radius: 7px; font-size: 12px; }
.episode-play { display: grid; place-items: center; inset: auto 10px 10px auto; width: 40px; height: 40px; border-radius: 50%; color: #c5e5ad; }
.episode-card:is(:hover, :focus-visible) .episode-play { background: #0d291b; }
.episode-info { display: flex; flex: 1; flex-direction: column; gap: 4px; padding: clamp(10px, 1.45vw, 20px); }
.episode-title { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 8px; }
.episode-title h2 { min-width: 0; margin: 0; overflow-wrap: anywhere; font-size: clamp(18px, 2vw, 30px); line-height: 1.55; }
.episode-id { padding: 1px 7px; border-radius: 5px; background: #e7efe1; color: #405e48; font-size: 12px; }
.episode-meaning, .episode-roman { margin: 0; overflow-wrap: anywhere; color: var(--card-muted); }
.episode-meaning { font-size: clamp(13px, 1.3vw, 16px); }
.episode-roman { margin-top: auto; padding-top: 8px; font-size: 13px; }
.episode-pagination { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 12px; margin-top: 24px; color: var(--card-muted); }
.episode-pagination a { padding: 6px 14px; border: 1px solid var(--card-line); border-radius: 8px; background: var(--card-bg); color: var(--card-accent); text-decoration: none; }
@media (max-width: 1000px) { .episode-list { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 720px) {
  .episode-catalog-head { flex-direction: column; align-items: start; gap: 10px; margin-bottom: 12px; }
  .episode-topics { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 3px; }
  .episode-topics a { flex: none; white-space: nowrap; }
  .episode-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 359px) { .episode-list { grid-template-columns: minmax(0, 1fr); } }
.video-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; gap: 24px; }
.video-layout h2 { margin: 0 0 8px; }
.episode-detail-heading { margin-bottom: 14px; }
.episode-detail-heading p { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 0; color: var(--muted); font-size: 13px; }
.episode-detail-heading h1 { margin: 6px 0 0; line-height: 1.4; font-size: clamp(23px, 4vw, 38px); }
.episode-stage { padding: 8px; border-radius: 18px; background: #182f25; }
.episode-stage .error { margin: 8px; color: #ffe0bf; }
.episode-transcript { padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.episode-transcript h2 { font-size: 18px; }
.episode-video { display: block; height: min(65svh, 560px); max-width: 100%; aspect-ratio: 9 / 16; margin-inline: auto; object-fit: contain; background: #15171b; border-radius: 12px; }
.episode-lines { list-style: none; margin: 0 0 18px; padding: 4px; display: grid; gap: 6px; max-height: 18rem; overflow-y: auto; }
.episode-line { display: grid; width: 100%; padding: 6px 10px; text-align: start; overflow-wrap: anywhere; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.episode-line span { color: var(--muted); }
.episode-line[aria-current] { border-color: var(--accent); box-shadow: inset 4px 0 var(--accent); }
.video-words { display: flex; flex-wrap: wrap; list-style: none; gap: 6px 14px; padding: 0; }
@media (max-width: 640px) {
  .video-layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .episode-video { width: min(100%, 18rem); height: min(42svh, 440px); }
  .episode-lines { max-height: 12rem; }
}
.letters { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.letter { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; text-align: left; }
.letter b { font-size: 34px; line-height: 1.3; }
.letter span { font-size: 14px; }
.letter small { font-size: 12px; color: var(--muted); }
.letter .letter-play, .letter-play span { font-size: 12px; color: var(--muted); }
.letter:hover .letter-play { color: var(--text); }
.letter.obsolete { opacity: .55; }
.alphabet-player { box-sizing: border-box; width: min(460px, calc(100% - 32px)); max-height: calc(100% - 32px); max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 32px); overflow: auto; overscroll-behavior: contain; padding: clamp(12px, 4vw, 24px); border: 1px solid var(--line); border-radius: 20px; background: var(--surface); color: var(--text); text-align: center; box-shadow: 0 16px 64px #0005; }
.alphabet-player::backdrop { background: #09110dcc; }
.letter-player-head, .letter-player-actions { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.letter-player-head { position: sticky; top: 0; z-index: 1; background: var(--surface); color: var(--muted); font-size: 14px; }
.letter-player-head form { margin: 0; }
.letter-player-head .btn { min-width: 44px; }
.letter-player-face { margin-block: 10px; padding: 6px; border-radius: 14px; background: #223c30; color: #f3f7e9; }
.letter-player-face h2 { margin: 0; font-size: clamp(66px, 19vw, 104px); line-height: 1.15; }
.letter-player-face p { margin: 0 0 6px; font-size: 24px; }
.alphabet-player audio { display: block; width: 100%; }
.letter-player-actions { flex-wrap: wrap; justify-content: center; margin-top: 12px; }
.letter-player-actions .btn { min-height: 44px; }
.letter-player-actions [aria-pressed="true"] { background: #b5d59e; border-color: #b5d59e; color: #182e20; }
.letter-player-actions :disabled { opacity: .5; cursor: default; }
table { border-collapse: collapse; width: 100%; margin: 8px 0 16px; background: var(--surface); }
th, td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: middle; }
.table-wrap { overflow-x: auto; padding: 2px; }
.contour path { fill: none; stroke-width: 3.5; stroke-linecap: round; }
.contour path.guide { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 3; }
.tone-mid { --tone: var(--tone-mid); } .tone-low { --tone: var(--tone-low); } .tone-falling { --tone: var(--tone-falling); }
.tone-high { --tone: var(--tone-high); } .tone-rising { --tone: var(--tone-rising); }
.contour path:not(.guide) { stroke: var(--tone); }
.syl { display: inline-flex; flex-direction: column; align-items: center; padding: 2px 8px; margin: 0 4px 4px 0; border-radius: 8px; border-bottom: 3px solid var(--tone); background: var(--bg); }
.syl small { font-size: 13px; color: var(--tone); }
.legend .syl { color: var(--tone); }
.word { position: relative; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.word h3 { margin: 0; font-size: 28px; }
.word p { margin: 4px 0; }
.word .meta { font-size: 13px; color: var(--muted); }
.word-filter { display: flex; align-items: stretch; gap: 8px; max-width: 420px; margin: 12px 0; }
.word-filter input[type="search"], .word-filter select { min-width: 0; max-width: 100%; min-height: 42px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
.word-filter input[type="search"] { flex: 1 1 0; }
.word-filter > .btn { flex: none; justify-content: center; white-space: nowrap; }
.word-library-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; margin-block: 14px 10px; }
.word-library-head h1 { margin: 0; }
.word-library-tabs, .word-detail-nav { display: flex; flex-wrap: wrap; gap: 8px; }
.word-library-tabs a { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 4px 9px; border: 1px solid var(--line); border-radius: 8px; color: var(--accent); background: var(--surface); text-decoration: none; font-size: .875rem; }
.word-library-tabs a:hover, .word-library-tabs a[aria-current="page"] { border-color: var(--accent); }
.word-library-tabs a[aria-current="page"] { font-weight: 650; }
.word-title, .word-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.word-title h1, .word-title h3 { min-width: 0; overflow-wrap: anywhere; }
.word-actions { gap: 4px; }
.play, .bookmark { flex: 0 0 44px; width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--accent); cursor: pointer; }
.bookmark { font: 23px/1 system-ui, sans-serif; }
.bookmark[aria-pressed="true"] { border-color: currentColor; }
.tone-form { display: flex; gap: 8px; flex-wrap: wrap; }
.tone-form input { font: 22px var(--thai); padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); min-width: 0; flex: 1 1 200px; }
.result { display: flex; gap: 16px; align-items: center; margin-top: 16px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); flex-wrap: wrap; }
.result p { margin: 2px 0; }
.big { font-size: 44px; margin: 0; }
.error { color: var(--accent); }
.flash { max-width: 520px; margin: 0 auto; padding: 28px 20px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.flash .big { font-size: 56px; }
.answer { font-size: 20px; margin: 0; }
.ratings { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%; }
.ratings small { font-size: 12px; color: var(--muted); }
.footer { text-align: center; padding-block: 16px 24px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); color: var(--muted); font-size: 14px; border-top: 1px solid var(--line); }
.tones th, .rules th { white-space: nowrap; }
.tones td:last-child { white-space: normal; min-width: 9em; }
.rules th small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); }
.mark { font-size: 22px; }
@media (max-width: 520px) { .ratings { grid-template-columns: repeat(2, minmax(0, 1fr)); } .big { font-size: 36px; } }
.footer p { margin: 6px 0; }
.footer-actions { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
.word h3 a { color: inherit; text-decoration: none; }
.word h3 a:hover { text-decoration: underline; }
.word-topics { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.word-topics a { padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); font-size: 14px; text-decoration: none; }
.word-topics a[aria-current] { border-color: var(--accent); color: var(--accent); }
.video-queue { margin: 12px 0 4px; }
@media (max-width: 640px) {
  .word-topics { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 3px; }
  .word-topics a { flex: none; white-space: nowrap; }
}
.roman-auto { font-style: italic; }
.roman-auto::after { content: " *"; opacity: .6; }
.vowels { border-collapse: collapse; margin: 12px 0 20px; width: 100%; max-width: 640px; }
.vowels td, .vowels th { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.vowels th { font-size: 14px; color: var(--muted); font-weight: 500; }
.vowel { display: inline-flex; flex-direction: column; align-items: center; min-width: 76px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.vowel:hover { border-color: var(--accent); }
.vowel b { font-size: 28px; font-weight: 500; }
.vowel span { font-size: 13px; color: var(--muted); }
.drill-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.active { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.drill { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.drill-play { font-size: 18px; padding: 12px 28px; }
.drill-options { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.drill-option { min-width: 88px; }
.drill-option b { font-size: 32px; font-weight: 500; }
.drill-option span { font-size: 14px; }
.drill-option.correct { border-color: #2f7d4f; background: color-mix(in srgb, #2f7d4f 14%, var(--surface)); }
.drill-option.wrong { border-color: #b4462c; background: color-mix(in srgb, #b4462c 14%, var(--surface)); }
.drill-option:disabled { cursor: default; opacity: 1; color: var(--text); }
.drill-result { min-height: 1.5em; margin: 0; font-weight: 600; }
.drill-result.ok { color: #2f7d4f; }
.drill-result.bad { color: var(--accent); }
.drill-answer { margin: 0; }
@media (max-width: 520px) { .tones-5 .drill-option { min-width: 60px; padding-inline: 8px; } }
.episode-lines li { display: flex; gap: 6px; align-items: stretch; }
.episode-lines .episode-line { flex: 1; min-width: 0; }
.line-add { flex: none; width: 36px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--accent); font: inherit; font-size: 18px; cursor: pointer; }
.line-add:hover:not(:disabled) { border-color: var(--accent); }
.line-add:disabled { color: #2f7d4f; cursor: default; }
.big.sentence { font-size: clamp(26px, 6vw, 40px); line-height: 1.5; overflow-wrap: anywhere; }
.word-filter select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 10px; font: inherit; font-size: 14px; color: var(--text); background: var(--surface); }
.example { display: flex; gap: 8px; align-items: flex-start; max-width: 640px; margin: 8px 0 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-align: start; }
.example p { margin: 2px 0; }
.example .link-btn { flex: none; font-size: 16px; padding: 2px 4px; }
.flash .example { margin: 8px auto 12px; }
#word-filter { display: grid; grid-template-columns: minmax(0, 22rem) max-content; max-width: none; }
.word-filter-search, .word-filter-options { display: flex; gap: 8px; min-width: 0; }
#word-filter :is(input[type="search"], select, .btn) { min-height: 36px; padding: 5px 9px; border-radius: 8px; font-size: .8125rem; line-height: 1.4; }
#word-filter input[type="search"] { flex: 1 1 0; }
#word-filter .btn { flex: none; justify-content: center; }
@media (max-width: 640px) {
  #word-filter { grid-template-columns: minmax(0, 1fr); }
  .word-filter-options { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1.15fr); gap: 6px; }
  #word-filter :is(input[type="search"], select, .btn) { min-height: 40px; }
  #word-filter select { width: 100%; padding-inline: 6px; font-size: .75rem; }
}
@media (hover: none) and (pointer: coarse) {
  #word-filter input[type="search"] { font-size: 1rem; }
}
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 16px 0; }
.stat-tile { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.stat-tile span { font-size: 14px; color: var(--muted); }
.stat-tile b { font-size: 26px; font-weight: 600; color: var(--text); }
.stat-tile small { font-size: 13px; color: var(--muted); }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 16px; }
.chart { margin: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.chart figcaption { font-weight: 600; margin-bottom: 6px; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .bar { fill: var(--accent); }
.chart .hit { fill: transparent; }
.chart .col:hover .bar, .chart .col:focus .bar { opacity: .75; }
.chart .col:focus { outline: none; }
.chart .col:focus .hit { stroke: var(--text); stroke-width: 1; }
.chart text { font-size: 11px; fill: var(--muted); }
.chart .peak { fill: var(--text); font-weight: 600; }
.chart details { margin-top: 6px; font-size: 14px; color: var(--muted); }
.chart-table { border-collapse: collapse; margin-top: 4px; }
.chart-table th, .chart-table td { padding: 2px 10px 2px 0; font-weight: 400; text-align: left; }
body:has(.static-page) > .topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding-block: 8px; padding-inline: max(16px, calc((100% - 1280px) / 2), env(safe-area-inset-left, 0px)) max(16px, calc((100% - 1280px) / 2), env(safe-area-inset-right, 0px)); border-bottom: 1px solid var(--line); background: var(--surface); }
body:has(.static-page) > .topbar nav { display: flex; flex-wrap: wrap; gap: 4px 12px; }
body:has(.static-page) > .topbar a { text-decoration: none; }
body:has(.static-page) > .topbar nav a { display: grid; place-items: center; min-height: 36px; font-size: .875rem; }
@media (max-width: 640px) {
  body:has(.static-page) > .topbar nav { order: 1; flex-basis: 100%; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0; }
}
.static-page h1 small { font-size: .55em; color: var(--muted); font-weight: 500; margin-inline-start: 8px; }
.static-page h1 [lang="th"] { font-size: 1.25em; }
.crumbs { font-size: 14px; color: var(--muted); }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; margin: 16px 0; }
.facts div { padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.facts dt { font-size: 13px; color: var(--muted); }
.facts dd { margin: 0; }
.link-list { padding-inline-start: 20px; }
.word-links { display: flex; flex-wrap: wrap; gap: 6px 10px; list-style: none; padding: 0; }
.word-links a { display: inline-block; padding: 4px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); text-decoration: none; color: var(--text); }
.word-links a:hover { border-color: var(--accent); }
.typing-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 760px) { .typing-layout { grid-template-columns: minmax(0, 1fr); } }
.typing-panel { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.typing-panel h2 { margin-top: 0; }
.typing-panel .drill-tabs .btn { align-items: flex-start; text-align: start; }
.typing-panel .drill-tabs small { color: var(--muted); font-size: 13px; }
.typing-range { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 12px 0 4px; }
.typing-range select { max-width: 100%; min-width: 0; padding: 6px 8px; border: 1px solid var(--line); border-radius: 10px; font: inherit; color: var(--text); background: var(--surface); }
.typing-best b { font-size: 32px; }
.typing-history { list-style: none; padding: 0; margin: 0; }
.typing-history li { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.typing-question { max-width: 640px; margin: 0 auto; }
.typing-top { display: flex; justify-content: space-between; color: var(--muted); font-size: 14px; }
.typing-prompt { text-align: center; margin: 8px 0; }
.typing-prompt .big { margin: 8px 0; }
.dictation-cover { padding: 24px; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); }
.typing-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
#typing-form label { display: block; font-size: 14px; color: var(--muted); margin: 8px 0 4px; }
#typing-answer { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font: 22px/1.8 var(--thai); color: var(--text); background: var(--bg); }
#typing-answer:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
/* 跟读练习 */
.shadow-list { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.shadow-list a { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); text-decoration: none; min-width: 0; }
.shadow-list a:hover { border-color: var(--accent); }
.shadow-list b { font-size: 22px; font-weight: 600; }
.shadow-list span { font-size: 14px; color: var(--muted); }
.shadow-list small { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shadow-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.shadow-actions .btn[disabled] { opacity: .5; cursor: default; }
.shadow-figure { width: 100%; max-width: 480px; }
.shadow-chart { width: 100%; height: auto; display: block; background: var(--bg); border-radius: 12px; }
.shadow-grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; }
.shadow-grid.mid { stroke-dasharray: none; }
.shadow-axis { fill: var(--muted); font-size: 11px; }
.shadow-native, .shadow-mine { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.shadow-native { stroke: var(--accent); }
.shadow-mine { stroke: var(--tone-mid); stroke-dasharray: 6 4; }
.shadow-legend { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; justify-content: center; margin-bottom: 0; }
.shadow-legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.shadow-legend .key { display: inline-block; width: 22px; height: 0; border-top: 3px solid var(--accent); }
.shadow-legend .key.mine { border-top: 3px dashed var(--tone-mid); }
.shadow-hint { font-weight: 600; min-height: 1.6em; margin: 0; }
.shadow-status:empty { display: none; }
/* 对话练习 */
.dialog-list { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.dialog-list a { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); text-decoration: none; min-width: 0; height: 100%; }
.dialog-list a:hover { border-color: var(--accent); }
.dialog-list span { font-size: 13px; color: var(--muted); }
.dialog-list small { font-size: 15px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dialog-pages { display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; margin: 8px 0 24px; }
.dialog { max-width: 620px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.dialog-roles { display: flex; gap: 8px; flex-wrap: wrap; }
.dialog-roles .btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.dialog-script { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.bubble { max-width: 85%; padding: 10px 14px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.bubble.theirs { align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.mine { align-self: flex-end; border-bottom-right-radius: 4px; background: var(--bg); }
.bubble.current { border-color: var(--accent); }
.dialog-who { font-size: 12px; color: var(--muted); }
.dialog-th { font-size: 24px; margin: 0; }
.dialog-roman { font-size: 14px; color: var(--muted); }
.dialog-roman.auto { font-style: italic; }
.dialog-zh { font-size: 15px; }
.dialog-prompt { margin: 0; font-size: 13px; color: var(--accent); font-weight: 600; }
.dialog-footer { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.dialog-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.dialog-actions .btn[disabled] { opacity: .6; cursor: default; }
.dialog-done { margin: 0; text-align: center; }

.episode-filter-options select, #word-filter .word-filter-options select, .typing-range select {
  appearance: none;
  padding-inline-end: 22px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 13px center, right 9px center;
  background-repeat: no-repeat;
  background-size: 4px 4px;
}
@media (forced-colors: active) {
  .episode-filter-options select, #word-filter .word-filter-options select, .typing-range select {
    appearance: auto;
    background-image: none;
  }
}
