:root {
  --bg: #FFFFFF;
  --text: #1A1A1A;
  --muted: #8A8A8A;
  --accent: #7A8F6A;
  --accent-soft: #E8F0E0;
  --correct: #2A9D8F;
  --correct-bg: #E8F6F3;
  --wrong: #E57373;
  --wrong-bg: #FDECEC;
  --tag: #E8F0E0;
  --tag-orange-bg: #FFF0E0;
  --tag-orange: #D4780A;
  --border: #EEEEEE;
  --border-soft: #E6E6E6;
  --charcoal: #1A1A1A;
  --radius: 16px;
  --radius-lg: 20px;
  --tabbar-h: 4.25rem;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --max: 430px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  height: auto;
  min-height: 100%;
  background: #F2F2F2;
  font-size: 16px; /* md 預設根字級；data-font 覆寫 */
}

body {
  min-height: 100%;
  min-height: 100dvh;
  height: auto;
  overflow-x: hidden;
  overflow-y: auto;
  background: #F2F2F2;
  color: var(--text);
  font-family: "PingFang HK", "Noto Sans TC", "Noto Sans CJK HK", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  /* R2.22: block + auto-margin, not row flex. A stray end-tag that
     pops #app would otherwise put later .view next to an empty white
     #app (iPhone: left void, list clipped on the right). Tabbar is
     position:fixed so it stays full-width either way. */
}

#app {
  width: 100%;
  max-width: var(--max);
  min-width: 0;
  margin-inline: auto;
  min-height: 100dvh;
  height: auto;
  background: var(--bg);
  position: relative;
  /* tabbar 不擋列表／內文最底列 */
  padding-bottom: calc(var(--tabbar-h) + 2rem + var(--safe-bottom));
}

.view {
  display: none;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: calc(0.875rem + var(--safe-top)) 1.25rem 1.5rem;
}
.view.active { display: block; }
.view-quiz.active { padding-bottom: calc(4.5rem + var(--safe-bottom)); }
#app.quiz-mode { padding-bottom: 0; }
#app.quiz-mode .tabbar,
#app.quiz-mode ~ .tabbar { display: none; }

/* Brand */
.brand-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}
.brand-row.compact { margin-bottom: 8px; gap: 6px; }
.list-brand { margin-top: 4px; margin-bottom: 10px; }
.brand-logo {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  background: #F7F7F7;
}
.brand-logo.sm { width: 1.75rem; height: 1.75rem; border-radius: 0.4375rem; }
.brand-title {
  font-size: 1.625rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.2;
}
.brand-title.sm { font-size: 1rem; }
.tag-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6875rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
}
.home-caption {
  color: var(--muted);
  font-size: 0.875rem;
  margin: 6px 0 16px;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.25;
  margin-bottom: 4px;
}
.page-sub {
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 16px;
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 2.75rem;
  padding: 4px 4px 4px 0;
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  margin-bottom: 2px;
}
.btn-back::before {
  content: "‹";
  font-size: 1.75rem;
  line-height: 1;
  margin-right: 2px;
}

/* Hero */
.hero {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 1.375rem;
  background: #2a3028;
  min-height: 8.25rem;
}
.hero img {
  width: 100%;
  height: auto;
  max-height: 9.5rem;
  object-fit: cover;
  display: block;
}
.hero-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 18px 18px;
  background: linear-gradient(to top, rgba(20,24,18,0.72), rgba(20,24,18,0.18) 55%, transparent);
  color: #fff;
}
.hero-overlay strong { font-size: 1.1875rem; font-weight: 700; }
.hero-overlay span { font-size: 0.8125rem; opacity: 0.92; margin-top: 3px; }

.section-label {
  font-size: 1.0625rem;
  font-weight: 700;
  margin-bottom: 12px;
}

/* Cards */
.card-list { display: flex; flex-direction: column; gap: 12px; }

.nav-card {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  width: 100%;
  text-align: left;
  padding: 1rem 0.875rem;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  min-height: 4.625rem;
}
.nav-card:active { transform: scale(0.985); }
.nav-card .icon-wrap {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 10px;
  background: #F5F6F4;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.nav-card .icon-wrap img {
  width: 1.375rem;
  height: 1.375rem;
  object-fit: contain;
}
.nav-card .body { flex: 1; min-width: 0; }
.nav-card .body strong {
  display: block;
  font-size: 1.125rem;
  font-weight: 700;
}
.nav-card .body span {
  display: block;
  font-size: 0.8125rem;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.4;
  word-break: break-word;
}
.nav-card .chev {
  color: #C4C4C4;
  font-size: 1.375rem;
  flex-shrink: 0;
  line-height: 1;
}
.nav-card .coming-badge {
  width: 72px;
  height: auto;
  margin-left: 2px;
}


/* Hub: center mode cards in visible content area (portrait phone) */
#view-hub.view.active {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - var(--tabbar-h) - var(--safe-bottom));
  box-sizing: border-box;
}
#hub-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: 0;
  padding: 8px 0 16px;
}
#hub-body .card-list {
  width: 100%;
  max-width: 100%;
}
#hub-body .placeholder-s3 {
  width: 100%;
}

.mode-card {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  width: 100%;
  text-align: left;
  padding: 1.125rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  min-height: 5.25rem;
}
.mode-card:active { transform: scale(0.985); }
.mode-card img.mode-icon {
  width: 2.25rem;
  height: 2.25rem;
  object-fit: contain;
  flex-shrink: 0;
}
.mode-card .body { flex: 1; min-width: 0; }
.mode-card .body strong {
  font-size: 1.0625rem;
  font-weight: 700;
  display: block;
}
.mode-card .body span {
  display: block;
  font-size: 0.8125rem;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.45;
  word-break: break-word;
}
.mode-card .chev { color: #C4C4C4; font-size: 1.375rem; }

/* Knowledge preview grid 4×2 */
.preview-label {
  font-size: 1rem;
  font-weight: 700;
  margin: 22px 0 12px;
}
.topic-preview {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px 6px;
  margin-bottom: 8px;
}
.topic-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4375rem;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  padding: 0.25rem 0.125rem;
  min-height: 4rem;
}
.topic-cell:active { opacity: 0.7; }
.topic-cell img {
  width: 1.75rem;
  height: 1.75rem;
  object-fit: contain;
}
.topic-cell span {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text);
  text-align: center;
  line-height: 1.2;
}

