/* =========================================================
   小學生手寫考卷系統 — 共用樣式
   設計方向：童趣、糖果色、圓潤蠟筆感、大觸控目標
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;600;700;800&family=Noto+Sans+TC:wght@500;700;900&display=swap');

:root {
  /* 糖果色盤 */
  --cream:      #FFF8EE;
  --paper:      #FFFDF8;
  --ink:        #4A3B2A;
  --ink-soft:   #8A7B66;

  --sun:        #FFC93C;   /* 黃 */
  --sun-deep:   #F4A800;
  --berry:      #FF6B8A;   /* 粉紅 */
  --berry-deep: #E84A6F;
  --grass:      #4CC38A;   /* 綠 */
  --grass-deep: #2FA56C;
  --sky:        #4EA8F5;   /* 藍 */
  --sky-deep:   #2E8BE0;
  --grape:      #9B7BE8;   /* 紫 */
  --tangerine:  #FF9A3C;   /* 橘 */

  --good:       #4CC38A;
  --bad:        #FF6B8A;

  --r-lg: 32px;
  --r-md: 22px;
  --r-sm: 14px;

  --shadow-soft: 0 10px 0 rgba(74,59,42,.08), 0 18px 40px rgba(74,59,42,.12);
  --shadow-pop:  0 6px 0 var(--shadow-color, rgba(74,59,42,.22));

  --font-display: 'Baloo 2', 'Noto Sans TC', system-ui, sans-serif;
  --font-body:    'Noto Sans TC', 'Baloo 2', system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%,  rgba(255,201,60,.28), transparent 38%),
    radial-gradient(circle at 88% 12%, rgba(78,168,245,.22), transparent 40%),
    radial-gradient(circle at 80% 92%, rgba(255,107,138,.20), transparent 42%),
    radial-gradient(circle at 8% 88%,  rgba(76,195,138,.20), transparent 42%),
    var(--cream);
  background-attachment: fixed;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

/* 飄浮的圓點底紋 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    radial-gradient(rgba(74,59,42,.05) 2px, transparent 2px);
  background-size: 34px 34px;
  pointer-events: none;
}

/* ---------- 通用 ---------- */

.wrap {
  max-width: 920px;
  margin: 0 auto;
  padding: 22px 18px 80px;
}

.screen { display: none; animation: pop-in .45s cubic-bezier(.2,1.2,.4,1) both; }
.screen.active { display: block; }

@keyframes pop-in {
  from { opacity: 0; transform: translateY(18px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.brand {
  text-align: center;
  margin: 10px 0 26px;
}
.brand h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(30px, 7vw, 50px);
  margin: 0;
  color: var(--ink);
  letter-spacing: 1px;
  line-height: 1.1;
}
.brand h1 .pop {
  display: inline-block;
  background: linear-gradient(180deg, var(--sun), var(--sun-deep));
  color: #fff;
  padding: 0 .28em;
  border-radius: 16px 16px 18px 16px;
  transform: rotate(-3deg);
  box-shadow: 0 5px 0 rgba(244,168,0,.45);
}
.brand p {
  margin: 12px 0 0;
  font-size: clamp(15px, 3.5vw, 19px);
  color: var(--ink-soft);
  font-weight: 700;
}

/* ---------- 按鈕 ---------- */

.btn {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(18px, 4vw, 22px);
  border: none;
  border-radius: var(--r-md);
  padding: 18px 26px;
  min-height: 64px;
  cursor: pointer;
  color: #fff;
  background: var(--sky);
  --shadow-color: var(--sky-deep);
  box-shadow: var(--shadow-pop);
  transition: transform .08s ease, box-shadow .08s ease, filter .15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  user-select: none;
  touch-action: manipulation;
}
.btn:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--shadow-color); }
.btn:hover { filter: brightness(1.04); }
.btn:disabled { opacity: .45; filter: grayscale(.4); cursor: not-allowed; transform: none; box-shadow: var(--shadow-pop); }

