/* ── SDPal — Tool & Component Styles ── */

/* ═══════════════════════════════════════
   CONTENT INPUT
   ═══════════════════════════════════════ */

.content-input {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.input-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  padding: 32px 20px;
  border: 1.5px dashed var(--border-hover);
  border-radius: var(--r-xl);
  background: var(--bg-card);
  transition: all var(--t);
  min-height: 200px;
}
.input-hero.dragover {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: var(--accent-glow);
}
.input-hero-icon { font-size: 44px; margin-bottom: 14px; }
.input-hero-title { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 4px; }
.input-hero-sub { font-size: 13px; color: var(--text-2); margin-bottom: 22px; max-width: 260px; line-height: 1.5; }
.input-hero-buttons { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 240px; }
.input-hero-btn {
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  font-size: 13px;
  width: 100%;
  border-radius: var(--r-full) !important;
}

.input-editor {
  display: flex;
  flex-direction: column;
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--bg-card);
  min-height: 0;
}
.input-editor-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-subtle);
}
.input-editor-chars { font-size: 11px; color: var(--text-3); font-weight: 500; }
.input-editor-textarea {
  flex: 1;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  min-height: 120px;
  resize: none;
  line-height: 1.7;
  font-size: 14px;
  padding: 14px 18px;
}
.input-editor-textarea:focus { box-shadow: none !important; }

.input-editor-previews { padding: 0 14px 10px; display: flex; flex-direction: column; gap: 4px; }
.input-editor-previews:empty { display: none; padding: 0; }

.input-file-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: var(--bg-input);
  border-radius: var(--r-sm);
  font-size: 12px;
}
.input-file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.input-file-status { font-size: 11px; color: var(--text-3); flex-shrink: 0; }


/* ═══════════════════════════════════════
   AI OUTPUT / READER
   ═══════════════════════════════════════ */

.ai-reader {
  flex: 1;
  overflow-y: auto;
  padding: 28px 4px;
  line-height: 1.85;
  font-size: 15px;
  overflow-wrap: break-word;
}
.ai-reader h1, .ai-reader h2, .ai-reader h3 { margin-top: 20px; margin-bottom: 8px; font-weight: 700; letter-spacing: -0.02em; color: var(--text-1); }
.ai-reader h1 { font-size: 20px; }
.ai-reader h2 { font-size: 17px; }
.ai-reader h3 { font-size: 15px; color: var(--accent); }
.ai-reader p { margin-bottom: 10px; }
.ai-reader ul, .ai-reader ol { padding-left: 20px; margin-bottom: 10px; }
.ai-reader li { margin-bottom: 5px; line-height: 1.7; }
.ai-reader li::marker { color: var(--text-3); }
.ai-reader code { background: rgba(255,255,255,0.06); padding: 2px 7px; border-radius: 5px; font-family: var(--font-mono); font-size: 0.88em; color: var(--accent); }
.ai-reader pre { background: var(--bg-elevated); border: 1px solid var(--border-subtle); border-radius: var(--r-md); padding: 14px; overflow-x: auto; margin-bottom: 14px; }
.ai-reader pre code { background: none; padding: 0; color: var(--text-2); }
.ai-reader strong { font-weight: 700; color: var(--text-1); }
.ai-reader em { color: var(--text-2); font-style: italic; }
.ai-reader blockquote {
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  margin: 12px 0;
  background: rgba(34,197,94,0.04);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  color: var(--text-2);
  font-size: 0.95em;
}
.ai-reader blockquote strong { color: var(--accent); }
.ai-reader hr { border: none; border-top: 1px solid var(--border-subtle); margin: 16px 0; }

/* Tables */
.ai-reader table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  overflow: hidden;
}
.ai-reader thead { background: rgba(255,255,255,0.04); }
.ai-reader th {
  padding: 8px 12px;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-2);
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}
.ai-reader td {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  color: var(--text-2);
  line-height: 1.5;
}
.ai-reader tr:last-child td { border-bottom: none; }
.ai-reader tr:hover td { background: rgba(255,255,255,0.02); }

/* KaTeX math rendering */
.ai-reader .katex-display { margin: 16px 0; overflow-x: auto; overflow-y: hidden; padding: 12px 0; }
.ai-reader .katex { font-size: 1.1em; }
.katex-error { color: var(--danger); font-size: 13px; background: var(--danger-dim); padding: 2px 6px; border-radius: 3px; }
.katex-display { text-align: center; margin: 14px 0; }

/* Reader panel math */
.ws-page-text .katex-display { margin: 12px 0; overflow-x: auto; }
.ws-page-text .katex { font-size: 1.05em; }

.ai-cursor::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 17px;
  background: var(--accent);
  border-radius: 1px;
  margin-left: 2px;
  animation: cursorBlink 0.9s step-end infinite;
  vertical-align: text-bottom;
}
@keyframes cursorBlink { 50% { opacity: 0; } }

.output-actions {
  display: flex;
  gap: 8px;
  padding: 14px 4px;
  border-top: 1px solid var(--border-subtle);
}
.output-actions .btn { flex: 1; }


/* ═══════════════════════════════════════
   MODE SWITCHER
   ═══════════════════════════════════════ */

.mode-switcher {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  padding: 3px;
  gap: 2px;
  max-width: 420px;
  margin: 0 auto 16px;
}
.mode-switcher button {
  flex: 1;
  padding: 8px 12px;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--text-2);
  transition: all var(--t);
}
.mode-switcher button.active {
  background: var(--accent);
  color: var(--text-inv);
  box-shadow: var(--accent-glow-sm);
}


/* ═══════════════════════════════════════
   QUIZ
   ═══════════════════════════════════════ */

.quiz-progress-bar {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 6px;
}
.quiz-progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.35s var(--ease);
}
.quiz-progress-text {
  font-size: 12px;
  color: var(--text-3);
  text-align: right;
  margin-bottom: 20px;
  font-weight: 500;
}

.quiz-q-text {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.55;
  letter-spacing: -0.02em;
  padding: 4px 0 28px;
}

/* ═══════════════════════════════════════
   PALVIZ PLAYER
   ═══════════════════════════════════════ */
/* PalViz in-chat loading */
.pv-loading-wrap { margin: 12px 0; }
.pv-loading-card {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px; border-radius: 12px;
  background: linear-gradient(135deg, rgba(26,26,46,0.9), rgba(30,30,50,0.9));
  border: 1px solid rgba(88,196,221,0.15);
  box-shadow: 0 0 20px rgba(88,196,221,0.05);
}
.pv-loading-spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid var(--border); border-top-color: var(--accent);
  animation: pvSpin 0.8s linear infinite; flex-shrink: 0;
}
@keyframes pvSpin { to { transform: rotate(360deg); } }
.pv-loading-text { font-size: 13px; color: var(--text-3); font-weight: 600; }
.pv-rendered-wrap { margin: 12px 0; border-radius: 12px; overflow: hidden; max-width: 520px; }
.pv-error {
  padding: 16px; text-align: center;
  font-size: 13px; color: var(--text-3);
  background: var(--bg-2); border-radius: 12px;
  border: 1px solid var(--border-subtle);
}

/* PalViz v2 player */
.pv-player {
  display: flex; flex-direction: column;
  border-radius: 12px; overflow: hidden;
  background: #1a1a2e;
  border: 1px solid rgba(88,196,221,0.12);
  box-shadow: 0 4px 24px rgba(0,0,0,0.3), 0 0 1px rgba(88,196,221,0.1);
}
.pv-stage { position: relative; width: 100%; line-height: 0; }
.pv-svg { width: 100%; height: auto; display: block; max-height: 400px; }
.pv-narration {
  padding: 14px 18px; min-height: 44px;
  font-size: 14px; color: #fff; font-weight: 500;
  background: rgba(0,0,0,0.5); text-align: center;
  line-height: 1.6; display: flex; align-items: center; justify-content: center;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.pv-narration .katex { font-size: 0.95em; }
.pv-narration-text { max-width: 100%; }
.pv-sliders {
  padding: 8px 14px; background: rgba(0,0,0,0.25);
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex; flex-wrap: wrap; gap: 6px 16px;
}
.pv-slider-row {
  display: flex; align-items: center; gap: 8px; min-width: 180px; flex: 1;
}
.pv-slider-label {
  font-size: 12px; color: #9cdceb; font-weight: 600; white-space: nowrap; min-width: 60px;
}
.pv-slider-val { color: #ffff00; font-family: monospace; }
.pv-slider {
  flex: 1; height: 4px; -webkit-appearance: none; appearance: none;
  background: rgba(255,255,255,0.15); border-radius: 2px; outline: none; cursor: pointer;
}
.pv-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: #58c4dd; border: 2px solid #1a1a2e; cursor: grab;
}
.pv-slider::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: #58c4dd; border: 2px solid #1a1a2e; cursor: grab;
}
.pv-debug-btn {
  position: absolute; top: 6px; right: 6px; z-index: 10;
  background: rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.4); font-size: 10px; padding: 3px 8px;
  border-radius: 4px; cursor: pointer; opacity: 0; transition: opacity 0.2s;
}
.pv-rendered-wrap { position: relative; }
.pv-rendered-wrap:hover .pv-debug-btn { opacity: 1; }
.pv-debug-btn:hover { color: #fff; background: rgba(0,0,0,0.7); }
.pv-controls {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: rgba(0,0,0,0.4);
}
.pv-controls-left { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.pv-controls-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.pv-btn {
  width: 30px; height: 30px; border-radius: 50%;
  border: none; background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.7);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; flex-shrink: 0; padding: 0;
}
.pv-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }
.pv-btn.pv-play {
  width: 34px; height: 34px; background: var(--accent); color: #fff;
}
.pv-btn.pv-play:hover { opacity: 0.9; transform: scale(1.05); }
.pv-dots {
  flex: 1; display: flex; align-items: center; justify-content: center;
  gap: 6px; flex-wrap: wrap; padding: 0 8px;
}
.pv-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(255,255,255,0.2); border: none;
  cursor: pointer; transition: all 0.2s; padding: 0;
}
.pv-dot:hover { background: rgba(255,255,255,0.4); }
.pv-dot.active { background: var(--accent); transform: scale(1.3); }
.pv-dot.completed { background: rgba(255,255,255,0.5); }
.pv-step-counter {
  font-size: 11px; color: rgba(255,255,255,0.4);
  font-variant-numeric: tabular-nums; min-width: 28px; text-align: center;
}