/* List */
.list-block { margin-top: 2px; }
.list-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 1rem 0.125rem;
  min-height: 3.5rem;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-family: inherit;
  color: inherit;
}
.list-row:last-child { border-bottom: none; }
.list-row:active { background: #FAFAFA; }
.list-row .num {
  color: var(--text);
  font-weight: 500;
  font-size: 1rem;
  flex-shrink: 0;
}
.list-row .label {
  flex: 1;
  min-width: 0;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.35;
  word-break: break-word;
}
.list-row .meta {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 400;
}
.list-row .chev { color: #C8C8C8; font-size: 1.125rem; }

/* Reader */
.reader { font-size: 0.9375rem; line-height: 1.75; color: var(--text); }
.reader h3 { font-size: 1rem; margin: 18px 0 8px; color: var(--accent); }
.reader p { margin: 8px 0; }
.reader ul, .reader ol { padding-left: 1.25em; margin: 8px 0; }
.reader li { margin: 4px 0; }
.reader strong { font-weight: 600; }

.practice-box {
  margin-top: 24px;
  padding: 16px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: #FAFBFA;
}
.practice-box h3 {
  font-size: 0.9375rem;
  color: var(--accent);
  margin: 0 0 12px;
}

.passage-card {
  background: #FAFBFA;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  overflow: visible;
  max-height: none;
}
.passage-card .source {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 8px;
}
.passage-card .classical {
  font-size: 1rem;
  line-height: 1.95;
  white-space: pre-wrap;
  letter-spacing: 0.02em;
  word-break: break-word;
  overflow: visible;
  max-height: none;
  -webkit-line-clamp: unset;
  display: block;
}
.passage-card .classical p {
  margin: 0 0 0.85em;
  white-space: pre-wrap;
}
.passage-card .classical p:last-child { margin-bottom: 0; }
.passage-card .notes {
  margin-top: 12px;
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.6;
  border-top: 1px dashed var(--border);
  padding-top: 10px;
}

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 3rem;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 999px;
  background: var(--charcoal);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn-primary:active { opacity: 0.9; }

/* Quiz */
.quiz-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 -4px 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.quiz-title {
  font-size: 1.0625rem;
  font-weight: 600;
  flex: 1;
  text-align: center;
}
.quiz-close {
  width: 2.75rem;
  min-height: 2.75rem;
  border: none;
  background: transparent;
  font-size: 1.25rem;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}
.quiz-top-link {
  min-width: 44px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.875rem;
  cursor: pointer;
  font-family: inherit;
  padding: 8px 4px;
}

.quiz-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6875rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.chip-orange {
  background: var(--tag-orange-bg);
  color: var(--tag-orange);
}
.quiz-count {
  margin-left: auto;
  font-size: 0.8125rem;
  color: var(--muted);
  font-weight: 500;
}

.q-stem {
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.55;
  margin-bottom: 16px;
}
.q-ref {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.option-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 0.9375rem 0.875rem;
  margin-bottom: 0.625rem;
  background: var(--bg);
  border: 1.5px solid var(--border-soft);
  border-radius: 0.875rem;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  min-height: 3.375rem;
  font-size: 0.9375rem;
  line-height: 1.45;
  position: relative;
}
.option-card:active:not(:disabled) { transform: scale(0.99); }
.option-card:disabled { cursor: default; }
.option-card .letter {
  width: 1.75rem;
  min-height: 1.75rem;
  height: auto;
  border-radius: 50%;
  background: #F0F0F0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8125rem;
  flex-shrink: 0;
  color: var(--text);
}
.option-card .opt-text { flex: 1; padding-right: 36px; }
.option-card .mark {
  width: 1.5rem;
  height: 1.5rem;
  flex-shrink: 0;
  display: none;
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
}
.option-card.correct {
  border-width: 2px;
  border-color: var(--correct);
  background: var(--correct-bg);
}
.option-card.correct .letter {
  background: var(--correct);
  color: #fff;
}
.option-card.correct .mark { display: block; }
.option-card.wrong {
  border-width: 2px;
  border-color: var(--wrong);
  background: var(--wrong-bg);
}
.option-card.wrong .letter {
  background: var(--wrong);
  color: #fff;
}
.option-card.wrong .mark { display: block; }
.option-card .your-choice {
  display: none;
  position: absolute;
  right: 42px;
  top: 8px;
  font-size: 0.6875rem;
  color: #fff;
  font-weight: 600;
  background: rgba(229, 115, 115, 0.92);
  padding: 2px 8px;
  border-radius: 999px;
}
.option-card.wrong .your-choice { display: block; }

.explain-panel {
  display: none;
  margin-top: 0.75rem;
  margin-bottom: 1rem;
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  background: #FAFAFA;
  animation: slideIn 180ms var(--ease-out);
}
.explain-panel.show { display: block; }
.explain-panel h4 {
  font-size: 0.9375rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.explain-panel p {
  font-size: 0.875rem;
  line-height: 1.7;
  color: #444;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.quiz-actionbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: var(--max);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0.625rem 1rem calc(0.625rem + var(--safe-bottom));
  background: #fff;
  border-top: 1px solid var(--border);
  z-index: 30;
}
.btn-prev-text {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  padding: 10px 8px;
  min-width: 64px;
  flex-shrink: 0;
}
.btn-prev-text:disabled {
  opacity: 0.35;
  cursor: default;
}
.btn-next-pill {
  flex: 1;
  min-height: 2.875rem;
  border: none;
  border-radius: 999px;
  background: #1A1A1A;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  padding: 0 1.25rem;
}
.btn-next-pill:active { opacity: 0.9; }

.quiz-done-wrap { padding: 24px 0; }
.done-card { text-align: center; padding: 32px 12px; }
.done-card h2 { font-size: 1.375rem; margin-bottom: 8px; }
.done-card p { color: var(--muted); margin-bottom: 24px; font-size: 0.9375rem; }

.footer-note {
  margin-top: 28px;
  font-size: 0.6875rem;
  color: #B0B0B0;
  line-height: 1.55;
  text-align: left;
}

.placeholder-s3 {
  text-align: center;
  padding: 40px 16px;
}
.placeholder-s3 img {
  width: 110px;
  height: auto;
  margin-bottom: 14px;
}
.placeholder-s3 p {
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.55;
}

/* Tab bar — R2.8.1：五等分、白底、頂細灰線、正式 tab_*.png＋二字標（跟 04-tabbar） */
.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: var(--max);
  min-height: calc(var(--tabbar-h) + var(--safe-bottom));
  height: auto;
  padding-bottom: var(--safe-bottom);
  display: flex;
  align-items: stretch;
  background: #FFFFFF;
  border-top: 1px solid #E5E5E5;
  z-index: 40;
}
.tab {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  border: none;
  background: transparent;
  color: #8E8E93; /* inactive 稍淺灰 */
  font-size: 0.6875rem; /* ~11px */
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  font-family: inherit;
  padding: 0.45rem 0 0.35rem;
  min-height: 3.5rem;
  letter-spacing: 0.02em;
  -webkit-tap-highlight-color: transparent;
}
.tab img {
  width: 1.625rem; /* ~26px，介於 24–30 */
  height: 1.625rem;
  object-fit: contain;
  /* R2.8.1：正式 tab_*.png 線稿已是 #373737；僅用 opacity 分態，唔再 brightness(0) */
  opacity: 0.42;
}
.tab.active {
  color: #1A1A1A; /* 選中近黑（跟 04-tabbar） */
  font-weight: 600;
}
.tab.active img {
  opacity: 1; /* 原色 #373737 近黑 */
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 24px + var(--safe-bottom));
  transform: translateX(-50%) translateY(12px);
  max-width: calc(var(--max) - 48px);
  padding: 10px 18px;
  background: rgba(40,40,40,0.92);
  color: #fff;
  font-size: 0.875rem;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out);
  z-index: 60;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}


