/* ============================================================
   AI私教 — Design System
   OKLCH color space · Warm editorial palette
   ============================================================ */

:root {
  /* Warm beige foundation with subtle chroma shift */
  --bg:         oklch(96% 0.012 75);
  --surface:    oklch(99% 0.006 80);
  --surface2:   oklch(97% 0.008 78);
  --bg-alt:     oklch(94% 0.01 70);
  --msg-user:   oklch(90% 0.015 80);
  --msg-ai:     oklch(99% 0.006 80);

  /* Neutrals — warm shift, no pure gray */
  --border:      oklch(86% 0.018 80);
  --text:        oklch(18% 0.02 60);
  --text-dim:    oklch(56% 0.025 70);
  --text-light:  oklch(70% 0.025 70);

  /* Accent — warm terracotta */
  --accent:      oklch(58% 0.12 45);
  --accent-dim:  oklch(50% 0.10 45);
  --accent-light: oklch(70% 0.08 50);
  --accent-bg:   oklch(94% 0.02 70);

  /* Semantic */
  --red:    oklch(62% 0.10 30);
  --green:  oklch(68% 0.08 145);
  --blue:   oklch(60% 0.08 255);
  --orange: oklch(68% 0.10 70);

  --radius: 12px;
  --shadow: 0 1px 4px oklch(0% 0 0 / 0.06);
  --font-serif: 'Noto Serif SC', 'Source Han Serif CN', serif;
  --font-sans:  'Space Grotesk', system-ui, sans-serif;
  --font-mono:  'JetBrains Mono', 'Fira Code', monospace;
}

/* Dark mode */
.dark {
  --bg:         oklch(16% 0.008 60);
  --surface:    oklch(20% 0.01 65);
  --surface2:   oklch(24% 0.012 65);
  --bg-alt:     oklch(22% 0.01 65);
  --msg-user:   oklch(26% 0.015 60);
  --msg-ai:     oklch(20% 0.01 65);
  --border:     oklch(28% 0.015 65);
  --text:       oklch(90% 0.01 80);
  --text-dim:   oklch(56% 0.02 75);
  --text-light: oklch(44% 0.02 70);
  --accent:     oklch(72% 0.08 50);
  --accent-light: oklch(80% 0.06 55);
  --accent-bg:  oklch(24% 0.015 65);
  --shadow: 0 1px 4px oklch(0% 0 0 / 0.2);
}

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

body {
  font-family: var(--font-serif);
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  transition: background 0.3s, color 0.3s;
}

/* ===== Scrollbar ===== */
.chat-area::-webkit-scrollbar { width: 4px; }
.chat-area::-webkit-scrollbar-track { background: transparent; }
.chat-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ===== Typography ===== */
.text-dim-center-p40 { font-size: 13px; color: var(--text-dim); text-align: center; padding: 40px; }
.red-center-p40 { text-align: center; padding: 40px; color: var(--red); font-size: 13px; }
.text-xs-dim { font-size: 10px; color: var(--text-dim); font-family: var(--font-sans); }

/* ===== Animations ===== */
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes slideDown { from { transform: translateY(-100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes typingBounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-6px); opacity: 1; } }
@keyframes timerPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes popCorrect { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }
@keyframes shakeWrong { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-4px); } 40% { transform: translateX(4px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
@keyframes celebrateBounce { 0%,100% { transform: translateY(0); } 30% { transform: translateY(-10px); } 60% { transform: translateY(-5px); } }
@keyframes comboAnim { 0% { transform: scale(0.5) translateY(20px); opacity: 0; } 30% { transform: scale(1.2) translateY(-5px); opacity: 1; } 60% { transform: scale(0.95) translateY(0); opacity: 1; } 100% { transform: scale(1) translateY(-30px); opacity: 0; } }
@keyframes coinDrop { 0% { transform: translateY(-20px) scale(0.5); opacity: 0; } 50% { transform: translateY(0) scale(1.2); opacity: 1; } 100% { transform: translateY(0) scale(1); opacity: 1; } }
@keyframes recPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }
@keyframes progressIndeterminate { 0% { transform: translateX(-100%); } 100% { transform: translateX(400%); } }
@keyframes ttsPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.6; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.anim-fade-in { animation: fadeIn 0.25s ease; }

/* ===== Header ===== */
.header { display: flex; flex-direction: column; gap: 4px; padding: 8px 16px 4px; flex-shrink: 0; background: var(--surface); position: relative; z-index: 50; }
.header-row1, .header-row2 { display: flex; align-items: center; gap: 8px; width: 100%; }
.header-info { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; }
.header-name { font-size: 15px; font-weight: 700; white-space: nowrap; }
.header-status { font-size: 11px; color: var(--text-light); font-family: var(--font-sans); white-space: nowrap; }
.header-energy { display: inline-flex; align-items: center; gap: 2px; font-size: 11px; color: var(--text-light); font-family: var(--font-sans); }

.nav-btn { font-size: 14px; color: var(--text-light); cursor: pointer; padding: 4px 8px; border-radius: 6px; background: none; border: none; transition: background 0.1s; }
.nav-btn:hover { background: var(--surface2); }

.header-grade-select, .subject-select { border: 1px solid var(--border); border-radius: 6px; background: var(--surface2); color: var(--text); font-size: 12px; font-family: var(--font-sans); padding: 4px 6px; cursor: pointer; outline: none; min-width: 68px; text-align: center; }
.header-grade-select:focus, .subject-select:focus { border-color: var(--accent); }

/* ===== Page Mode Switch ===== */
.page-mode-switch { display: flex; background: var(--surface); padding: 0 16px; gap: 2px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.page-mode-btn { flex: 1; padding: 7px 6px; text-align: center; font-size: 13px; font-family: var(--font-sans); font-weight: 500; cursor: pointer; border: none; background: none; color: var(--text-dim); border-bottom: 2px solid transparent; transition: all 0.15s; border-radius: 6px 6px 0 0; white-space: nowrap; }
.page-mode-btn:hover { color: var(--text); background: var(--bg); }
.page-mode-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.page-content { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#pageChat { position: relative; }

/* ===== Landing Page ===== */
.landing { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.landing-bg { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 0%, var(--accent-bg) 0%, transparent 60%), radial-gradient(ellipse at 80% 100%, oklch(97% 0.015 70) 0%, transparent 50%); }
.landing-content { position: relative; text-align: center; padding: 24px; max-width: 360px; width: 100%; }
.landing-logo { font-size: 56px; margin-bottom: 8px; }
.landing-title { font-size: 28px; font-weight: 700; margin-bottom: 4px; }
.landing-sub { font-size: 14px; color: var(--text-dim); margin-bottom: 20px; }
.landing-feats { display: flex; gap: 6px; justify-content: center; margin-bottom: 24px; flex-wrap: wrap; }
.landing-feats span { font-size: 12px; background: var(--surface); border: 1px solid var(--border); padding: 4px 10px; border-radius: 12px; color: var(--text-dim); }
.landing-close-btn { position: absolute; top: 8px; right: 8px; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-light); padding: 4px 8px; z-index: 1; font-family: var(--font-sans); line-height: 1; }
.landing-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.ltab { flex: 1; padding: 8px; font-size: 13px; font-family: var(--font-sans); border: none; background: none; color: var(--text-dim); cursor: pointer; border-bottom: 2px solid transparent; transition: all 0.15s; }
.ltab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 500; }
.landing-input { width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; font-family: var(--font-serif); font-size: 15px; outline: none; background: var(--bg); margin-bottom: 10px; transition: border-color 0.2s; }
.landing-input:focus { border-color: var(--accent); }
.landing-btn { width: 100%; padding: 12px; border: none; border-radius: 8px; background: var(--accent); color: #fff; font-family: var(--font-sans); font-size: 15px; font-weight: 600; cursor: pointer; transition: background 0.15s; margin-top: 4px; }
.landing-btn:hover { background: var(--accent-light); }
.landing-btn:disabled { opacity: 0.5; cursor: default; }
.landing-error { font-size: 12px; color: var(--red); margin-top: 8px; min-height: 20px; }
.landing-footer { margin-top: 16px; font-size: 12px; color: var(--text-dim); }
.landing-footer a { color: var(--accent); text-decoration: none; }

/* ===== Input Area (Chat) ===== */
.input-area { border-top: 1px solid var(--border); background: var(--surface); padding: 8px 12px; flex-shrink: 0; }
.input-row { display: flex; gap: 6px; align-items: flex-end; }
.input-area textarea { flex: 1; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-family: var(--font-serif); font-size: 15px; resize: none; outline: none; background: var(--bg); min-height: 44px; max-height: 100px; transition: border-color 0.2s; }
.input-area textarea:focus { border-color: var(--accent); }
.toolbar-row { display: flex; gap: 4px; padding-top: 6px; justify-content: center; }
.input-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg); color: var(--text-dim); font-size: 15px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.15s; flex-shrink: 0; }
.input-btn:hover { background: var(--surface); border-color: var(--accent); color: var(--accent); }
.send-btn { width: 44px; height: 44px; border-radius: 50%; border: none; background: var(--accent); color: #fff; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.15s; flex-shrink: 0; }
.send-btn:hover { background: var(--accent-light); transform: scale(1.05); }
.send-btn:disabled { opacity: 0.4; cursor: default; transform: none; }

/* ===== Chat Area ===== */
.chat-area { flex: 1; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { display: flex; gap: 8px; max-width: 88%; animation: fadeIn 0.25s ease; }
.msg.user { margin-left: auto; flex-direction: row-reverse; }
.msg.ai { margin-right: auto; }
.msg.system { justify-content: center; max-width: 100%; }
.msg.system > div { font-size: 11px; color: var(--text-light); background: var(--surface2); padding: 4px 14px; border-radius: 12px; font-family: var(--font-sans); }
.msg .bubble { padding: 10px 14px; border-radius: var(--radius); font-size: 14px; line-height: 1.8; position: relative; min-width: 30px; }
.msg.user .bubble { background: var(--msg-user); border-radius: 16px 4px 16px 16px; }
.msg.ai .bubble { background: var(--surface); border: 1px solid var(--border); border-radius: 4px 16px 16px 16px; box-shadow: var(--shadow); }

/* Typing indicator */
.typing .bubble { display: flex; align-items: center; gap: 4px; padding: 12px 16px; }
.typing-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-dim); animation: typingBounce 1.4s infinite; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* ===== Recording Banner ===== */

/* ===== TTS / Voice ===== */
.tts-btn { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface2); color: var(--text-dim); font-size: 13px; cursor: pointer; transition: all 0.15s; flex-shrink: 0; margin: 0 0 0 6px; vertical-align: middle; }
.tts-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }
.tts-btn.playing { background: var(--accent); color: #fff; border-color: var(--accent); animation: ttsPulse 0.8s infinite; }
.tts-toggle { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-dim); cursor: pointer; padding: 2px 8px; border-radius: 20px; border: 1px solid var(--border); background: var(--surface2); transition: all 0.2s; margin-left: auto; }
.tts-toggle.on { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }

