:root {
  --bg: #FAECD2; --paper: #FFFCF5; --ink: #3A2E2A; --ink-soft: #7A6A60; --red: #C44828; --red-deep: #8E2E14;
  --green: #9CD08A; --green-deep: #5E9A4B; --sand: #E8D3A8; --hl: #FFE27A;
  --ui: ui-rounded, "PingFang TC", "Noto Sans TC", system-ui, sans-serif;
  --kai: "BiauKai", "DFKai-SB", "標楷體", "Kaiti TC", "STKaiti", serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body { font-family: var(--ui); color: var(--ink); background: var(--bg);
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
  -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
.loading { text-align: center; margin-top: 40vh; color: var(--ink-soft); }
main { max-width: 720px; margin: 0 auto; padding: 12px 16px 40px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pill { border: 0; background: var(--paper); border-radius: 999px; padding: 6px 14px 6px 6px; min-height: 44px; display: flex; align-items: center; gap: 6px; box-shadow: 0 3px 0 var(--sand); }
.pill img { width: 36px; height: 36px; object-fit: contain; }
.icon-btn { border: 0; background: var(--paper); border-radius: 50%; width: 44px; height: 44px; font-size: 1.2rem; box-shadow: 0 3px 0 var(--sand); }
h1 { font-size: 1.5rem; margin: 12px 0 4px; }
.sub { color: var(--ink-soft); margin: 0 0 12px; }
.card { background: var(--paper); border-radius: 22px; padding: 14px 16px; margin: 12px 0; box-shadow: 0 4px 0 rgba(58,46,42,.08); }
.big-btn { border: 0; border-radius: 999px; background: var(--red); color: #fff; font-weight: 700; font-size: 1.05rem; padding: 12px 22px; min-height: 50px; box-shadow: 0 5px 0 var(--red-deep); display: inline-flex; align-items: center; gap: 8px; justify-content: center; }
.big-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--red-deep); }
.big-btn.soft { background: var(--paper); color: var(--ink); box-shadow: 0 5px 0 var(--sand); }
.big-btn.small { padding: 8px 16px; min-height: 42px; font-size: .95rem; }
.big-btn:disabled { opacity: .45; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 10px 0; }
.row.center { justify-content: center; }
.small { font-size: .88rem; color: var(--ink-soft); line-height: 1.6; }
.link-btn { border: 0; background: none; text-decoration: underline; color: var(--ink-soft); min-height: 40px; padding: 6px; }
.link-btn.danger { color: #A1331B; }

/* 選人 */
.who { min-height: 90vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; text-align: center; }
.pick { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; }
.pick-btn { border: 0; background: var(--paper); border-radius: 28px; width: 180px; padding: 16px; box-shadow: 0 6px 0 var(--sand); display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 1.3rem; font-weight: 700; }
.pick-btn img { height: 130px; }

/* 課次島 */
.lessons { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.lesson { border: 0; text-align: left; background: var(--paper); border-radius: 22px; padding: 14px; box-shadow: 0 4px 0 var(--sand); display: flex; flex-direction: column; gap: 4px; min-height: 120px; }
.lesson .no { font-size: .85rem; color: var(--ink-soft); }
.lesson .ttl { font-size: 1.25rem; font-weight: 700; font-family: var(--kai); }
.lesson .st { font-size: .9rem; margin-top: auto; }
.lesson.done { background: #E9F6E2; box-shadow: 0 4px 0 #BFDDB0; }
.lesson.doing { outline: 3px solid var(--hl); }
.badge { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: .8rem; background: #FFF1C9; }

/* 測驗 */
.progress { height: 10px; border-radius: 999px; background: var(--paper); overflow: hidden; margin: 8px 0; }
.progress span { display: block; height: 100%; background: var(--green-deep); }
.q-card { background: var(--paper); border-radius: 26px; padding: 22px 18px; margin-top: 10px; text-align: center; box-shadow: 0 4px 0 rgba(58,46,42,.08); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.q-kind { font-weight: 700; color: var(--red); }
.q-sentence { font-family: var(--kai); font-size: clamp(1.6rem, 6vw, 2.3rem); line-height: 1.7; margin: 6px 0; }
.q-sentence .blank { display: inline-block; border-bottom: 3px solid var(--ink); min-width: 1.2em; margin: 0 .1em; color: transparent; }
.q-word { font-family: var(--kai); font-size: clamp(2.4rem, 11vw, 3.4rem); letter-spacing: .1em; }
.q-word .target { color: var(--red); border-bottom: 3px solid var(--red); }
.q-prompt { font-family: var(--kai); font-size: clamp(1.4rem, 5.5vw, 1.9rem); line-height: 1.5; }
.speaker { width: 88px; height: 88px; border-radius: 50%; border: 0; background: var(--red); color: #fff; font-size: 2.2rem; box-shadow: 0 6px 0 var(--red-deep); }
.speaker:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--red-deep); }
.nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; }

/* 對答案 */
.ans-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-top: 1px dashed var(--sand); }
.ans-item .n { color: var(--ink-soft); min-width: 1.8em; }
.ans-item .body { flex: 1; line-height: 1.6; }
.ans-item .answer { font-family: var(--kai); font-size: 1.35rem; font-weight: 700; color: var(--red-deep); }
.mark { display: flex; gap: 6px; }
.mark button { width: 48px; height: 48px; border-radius: 14px; border: 2px solid var(--sand); background: #fff; font-size: 1.3rem; }
.mark button.ok[aria-pressed="true"] { background: var(--green-deep); color: #fff; border-color: var(--green-deep); }
.mark button.ng[aria-pressed="true"] { background: #D2462C; color: #fff; border-color: #D2462C; }
.sec-title { margin: 16px 0 4px; font-size: 1.1rem; }

/* 開張跟讀 */
.read-card { background: var(--paper); border-radius: 26px; padding: 22px 18px; text-align: center; margin-top: 14px; box-shadow: 0 4px 0 rgba(58,46,42,.08); }
.read-step { font-family: var(--kai); opacity: .25; transition: opacity .3s, transform .3s; margin: 10px 0; }
.read-step.on { opacity: 1; transform: scale(1.04); }
.read-char { font-size: 4rem; color: var(--red); }
.read-word { font-size: 2.6rem; letter-spacing: .1em; }
.read-sent { font-size: 1.7rem; line-height: 1.6; }
.read-sent b { color: var(--red); }
.read-mean { font-size: 1.1rem; color: var(--ink-soft); font-family: var(--ui); }

/* 抽屜、提示 */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(58,46,42,.35); }
.sheet { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); width: min(100%, 600px); max-height: 90vh; overflow-y: auto; background: var(--paper); border-radius: 26px 26px 0 0; padding: 20px 18px calc(24px + env(safe-area-inset-bottom, 0)); }
.sheet-close { position: absolute; top: 10px; right: 10px; width: 44px; height: 44px; border: 0; border-radius: 50%; background: #F1E6D0; }
.text-in { width: 100%; font: inherit; font-size: 1rem; padding: 10px; border-radius: 12px; border: 2px solid var(--sand); background: #fff; margin: 4px 0; }
textarea.text-in { resize: vertical; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 16px; z-index: 30; max-width: 90vw; text-align: center; }
.seg { display: flex; gap: 8px; }
.seg button { flex: 1; border: 2px solid var(--sand); background: #fff; border-radius: 12px; padding: 8px; min-height: 44px; }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
ul.plain { padding-left: 1.1em; line-height: 1.7; }