/* PalViz animation classes */
.pv-el { transition: opacity 0.4s cubic-bezier(0.65, 0, 0.35, 1); }
@keyframes pvPulse {
  0%, 100% { filter: brightness(1) drop-shadow(0 0 0 transparent); }
  50% { filter: brightness(1.6) drop-shadow(0 0 8px rgba(88,196,221,0.5)); }
}
.pv-pulse { animation: pvPulse 0.8s cubic-bezier(0.65, 0, 0.35, 1); }

/* Smooth transition base for all PalViz elements */
.pv-el { will-change: opacity, transform; }

/* Fullscreen mode */
.pv-player.pv-fullscreen-active {
  position: fixed !important; inset: 0 !important;
  width: 100vw !important; height: 100vh !important;
  z-index: 99999; border-radius: 0 !important; max-width: none !important;
  margin: 0 !important; display: flex !important; flex-direction: column;
  background: #0d0d1a;
}
.pv-player.pv-fullscreen-active .pv-stage {
  flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.pv-player.pv-fullscreen-active .pv-svg { max-width: 100%; max-height: 100%; width: auto; height: auto; }
.pv-player.pv-fullscreen-active .pv-narration { flex-shrink: 0; font-size: 17px; padding: 16px 32px; min-height: 52px; }
.pv-player.pv-fullscreen-active .pv-controls { flex-shrink: 0; padding: 12px 24px; position: relative; z-index: 10; }
.pv-player.pv-fullscreen-active .pv-btn { width: 36px; height: 36px; }
.pv-player.pv-fullscreen-active .pv-btn.pv-play { width: 44px; height: 44px; }
.pv-player.pv-fullscreen-active .pv-dot { width: 10px; height: 10px; }

/* Tooltip */
.pv-tooltip {
  position: absolute; z-index: 10;
  padding: 4px 10px; border-radius: 6px;
  background: rgba(0,0,0,0.85); color: #fff;
  font-size: 12px; font-family: 'Outfit',system-ui,sans-serif;
  pointer-events: none; white-space: nowrap;
  border: 1px solid rgba(88,196,221,0.2);
  backdrop-filter: blur(4px);
}

/* ── Quiz: Clean Redesign ── */

/* Top bar */
.qz-topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0 16px; flex-shrink: 0;
}
.qz-progress {
  flex: 1; height: 4px; background: var(--border);
  border-radius: 2px; overflow: hidden;
}
.qz-progress-fill {
  height: 100%; background: var(--accent); border-radius: 2px;
  transition: width 0.4s ease;
}
.qz-count { font-size: 12px; font-weight: 700; color: var(--text-3); white-space: nowrap; }
.qz-streak {
  font-size: 11px; font-weight: 800; color: #f59e0b;
  background: rgba(245,158,11,0.1); padding: 2px 8px;
  border-radius: var(--r-full); white-space: nowrap;
  animation: streakPop 0.3s ease;
}
@keyframes streakPop { 0% { transform: scale(0); } 60% { transform: scale(1.2); } 100% { transform: scale(1); } }

/* Question body */
.qz-body { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }
.qz-question {
  font-size: 18px; font-weight: 700; line-height: 1.6;
  letter-spacing: -0.02em; padding-bottom: 20px;
  color: var(--text-1);
}
.qz-question p { margin: 0 0 8px; }

/* Hint */
.qz-hint {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 12px; border-radius: var(--r-full);
  border: 1px solid var(--border); background: var(--bg-2);
  color: var(--text-3); font-size: 12px; font-weight: 600;
  font-family: inherit; cursor: pointer; transition: all var(--t);
  margin-bottom: 14px; align-self: flex-start;
}
.qz-hint:hover { border-color: var(--accent-mid); color: var(--accent); }
.qz-hint.revealed { border-color: var(--accent-mid); color: var(--accent); background: var(--accent-dim); cursor: default; }

/* Options */
.qz-opts { display: flex; flex-direction: column; gap: 8px; }
.qz-opt {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  cursor: pointer; transition: all 0.15s;
  font-size: 15px; line-height: 1.5;
  background: var(--bg-card);
  -webkit-tap-highlight-color: transparent;
  min-height: 50px;
}
.qz-opt:hover { border-color: var(--border-hover); background: var(--bg-card-hover); }
.qz-opt:active { transform: scale(0.98); }
.qz-opt .qz-opt-letter {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; flex-shrink: 0;
  transition: all 0.2s;
  color: var(--text-3);
}
.qz-opt .qz-opt-text { flex: 1; min-width: 0; }

/* Correct/Wrong states */
.qz-opt.correct {
  border-color: #22c55e; background: rgba(34,197,94,0.08);
}
.qz-opt.correct .qz-opt-letter {
  background: #22c55e; color: #fff; border-color: #22c55e;
}
.qz-opt.wrong {
  border-color: #ef4444; background: rgba(239,68,68,0.06);
}
.qz-opt.wrong .qz-opt-letter {
  background: #ef4444; color: #fff; border-color: #ef4444;
}