/* ===== Progress Bar ===== */
.progress-bar { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; margin-top: 6px; }
.progress-bar::after { content: ''; display: block; height: 100%; width: 30%; background: var(--accent); border-radius: 2px; animation: progressIndeterminate 1.5s infinite; }

/* ===== Photo Modal ===== */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: oklch(0% 0 0 / 0.5); z-index: 1000; display: flex; align-items: flex-end; justify-content: center; }
.photo-sheet { background: var(--bg); border-radius: 16px 16px 0 0; padding: 12px 20px 28px; width: 100%; max-width: 420px; box-shadow: 0 -4px 20px oklch(0% 0 0 / 0.15); animation: slideUp 0.3s ease-out; }
.photo-sheet-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--border); margin: 0 auto 16px; }
.photo-sheet-title { font-size: 16px; font-weight: 600; color: var(--text); text-align: center; margin-bottom: 16px; }
.photo-sheet-options { display: flex; flex-direction: column; gap: 8px; }
.photo-sheet-option { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 12px; cursor: pointer; transition: 0.15s; }
.photo-sheet-option:hover { background: var(--accent-bg); }
.photo-sheet-option:active { transform: scale(0.98); }
.ps-icon { font-size: 28px; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; background: var(--accent-bg); border-radius: 12px; }
.ps-text { flex: 1; }
.ps-title { font-size: 15px; font-weight: 500; color: var(--text); }
.ps-desc { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.photo-sheet-cancel { width: 100%; padding: 12px; margin-top: 12px; border-radius: 12px; background: var(--bg-alt); color: var(--text-dim); font-size: 14px; border: none; cursor: pointer; }

.photo-intent-modal { background: var(--bg); border-radius: 16px 16px 0 0; padding: 24px 20px 32px; width: 100%; max-width: 420px; box-shadow: 0 -4px 20px oklch(0% 0 0 / 0.15); text-align: center; animation: slideUp 0.3s ease-out; }
.photo-intent-header { font-size: 18px; font-weight: 600; color: var(--text); margin-bottom: 12px; }
.photo-intent-preview { max-height: 120px; overflow: hidden; border-radius: 8px; margin-bottom: 12px; }
.photo-intent-preview img { width: 100%; max-height: 120px; object-fit: cover; border-radius: 8px; }
.photo-intent-text { font-size: 14px; color: var(--text-dim); margin-bottom: 16px; }
.photo-intent-btns { display: flex; gap: 12px; margin-bottom: 12px; }
.intent-btn { flex: 1; padding: 14px 16px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--bg); font-size: 15px; cursor: pointer; color: var(--text); transition: 0.2s; font-family: inherit; }
.intent-btn:hover { transform: translateY(-1px); }
.intent-explain { border-color: var(--accent); background: var(--accent-bg); color: var(--accent); }
.intent-explain:hover { background: var(--accent); color: #fff; }
.intent-grade { border-color: oklch(72% 0.10 70); background: oklch(98% 0.015 80); color: oklch(50% 0.08 70); }
.intent-grade:hover { background: oklch(72% 0.10 70); color: #fff; }
.intent-cancel { width: 100%; padding: 10px; border-radius: 10px; background: transparent; color: var(--text-dim); font-size: 13px; border: none; }

/* ===== Test / Dashboard ===== */
.test-level { padding: 14px 16px 10px; background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.tl-header { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.tl-icon { font-size: 22px; }
.tl-name { font-size: 15px; font-weight: 700; flex: 1; }
.tl-points { font-size: 12px; color: var(--text-dim); font-family: var(--font-sans); }
.tl-bar-bg { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.tl-bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-light)); border-radius: 3px; transition: width 0.6s ease; }
.tl-next { font-size: 10px; color: var(--text-light); font-family: var(--font-sans); margin-top: 4px; }
.tl-shields { font-size: 11px; color: var(--text-light); margin-top: 2px; }
.test-stats { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 6px; padding: 10px 16px; flex-shrink: 0; }
.test-stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 4px; text-align: center; }
.test-stat-card .num { font-size: 18px; font-weight: 700; line-height: 1.3; }
.test-stat-card .num .small { font-size: 10px; font-weight: 400; color: var(--text-dim); }
.test-stat-card .label { font-size: 9px; color: var(--text-dim); font-family: var(--font-sans); margin-top: 1px; }
.test-freeze { display: flex; align-items: center; justify-content: space-between; padding: 6px 16px; flex-shrink: 0; }
.tf-left { font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 4px; }
.tf-right { display: flex; gap: 4px; }
.tf-btn { font-size: 10px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); cursor: pointer; color: var(--text); font-family: var(--font-sans); transition: all 0.15s; }
.tf-btn:hover { border-color: var(--accent); color: var(--accent); }
.test-list { flex: 1; overflow-y: auto; padding: 4px 16px 16px; }
.test-item { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.test-item .t-icon { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.test-item .t-icon.perfect { background: oklch(95% 0.03 145); }
.test-item .t-icon.good { background: oklch(94% 0.03 255); }
.test-item .t-icon.ok { background: oklch(96% 0.04 70); }
.test-item .t-icon.poor { background: oklch(95% 0.03 15); }
.test-item .t-body { flex: 1; min-width: 0; }
.test-item .t-topic { font-size: 13px; font-weight: 600; }
.test-item .t-meta { font-size: 10px; color: var(--text-dim); font-family: var(--font-sans); margin-top: 1px; }
.test-item .t-score { font-size: 16px; font-weight: 700; flex-shrink: 0; }
.test-item .t-score.pass { color: var(--green); }
.test-item .t-score.fail { color: var(--red); }
.test-item .t-diff-badge { font-size: 9px; padding: 1px 5px; border-radius: 3px; font-family: var(--font-sans); flex-shrink: 0; }
.test-item .t-diff-badge.easy { background: oklch(95% 0.03 145); color: oklch(45% 0.06 145); }
.test-item .t-diff-badge.medium { background: oklch(97% 0.04 70); color: oklch(50% 0.08 50); }
.test-item .t-diff-badge.hard { background: oklch(95% 0.03 15); color: oklch(45% 0.08 20); }

/* ===== Quiz Session ===== */
.qs-header { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.qs-back { font-size: 16px; background: none; border: none; cursor: pointer; color: var(--text-dim); padding: 2px 4px; }
.qs-title { font-size: 14px; font-weight: 600; flex: 1; }
.qs-timer { font-size: 14px; font-family: var(--font-sans); font-weight: 600; color: var(--accent); background: var(--accent-bg); padding: 3px 10px; border-radius: 4px; }
.qs-timer.urgent { color: var(--red); background: oklch(95% 0.03 15); animation: timerPulse 1s infinite; }
.qs-progress { display: flex; gap: 4px; padding: 8px 14px; flex-shrink: 0; background: var(--surface); }
.qs-progress .dot { flex: 1; height: 3px; border-radius: 2px; background: var(--border); transition: background 0.3s; }
.qs-progress .dot.done { background: var(--green); }
.qs-progress .dot.current { background: var(--accent); }
.qs-progress .dot.wrong { background: var(--red); }
.qs-body { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; }
.qs-loading { text-align: center; padding: 80px 20px; font-size: 15px; color: var(--text-dim); }
.qs-loading::after { content: ''; display: block; margin: 16px auto 0; width: 24px; height: 24px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
.qs-question { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 14px; margin-bottom: 12px; }
.qs-q-header { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.qs-q-num { width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.qs-q-type { font-size: 10px; color: var(--text-light); font-family: var(--font-sans); background: var(--bg-alt); padding: 1px 6px; border-radius: 3px; }
.qs-q-text { font-size: 14px; line-height: 1.7; margin-bottom: 10px; }
.qs-options { display: flex; flex-direction: column; gap: 6px; }
.qs-option { padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 6px; font-size: 13px; cursor: pointer; transition: all 0.15s; background: var(--bg); line-height: 1.4; }
.qs-option:hover { border-color: var(--accent); }
.qs-option.selected { background: var(--accent-bg); border-color: var(--accent); }
.qs-option.correct { background: oklch(95% 0.03 145); border-color: var(--green); color: oklch(35% 0.06 145); }
.qs-option.wrong { background: oklch(95% 0.03 15); border-color: var(--red); color: oklch(35% 0.08 20); }
.qs-fill-input { width: 100%; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 6px; font-family: var(--font-serif); font-size: 14px; outline: none; background: var(--bg); transition: border-color 0.2s; }
.qs-fill-input:focus { border-color: var(--accent); }
.qs-fill-input.correct { background: oklch(95% 0.03 145); border-color: var(--green); }
.qs-fill-input.wrong { background: oklch(95% 0.03 15); border-color: var(--red); }
.qs-essay-input { width: 100%; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 6px; font-family: var(--font-serif); font-size: 14px; outline: none; background: var(--bg); resize: vertical; min-height: 80px; transition: border-color 0.2s; }
.qs-essay-input:focus { border-color: var(--accent); }
.qs-explanation { margin-top: 8px; padding: 10px; background: var(--surface2); border-radius: 6px; font-size: 12px; line-height: 1.6; color: var(--text-dim); border-left: 3px solid var(--green); }
.qs-explanation.wrong { border-left-color: var(--red); }
.qs-footer { padding: 10px 14px; border-top: 1px solid var(--border); background: var(--surface); flex-shrink: 0; }
.qs-submit-btn { width: 100%; padding: 12px; border: none; border-radius: 8px; font-family: var(--font-sans); font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.15s; background: var(--accent); color: #fff; }
.qs-submit-btn:hover { background: var(--accent-light); }
.qs-submit-btn:disabled { background: var(--border); color: var(--text-light); cursor: default; }
.qs-submit-btn.retry { background: var(--blue); }
.qs-result { text-align: center; padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 12px; }
.qs-result .big-score { font-size: 48px; font-weight: 700; line-height: 1; }
.qs-result .big-score.pass { color: var(--green); }
.qs-result .big-score.fail { color: var(--red); }
.qs-result .detail-row { display: flex; justify-content: center; gap: 20px; margin-top: 10px; font-size: 13px; }
.qs-result .detail-row span { color: var(--text-dim); font-family: var(--font-sans); }
.qs-result .level-up { margin-top: 10px; padding: 8px; background: oklch(96% 0.04 70); border-radius: 6px; font-size: 13px; animation: fadeIn 0.3s; }

/* ===== Diff Buttons ===== */
.diff-btn { flex: 1; padding: 8px 0; border: 1.5px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font-family: var(--font-serif); font-size: 13px; cursor: pointer; transition: all 0.15s; text-align: center; }
.diff-btn:hover { border-color: var(--accent); }
.diff-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 500; }
.diff-btn[data-diff=hard].active { background: oklch(45% 0.16 30); border-color: oklch(45% 0.16 30); }
.diff-btn[data-diff=easy].active { background: var(--green); border-color: var(--green); }

/* ===== Sign-in ===== */
.sign-in-banner { display: flex; align-items: center; justify-content: space-between; margin: 0 16px 6px; padding: 10px 14px; background: linear-gradient(135deg, var(--accent-bg), oklch(97% 0.02 70)); border: 1px solid var(--accent); border-radius: 8px; cursor: pointer; transition: all 0.15s; flex-shrink: 0; }
.sign-in-banner:hover { transform: scale(1.01); }
.sign-in-banner span { font-size: 13px; font-weight: 600; }
.si-bonus { background: var(--accent); color: #fff; padding: 2px 10px; border-radius: 4px; font-size: 11px; font-family: var(--font-sans); }
.sign-in-banner.done { background: var(--bg); border-color: var(--green); opacity: 0.7; cursor: default; transform: none !important; }
.sign-in-banner.done .si-bonus { background: var(--green); }

/* ===== Quests ===== */
.quests-bar { display: flex; gap: 4px; padding: 4px 16px 6px; flex-shrink: 0; overflow-x: auto; }
.quest-item, .quest-all { flex-shrink: 0; font-size: 10px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); white-space: nowrap; font-family: var(--font-sans); }
.quest-item.done { background: oklch(95% 0.03 145); border-color: var(--green); }
.quest-all { background: var(--accent-bg); border-color: var(--accent); font-weight: 500; cursor: pointer; }
.quest-all.claimed { background: var(--bg); border-color: var(--border); opacity: 0.6; cursor: default; }
.q-bonus { font-size: 9px; color: var(--accent); font-weight: 600; }

/* ===== Achievements / KP ===== */
.ach-section { padding: 0 16px 8px; flex-shrink: 0; }
.ach-title { font-size: 11px; color: var(--text-dim); font-family: var(--font-sans); margin-bottom: 4px; }
.ach-grid { display: flex; gap: 4px; flex-wrap: wrap; }
.ach-item { font-size: 10px; padding: 3px 7px; border-radius: 4px; background: var(--surface2); border: 1px solid var(--border); font-family: var(--font-sans); transition: all 0.2s; }
.ach-item.earned { background: oklch(96% 0.04 70); border-color: var(--accent); font-weight: 500; }
.kp-section { padding: 6px 16px 8px; flex-shrink: 0; }
.kp-title { font-size: 11px; color: var(--text-dim); font-family: var(--font-sans); margin-bottom: 6px; }
.kp-grid { display: flex; flex-direction: column; gap: 4px; }
.kp-item { display: flex; align-items: center; gap: 8px; }
.kp-label { font-size: 11px; width: 80px; flex-shrink: 0; color: var(--text); }
.kp-bar-bg { flex: 1; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.kp-bar { height: 100%; border-radius: 3px; transition: width 0.8s ease; }
.kp-bar.high { background: var(--green); }
.kp-bar.mid { background: var(--accent); }
.kp-bar.low { background: var(--red); }
.kp-pct { font-size: 10px; width: 28px; text-align: right; font-family: var(--font-sans); color: var(--text-dim); }

/* ===== Sidebar ===== */
.sidebar-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: oklch(0% 0 0 / 0.35); z-index: 199; display: none; -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.sidebar-overlay.show { display: block; }
.sidebar { position: fixed; top: 0; right: -340px; width: 320px; max-width: 85vw; height: 100%; background: var(--surface); border-left: 1px solid var(--border); transition: right 0.3s cubic-bezier(0.22,1,0.36,1); z-index: 200; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; }
.sidebar.open { right: 0; }
.sidebar-left { left: -340px; right: auto; border-left: none; border-right: 1px solid var(--border); }
.sidebar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.sidebar-header h3 { font-size: 15px; font-weight: 600; }
.sidebar-close { font-size: 20px; cursor: pointer; color: var(--text-dim); background: none; border: none; padding: 4px; line-height: 1; }
.sidebar-section { margin-bottom: 20px; }
.sidebar-section h4 { font-size: 12px; color: var(--text-dim); font-family: var(--font-sans); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.sidebar label { font-size: 11px; color: var(--text-dim); display: block; margin-bottom: 3px; font-family: var(--font-sans); }
.field { margin-bottom: 10px; }
.sidebar input, .sidebar select { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-family: var(--font-serif); font-size: 13px; background: var(--bg); outline: none; }
.sidebar input:focus, .sidebar select:focus { border-color: var(--accent); }
.save-btn { width: 100%; padding: 10px; border: none; border-radius: 6px; background: var(--accent); color: #fff; font-family: var(--font-sans); font-size: 13px; font-weight: 500; cursor: pointer; transition: background 0.15s; }
.save-btn:hover { background: var(--accent-light); }
.profile-display { font-size: 12px; color: var(--text-dim); padding: 10px; background: var(--bg); border-radius: 6px; line-height: 1.6; margin-top: 10px; }
.auto-profile { font-size: 11px; color: var(--text-dim); padding: 0 12px 6px; }

/* ===== Knowledge Tree ===== */
#pageKnowledge { background: var(--surface); }
.knowledge-page-header { border-bottom: 1px solid var(--border); flex-shrink: 0; background: var(--surface); }

/* ===== Onboarding ===== */
.onboarding-overlay { position: fixed; inset: 0; z-index: 1500; background: oklch(0% 0 0 / 0.5); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); display: none; align-items: center; justify-content: center; padding: 20px; animation: fadeIn 0.25s ease; }
.onboarding-overlay.show { display: flex; }
.onboarding-card { background: var(--surface); border-radius: 20px; padding: 36px 32px 28px; max-width: 400px; width: 100%; text-align: center; box-shadow: 0 20px 60px oklch(0% 0 0 / 0.15); animation: slideUp 0.3s ease; position: relative; }
.onboarding-progress { display: flex; gap: 6px; justify-content: center; margin-bottom: 16px; }
.onboarding-progress .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); transition: all 0.3s; }
.onboarding-progress .dot.active { background: var(--accent); transform: scale(1.3); }
.big-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.text-desc { font-size: 14px; color: var(--text-dim); line-height: 1.7; margin-bottom: 16px; }
.btn-primary { width: 100%; padding: 12px; border: none; border-radius: 10px; background: var(--accent); color: #fff; font-family: var(--font-sans); font-size: 15px; font-weight: 600; cursor: pointer; transition: background 0.2s; }
.btn-primary:hover { background: var(--accent-dim); }
.ob-grade-btn { flex: 1; padding: 12px 0; border: 1.5px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); font-family: var(--font-serif); font-size: 15px; font-weight: 500; cursor: pointer; transition: all 0.15s; text-align: center; letter-spacing: 1px; }
.ob-grade-btn:hover { border-color: var(--accent); background: var(--accent-bg); }
.ob-grade-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }

/* ===== Error Book ===== */
.error-item { padding: 10px; background: var(--bg); border-radius: 6px; margin-bottom: 8px; border-left: 3px solid var(--red); font-size: 13px; line-height: 1.6; }
.error-item .q { font-weight: 600; margin-bottom: 4px; }
.error-item .a { color: var(--green); }
.error-item .x { color: var(--red); text-decoration: line-through; }
.error-item .del-btn { float: right; background: none; border: none; color: var(--text-light); cursor: pointer; font-size: 12px; padding: 2px 4px; }
.error-item .del-btn:hover { color: var(--red); }
.report-item { background: var(--bg); border-radius: 6px; padding: 10px; margin-bottom: 6px; font-size: 12px; line-height: 1.6; }
.report-item .act { font-family: var(--font-sans); font-size: 10px; color: var(--text-light); }

/* ===== Markdown ===== */
.bubble strong { font-weight: 600; }
.bubble code { background: var(--surface2); padding: 1px 5px; border-radius: 3px; font-size: 13px; font-family: var(--font-mono); }
.bubble pre { background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; overflow-x: auto; margin: 6px 0; font-size: 13px; line-height: 1.6; }
.bubble pre code { background: none; padding: 0; }
.bubble table { border-collapse: collapse; margin: 6px 0; width: 100%; font-size: 13px; }
.bubble th, .bubble td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.bubble th { background: var(--surface2); font-weight: 600; }
.bubble ul, .bubble ol { padding-left: 20px; margin: 4px 0; }
.bubble li { margin: 2px 0; }
.bubble blockquote { border-left: 3px solid var(--accent); margin: 6px 0; padding: 4px 12px; color: var(--text-dim); background: var(--surface2); border-radius: 0 4px 4px 0; }

/* ===== Celebrations ===== */
.level-up-celebration { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 999; text-align: center; animation: celebrateBounce 1s ease; }
.level-up-celebration .big { font-size: 48px; margin-bottom: 8px; }
.level-up-celebration .text { font-size: 22px; font-weight: 700; color: var(--accent); }
.level-up-celebration .sub { font-size: 13px; color: var(--text-dim); margin-top: 4px; }
.combo-anim { position: fixed; top: 40%; left: 50%; transform: translate(-50%, -50%); z-index: 999; font-size: 28px; font-weight: 800; color: var(--accent-dim); text-align: center; pointer-events: none; white-space: nowrap; text-shadow: 0 2px 8px oklch(0% 0 0 / 0.1); animation: comboAnim 0.8s ease forwards; font-family: var(--font-sans); }
.coin-anim { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 999; font-size: 48px; text-align: center; animation: coinDrop 0.6s ease; pointer-events: none; }
.coin-anim .sub { font-size: 14px; color: var(--accent); font-weight: 600; }
.obq-inline-fill { display: inline; border: none; border-bottom: 2px solid var(--accent); background: transparent; font-family: var(--font-serif); font-size: 14px; color: var(--text); outline: none; width: 120px; padding: 0 2px; margin: 0 2px; transition: border-color 0.2s; line-height: 1.7; vertical-align: baseline; }
.obq-inline-fill:focus { border-bottom-color: var(--accent-dim); }
.obq-inline-fill.correct { border-bottom-color: var(--green); color: var(--green); }
.obq-inline-fill.wrong { border-bottom-color: var(--red); color: var(--red); }

/* ===== Suggestion Grid ===== */
.suggestion-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; animation: fadeIn 0.3s ease; }
.suggestion-btn { padding: 12px 10px; border: 1.5px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font-family: var(--font-serif); font-size: 13px; cursor: pointer; transition: all 0.2s; text-align: center; line-height: 1.4; }
.suggestion-btn:hover { border-color: var(--accent); background: var(--accent-bg); transform: translateY(-2px); }
.suggestion-btn.fade { opacity: 0; transform: translateY(8px); transition: opacity 0.2s, transform 0.2s; pointer-events: none; }

/* ===== Misc ===== */
.img-preview { max-width: 200px; max-height: 200px; border-radius: 8px; border: 1px solid var(--border); }
.report-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--bg); z-index: 300; padding: 20px; overflow-y: auto; display: none; }
.report-modal.show { display: block; }
.report-modal .back-btn { background: none; border: none; color: var(--accent); font-size: 14px; cursor: pointer; font-family: var(--font-sans); margin-bottom: 16px; display: inline-block; }
.comparison-row { margin-top: 8px; font-size: 11px; color: var(--text-dim); display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; background: var(--surface2); border-radius: 6px; padding: 8px 12px; }
.comparison-row strong { color: var(--accent); font-weight: 700; }
.scroll-area { flex: 1; overflow-y: auto; }
.scroll-area-no-pad { flex: 1; overflow-y: auto; }
.auto-weak-btn { display: inline-block; font-size: 10px; padding: 1px 5px; margin: 1px; background: oklch(96% 0.04 70); border: 1px solid oklch(80% 0.06 70); border-radius: 3px; cursor: pointer; }

/* ===== Stage/Dash ===== */
.stage-bar { display: flex; align-items: center; justify-content: space-between; background: linear-gradient(135deg, var(--accent-bg), oklch(97% 0.02 70)); border: 1px solid var(--accent); border-radius: 12px; padding: 10px 14px; margin-bottom: 8px; cursor: pointer; transition: transform 0.15s; }
.stage-bar:hover { transform: scale(1.01); }
.stage-bar span { font-size: 13px; font-weight: 600; }
.stage-btn-sm { padding: 5px 14px; border-radius: 14px; border: none; background: var(--accent); color: #fff; font-size: 11px; font-weight: 600; cursor: pointer; font-family: var(--font-sans); }
.stage-btn-sm:hover { transform: scale(1.05); }

.dash-tabs { display: flex; gap: 4px; margin: 8px 0 10px; }
.dash-tab { flex: 1; padding: 8px 4px; border: 1.5px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text-dim); font-family: var(--font-serif); font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.15s; text-align: center; }
.dash-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.dash-tab:hover:not(.active) { background: var(--bg-alt); }
.dash-panel { padding: 0; }

/* ===== Leaderboard ===== */
.lb-item { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.lb-rank { width: 24px; text-align: center; font-size: 14px; font-weight: 700; flex-shrink: 0; font-family: var(--font-sans); }
.lb-rank.gold { color: oklch(70% 0.12 75); }
.lb-rank.silver { color: oklch(60% 0.02 200); }
.lb-rank.bronze { color: oklch(55% 0.06 50); }
.lb-name { flex: 1; font-size: 13px; font-weight: 600; }
.lb-name.me { color: var(--accent); }
.lb-meta { font-size: 10px; color: var(--text-dim); font-family: var(--font-sans); }
.lb-pts { font-size: 14px; font-weight: 700; color: var(--accent); font-family: var(--font-sans); }
.lb-pts .sm { font-size: 10px; font-weight: 400; color: var(--text-light); }

/* ===== Shop ===== */
.shop-item { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 8px; }
.shop-item .si-name { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.shop-item .si-desc { font-size: 11px; color: var(--text-dim); margin-bottom: 8px; }
.shop-item .si-buy { width: 100%; padding: 8px; border: none; border-radius: 6px; background: var(--accent); color: #fff; cursor: pointer; font-family: var(--font-sans); font-size: 12px; font-weight: 500; transition: background 0.15s; }
.shop-item .si-buy:hover { background: var(--accent-light); }
.shop-item .si-buy:disabled { background: var(--border); color: var(--text-light); cursor: default; }

/* ===== Helpers ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.card-bg { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px 8px; text-align: center; }
.stat-num { font-size: 22px; font-weight: 700; line-height: 1.2; }
.deep-explain-btn { margin-top: 6px; padding: 4px 10px; border: 1px solid var(--accent); border-radius: 4px; background: var(--accent-bg); color: var(--accent); font-size: 11px; cursor: pointer; font-family: var(--font-sans); transition: all 0.15s; }
.deep-explain-btn:hover { background: var(--accent); color: #fff; }
.deep-explain-content { margin-top: 8px; padding: 10px 12px; background: var(--bg); border-radius: 8px; font-size: 13px; line-height: 1.7; white-space: pre-wrap; border: 1px solid var(--accent); }

/* ===== Practice Page ===== */
.practice-header {
  text-align: center;
  padding: 24px 16px 8px;
}
.practice-header h2 {
  font-size: 20px;
  font-weight: 700;
}
.practice-subtitle {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 4px;
  font-family: var(--font-sans);
}

.practice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 12px 16px 24px;
  flex: 1;
  align-content: start;
}

.practice-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 18px 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.practice-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent-bg) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.practice-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px oklch(0% 0 0 / 0.08);
}
.practice-card:hover::before {
  opacity: 1;
}
.practice-card:active {
  transform: scale(0.97);
}

.practice-card .card-icon {
  font-size: 32px;
  margin-bottom: 6px;
  position: relative;
  z-index: 1;
}
.practice-card .card-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
  position: relative;
  z-index: 1;
}
.practice-card .card-desc {
  font-size: 11px;
  color: var(--text-light);
  line-height: 1.4;
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
  font-family: var(--font-sans);
}
.practice-card .card-stats {
  display: flex;
  justify-content: center;
  gap: 8px;
  font-size: 10px;
  color: var(--text-dim);
  font-family: var(--font-sans);
  position: relative;
  z-index: 1;
  flex-wrap: wrap;
}
.practice-card .card-stats span {
  background: var(--surface2);
  padding: 2px 8px;
  border-radius: 4px;
}

/* Dev (coming soon) card states */
.practice-card.dev {
  opacity: 0.75;
}
.practice-card.dev::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 8px,
    oklch(0% 0 0 / 0.02) 8px,
    oklch(0% 0 0 / 0.02) 16px
  );
  pointer-events: none;
}
.practice-card.dev .card-stats span {
  color: var(--text-light);
  background: var(--bg-alt);
}

