/* 寫作發芽 —— 簡潔樣式（需求 §50：不要過度設計 UI） */
/* 色調呼應「發芽」意象：主色是嫩芽綠，卡片維持白底，孩子卡沿用原本的暖色調（像土壤／種子） */

:root {
  /* 色票沿用設計團隊 UI 參考檔（writing-sprout-ui-package/styles.css）的 token 數值 */
  --ink: #153326;
  --muted: #52675b;
  --line: #dbe6de;
  --bg: #f2f7f3;
  --card: #ffffff;
  --surface-soft: #eef6f0;
  --primary: #2f8554;
  --primary-dark: #236c43;
  --blue: #2f5f9d;
  --blue-bg: #eaf2fb;
  --amber: #e1a92a;
  --amber-ink: #9b6b13;
  --amber-bg: #fff4d9;
  --child-bg: #fef7ec;
  --child-line: #f0d9a8;
  --error-bg: #fdecec;
  --error-ink: #b0342a;
}

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

body {
  margin: 0;
  min-width: 320px;
  font-family: "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.7;
  overflow-x: hidden;
}

/* 響應式護欄：圖片/圖表不溢位、中文長句正常斷行（不逐字直排、不 break-all） */
img { display: block; max-width: 100%; }
svg { max-width: 100%; }
h1, h2, h3, p, li, td, th, a, button, span { overflow-wrap: anywhere; }

.container {
  width: min(100% - 24px, 1180px);
  margin-inline: auto;
}
@media (min-width: 768px) {
  .container { width: min(100% - 40px, 1180px); }
}