.btn--yellow { background: var(--sun);   --shadow-color: var(--sun-deep);   color: var(--ink); }
.btn--berry  { background: var(--berry); --shadow-color: var(--berry-deep); }
.btn--grass  { background: var(--grass); --shadow-color: var(--grass-deep); }
.btn--grape  { background: var(--grape); --shadow-color: #7a5cc7; }
.btn--orange { background: var(--tangerine); --shadow-color: #e07d20; }
.btn--ghost  {
  background: var(--paper); color: var(--ink-soft);
  --shadow-color: rgba(74,59,42,.18);
  box-shadow: 0 4px 0 var(--shadow-color), inset 0 0 0 3px rgba(74,59,42,.08);
}
.btn--big { font-size: clamp(20px, 5vw, 26px); padding: 22px 30px; min-height: 76px; }
.btn--block { width: 100%; }

/* ---------- 卡片 ---------- */

.card {
  background: var(--paper);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-soft);
  padding: 26px;
}

/* 選單格 */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}

.pick-card {
  position: relative;
  text-align: left;
  border: none;
  cursor: pointer;
  border-radius: var(--r-lg);
  padding: 24px 22px;
  background: var(--paper);
  box-shadow: 0 8px 0 rgba(74,59,42,.10), 0 14px 30px rgba(74,59,42,.10);
  transition: transform .12s cubic-bezier(.2,1.3,.4,1), box-shadow .12s;
  overflow: hidden;
  font-family: var(--font-body);
}
.pick-card::after {
  content: "";
  position: absolute;
  top: -40px; right: -40px;
  width: 130px; height: 130px;
  border-radius: 50%;
  background: var(--accent, var(--sun));
  opacity: .18;
}
.pick-card:active { transform: translateY(4px) scale(.99); }
.pick-card:hover { transform: translateY(-4px); box-shadow: 0 12px 0 rgba(74,59,42,.10), 0 22px 40px rgba(74,59,42,.16); }
.pick-card .emoji { font-size: 40px; line-height: 1; }
.pick-card .gname {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 26px;
  margin: 12px 0 4px;
  color: var(--ink);
  position: relative;
}
.pick-card .gsem { font-size: 18px; font-weight: 700; color: var(--ink-soft); position: relative; }
.pick-card .gtags { margin-top: 16px; display: flex; gap: 8px; flex-wrap: wrap; position: relative; }
.tag {
  font-weight: 800;
  font-size: 14px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(78,168,245,.16);
  color: var(--sky-deep);
}
.tag.zhuyin { background: rgba(255,107,138,.16); color: var(--berry-deep); }

/* ---------- 狀態（loading / empty / error） ---------- */

.state {
  text-align: center;
  padding: 50px 20px;
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 19px;
}
.state .big-emoji { font-size: 62px; display: block; margin-bottom: 14px; animation: bob 2s ease-in-out infinite; }
@keyframes bob { 0%,100%{ transform: translateY(0);} 50%{ transform: translateY(-10px);} }

.spinner {
  width: 56px; height: 56px;
  border-radius: 50%;
  border: 7px solid rgba(255,201,60,.35);
  border-top-color: var(--sun-deep);
  margin: 0 auto 18px;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 進度條 ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.progress {
  flex: 1;
  height: 22px;
  background: rgba(74,59,42,.10);
  border-radius: 999px;
  overflow: hidden;
}
.progress > i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--grass), var(--sun));
  transition: width .4s cubic-bezier(.3,1.2,.4,1);
}
.qcount {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 20px;
  color: var(--ink);
  white-space: nowrap;
}

/* ---------- 題目 ---------- */

.q-prompt {
  text-align: center;
  margin-bottom: 12px;
}
.q-prompt .label {
  font-weight: 800;
  color: var(--ink-soft);
  font-size: 18px;
  margin-bottom: 6px;
}
.q-prompt .zhuyin-big {
  font-family: var(--font-display);
  font-size: clamp(40px, 12vw, 72px);
  font-weight: 800;
  color: var(--sky-deep);
  letter-spacing: 4px;
  line-height: 1.1;
}
.q-prompt .char-big {
  font-family: 'Noto Sans TC', serif;
  font-size: clamp(96px, 30vw, 180px);
  font-weight: 900;
  color: var(--ink);
  line-height: 1;
}