@media (max-width: 480px) {
  .practice-grid {
    gap: 10px;
    padding: 10px 12px 20px;
  }
  .practice-card {
    padding: 14px 10px;
  }
  .practice-card .card-icon {
    font-size: 28px;
  }
  .practice-card .card-title {
    font-size: 14px;
  }
  .practice-card .card-desc {
    font-size: 10px;
  }
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .header { padding: 6px 12px 4px; gap: 4px; }
  .header-row1, .header-row2 { gap: 6px; }
  .header-name { font-size: 13px; }
  .header-status { font-size: 10px; }
  .header-grade-select, .subject-select { font-size: 11px; padding: 3px 4px; min-width: 60px; }
  .nav-btn { font-size: 12px; padding: 3px 6px; }
  .page-mode-btn { font-size: 11px; padding: 6px 4px; }
  .msg { max-width: 92%; }
  .chat-area { padding: 8px 10px; }
  .msg .bubble { font-size: 14px; padding: 10px 12px; }
  .qs-question { padding: 10px; }
  .qs-body { padding: 8px 10px; }
  .qs-header { padding: 8px 10px; }
  .qs-q-text { font-size: 14px; line-height: 1.6; }
  .qs-footer { padding: 8px 10px; }
  .qs-option { font-size: 13px; padding: 12px 10px; min-height: 44px; display: flex; align-items: center; }
  .qs-timer { font-size: 12px; padding: 2px 8px; }
  .qs-submit-btn { font-size: 13px; padding: 12px 20px; }
  #testSession { border-radius: 0; }
  .sidebar { width: 300px; }
}