/* Question nav dots — bottom row */
.qz-dots {
  display: flex; gap: 4px; justify-content: center; flex-wrap: wrap;
  padding: 8px 0; flex-shrink: 0; margin-top: auto;
}
.qz-dot {
  width: 28px; height: 28px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700;
  border: 1.5px solid var(--border); color: var(--text-3);
  background: transparent; transition: all 0.15s;
}
.qz-dot.current { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.qz-dot.answered-correct { border-color: #22c55e; background: rgba(34,197,94,0.15); color: #22c55e; }
.qz-dot.answered-wrong { border-color: #ef4444; background: rgba(239,68,68,0.1); color: #ef4444; }

/* Feedback banner — fixed to bottom of screen */
.qz-feedback {
  position: fixed; bottom: 0; left: 0; right: 0;
  padding: 16px 20px; padding-bottom: calc(16px + env(safe-area-inset-bottom, 0));
  border-radius: 16px 16px 0 0;
  transform: translateY(100%);
  transition: transform 0.25s ease-out;
  z-index: 100;
}
.qz-feedback.visible { transform: translateY(0); }
.qz-feedback-correct { background: #0f3d1c; border-top: 2px solid #22c55e; }
.qz-feedback-wrong { background: #3d1519; border-top: 2px solid #ef4444; }

.qz-feedback-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.qz-feedback-icon { font-size: 18px; font-weight: 800; }
.qz-feedback-correct .qz-feedback-icon { color: #22c55e; }
.qz-feedback-wrong .qz-feedback-icon { color: #ef4444; }
.qz-feedback-title { font-size: 16px; font-weight: 800; color: #fff; }
.qz-streak-badge {
  font-size: 11px; font-weight: 700; color: #f59e0b;
  background: rgba(245,158,11,0.15); padding: 2px 8px;
  border-radius: var(--r-full); margin-left: auto;
}
.qz-feedback-answer { font-size: 13px; color: rgba(255,255,255,0.7); margin-bottom: 6px; }
.qz-feedback-exp { font-size: 13px; color: rgba(255,255,255,0.6); line-height: 1.5; margin-bottom: 12px; max-height: 80px; overflow-y: auto; }
.qz-feedback-next {
  width: 100%; padding: 12px; border: none;
  border-radius: 10px; font-size: 15px; font-weight: 700;
  font-family: inherit; cursor: pointer; transition: all 0.15s;
}
.qz-feedback-correct .qz-feedback-next { background: #22c55e; color: #fff; }
.qz-feedback-wrong .qz-feedback-next { background: #ef4444; color: #fff; }
.qz-feedback-next:active { transform: scale(0.98); opacity: 0.9; }

/* Keep old class names working for results/review */
.quiz-options { display: flex; flex-direction: column; gap: 8px; }
.quiz-opt { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: 10px; font-size: 14px; background: var(--bg-card); }
.quiz-opt-badge { width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }

.quiz-results { text-align: center; padding: 36px 0; }
.quiz-score-ring { width: 150px; height: 150px; margin: 0 auto 24px; position: relative; }
.quiz-score-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.quiz-score-ring .ring-bg { fill: none; stroke: var(--border); stroke-width: 7; }
.quiz-score-ring .ring-fill { fill: none; stroke: var(--accent); stroke-width: 7; stroke-linecap: round; transition: stroke-dashoffset 1.5s var(--ease); filter: drop-shadow(0 0 8px rgba(34,197,94,0.3)); }
.quiz-score-num { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); font-size: 34px; font-weight: 800; letter-spacing: -0.03em; }

.quiz-dots { display: flex; gap: 6px; justify-content: center; margin: 18px 0; flex-wrap: wrap; }
.quiz-dot { width: 10px; height: 10px; border-radius: 50%; transition: all var(--t); }
.quiz-dot.correct { background: var(--accent); box-shadow: 0 0 6px rgba(34,197,94,0.3); }
.quiz-dot.wrong { background: var(--danger); }
.quiz-dot.skipped { background: var(--border); }

.quiz-review-card {
  text-align: left;
  padding: 16px 18px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  margin-bottom: 10px;
  background: var(--bg-card);
}
.quiz-review-card.is-correct { border-left: 4px solid var(--accent); }
.quiz-review-card.is-wrong { border-left: 4px solid var(--danger); }
.quiz-review-q { font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.quiz-review-explain { font-size: 13px; color: var(--text-2); margin-top: 10px; padding: 12px; background: var(--bg-input); border-radius: var(--r-sm); line-height: 1.65; }


/* ═══════════════════════════════════════
   FLASHCARDS
   ═══════════════════════════════════════ */

.fc-viewport {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  touch-action: pan-y;
  max-width: 100% !important;
}

.fc-card {
  width: calc(100% - 40px);
  max-width: 440px;
  aspect-ratio: 4/3;
  max-height: 55vh;
  perspective: 1200px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.3s var(--ease);
}
.fc-card.swipe-left { transform: translateX(-120%) rotate(-12deg); opacity: 0; transition: all 0.4s var(--ease); }
.fc-card.swipe-right { transform: translateX(120%) rotate(12deg); opacity: 0; transition: all 0.4s var(--ease); }

.fc-inner {
  width: 100%; height: 100%;
  position: relative;
  transition: transform 0.5s var(--ease);
  transform-style: preserve-3d;
}
.fc-inner.flipped { transform: rotateY(180deg); }

.fc-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px;
  text-align: center;
  overflow-y: auto;
  background: var(--bg-card);
}
.fc-front { background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-secondary)); }
.fc-back { background: linear-gradient(135deg, var(--bg-elevated), var(--bg-tertiary)); transform: rotateY(180deg); }

.fc-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-3); margin-bottom: 14px; }
.fc-text-front { font-size: 20px; font-weight: 700; line-height: 1.5; letter-spacing: -0.02em; }
.fc-text-back { font-size: 15px; line-height: 1.7; color: var(--text-2); }
.fc-hint { font-size: 12px; color: var(--text-3); text-align: center; }

.fc-counter { font-size: 14px; font-weight: 600; color: var(--text-2); text-align: center; margin-bottom: 6px; }
.fc-progress-bar { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; margin-bottom: 16px; }
.fc-progress-fill { height: 100%; background: var(--accent); transition: width 0.35s var(--ease); }

.fc-actions { display: flex; gap: 28px; justify-content: center; padding: 14px 0; }
.fc-action-btn {
  width: 52px; height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  transition: all var(--t-spring);
}
.fc-action-btn:active { transform: scale(0.88); }
.fc-btn-no { border: 2px solid var(--danger); color: var(--danger); }
.fc-btn-no:hover { background: var(--danger-dim); }
.fc-btn-yes { border: 2px solid var(--accent); color: var(--accent); }
.fc-btn-yes:hover { background: var(--accent-dim); box-shadow: var(--accent-glow-sm); }

.fc-summary-grid { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin: 16px 0; }
.fc-summary-sq {
  width: 34px; height: 34px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--t);
}
.fc-summary-sq.known { background: var(--accent-dim); color: var(--accent); border: 1px solid var(--accent-mid); }
.fc-summary-sq.missed { background: var(--danger-dim); color: var(--danger); border: 1px solid var(--danger-border); }

.fc-flash { position: absolute; inset: 0; opacity: 0; animation: fcFlash 0.4s ease-out; pointer-events: none; border-radius: var(--r-xl); }
.fc-flash-green { background: rgba(34,197,94,0.15); }
.fc-flash-red { background: rgba(244,63,94,0.15); }
@keyframes fcFlash { 0% { opacity: 0.8; } 100% { opacity: 0; } }

.fc-summary { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; gap: 6px; text-align: center; padding: 24px; max-width: 100% !important; }
.fc-summary-emoji { font-size: 48px; margin-bottom: 8px; }
.fc-summary-score { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.fc-summary-pct { font-size: 14px; color: var(--text-2); }
.fc-summary-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; justify-content: center; }


/* ═══════════════════════════════════════
   CHAT
   ═══════════════════════════════════════ */

.chat-wrap {
  display: flex;
  height: 100%;
  width: 100%;
  position: relative;
  overflow: hidden;
}
.chat-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  height: 100%;
}

/* Chat sidebar */
.chat-sidebar {
  width: 280px;
  background: var(--bg-1);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transform: translateX(-100%);
  position: absolute;
  top: 0; left: 0; bottom: 0;
  z-index: 10;
  transition: transform 0.25s var(--ease);
}
.chat-sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,0.3); }
@media (min-width: 1080px) {
  .chat-sidebar.open { position: static; transform: none; box-shadow: none; }
}
.chat-sb-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border-subtle); flex-shrink: 0;
}
.chat-sb-close {
  width: 28px; height: 28px; border: none; background: none;
  color: var(--text-3); font-size: 18px; cursor: pointer; border-radius: var(--r-sm);
}
.chat-sb-close:hover { background: rgba(255,255,255,0.05); }
.chat-sb-list { flex: 1; overflow-y: auto; padding: 8px; }
.chat-sb-item {
  padding: 10px 12px; border-radius: var(--r-md);
  cursor: pointer; transition: background 0.15s; margin-bottom: 2px;
}
.chat-sb-item:hover { background: rgba(255,255,255,0.04); }
.chat-sb-item.active { background: var(--accent-dim); border: 1px solid var(--accent-mid); }
.chat-sb-item-title {
  font-size: 13px; font-weight: 600; color: var(--text-1);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-sb-item-meta { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* Chat toolbar (replaces header) */
.chat-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.chat-tb-btn {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2); transition: all var(--t); cursor: pointer;
  border: none; background: none; flex-shrink: 0;
}
.chat-tb-btn:hover { background: rgba(255,255,255,0.05); color: var(--text-1); }
.chat-tb-btn svg { width: 18px; height: 18px; }

/* Quiz/Flashcard home cards */
.qz-home-card {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--r-md);
  cursor: pointer; transition: all 0.15s; font-family: inherit; color: var(--text-1);
  text-align: left; width: 100%;
}
.qz-home-card:hover { border-color: var(--border-hover); background: var(--bg-card-hover); transform: translateY(-1px); }
.qz-home-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: rgba(34,197,94,0.1); color: var(--accent);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  font-weight: 700;
}
.qz-home-info { flex: 1; min-width: 0; }
.qz-home-label { font-size: 14px; font-weight: 600; }
.qz-home-desc { font-size: 11px; color: var(--text-3); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Question count selector */
.qz-count-btn {
  width: 44px; height: 36px; border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--bg-2);
  color: var(--text-3); font-size: 13px; font-weight: 700;
  font-family: inherit; cursor: pointer; transition: all var(--t);
}
.qz-count-btn:hover { border-color: var(--accent-mid); color: var(--accent); }
.qz-count-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Flashcard confidence rating */
.fc-confidence { padding: 8px 16px; flex-shrink: 0; }
.fc-conf-btns { display: flex; gap: 6px; justify-content: center; }
.fc-conf-btn {
  flex: 1; max-width: 70px; padding: 8px 4px;
  border-radius: var(--r-md); border: 2px solid var(--cc, var(--border));
  background: transparent; color: var(--cc, var(--text-2));
  font-size: 16px; font-weight: 800; font-family: inherit;
  cursor: pointer; transition: all 0.15s;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.fc-conf-btn span { font-size: 9px; font-weight: 600; opacity: 0.7; }
.fc-conf-btn:hover { background: color-mix(in srgb, var(--cc) 15%, transparent); }
.fc-conf-btn:active { transform: scale(0.95); }

/* Match game tiles */
.fc-match-tile {
  padding: 12px 8px; border-radius: var(--r-md);
  border: 1.5px solid var(--border); background: var(--bg-card);
  color: var(--text-1); font-size: 12px; font-family: inherit;
  cursor: pointer; transition: all 0.15s; text-align: center;
  min-height: 60px; display: flex; align-items: center; justify-content: center;
}
.fc-match-tile:hover { border-color: var(--border-hover); }
.fc-match-tile.selected { border-color: var(--accent); background: var(--accent-dim); box-shadow: 0 0 8px rgba(34,197,94,0.2); }
.fc-match-tile.matched { border-color: var(--accent); background: rgba(34,197,94,0.15); opacity: 0.5; cursor: default; pointer-events: none; }
.fc-match-tile.wrong { border-color: var(--danger); background: rgba(239,68,68,0.1); animation: shake 0.3s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.fc-match-tile span { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }

/* chat-header removed — using chat-toolbar now */

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 24px;
  width: 100%;
}

.chat-msg { display: flex; gap: 10px; animation: pageIn 0.2s var(--ease); }
.chat-msg.user { align-self: flex-end; flex-direction: row-reverse; max-width: 75%; }
.chat-msg.bot { align-self: flex-start; max-width: 90%; }

.chat-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-msg.bot .chat-avatar { background: var(--accent-dim); color: var(--accent); }

.chat-bot-col { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.chat-bot-label { font-size: 10px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.5px; }

.chat-bubble {
  padding: 12px 16px;
  border-radius: var(--r-lg);
  font-size: 14px;
  line-height: 1.7;
  overflow-wrap: break-word;
}
.chat-bubble-img { padding: 4px; background: transparent; border: none; }
.chat-bubble-img img { border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
.chat-msg.user .chat-bubble {
  background: var(--accent);
  color: var(--text-inv);
  border-bottom-right-radius: 4px;
  box-shadow: var(--accent-glow-sm);
}
.chat-msg.bot .chat-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-bottom-left-radius: 4px;
}
.chat-msg.bot .chat-bubble h3 { font-size: 14px; color: var(--accent); margin-top: 12px; }
.chat-msg.bot .chat-bubble h3:first-child { margin-top: 0; }
.chat-msg.bot .chat-bubble p { margin-bottom: 8px; }
.chat-msg.bot .chat-bubble p:last-child { margin-bottom: 0; }
.chat-msg.bot .chat-bubble ul, .chat-msg.bot .chat-bubble ol { margin-bottom: 8px; padding-left: 18px; }
.chat-msg.bot .chat-bubble li { margin-bottom: 3px; font-size: 14px; }
.chat-msg.bot .chat-bubble table { font-size: 12px; margin: 8px 0; }
.chat-msg.bot .chat-bubble th { font-size: 10px; padding: 6px 8px; }
.chat-msg.bot .chat-bubble td { padding: 6px 8px; }
.chat-msg.bot .chat-bubble blockquote { font-size: 13px; padding: 8px 10px; margin: 8px 0; }
.chat-msg.bot .chat-bubble code { font-size: 12px; }
.chat-msg.bot .chat-bubble hr { margin: 10px 0; }
.chat-msg.bot .chat-bubble strong { color: var(--text-1); }

/* Quick actions row (above input bar) */
.chat-quick-row {
  display: flex; gap: 6px; padding: 0 18px;
  flex-shrink: 0; flex-wrap: wrap;
  min-height: 0;
}
.chat-quick-row:empty { padding: 0; }
.chat-qbtn {
  padding: 5px 12px; border-radius: 6px;
  border: 1px solid var(--border-subtle); background: var(--bg-2);
  color: var(--text-3); font-size: 11px; font-weight: 600;
  font-family: inherit; cursor: pointer; transition: all var(--t);
  white-space: nowrap;
}
.chat-qbtn:hover { border-color: var(--accent-mid); color: var(--accent); background: var(--accent-dim); }
.chat-qbtn-esc { border-color: var(--accent-mid); color: var(--accent); background: var(--accent-dim); }
.chat-qbtn-tool { border-style: dashed; }
.chat-qbtn-tool:hover { border-style: solid; }

/* Pin removed */

/* Inline quiz cards */
.chat-quiz-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 12px; margin: 10px 0;
}
.chat-quiz-q { font-weight: 600; font-size: 14px; margin-bottom: 10px; line-height: 1.5; }
.chat-quiz-opt {
  display: block; width: 100%; text-align: left;
  padding: 10px 14px; margin-bottom: 6px;
  border: 1.5px solid var(--border); border-radius: var(--r-md);
  background: var(--bg-card); color: var(--text-1);
  font-size: 13px; font-family: inherit; cursor: pointer; transition: all 0.15s;
}
.chat-quiz-opt:hover { border-color: var(--accent-mid); background: var(--accent-dim); }
.chat-quiz-card.answered .chat-quiz-opt { cursor: default; opacity: 0.5; }
.chat-quiz-card.answered .chat-quiz-opt:hover { border-color: var(--border); background: var(--bg-card); }
.chat-quiz-opt.correct { border-color: #22c55e; background: rgba(34,197,94,0.1); opacity: 1; color: #22c55e; font-weight: 600; }
.chat-quiz-opt.wrong { border-color: #ef4444; background: rgba(239,68,68,0.08); opacity: 1; color: #ef4444; }
.chat-quiz-opt.selected { border-color: var(--accent); background: var(--accent-dim); opacity: 1; }

/* Camera button */
.chat-camera-btn {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent); border: 1px solid var(--accent-mid);
  background: var(--accent-dim); flex-shrink: 0; cursor: pointer; transition: all var(--t);
}
.chat-camera-btn:hover { background: var(--accent); color: #fff; }
.chat-camera-btn svg { width: 16px; height: 16px; }

/* Context toggle (inline in toolbar) */
.chat-context-toggle {
  display: flex; align-items: center; gap: 6px;
  flex: 1; min-width: 0; font-size: 12px;
}
.chat-context-label { font-weight: 600; color: var(--text-3); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-context-btn {
  padding: 4px 10px; border-radius: var(--r-full);
  border: 1px solid var(--border); background: var(--bg-2);
  color: var(--text-2); font-size: 11px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: all var(--t); white-space: nowrap;
}
.chat-context-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Ask PalAI button in selection toolbar */
.ws-sel-btn-ask { color: var(--accent); font-weight: 700; }

/* Step-by-step toggle */
.ws-chat-step-toggle {
  padding: 6px 10px; border-radius: var(--r-full);
  border: 1px solid var(--border); background: var(--bg-2);
  color: var(--text-3); font-size: 10px; font-weight: 600;
  cursor: pointer; font-family: inherit; flex-shrink: 0;
  transition: all var(--t); white-space: nowrap;
}
.ws-chat-step-toggle.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.chat-typing-dots { display: flex; gap: 5px; padding: 4px 0; }
.chat-typing-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); animation: chatBounce 1.2s infinite; }
.chat-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatBounce { 0%,80%,100% { transform: translateY(0); } 40% { transform: translateY(-5px); } }

.chat-input-bar {
  display: flex;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border-subtle);
  align-items: flex-end;
  background: var(--bg-secondary);
}
.chat-attach-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  border: 1px solid var(--border);
  flex-shrink: 0;
  transition: all var(--t);
}
.chat-attach-btn:hover { border-color: var(--accent); color: var(--accent); }
.chat-attach-btn svg { width: 16px; height: 16px; }