.writer-stage {
  display: flex;
  justify-content: center;
  margin: 8px auto 14px;
}
.writer-box {
  position: relative;
  border-radius: var(--r-md);
  background:
    linear-gradient(var(--paper), var(--paper)) padding-box,
    repeating-linear-gradient(0deg, transparent, transparent 9px, rgba(74,59,42,.05) 9px, rgba(74,59,42,.05) 10px);
  box-shadow: inset 0 0 0 4px rgba(255,201,60,.55), var(--shadow-soft);
  padding: 8px;
}
/* 田字格輔助線 */
.writer-box::before, .writer-box::after {
  content: "";
  position: absolute;
  background: rgba(255,107,138,.30);
  pointer-events: none;
}
.writer-box::before { left: 50%; top: 8px; bottom: 8px; width: 2px; transform: translateX(-1px); }
.writer-box::after  { top: 50%; left: 8px; right: 8px; height: 2px; transform: translateY(-1px); }

/* 自由手寫 canvas */
.draw-box {
  position: relative;
  border-radius: var(--r-md);
  background: var(--paper);
  box-shadow: inset 0 0 0 4px rgba(78,168,245,.5), var(--shadow-soft);
  touch-action: none;
  overflow: hidden;
}
.draw-box::before, .draw-box::after {
  content: ""; position: absolute; background: rgba(74,59,42,.10); pointer-events: none;
}
.draw-box::before { left: 50%; top: 0; bottom: 0; width: 2px; }
.draw-box::after  { top: 50%; left: 0; right: 0; height: 2px; }
.draw-box canvas { display: block; position: relative; z-index: 1; touch-action: none; }

/* =========================================================
   注音鍵盤（bopomofo keypad）— 取代自由手寫 + 自我評分
   點符號拼出讀音，按「確定」自動批改
   ========================================================= */
.zhuyin-pad {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}

/* 顯示孩子拼出的注音（大、含閃爍游標） */
.zhuyin-display {
  position: relative;
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 14px 22px;
  border-radius: var(--r-md);
  background: var(--paper);
  box-shadow: inset 0 0 0 4px rgba(78,168,245,.5), var(--shadow-soft);
}
.zhuyin-display .zd-text {
  font-family: var(--font-body);
  font-weight: 900;
  font-size: clamp(40px, 11vw, 64px);
  letter-spacing: 6px;
  color: var(--sky-deep);
  line-height: 1;
  /* 注音直書感：符號水平排列即可，孩子熟悉的橫式 */
}
.zhuyin-display .zd-placeholder {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(20px, 5.5vw, 26px);
  color: var(--ink-soft);
  letter-spacing: 1px;
}
.zhuyin-display .zd-caret {
  display: inline-block;
  width: 5px;
  height: clamp(40px, 10vw, 58px);
  margin-left: 4px;
  border-radius: 3px;
  background: var(--berry);
  animation: zd-blink 1s steps(1) infinite;
}
@keyframes zd-blink { 0%,50%{opacity:1} 50.01%,100%{opacity:0} }
@media (prefers-reduced-motion: reduce) {
  .zhuyin-display .zd-caret { animation: none; opacity: 1; }
  .zkey { transition: none; }
}

/* 鍵盤分組 */
.zhuyin-keys { display: flex; flex-direction: column; gap: 10px; }
.zk-group {
  border-radius: var(--r-sm);
  padding: 8px;
  background: rgba(74,59,42,.04);
}
.zk-group-label {
  display: block;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 14px;
  color: var(--ink-soft);
  margin: 0 4px 7px;
  letter-spacing: 1px;
}
.zk-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 7px;
}
.zk-row.zk-tone { grid-template-columns: repeat(5, 1fr); }