/* Document scroll: views must not trap overflow */
.view {
  overflow: visible;
  max-height: none;
}
#view-passage-list,
#view-passage,
#passage-list,
#pass-text {
  overflow: visible;
  max-height: none;
}

.hidden { display: none !important; }

/* ---------- Font scale R2.1：根字級驅動全站 rem（標題／正文／按鈕皆 rem） ---------- */
html[data-font="sm"] { font-size: 14px; }
html[data-font="md"] { font-size: 16px; }
html[data-font="lg"] { font-size: 18px; }
html[data-font="xl"] { font-size: 20px; }

.btn-gear {
  margin-left: auto;
  width: 2.5rem;
  min-height: 2.5rem;
  border: none;
  background: #F5F5F5;
  border-radius: 10px;
  font-size: 1.125rem;
  cursor: pointer;
  color: var(--muted);
  font-family: inherit;
}
.btn-gear:active { opacity: 0.8; }

.page-head-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.page-head-row .page-title { flex: 1; margin-bottom: 0; }

.link-btn {
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  padding: 8px 4px;
}
.link-btn.danger { color: var(--wrong); }

.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding: 8px 16px;
  border: 1.5px solid var(--border-soft);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn-outline:active { background: #FAFAFA; }

.settings-card {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.875rem;
  background: #fff;
}
.settings-label {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.settings-hint {
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 12px;
}
.font-scale-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.font-opt {
  min-height: 2.75rem;
  border: 1.5px solid var(--border-soft);
  border-radius: 12px;
  background: #fff;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
}
.font-opt.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.font-preview {
  font-size: 0.9375rem;
  line-height: 1.65;
  color: #333;
  padding: 10px 12px;
  background: #F7F7F7;
  border-radius: 12px;
}

.wrong-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.filter-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  color: var(--muted);
  cursor: pointer;
}
.wrong-list { display: flex; flex-direction: column; gap: 10px; }
.wrong-card {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}
.wrong-card.fixed { opacity: 0.85; }
.wrong-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 14px 14px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  min-height: 4.5rem;
}
.wrong-card-main { flex: 1; min-width: 0; }
.wrong-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.chip-red {
  background: #FDECEC;
  color: var(--wrong);
}
.chip-green {
  background: var(--accent-soft);
  color: var(--accent);
}
.wrong-stem {
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 4px;
}
.wrong-meta {
  font-size: 0.75rem;
  color: var(--muted);
}
.wrong-detail {
  padding: 0 14px 14px;
  border-top: 1px solid var(--border);
}
.wrong-qa {
  font-size: 0.875rem;
  line-height: 1.6;
  margin-top: 10px;
  color: #333;
}
.wrong-qa.ok { color: #1F6F66; }
.wrong-qa strong {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 2px;
  font-weight: 600;
}
.wrong-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.retest-passage-wrap {
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: #FAFBFA;
  overflow: visible;
  max-height: none;
}
.retest-pass-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}
.retest-passage-wrap .classical {
  line-height: 1.95;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: visible;
  max-height: none;
}
.retest-passage-wrap .classical p {
  margin: 0 0 0.85em;
  white-space: pre-wrap;
}
.retest-passage-wrap .classical p:last-child { margin-bottom: 0; }

