/* ── Variables ─────────────────────────────────────────── */
:root {
  --primary: #2563EB;
  --primary-dark: #1D4ED8;
  --accent: #DBEAFE;
  --success: #22C55E;
  --error: #EF4444;
  --bg: #F1F5F9;
  --card: #FFFFFF;
  --text: #1E293B;
  --muted: #64748B;
  --gold: #F59E0B;
  --radius: 16px;
}
[data-theme="eva"]    { --primary: #9333EA; --primary-dark: #7C3AED; --accent: #F3E8FF; }
[data-theme="parent"] { --primary: #0F766E; --primary-dark: #0D5F58; --accent: #CCFBF1; }

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-tap-highlight-color: transparent; }
body { font-family: -apple-system, 'Noto Sans TC', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* ── Pages ─────────────────────────────────────────────── */
.page { display: none; min-height: 100vh; }
.page.active { display: flex; flex-direction: column; }

/* ── Buttons ───────────────────────────────────────────── */
.btn { display: block; width: 100%; padding: 16px; border: none; border-radius: var(--radius); font-size: 1.05rem; font-weight: 600; cursor: pointer; transition: transform 0.1s, opacity 0.1s; }
.btn:active { transform: scale(0.97); opacity: 0.85; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; }
.btn-outline  { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn-ghost    { background: transparent; color: var(--muted); font-size: 0.9rem; padding: 10px; }

/* ── Card ──────────────────────────────────────────────── */
.card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: 0 2px 12px rgba(0,0,0,0.07); margin: 0 16px 14px; }
.mb-12 { margin-bottom: 12px; }

/* ══ LOGIN ════════════════════════════════════════════════ */
#login { align-items: center; justify-content: center; padding: 40px 24px; gap: 16px; }
.login-title { font-size: 1.7rem; font-weight: 800; }
.login-sub   { color: var(--muted); font-size: 0.95rem; }
.user-grid   { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; width: 100%; max-width: 360px; }
.user-btn {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 24px 12px; border: 3px solid transparent; border-radius: 20px;
  background: var(--card); cursor: pointer; font-size: 1rem; font-weight: 700;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08); transition: transform 0.15s;
}
.user-btn:active { transform: scale(0.95); }
.user-btn .avatar { font-size: 3rem; line-height: 1; }
.user-btn.max { border-color: #2563EB; color: #2563EB; }
.user-btn.eva { border-color: #9333EA; color: #9333EA; }
.grade-tag { font-size: 0.75rem; font-weight: 400; color: var(--muted); }
.parent-btn {
  width: 100%; max-width: 360px; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px; border: 2px solid #CBD5E1; border-radius: var(--radius);
  background: var(--card); color: var(--muted); cursor: pointer; font-size: 0.95rem; font-weight: 600;
  box-shadow: 0 1px 6px rgba(0,0,0,0.05); transition: transform 0.1s;
}
.parent-btn:active { transform: scale(0.97); }

/* ══ DASHBOARD ════════════════════════════════════════════ */
#dashboard { gap: 0; }
.dash-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; padding: 24px 20px 36px; border-radius: 0 0 32px 32px;
}
.dash-header h2 { font-size: 1.5rem; font-weight: 800; }
.dash-header .date { font-size: 0.9rem; opacity: 0.8; margin-top: 4px; }
.dash-content { flex: 1; padding: 16px; margin-top: -16px; }

.status { font-size: 1rem; font-weight: 600; padding: 12px 16px; border-radius: 12px; margin-bottom: 14px; text-align: center; }
.status.done    { background: #DCFCE7; color: #166534; }
.status.pending { background: #FEF9C3; color: #854D0E; }

/* Level card */
.level-card { padding: 14px 16px; }
.level-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.level-left { display: flex; align-items: center; gap: 8px; }
.level-icon { font-size: 1.6rem; }
.level-name { font-size: 1.15rem; font-weight: 800; color: var(--primary); }
.level-right { display: flex; gap: 14px; font-size: 0.9rem; color: var(--muted); }
.level-right strong { color: var(--text); }
.level-bar-bg { height: 8px; background: #E2E8F0; border-radius: 99px; overflow: hidden; }
.level-bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-dark)); border-radius: 99px; transition: width 0.5s ease; }

/* Week calendar */
.week-title { font-size: 0.82rem; color: var(--muted); margin-bottom: 10px; font-weight: 600; letter-spacing: 0.03em; }
#week-calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 7px 3px; border-radius: 10px; background: #F8FAFC; border: 2px solid transparent; }
.cal-cell.today { border-color: var(--primary); background: var(--accent); }
.cal-cell.done  { background: #DCFCE7; }
.cal-day  { font-size: 0.68rem; color: var(--muted); font-weight: 600; }
.cal-icon { font-size: 0.95rem; }

/* Badges */
.badges-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.badge-item { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px; border-radius: 12px; text-align: center; transition: transform 0.15s; }
.badge-item.unlocked { background: var(--accent); }
.badge-item.locked   { background: #F1F5F9; filter: grayscale(0.8); opacity: 0.5; }
.badge-icon { font-size: 1.6rem; }
.badge-name { font-size: 0.7rem; font-weight: 600; color: var(--text); }

/* ══ PRACTICE ══════════════════════════════════════════════ */
#practice { gap: 0; }
.prac-header { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; padding: 20px 20px 24px; }
.prac-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 0.88rem; opacity: 0.9; }
.subject-badge { background: rgba(255,255,255,0.25); border-radius: 20px; padding: 4px 14px; font-weight: 700; }
.progress-bar { height: 6px; background: rgba(255,255,255,0.3); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; background: #fff; border-radius: 99px; transition: width 0.4s ease; }
.prac-body   { flex: 1; padding: 20px 16px 0; overflow-y: auto; }
.prac-footer { padding: 12px 16px 24px; display: flex; flex-direction: column; gap: 10px; }
.question-text { font-size: 1.2rem; font-weight: 700; line-height: 1.5; margin-bottom: 18px; min-height: 56px; }
.opt-btn {
  display: block; width: 100%; text-align: left; padding: 15px 18px; margin-bottom: 11px;
  border: 2.5px solid #E2E8F0; border-radius: var(--radius); background: var(--card);
  font-size: 0.98rem; font-weight: 500; cursor: pointer; transition: border-color 0.15s, background 0.15s; line-height: 1.4;
}
.opt-btn.selected { border-color: var(--primary); background: var(--accent); }
.opt-btn.correct  { border-color: var(--success); background: #DCFCE7; color: #166534; }
.opt-btn.wrong    { border-color: var(--error);   background: #FEE2E2; color: #991B1B; }
.opt-btn:disabled { cursor: default; }
.explanation { display: none; padding: 14px 16px; border-radius: var(--radius); font-size: 0.92rem; line-height: 1.65; margin-bottom: 14px; }
.explanation.correct { background: #DCFCE7; color: #166534; border-left: 4px solid var(--success); }
.explanation.wrong   { background: #FEE2E2; color: #991B1B; border-left: 4px solid var(--error); }

/* Coin flash */
@keyframes coinFloat {
  0%   { opacity: 1; transform: translate(-50%, -50%); }
  100% { opacity: 0; transform: translate(-50%, -180%); }
}
.coin-flash {
  position: fixed; pointer-events: none; z-index: 9999;
  font-size: 1.5rem; font-weight: 800; color: var(--gold);
  text-shadow: 0 2px 8px rgba(0,0,0,0.15);
  animation: coinFloat 0.85s ease-out forwards;
}

/* ══ RESULT ═══════════════════════════════════════════════ */
#result { align-items: center; justify-content: center; padding: 40px 24px; text-align: center; gap: 10px; }
.result-stars  { font-size: 2rem; }
.result-score  { font-size: 3.2rem; font-weight: 800; color: var(--primary); line-height: 1; }
.result-pct    { font-size: 1rem; color: var(--muted); }
.result-coins  { font-size: 1.3rem; font-weight: 700; color: var(--gold); }
.result-level  { font-size: 1rem; color: var(--muted); }
.result-msg    { font-size: 1.2rem; font-weight: 600; margin: 4px 0 8px; }
.result-badges { background: #FEF9C3; border-radius: var(--radius); padding: 12px 16px; font-size: 0.95rem; font-weight: 600; color: #92400E; line-height: 1.7; width: 100%; max-width: 360px; }
.result-actions { width: 100%; max-width: 360px; }

/* ══ PARENT ════════════════════════════════════════════════ */
#parent { gap: 0; }
.parent-header { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; padding: 24px 20px 28px; border-radius: 0 0 28px 28px; }
.parent-header h2 { font-size: 1.3rem; font-weight: 800; }
.parent-body { flex: 1; padding: 16px; overflow-y: auto; }
.parent-card { margin-bottom: 16px; }
.parent-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.parent-card-header h3 { font-size: 1rem; font-weight: 700; color: var(--primary); }
.parent-summary { font-size: 0.85rem; color: var(--muted); margin-top: 2px; }
.btn-pdf {
  background: var(--accent); color: var(--primary); border: none; border-radius: 10px;
  padding: 7px 14px; font-size: 0.82rem; font-weight: 700; cursor: pointer; white-space: nowrap;
  transition: transform 0.1s;
}
.btn-pdf:active { transform: scale(0.95); }
.chart-wrap { margin-bottom: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { padding: 8px 6px; text-align: center; border-bottom: 1px solid #F1F5F9; }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; }