/* 單一鍵：大觸控目標 */
.zkey {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 900;
  font-size: clamp(22px, 6vw, 30px);
  color: var(--ink);
  background: var(--paper);
  border-radius: var(--r-sm);
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 0 rgba(74,59,42,.16);
  transition: transform .08s, box-shadow .08s, background .12s;
  user-select: none;
}
.zkey:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(74,59,42,.16);
  background: #FFF3DC;
}
.zkey.zk-tone-key { background: rgba(255,201,60,.22); font-size: clamp(20px, 5.5vw, 28px); }
.zkey.zk-tone-key .zk-tone-sub { font-size: 12px; font-weight: 700; color: var(--ink-soft); margin-left: 2px; }
.zkey.zk-tone-key.sel { background: var(--sun); box-shadow: 0 4px 0 var(--sun-deep); }
.zkey.zk-ctrl { background: rgba(155,123,232,.18); font-size: clamp(18px, 5vw, 24px); }
.zkey.zk-ctrl:active { background: rgba(155,123,232,.34); }

/* 確定鍵：大、醒目 */
.zhuyin-pad .zk-submit {
  width: 100%;
  font-size: clamp(22px, 6vw, 28px);
  min-height: 68px;
}
.zhuyin-pad .zk-submit:disabled { opacity: .45; }
.zhuyin-pad-foot { display: flex; gap: 12px; }
.zhuyin-pad-foot .zk-peek {
  flex: 0 0 auto;
  font-size: 17px;
  min-height: 52px;
  padding: 10px 18px;
}

.q-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 8px;
}
.q-actions .btn { flex: 1 1 160px; }

/* 即時對錯回饋 */
.feedback {
  text-align: center;
  min-height: 40px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  margin: 6px 0 2px;
}
.feedback.ok  { color: var(--grass-deep); }
.feedback.bad { color: var(--berry-deep); }
.feedback .shake { display: inline-block; animation: shake .4s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-7px)} 75%{transform:translateX(7px)} }

.answer-reveal {
  text-align: center;
  margin: 10px 0;
  font-weight: 800;
  font-size: 20px;
  color: var(--ink-soft);
}
.answer-reveal b {
  font-family: var(--font-display);
  font-size: 30px;
  color: var(--berry-deep);
  letter-spacing: 3px;
}

/* ---------- 成績畫面 ---------- */

.result-card { text-align: center; }
.result-stars { font-size: 54px; letter-spacing: 6px; margin: 6px 0 4px; }
.result-stars span { display: inline-block; animation: star-pop .5s both; }
@keyframes star-pop { from{ transform: scale(0) rotate(-40deg);} to{ transform: scale(1) rotate(0);} }
.score-ring {
  width: 200px; height: 200px;
  margin: 14px auto;
  border-radius: 50%;
  display: grid;
  place-content: center;
  background: conic-gradient(var(--grass) var(--p,0%), rgba(74,59,42,.10) 0);
  position: relative;
}
.score-ring::after {
  content: "";
  position: absolute; inset: 16px;
  background: var(--paper);
  border-radius: 50%;
}
.score-ring .num {
  position: relative;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 60px;
  color: var(--ink);
  line-height: 1;
}
.score-ring .num small { display: block; font-size: 18px; color: var(--ink-soft); }
.result-line { font-size: 22px; font-weight: 800; margin: 6px 0 22px; color: var(--ink); }
.result-msg { font-family: var(--font-display); font-size: 26px; font-weight: 800; margin-bottom: 16px; }

/* ---------- 表單元件 ---------- */

.field { margin-bottom: 18px; }
.field > label {
  display: block;
  font-weight: 800;
  margin-bottom: 8px;
  font-size: 17px;
  color: var(--ink);
}
.input, select.input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  padding: 15px 16px;
  min-height: 56px;
  border: 3px solid rgba(74,59,42,.14);
  border-radius: var(--r-sm);
  background: var(--paper);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, select.input:focus {
  border-color: var(--sky);
  box-shadow: 0 0 0 4px rgba(78,168,245,.18);
}