/* ===== Utility classes for common inline styles ===== */
.text-center { text-align: center; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mt-6 { margin-top: 6px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.p-16 { padding: 16px; }
.text-xs-light { font-size: 10px; color: var(--text-light); font-family: var(--font-sans); }
.text-sm-dim { font-size: 12px; color: var(--text-dim); }
.text-sm-light { font-size: 12px; color: var(--text-light); }
.text-sm-light-mt6 { font-size: 12px; color: var(--text-light); margin-top: 6px; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.inline-flex-center { display: inline-flex; align-items: center; }
.fw-700 { font-weight: 700; }
.fw-600 { font-weight: 600; }
.fs-24 { font-size: 24px; }
.fs-16 { font-size: 16px; }
.fs-15 { font-size: 15px; }
.fs-14 { font-size: 14px; }
.fs-13 { font-size: 13px; }
.card-s { background: var(--surface2); border-radius: 8px; padding: 12px; margin: 12px 0; font-size: 13px; line-height: 1.6; }
.btn-tertiary { padding: 8px 20px; border: none; border-radius: 6px; background: var(--accent); color: #fff; font-size: 14px; cursor: pointer; }
.btn-tertiary:hover { background: var(--accent-light); }
.w-80-p { width: 80%; max-width: 280px; }

@media (max-width: 400px) {
  .header-grade-select, .subject-select { min-width: 50px; font-size: 10px; padding: 2px; }
  .nav-btn { font-size: 11px; padding: 2px 4px; }
  .header-row1, .header-row2 { gap: 4px; }
  .page-mode-btn { font-size: 11px; padding: 5px 0; }
  .msg .bubble { font-size: 13px; padding: 8px 10px; }
}

/* ===== Landing Demo ===== */
.landing-demo-chat { margin: 0 auto 16px; max-width: 340px; text-align: left; width: 100%; }
.demo-bubble { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; font-size: 13px; line-height: 1.7; margin-bottom: 8px; animation: fadeSlideIn .3s ease-out; white-space: pre-wrap; }
.demo-bubble-ai { background: var(--accent-bg); border-color: var(--accent); }
.demo-bubble-user { background: var(--surface2); border-color: var(--border); text-align: right; }
.demo-bubble span { display: block; }
.landing-demo-btns { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 8px 0; }
.demo-question-btn { padding: 7px 14px; border: 1.5px solid var(--accent); border-radius: 20px; background: var(--bg); color: var(--accent); font-family: var(--font-sans); font-size: 11px; cursor: pointer; transition: all .2s; white-space: nowrap; }
.demo-question-btn:hover { background: var(--accent); color: #fff; }
.demo-question-btn:disabled { opacity: .4; cursor: default; }
.landing-demo-action { text-align: center; margin-top: 10px; }
.landing-btn-primary { background: var(--accent); color: oklch(99% 0 0); border: none; padding: 12px 32px; border-radius: 10px; font-size: 15px; font-weight: 600; cursor: pointer; width: 100%; max-width: 280px; }
.landing-btn-primary:hover { background: var(--accent-dim); }

/* ===== Review Plan ===== */
.review-plan-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 14px; }
.review-plan-card h3 { font-size: 13px; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.review-plan-item { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.review-plan-item:last-child { border-bottom: none; }
.review-plan-item .rp-topic { flex: 1; }
.review-plan-item .rp-count { font-size: 10px; color: var(--red); font-family: var(--font-sans); flex-shrink: 0; }
.review-plan-item .rp-actions { display: flex; gap: 4px; flex-shrink: 0; }
.rp-btn { padding: 3px 8px; border-radius: 4px; font-size: 10px; cursor: pointer; font-family: var(--font-sans); transition: all .15s; }
.rp-btn-review { border: 1px solid var(--accent); background: var(--accent-bg); color: var(--accent); }
.rp-btn-done { border: 1px solid var(--green); background: oklch(95% 0.03 145); color: var(--green); }
.rp-btn:hover { filter: brightness(.9); }

/* Next lesson recommendation */
.next-lesson-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin: 12px 0; }
.next-lesson-card h4 { font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.next-lesson-card p { font-size: 11px; color: var(--text-dim); }
.next-lesson-card .nl-link { color: var(--accent); cursor: pointer; font-weight: 600; }
.next-lesson-card .nl-link:hover { text-decoration: underline; }

/* Animations */
@keyframes fadeSlideIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Scrollable landing content on mobile */
.landing-content.demo-mode { max-height: 90vh; overflow-y: auto; padding: 20px 24px 28px; }

/* ===== Diagnosis ===== */
.diag-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 10px; }
.diag-card h4 { font-size: 13px; font-weight: 600; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.weak-item { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.weak-item:last-child { border-bottom: none; }
.severity-badge { display: inline-block; padding: 2px 7px; border-radius: 4px; font-size: 10px; font-weight: 600; white-space: nowrap; }
.severity-critical { background: oklch(95% 0.05 30); color: oklch(55% 0.18 30); }
.severity-serious { background: oklch(95% 0.04 60); color: oklch(60% 0.12 60); }
.severity-moderate { background: oklch(95% 0.02 80); color: oklch(62% 0.08 80); }
.accuracy-bar { height: 4px; border-radius: 2px; background: var(--border); flex: 1; min-width: 40px; }
.accuracy-bar-fill { height: 100%; border-radius: 2px; }
.diag-action-btn { display: block; width: 100%; padding: 10px; border: 1.5px solid var(--accent); border-radius: 8px; background: var(--accent-bg); color: var(--accent-dim); font-family: var(--font-sans); font-size: 13px; font-weight: 600; cursor: pointer; text-align: center; margin-top: 6px; }
.diag-action-btn:hover { background: var(--accent); color: #fff; }

/* ===== Enhanced Error Book ===== */
.error-group-header { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--bg); border-bottom: 1px solid var(--border); cursor: pointer; font-size: 13px; font-weight: 600; }
.error-group-header:hover { background: var(--accent-bg); }
.error-group-header .badge { margin-left: auto; font-size: 10px; padding: 2px 8px; border-radius: 10px; background: var(--accent-bg); color: var(--accent-dim); }
.error-item-top { padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 12px; line-height: 1.5; }
.error-item-top .q { font-weight: 500; }
.error-item-top .x { color: var(--red); font-size: 11px; margin-top: 3px; }
.error-item-top .a { color: var(--green); font-size: 11px; margin-top: 2px; }
.error-mastered { opacity: 0.5; }
.error-mastered .q::after { content: ' ✅已掌握'; color: var(--green); font-size: 10px; }
.pattern-banner { background: var(--accent-bg); border: 1px solid var(--accent-light); border-radius: 8px; padding: 10px 14px; margin: 6px 12px; font-size: 12px; line-height: 1.5; }
.pattern-banner .label { font-weight: 600; color: var(--accent-dim); }

/* ===== Study Companion ===== */
.study-session-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin: 12px; text-align: center; }
.study-timer { font-size: 48px; font-weight: 700; font-family: var(--font-mono); letter-spacing: 2px; margin: 12px 0; color: var(--accent); }
.study-timer.active { color: var(--green); }
.study-timer.paused { color: var(--orange); }
.study-duration-btns { display: flex; gap: 6px; justify-content: center; margin: 12px 0; }
.study-duration-btn { padding: 6px 14px; border: 1.5px solid var(--border); border-radius: 20px; background: var(--surface); font-family: var(--font-sans); font-size: 12px; cursor: pointer; }
.study-duration-btn:hover, .study-duration-btn.active { border-color: var(--accent); background: var(--accent-bg); color: var(--accent-dim); }
.study-btn { display: inline-block; padding: 10px 24px; border: none; border-radius: 8px; font-family: var(--font-sans); font-size: 14px; font-weight: 600; cursor: pointer; margin: 4px; }
.study-btn-start { background: var(--accent); color: #fff; }
.study-btn-start:hover { background: var(--accent-dim); }
.study-btn-end { background: var(--red); color: #fff; }
.study-btn-end:hover { opacity: 0.8; }
.study-btn-pause { background: var(--orange); color: #fff; }
.study-btn-pause:hover { opacity: 0.8; }
.study-input { width: 100%; padding: 8px 12px; border: 1.5px solid var(--border); border-radius: 8px; font-family: var(--font-sans); font-size: 13px; background: var(--bg); outline: none; box-sizing: border-box; margin-bottom: 8px; }
.study-checkin-banner { background: linear-gradient(135deg, var(--accent-bg), oklch(95% 0.02 70)); border: 1px solid var(--accent-light); border-radius: 10px; padding: 12px 16px; margin: 8px 0; text-align: center; font-size: 13px; line-height: 1.5; }
.study-checkin-banner .emoji { font-size: 24px; margin-bottom: 4px; }
.focus-rating { display: flex; gap: 4px; justify-content: center; margin: 8px 0; }
.focus-star { font-size: 24px; cursor: pointer; opacity: 0.3; }
.focus-star.active, .focus-star:hover { opacity: 1; }
.study-summary { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin: 12px; text-align: center; }
.study-summary .big { font-size: 28px; font-weight: 700; color: var(--accent); }
.study-summary .stat-row { display: flex; justify-content: center; gap: 20px; margin: 10px 0; }
.study-summary .stat-item { text-align: center; }
.study-summary .stat-item .num { font-size: 20px; font-weight: 700; }
.study-summary .stat-item .label { font-size: 10px; color: var(--text-light); }
/* Quiz practice button in chat */
.dark .quiz-practice-btn { border-color: var(--accent); background: var(--surface2); color: var(--accent-light); }
.quiz-practice-btn { padding: 6px 14px; border: 1.5px solid var(--accent); border-radius: 6px; background: var(--accent-bg); color: var(--accent-dim); font-family: var(--font-sans); font-size: 12px; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.quiz-practice-btn:hover { background: var(--accent); color: #fff; }

/* ===== Essay Grading ===== */
#essaySidebar { width: 380px; max-width: 92vw; }
#essaySidebar .p-16 { flex: 1; overflow-y: auto; }
.essay-score-card { animation: fadeIn 0.3s ease; }
.essay-score-card .big-score { font-size: 40px; font-weight: 700; line-height: 1; }
.essay-dimensions { animation: fadeIn 0.35s ease; }
.essay-dimensions .dim-bar { transition: width 0.6s ease; }
#essayResult { animation: fadeIn 0.3s ease; }
#essayResult > div { margin-bottom: 8px; }
#essayHistoryArea { max-height: 400px; overflow-y: auto; }

@media (max-width: 400px) {
  #essaySidebar { width: 100vw; max-width: 100vw; }
}

/* ===== Reading Comprehension ===== */
.reading-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.reading-back-btn {
  background: none;
  border: none;
  font-size: 14px;
  color: var(--accent);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-weight: 500;
}
.reading-back-btn:hover {
  background: var(--accent-bg);
}
.reading-type-tag {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.reading-type-btn {
  padding: 16px 24px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-serif);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
}
.reading-type-btn:hover {
  border-color: var(--accent);
  background: var(--accent-bg);
  transform: translateY(-1px);
}
.reading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: readingSpin 0.8s linear infinite;
}
@keyframes readingSpin {
  to { transform: rotate(360deg); }
}
.reading-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}
.reading-passage-container {
  padding: 20px 16px;
}
.reading-passage-title {
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font-serif);
  text-align: center;
  margin-bottom: 6px;
  color: var(--text);
  line-height: 1.4;
}
.reading-passage-meta {
  font-size: 12px;
  color: var(--text-light);
  text-align: center;
  margin-bottom: 18px;
}
.reading-passage-body {
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.9;
  color: var(--text);
}
.reading-para {
  margin-bottom: 18px;
  display: flex;
  gap: 8px;
}
.reading-para-num {
  display: inline-flex;
  align-items: flex-start;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  border-radius: 50%;
  font-family: var(--font-sans);
  flex-shrink: 0;
  margin-top: 4px;
}
.reading-para-text {
  flex: 1;
  text-indent: 2em;
  text-align: justify;
}
.reading-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  margin: 8px 0 4px;
}
.reading-divider::before,
.reading-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.reading-divider span {
  font-size: 11px;
  color: var(--text-light);
  font-weight: 600;
  letter-spacing: 2px;
  white-space: nowrap;
}
.reading-questions-area {
  padding: 8px 16px 20px;
}
.reading-q-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
  transition: box-shadow 0.2s;
}
.reading-q-card:last-child {
  margin-bottom: 0;
}
.reading-q-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.reading-q-num {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-bg);
  padding: 2px 10px;
  border-radius: 10px;
}
.reading-q-type-label {
  font-size: 10px;
  color: var(--text-light);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 8px;
}
.reading-q-text {
  font-size: 14px;
  line-height: 1.7;
  margin-bottom: 12px;
  color: var(--text);
}
.reading-q-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.reading-q-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg);
}
.reading-q-option:hover {
  border-color: var(--accent);
  background: var(--accent-bg);
}
.reading-q-option.selected {
  border-color: #2ecc71;
  background: #e8f8f0;
}
.reading-q-opt-letter {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
  color: var(--text);
  font-family: var(--font-sans);
}
.reading-q-option.selected .reading-q-opt-letter {
  background: #2ecc71;
  color: #fff;
  border-color: #2ecc71;
}
.reading-q-opt-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
}
.reading-q-fill,
.reading-q-essay {
  margin-top: 4px;
}
.reading-fill-input {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: var(--font-serif);
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}
.reading-fill-input:focus {
  border-color: var(--accent);
}
.reading-essay-input {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: var(--font-serif);
  background: var(--bg);
  color: var(--text);
  outline: none;
  resize: vertical;
  box-sizing: border-box;
  transition: border-color 0.2s;
}
.reading-essay-input:focus {
  border-color: var(--accent);
}
.reading-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* ===== Reading Result ===== */
.reading-result-header {
  padding: 24px 16px 16px;
  text-align: center;
}
.reading-score {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
}
.reading-score-num {
  font-size: 28px;
  color: var(--accent);
}
.reading-score-msg {
  font-size: 13px;
  color: var(--text-light);
}
.reading-result-questions {
  padding: 0 16px;
}
.reading-result-q {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}
.reading-result-q.correct {
  border-left: 4px solid #2ecc71;
}
.reading-result-q.wrong {
  border-left: 4px solid #e74c3c;
}
.reading-result-q-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  margin-bottom: 8px;
}
.reading-result-q-status {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-light);
}
.reading-result-q-text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 8px;
}
.reading-result-answer-line {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 4px;
  line-height: 1.5;
}
.correct-text {
  color: #2ecc71;
  font-weight: 600;
}
.wrong-text {
  color: #e74c3c;
  font-weight: 600;
}
.reading-result-correct-ans {
  color: #2ecc71;
  font-weight: 600;
}
.reading-result-explanation {
  margin-top: 8px;
  padding: 10px;
  background: var(--bg);
  border-radius: 8px;
  border-left: 3px solid var(--accent);
}
.reading-result-explabel {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
  display: block;
}
.reading-result-explanation p {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-dim);
  margin: 0;
}

