:root {
  --sky: #5aa9e6;
  --sky-soft: #e3f1fb;
  --sky-ink: #1f5f94;
  --grass: #7bb661;
  --grass-soft: #eaf5e1;
  --grass-ink: #2e6b22;
  --beige: #f7efdd;
  --paper: #fffaf0;
  --sand: #efe2c6;
  --coral: #c24a34;
  --coral-hover: #a83e2b;
  --coral-soft: #fbe6e0;
  --gold: #a8741a;
  --gold-soft: #fbf0d6;
  --ink: #3f2e22;
  --muted: #6b5848;
  --line: #e5d7bb;
  --bad: #b8322a;
  --ok: #2e7d32;
  --miss: #6a6a6a;
  --extra: #8a4f00;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 6px 18px rgba(92, 70, 40, .10);
  --font: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Heiti TC", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--ink); font-size: 17px; line-height: 1.65;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(90, 169, 230, .20), transparent 60%),
    radial-gradient(900px 400px at 100% 0%, rgba(123, 182, 97, .16), transparent 60%),
    var(--beige);
  min-height: 100vh;
}
img { max-width: 100%; display: block; }
a { color: var(--sky-ink); }
a:hover { color: #164a74; }
:focus-visible { outline: 3px solid #1f5f94; outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: -999px; top: 8px; background: #fff; padding: 8px 14px; border-radius: 8px; z-index: 10; }
.skip:focus { left: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- 頁首 ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  background: rgba(255, 250, 240, .94); backdrop-filter: blur(6px);
  border-bottom: 2px solid var(--line);
}
.top-in { max-width: 1120px; margin: 0 auto; padding: 8px 16px; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand img { width: 44px; height: 44px; border-radius: 50%; box-shadow: 0 0 0 3px #fff, 0 2px 6px rgba(0,0,0,.12); }
.brand b { display: block; font-size: 18px; line-height: 1.2; letter-spacing: .2px; white-space: nowrap; }
.brand small { display: block; color: var(--grass-ink); font-size: 13px; line-height: 1.2; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.who { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
.nav { max-width: 1120px; margin: 0 auto; padding: 0 12px 8px; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  flex: none; text-decoration: none; color: var(--ink); padding: 8px 14px; border-radius: 999px; font-size: 15px;
  background: transparent; border: 2px solid transparent; min-height: 40px; display: inline-flex; align-items: center;
}
.nav a:hover { background: var(--sky-soft); }
.nav a[aria-current="page"] { background: var(--sky); color: #fff; font-weight: 700; background: #276da6; }

main { max-width: 1120px; margin: 0 auto; padding: 18px 16px 64px; }
h1 { font-size: 26px; margin: 6px 0 14px; line-height: 1.35; }
h2 { font-size: 20px; margin: 0 0 10px; line-height: 1.4; }
h3 { font-size: 17px; margin: 0 0 6px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--paper); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  border: 2px solid #f1e6cf; margin-bottom: 16px;
}
.card.sky { border-color: #cfe5f6; background: linear-gradient(180deg, #f4faff, var(--paper)); }
.card.grass { border-color: #d6eac9; background: linear-gradient(180deg, #f5fbf0, var(--paper)); }
.card h2 .pill { vertical-align: middle; }
.grid { display: grid; gap: 16px; }
@media (min-width: 900px) {
  .grid.two { grid-template-columns: 1fr 1fr; }
  .grid.side { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; }
}
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.stack > * + * { margin-top: 10px; }

/* ---------- 按鈕 ---------- */
.btn {
  appearance: none; border: 2px solid transparent; border-radius: 999px; padding: 10px 20px; font: inherit; font-size: 16px;
  font-weight: 700; cursor: pointer; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none; line-height: 1.2; transition: background .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--coral); color: #fff; box-shadow: 0 3px 0 #9a3a28; }
.btn.primary:hover { background: var(--coral-hover); color: #fff; }
.btn.blue { background: #276da6; color: #fff; box-shadow: 0 3px 0 #1f5f94; }
.btn.blue:hover { background: #1f5f94; color: #fff; }
.btn.green { background: #377a28; color: #fff; box-shadow: 0 3px 0 #2e6b22; }
.btn.green:hover { background: #2e6b22; color: #fff; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--sky-soft); }
.btn.small { min-height: 38px; padding: 6px 14px; font-size: 15px; }
.btn.link { background: none; border: 0; color: var(--sky-ink); padding: 6px 4px; min-height: 38px; text-decoration: underline; font-weight: 500; }
.btn.wide { width: 100%; }

/* ---------- 表單 ---------- */
label { display: block; font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.hint { font-weight: 400; color: var(--muted); font-size: 14px; }
input[type=text], input[type=password], input[type=number], input[type=datetime-local], select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: #fff; border: 2px solid #d9c8a6; border-radius: var(--radius-sm);
  padding: 10px 12px; min-height: 46px;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { border-color: #276da6; outline: 3px solid rgba(47, 127, 192, .25); outline-offset: 0; }
.field { margin-bottom: 14px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 500; }
.check input { width: 22px; height: 22px; margin-top: 3px; flex: none; }
.form-grid { display: grid; gap: 0 14px; }
@media (min-width: 720px) { .form-grid.cols { grid-template-columns: repeat(2, minmax(0, 1fr)); } .form-grid.cols3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.err { color: var(--bad); font-size: 15px; margin: 6px 0 0; }
.notice { border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 14px; font-size: 16px; }
.notice.info { background: var(--sky-soft); color: #174a73; }
.notice.ok { background: var(--grass-soft); color: #245a1a; }
.notice.warn { background: var(--gold-soft); color: #6d4a07; }
.notice.bad { background: var(--coral-soft); color: #8f2a1c; }

/* ---------- 標籤 ---------- */
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 14px; font-weight: 700; line-height: 1.6; white-space: nowrap; }
.pill.todo { background: #fdebd0; color: #8a4b00; }
.pill.done { background: #e1f2d8; color: #245a1a; }
.pill.wait { background: #ddeefb; color: #174a73; }
.pill.late { background: #fbe0da; color: #8f2a1c; }
.pill.grey { background: #ece6da; color: #574636; }
.pill.demo { background: #f3e3ff; color: #5b2a86; }

/* ---------- 首頁 ---------- */
.hero { position: relative; border-radius: 22px; overflow: hidden; box-shadow: var(--shadow); border: 4px solid #fff; background: #cfe5f6; }
.hero img { width: 100%; height: auto; aspect-ratio: 16 / 9; }
.hero { display: block; transition: transform .15s, box-shadow .15s; }
.hero:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(92, 70, 40, .18); }
.hero:focus-visible { outline: 4px solid #1f5f94; outline-offset: 4px; }
@media (prefers-reduced-motion: reduce) { .hero, .hero:hover { transition: none; transform: none; } }
.steps { display: grid; gap: 14px; margin-top: 18px; }
@media (min-width: 760px) { .steps { grid-template-columns: repeat(3, 1fr); } }
.step { background: var(--paper); border-radius: var(--radius); padding: 16px; border: 2px solid #f1e6cf; box-shadow: var(--shadow); }
.step .num { display: inline-flex; width: 34px; height: 34px; border-radius: 50%; align-items: center; justify-content: center; color: #fff; font-weight: 800; margin-bottom: 6px; }
.step:nth-child(1) .num { background: #276da6; } .step:nth-child(2) .num { background: var(--coral); } .step:nth-child(3) .num { background: #377a28; }

/* ---------- 登入 ---------- */
.auth { max-width: 440px; margin: 10px auto; }
.auth .logo { width: 220px; margin: 0 auto 6px; }
.auth h1 { text-align: center; font-size: 22px; margin-bottom: 4px; }
.auth .sub { text-align: center; color: var(--grass-ink); margin-bottom: 16px; font-weight: 700; }

/* ---------- 課程清單 ---------- */
.course-title { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.course-title .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--sky); flex: none; }
.course-title .dot.g { background: var(--grass); }
.alist { list-style: none; padding: 0; margin: 0; }
.alist li + li { margin-top: 10px; }
.aitem {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius-sm); background: #eef6fd;
  text-decoration: none; color: var(--ink); border: 2px solid transparent; min-height: 56px;
}
.aitem:hover { border-color: #9fcaee; color: var(--ink); }
.aitem .t { font-weight: 700; flex: 1; min-width: 0; }
.aitem .t small { display: block; font-weight: 400; color: var(--muted); font-size: 14px; }
.aitem .go { color: var(--sky-ink); font-size: 20px; }

/* ---------- 朗讀頁 ---------- */
.passage {
  font-size: 22px; line-height: 1.9; background: #fff; border: 2px solid #eadbbd; border-radius: var(--radius-sm); padding: 14px 16px;
  font-family: "Nunito", "Segoe UI", "Helvetica Neue", Arial, var(--font); letter-spacing: .2px; word-break: break-word;
}
@media (min-width: 900px) { .passage { font-size: 24px; } }
.model { display: flex; flex-direction: column; gap: 6px; background: var(--sky-soft); border-radius: var(--radius-sm); padding: 12px 14px; margin: 14px 0; }
.model b { color: #174a73; }
audio { width: 100%; height: 44px; }
.recorder { text-align: center; padding: 8px 0 4px; }
.rec-btn {
  width: min(100%, 320px); min-height: 64px; font-size: 20px; border-radius: 999px; border: 0; cursor: pointer; font-weight: 800;
  background: var(--coral); color: #fff; box-shadow: 0 4px 0 #9a3a28; font-family: inherit; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
}
.rec-btn:hover { background: var(--coral-hover); }
.rec-btn .dot { width: 16px; height: 16px; border-radius: 50%; background: #fff; }
.rec-btn.on { background: #8f2a1c; box-shadow: 0 4px 0 #5e1b12; }
.rec-btn.on .dot { border-radius: 3px; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .rec-btn.on .dot { animation: none; } }
.rec-time { font-variant-numeric: tabular-nums; font-size: 18px; margin-top: 8px; color: var(--muted); min-height: 28px; }
.rec-actions { display: flex; gap: 10px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.rec-actions .btn { min-width: 132px; }
.meter { height: 8px; border-radius: 99px; background: #f0e3c8; overflow: hidden; width: min(100%, 320px); margin: 10px auto 0; }
.meter i { display: block; height: 100%; width: 0; background: var(--grass); transition: width .08s; }

/* ---------- 回饋 ---------- */
.marked .w { padding: 0 1px; border-radius: 4px; }
.marked .correct { color: var(--ok); font-weight: 700; }
.marked .wrong { color: var(--bad); font-weight: 800; text-decoration: underline wavy; text-underline-offset: 5px; text-decoration-thickness: 2px; }
.marked .missed { color: var(--miss); text-decoration: line-through; text-decoration-thickness: 2px; }
.marked .extra { color: var(--extra); font-style: italic; border: 2px dotted #c98a2b; padding: 0 4px; font-size: .88em; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14px; margin-top: 10px; color: var(--muted); }
.legend span b { font-size: 15px; }
.scores { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.scores.four { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 640px) { .scores.four { grid-template-columns: repeat(4, 1fr); } }
.score { background: var(--grass-soft); border-radius: var(--radius-sm); padding: 10px 6px; text-align: center; font-size: 15px; color: #2b4f21; }
.score b { display: block; font-size: 28px; line-height: 1.2; color: #245a1a; }
.score.total { background: #fde7df; color: #7d2a1b; }
.score.total b { color: #9a2f1d; }
.bubble { background: #eef6fd; border-radius: var(--radius-sm); padding: 12px 14px; margin-top: 10px; display: flex; gap: 10px; }
.bubble.teacher { background: var(--gold-soft); }
.bubble .ic { font-size: 22px; line-height: 1.3; flex: none; }
.bubble ul { margin: 0; padding-left: 18px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 16px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid #eadfc9; vertical-align: middle; }
th { color: var(--muted); font-weight: 700; font-size: 14px; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num { font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  table.cards thead { display: none; }
  table.cards tr { display: block; padding: 10px 0; border-bottom: 1px solid #eadfc9; }
  table.cards td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 4px 2px; }
  table.cards td::before { content: attr(data-label); color: var(--muted); font-size: 14px; font-weight: 700; }
  table.cards td.main { font-weight: 800; font-size: 17px; }
  table.cards td.main::before { content: none; }
}

/* ---------- 統計 ---------- */
.stat { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .stat { grid-template-columns: repeat(4, 1fr); } }
.stat div { background: #eef6fd; border-radius: var(--radius-sm); padding: 10px; text-align: center; font-size: 14px; color: #174a73; }
.stat b { display: block; font-size: 24px; color: #174a73; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.chip { background: #fff; border: 2px solid #eadbbd; border-radius: 999px; padding: 2px 12px; font-size: 15px; }
.bar { height: 10px; background: #efe3c9; border-radius: 99px; overflow: hidden; min-width: 80px; }
.bar i { display: block; height: 100%; background: var(--grass); }

details.panel { background: var(--paper); border-radius: var(--radius); border: 2px solid #f1e6cf; box-shadow: var(--shadow); margin-bottom: 16px; }
details.panel > summary { cursor: pointer; padding: 14px 18px; font-weight: 800; font-size: 17px; list-style: none; display: flex; align-items: center; gap: 8px; min-height: 52px; }
details.panel > summary::before { content: "＋"; color: var(--coral); font-weight: 900; }
details.panel[open] > summary::before { content: "－"; }
details.panel > .in { padding: 0 18px 18px; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: #3f2e22; color: #fff; padding: 12px 18px; border-radius: 14px;
  box-shadow: 0 8px 22px rgba(0,0,0,.25); z-index: 20; max-width: calc(100% - 32px); font-size: 16px;
}
.toast[hidden] { display: none; }
.empty { text-align: center; padding: 26px 10px; color: var(--muted); }
.empty img { width: 120px; margin: 0 auto 8px; opacity: .95; }
.loading { padding: 30px; text-align: center; color: var(--muted); }
.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 20px 0 30px; }
.back { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 8px; text-decoration: none; font-weight: 700; min-height: 40px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.inline-form .field { flex: 1 1 180px; margin-bottom: 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
a.card { display: block; text-decoration: none; color: var(--ink); transition: border-color .15s; }
a.card:hover { border-color: #9fcaee; color: var(--ink); }
a.card h2 { color: var(--sky-ink); }
hr.sep { border: 0; border-top: 2px dashed var(--line); margin: 16px 0; }
.mt { margin-top: 14px; }
details > summary.muted { cursor: pointer; margin-top: 10px; min-height: 36px; }
main:focus, main:focus-visible { outline: none; }
.btn { white-space: nowrap; }
.bubble + .passage, .notice + .passage { margin-top: 12px; }
@media (max-width: 560px) {
  .who { display: none; }
  .brand b { font-size: 16px; }
  h1 { font-size: 22px; }
  .card { padding: 14px; }
}
.auth form + p { margin-top: 14px; text-align: center; }