.chat-input {
  flex: 1;
  min-height: 38px;
  max-height: 120px;
  resize: none;
  padding: 8px 16px;
  border-radius: var(--r-xl) !important;
  font-size: 14px;
  line-height: 1.5;
}

.chat-send {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--text-inv);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--t);
  box-shadow: var(--accent-glow-sm);
}
.chat-send:hover { background: var(--accent-hover); box-shadow: var(--accent-glow); }
.chat-send:disabled { opacity: 0.35; box-shadow: none; }
.chat-send svg { width: 16px; height: 16px; }

/* 2x2 suggestion grid (empty state) */
.chat-empty-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
  max-width: 480px;
}
.chat-sg-card {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 14px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer; transition: all 0.15s;
  text-align: left; font-family: inherit;
  color: var(--text-1);
}
.chat-sg-card:hover { border-color: var(--accent-mid); background: var(--accent-dim); }
.chat-sg-card {
  opacity: 0; transform: translateY(14px);
  position: relative; overflow: hidden;
}
/* Shimmer effect on hover */
.chat-sg-card::after {
  content: ''; position: absolute; top: 0; left: -100%; width: 50%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.04), transparent);
  transition: left 0.5s ease;
}
.chat-sg-card:hover::after { left: 150%; }

.chat-empty.loaded .chat-sg-card { animation: sgCardIn 0.5s ease-out forwards; }
.chat-empty.loaded .chat-sg-card:nth-child(1) { animation-delay: 0.7s; }
.chat-empty.loaded .chat-sg-card:nth-child(2) { animation-delay: 0.85s; }
.chat-empty.loaded .chat-sg-card:nth-child(3) { animation-delay: 1.0s; }
.chat-empty.loaded .chat-sg-card:nth-child(4) { animation-delay: 1.15s; }
@keyframes sgCardIn {
  0% { opacity: 0; transform: translateY(14px); }
  100% { opacity: 1; transform: translateY(0); }
}

.chat-empty-grid { opacity: 0; }
.chat-empty.loaded .chat-empty-grid { animation: gridFadeIn 0.3s ease 0.6s forwards; }
@keyframes gridFadeIn { to { opacity: 1; } }
.chat-sg-icon {
  width: 36px; height: 36px; border-radius: 8px;
  background: rgba(255,255,255,0.04);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2); flex-shrink: 0;
}
.chat-sg-card:hover .chat-sg-icon { color: var(--accent); }
.chat-sg-info { min-width: 0; }
.chat-sg-label { font-size: 13px; font-weight: 600; }
.chat-sg-desc { font-size: 11px; color: var(--text-3); margin-top: 1px; }

@media (max-width: 480px) {
  .chat-empty-grid { grid-template-columns: 1fr; }
  .chat-sg-card { padding: 12px; }
}

.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 8px;
  padding: 0 20px 10vh;
  opacity: 0;
}
.chat-empty.loaded { opacity: 1; }

/* Logo entrance — clean fade + scale, no overshoot */
.palai-logo-anim {
  opacity: 0;
  transform: scale(0.9);
  filter: blur(6px);
}
.chat-empty.loaded .palai-logo-anim {
  animation: logoReveal 1s ease-out 0s forwards,
             logoBreath 5s ease-in-out 2s infinite;
}
@keyframes logoReveal {
  0% { opacity: 0; transform: scale(0.9); filter: blur(6px); }
  50% { opacity: 0.7; filter: blur(1px); }
  100% { opacity: 1; transform: scale(1); filter: blur(0); }
}
@keyframes logoBreath {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.1) drop-shadow(0 0 16px rgba(168, 85, 247, 0.12)); }
}
.chat-empty-avatar { font-size: 44px; }
.chat-empty-text { font-size: 16px; font-weight: 600; color: var(--text-2); letter-spacing: -0.01em; }
.chat-suggestions { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 340px; margin-top: 4px; }
.chat-suggestion {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t);
  text-align: left;
}
.chat-suggestion:hover { border-color: var(--accent-mid); background: var(--accent-dim); }
.chat-suggestion-icon { font-size: 18px; flex-shrink: 0; }


/* ═══════════════════════════════════════
   TIMER
   ═══════════════════════════════════════ */

/* Mini floating timer */
.timer-mini {
  position: fixed; bottom: 80px; right: 20px; z-index: 600;
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  padding: 10px 14px; display: flex; align-items: center; gap: 10px;
  min-width: 200px; user-select: none;
}
.timer-mini-drag {
  cursor: grab; color: var(--text-3); font-size: 14px; padding: 2px 4px;
  flex-shrink: 0;
}
.timer-mini-drag:active { cursor: grabbing; }
.timer-mini-time {
  font-size: 22px; font-weight: 800; letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums; color: var(--text-1);
}
.timer-mini-label {
  font-size: 9px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-3);
}
.timer-mini-controls {
  display: flex; gap: 4px; margin-left: auto;
}
.timer-mini-btn {
  width: 28px; height: 28px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg-2);
  color: var(--text-2); font-size: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-family: inherit; transition: all var(--t);
}
.timer-mini-btn:hover { background: var(--bg-3); color: var(--text-1); }

.timer-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 28px;
  padding: 24px;
  max-width: 100% !important;
}

.timer-ring-wrap { width: 260px; height: 260px; position: relative; }
@media (min-width: 500px) { .timer-ring-wrap { width: 280px; height: 280px; } }
.timer-ring-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-ring-bg { fill: none; stroke: var(--border); stroke-width: 4; }
.timer-ring-fill { fill: none; stroke: var(--accent); stroke-width: 4; stroke-linecap: round; transition: stroke-dashoffset 0.5s; filter: drop-shadow(0 0 10px rgba(34,197,94,0.25)); }
.timer-display { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); text-align: center; }
.timer-time { font-size: 52px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -3px; }
.timer-mode-label { font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 2px; margin-top: 4px; }

.focus-timer .timer-time { font-size: 72px; }
.focus-timer .timer-ring-wrap { width: 320px; height: 320px; }
.focus-timer .timer-ring-fill { filter: drop-shadow(0 0 16px rgba(34,197,94,0.35)); }

.timer-play {
  width: 68px; height: 68px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--text-inv);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-spring);
  box-shadow: var(--accent-glow);
}
.timer-play:hover { transform: scale(1.06); }
.timer-play:active { transform: scale(0.94); }
.timer-play svg { width: 26px; height: 26px; }

.timer-modes { display: flex; gap: 6px; }
.timer-mode-btn {
  padding: 7px 18px;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  border: 1px solid var(--border);
  transition: all var(--t);
}
.timer-mode-btn.active { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); box-shadow: var(--accent-glow-sm); }