/* 大選項按鈕（類型/題數） */
.choice-row { display: flex; gap: 14px; flex-wrap: wrap; }
.choice {
  flex: 1 1 140px;
  border: 4px solid rgba(74,59,42,.12);
  background: var(--paper);
  border-radius: var(--r-md);
  padding: 20px 14px;
  cursor: pointer;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  color: var(--ink);
  transition: transform .1s, border-color .15s, background .15s;
  user-select: none;
}
.choice .ico { font-size: 38px; display: block; margin-bottom: 6px; }
.choice small { display: block; font-weight: 700; font-size: 14px; color: var(--ink-soft); margin-top: 4px; font-family: var(--font-body); }
.choice.sel { border-color: var(--sun-deep); background: rgba(255,201,60,.18); transform: translateY(-2px); }
.choice:active { transform: scale(.97); }

.count-row { display: flex; gap: 10px; flex-wrap: wrap; }
.count-pill {
  flex: 1 1 60px;
  min-width: 64px;
  min-height: 60px;
  border: 4px solid rgba(74,59,42,.12);
  border-radius: 999px;
  background: var(--paper);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  color: var(--ink);
  cursor: pointer;
  transition: transform .1s, border-color .15s, background .15s;
}
.count-pill.sel { border-color: var(--grass-deep); background: rgba(76,195,138,.18); }
.count-pill:active { transform: scale(.94); }

/* ---------- 後台 ---------- */

.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.admin-head h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(24px, 5vw, 34px);
  margin: 0;
}
.tabs { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.tab {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  padding: 14px 22px;
  min-height: 56px;
  border: none;
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink-soft);
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(74,59,42,.10);
  transition: transform .08s, background .15s, color .15s;
}
.tab.active { background: var(--grape); color: #fff; box-shadow: 0 4px 0 #7a5cc7; }
.tab:active { transform: translateY(2px); }

.pane { display: none; }
.pane.active { display: block; animation: pop-in .35s both; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px){ .row2 { grid-template-columns: 1fr; } }

.preview-img {
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  border-radius: var(--r-md);
  background: #fff;
  box-shadow: var(--shadow-soft);
  margin-bottom: 16px;
}

/* 表格 */
.tbl-wrap { overflow-x: auto; border-radius: var(--r-md); }
table.tbl {
  width: 100%;
  border-collapse: collapse;
  background: var(--paper);
  font-size: 17px;
}
table.tbl th, table.tbl td {
  padding: 12px 12px;
  text-align: left;
  border-bottom: 2px solid rgba(74,59,42,.08);
}
table.tbl th {
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--ink-soft);
  background: rgba(255,201,60,.12);
  position: sticky; top: 0;
}
table.tbl td.char-cell { font-size: 24px; font-weight: 900; }
table.tbl input.cell {
  width: 100%;
  font-family: var(--font-body);
  font-size: 18px;
  font-weight: 700;
  padding: 10px;
  min-height: 48px;
  border: 2px solid rgba(74,59,42,.14);
  border-radius: 10px;
  background: #fff;
}
table.tbl input.cell:focus { outline: none; border-color: var(--sky); }

.icon-btn {
  border: none;
  background: rgba(255,107,138,.14);
  color: var(--berry-deep);
  font-weight: 800;
  font-size: 18px;
  width: 48px; height: 48px;
  min-height: 48px;
  border-radius: 12px;
  cursor: pointer;
  transition: background .15s, transform .08s;
}
.icon-btn:hover { background: rgba(255,107,138,.25); }
.icon-btn:active { transform: scale(.9); }

.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin: 16px 0; }

