:root {
  --forest: #066648;
  --forest-2: #0a7a56;
  --mint: #d7f5e7;
  --cream: #fffbeb;
  --ink: #172033;
  --muted: #64748b;
  --amber: #f6b73c;
  --paper: #ffffff;
  --line: #dce6e2;
  --shadow: 0 14px 36px rgba(21, 74, 55, .12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--cream);
  font-size: 16px;
  line-height: 1.65;
}
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: linear-gradient(135deg, #075f45, #087454);
  color: #fff;
  box-shadow: 0 6px 20px rgba(3, 48, 34, .23);
}
.header-inner, .page-shell { width: min(1160px, calc(100% - 32px)); margin: 0 auto; }
.header-inner { display: flex; gap: 18px; align-items: center; justify-content: space-between; padding: 18px 0; }
.brand { display: flex; gap: 14px; align-items: center; min-width: 0; }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 15px; background: rgba(255,255,255,.12); font-size: 28px; }
.brand h1 { margin: 0; font-size: clamp(1.1rem, 2vw, 1.55rem); line-height: 1.3; font-weight: 900; }
.brand p { margin: 2px 0 0; color: #d8f4e8; font-size: .88rem; }
.home-link { color: #fff; text-decoration: none; border: 1px solid rgba(255,255,255,.28); border-radius: 12px; padding: 9px 13px; font-weight: 800; white-space: nowrap; }
.header-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: flex-end; }
.control-btn { border: 0; color: #fff; background: rgba(255,255,255,.13); border-radius: 10px; padding: 8px 11px; font-weight: 800; }
.control-btn:hover, .control-btn:focus-visible { background: rgba(255,255,255,.23); outline: 2px solid #fde68a; outline-offset: 2px; }
.score { background: var(--amber); color: #422e05; border-radius: 10px; padding: 8px 13px; font-weight: 900; }

.page-shell { padding: 34px 0 54px; }
.intro-panel { background: #fff; border-left: 5px solid #13a477; border-radius: 0 14px 14px 0; padding: 22px 24px; box-shadow: 0 8px 24px rgba(30,41,59,.07); margin-bottom: 30px; }
.intro-panel h2 { margin: 0 0 6px; font-size: 1.25rem; }
.intro-panel p { margin: 0; color: #475569; }
.unit { margin-top: 36px; }
.unit-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.unit-pill { background: #d97706; color: #fff; font-weight: 900; font-size: .8rem; padding: 5px 10px; border-radius: 7px; }
.unit-heading h2 { margin: 0; font-size: 1.28rem; }
.lesson-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.lesson-card { display: flex; flex-direction: column; min-height: 315px; background: #fff; border: 2px solid #20b887; border-radius: 18px; overflow: hidden; box-shadow: 0 8px 18px rgba(30,41,59,.07); transition: transform .2s ease, box-shadow .2s ease; }
.lesson-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.card-body { padding: 22px 22px 16px; flex: 1; }
.card-top { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: .82rem; }
.status { color: #075f45; background: var(--mint); border-radius: 999px; padding: 4px 9px; font-weight: 800; }
.lesson-card h3 { margin: 17px 0 7px; font-size: 1.25rem; }
.lesson-card p { margin: 0; color: #526072; }
.tags { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 18px; }
.tag { background: #f1f5f9; color: #607087; padding: 3px 8px; border-radius: 6px; font-size: .78rem; }
.card-action { background: #ecfdf5; padding: 14px; }
.card-action a { display: block; text-align: center; color: #fff; text-decoration: none; background: #0ba577; padding: 10px 14px; border-radius: 12px; font-weight: 900; }
.card-action a:hover, .card-action a:focus-visible { background: #087b5a; outline: 3px solid #f6b73c; }

.tabs-bar { position: sticky; top: 84px; z-index: 20; background: #07845e; color: #fff; box-shadow: 0 5px 16px rgba(3,48,34,.14); }
.tabs-scroll { width: min(1160px, 100%); margin: auto; display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px 12px; scrollbar-color: #9bb8ae #e8f5f0; }
.tab-btn { flex: 0 0 auto; border: 0; color: #fff; background: transparent; padding: 10px 13px; border-radius: 10px; font-weight: 900; }
.tab-btn[aria-selected="true"] { color: #075f45; background: #fff; box-shadow: 0 3px 10px rgba(0,0,0,.15); }
.tab-btn:focus-visible { outline: 3px solid #f6b73c; outline-offset: 2px; }

.lesson-main { width: min(1100px, calc(100% - 32px)); margin: 28px auto 58px; }
.module-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 20px; padding: clamp(20px, 4vw, 34px); box-shadow: 0 12px 32px rgba(30,41,59,.07); }
.module-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.module-head h2 { margin: 0; font-size: clamp(1.25rem, 2vw, 1.55rem); }
.module-head p { margin: 4px 0 0; color: var(--muted); }
.primary-btn, .secondary-btn { border: 0; border-radius: 12px; padding: 10px 16px; font-weight: 900; }
.primary-btn { background: #0ba577; color: #fff; }
.primary-btn:hover { background: #087b5a; }
.secondary-btn { background: #eef2f6; color: #334155; }
.module-actions { display: flex; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }
.source-index-link { display: inline-flex; align-items: center; text-decoration: none; }
.audio-source-note { display: flex; align-items: center; gap: 12px; margin: -4px 0 18px; padding: 12px 15px; border: 1px solid #a7e3ce; border-radius: 13px; background: #ecfdf5; color: #175746; }
.audio-source-note span { color: #3f6259; }
.reading-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.para-card { border: 1px solid #e2e8f0; background: #f8fafc; border-radius: 14px; padding: 17px; text-align: left; display: flex; gap: 14px; align-items: flex-start; color: var(--ink); }
.para-card:hover, .para-card.active { background: #ecfdf5; border-color: #19a979; }
.para-copy { flex: 1; min-width: 0; }
.para-text { margin: 0; line-height: 1.8; }
.para-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 13px; }
.official-audio-link { display: inline-flex; align-items: center; border: 1px solid #087b5a; border-radius: 999px; padding: 7px 11px; background: #087b5a; color: #fff; font-size: .86rem; font-weight: 800; text-decoration: none; cursor: pointer; }
.official-audio-link:hover, .official-audio-link:focus-visible { background: #065f46; border-color: #065f46; }
.number-dot { width: 28px; height: 28px; flex: 0 0 28px; border-radius: 50%; background: #0a8a64; color: #fff; display: grid; place-items: center; font-weight: 900; font-size: .82rem; }
.subnav { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; padding: 7px; border-radius: 12px; background: #f1f5f9; }
.subnav button { border: 0; background: transparent; color: #526072; border-radius: 8px; padding: 8px 12px; font-weight: 800; }
.subnav button.active { color: #fff; background: #087b5a; }
.study-layout { display: grid; grid-template-columns: 1fr 1.1fr; gap: 24px; align-items: stretch; }
.flash-card { min-height: 360px; border: 2px solid #9ce1ca; border-radius: 20px; padding: 28px; background: linear-gradient(145deg,#fff,#effcf7); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.big-char { font-size: clamp(5rem, 15vw, 8.5rem); line-height: 1; color: #087b5a; font-weight: 900; }
.bpmf { font-size: 1.3rem; color: #526072; letter-spacing: .25em; }
.detail-card { border-radius: 20px; background: #086348; color: #fff; padding: 28px; }
.detail-card h3 { margin-top: 0; }
.pager { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; }
.quiz-box { border: 1px solid #d8e5df; border-radius: 16px; padding: 22px; background: #f8fcfa; }
.option-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; margin-top: 16px; }
.option { border: 2px solid #cbd5e1; background: #fff; color: var(--ink); border-radius: 12px; padding: 15px; font-weight: 900; }
.option:hover { border-color: #0a8a64; }
.component-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; }
.component-card { border: 1px solid #dbe7e2; border-radius: 16px; background: #fff; padding: 18px; }
.component-card h3 { font-size: 2rem; margin: 0 0 6px; }
.component-card .parts { display: flex; gap: 6px; margin: 12px 0; }
.part { background: #e5f6ef; color: #086348; border-radius: 7px; padding: 3px 8px; font-weight: 800; }
.revealed { margin-top: 12px; padding-top: 12px; border-top: 1px dashed #b9cdc5; color: #475569; }
.challenge { max-width: 760px; margin: auto; }
.progress-track { height: 10px; background: #e2e8f0; border-radius: 999px; overflow: hidden; margin: 14px 0 24px; }
.progress-bar { height: 100%; background: linear-gradient(90deg,#0ba577,#f6b73c); transition: width .25s ease; }
.drop-zone { min-height: 72px; border: 2px dashed #72bda5; background: #f1fcf8; border-radius: 14px; padding: 12px; display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; }
.chip-bank { display: flex; gap: 9px; flex-wrap: wrap; margin: 18px 0; }
.chip { border: 1px solid #9fbfb3; border-radius: 10px; background: #fff; color: #26384a; padding: 9px 12px; font-weight: 800; }
.chip.used { opacity: .35; }
.feedback { min-height: 28px; margin-top: 12px; font-weight: 900; }
.feedback.good { color: #087b5a; }
.feedback.bad { color: #b42318; }
.form-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 18px; }
.field-group { background: #f8fafc; border-radius: 14px; padding: 16px; }
.field-group label { font-weight: 900; display: block; margin-bottom: 10px; }
.choice-stack { display: grid; gap: 8px; }
.choice-stack button { border: 1px solid #cbd5e1; background: #fff; padding: 9px; border-radius: 9px; text-align: left; }
.choice-stack button.active { border-color: #0ba577; background: #e7f8f1; color: #075f45; font-weight: 900; }
.writing-output { margin-top: 22px; background: #fff9dd; border: 1px solid #f2d474; border-radius: 16px; padding: 22px; font-size: 1.08rem; }
.footer { background: #1e293b; color: #9aa7b9; text-align: center; padding: 26px 16px; font-size: .82rem; }
.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; }
body.large-text { font-size: 20px; }
body.focus-mode .site-header .brand p, body.focus-mode .header-controls, body.focus-mode .footer { display: none; }
body.focus-mode .brand h1 { font-size: 1.05rem; }
body.focus-mode .lesson-main { width: min(860px, calc(100% - 28px)); }
.focus-exit { display: none; position: fixed; right: 18px; bottom: 18px; z-index: 60; }
body.focus-mode .focus-exit { display: block; }

@media (max-width: 900px) {
  .lesson-grid { grid-template-columns: 1fr 1fr; }
  .component-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .tabs-bar { top: 108px; }
}
@media (max-width: 640px) {
  .site-header { position: relative; }
  .header-inner { flex-direction: column; align-items: stretch; padding: 13px 0; }
  .brand { width: 100%; align-items: flex-start; }
  .brand > div { min-width: 0; }
  .brand h1 { font-size: 1.08rem; line-height: 1.45; }
  .brand-mark { width: 40px; height: 40px; font-size: 23px; }
  .brand p { display: none; }
  .header-controls { justify-content: flex-start; gap: 5px; }
  .control-btn { font-size: .78rem; padding: 7px 8px; }
  .score { font-size: .8rem; padding: 7px 9px; }
  .page-shell { padding-top: 22px; }
  .lesson-grid, .reading-grid, .study-layout, .component-grid { grid-template-columns: 1fr; }
  .lesson-card { min-height: 0; }
  .module-head { flex-direction: column; }
  .module-head .primary-btn { width: 100%; }
  .module-actions { width: 100%; justify-content: stretch; }
  .module-actions > * { flex: 1; justify-content: center; text-align: center; }
  .audio-source-note { align-items: flex-start; flex-direction: column; gap: 4px; }
  .option-grid { grid-template-columns: 1fr; }
  .tabs-bar { top: 0; }
  .tab-btn { padding: 9px 10px; }
}

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