.timer-presets { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.timer-preset {
  padding: 9px 20px;
  border-radius: var(--r-full);
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  transition: all var(--t);
}
.timer-preset:hover { border-color: var(--accent-mid); background: var(--accent-dim); color: var(--accent); }


/* ═══════════════════════════════════════
   TRANSLATOR
   ═══════════════════════════════════════ */

.translate-pane { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.translate-half { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.translate-label {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 18px 6px;
  font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 1px;
}
.translate-lang-pill {
  background: var(--bg-card); border: 1px solid var(--border);
  padding: 4px 12px; border-radius: var(--r-full);
  font-size: 12px; font-weight: 600; color: var(--text-1); cursor: pointer;
  text-transform: none; letter-spacing: 0; transition: all var(--t);
}
.translate-lang-pill:hover { border-color: var(--accent-mid); }
.translate-textarea {
  flex: 1; border: none !important; background: transparent !important;
  padding: 10px 18px; font-size: 15px; line-height: 1.7; resize: none;
}
.translate-textarea:focus { box-shadow: none !important; }
.translate-divider { display: flex; align-items: center; justify-content: center; height: 1px; background: var(--border); position: relative; }
.translate-swap {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--bg-secondary); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2); position: absolute; z-index: 2; cursor: pointer;
  transition: all var(--t);
}
.translate-swap:hover { border-color: var(--accent); color: var(--accent); }
.translate-swap svg { width: 16px; height: 16px; }
.translate-output { flex: 1; padding: 10px 18px; font-size: 15px; line-height: 1.7; overflow-y: auto; }
.translate-loading { height: 2px; background: var(--border); position: absolute; left: 0; right: 0; top: -1px; overflow: hidden; }
.translate-loading.active::after { content: ''; position: absolute; left: -40%; width: 40%; height: 100%; background: var(--accent); animation: translateSlide 1.5s infinite; }
@keyframes translateSlide { to { left: 100%; } }


/* ═══════════════════════════════════════
   TTS PLAYER
   ═══════════════════════════════════════ */

.tts-player {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; gap: 28px; padding: 28px; max-width: 100% !important;
}
.tts-waveform { display: flex; align-items: center; gap: 3px; height: 80px; }
.tts-bar {
  width: 3px; border-radius: 2px; background: var(--accent); opacity: 0.25;
  transition: height 0.12s, opacity 0.12s;
}
.tts-bar.active { opacity: 0.85; }
.tts-play-btn {
  width: 68px; height: 68px; border-radius: 50%;
  background: var(--accent); color: var(--text-inv);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--accent-glow); transition: all var(--t-spring);
}
.tts-play-btn:hover { transform: scale(1.06); }
.tts-play-btn:active { transform: scale(0.94); }
.tts-play-btn svg { width: 26px; height: 26px; }


/* ═══════════════════════════════════════
   NOTES (Rich Editor)
   ═══════════════════════════════════════ */

.notes-wrap{display:flex;flex:1;min-height:0;max-width:100%!important;overflow:hidden}

/* Sidebar */
.notes-sidebar{
  width:260px;border-right:1px solid var(--border-subtle);
  display:flex;flex-direction:column;flex-shrink:0;
  background:var(--bg-1);
}
.notes-sb-header{
  display:flex;align-items:center;gap:8px;padding:14px 16px;
  border-bottom:1px solid var(--border-subtle);
}
.notes-sb-title{font-size:15px;font-weight:700;flex:1}
.notes-sb-btn{
  width:32px;height:32px;border-radius:var(--r-sm);
  display:flex;align-items:center;justify-content:center;
  color:var(--text-2);transition:all var(--t);
}
.notes-sb-btn:hover{background:rgba(255,255,255,0.05);color:var(--accent)}
.notes-sb-search{padding:8px 12px}
.notes-sb-search input{height:36px;font-size:13px;border-radius:var(--r-sm);padding:6px 12px}
.notes-sb-list{flex:1;overflow-y:auto;padding:4px 8px}
.notes-sb-list::-webkit-scrollbar{width:3px}
.notes-sb-list::-webkit-scrollbar-thumb{background:rgba(255,255,255,0.04);border-radius:2px}

.notes-sb-item{
  display:flex;flex-direction:column;gap:2px;
  padding:10px 12px;border-radius:var(--r-sm);cursor:pointer;
  margin-bottom:2px;transition:background 0.12s;
  width:100%;text-align:left;border:none;background:none;color:var(--text-1);font-family:var(--font);
}
.notes-sb-item:hover{background:rgba(255,255,255,0.03)}
.notes-sb-item.active{background:var(--accent-dim)}
.notes-sb-item-title{font-size:13px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.notes-sb-item-preview{font-size:11px;color:var(--text-3);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.notes-sb-item-time{font-size:10px;color:var(--text-3)}

/* Editor */
.notes-editor{flex:1;display:flex;flex-direction:column;min-width:0;overflow:hidden}

/* Toolbar */
.notes-toolbar{
  display:flex;gap:1px;padding:6px 12px;
  border-bottom:1px solid var(--border-subtle);
  overflow-x:auto;-webkit-overflow-scrolling:touch;flex-shrink:0;
  scrollbar-width:none;
}
.notes-toolbar::-webkit-scrollbar{display:none}
.notes-tb-btn{
  width:32px;height:32px;border-radius:var(--r-xs);flex-shrink:0;
  display:flex;align-items:center;justify-content:center;
  color:var(--text-2);font-size:13px;transition:all var(--t);cursor:pointer;
}
.notes-tb-btn:hover{background:rgba(255,255,255,0.05);color:var(--text-1)}
.notes-tb-btn:active{background:rgba(255,255,255,0.08)}
.notes-tb-sep{width:1px;height:20px;background:var(--border-subtle);margin:6px 4px;flex-shrink:0}

/* Title input */
.notes-title-input{
  border:none!important;border-bottom:1px solid var(--border-subtle)!important;
  border-radius:0!important;font-size:20px;font-weight:700;padding:14px 24px;
  background:transparent!important;letter-spacing:-0.02em;
}
.notes-title-input:focus{box-shadow:none!important}

/* Content area */
.notes-content{
  flex:1;padding:16px 24px;outline:none;overflow-y:auto;
  line-height:1.85;font-size:15px;overflow-wrap:break-word;
}
.notes-content:empty::before{content:attr(data-placeholder);color:var(--text-3)}
.notes-content h1{font-size:22px;font-weight:700;margin:18px 0 8px;letter-spacing:-0.02em}
.notes-content h2{font-size:18px;font-weight:700;margin:16px 0 6px;letter-spacing:-0.02em}
.notes-content h3{font-size:16px;font-weight:700;margin:14px 0 4px}
.notes-content ul,.notes-content ol{padding-left:22px;margin:8px 0}
.notes-content li{margin-bottom:4px}
.notes-content blockquote{border-left:3px solid var(--accent);padding:8px 16px;margin:10px 0;color:var(--text-2);background:var(--accent-dim);border-radius:0 var(--r-sm) var(--r-sm) 0}
.notes-content hr{border:none;border-top:1px solid var(--border);margin:16px 0}
.notes-content a{color:var(--accent);text-decoration:underline}
.notes-content img{max-width:100%;border-radius:var(--r-sm);margin:8px 0}

/* Checklist */
.note-checklist{margin:6px 0;display:flex;align-items:center;gap:8px}
.note-checklist label{display:flex;align-items:center;gap:8px;cursor:pointer}
.note-checklist input[type="checkbox"]{
  width:18px;height:18px;border-radius:4px;accent-color:var(--accent);cursor:pointer;
}
.note-checklist input:checked + span{text-decoration:line-through;color:var(--text-3)}

/* Code block in notes */
.note-code{
  background:var(--bg-elevated);border:1px solid var(--border-subtle);
  border-radius:var(--r-sm);padding:14px;font-family:var(--font-mono);font-size:13px;
  overflow-x:auto;margin:10px 0;white-space:pre;
}

/* Math block in notes */
.note-math{
  text-align:center;padding:12px 0;margin:10px 0;
  background:var(--bg-card);border-radius:var(--r-sm);
}

/* Status bar */
.notes-status{
  padding:6px 24px;border-top:1px solid var(--border-subtle);
  font-size:11px;color:var(--text-3);display:flex;align-items:center;gap:10px;
  flex-shrink:0;
}

/* Scrim (mobile) */
.notes-scrim{display:none;position:fixed;inset:0;background:rgba(0,0,0,0.5);z-index:199}

/* Mobile */
@media(max-width:768px){
  .notes-sidebar{
    display:none;position:fixed;top:0;left:0;bottom:0;z-index:200;width:280px;
    box-shadow:var(--shadow-xl);
  }
  .notes-sidebar.open{display:flex}
  .notes-sidebar.open ~ .notes-scrim{display:block}
  .notes-sb-toggle{display:flex!important}
  .notes-title-input{font-size:18px;padding:12px 16px}
  .notes-content{padding:12px 16px}
  .notes-status{padding:6px 16px}
  .notes-tb-btn{width:36px;height:36px}
}

@media (max-width: 768px) {
  .notes-sidebar { display: none; position: fixed; top: 0; left: 0; bottom: 0; z-index: 200; width: 260px; }
  .notes-sidebar.open { display: flex; }
  .notes-scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 199; }
}


/* ═══════════════════════════════════════
   LIBRARY
   ═══════════════════════════════════════ */

.library-search { position: relative; margin-bottom: 12px; }
.library-search input { padding-left: 42px; height: 46px; font-size: 14px; border-radius: var(--r-lg); }
.library-search svg { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--text-3); }

.library-filters { display: flex; gap: 6px; margin-bottom: 16px; overflow-x: auto; padding-bottom: 2px; }
.library-filter {
  padding: 7px 15px; border-radius: var(--r-full); font-size: 12px; font-weight: 600;
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text-2);
  white-space: nowrap; flex-shrink: 0; transition: all var(--t);
}
.library-filter.active { background: var(--accent-dim); border-color: var(--accent-mid); color: var(--accent); }

.library-items { display: flex; flex-direction: column; gap: 6px; }
.library-item {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-md);
  cursor: pointer; transition: all var(--t);
}
.library-item:hover { background: var(--bg-card-hover); border-color: var(--border-hover); }

.library-item-icon {
  width: 38px; height: 38px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0;
}
.library-item-info { flex: 1; min-width: 0; }
.library-item-title { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: -0.01em; }
.library-item-meta { font-size: 11px; color: var(--text-3); margin-top: 2px; }


/* ═══════════════════════════════════════
   MEMORIZE
   ═══════════════════════════════════════ */