/* ===== Reading Analysis ===== */
.reading-analysis-section {
  padding: 16px;
  background: var(--bg);
  margin: 8px 16px;
  border-radius: 12px;
}
.reading-analysis-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text);
}
.analysis-card {
  background: var(--surface);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.analysis-card-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.analysis-card-text {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
}
.analysis-para-item {
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.analysis-para-item:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}
.analysis-para-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
}
.analysis-para-content {
  font-size: 12px;
  line-height: 1.7;
  color: var(--text);
  margin-bottom: 4px;
}
.analysis-para-tech {
  font-size: 11px;
  color: #8e44ad;
  padding: 4px 8px;
  background: #f3e8ff;
  border-radius: 6px;
  display: inline-block;
}
.analysis-tech-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.8;
  color: var(--text);
}
.analysis-theme-item {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
}
.analysis-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.reading-kp-tag {
  display: inline-block;
  padding: 6px 12px;
  background: #fef9e7;
  border: 1px solid #f9e79f;
  border-radius: 8px;
  font-size: 12px;
  color: #7d6608;
  font-family: var(--font-serif);
}
.reading-retry-btn {
  padding: 12px 32px;
  border: 2px solid var(--accent);
  border-radius: 10px;
  background: var(--surface);
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  font-family: var(--font-serif);
  transition: all 0.2s;
}
.reading-retry-btn:hover {
  background: var(--accent);
  color: #fff;
}