.quiz-top-link.muted {
  color: var(--muted);
  cursor: default;
  pointer-events: none;
}

/* R2.2 — knowledge true text (≥ reader body, rem scales with root) */
/* R2.5 — merged knowledge tiers */
.know-tier {
  margin: 0 0 1.25rem;
  padding: 0 0 1rem;
  border-bottom: 1px dashed var(--border-soft, #E0E4E0);
}
.know-tier:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}
.know-tier-title {
  margin: 0 0 0.65rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent, #7A8F6A);
  letter-spacing: 0.04em;
}

.reader .level-badge {
  display: inline-block;
  margin: 0 0 0.75rem;
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  background: #EEF6F2;
  color: var(--accent, #2F6F5E);
  font-size: 0.875rem;
  font-weight: 600;
}
.reader .know-lead {
  margin: 0 0 0.75rem;
  font-size: 1em; /* = .reader body */
  line-height: 1.7;
  color: #444;
}
.reader .know-card {
  margin: 0.75rem 0 1rem;
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: #FAFBFA;
  font-size: 1em;
}
.reader .know-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1.0667em; /* ≥ body */
}
.reader .know-chart {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  margin: 0.625rem 0 0.875rem;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: #fff;
}
.reader .know-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0.5rem 0 0.875rem;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: #fff;
}
.reader .know-table {
  width: 100%;
  min-width: 17.5rem;
  border-collapse: collapse;
  font-size: 1em; /* ≥ .reader body；跟根 rem */
  line-height: 1.6;
}
.reader .know-table th,
.reader .know-table td {
  padding: 0.625rem 0.75rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border-soft);
  word-break: break-word;
  font-size: 1em;
}
.reader .know-table th {
  background: #F3F7F5;
  color: var(--accent, #2F6F5E);
  font-weight: 700;
  white-space: nowrap;
}
.reader .know-table tr:last-child td { border-bottom: none; }
.reader .know-table td:first-child { font-weight: 600; white-space: nowrap; }
.reader .know-bullets {
  margin: 0.5rem 0 0.25rem;
  padding-left: 1.2em;
  font-size: 1em;
  line-height: 1.65;
  color: #444;
}
.reader .know-bullets li { margin: 0.25rem 0; }
.reader .know-tip {
  margin: 0.625rem 0 0;
  padding: 0.625rem 0.75rem;
  border-left: 3px solid var(--accent, #2F6F5E);
  background: #F7FAF8;
  font-size: 1em;
  line-height: 1.65;
  color: #444;
}

/* ---------- R2.4: plain text / explain tables / word sheet ---------- */
.passage-plain {
  margin: 0 0 1rem;
}
.passage-plain .source {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 10px;
}
.passage-plain .classical {
  font-size: 1.0625rem;
  line-height: 1.95;
  letter-spacing: 0.02em;
  word-break: break-word;
  color: var(--text);
}
.passage-plain .classical p {
  margin: 0 0 0.95em;
  white-space: pre-wrap;
}
.passage-plain .classical p:last-child { margin-bottom: 0; }
.passage-plain.hidden { display: none !important; }

.pass-explain {
  margin: 0 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.pass-explain.hidden,
.pass-explain[hidden] { display: none !important; }

.explain-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  border: 1px solid #E0E4E0;
  background: #fff;
  font-size: 0.9375rem;
}
.explain-table th,
.explain-table td {
  border: 1px solid #E0E4E0;
  vertical-align: top;
  padding: 0.7rem 0.65rem;
  text-align: left;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.explain-table th {
  width: 4.75rem;
  background: #F2F5F2;
  color: #4A5560;
  font-weight: 600;
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
  line-height: 1.45;
}
.explain-table td {
  background: #fff;
  color: var(--text);
  line-height: 1.75;
}
.explain-table .cell-classical {
  font-size: 1rem;
  line-height: 1.9;
  letter-spacing: 0.02em;
}

/* Highlights (pastel + dashed underline) — used inside explain tables */
.hl {
  display: inline;
  padding: 0.05em 0.12em;
  margin: 0 0.02em;
  border-radius: 0.2em;
  border: none;
  border-bottom: 0.12em dashed currentColor;
  cursor: pointer;
  font: inherit;
  line-height: inherit;
  vertical-align: baseline;
  -webkit-tap-highlight-color: transparent;
  background: transparent;
  color: inherit;
}
.hl:active { filter: brightness(0.95); }
.hl-shi {
  background: #FFF0DA;
  color: #8A5A1A;
  border-bottom-color: #E6963C;
}
.hl-xu {
  background: #EAF4E5;
  color: #4F6344;
  border-bottom-color: #7A8F6A;
}
.hl-tong {
  background: #E4F2F3;
  color: #2F5E63;
  border-bottom-color: #4E8E95;
}
.hl-huo {
  background: #F1E8FB;
  color: #5A3E7A;
  border-bottom-color: #8264B4;
}

/* Black pill toggle — both states */
.btn-explain {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin: 0 0 1rem;
  padding: 0.75rem 1.25rem;
  min-height: 2.875rem;
  border: none;
  border-radius: 999px;
  background: #1A1A1A;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.02em;
}
.btn-explain.hidden { display: none !important; }
.btn-explain:active { opacity: 0.9; }
.btn-explain .btn-explain-label {
  color: inherit;
}

/* Knowledge deco header */
.know-deco {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  margin: 0 0 1rem;
  border-radius: var(--radius);
}

/* Word bottom sheet */
.word-sheet {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.word-sheet.hidden,
.word-sheet[hidden] { display: none !important; }
.word-sheet-mask {
  position: absolute;
  inset: 0;
  border: none;
  padding: 0;
  margin: 0;
  background: rgba(0, 0, 0, 0.38);
  cursor: pointer;
}
.word-sheet-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 430px;
  max-height: min(88vh, 640px);
  overflow-y: auto;
  background: #fff;
  border-radius: 18px 18px 0 0;
  padding: 10px 1.1rem calc(1rem + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.16);
  box-sizing: border-box;
}
.word-sheet-handle {
  width: 2.5rem;
  height: 0.28rem;
  border-radius: 999px;
  background: #D0D4D0;
  margin: 2px auto 14px;
}
.ws-field { margin-bottom: 1rem; }
.ws-label {
  font-size: 0.8125rem;
  color: #8A9290;
  margin-bottom: 0.35rem;
  font-weight: 500;
}
.ws-label.dark { color: #3A3F3E; }
.ws-value {
  font-size: 1rem;
  color: var(--text);
  line-height: 1.55;
}
.ws-word {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.ws-pron {
  background: #E8F6EF;
  border-radius: 12px;
  padding: 0.85rem 0.9rem;
  margin-bottom: 1rem;
}
.ws-jyut {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  margin: 0.15rem 0 0.35rem;
}
.ws-pron-hint {
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  color: #5A6A62;
  line-height: 1.45;
}
.ws-play {
  display: block;
  width: 100%;
  min-height: 2.5rem;
  padding: 0.55rem 1rem;
  border: none;
  border-radius: 999px;
  background: #fff;
  color: #1A1A1A;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.ws-play:active { opacity: 0.92; }
.ws-gloss-box {
  border: 1px solid #E0E4E0;
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--text);
  background: #fff;
}
.ws-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 3rem;
  margin-top: 0.25rem;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 14px;
  background: #1A1A1A;
  color: #fff;
  font-size: 1.0625rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.ws-close-btn:active { opacity: 0.9; }

/* R2.1 — knowledge charts never clip */
img.know-chart,
.reader .know-chart,
img[src*="art/knowledge/chart_"] {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: block;
}

/* ---------- R2 P3: bookmark + vocab（rem 對齊 R2.1） ---------- */
.btn-bookmark {
  min-width: 2.75rem;
  min-height: 2.75rem;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0.375rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}
.btn-bookmark img {
  width: 1.75rem;
  height: 1.75rem;
  object-fit: contain;
  display: block;
}
.btn-bookmark .bm-on { display: none; }
.btn-bookmark.is-on .bm-off { display: none; }
.btn-bookmark.is-on .bm-on { display: block; }

.vocab-sentence {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.7;
  margin-bottom: 0.5rem;
  padding: 0.875rem 1rem;
  background: #FAFAFA;
  border-radius: 0.875rem;
  border: 1px solid var(--border);
}
.vocab-sentence .tw {
  color: var(--accent);
  border-bottom: 0.12em solid var(--accent);
  padding: 0 0.06em;
}
.vocab-source {
  font-size: 0.8125rem;
  color: var(--muted);
  margin-bottom: 0.875rem;
}
.vocab-ask {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.reshuffle-tip {
  font-size: 0.8125rem;
  color: var(--accent);
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.done-card .btn-outline {
  display: block;
}


/* R2.6: home feature entry icons enlarged (~1.5×); grade cards unchanged */
.nav-card.feat-entry {
  min-height: 5.25rem;
  gap: 1rem;
  padding: 1.05rem 0.95rem;
}
.nav-card.feat-entry .icon-wrap {
  width: 3.75rem;
  height: 3.75rem;
  border-radius: 14px;
}
.nav-card.feat-entry .icon-wrap img {
  width: 2.35rem;
  height: 2.35rem;
  object-fit: contain;
}

/* R2.7.2: compact secondary next button (art 360×72 → ~180×36 @2x; tap ≥44px tall) */
.quiz-next-inline {
  margin: 0.75rem 0 1rem;
  padding-bottom: 0.25rem;
  display: flex;
  justify-content: center;
}
.quiz-next-inline.hidden { display: none !important; }
.btn-next-asset {
  display: block;
  width: auto;
  max-width: 13.75rem; /* 220px ≈ 360@~1.64×; height ~44px */
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
}
.btn-next-asset .next-img {
  display: block;
  width: 13.75rem;
  max-width: 100%;
  height: auto;
  border-radius: 999px;
}
.btn-next-asset .next-text {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 13.75rem;
  max-width: 100%;
  min-height: 2.75rem;
  border-radius: 999px;
  background: #1A1A1A;
  color: #fff;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 0 1rem;
  box-sizing: border-box;
}
.btn-next-asset .next-text.hidden { display: none !important; }
.btn-next-asset.is-end .next-img { display: none !important; }
.btn-next-asset.is-end .next-text { display: flex !important; }
.btn-next-asset:active { opacity: 0.92; }

/* Ensure quiz view can scroll past inline next above tab/home safe area */
.view-quiz.active {
  padding-bottom: calc(5.5rem + var(--safe-bottom));
}

/* R2.6: deco assets must not appear even if leftover markup */
.know-deco { display: none !important; }


/* R2.7 word sheet pos + words table */
#ws-pos { font-weight: 600; color: var(--text); }
.words-table-wrap { margin-top: 1rem; overflow-x: auto; }
.words-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.words-table th, .words-table td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.625rem;
  text-align: left;
  vertical-align: top;
}
.words-table th { background: #f7f7f7; font-weight: 600; white-space: nowrap; }
.words-table td.wt-word { font-weight: 600; white-space: nowrap; }
.words-table td.wt-pos { white-space: nowrap; color: var(--muted); }


/* ===== R2.9: color legend / rare / glossary / knowledge media ===== */
.hl-legend {
  margin: 0 0 1rem;
  padding: 0.75rem 0.875rem;
  border-radius: var(--radius, 12px);
  background: #FAFAF7;
  border: 1px solid #E8E4DA;
}
.hl-legend-title {
  font-size: 0.8125rem;
  font-weight: 700;
  color: #3A3A3A;
  margin-bottom: 0.5rem;
}
.hl-legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
}
.hl-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8125rem;
  color: #4A4A4A;
}
.hl-swatch {
  display: inline-block;
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 4px;
  border-bottom: 2px dotted transparent;
  box-sizing: border-box;
}
.hl-swatch.hl-shi { background: #FFF0DA; border-bottom-color: #E6963C; }
.hl-swatch.hl-xu { background: #EAF4E5; border-bottom-color: #7A8F6A; }
.hl-swatch.hl-tong { background: #E4F2F3; border-bottom-color: #4E8E95; }
.hl-swatch.hl-huo { background: #F1E8FB; border-bottom-color: #8264B4; }
.hl-swatch.hl-rare { background: #FDE2E8; border-bottom-color: #C45C7A; }
.hl-legend-hint {
  margin: 0.5rem 0 0;
  font-size: 0.75rem;
  color: #8A8A8A;
}

/* 生僻：粉紅底 #FDE2E8、字色 #C45C7A（NOA／RIN） */
.hl-rare {
  background: #FDE2E8 !important;
  color: #C45C7A !important;
  border-bottom-color: #C45C7A !important;
}

/* R2.10 Glossary — 疏朗卡片 · ①②③ 對齊 */
.glossary-wrap { margin-top: 0.75rem; }
.glossary-cards {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.glossary-card {
  background: #FFFEFA;
  border: 1px solid #E8E4DA;
  border-radius: 16px;
  padding: 1rem 1.05rem 1.1rem;
  box-shadow: 0 1px 0 rgba(0,0,0,0.03);
}
.glossary-card .gl-word {
  font-weight: 800;
  font-size: 1.2rem;
  color: #1A1A1A;
  letter-spacing: 0.04em;
  margin: 0 0 0.65rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px dashed #E5DFD2;
}
.glossary-card .gl-body {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.glossary-card .gl-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.55rem 0.6rem;
  border-radius: 12px;
  background: #F9F6F0;
  line-height: 1.65;
}
.glossary-card .gl-sense {
  font-size: 0.98rem;
  color: #2A2A2A;
}
.glossary-card .gl-sense-text { font-weight: 600; }
.glossary-card .gl-ex,
.glossary-card .gl-tr,
.glossary-card .gl-src {
  font-size: 0.9rem;
  color: #4A4A4A;
  padding-left: 0.1rem;
}
.glossary-card .gl-k {
  display: inline-block;
  min-width: 1.4rem;
  margin-right: 0.25rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: #8A6A3A;
  letter-spacing: 0.06em;
}
.glossary-card .gl-idx {
  color: #8A6A3A;
  font-weight: 700;
  margin-right: 0.28rem;
}


.glossary-card .gl-src.gl-src-pending,
.glossary-card .gl-src-pending {
  color: #8a5a00;
  background: #fff6e0;
  border-radius: 6px;
  padding: 0.15rem 0.35rem;
}
.glossary-card .gl-src-pending::before {
  content: none;
}

/* Knowledge multimedia skeleton (NOA art later) */
.reader .note-card {
  margin: 1rem 0;
  padding: 0.875rem 1rem;
  border-radius: 14px;
  border: 1.5px dashed #C9B896;
  background: #FFFDF7;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.6);
}
.reader .note-card-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #8A6A3A;
  margin-bottom: 0.4rem;
}
.reader .note-pink { background: #FFF5F7; border-color: #E8A0B0; }
.reader .note-amber { background: #FFF8EE; border-color: #E0B878; }
.reader .note-mint { background: #F3FAF1; border-color: #A3C49A; }
.reader .note-lilac { background: #F7F2FC; border-color: #C4A8E0; }
.reader .note-sky { background: #F2F8FA; border-color: #9BBED0; }

.reader .circle-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-right: 0.25rem;
  vertical-align: middle;
}
.reader .circle-yi { background: #FDE2E8; color: #C45C7A; }
.reader .circle-shi { background: #E4F2F3; color: #2F5E63; }

.reader .compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin: 0.85rem 0;
}
@media (max-width: 420px) {
  .reader .compare-grid { grid-template-columns: 1fr; }
}
.reader .compare-card {
  border-radius: 12px;
  padding: 0.75rem;
  border: 1px solid #E5E0D6;
}
.reader .compare-card.yi { background: #FFF5F7; border-color: #E8B0BE; }
.reader .compare-card.shi { background: #F0F7F8; border-color: #A8CDD2; }
.reader .compare-card h4 { margin: 0 0 0.35rem; font-size: 0.95rem; }
.reader .compare-card .def { margin: 0 0 0.35rem; font-size: 0.875rem; }
.reader .compare-card .formula { margin: 0; font-size: 0.8125rem; color: #5A5A5A; }

.reader .path-steps { margin: 0.75rem 0 1rem; }
.reader .path-step {
  display: flex;
  gap: 0.65rem;
  margin: 0.5rem 0;
  align-items: flex-start;
}
.reader .step-num {
  flex: 0 0 1.6rem;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 999px;
  background: #1A1A1A;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.reader .path-step p { margin: 0.2rem 0 0; font-size: 0.875rem; }

.reader .self-test {
  margin: 1rem 0;
  padding: 0.75rem 0.875rem;
  border-radius: 12px;
  background: #F7F9F4;
  border: 1px solid #C5D4B8;
}
.reader .st-q { font-weight: 600; margin: 0.35rem 0; }
.reader .st-ans summary {
  cursor: pointer;
  color: #4F6344;
  font-size: 0.875rem;
  margin-top: 0.35rem;
}
.reader .st-ans p { margin: 0.5rem 0 0; font-size: 0.875rem; }


.reader .know-visual-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0 1rem;
  justify-content: space-between;
}
.reader .viz-circle {
  flex: 1 1 22%;
  min-width: 3.5rem;
  aspect-ratio: 1;
  max-width: 4.5rem;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  font-weight: 700;
  color: #3A3A3A;
}
.reader .viz-circle.c1 { background: #FFF0DA; }
.reader .viz-circle.c2 { background: #EAF4E5; }
.reader .viz-circle.c3 { background: #E4F2F3; }
.reader .viz-circle.c4 { background: #F1E8FB; }

.reader .know-h3 {
  font-size: 1.05rem;
  margin: 1.25rem 0 0.5rem;
  color: #2A2A2A;
}
.reader .know-media-block {
  margin: 1rem 0 1.25rem;
  padding-top: 0.25rem;
  border-top: 1px dashed #DDD6C8;
}

.reader .teach-art-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin: 0.75rem 0;
}
@media (max-width: 420px) {
  .reader .teach-art-row { grid-template-columns: 1fr; }
}
.reader .teach-art {
  margin: 0.5rem 0 0.75rem;
  padding: 0.5rem;
  background: #FFFEFA;
  border: 1px solid #E8E4DA;
  border-radius: 12px;
  text-align: center;
}
.reader .teach-art img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 220px;
  object-fit: contain;
  margin: 0 auto;
}
.reader .teach-art figcaption {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: #8A6A3A;
}
.reader .teach-art-wide img { max-height: 280px; }


/* ---------- R2.10 Knowledge immerse (點選 only) ---------- */
.list-grade-head {
  margin: 0.85rem 0 0.35rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.8125rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #8A6A3A;
  background: #F5F2EA;
  border-radius: 8px;
}
.list-grade-head:first-child { margin-top: 0.25rem; }

.reader .know-hero {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1rem;
  padding: 0.75rem 0.85rem;
  border-radius: 16px;
  background-color: #FFF8EE;
  background-image: url("../art/ui/immersive_panel_bg.png");
  background-size: cover;
  background-position: center;
  border: 1px solid #E8E0D0;
}
.reader .know-hero-art {
  position: relative;
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
}
.reader .know-hero-art img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: 14px;
  background: #fff;
  border: 1px solid #E8E4DA;
}
.reader .know-hero-art img.hero-fallback { padding: 6px; }
.reader .tap-hint-ring {
  position: absolute;
  inset: -6px;
  border-radius: 18px;
  pointer-events: none;
  background: url("../art/ui/tap_hint_ring.png") center / contain no-repeat;
}
.reader .know-hero-cap {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.45;
  color: #4A4A4A;
  font-weight: 600;
}

.reader .chip-panel,
.reader .immersive-panel {
  font-size: 0.8125rem;
  line-height: 1.5;
  color: #3A3A3A;
  margin-top: 0.15rem;
  padding: 0.45rem 0.5rem;
  border-radius: 10px;
  background-color: rgba(255,255,255,0.78);
  background-image: url("../art/ui/immersive_panel_bg.png");
  background-size: cover;
  border: 1px solid rgba(0,0,0,0.05);
}
.reader .compare-card .immersive-panel[hidden] {
  display: none !important;
}

.reader .note-hot {
  cursor: pointer;
  transition: none; /* ui-motion: no box-shadow transitions */
}
.reader .note-hot .tap-mini {
  margin-left: 0.35rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: #A08050;
  opacity: 0.85;
}
.reader .note-hot:not(.is-open) > :not(.note-card-label) {
  display: none;
}
.reader .note-hot.is-open {
  box-shadow: 0 0 0 2px rgba(138, 106, 58, 0.25);
}
.reader .note-hot.is-open .tap-mini { display: none; }

.reader table.know-table-hot tbody tr {
  cursor: pointer;
  transition: none; /* ui-motion: no background transitions */
}
.reader table.know-table-hot tbody tr.is-hot {
  background: #FFF3D6;
  outline: 2px solid #E0B878;
  outline-offset: -2px;
}
.reader table.know-table-hot tbody tr:focus-visible {
  outline: 2px solid #C45C7A;
}

.reader .viz-circle {
  cursor: pointer;
}
.reader .viz-circle.is-hot {
  box-shadow: 0 0 0 3px rgba(78, 142, 149, 0.45);
  transform: scale(1.04);
}


.reader .know-chart-slot.chart-missing {
  display: none;
}
.reader .teach-art img[src*="hero_"] { max-height: 160px; }


/* R2.11 function words — pattern / cat / note */
.glossary-card .gl-cat {
  margin-left: 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: #7A8F6A;
  letter-spacing: 0.04em;
  vertical-align: middle;
}
.glossary-card .gl-alias {
  margin-left: 0.45rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: #8A6A3A;
}
.glossary-card .gl-note {
  margin: 0 0 0.55rem;
  font-size: 0.82rem;
  color: #6A6A6A;
  line-height: 1.5;
}
.glossary-card .gl-pat {
  font-size: 0.88rem;
  color: #3A5A4A;
  padding-left: 0.1rem;
}
.glossary-card .gl-pat-text {
  font-weight: 700;
  color: #2F6B4F;
  background: #EAF4E5;
  border-radius: 6px;
  padding: 0.05rem 0.35rem;
}
.fw-banner {
  margin: 0 0 0.85rem;
  padding: 0.7rem 0.85rem;
  font-size: 0.86rem;
  line-height: 1.55;
  color: #4A4A4A;
  background: #F3F7F0;
  border: 1px solid #D5E2CF;
  border-radius: 12px;
}
.know-table .pat-tag {
  display: inline-block;
  margin-left: 0.25rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: #2F6B4F;
  background: #EAF4E5;
  border-radius: 6px;
  padding: 0.05rem 0.35rem;
  white-space: nowrap;
}

/* ===== R2.12 — content lightbox + knowledge media DOM text ===== */
.img-lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  padding-bottom: calc(1rem + var(--safe-bottom));
}
.img-lightbox.hidden,
.img-lightbox[hidden] {
  display: none !important;
}
.img-lightbox-mask {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  margin: 0;
  background: rgba(20, 18, 14, 0.72);
  cursor: pointer;
}
.img-lightbox-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 26rem);
  max-height: min(88dvh, 40rem);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.65rem;
  padding: 0.75rem 0.75rem 0.9rem;
  border-radius: 16px;
  background: #FFFEFA;
  border: 1px solid #E8E4DA;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
}
.img-lightbox-panel img {
  display: block;
  width: 100%;
  max-height: min(70dvh, 32rem);
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  background: #fff;
}
.img-lightbox-cap {
  margin: 0;
  font-size: 0.875rem; /* rem → follows html[data-font] */
  line-height: 1.45;
  font-weight: 600;
  color: #4A4A4A;
  text-align: center;
}
.img-lightbox-close {
  align-self: center;
  min-height: 2.5rem;
  padding: 0.45rem 1.35rem;
  border-radius: 999px;
  border: 1px solid #E0D8C8;
  background: #F5F2EA;
  color: #2A2A2A;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
}

img.content-zoomable,
.teach-media-frame img.content-zoomable,
.know-hero-art img.content-zoomable {
  cursor: zoom-in;
}
img.content-zoomable:focus-visible {
  outline: 2px solid #C45C7A;
  outline-offset: 2px;
}

.reader .teach-sys-caption {
  display: block;
  margin: 0.35rem 0 0;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: #6F5A3A;
  text-align: center;
}
.reader .teach-sys-note {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  line-height: 1.4;
  color: #8A6A3A;
}
.reader .teach-art.media-broken,
.reader .know-hero.media-broken .know-hero-art {
  outline: 2px dashed #E57373;
  outline-offset: 2px;
}
.reader .teach-art.media-broken::after {
  content: "圖片未能載入";
  display: block;
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: #E57373;
}

/* R2.12: hero 改為內容圖寬幅（舊 64×64 會把焗字卡壓成破圖） */
.reader .know-hero {
  flex-direction: column;
  align-items: stretch;
  gap: 0.55rem;
}
.reader .know-hero-art {
  width: 100%;
  height: auto;
  align-self: stretch;
}
.reader .know-hero-art img {
  width: 100%;
  height: auto;
  max-height: 220px;
  object-fit: contain;
  border-radius: 14px;
  background: #fff;
  border: 1px solid #E8E4DA;
}
.reader .know-hero-art .tap-hint-ring {
  display: none; /* 寬圖唔再用細熱點環 */
}
.reader .know-hero-cap {
  font-size: 0.9375rem; /* system font; follows data-font */
}

/* chart：圖下系統字說明＋可放大；色塊與表格仍是主說明 */
.reader .know-chart-slot .teach-sys-note {
  font-weight: 600;
}

/* ===== R2.13 — image hotspots + corner zoom badge ===== */
.reader .teach-media-frame,
.reader .know-hero-art.teach-media-frame,
.reader figure.teach-art.teach-media-frame {
  position: relative;
}

.reader .media-zoom-badge {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  z-index: 5;
  margin: 0;
  padding: 0.28rem 0.55rem;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #5A4A32;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
.reader .media-zoom-badge:focus-visible {
  outline: 2px solid #C45C7A;
  outline-offset: 2px;
}

.reader .img-hotspot {
  position: absolute;
  z-index: 4;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  margin: 0;
  padding: 0.15rem;
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  color: inherit;
  min-width: 2.4rem;
  -webkit-tap-highlight-color: transparent;
}
.reader .img-hotspot .hotspot-dot {
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 999px;
  background: url("../art/ui/hotspot_dot.png") center / contain no-repeat;
  background-color: #C45C7A;
  box-shadow: 0 0 0 3px rgba(196, 92, 122, 0.28), 0 1px 4px rgba(0, 0, 0, 0.15);
  pointer-events: none;
}
.reader .img-hotspot-lab {
  max-width: 4.8rem;
  padding: 0.12rem 0.35rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.06);
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.25;
  color: #3A3A3A;
  text-align: center;
  pointer-events: none;
}
.reader .img-hotspot.is-open .hotspot-dot {
  box-shadow: 0 0 0 4px rgba(196, 92, 122, 0.45), 0 1px 4px rgba(0, 0, 0, 0.15);
}
.reader .img-hotspot:focus-visible {
  outline: 2px solid #C45C7A;
  outline-offset: 3px;
  border-radius: 10px;
}

.reader .img-hotspot-reveal {
  margin: 0.45rem 0 0.75rem;
  padding: 0.7rem 0.8rem;
  border-radius: 14px;
  border: 1px solid #E8E0D0;
  background-color: #FFF8EE;
  background-image: url("../art/ui/immersive_panel_bg.png");
  background-size: cover;
}
.reader .img-hotspot-reveal[hidden] {
  display: none !important;
}
.reader .img-hotspot-reveal-lab {
  margin: 0 0 0.35rem;
  font-size: 0.9rem;
  font-weight: 800;
  color: #4A3A28;
}
.reader .img-hotspot-reveal-body {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.55;
  color: #3A3A3A;
}

/* knowledge media: image itself is not the zoom control */
.reader .know-hero-art img,
.reader figure.teach-art img {
  cursor: default;
}

.reader .media-zoom-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.reader .media-zoom-badge-icon {
  width: 1.15rem;
  height: 1.15rem;
  object-fit: contain;
  pointer-events: none;
}