.mem-journey { display: flex; align-items: center; justify-content: center; padding: 16px 0 22px; }
.mem-node {
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid var(--border); display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--text-3); flex-shrink: 0;
  transition: all 0.3s;
}
.mem-node.active { border-color: var(--accent); color: var(--accent); animation: memPulse 2s infinite; }
.mem-node.done { border-color: var(--accent); background: var(--accent); color: var(--text-inv); }
.mem-line { width: 36px; height: 2px; background: var(--border); }
.mem-line.done { background: var(--accent); }
@keyframes memPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(34,197,94,0.3); } 50% { box-shadow: 0 0 0 7px transparent; } }


/* ═══════════════════════════════════════
   PLANNER
   ═══════════════════════════════════════ */

.planner-week { display: flex; align-items: center; border-bottom: 1px solid var(--border-subtle); padding: 8px 4px; }
.planner-week-btn { padding: 8px; color: var(--text-3); }
.planner-days { display: flex; flex: 1; gap: 2px; }
.planner-day {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 4px; border-radius: var(--r-md); cursor: pointer; transition: all var(--t);
}
.planner-day.today { background: var(--accent-dim); }
.planner-day.selected { border: 1px solid var(--accent); }
.planner-day-abbr { font-size: 10px; font-weight: 600; color: var(--text-3); text-transform: uppercase; }
.planner-day-num { font-size: 16px; font-weight: 700; }
.planner-day-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }

.planner-fab {
  position: fixed;
  bottom: calc(var(--bnav-h) + env(safe-area-inset-bottom, 0) + 18px);
  right: 22px;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent); color: var(--text-inv);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--accent-glow), var(--shadow-lg); z-index: 50;
  transition: all var(--t-spring);
}
.planner-fab:hover { transform: scale(1.08); }
.planner-fab svg { width: 22px; height: 22px; }
@media (min-width: 769px) { .planner-fab { bottom: 24px; } }


/* ═══════════════════════════════════════
   SHARED COMPONENTS
   ═══════════════════════════════════════ */

.toast-container { position: fixed; top: 16px; right: 16px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 11px 18px; font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg); animation: slideInRight 0.3s var(--ease); max-width: 320px;
}
.toast.success { border-color: var(--accent-mid); color: var(--accent-bright); }
.toast.error { border-color: var(--danger-border); color: var(--danger); }
@keyframes slideInRight { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 500;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fadeIn 0.15s;
}
.modal {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--r-xl); padding: 26px; max-width: 400px; width: 100%;
  box-shadow: var(--shadow-xl);
}
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 8px; letter-spacing: -0.02em; }
.modal-body { color: var(--text-2); font-size: 14px; margin-bottom: 20px; line-height: 1.6; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; gap: 10px; text-align: center; padding: 48px 24px; max-width: 100% !important;
}
.empty-state-icon { font-size: 44px; opacity: 0.45; }
.empty-state-text { font-size: 14px; color: var(--text-3); max-width: 260px; line-height: 1.6; }


/* ═══════════════════════════════════════
   TROPHY + RANK SYSTEM
   ═══════════════════════════════════════ */

/* Rank badge glow pulse */
.rank-badge { filter: drop-shadow(0 0 8px var(--rank-glow, rgba(205,127,50,0.3))); transition: filter 0.3s; }
.rank-badge:hover { filter: drop-shadow(0 0 16px var(--rank-glow, rgba(205,127,50,0.5))); }

/* Trophy toast — floats up from center */
.trophy-toast-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--r-full);
  font-size: 20px; font-weight: 800; letter-spacing: -0.02em;
  animation: trophyFloat 1.8s var(--ease) forwards;
  pointer-events: none; white-space: nowrap;
}
.trophy-toast-item.gain {
  background: rgba(34,197,94,0.15); color: #4ade80;
  border: 1px solid rgba(34,197,94,0.3);
  text-shadow: 0 0 12px rgba(34,197,94,0.4);
}
.trophy-toast-item.loss {
  background: rgba(244,63,94,0.15); color: #f43f5e;
  border: 1px solid rgba(244,63,94,0.3);
  text-shadow: 0 0 12px rgba(244,63,94,0.4);
}
.trophy-toast-item.neutral { background: rgba(255,255,255,0.06); color: var(--text-2); border: 1px solid var(--border); }
.trophy-toast-icon { font-size: 24px; }
.trophy-toast-delta { font-variant-numeric: tabular-nums; }

@keyframes trophyFloat {
  0% { opacity: 0; transform: translateY(20px) scale(0.8); }
  15% { opacity: 1; transform: translateY(0) scale(1.1); }
  30% { transform: translateY(0) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-60px) scale(0.9); }
}

/* Rank-up celebration overlay */
.rankup-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.3s;
  overflow: hidden;
}
.rankup-overlay.rankup-exit { animation: fadeOut 0.4s forwards; }
@keyframes fadeOut { to { opacity: 0; } }

.rankup-content {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  animation: rankupBounce 0.6s var(--ease-spring);
  position: relative; z-index: 2;
}
@keyframes rankupBounce {
  0% { opacity: 0; transform: scale(0.5); }
  60% { transform: scale(1.1); }
  100% { opacity: 1; transform: scale(1); }
}

.rankup-flash {
  position: absolute; width: 300px; height: 300px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 70%);
  animation: rankFlash 1.5s ease-out;
  pointer-events: none;
}
@keyframes rankFlash {
  0% { transform: scale(0); opacity: 1; }
  100% { transform: scale(3); opacity: 0; }
}

.rankup-badge { animation: badgeSpin 0.8s var(--ease); }
@keyframes badgeSpin {
  0% { transform: rotateY(180deg) scale(0.3); opacity: 0; }
  50% { transform: rotateY(0deg) scale(1.15); }
  100% { transform: rotateY(0deg) scale(1); opacity: 1; }
}

.rankup-title { font-size: 14px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: 3px; }
.rankup-name { font-size: 36px; font-weight: 900; letter-spacing: -0.03em; }
.rankup-trophies { font-size: 15px; color: var(--text-2); font-weight: 600; }

/* Confetti particles */
.confetti-particle {
  position: absolute; top: 40%;
  width: 8px; height: 8px; border-radius: 2px;
  animation: confettiFall var(--ease) forwards;
  pointer-events: none;
}
@keyframes confettiFall {
  0% { transform: translateY(0) translateX(0) rotate(0deg) scale(1); opacity: 1; }
  100% { transform: translateY(300px) translateX(var(--drift, 0px)) rotate(var(--spin, 360deg)) scale(0); opacity: 0; }
}

/* ═══════════════════════════════════════
   DASHBOARD — GAME LOBBY
   ═══════════════════════════════════════ */

.dash-rank-hero {
  display: flex; align-items: center; gap: 20px;
  padding: 24px; border-radius: var(--r-xl);
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
  border: 1px solid var(--border);
  position: relative; overflow: hidden;
  margin-bottom: 20px;
  cursor: pointer; transition: all 0.25s var(--ease);
}
.dash-rank-hero:hover { border-color: var(--border-hover); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.dash-rank-hero::after {
  content: ''; position: absolute; top: -50%; right: -20%;
  width: 280px; height: 280px;
  background: radial-gradient(circle, var(--rank-glow, rgba(205,127,50,0.06)) 0%, transparent 70%);
  pointer-events: none;
}

.dash-rank-info { flex: 1; z-index: 1; }
.dash-rank-name { font-size: 22px; font-weight: 800; letter-spacing: -0.03em; }
.dash-rank-trophies { font-size: 14px; color: var(--text-2); margin-top: 2px; font-weight: 600; }
.dash-rank-bar { height: 6px; background: var(--border); border-radius: 3px; margin-top: 10px; overflow: hidden; }
.dash-rank-bar-fill { height: 100%; border-radius: 3px; transition: width 0.8s var(--ease); }
.dash-rank-next { font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* Quick Match — the big CTA */
.quick-match {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  width: 100%; padding: 18px; border-radius: var(--r-xl);
  background: var(--accent); color: var(--text-inv);
  font-size: 17px; font-weight: 700; letter-spacing: -0.02em;
  box-shadow: var(--accent-glow-btn);
  transition: all 0.2s var(--ease);
  margin-bottom: 20px;
  position: relative; overflow: hidden;
}
.quick-match:hover { transform: translateY(-2px); box-shadow: var(--accent-glow), 0 6px 20px rgba(0,0,0,0.3); }
.quick-match:active { transform: scale(0.97); }
.quick-match .qm-pulse {
  position: absolute; width: 100%; height: 100%;
  background: rgba(255,255,255,0.1);
  border-radius: var(--r-xl);
  animation: qmPulse 2s ease-in-out infinite;
}
@keyframes qmPulse { 0%,100% { opacity: 0; } 50% { opacity: 1; } }

/* Streak flame */
.streak-card {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px; border-radius: var(--r-lg);
  background: var(--bg-card); border: 1px solid var(--border);
  margin-bottom: 20px;
}
.streak-flame { font-size: 32px; animation: flamePulse 1.5s ease-in-out infinite; }
@keyframes flamePulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.12) rotate(3deg); } }
.streak-count { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.streak-label { font-size: 12px; color: var(--text-3); font-weight: 600; }

/* Stats row */
.dash-stats { display: flex; gap: 8px; margin-bottom: 20px; }
.dash-stat {
  flex: 1; padding: 14px 12px; border-radius: var(--r-lg);
  background: var(--bg-card); border: 1px solid var(--border);
  text-align: center;
}
.dash-stat-num { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.dash-stat-label { font-size: 10px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }

/* Continue studying cards */
.continue-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: var(--r-lg);
  background: var(--bg-card); border: 1px solid var(--border);
  cursor: pointer; transition: all var(--t);
  margin-bottom: 8px;
}
.continue-card:hover { background: var(--bg-card-hover); border-color: var(--border-hover); transform: translateX(4px); }
.continue-card-icon { width: 40px; height: 40px; border-radius: var(--r-md); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.continue-card-info { flex: 1; min-width: 0; }
.continue-card-title { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.continue-card-meta { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.continue-card-arrow { color: var(--text-3); font-size: 18px; }

/* Question timer ring (for timed quiz) */
.q-timer-ring { width: 44px; height: 44px; position: relative; flex-shrink: 0; }
.q-timer-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.q-timer-ring .ring-bg { fill: none; stroke: var(--border); stroke-width: 3; }
.q-timer-ring .ring-fill { fill: none; stroke-width: 3; stroke-linecap: round; transition: stroke-dashoffset 1s linear; }
.q-timer-ring .ring-fill.urgent { stroke: var(--danger) !important; }
.q-timer-num {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums;
}
.q-timer-num.urgent { color: var(--danger); animation: timerPulse 0.5s ease-in-out infinite; }
@keyframes timerPulse { 50% { transform: translate(-50%,-50%) scale(1.15); } }


/* ═══════════════════════════════════════
   TABLET OPTIMIZATIONS (769px — 1024px)
   ═══════════════════════════════════════ */

@media (min-width: 769px) {
  /* Quiz options: 2-column on wider screens */
  .quiz-options { display: grid; grid-template-columns: 1fr 1fr; }
  .quiz-q-text { font-size: 20px; }

  /* Flashcards: wider card */
  .fc-card { max-width: 500px; }

  /* Chat: wider messages */
  .chat-msg { max-width: 75%; }
  .chat-wrap { max-width: 100%; }

  /* Notes: show sidebar on tablets */
  .notes-sidebar { display: flex !important; position: static !important; }
  .notes-scrim { display: none !important; }

  /* Input hero: wider buttons row */
  .input-hero-buttons { flex-direction: row; max-width: 400px; }
  .input-hero-btn { flex: 1; }

  /* Wider content input */
  .content-input { max-width: 100%; }
}


/* ═══════════════════════════════════════
   STUDY PLANNER
   ═══════════════════════════════════════ */

/* Onboarding option cards */
.sp-ob-opt {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px; border-radius: 12px;
  background: rgba(255,255,255,0.02); border: 1.5px solid rgba(255,255,255,0.06);
  cursor: pointer; transition: all 0.15s; text-align: left;
  width: 100%; font-family: inherit; color: var(--text-1);
}
.sp-ob-opt:hover { background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.1); }
.sp-ob-opt.active { border-color: var(--accent); background: rgba(34,197,94,0.04); }
.sp-ob-icon { font-size: 22px; flex-shrink: 0; }
.sp-ob-text { display: flex; flex-direction: column; gap: 1px; }
.sp-ob-text strong { font-size: 14px; font-weight: 700; }
.sp-ob-text span { font-size: 12px; color: var(--text-2); }

/* Exam selection cards */
.sp-exam-card {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: 10px;
  background: rgba(255,255,255,0.015); border: 1px solid rgba(255,255,255,0.04);
  cursor: pointer; transition: all 0.15s; margin-bottom: 4px;
}
.sp-exam-card:hover { background: rgba(255,255,255,0.03); }
.sp-exam-cb { display: none; }
.sp-exam-tick {
  width: 20px; height: 20px; border-radius: 6px;
  border: 2px solid rgba(255,255,255,0.1); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; transition: all 0.15s;
}
.sp-exam-cb:checked + .sp-exam-tick { background: var(--c, var(--accent)); border-color: var(--c, var(--accent)); }
.sp-exam-cb:checked + .sp-exam-tick::after {
  content: ''; width: 5px; height: 9px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); margin-top: -2px;
}

/* Setup chips */
.sp-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px;
  background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.06);
  cursor: pointer; transition: all 0.15s; font-family: inherit; font-size: 12px; font-weight: 600; color: var(--text-2);
}
.sp-chip:hover { background: rgba(255,255,255,0.04); }
.sp-chip.active { border-color: var(--accent); background: rgba(34,197,94,0.05); color: var(--accent); }
.sp-chip-dot { width: 8px; height: 8px; border-radius: 3px; flex-shrink: 0; }