.site-header {
  background: var(--primary);
  color: #fff;
  padding: 14px 0;
}
.site-header-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.site-header .brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  text-decoration: none;
  font-size: 1.15rem;
  font-weight: 700;
}
.brand-icon { flex-shrink: 0; }
.site-nav { display: flex; gap: 16px; }
.site-nav a { color: #fff; text-decoration: none; font-size: 0.95rem; opacity: 0.9; }
.site-nav a:hover { opacity: 1; text-decoration: underline; }
.site-footer {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 24px 0;
  text-align: center;
}

main.container { padding-top: 24px; padding-bottom: 24px; }

h1 { font-size: 1.6rem; margin: 0 0 16px; }
h2 { font-size: 1.4rem; margin: 0 0 12px; }
h3 { font-size: 1.05rem; margin: 16px 0 6px; }

a { color: var(--primary); }

.muted { color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
  min-width: 0;
}
@media (min-width: 768px) { .card { padding: 20px; border-radius: 16px; } }
@media (min-width: 1100px) { .card { padding: 24px; } }

/* 可展開／收合的卡片（原生 details/summary，不用 JS） */
details.card summary {
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
}
details.card[open] summary { margin-bottom: 12px; }
details.card .details-body > *:first-child { margin-top: 0; }

/* 表單 */
.stack { display: flex; flex-direction: column; gap: 12px; }
label { display: block; font-weight: 600; }
input[type="text"], input[type="number"], input[type="date"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  color: inherit;
  margin-top: 6px;
}
textarea { resize: vertical; }

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 11px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { background: var(--muted); cursor: progress; }

.btn-secondary {
  display: inline-block;
  background: #fff;
  color: var(--primary-dark);
  border: 1.5px solid var(--primary);
  border-radius: 8px;
  padding: 9px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.btn-secondary:hover { background: #eef6f0; }

/* 次要選擇（例如「晚點換」）：主色的淺色版，跟 btn-primary 並排時分得出主從，
   但仍在寫作發芽的綠色調裡。內距與 btn-primary 相同，兩顆並排才會等高。 */
.btn-soft {
  display: inline-block;
  background: #d9ede1;
  color: var(--primary-dark);
  border: 1.5px solid #a9d3ba;
  border-radius: 8px;
  padding: 9.5px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.btn-soft:hover { background: #c8e3d3; }

.actions { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }

/* 學生列表 */
.student-list { list-style: none; padding: 0; margin: 0; }
.student-list li {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.student-list li:last-child { border-bottom: none; }
.student-name { font-weight: 600; }
.badge {
  background: #e8f3ec; color: var(--primary-dark);
  border-radius: 999px; padding: 2px 10px; font-size: 0.8rem; font-weight: 700;
}
.badge-revision { background: var(--blue-bg); color: var(--blue); }
.badge-unclaimed { background: var(--amber-bg); color: var(--amber-ink); }

/* 習慣軸：金幣（docs/02-design-decisions.md D7-5、D7-6） */
.coin-pill {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(255, 255, 255, 0.18); color: #fff;
  border-radius: 999px; padding: 3px 12px; font-size: 0.95rem; font-weight: 700;
}
.coin-hint {
  background: var(--amber-bg); color: var(--amber-ink);
  border-radius: 8px; padding: 8px 12px; margin: 10px 0 0;
  display: flex; align-items: baseline; gap: 6px; font-size: 0.9rem;
}
.coin-claim { text-align: center; }
.coin-claim-title {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin: 0 0 6px; font-size: 1.15rem;
}
.coin-award-list { list-style: none; padding: 0; margin: 14px auto 0; max-width: 320px; }
.coin-award-list li {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 7px 0; border-bottom: 1px dashed var(--line);
}
.coin-award-list li:last-child { border-bottom: none; }
.coin-award-list strong { color: var(--amber-ink); }

/* 畫面 7：卡片蒐集本與抽卡（D7-3、D7-4、D7-6） */
.draw-panel { text-align: center; }
.draw-balance { font-size: 1.05rem; margin: 0 0 10px; }
.draw-action { margin-top: 16px; }
.btn-small {
  background: var(--card); color: var(--primary-dark);
  border: 1px solid var(--primary); border-radius: 6px;
  padding: 3px 10px; font-size: 0.78rem; cursor: pointer;
}
.btn-small:hover { background: #e8f3ec; }
.btn-plain {
  background: none; border: none; color: var(--muted);
  text-decoration: underline; cursor: pointer; font-size: 0.9rem;
}

/* 翻牌：卡背朝上 → 繞垂直軸翻轉 180° 露出卡面 */
.flip-stage { perspective: 1000px; display: flex; justify-content: center; margin: 8px 0 14px; }
.flip-card {
  position: relative; width: 240px; aspect-ratio: 3 / 4; cursor: zoom-in;
  transform-style: preserve-3d; transform: rotateY(0deg);
  transition: transform 0.75s cubic-bezier(0.4, 0.1, 0.2, 1);
}
.flip-card.is-flipped { transform: rotateY(180deg); }
.flip-face {
  position: absolute; inset: 0; backface-visibility: hidden;
  border-radius: 12px; overflow: hidden; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}
.flip-face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.flip-face-front { transform: rotateY(180deg); }
.draw-result { margin: 0 0 10px; }
.rare-result { color: var(--amber-ink); font-weight: 700; margin: 0 0 10px; }

/* 合成揭曉（兌換稀有卡）：三張同款普通卡聚攏 → 中央浮現卡背 → 翻正露出稀有卡。
   舞台尺寸與卡框刻意跟抽卡的 .flip-stage 完全一樣（2026-08-11）——稀有卡揭曉不再加
   金框與外圈光暈，跟普通卡同一個外觀，情緒高低差交給動畫本身，不靠邊框裝飾。
   置中一定要用 flex／margin auto：全域有 img { display: block }，父層的 text-align
   對它無效（舊版 .rare-reveal-art 就是這樣被推到左邊的）。 */
.merge-stage {
  position: relative; width: 240px; aspect-ratio: 3 / 4;
  margin: 8px auto 14px; perspective: 1000px;
}
.merge-common {
  position: absolute; top: 50%; left: 50%;
  width: 108px; height: 144px; object-fit: cover;
  border-radius: 10px; border: 2px solid #fff;
  box-shadow: 0 4px 12px rgba(21, 51, 38, 0.28);
  transition: transform 0.7s cubic-bezier(0.55, 0, 0.55, 1), opacity 0.7s ease-in;
}
.merge-common-1 { transform: translate(-50%, -50%) translateX(-64px) rotate(-11deg); }
.merge-common-2 { transform: translate(-50%, -50%) translateY(-6px); }
.merge-common-3 { transform: translate(-50%, -50%) translateX(64px) rotate(11deg); }
/* 三張一起收到正中央、縮小消失，位置與旋轉全部歸零，看起來才像「疊成一張」 */
.merge-stage.is-merged .merge-common {
  transform: translate(-50%, -50%) scale(0.42); opacity: 0;
}
/* 還沒揭曉前擋掉點擊：不然聚攏那 0.7 秒點下去會提早看到稀有卡大圖 */
.merge-result { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.merge-stage.is-revealed .merge-result { pointer-events: auto; }
.merge-stage.is-revealed .merge-result {
  opacity: 1; animation: merge-pop 0.35s cubic-bezier(0.2, 1.2, 0.4, 1);
}
/* 光暈只閃一次就散掉（不是常駐的邊框），分兩層做：
   ::before 是從卡片後方炸開的螢光散射（radial-gradient 放大＋淡出），::after 是貼著
   卡緣的光圈脈衝。兩層疊起來才夠亮、夠有擴散感（2026-08-11 使用者回報第一版太弱）。
   ::before 在 DOM 順序上先於 .flip-card，所以光是從卡片背後散出來的，不會蓋住卡面。 */
.merge-result::before {
  content: ""; position: absolute; inset: -45%;
  border-radius: 50%; pointer-events: none; opacity: 0;
  background: radial-gradient(circle,
      rgba(255, 255, 255, 0.95) 0%,
      rgba(255, 243, 176, 0.9) 22%,
      rgba(255, 214, 74, 0.7) 42%,
      rgba(255, 190, 40, 0.32) 60%,
      rgba(255, 190, 40, 0) 74%);
}
.merge-result::after {
  content: ""; position: absolute; inset: -4px;
  border-radius: 16px; pointer-events: none;
}
/* 兩層都必須在翻牌開始前收乾淨（0.6s ＝ script 裡的 POP_MS）：卡片轉到側面時只剩一條
   窄邊，還亮著的光會變成一個懸空的方框，很怪。 */
.merge-stage.is-revealed .merge-result::before { animation: merge-burst 0.6s ease-out; }
.merge-stage.is-revealed .merge-result::after { animation: merge-glow 0.6s ease-out; }
@keyframes merge-pop { from { transform: scale(0.5); } to { transform: scale(1); } }
/* 開了「減少動態效果」時 script 會直接跳到最終狀態，這裡把 CSS 這半邊也關掉——
   否則卡片雖然到位，光暈仍會自己閃一次。 */
@media (prefers-reduced-motion: reduce) {
  .merge-common { display: none; }
  .flip-card { transition: none; }
  .merge-stage.is-revealed .merge-result,
  .merge-stage.is-revealed .merge-result::before,
  .merge-stage.is-revealed .merge-result::after { animation: none; }
}
@keyframes merge-burst {
  0%   { opacity: 0; transform: scale(0.42); }
  18%  { opacity: 1; }
  100% { opacity: 0; transform: scale(1.55); }
}
/* 顏色比蒐集本的 --amber 亮一階（近乎螢光的暖黃），只在這 0.6 秒出現，不進色票 */
@keyframes merge-glow {
  0%   { box-shadow: 0 0 0 0 rgba(255, 246, 199, 0.95),
                     0 0 26px 8px rgba(255, 226, 110, 0.95),
                     0 0 60px 26px rgba(255, 198, 44, 0.75); }
  55%  { box-shadow: 0 0 0 14px rgba(255, 246, 199, 0.32),
                     0 0 34px 14px rgba(255, 226, 110, 0.6),
                     0 0 84px 40px rgba(255, 198, 44, 0.4); }
  100% { box-shadow: 0 0 0 38px rgba(255, 246, 199, 0),
                     0 0 44px 20px rgba(255, 226, 110, 0),
                     0 0 110px 56px rgba(255, 198, 44, 0); }
}
.exchange-prompt {
  background: var(--amber-bg); border: 1px solid var(--amber); border-radius: 8px;
  padding: 12px; margin: 12px auto 0; max-width: 380px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
/* display: flex 的優先度比 UA 的 [hidden] { display: none } 高，「晚點換」按下去會沒反應，
   所以必須明寫（.card-zoom、.welcome-overlay 也是同樣理由）。 */
.exchange-prompt[hidden] { display: none; }
.exchange-prompt p { margin: 0; color: var(--amber-ink); }
.prompt-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; }
/* 翻牌途中先佔好版位，等動畫演完才顯示——用 display: none 藏的話，內容冒出來時
   下面整片會往下彈一次（2026-08-11 使用者回報「欄位往上跑一下再降下來」）。 */
.is-pending { visibility: hidden; }

/* 蒐集本格狀排列：手機三張一排，寬螢幕才加欄。
   卡牌類遊戲在手機直式版面呈現「完整卡面」時的通例是 3 欄——4 欄以上每張太窄、卡面
   認不出來，那類版面用的是方形頭像或裁切過的圖，不是完整卡片。實測 3 欄每張約 114px，
   4 欄只有 85px（我們自己的美術驗收標準是 160px 要能看出主角在做什麼）。 */
.card-grid {
  display: grid; gap: 8px; margin-top: 12px;
  grid-template-columns: repeat(3, 1fr);
}
@media (min-width: 640px)  { .card-grid { grid-template-columns: repeat(4, 1fr); gap: 12px; } }
@media (min-width: 1000px) { .card-grid { grid-template-columns: repeat(6, 1fr); } }
.card-cell { display: flex; flex-direction: column; align-items: center; gap: 6px; }

/* 卡框由 CSS 統一處理，美術不用畫（docs/08 §2）：白邊＋圓角＋陰影，做出實體卡片感 */
.card-slot {
  position: relative; width: 100%; aspect-ratio: 3 / 4;
  border-radius: 8px; overflow: hidden; background: #e8f3ec;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(21, 51, 38, 0.18);
}
.card-slot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-slot.is-owned {
  cursor: zoom-in;
  box-shadow: 0 2px 8px rgba(21, 51, 38, 0.28);
}
/* 還沒收集到的卡顯示卡背（2026-08-10 起不再用剪影，改成完全不揭露卡面內容——
   翻開才知道是什麼，收集的驚喜感比「看得到目標」重要）。
   **不另外加壓暗濾鏡**：卡背（v5）是低彩度的霧面藍綠，實測亮度 151.8 其實比卡面
   （123.6–132.1）略亮，但它單一色相、明暗起伏小，跟高彩度的卡面並排時自然退到背景，
   對比已經很夠；再壓一層只會讓卡背變濁、蓋掉設計端刻意做的紙紋質感。 */

/* 稀有卡在蒐集本裡不做任何額外裝飾（2026-08-11 起）：原本有金框＋左上角 ★，實機看
   起來反而雜。層級差改為只靠「稀有卡」分區標題與兌換動線本身表達，卡片外觀全部一致。 */
.card-count {
  position: absolute; right: 6px; bottom: 6px;
  background: var(--primary-dark); color: #fff;
  border-radius: 999px; padding: 1px 8px; font-size: 0.78rem; font-weight: 700;
}
/* 只給螢幕閱讀器的文字（例如卡片頁那個不顯示的 h1），畫面上完全不佔空間 */
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* 自製確認視窗，取代瀏覽器的 confirm()（樣式改不動，且可能被瀏覽器擋掉）。
   版型沿用開工首抽的 .welcome-overlay，只是邊框用中性色，不是慶祝用的琥珀色。 */
.modal-overlay {
  position: fixed; inset: 0; z-index: 60; padding: 24px;
  background: rgba(21, 51, 38, 0.6);
  display: flex; align-items: center; justify-content: center;
}
.modal-overlay[hidden] { display: none; }
.modal-box {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 22px 20px; max-width: 360px; text-align: center;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.3);
  animation: welcome-pop 0.25s cubic-bezier(0.2, 1.2, 0.4, 1);
}
.modal-text { margin: 0 0 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.card-zoom {
  position: fixed; inset: 0; z-index: 50; cursor: zoom-out;
  background: rgba(0, 0, 0, 0.75);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.card-zoom[hidden] { display: none; }
.card-zoom img { max-width: 100%; max-height: 100%; border-radius: 12px; }

/* 開工首抽的歡迎視窗（D7-7）：只在安置回饋頁領完金幣後出現一次 */
.welcome-overlay {
  position: fixed; inset: 0; z-index: 60; padding: 24px;
  background: rgba(21, 51, 38, 0.6);
  display: flex; align-items: center; justify-content: center;
}
.welcome-overlay[hidden] { display: none; }
.welcome-box {
  background: var(--card); border-radius: 16px; padding: 26px 22px;
  max-width: 380px; text-align: center;
  border: 2px solid var(--amber);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.3);
  animation: welcome-pop 0.35s cubic-bezier(0.2, 1.2, 0.4, 1);
}
@keyframes welcome-pop {
  from { opacity: 0; transform: scale(0.9) translateY(10px); }
  to { opacity: 1; transform: none; }
}
.welcome-title { font-size: 1.2rem; font-weight: 700; color: var(--amber-ink); margin: 0 0 10px; }
.welcome-actions {
  display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 18px 0 0;
}
.welcome-hint { font-size: 0.85rem; margin: 14px 0 0; }

/* 欄位清單（任務卡 / 回饋） */
.field-list { margin: 0; }
.field-list dt { font-weight: 700; color: var(--muted); margin-top: 12px; }
.field-list dt:first-child { margin-top: 0; }
.field-list dd { margin: 4px 0 0; }
.field-list ul { margin: 4px 0 0; padding-left: 20px; }

/* 本次題目的單選清單（學生從提供的題目中挑 1 題寫，D3） */
.topic-choices { list-style: none; margin: 4px 0 0; padding: 0; }
.topic-choices li { margin-top: 6px; }
.topic-choices label {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border: 1px solid var(--line); border-radius: 6px;
  cursor: pointer;
}
.topic-choices label:hover { background: #eef6f0; border-color: var(--primary); }
.topic-choices input { flex-shrink: 0; accent-color: var(--primary); }
.topic-choices input:checked + span { font-weight: 700; color: var(--primary-dark); }

.master-tip {
  margin-top: 14px; padding: 10px 14px;
  background: #eef6f0; border-left: 3px solid var(--primary);
  border-radius: 4px; font-size: 0.95rem;
}

.completion-note {
  margin: 0 0 16px; padding: 10px 14px;
  background: var(--bg); border-left: 3px solid var(--muted);
  border-radius: 4px; font-size: 0.95rem;
}

/* 回饋頁：家長區與孩子回饋卡視覺分開 */
.child-card {
  background: var(--child-bg);
  border: 2px solid var(--child-line);
}
.child-card summary { color: #a9741a; }
.child-card ul { padding-left: 20px; }
.child-card .detective-note { font-weight: 700; color: var(--muted); margin: 10px 0 4px; }

.word-count { margin: -6px 0 0; font-size: 0.85rem; }

/* 陪練三層引導的逐步揭露（提示階梯） */
.hint-ladder { margin: 14px 0; padding-top: 14px; border-top: 1px dashed var(--child-line); }
.hint-progress { display: flex; gap: 6px; margin-bottom: 12px; }
.hint-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.hint-dot.is-active { background: var(--primary); }

.hint-step {
  display: flex; align-items: flex-start; gap: 10px;
  max-height: 0; opacity: 0; overflow: hidden;
  transform: translateY(-6px);
  transition: max-height 0.4s ease, opacity 0.4s ease, transform 0.4s ease;
}
.hint-step[hidden] { display: flex; }
.hint-step.is-active { max-height: 320px; opacity: 1; transform: translateY(0); margin-bottom: 10px; }
.hint-step-body { flex: 1; min-width: 0; }
.hint-step-body p { margin: 0 0 6px; }
.hint-icon-1 { color: var(--primary); flex-shrink: 0; margin-top: 2px; }
.hint-icon-2 { color: #c98a2e; flex-shrink: 0; margin-top: 2px; }
.hint-icon-3 { color: #a9741a; flex-shrink: 0; margin-top: 2px; }

.hint-reveal-btn {
  background: none; border: 1px dashed var(--line); border-radius: 999px;
  padding: 4px 12px; font-size: 0.85rem; color: var(--primary-dark);
  cursor: pointer;
}
.hint-revealed-note { margin: 0 0 6px !important; font-size: 0.85rem; color: var(--muted); }
.hint-reminder { font-size: 0.85rem; font-style: italic; color: #a9741a; }

.revise-box {
  margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--child-line);
}

.error {
  background: var(--error-bg); color: var(--error-ink);
  border: 1px solid #f0b8b3; border-radius: 8px;
  padding: 10px 14px; margin-bottom: 12px;
}

.notice {
  background: var(--amber-bg); color: var(--amber-ink);
  border: 1px solid var(--amber); border-radius: 8px;
  padding: 10px 14px; margin-bottom: 12px;
}

/* 修改重評改動幅度不夠時，把「可以升級的地方」重新標亮，提醒孩子照著改 */
.revise-nudge {
  background: var(--amber-bg); border: 1px solid var(--amber);
  border-radius: 10px; padding: 14px; margin: 10px 0;
}

/* ============ 進步地圖 ============ */
/* 統一的功能圖示（線性、currentColor、~2px 圓角），大小由 font-size/寬高控制 */
.ico { flex-shrink: 0; vertical-align: -0.15em; }
.h-ico { color: var(--primary); vertical-align: -0.15em; margin-right: 6px; }

/* 下一個練習主卡（首屏、僅次於成長卡）：桌面文案+按鈕雙欄，手機按鈕滿寬 */
.next-practice { background: var(--amber-bg); border-color: var(--amber); }
.next-practice-grid { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: center; }
.next-practice-body { min-width: 0; }
.next-practice-line {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px;
  margin: 8px 0 0;
}
.next-practice-name {
  display: inline-block; flex-shrink: 0; background: var(--blue-bg); color: var(--blue);
  border-radius: 999px; padding: 6px 14px; font-weight: 700;
}
.next-practice-reason { color: var(--muted); }
.next-practice .btn-primary { width: 100%; }
@media (min-width: 768px) {
  .next-practice-grid { grid-template-columns: minmax(0, 1fr) auto; gap: 24px; }
  .next-practice .btn-primary { width: auto; min-width: 148px; }
}

/* 七大能力狀態卡最上面的重點摘要（最穩定／正在進步） */
.ability-highlights {
  display: flex; flex-direction: column; gap: 6px;
  margin: 0 0 16px; padding-bottom: 16px; border-bottom: 1px solid var(--line);
}
.ability-highlights p { margin: 0; display: flex; align-items: baseline; gap: 6px; }
.ability-highlights .ico { color: var(--primary); flex-shrink: 0; align-self: center; }

/* 練習紀錄：作品卡列表 */
.progress-list { list-style: none; padding: 0; margin: 0; }
.progress-list li { padding: 14px 0; border-bottom: 1px solid var(--line); }
.progress-list li:last-child { border-bottom: none; padding-bottom: 0; }
.record-row { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; }
.record-icon { width: 30px; height: 30px; flex-shrink: 0; }
.record-main { min-width: 0; }
/* 標題＋題目類型只占一行，超過的省略號截斷，日期跟關卡標籤不擠壓 */
.record-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; }
.record-date, .record-title-row .badge { flex-shrink: 0; }
.record-title {
  min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  font-size: 1.1rem;
}
.record-date { font-size: 0.9rem; }
.record-preview {
  margin: 6px 0 0; font-size: 0.92rem;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}
.record-actions { display: flex; align-items: center; gap: 14px; margin-top: 10px; }
.record-actions a { font-size: 0.92rem; font-weight: 600; }
@media (min-width: 768px) {
  .record-row { grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; }
  .record-actions { margin-top: 0; flex-direction: column; align-items: flex-end; gap: 6px; white-space: nowrap; }
}

.filter-form { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.filter-field { font-size: 0.9rem; font-weight: 600; }
.filter-field select { margin-top: 4px; width: auto; }

.inline-form { display: inline; }
/* 刪除：降低視覺權重（比「查看完整內容」弱） */
.link-danger {
  background: none; border: none; padding: 0;
  color: var(--muted); text-decoration: underline; cursor: pointer;
  font: inherit; font-size: 0.85rem;
}
.link-danger:hover { color: var(--error-ink); }

.state-table { width: 100%; border-collapse: collapse; }
.state-table th, .state-table td { text-align: left; padding: 10px; border-bottom: 1px solid var(--line); }
.state-table th { color: var(--muted); font-size: 0.9rem; }
.state-table td:last-child { color: var(--muted); }
/* 手機：能力表改成一列一項（名稱＋狀態），不硬塞桌面兩欄表格 */
@media (max-width: 767px) {
  .state-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .state-table tr { display: flex; justify-content: space-between; gap: 12px; }
  .state-table td { border-bottom: none; padding: 8px 0; }
  .state-table td:first-child { font-weight: 600; }
  .state-table tr { border-bottom: 1px solid var(--line); }
}

/* 七大能力：桌面雷達圖＋文字摘要雙欄；1099px 以下上下排列 */
.ability-layout { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
@media (min-width: 1100px) { .ability-layout { grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); gap: 24px; } }
.radar-wrap { display: flex; justify-content: center; }
.radar-chart { width: min(100%, 360px); height: auto; aspect-ratio: 1 / 1; }
.radar-ring { fill: none; stroke: var(--line); stroke-width: 1; }
.radar-axis { stroke: var(--line); stroke-width: 1; }
.radar-data { fill: rgba(47, 133, 84, 0.20); stroke: var(--primary); stroke-width: 2.4; }
.radar-point { fill: var(--primary); }
.radar-label { fill: var(--ink); font-size: 10px; font-weight: 600; }

/* 成長階段主視覺卡 */
.growth-card { display: flex; flex-direction: column; gap: 16px; }
.growth-top {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 14px;
}
.growth-visual { display: flex; align-items: center; gap: 14px; min-width: 0; }
.growth-icon { color: var(--primary); flex-shrink: 0; }
.growth-card h2 { margin-bottom: 4px; }

.growth-pills { display: flex; gap: 10px; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: #eef6f0; color: var(--primary-dark);
  border-radius: 999px; padding: 6px 12px;
  font-size: 0.85rem; font-weight: 600; white-space: nowrap;
}
.pill-amber { background: var(--amber-bg); color: var(--amber-ink); }
.pill-link { text-decoration: none; cursor: pointer; }
.pill-link:hover { background: var(--amber-bg); color: var(--amber-ink); }

.milestone-label {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 0.9rem; font-weight: 600; margin-bottom: 6px;
}
.milestone-pct { color: var(--primary-dark); }
.milestone-bar { background: var(--line); border-radius: 999px; height: 10px; overflow: hidden; }
.milestone-fill { background: var(--primary); height: 100%; border-radius: 999px; }
.milestone-max {
  display: flex; align-items: center; gap: 8px; margin: 0;
  font-weight: 600; color: var(--primary-dark);
}
.milestone-max-icon { color: var(--primary); flex-shrink: 0; }

.stage-track { display: flex; align-items: flex-start; }
.stage-node {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  flex: 1; min-width: 0; text-align: center;
}
.stage-dot {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); border: 2px solid var(--line); color: var(--muted);
}
.stage-node.is-done .stage-dot { background: #eef6f0; border-color: var(--primary); color: var(--primary); }
.stage-node.is-current .stage-dot { background: var(--primary); border-color: var(--primary); color: #fff; }
.stage-node.is-locked .stage-dot { opacity: 0.55; }
.stage-name { font-size: 0.85rem; font-weight: 700; color: var(--ink); }
.stage-tagline { font-size: 0.75rem; color: var(--muted); }
.stage-node.is-locked .stage-name, .stage-node.is-locked .stage-tagline { color: var(--muted); }
.stage-line { flex: 0 0 16px; height: 2px; background: var(--line); margin-top: 18px; }
.stage-line.is-done { background: var(--primary); }

/* 頁尾鼓勵（只放插圖＋文字，不放大型 CTA） */
.encourage-banner {
  display: flex; align-items: center; gap: 14px;
  background: var(--amber-bg); border-color: var(--amber);
}
.encourage-banner p { margin: 0; font-weight: 600; min-width: 0; }
.encourage-icon { width: 56px; height: 56px; flex-shrink: 0; }

/* 回饋頁：孩子原文 */
.essay-text { white-space: pre-wrap; }

/* 手機：階段軸精簡 */
@media (max-width: 480px) {
  .stage-tagline { display: none; }
  .stage-dot { width: 30px; height: 30px; }
}

/* ============ 習慣軸：連續紀錄提醒（docs/02 D7-1） ============ */

.streak-reminder { margin-top: 4px; }
.streak-reminder-reset { background: var(--surface-soft); color: var(--primary-dark); border-color: var(--line); }

/* ---------- 帳號區塊與登入／註冊頁（TASKS.md P2-1／P2-2） ---------- */

/* 帳號區塊在頁首最右邊，與學生端導覽列分開，不佔 D7-6 的三個平鋪名額 */
.site-account { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.site-account .account-email {
  color: #fff; opacity: 0.75; font-size: 0.82rem;
  max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.site-account .admin-link {
  color: #fff; text-decoration: none; font-size: 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.5); border-radius: 999px; padding: 2px 10px;
}
.site-account .admin-link:hover { background: rgba(255, 255, 255, 0.15); }
.site-account form { margin: 0; }

.btn-link {
  background: none; border: none; padding: 0; cursor: pointer;
  color: inherit; font: inherit; text-decoration: underline; opacity: 0.85;
}
.btn-link:hover { opacity: 1; }
/* 頁首裡的登出鈕是白字，頁面內容裡的（例如「用別的帳號登入」）要用主色 */
.auth-card .btn-link { color: var(--primary); }

.auth-card { max-width: 460px; margin: 40px auto; text-align: center; }
.auth-card h1 { margin-top: 0; }
.auth-card .stack { margin-top: 18px; text-align: left; }
.auth-lead { color: var(--muted); line-height: 1.7; }
.auth-note { color: var(--muted); font-size: 0.88rem; margin-top: 16px; line-height: 1.6; }
.auth-secondary { margin-top: 18px; }
.auth-error {
  background: var(--error-bg); color: var(--error-ink);
  border-radius: 10px; padding: 10px 14px; margin: 14px 0; text-align: left;
}
.auth-error[hidden] { display: none; }
.auth-card input[type="text"] {
  text-transform: uppercase; letter-spacing: 0.08em; font-family: ui-monospace, monospace;
}

/* ---------- 管理員後台（TASKS.md P3） ---------- */

.admin-head {
  display: flex; align-items: baseline; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-bottom: 8px;
}
.admin-head h1 { margin: 0; }
.admin-nav { display: flex; gap: 14px; }
.admin-nav a { color: var(--muted); text-decoration: none; font-size: 0.95rem; }
.admin-nav a:hover { color: var(--ink); }
.admin-nav a.is-current { color: var(--primary); font-weight: 600; }

.admin-stats { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 28px; }
.admin-stats li { display: flex; flex-direction: column; }
.stat-number { font-size: 1.8rem; font-weight: 700; color: var(--primary); line-height: 1.2; }
.stat-label { color: var(--muted); font-size: 0.85rem; }

.admin-links { margin: 0; padding-left: 20px; line-height: 2; }
.admin-note { font-size: 0.85rem; margin-top: 14px; }

/* 表格可能比手機螢幕寬，讓它自己橫向捲，不要把整個頁面撐開 */
.table-scroll { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.admin-table th, .admin-table td {
  text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.admin-table th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
.admin-table code { font-size: 0.92rem; }

.state-pill { border-radius: 999px; padding: 2px 10px; font-size: 0.82rem; }
.state-ok { background: var(--surface-soft); color: var(--primary-dark); }
.state-off { background: var(--error-bg); color: var(--error-ink); }

.admin-detail { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; }
.admin-detail dt { color: var(--muted); font-size: 0.9rem; }
.admin-detail dd { margin: 0; }

.admin-action { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.field-hint { display: block; color: var(--muted); font-size: 0.82rem; margin-top: 4px; }

.btn-danger {
  background: var(--error-ink); color: #fff; border: none; border-radius: 10px;
  padding: 10px 18px; font-size: 0.95rem; cursor: pointer;
}
.btn-danger:hover { filter: brightness(1.1); }

.created-codes .code-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.created-codes .code-list code {
  background: var(--surface-soft); border-radius: 8px; padding: 6px 12px;
  font-size: 1.05rem; letter-spacing: 0.06em;
}
.code-usage { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 0; }

.admin-student { padding: 14px 0; border-top: 1px solid var(--line); }
.admin-student:first-of-type { border-top: none; padding-top: 0; }
.admin-student h3 { margin: 0 0 8px; }
.admin-student-meta, .admin-states {
  list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px;
  font-size: 0.9rem;
}
.admin-states { margin-top: 8px; color: var(--muted); font-size: 0.85rem; }

/* 後台表單的數字與日期欄位不必撐滿整行，太寬反而不好讀。
   display:block 是為了讓它跟同一份表單裡的文字欄位一樣換到下一行，
   不然窄欄位會跟標籤擠在同一行、整份表單的對齊就亂了。 */
.admin-head ~ .card input[type="number"] { display: block; max-width: 140px; }
.admin-head ~ .card input[type="date"] { display: block; max-width: 200px; }

/* 批改模型選擇（TASKS.md P6-3） */
.model-choice { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.model-choice input { width: auto; margin: 0; }
.model-choice .model-label { font-weight: 600; }
.model-choice .model-id { color: var(--muted); font-size: 0.85rem; }
.notice-ok {
  background: var(--surface-soft); color: var(--primary-dark);
  border-radius: 10px; padding: 10px 14px; margin: 14px 0;
}

/* 註冊第二步顯示驗過的碼 */
.code-ok {
  display: inline-block; background: var(--surface-soft); color: var(--primary-dark);
  border-radius: 8px; padding: 6px 12px; margin: 8px 0;
  font-size: 1.05rem; letter-spacing: 0.06em;
}