/* ===== Live2D Character Widget ===== */
.l2d-widget {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 180px;
  height: 280px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  z-index: 100;
  animation: l2dFadeIn 0.3s ease;
}
@keyframes l2dFadeIn {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.l2d-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: linear-gradient(135deg, var(--accent), #764ba2);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  z-index: 2;
  position: relative;
}
.l2d-header .l2d-status {
  font-size: 8px;
}
.l2d-header .l2d-name {
  flex: 1;
  font-family: var(--font-sans);
}
.l2d-header .l2d-close {
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.l2d-header .l2d-close:hover {
  background: rgba(255,255,255,0.35);
}
.l2d-widget canvas {
  width: 100%;
  height: calc(100% - 28px);
  display: block;
}
.l2d-toggle-btn {
  font-size: 16px;
  padding: 4px 6px;
}
.l2d-toggle-btn:hover {
  transform: scale(1.1);
}

/* On small screens, make widget smaller */
@media (max-width: 400px) {
  .l2d-widget {
    width: 130px;
    height: 200px;
    right: 4px;
    bottom: 4px;
  }
}

/* ============================================================
   Compliance: AI Banner, Usage Reminder
   ============================================================ */
.ai-disclosure-banner {
  position: relative;
  z-index: 50;
  animation: slideDown 0.3s ease-out;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

#usageReminderToast {
  animation: fadeIn 0.3s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translate(-50%,-50%) scale(0.9); }
  to { opacity: 1; transform: translate(-50%,-50%) scale(1); }
}