.sp-day-btn {
  flex: 1; padding: 8px 4px; border-radius: 8px; font-size: 11px; font-weight: 600;
  background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.05);
  cursor: pointer; transition: all 0.15s; font-family: inherit; color: var(--text-2); text-align: center;
}
.sp-day-btn:hover { background: rgba(255,255,255,0.04); }
.sp-day-btn.active { border-color: var(--accent); background: rgba(34,197,94,0.05); color: var(--accent); }

/* Toolbar */
.sp-toolbar {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 0 12px; flex-shrink: 0;
}
.sp-week-label { font-size: 14px; font-weight: 700; letter-spacing: -0.02em; margin-left: 8px; }
.sp-progress { width: 80px; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.sp-progress-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.3s; }

/* Week grid */
.sp-week-grid {
  flex: 1; display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px; min-height: 0; overflow: hidden;
}
.sp-week-col {
  display: flex; flex-direction: column;
  background: rgba(255,255,255,0.012); border: 1px solid rgba(255,255,255,0.03);
  border-radius: 10px; overflow: hidden; min-height: 0;
}
.sp-week-col.sp-today { border-color: rgba(34,197,94,0.12); background: rgba(34,197,94,0.015); }

.sp-week-hdr {
  padding: 8px 8px 6px; text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.03); flex-shrink: 0;
}
.sp-week-day-name { font-size: 9px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.5px; }
.sp-week-day-num { font-size: 16px; font-weight: 800; color: var(--text-2); margin-top: 1px; }
.sp-today-num { color: var(--accent) !important; }
.sp-exam-badge {
  font-size: 7px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px;
  color: #fff; padding: 2px 5px; border-radius: 4px;
  display: block; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%; line-height: 1.3; opacity: 0.85;
}
.sp-week-count { font-size: 9px; color: var(--text-3); margin-top: 2px; }

.sp-week-tasks { flex: 1; overflow-y: auto; padding: 4px; display: flex; flex-direction: column; gap: 2px; }
.sp-week-tasks::-webkit-scrollbar { width: 2px; }
.sp-week-tasks::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.04); }

/* Task cards */
.sp-task {
  display: flex; align-items: flex-start; gap: 6px;
  padding: 5px 6px; border-radius: 6px;
  cursor: pointer; transition: background 0.12s;
  position: relative; overflow: hidden;
}
.sp-task:hover { background: rgba(255,255,255,0.03); }
.sp-task-done { opacity: 0.35; }
.sp-task-exam { background: rgba(239,68,68,0.04); border-left: 2px solid var(--danger); }

.sp-task-check {
  width: 14px; height: 14px; border-radius: 4px;
  border: 2px solid var(--c, rgba(255,255,255,0.15));
  flex-shrink: 0; margin-top: 1px; cursor: pointer; transition: all 0.15s;
}
.sp-task-done .sp-task-check {
  background: var(--c, var(--accent)); border-color: var(--c, var(--accent));
}
.sp-task-body { flex: 1; min-width: 0; }
.sp-task-title {
  font-size: 10px; font-weight: 500; color: var(--text-2); line-height: 1.4;
}
.sp-task-done .sp-task-title { text-decoration: line-through; color: var(--text-3); }
.sp-task-due {
  font-size: 8px; font-weight: 700; color: rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.04); padding: 1px 5px; border-radius: 3px;
  margin-top: 2px; display: inline-block; letter-spacing: 0.3px;
}
/* Subject icon */
.sp-task-icon {
  width: 18px; height: 18px; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; color: var(--text-2); opacity: 0.7;
}
/* Exam due date — compact M/D on far right */
.sp-task-due-date {
  font-size: 9px; font-weight: 800; color: var(--text-3);
  white-space: nowrap; flex-shrink: 0;
  padding: 1px 8px 1px 4px; align-self: center;
  letter-spacing: 0.2px; font-variant-numeric: tabular-nums;
  background: rgba(255,255,255,0.04); border-radius: 3px;
}
/* Drag-and-drop states */
.sp-task-dragging { opacity: 0.3; }
.sp-task[draggable="true"] { cursor: grab; }
.sp-task[draggable="true"]:active { cursor: grabbing; }
.sp-week-tasks.sp-drag-over {
  background: rgba(34,197,94,0.06);
  border: 1px dashed rgba(34,197,94,0.3);
  border-radius: 6px;
}
.sp-task-color-bar {
  position: absolute; right: 0; top: 0; bottom: 0; width: 4px;
  border-radius: 0 6px 6px 0; opacity: 0.75;
}

.sp-week-add {
  width: 100%; padding: 5px; border: 1px dashed rgba(255,255,255,0.1); background: rgba(255,255,255,0.02);
  color: var(--text-3); font-size: 16px; cursor: pointer; transition: 0.15s;
  border-radius: 5px; font-family: inherit; margin-top: auto;
}
.sp-week-add:hover { background: rgba(34,197,94,0.08); border-color: rgba(34,197,94,0.3); color: var(--accent); }


/* ═══════════════════════════════════════
   MOBILE TOOL OPTIMIZATIONS (<768px)
   ═══════════════════════════════════════ */

@media (max-width: 767px) {
  /* Quiz: bigger options, readable text */
  .quiz-q-text { font-size: 16px; padding: 4px 0 20px; }
  .quiz-opt { padding: 14px 16px; min-height: 52px; font-size: 14px; gap: 12px; }
  .quiz-opt-badge { width: 32px; height: 32px; }
  .quiz-score-ring { width: 130px; height: 130px; }

  /* Flashcards: constrain to screen */
  .fc-card { width: calc(100% - 24px); max-width: 100%; }
  .fc-face { padding: 20px; }
  .fc-text-front { font-size: 18px; }
  .fc-text-back { font-size: 14px; }
  .fc-action-btn { width: 56px; height: 56px; font-size: 24px; }
  .fc-actions { gap: 40px; }

  /* Timer: fit small screens */
  .timer-ring-wrap { width: 220px; height: 220px; }
  .timer-time { font-size: 44px; }
  .timer-play { width: 60px; height: 60px; }

  /* Chat: mobile optimized */
  .chat-msg.user { max-width: 85%; }
  .chat-msg.bot { max-width: 95%; }
  .chat-bubble { padding: 10px 14px; font-size: 14px; }
  .chat-send { width: 44px; height: 44px; }
  .chat-input { min-height: 44px; font-size: 16px; /* prevents iOS zoom */ }
  .chat-camera-btn { width: 44px; height: 44px; }
  .chat-messages { padding: 14px 12px; gap: 12px; }
  .chat-toolbar { padding: 6px 10px; }
  .chat-context-btn { font-size: 10px; padding: 3px 8px; }
  .chat-input-bar { padding: 8px 10px; padding-bottom: calc(8px + env(safe-area-inset-bottom, 0)); }
  .chat-empty-grid { grid-template-columns: 1fr; gap: 6px; padding: 0 8px; }
  .chat-sg-card { padding: 12px; }

  /* Workspace chat mobile */
  .ws-chat-input-bar { padding-bottom: calc(8px + env(safe-area-inset-bottom, 0)); }
  .ws-chat-messages { padding: 12px 10px; }

  /* AI reader: comfortable reading */
  .ai-reader { padding: 20px 2px; font-size: 15px; }
  .ai-reader h1 { font-size: 20px; }
  .ai-reader h2 { font-size: 17px; }

  /* Input hero: bigger buttons */
  .input-hero { min-height: 160px; padding: 24px 16px; }
  .input-hero-btn { height: 48px; font-size: 14px; }

  /* Notes */
  .notes-toolbar button { width: 40px; height: 40px; }

  /* Planner: horizontal scroll on narrow */
  .sp-week-grid { overflow-x: auto; min-width: 600px; }

  /* Cheat Sheet: smaller padding on mobile */
  .cs-paper { padding: 24px 20px 20px; }
  .cs-scroll-wrap { padding: 12px; }

  /* Visualizer: full width on mobile */
  .viz-svg-wrap { max-height: 50vh; }

  /* Workspace chat */
  .ws-chat-input-bar { padding-bottom: env(safe-area-inset-bottom, 8px); }
}