.toast {
  position: fixed;
  left: 50%; bottom: 26px;
  transform: translateX(-50%) translateY(120px);
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  font-size: 17px;
  padding: 16px 26px;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  z-index: 100;
  transition: transform .35s cubic-bezier(.2,1.3,.4,1);
  max-width: 90vw;
  text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.ok  { background: var(--grass-deep); }
.toast.err { background: var(--berry-deep); }

.summary-pills { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.summary-pills .sp {
  background: var(--paper);
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 800;
  box-shadow: 0 4px 0 rgba(74,59,42,.08);
  font-size: 16px;
}
.summary-pills .sp b { font-family: var(--font-display); color: var(--grape); }

.hint-text { color: var(--ink-soft); font-weight: 700; font-size: 15px; margin: 4px 0 0; }

.section-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  margin: 4px 0 16px;
  display: flex; align-items: center; gap: 10px;
}

/* 登入 */
.login-wrap { max-width: 420px; margin: 8vh auto 0; }

/* 浮動裝飾 */
.deco {
  position: fixed;
  font-size: 46px;
  z-index: -1;
  opacity: .5;
  animation: float 6s ease-in-out infinite;
  pointer-events: none;
  user-select: none;
}
.deco.d1 { top: 14%; left: 6%; animation-delay: 0s; }
.deco.d2 { top: 22%; right: 7%; animation-delay: 1.4s; }
.deco.d3 { bottom: 14%; left: 9%; animation-delay: .7s; }
.deco.d4 { bottom: 20%; right: 8%; animation-delay: 2.1s; }
@keyframes float { 0%,100%{ transform: translateY(0) rotate(-6deg);} 50%{ transform: translateY(-16px) rotate(6deg);} }
@media (max-width: 640px){ .deco { display: none; } }

.confetti {
  position: fixed; top: -20px; width: 12px; height: 16px;
  z-index: 200; pointer-events: none; border-radius: 3px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(540deg); opacity: .9; }
}

/* ---------- 選課程 chips（學生選範圍） ---------- */

.chip-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.chip-all {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 16px;
  padding: 12px 18px;
  min-height: 48px;
  border: none;
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink-soft);
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(74,59,42,.10);
  transition: transform .08s, filter .15s;
  touch-action: manipulation;
}
.chip-all:active { transform: translateY(2px); }
.chip-all:hover { filter: brightness(1.03); }

/* 首頁篩選（出版社 / 年級） */
.filters {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0 auto 20px;
  max-width: 680px;
  width: 100%;
}
.filter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.filter-label {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 16px;
  color: var(--ink-soft);
  flex: 0 0 auto;
  min-width: 40px;
}
.filters .chip {
  min-height: 46px;
  padding: 8px 18px;
  font-size: 18px;
  border-width: 3px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 4px solid rgba(74,59,42,.12);
  background: var(--paper);
  border-radius: 999px;
  padding: 12px 20px;
  min-height: 58px;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 20px;
  color: var(--ink);
  transition: transform .1s, border-color .15s, background .15s;
  user-select: none;
  touch-action: manipulation;
}
.chip .chip-name { line-height: 1; }
.chip .chip-num {
  font-size: 14px;
  font-weight: 800;
  background: rgba(74,59,42,.10);
  color: var(--ink-soft);
  padding: 4px 11px;
  border-radius: 999px;
  min-width: 24px;
  text-align: center;
}
.chip.sel {
  border-color: var(--grass-deep);
  background: rgba(76,195,138,.16);
}
.chip.sel .chip-num {
  background: var(--grass);
  color: #fff;
}
.chip.sel::before {
  content: "✓";
  font-size: 16px;
  color: var(--grass-deep);
  font-weight: 900;
}
.chip:active { transform: scale(.96); }
.chip:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- 題庫管理：依課分組（後台） ---------- */

.lesson-block { margin-bottom: 22px; }
.lesson-block:last-child { margin-bottom: 0; }
.lesson-head {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 20px;
  color: var(--ink);
  padding: 10px 16px;
  margin-bottom: 10px;
  background: rgba(155,123,232,.14);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
}

/* ---------- 弱點分析（後台） ---------- */

.weak-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.weak-filter { display: flex; gap: 10px; flex-wrap: wrap; flex: 1 1 auto; }
.weak-refresh { flex: 0 0 auto; }
.weak-chip.sel {
  background: var(--grape);
  color: #fff;
  box-shadow: 0 4px 0 #7a5cc7;
}

