/* ═══════════════════════════════════════════════════════════════
   🍑 小桃子 2.0：學霸動態出版與課堂互動系統 — style.css
   GDD v27 驅動 · MomoLab
   ═══════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────
   § 0. RESET & BASE
   ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { margin: 0; -webkit-font-smoothing: antialiased; }
img { max-width: 100%; }
button { font-family: 'Noto Sans TC', sans-serif; }

/* ─────────────────────────────────────────
   § 1. VIEW SYSTEM
   ───────────────────────────────────────── */
.view { min-height: 100vh; }
.view.hidden { display: none !important; }

/* 💡 View Transitions API 平滑轉場 */
::view-transition-old(root) {
  animation: fadeOut 0.2s ease-out both;
}
::view-transition-new(root) {
  animation: fadeIn 0.25s ease-in both;
}
@keyframes fadeOut {
  to { opacity: 0; transform: translateY(-6px); }
}

/* ─────────────────────────────────────────
   § 2. ANIMATIONS
   ───────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pop {
  0%   { transform: scale(0.6); opacity: 0; }
  50%  { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%  { transform: translateX(-6px); }
  40%  { transform: translateX(6px); }
  60%  { transform: translateX(-4px); }
  80%  { transform: translateX(4px); }
}
@keyframes slideDown {
  from { opacity: 0; transform: translateX(-50%) translateY(-14px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}
@keyframes glow {
  0%, 100% { box-shadow: 0 0 8px rgba(232,115,74,0.3); }
  50%      { box-shadow: 0 0 20px rgba(232,115,74,0.6); }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

.animate-up      { animation: fadeUp 0.4s ease both; }
.animate-pop     { animation: pop 0.5s ease both; }
.animate-shake   { animation: shake 0.35s ease; }

/* 💡 離線模式指示器 */
body.is-offline::after {
  content: '📡 離線模式';
  position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%);
  background: #F59E0B; color: #fff;
  padding: 4px 14px; border-radius: 20px;
  font-size: 11px; font-weight: 700;
  z-index: 9999; pointer-events: none;
  animation: fadeIn 0.3s ease;
}
.animate-pulse   { animation: pulse 1.5s ease infinite; }
.animate-glow    { animation: glow 2s ease infinite; }
.animate-slideup { animation: slideUp 0.35s ease both; }