/* ═══════════════════════════════════════
   CHEAT SHEET
   ═══════════════════════════════════════ */

/* ── CHEAT SHEET — A4 Paper ── */

.cs-scroll-wrap {
  flex: 1; overflow-y: auto; min-height: 0;
  padding: 20px;
  display: flex; justify-content: center; align-items: flex-start;
  background: rgba(0,0,0,0.3);
}
.cs-actions-bar {
  display: flex; gap: 8px; padding: 10px 16px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0; flex-wrap: wrap;
}

/* A4 paper — real ratio 210:297, multi-page */
.cs-paper {
  width: 100%;
  max-width: 595px; /* A4 at 72dpi */
  min-height: 842px; /* A4 height at 72dpi */
  background: #ffffff;
  border-radius: 4px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.2);
  padding: 36px 32px 28px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

/* Header — green bar with title + branding */
.cs-paper-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  margin-bottom: 10px;
  border-bottom: 2.5px solid #16a34a;
  flex-shrink: 0;
}
.cs-paper-title {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  font-weight: 800;
  color: #111;
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.cs-paper-brand {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 9px;
  color: #999;
  letter-spacing: 0.4px;
  flex-shrink: 0;
  margin-left: 12px;
}
.cs-paper-brand b { color: #16a34a; font-weight: 700; }

/* Footer */
.cs-paper-footer {
  margin-top: auto;
  padding-top: 6px;
  border-top: 1px solid #e5e7eb;
  text-align: center;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 7px;
  color: #bbb;
  letter-spacing: 0.4px;
  flex-shrink: 0;
}

/* Content area — flows naturally, paper grows */
.cs-paper-content {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 12px;
  line-height: 1.5;
  color: #1a1a1a;
  flex: 1;
}

.cs-paper-content.ai-cursor::after {
  content: '';
  display: inline-block;
  width: 2px; height: 13px;
  background: #16a34a;
  animation: blink 0.8s infinite;
  margin-left: 2px;
  vertical-align: text-bottom;
}
@keyframes blink { 0%,50% { opacity: 1; } 51%,100% { opacity: 0; } }

/* Hide the AI-generated h1 title (shown in header instead) */
.cs-paper-content h1 { display: none; }

.cs-paper-content h3 {
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin: 14px 0 4px;
  padding: 2px 0 2px 8px;
  border-left: 3px solid #16a34a;
  color: #16a34a;
}
.cs-paper-content h3:first-child { margin-top: 0; }
.cs-paper-content ul, .cs-paper-content ol { margin: 2px 0 6px; padding-left: 16px; }
.cs-paper-content li { margin-bottom: 2px; font-size: 12px; color: #222; line-height: 1.5; }
.cs-paper-content li::marker { color: #16a34a; }
.cs-paper-content p { margin: 3px 0; font-size: 12px; color: #222; }
.cs-paper-content strong { font-weight: 700; color: #111; }
.cs-paper-content em { font-style: italic; color: #555; }
.cs-paper-content code {
  font-size: 11px; background: #f0fdf4; padding: 1px 4px;
  border-radius: 2px; color: #16a34a; font-family: "Cascadia Code","Fira Code",monospace;
}
.cs-paper-content blockquote {
  border-left: 3px solid #16a34a;
  padding: 5px 9px; margin: 6px 0;
  background: #f0fdf4; border-radius: 0 3px 3px 0;
  font-size: 11px; color: #222;
}
.cs-paper-content blockquote strong { color: #16a34a; }
.cs-paper-content hr { border: none; border-top: 1px solid #e5e7eb; margin: 8px 0; }
.cs-paper-content table { width: 100%; border-collapse: collapse; font-size: 11px; margin: 6px 0; }
.cs-paper-content th {
  background: #f0fdf4; padding: 4px 7px;
  border: 1px solid #d1d5db;
  font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  text-align: left; color: #16a34a;
}
.cs-paper-content td { padding: 4px 7px; border: 1px solid #e5e7eb; color: #222; line-height: 1.4; }
.cs-paper-content tr:nth-child(even) td { background: #fafafa; }
.cs-paper-content .katex { color: #1a1a1a; font-size: 1.15em; }
.cs-paper-content .katex-display { margin: 6px 0; overflow-x: auto; }
.cs-paper-content .katex-display .katex { font-size: 1.25em; }

/* ═══════════════════════════════════════
   VISUALIZER
   ═══════════════════════════════════════ */

.viz-output {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.viz-svg-wrap {
  flex: 1;
  overflow: auto;
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 16px;
  min-height: 0;
}
.viz-svg-wrap svg {
  max-width: 100%;
  height: auto;
}
.viz-fallback {
  flex: 1;
  overflow: auto;
  padding: 16px;
  font-family: var(--font-mono, 'Courier New', monospace);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  color: var(--text-2);
  background: var(--bg-2);
  border-radius: var(--r-md);
  margin: 12px 16px;
  border: 1px solid var(--border-subtle);
}
.viz-actions {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
}

/* ═══════════════════════════════════════
   WORKSPACE CHAT
   ═══════════════════════════════════════ */

.ws-chat-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.ws-chat-context {
  padding: 8px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.ws-chat-context-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px rgba(34,197,94,0.4);
}
.ws-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}
.ws-chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}
.ws-chat-msg {
  display: flex;
  max-width: 85%;
}
.ws-chat-msg.user {
  align-self: flex-end;
}
.ws-chat-msg.user .ws-chat-bubble {
  background: var(--accent-dim);
  color: var(--text-1);
  border-radius: 16px 16px 4px 16px;
}
.ws-chat-msg.bot {
  align-self: flex-start;
}
.ws-chat-msg.bot .ws-chat-bubble {
  background: var(--bg-2);
  color: var(--text-1);
  border-radius: 16px 16px 16px 4px;
}
.ws-chat-bubble {
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}
.ws-chat-bubble .ai-reader { font-size: 14px; line-height: 1.7; }
.ws-chat-bubble .ai-reader p { margin: 6px 0; }
.ws-chat-bubble .ai-reader p:last-child { margin-bottom: 0; }
.ws-chat-bubble .ai-reader h3 { font-size: 13px; color: var(--accent); margin-top: 10px; margin-bottom: 4px; }
.ws-chat-bubble .ai-reader h3:first-child { margin-top: 0; }
.ws-chat-bubble .ai-reader ul, .ws-chat-bubble .ai-reader ol { padding-left: 16px; margin: 6px 0; }
.ws-chat-bubble .ai-reader li { margin-bottom: 2px; font-size: 13px; }
.ws-chat-bubble .ai-reader table { font-size: 12px; }
.ws-chat-bubble .ai-reader th { font-size: 10px; padding: 5px 7px; }
.ws-chat-bubble .ai-reader td { padding: 5px 7px; }
.ws-chat-bubble .ai-reader blockquote { font-size: 12px; padding: 6px 8px; margin: 6px 0; }
.ws-chat-bubble .ai-reader strong { color: var(--text-1); }
.ws-chat-input-bar {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--border-subtle);
  align-items: flex-end;
  flex-shrink: 0;
}
.ws-chat-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 12px;
  font-size: 14px;
  background: var(--bg-2);
  color: var(--text-1);
  font-family: inherit;
  max-height: 100px;
  overflow-y: auto;
}
.ws-chat-input:focus { border-color: var(--border-focus); outline: none; }
.ws-chat-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity var(--t);
}
.ws-chat-send:disabled { opacity: 0.4; cursor: default; }
.ws-chat-send svg { width: 16px; height: 16px; }
.ws-chat-typing span {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  margin: 0 2px;
  animation: chatBounce 1.2s infinite;
}
.ws-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.ws-chat-typing span:nth-child(3) { animation-delay: 0.4s; }

/* ═══════════════════════════════════════
   LEADERBOARD
   ═══════════════════════════════════════ */

.lb-wrap {
  max-width: 600px;
  margin: 0 auto;
  padding: var(--page-px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.lb-header {
  text-align: center;
  padding: 12px 0;
}
.lb-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
}
.lb-header p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-3);
}
.lb-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-2);
  border-radius: var(--r-md);
  padding: 3px;
}
.lb-tab {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-3);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--t);
}
.lb-tab.active {
  background: var(--bg-3);
  color: var(--text-1);
}
.lb-sort-bar {
  display: flex;
  gap: 6px;
}
.lb-sort-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: transparent;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--t);
}
.lb-sort-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}
.lb-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.lb-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-2);
  border-radius: var(--r-md);
  border: 1px solid transparent;
  transition: border-color var(--t);
}
.lb-entry.me {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.lb-rank {
  font-size: 14px;
  font-weight: 800;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}
.lb-rank.gold { color: #fbbf24; }
.lb-rank.silver { color: #a8b4c0; }
.lb-rank.bronze { color: #cd7f32; }
.lb-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-2);
  flex-shrink: 0;
}
.lb-info {
  flex: 1;
  min-width: 0;
}
.lb-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lb-school {
  font-size: 11px;
  color: var(--text-3);
}
.lb-stat {
  text-align: right;
  flex-shrink: 0;
}
.lb-stat-num {
  font-size: 16px;
  font-weight: 800;
}
.lb-stat-label {
  font-size: 10px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.lb-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-3);
  font-size: 14px;
}
.lb-my-card {
  position: sticky;
  bottom: 0;
  padding: 12px 14px;
  background: var(--bg-base);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 12px;
}