/* 每位小朋友一張卡 */
.weak-card { margin-bottom: 18px; padding: 22px; }
.weak-card:last-child { margin-bottom: 0; }

.weak-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.weak-avatar {
  flex: 0 0 auto;
  width: 56px; height: 56px;
  display: grid; place-content: center;
  font-size: 34px;
  line-height: 1;
  border-radius: 50%;
  background: rgba(255,201,60,.18);
  box-shadow: inset 0 0 0 3px rgba(255,201,60,.5);
}
.weak-id { flex: 1 1 auto; min-width: 0; }
.weak-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  color: var(--ink);
  line-height: 1.15;
}
.weak-grade { font-size: 15px; font-weight: 700; color: var(--ink-soft); margin-top: 2px; }

.weak-badge {
  flex: 0 0 auto;
  font-weight: 800;
  font-size: 14px;
  color: var(--berry-deep);
  background: rgba(255,107,138,.16);
  padding: 9px 16px;
  border-radius: 999px;
  white-space: nowrap;
}
.weak-badge b { font-family: var(--font-display); font-size: 18px; margin-left: 2px; }
.weak-badge.is-zero { color: var(--grass-deep); background: rgba(76,195,138,.16); }

.weak-none {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  color: var(--grass-deep);
  background: rgba(76,195,138,.12);
  padding: 18px 20px;
  border-radius: var(--r-sm);
  text-align: center;
}

.weak-chips { display: flex; flex-wrap: wrap; gap: 12px; }

/* 單一弱點字 chip：紅色強度隨錯誤次數加深 */
.weak-chip-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--r-sm);
  padding: 10px 14px;
  border: 2px solid transparent;
  transition: transform .1s;
}
.weak-chip-item:active { transform: scale(.97); }
.weak-chip-item .wc-char {
  font-family: 'Noto Sans TC', serif;
  font-weight: 900;
  font-size: 30px;
  line-height: 1;
  color: var(--ink);
}
.weak-chip-item .wc-type {
  font-weight: 800;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
}
.weak-chip-item .wc-type.is-char   { background: rgba(78,168,245,.18);  color: var(--sky-deep); }
.weak-chip-item .wc-type.is-zhuyin { background: rgba(155,123,232,.18); color: #7a5cc7; }
.weak-chip-item .wc-stat { font-weight: 700; font-size: 13px; color: var(--ink-soft); white-space: nowrap; }
.weak-chip-item .wc-stat b { font-family: var(--font-display); color: var(--berry-deep); }

/* 4 級紅：light → strong */
.weak-chip-item.lv1 { background: rgba(255,107,138,.10); border-color: rgba(255,107,138,.20); }
.weak-chip-item.lv2 { background: rgba(255,107,138,.20); border-color: rgba(255,107,138,.34); }
.weak-chip-item.lv3 { background: rgba(255,107,138,.34); border-color: rgba(232,74,111,.5); }
.weak-chip-item.lv4 { background: rgba(232,74,111,.48); border-color: var(--berry-deep); }
.weak-chip-item.lv4 .wc-char,
.weak-chip-item.lv4 .wc-stat { color: var(--berry-deep); }
.weak-chip-item.lv4 .wc-stat b { color: #fff; background: var(--berry-deep); padding: 1px 7px; border-radius: 999px; }

/* ---------- 首頁底部：家長/後台入口 ---------- */
.home-footer {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 34px auto 0;
  max-width: 680px;
}
.home-footer .btn {
  flex: 1 1 200px;
  text-decoration: none;
  font-size: 18px;
  min-height: 56px;
}

/* ---------- 後台：家長帳號卡片 ---------- */
.parent-row {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  justify-content: space-between;
}
.parent-info { min-width: 160px; }
.parent-name { font-family: var(--font-display); font-weight: 800; font-size: 20px; color: var(--ink); }
.parent-meta { font-size: 14px; color: var(--ink-soft); font-weight: 700; margin-top: 2px; }