/* ─────────────────────────────────────────
   § 3. CARDS
   ───────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  transition: all 0.15s ease;
}
.card.clickable:hover {
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}
.card.clickable:active {
  transform: scale(0.98);
}

/* ─────────────────────────────────────────
   § 4. BUTTONS
   ───────────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 22px; border-radius: 10px; border: none;
  background: #E8734A; color: #fff;
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: all 0.15s ease;
}
.btn-primary:hover:not(:disabled) { background: #C74B2A; }
.btn-primary:disabled { background: #E2E2EC; cursor: not-allowed; opacity: 0.6; }
.btn-primary:active:not(:disabled) { transform: scale(0.97); }

.btn-forest {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 22px; border-radius: 10px; border: none;
  background: #4A7A62; color: #fff;
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: all 0.15s ease;
}
.btn-forest:hover { background: #2D4A3E; }
.btn-forest:active { transform: scale(0.97); }

.btn-outline {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border-radius: 10px;
  border: 2px solid #7A7A92; background: transparent; color: #7A7A92;
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all 0.15s ease;
}
.btn-outline:hover { border-color: #3A3A52; color: #3A3A52; }

.btn-danger-outline {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border-radius: 10px;
  border: 2px solid #E05252; background: transparent; color: #E05252;
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all 0.15s ease;
}
.btn-danger-outline:hover { background: #FEE2E2; }

/* 🎯 AI 快捷微調按鈕 */
.ai-quick-btn {
  background: #f8f5ee; border: 1px solid #e0ddd0; border-radius: 14px;
  padding: 3px 10px; font-size: 0.72rem; color: #6d5a30; cursor: pointer;
  white-space: nowrap; transition: all 0.2s; font-family: inherit;
}
.ai-quick-btn:hover { background: #f0ecdf; border-color: #b06820; color: #b06820; }
.ai-quick-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border-radius: 10px;
  border: 2px solid #4A7A62; background: transparent; color: #4A7A62;
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all 0.15s ease;
  font-family: 'Noto Sans TC', sans-serif;
}
.btn-secondary:hover { background: #E6F2EC; }

.btn-small {
  padding: 5px 12px; font-size: 12px; border-radius: 8px;
}

.icon-btn {
  background: none; border: 1.5px solid #E2E2EC; border-radius: 10px;
  padding: 6px 10px; cursor: pointer; font-size: 16px;
  transition: all 0.15s ease; color: #3A3A52;
}
.icon-btn:hover { border-color: #B0B0C4; background: #FAF7F4; }

.btn-back {
  background: none; border: none; font-size: 20px;
  cursor: pointer; padding: 4px 8px; color: #3A3A52;
}
.btn-back:hover { color: #1E1E2C; }

/* ─────────────────────────────────────────
   § 5. FORMS
   ───────────────────────────────────────── */
.form-label {
  display: block; font-size: 13px; font-weight: 700;
  color: #3A3A52; margin-bottom: 6px;
}
.form-input,
.form-select {
  width: 100%; padding: 12px 14px; border-radius: 10px;
  border: 1.5px solid #E2E2EC; font-size: 16px;
  outline: none; background: #fff; color: #1E1E2C;
  font-family: 'Noto Sans TC', sans-serif;
  transition: border-color 0.2s ease;
  -webkit-appearance: none; appearance: none;
}
.form-input:focus,
.form-select:focus {
  border-color: #E8734A;
  box-shadow: 0 0 0 3px rgba(232,115,74,0.1);
}
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%237A7A92'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
textarea.form-input { resize: vertical; line-height: 1.6; }

/* ─────────────────────────────────────────
   § 6. TAB BAR
   ───────────────────────────────────────── */
.tab-bar {
  display: flex;
  background: rgba(226,226,236,0.35);
  border-radius: 10px; padding: 3px;
}
.tab-item {
  flex: 1; text-align: center; padding: 8px 4px; border-radius: 8px;
  cursor: pointer; font-weight: 500; font-size: 12px; color: #7A7A92;
  transition: all 0.2s ease; user-select: none;
}
.tab-item.active {
  background: #fff; font-weight: 700; color: #1E1E2C;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
.tab-item:not(.active):hover { color: #3A3A52; }

/* ─────────────────────────────────────────
   § 7. BADGES & TAGS
   ───────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 10px;
  border-radius: 20px; font-size: 12px; font-weight: 700; line-height: 1.5;
}
.badge-peach  { background: rgba(232,115,74,0.1);  color: #E8734A; }
.badge-forest { background: rgba(74,122,98,0.1);   color: #4A7A62; }
.badge-violet { background: rgba(123,97,176,0.1);  color: #7B61B0; }
.badge-gold   { background: rgba(232,168,48,0.1);  color: #E8A830; }
.badge-sky    { background: rgba(74,140,200,0.1);   color: #4A8CC8; }
.badge-danger { background: rgba(224,82,82,0.1);    color: #E05252; }

.source-tag {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  background: #EAF3FB; color: #4A8CC8; font-size: 11px; font-weight: 600;
}

/* ─────────────────────────────────────────
   § 8. SOURCE PICKER
   ───────────────────────────────────────── */
.source-picker {
  border-radius: 12px; border: 1.5px solid #E2E2EC;
  padding: 14px; background: #FAF7F4;
}
.source-type-btn {
  padding: 5px 10px; border-radius: 8px; cursor: pointer;
  font-size: 12px; font-weight: 600;
  background: #fff; border: 1px solid #E2E2EC; color: #7A7A92;
  transition: all 0.15s ease; display: inline-block;
  font-family: 'Noto Sans TC', sans-serif;
}
.source-type-btn.active {
  background: rgba(232,115,74,0.1); border-color: #E8734A; color: #E8734A;
}
.source-type-btn:hover:not(.active) { border-color: #B0B0C4; }

/* ─────────────────────────────────────────
   § 9. OPTIONS (出題 + 挑戰)
   ───────────────────────────────────────── */
.option-row { display: flex; gap: 8px; align-items: center; }
.option-row input { flex: 1; }

.answer-circle {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; border: 2px solid #E2E2EC;
  background: transparent; color: transparent;
  font-size: 14px; font-weight: 700;
  transition: all 0.2s ease; flex-shrink: 0;
}
.answer-circle.selected {
  background: #4A7A62; border-color: #4A7A62; color: #fff;
}

/* Challenge options */
.q-option {
  padding: 12px 16px; border-radius: 12px;
  border: 1.5px solid #E2E2EC; background: #fff;
  font-size: 14px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  transition: all 0.2s ease; color: #3A3A52;
}
.q-option:hover:not(.locked) { border-color: #F4A488; background: #FFF2ED; }
.q-option.selected { border-color: #E8734A; background: #FFF2ED; color: #C74B2A; }
.q-option.correct { border: 2px solid #4A7A62; background: #E6F2EC; color: #2D4A3E; }
.q-option.correct .opt-circle { background: #4A7A62; border-color: #4A7A62; color: #fff; }
.q-option.wrong { border: 2px solid #E05252; background: #FEE2E2; color: #E05252; }
.q-option.locked { cursor: default; }

.opt-circle {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800;
  border: 1.5px solid currentColor; flex-shrink: 0;
}

/* ─────────────────────────────────────────
   § 10. CATEGORY CHIPS & SELECT
   ───────────────────────────────────────── */
.cat-chip {
  border-radius: 12px; padding: 12px 8px; text-align: center;
  transition: all 0.15s ease;
}
.cat-select-btn {
  padding: 10px 4px; border-radius: 10px; text-align: center;
  cursor: pointer; border: 1.5px solid #E2E2EC; background: #fff;
  transition: all 0.2s ease;
}
.cat-select-btn.active { border-width: 2px; }
.cat-select-btn:hover:not(.active) { border-color: #B0B0C4; }

/* ─────────────────────────────────────────
   § 11. TOAST
   ───────────────────────────────────────── */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  background: #2D4A3E; color: #fff;
  padding: 10px 24px; border-radius: 12px;
  font-size: 14px; font-weight: 600; z-index: 9999;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  animation: slideDown 0.3s ease; white-space: nowrap;
}
.toast.hidden { display: none; }

/* ─────────────────────────────────────────
   § 12. HUB COMPONENTS
   ───────────────────────────────────────── */
.leader-row {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 0; font-size: 13px;
}
.student-card {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; cursor: pointer;
}
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800;
}
.result-mark {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800;
}

/* ─────────────────────────────────────────
   § 13. MODAL SYSTEM (共用)
   ───────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 8000;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}
.modal-overlay.hidden { display: none !important; }

.modal-content {
  background: #fff; border-radius: 20px;
  padding: 24px; width: 100%;
  max-height: 90vh; overflow-y: auto;
  position: relative;
  animation: slideUp 0.3s ease both;
}

.modal-close-btn {
  font-size: 20px; color: #7A7A92;
  cursor: pointer; background: transparent; border: none;
  padding: 4px 8px; border-radius: 8px;
  transition: all 0.15s;
}
.modal-close-btn:hover { color: #1E1E2C; background: #FAF7F4; }

/* ═══════════════════════════════════════════
   §§ 2.0 NEW MODULES
   ═══════════════════════════════════════════ */

/* ─────────────────────────────────────────
   § 14. FACTION (四大陣營)
   ───────────────────────────────────────── */
.faction-card {
  border-radius: 16px; padding: 20px 12px;
  text-align: center; cursor: pointer;
  border: 2.5px solid #E2E2EC; background: #fff;
  transition: all 0.25s ease;
}
.faction-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0,0,0,0.1);
}
.faction-card.selected {
  border-width: 3px;
  transform: scale(1.03);
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}
.faction-card.selected[data-faction="dawn"]   { border-color: #F59E0B; background: #FEF3C7; }
.faction-card.selected[data-faction="azure"]  { border-color: #3B82F6; background: #DBEAFE; }
.faction-card.selected[data-faction="dragon"] { border-color: #8B5CF6; background: #EDE9FE; }
.faction-card.selected[data-faction="wave"]   { border-color: #06B6D4; background: #CFFAFE; }

/* Faction bar (hub 陣營戰況) */
.faction-bar {
  display: flex; align-items: center; gap: 8px;
}
.faction-bar-fill {
  height: 14px; border-radius: 7px;
  transition: width 0.6s ease;
  min-width: 6px;
}
.faction-bar-fill[data-f="dawn"]   { background: linear-gradient(90deg, #F59E0B, #FBBF24); }
.faction-bar-fill[data-f="azure"]  { background: linear-gradient(90deg, #3B82F6, #60A5FA); }
.faction-bar-fill[data-f="dragon"] { background: linear-gradient(90deg, #8B5CF6, #A78BFA); }
.faction-bar-fill[data-f="wave"]   { background: linear-gradient(90deg, #06B6D4, #22D3EE); }

/* ─────────────────────────────────────────
   § 15. PENNAME (署名選擇器)
   ───────────────────────────────────────── */
.penname-btn {
  border-radius: 12px; padding: 10px 4px;
  text-align: center; cursor: pointer;
  border: 2px solid #E2E2EC; background: #fff;
  transition: all 0.2s ease;
}
.penname-btn:hover:not(.active) { border-color: #B0B0C4; }
.penname-btn.active {
  border-color: #E8734A; background: #FFF2ED;
}
.penname-btn.active .text-xs { color: #E8734A; }

/* ─────────────────────────────────────────
   § 16. CORNELL NOTEBOOK (康乃爾雙欄)
   ───────────────────────────────────────── */
.cornell-layout {
  display: flex; gap: 12px;
  border: 1.5px solid #E2E2EC; border-radius: 12px;
  overflow: hidden; background: #fff;
}
.cornell-left {
  width: 35%; min-width: 100px;
  padding: 14px 12px;
  background: #FAF7F4;
  border-right: 1.5px solid #E2E2EC;
  overflow-y: auto; max-height: 360px;
}
.cornell-right {
  flex: 1; padding: 10px 12px;
}

@media (max-width: 400px) {
  .cornell-layout { flex-direction: column; }
  .cornell-left {
    width: 100%; max-height: 120px;
    border-right: none; border-bottom: 1.5px solid #E2E2EC;
  }
}

/* ─────────────────────────────────────────
   § 17. CANVAS TOOLS (手寫畫布)
   ───────────────────────────────────────── */
.handwrite-canvas {
  width: 100%; height: auto;
  border: 1.5px solid #E2E2EC; border-radius: 10px;
  cursor: crosshair; touch-action: none;
  background: #FEFEFE;
}

.canvas-tool-btn {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: #fff; border: 1.5px solid #E2E2EC;
  color: #7A7A92; cursor: pointer;
  font-size: 13px; transition: all 0.15s;
}
.canvas-tool-btn:hover { border-color: #B0B0C4; color: #3A3A52; }
.canvas-tool-btn.active {
  background: #E8734A; border-color: #E8734A; color: #fff;
}

.canvas-color-btn {
  width: 22px; height: 22px; border-radius: 50%;
  cursor: pointer; border: 2px solid transparent;
  transition: all 0.15s; flex-shrink: 0;
}
.canvas-color-btn.active {
  border-color: #1E1E2C;
  box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px currentColor;
}
.canvas-color-btn:hover:not(.active) {
  transform: scale(1.15);
}

/* ─────────────────────────────────────────
   § 18. NOTEBOOK CARD (錯題卡)
   ───────────────────────────────────────── */
.notebook-card {
  background: #fff; border-radius: 14px;
  padding: 16px; position: relative;
  border-left: 4px solid #E8734A;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  transition: all 0.15s ease;
}
.notebook-card.mastered {
  border-left-color: #4A7A62; opacity: 0.7;
}
.notebook-card .nb-actions {
  display: flex; gap: 6px; margin-top: 10px;
}

/* ─────────────────────────────────────────
   § 19. PRINT ENGINE (列印出版)
   ───────────────────────────────────────── */
.print-color-btn {
  width: 28px; height: 28px; border-radius: 50%;
  cursor: pointer; border: 2.5px solid transparent;
  transition: all 0.15s; flex-shrink: 0;
}
.print-color-btn.active {
  border-color: #1E1E2C;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px currentColor;
}
.print-color-btn:hover:not(.active) { transform: scale(1.1); }

/* 遮蔽答案模式 */
.print-masked .print-answer,
.print-masked .print-explain {
  position: relative;
  color: transparent !important;
  user-select: none;
}
.print-masked .print-answer::after,
.print-masked .print-explain::after {
  content: '🔥 遮蔽中 — 自己想想看！';
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: repeating-linear-gradient(
    45deg, #FFF2ED, #FFF2ED 4px, #FFE4D6 4px, #FFE4D6 8px
  );
  color: #E8734A; font-size: 11px; font-weight: 700;
  border-radius: 6px;
}

/* ─────────────────────────────────────────
   § 20. EDITOR (全能編輯器)
   ───────────────────────────────────────── */
.editor-ans-btn {
  width: 42px; height: 42px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #E2E2EC; background: #fff;
  color: #7A7A92; font-size: 16px; font-weight: 800;
  cursor: pointer; transition: all 0.2s;
  font-family: 'Noto Sans TC', sans-serif;
}
.editor-ans-btn.active {
  background: #4A7A62; border-color: #4A7A62; color: #fff;
}
.editor-ans-btn:hover:not(.active) { border-color: #7BAF95; }

/* ─────────────────────────────────────────
   § 21. LIVE ARENA (即時競技場)
   ───────────────────────────────────────── */
.live-overlay {
  position: fixed; inset: 0; z-index: 9500;
  background: linear-gradient(135deg, #1E1E2C 0%, #2D4A3E 50%, #1E1E2C 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn 0.4s ease;
}
.live-overlay.hidden { display: none !important; }

.live-arena {
  max-width: 440px; width: 100%;
}

/* Live 題目勾選列表 (老師控制台) */
.live-check-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 8px;
  cursor: pointer; transition: background 0.15s;
}
.live-check-item:hover { background: #FAF7F4; }

.live-checkbox {
  width: 20px; height: 20px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #E2E2EC; background: #fff;
  font-size: 12px; font-weight: 800; color: transparent;
  transition: all 0.2s; flex-shrink: 0;
}
.live-checkbox.checked {
  background: #E8734A; border-color: #E8734A; color: #fff;
}

/* ─────────────────────────────────────────
   § 22. TTS BUTTON (語音朗讀)
   ───────────────────────────────────────── */
.tts-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 8px;
  background: #EAF3FB; border: none;
  color: #4A8CC8; font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
  font-family: 'Noto Sans TC', sans-serif;
}
.tts-btn:hover { background: #D0E7F8; }
.tts-btn.speaking {
  background: #4A8CC8; color: #fff;
  animation: pulse 1s ease infinite;
}

/* ─────────────────────────────────────────
   § 23. TEACHER COMPONENTS
   ───────────────────────────────────────── */
/* Analytics bar */
.bar-h {
  height: 20px; border-radius: 6px;
  transition: width 0.5s ease; min-width: 4px;
}

/* Student row */
.stu-row {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 12px; border-radius: 10px;
  cursor: pointer; transition: background 0.15s;
}
.stu-row:hover { background: #FAF7F4; }

/* Metric card */
.metric-card {
  border-radius: 10px; padding: 10px 12px; text-align: center;
}

/* Algorithm progress bar */
.algo-bar-bg {
  height: 10px; background: #E2E2EC;
  border-radius: 5px; overflow: hidden;
}
.algo-bar-fill {
  height: 100%; border-radius: 5px;
  transition: width 0.6s ease;
}

/* ─────────────────────────────────────────
   § 24. PARENT REPORT
   ───────────────────────────────────────── */
.parent-guide-section {
  padding: 12px; border-radius: 10px;
  background: #FAF7F4;
}
.parent-guide-section h5 {
  font-size: 13px; font-weight: 800; margin: 0 0 6px 0;
}
.parent-guide-section p {
  font-size: 13px; color: #3A3A52;
  line-height: 1.7; margin: 0;
}

/* ─────────────────────────────────────────
   § 25. BLINDBOX (艾賓浩斯盲盒)
   ───────────────────────────────────────── */
.blindbox-reveal {
  animation: pop 0.5s ease both;
}

/* ─────────────────────────────────────────
   § 26. CHALLENGE FEEDBACK ACTIONS
   ───────────────────────────────────────── */
.feedback-actions {
  display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px;
}
.feedback-action-btn {
  padding: 5px 12px; border-radius: 8px;
  font-size: 12px; font-weight: 600;
  cursor: pointer; border: 1.5px solid #E2E2EC;
  background: #fff; color: #7A7A92;
  transition: all 0.15s;
  font-family: 'Noto Sans TC', sans-serif;
}
.feedback-action-btn:hover { border-color: #B0B0C4; color: #3A3A52; }
.feedback-action-btn.voted {
  background: #E6F2EC; border-color: #4A7A62; color: #4A7A62;
}

/* ─────────────────────────────────────────
   § 27. SCROLLBAR
   ───────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #E2E2EC; border-radius: 4px; }

/* ─────────────────────────────────────────
   § 28. TEXT UTILITIES
   ───────────────────────────────────────── */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.line-clamp-1 {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ─────────────────────────────────────────
   § 29. RESPONSIVE
   ───────────────────────────────────────── */
@media (max-width: 380px) {
  .tab-item { font-size: 10px; padding: 6px 2px; }
  .penname-btn { padding: 8px 2px; }
  .penname-btn .text-lg { font-size: 16px; }
  .faction-card { padding: 14px 8px; }
}

/* 💡 行動裝置優化 */
@media (max-width: 640px) {
  /* iOS 安全區域 (notch / home indicator) */
  body { padding-bottom: env(safe-area-inset-bottom, 0); }
  
  /* 觸控目標最小 44px (Apple HIG) */
  button, .clickable, .tab-item, .faction-card {
    min-height: 44px;
  }
  
  /* 防止 iOS 雙擊縮放 */
  button, input, select, textarea { touch-action: manipulation; }
  
  /* 更流暢的捲動 */
  .modal-content, .view {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  
  /* Toast 位置避開底部安全區 */
  #toast {
    bottom: calc(20px + env(safe-area-inset-bottom, 0)) !important;
  }
}

/* 💡 平板裝置優化 (768px–1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
  /* Modal 對話框不溢出，限寬並增加內距 */
  .modal-content {
    max-width: 90vw;
    padding: 28px;
  }

  /* 來源選擇器與表單欄位在平板更寬敞 */
  .source-picker {
    padding: 18px;
  }

  /* Tab bar 文字在平板稍大 */
  .tab-item {
    font-size: 13px;
    padding: 10px 6px;
  }

  /* 康乃爾筆記雙欄在平板加大左欄 */
  .cornell-left {
    max-height: 420px;
  }

  /* 手寫畫布在平板更高 */
  .handwrite-canvas {
    min-height: 320px;
  }

  /* 卡片在平板加大內距 */
  .card {
    padding: 24px;
  }

  /* 固定寬度元素改為響應式 */
  .live-arena {
    max-width: 560px;
  }
}

/* 💡 減少動畫（使用者偏好設定） */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─────────────────────────────────────────
   § 30. PRINT-ONLY STYLES (PDF 匯出用)
   ───────────────────────────────────────── */
@media print {
  @page { margin: 12mm; }
  body { background: #fff !important; }
  .toast, .live-overlay,
  .btn-back, .icon-btn, .tab-bar,
  #toast, .feedback-actions { display: none !important; }
  .card { box-shadow: none !important; break-inside: avoid; page-break-inside: avoid; }
  .view { min-height: auto !important; }
  /* Modal 列印核心：從 fixed 轉為靜態文檔流，讓瀏覽器正確分頁 */
  .modal-content {
    position: static !important;
    transform: none !important;
    max-height: none !important;
    overflow: visible !important;
    box-shadow: none !important;
  }
  .modal-overlay {
    position: absolute !important;
    overflow: visible !important;
    height: auto !important;
    /* 🔑 解除 flex 置中，防止多頁列印頂部被切 */
    display: block !important;
    align-items: normal !important;
  }
  /* 題目卡 / 錯題卡防截斷 */
  .pdf-question-block, .mistake-card {
    break-inside: avoid !important;
    page-break-inside: avoid !important;
    margin-bottom: 12px !important;
  }
  /* 列印字體穩定化 */
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
}
