/* ── 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 v2: Complete Redesign ── */

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

/* Center area */
.qzh-center {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 24px 40px; overflow-y: auto;
}
.qzh-create {
  width: 100%; max-width: 640px;
  display: flex; flex-direction: column; gap: 14px;
}

/* The card surface */
.qzh-card {
  background: linear-gradient(170deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.01) 100%);
  border: 1px solid var(--glass-card-border);
  border-radius: 24px;
  padding: 28px;
  display: flex; flex-direction: column; gap: 16px;
  box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset, var(--shadow-lg);
  position: relative;
  overflow: hidden;
}
/* Subtle top-edge shine */
.qzh-card::before {
  content: ''; position: absolute; top: 0; left: 10%; right: 10%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(34,197,94,0.2), transparent);
  pointer-events: none;
}

/* Drop zone */
.qzh-drop {
  border-radius: 18px; cursor: pointer;
  transition: all 0.3s var(--ease);
  overflow: hidden; position: relative;
  background: var(--bg-base);
  border: 1.5px solid var(--border);
}
.qzh-drop:hover { border-color: rgba(34,197,94,0.3); }
.qzh-drop.dragover {
  border-color: var(--accent);
  box-shadow: 0 0 60px rgba(34,197,94,0.12);
}

/* Animated green glow orbs */
.qzh-glow-orb {
  position: absolute; width: 200px; height: 200px;
  border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(34,197,94,0.14) 0%, transparent 70%);
  filter: blur(50px);
  animation: qzhOrb1 10s ease-in-out infinite;
  top: 5%; left: 15%;
}
.qzh-glow-orb2 {
  width: 140px; height: 140px;
  background: radial-gradient(circle, rgba(34,197,94,0.10) 0%, transparent 70%);
  filter: blur(35px);
  animation: qzhOrb2 13s ease-in-out infinite;
  top: 30%; left: 55%;
}
@keyframes qzhOrb1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(100px, -15px) scale(1.3); }
  66% { transform: translate(-40px, 35px) scale(0.8); }
}
@keyframes qzhOrb2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(-60px, 25px) scale(1.15); }
  66% { transform: translate(50px, -35px) scale(0.85); }
}

.qzh-drop-empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 10px; padding: 52px 20px;
  position: relative;
}
.qzh-drop-icn {
  width: 36px; height: 36px; color: var(--accent); opacity: 0.6;
  margin-bottom: 4px;
}
.qzh-drop-cta {
  font-size: 18px; font-weight: 700; color: var(--text-1);
  letter-spacing: -0.02em;
}
.qzh-drop-hint { font-size: 13px; color: var(--text-3); }

/* Thumbs */
.qzh-drop .qz-thumbs {
  display: none; gap: 10px; padding: 24px; flex-wrap: wrap; align-items: center;
}
.qz-thumb {
  width: 88px; height: 88px; border-radius: 12px;
  overflow: hidden; position: relative; flex-shrink: 0;
  border: 1.5px solid var(--border); background: var(--bg-3);
}
.qz-thumb img { width: 100%; height: 100%; object-fit: cover; }
.qz-thumb-remove {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0,0,0,0.8); color: #fff;
  border: none; font-size: 14px; line-height: 1;
  cursor: pointer; display: flex; align-items: center;
  justify-content: center; padding: 0;
  opacity: 0; transition: opacity 0.15s;
}
.qz-thumb:hover .qz-thumb-remove { opacity: 1; }
.qz-thumb-remove:hover { background: var(--danger); }
.qz-thumb-add {
  display: flex; align-items: center; justify-content: center;
  border: 1.5px dashed var(--border); color: var(--text-3);
  cursor: pointer; background: transparent;
}
.qz-thumb-add:hover { border-color: var(--accent); color: var(--accent); }

/* Topic input */
.qzh-topic {
  width: 100% !important; padding: 14px 18px; border-radius: 14px;
  border: 1px solid var(--border); background: rgba(255,255,255,0.03);
  color: var(--text-1); font-size: 15px; font-family: inherit;
  transition: border-color 0.15s;
}
.qzh-topic:focus { border-color: var(--accent); outline: none; background: rgba(255,255,255,0.05); }
.qzh-topic::placeholder { color: var(--text-3); }
.qzh-paste {
  width: 100% !important; padding: 14px 18px; border-radius: 14px;
  border: 1px solid var(--border); background: rgba(255,255,255,0.03);
  color: var(--text-1); font-size: 15px; font-family: inherit;
  line-height: 1.6; resize: vertical; min-height: 80px; max-height: 180px;
}
.qzh-paste:focus { border-color: var(--accent); outline: none; }
.qzh-paste::placeholder { color: var(--text-3); }

/* Config row */
.qzh-config-row {
  display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap;
}
.qzh-counts { display: flex; gap: 3px; flex-shrink: 0; }
.qzh-pill-group { display: flex; gap: 3px; flex-shrink: 0; }
.qzh-pill {
  padding: 7px 14px; border-radius: var(--r-full);
  border: 1px solid var(--border); background: transparent;
  color: var(--text-3); font-size: 12px; font-weight: 600;
  font-family: inherit; cursor: pointer; transition: all 0.15s;
}
.qzh-pill:hover { border-color: var(--border-hover); color: var(--text-2); }
.qzh-pill.active { background: var(--accent-dim); border-color: var(--accent-mid); color: var(--accent); }
.qzh-sel { display: none; }

/* Generate button */
.qzh-go {
  width: 100%; padding: 16px 32px;
  background: var(--accent); color: var(--text-inv);
  border: none; border-radius: 14px;
  font-size: 16px; font-weight: 700; font-family: inherit;
  cursor: pointer; transition: all 0.2s var(--ease);
  box-shadow: var(--accent-glow-btn);
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.qzh-go:hover { background: var(--accent-hover); box-shadow: 0 0 32px rgba(34,197,94,0.3), 0 4px 16px rgba(0,0,0,0.4); transform: translateY(-1px); }
.qzh-go:active { transform: translateY(0); }

/* Session chips */
.qzh-sessions { display: flex; gap: 6px; flex-wrap: wrap; }
.qzh-session-chip {
  padding: 5px 12px; border-radius: var(--r-full);
  border: 1px solid var(--border); background: transparent;
  color: var(--text-3); font-size: 11px; font-weight: 600;
  font-family: inherit; cursor: pointer; transition: all 0.15s;
}
.qzh-session-chip:hover { border-color: var(--accent-mid); color: var(--accent); }

/* ─── Bottom bar: horizontal history cards ─── */
.qzh-history-bar {
  flex-shrink: 0; border-top: 1px solid var(--border);
  padding: 12px 0 12px 20px;
  display: flex; align-items: center; gap: 14px;
}
.qzh-hb-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-3);
  writing-mode: vertical-lr; transform: rotate(180deg);
  flex-shrink: 0;
}
.qzh-hb-scroll {
  display: flex; gap: 10px; overflow-x: auto;
  padding-right: 20px; scrollbar-width: none; flex: 1;
}
.qzh-hb-scroll::-webkit-scrollbar { display: none; }
.qzh-hcard {
  flex-shrink: 0; width: 200px; min-height: 140px;
  padding: 14px 14px 10px; border-radius: 14px;
  border: 1px solid var(--border); background: var(--bg-card);
  display: flex; flex-direction: column; gap: 6px;
  transition: all 0.15s;
  position: relative;
}
.qzh-hcard:hover { border-color: var(--border-hover); background: var(--bg-card-hover); transform: translateY(-1px); }
.qzh-hcard-top {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 26px;
}
.qzh-hcard-pct { font-size: 24px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.qzh-hcard-new {
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-3); padding: 3px 8px; border-radius: var(--r-full);
  background: rgba(255,255,255,0.03); border: 1px solid var(--border);
}
.qzh-hcard-shared {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 6px;
  background: var(--accent-dim); color: var(--accent);
  border: 1px solid var(--accent-mid);
}
.qzh-hcard-shared svg { width: 11px; height: 11px; }
.qzh-hcard-title {
  font-size: 12px; font-weight: 700; color: var(--text-1);
  line-height: 1.35; overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  letter-spacing: -0.01em;
}
.qzh-hcard-meta { font-size: 10px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.qzh-hcard-btns {
  display: flex; gap: 4px; margin-top: auto; padding-top: 6px;
  align-items: center;
}
.qzh-hcard-btn {
  padding: 5px 10px; border-radius: var(--r-full);
  border: 1px solid var(--border); background: transparent;
  color: var(--text-2); font-size: 10px; font-weight: 700;
  font-family: inherit; cursor: pointer; transition: all 0.15s;
  display: inline-flex; align-items: center; gap: 4px;
}
.qzh-hcard-btn:hover { border-color: var(--border-hover); color: var(--text-1); background: rgba(255,255,255,0.03); }
.qzh-hcard-btn-primary {
  border-color: rgba(34,197,94,0.3); color: var(--accent); background: rgba(34,197,94,0.06);
}
.qzh-hcard-btn-primary:hover { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }
.qzh-view-results:hover { border-color: #fbbf24; color: #fbbf24; background: rgba(251,191,36,0.08); }
.qzh-hcard-share:hover { border-color: #3b82f6; color: #3b82f6; background: rgba(59,130,246,0.08); }
.qzh-hcard-menu {
  padding: 5px 6px; margin-left: auto;
}
.qzh-hcard-menu svg { width: 14px; height: 14px; }
.qzh-hcard-menu:hover { color: var(--danger); border-color: rgba(244,63,94,0.3); background: rgba(244,63,94,0.06); }

@media (max-width: 768px) {
  .qzh-center { padding: 16px; }
  .qzh-drop-empty { padding: 36px 16px; }
}

/* Section label (shared) */
.qz-section-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-3); margin-bottom: 6px;
}

/* ═══ RESULTS LAYOUT ═══ */
.qz-results-layout {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 320px;
  gap: 20px; height: 100%;
  padding: 16px 24px;
  overflow-y: auto;
  align-items: start;
}
.qz-results-layout.has-review {
  grid-template-columns: minmax(260px, 1fr) minmax(300px, 1.3fr) 320px;
}
.qz-results-score {
  min-width: 0;
  display: flex; flex-direction: column;
  align-items: center; text-align: center;
  padding: 8px 0;
}
.qz-results-review {
  min-width: 0; padding: 8px 4px; text-align: left;
}
.qz-results-lb {
  display: flex; flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-card);
  overflow: hidden;
  position: sticky; top: 8px;
  max-height: calc(100vh - 120px);
}
@media (max-width: 1100px) {
  .qz-results-layout,
  .qz-results-layout.has-review {
    grid-template-columns: minmax(260px, 1fr) 300px;
  }
  .qz-results-review { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .qz-results-layout,
  .qz-results-layout.has-review {
    grid-template-columns: 1fr;
    padding: 12px;
  }
  .qz-results-review { grid-column: auto; }
  .qz-results-lb { position: static; max-height: 300px; }
}
.qz-results-mot { margin-top: 12px; font-size: 22px; font-weight: 800; letter-spacing: -0.03em; }
.qz-results-sub { color: var(--text-2); font-size: 14px; margin-top: 4px; }
.qz-results-trophy { margin-top: 12px; display: flex; align-items: center; justify-content: center; gap: 12px; }
.qz-results-actions {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 16px; width: 100%; max-width: 380px;
}
.qz-share-btn { font-size: 15px; padding: 14px; }

/* Wrong answers items */
.qz-wrong-item {
  padding: 10px 12px; background: rgba(239,68,68,0.04);
  border: 1px solid rgba(239,68,68,0.12); border-radius: var(--r-md);
  margin-bottom: 6px;
}
.qz-wrong-q { font-size: 13px; font-weight: 600; color: var(--text-1); line-height: 1.45; margin-bottom: 4px; }
.qz-wrong-you { color: var(--danger); font-size: 12px; line-height: 1.4; }
.qz-wrong-skip { color: var(--text-3); font-size: 12px; }
.qz-wrong-ans { color: var(--accent); font-size: 12px; line-height: 1.4; margin-top: 2px; }

/* ═══ LEADERBOARD ═══ */
.qz-lb-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.qz-lb-title { font-size: 14px; font-weight: 800; letter-spacing: -0.02em; }
.qz-lb-count { font-size: 11px; color: var(--text-3); }
.qz-lb-list { flex: 1; overflow-y: auto; padding: 4px 0; }
.qz-lb-empty {
  padding: 24px 16px; text-align: center;
  font-size: 13px; color: var(--text-3);
}
.qz-lb-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px; transition: background 0.1s;
  font-size: 13px;
}
.qz-lb-row:hover { background: rgba(255,255,255,0.02); }
.qz-lb-me { background: rgba(34,197,94,0.06); border-left: 3px solid var(--accent); }
.qz-lb-rank {
  width: 24px; text-align: center; font-weight: 800;
  font-size: 12px; color: var(--text-3); flex-shrink: 0;
}
.qz-lb-gold .qz-lb-rank { color: #fbbf24; }
.qz-lb-silver .qz-lb-rank { color: #94a3b8; }
.qz-lb-bronze .qz-lb-rank { color: #d97706; }
.qz-lb-name {
  flex: 1; min-width: 0; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.qz-lb-score { font-weight: 800; color: var(--accent); flex-shrink: 0; }
.qz-lb-detail { font-size: 11px; color: var(--text-3); flex-shrink: 0; }

/* ═══ SHARED QUIZ — v2 layout (left-aligned, horizontal stats, difficulty) ═══ */
.qz-shared-v2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 28px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 32px 48px;
  align-items: start;
}
@media (max-width: 1100px) {
  .qz-shared-v2 { grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; padding: 20px 20px 40px; }
}
@media (max-width: 820px) {
  .qz-shared-v2 { grid-template-columns: 1fr; padding: 16px; }
}
.sq2-main { min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.sq2-head { display: flex; align-items: center; gap: 10px; }
.sq2-badge {
  font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--accent); background: var(--accent-dim);
  padding: 4px 10px; border-radius: var(--r-full); border: 1px solid var(--accent-mid);
}
.sq2-diff {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 1.5px;
  padding: 4px 10px; border-radius: var(--r-full);
  border: 1px solid var(--diff-border, rgba(255,255,255,0.1));
  background: var(--diff-bg, rgba(255,255,255,0.03));
  color: var(--diff-color, var(--text-2));
}
.sq2-diff-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--diff-color, var(--text-2)); box-shadow: 0 0 6px var(--diff-color, var(--text-2)); }
.sq2-diff-easy   { --diff-color:#22c55e; --diff-bg:rgba(34,197,94,0.08);  --diff-border:rgba(34,197,94,0.25); }
.sq2-diff-medium { --diff-color:#fbbf24; --diff-bg:rgba(251,191,36,0.08); --diff-border:rgba(251,191,36,0.25); }
.sq2-diff-hard   { --diff-color:#fb923c; --diff-bg:rgba(251,146,60,0.08); --diff-border:rgba(251,146,60,0.25); }
.sq2-diff-expert { --diff-color:#f43f5e; --diff-bg:rgba(244,63,94,0.08);  --diff-border:rgba(244,63,94,0.25); }

.sq2-title {
  font-size: 32px; font-weight: 800; letter-spacing: -0.035em;
  line-height: 1.15; margin: 2px 0 0; color: var(--text-1);
}
@media (max-width: 640px) { .sq2-title { font-size: 24px; } }
.sq2-sub { font-size: 14px; color: var(--text-2); margin-top: -4px; }
.sq2-sub strong { color: var(--text-1); font-weight: 700; }

.sq2-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px; margin-top: 4px;
}
.sq2-stat {
  padding: 14px 14px; border-radius: 12px;
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(255,255,255,0.06);
  display: flex; flex-direction: column; gap: 4px;
  transition: border-color 0.15s, background 0.15s;
}
.sq2-stat:hover { background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.1); }
.sq2-stat-icon { color: var(--text-3); }
.sq2-stat-icon svg { width: 15px; height: 15px; }
.sq2-stat-num {
  font-size: 22px; font-weight: 800; letter-spacing: -0.025em;
  color: var(--text-1); font-variant-numeric: tabular-nums; line-height: 1.1;
}
.sq2-stat-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-3); font-weight: 700;
}

.sq2-cta-row { display: flex; align-items: center; gap: 14px; margin-top: 6px; flex-wrap: wrap; }
.sq2-start {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 15px; padding: 12px 26px; font-weight: 800; border-radius: 12px;
  box-shadow: 0 6px 18px rgba(34,197,94,0.28);
}
.sq2-cta-link { font-size: 12px; color: var(--text-3); text-decoration: none; font-weight: 600; }
.sq2-cta-link:hover { color: var(--accent); }

.sq2-aside { position: sticky; top: 16px; }
@media (max-width: 820px) { .sq2-aside { position: static; } }
.sq2-lb {
  display: flex; flex-direction: column;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  background: rgba(255,255,255,0.02);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  overflow: hidden;
  max-height: calc(100vh - 120px);
}

/* ═══ SHARED QUIZ (legacy layout kept for results page — not the intro) ═══ */
.qz-shared-layout {
  display: flex; gap: 24px; height: 100%;
  padding: var(--page-px); overflow-y: auto;
}
@media (max-width: 768px) {
  .qz-shared-layout { flex-direction: column; }
}
.qz-shared-info {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; gap: 8px; padding: 20px 0;
}
.qz-shared-badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.5px; color: var(--accent);
  background: var(--accent-dim); padding: 4px 12px;
  border-radius: var(--r-full); border: 1px solid var(--accent-mid);
}
.qz-shared-title { font-size: 24px; font-weight: 800; letter-spacing: -0.03em; margin-top: 8px; }
.qz-shared-meta { font-size: 14px; color: var(--text-2); }
.qz-shared-creator-score {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--r-md);
  background: var(--bg-card); border: 1px solid var(--border);
  font-size: 13px; color: var(--text-2); margin-top: 8px;
}
.qz-shared-creator-pct { font-size: 20px; font-weight: 800; color: var(--text-1); }
.qz-shared-stats {
  display: flex; gap: 16px; font-size: 12px; color: var(--text-3);
  margin-top: 4px;
}
.qz-shared-start {
  font-size: 18px; padding: 16px 48px; margin-top: 16px;
  font-weight: 800; border-radius: 14px;
}
.qz-shared-cta { font-size: 12px; color: var(--text-3); margin-top: 12px; }
.qz-shared-lb {
  width: 300px; flex-shrink: 0;
  display: flex; flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-card);
  overflow: hidden; max-height: 100%;
}
@media (max-width: 768px) {
  .qz-shared-lb { width: 100%; max-height: 280px; }
}

/* Shared quiz results */
.qz-shared-results-layout {
  display: flex; gap: 24px; height: 100%;
  padding: var(--page-px); overflow-y: auto;
}
.qz-shared-results-left {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center;
}
.qz-shared-results-loading {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; flex: 1;
}
.qz-shared-results-content {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; width: 100%; max-width: 400px;
}
.qz-name-input {
  width: 100%; max-width: 300px; padding: 12px 16px;
  border-radius: var(--r-md); border: 2px solid var(--border);
  background: var(--bg-card); color: var(--text-1);
  font-size: 16px; font-family: inherit; text-align: center;
  font-weight: 600;
}
.qz-name-input:focus { border-color: var(--accent); outline: none; }
@media (max-width: 768px) {
  .qz-shared-results-layout { flex-direction: column; }
}

/* ═══ WAKE UP — Immersive Motivation ═══ */
.mo-wrap {
  position: relative; width: 100%; height: 100%;
  background: #000; overflow: hidden;
  user-select: none; -webkit-user-select: none;
}
.mo-particles {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 0;
}
.mo-x {
  position: absolute; top: 16px; right: 16px; z-index: 20;
  width: 40px; height: 40px; border-radius: 50%;
  border: none; background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.3s; padding: 0;
}
.mo-x:hover { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.5); }

/* Slides */
.mo-slide {
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  padding: 48px;
  opacity: 0; transition: opacity 0.7s ease;
}
.mo-slide.in { opacity: 1; }
.mo-center {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: 24px; max-width: 620px; width: 100%;
  position: relative;
}

/* Opening question */
.mo-big {
  font-size: 38px; font-weight: 500; color: rgba(255,255,255,0.9);
  letter-spacing: -0.03em; line-height: 1.3;
}
@media (max-width: 600px) { .mo-big { font-size: 26px; } }

/* Input */
.mo-input {
  width: 100% !important; max-width: 440px; padding: 16px 24px;
  border-radius: 16px; border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04); color: #fff;
  font-size: 18px; font-family: inherit; text-align: center;
  font-weight: 500; outline: none; transition: border-color 0.2s;
}
.mo-input:focus { border-color: rgba(34,197,94,0.4); }
.mo-input::placeholder { color: rgba(255,255,255,0.2); }

.mo-textarea {
  width: 100% !important; max-width: 480px; padding: 16px 24px;
  border-radius: 16px; border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04); color: #fff;
  font-size: 17px; font-family: inherit; text-align: center;
  font-weight: 500; outline: none; resize: none; line-height: 1.6;
  transition: border-color 0.2s;
}
.mo-textarea:focus { border-color: rgba(34,197,94,0.4); }
.mo-textarea::placeholder { color: rgba(255,255,255,0.15); }

.mo-next {
  width: 52px; height: 52px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.15); background: rgba(255,255,255,0.06);
  color: #fff; cursor: pointer; transition: all 0.2s;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; padding: 0;
  font-size: 24px; line-height: 1;
}
.mo-next:hover { background: rgba(34,197,94,0.15); border-color: rgba(34,197,94,0.4); }

/* Stats (mirror phase) */
.mo-stat {
  font-size: 18px; color: rgba(255,255,255,0.4); font-weight: 500;
}
.mo-num {
  font-size: 56px; font-weight: 800; display: block;
  letter-spacing: -0.05em; line-height: 1.1;
  background: linear-gradient(135deg, #fff 50%, var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.mo-num.mo-warn {
  background: linear-gradient(135deg, #fff 50%, #f43f5e);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.mo-stat-sub { font-size: 15px; color: rgba(255,255,255,0.15); margin-top: 10px; }

/* Barrier question */
.mo-q {
  font-size: 30px; font-weight: 500; color: rgba(255,255,255,0.9);
  letter-spacing: -0.02em; line-height: 1.3;
}
.mo-choices { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 380px; }
.mo-choice {
  padding: 14px 22px; border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.08); background: rgba(255,255,255,0.03);
  color: rgba(255,255,255,0.5); font-size: 16px; font-weight: 600;
  font-family: inherit; cursor: pointer; transition: all 0.2s;
  text-align: left;
}
.mo-choice:hover { border-color: rgba(255,255,255,0.15); color: rgba(255,255,255,0.8); background: rgba(255,255,255,0.05); }
.mo-choice.picked { border-color: var(--accent); color: var(--accent); background: rgba(34,197,94,0.08); }

/* Deep question */
.mo-deep-q {
  font-size: 28px; font-weight: 500; color: rgba(255,255,255,0.9);
  letter-spacing: -0.02em; line-height: 1.4;
}
@media (max-width: 600px) { .mo-deep-q { font-size: 21px; } .mo-q { font-size: 23px; } }

/* Conversation slide */
.mo-conv-slide { z-index: 6; }
.mo-conv-slide .mo-center { gap: 16px; max-width: 540px; }
.mo-ai-glow {
  position: absolute; width: 300px; height: 300px;
  border-radius: 50%; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(34,197,94,0.05) 0%, transparent 70%);
  filter: blur(60px); pointer-events: none;
  animation: moGlow 4s ease-in-out infinite alternate;
}
@keyframes moGlow { from { opacity: 0.5; transform: translate(-50%,-50%) scale(0.9); } to { opacity: 1; transform: translate(-50%,-50%) scale(1.1); } }

.mo-conv-text {
  font-size: 21px; font-weight: 400; color: rgba(255,255,255,0.85);
  letter-spacing: -0.01em;
  position: relative; text-align: center;
  display: flex; flex-direction: column; gap: 14px;
}
.mo-line {
  line-height: 1.65;
}
.mo-line-inner { opacity: 0; }
.mo-line strong { font-weight: 700; color: #fff; }
.mo-line em { font-style: italic; color: rgba(255,255,255,0.7); }
.mo-quote { color: var(--accent); font-weight: 500; }
.mo-word { opacity: 0; display: inline; transition: opacity 0.35s ease; }
.mo-word.in { opacity: 1; }

/* Reply input inside conversation */
.mo-conv-input-area {
  display: flex; gap: 8px; align-items: flex-end;
  width: 100%; max-width: 420px;
}
.mo-conv-reply {
  flex: 1; padding: 14px 20px; border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.1); background: rgba(255,255,255,0.04);
  color: #fff; font-size: 17px; font-family: inherit;
  resize: none; outline: none; line-height: 1.5; min-height: 50px;
  transition: border-color 0.2s;
}
.mo-conv-reply:focus { border-color: rgba(34,197,94,0.4); }
.mo-conv-reply::placeholder { color: rgba(255,255,255,0.15); }

/* Final closing */
.mo-final-slide .mo-center { max-width: 560px; }
.mo-final-glow {
  position: absolute; width: 400px; height: 400px;
  border-radius: 50%; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(34,197,94,0.08) 0%, transparent 70%);
  filter: blur(80px); pointer-events: none;
  animation: moGlow 3s ease-in-out infinite alternate;
}
.mo-final-text {
  font-size: 24px; font-weight: 400; color: #fff;
  letter-spacing: -0.02em;
  position: relative; text-align: center;
  display: flex; flex-direction: column; gap: 18px;
}
.mo-final-text .mo-line { line-height: 1.6; }

/* Tap hint */
.mo-tap-hint {
  font-size: 11px; color: rgba(255,255,255,0.12);
  margin-top: 24px; opacity: 0;
  transition: opacity 1s ease;
  letter-spacing: 1px; text-transform: uppercase; font-weight: 600;
}

/* Loading pulse */
.mo-loading-pulse {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); opacity: 0.6;
  animation: moPulse 1.2s ease-in-out infinite;
}
@keyframes moPulse { 0%, 100% { transform: scale(1); opacity: 0.4; } 50% { transform: scale(1.8); opacity: 0.8; } }

/* Commit */
.mo-commit-q {
  font-size: 40px; font-weight: 500; color: rgba(255,255,255,0.9);
  letter-spacing: -0.03em;
}
.mo-time-row { display: flex; gap: 16px; }
.mo-time {
  width: 86px; height: 86px; border-radius: 20px;
  border: 1.5px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.02);
  color: rgba(255,255,255,0.4); font-family: inherit;
  font-size: 11px; font-weight: 600;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  cursor: pointer; transition: all 0.25s;
}
.mo-time span {
  font-size: 26px; font-weight: 800; color: #fff;
  letter-spacing: -0.03em; line-height: 1;
}
.mo-time:hover {
  border-color: var(--accent); background: rgba(34,197,94,0.06);
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(34,197,94,0.1);
}
.mo-time.picked {
  border-color: var(--accent); background: rgba(34,197,94,0.12);
  box-shadow: 0 0 30px rgba(34,197,94,0.15);
}
.mo-time-rec { border-color: rgba(34,197,94,0.2); background: rgba(34,197,94,0.05); }
.mo-time-rec span { color: var(--accent-bright); }

/* Countdown */
.mo-countdown .mo-cd-num {
  font-size: 120px; font-weight: 800; color: #fff;
  letter-spacing: -0.06em; opacity: 0.9;
}

/* Go */
.mo-go-slide .mo-go-text {
  font-size: 64px; font-weight: 800; color: var(--accent);
  letter-spacing: -0.04em;
  text-shadow: 0 0 60px rgba(34,197,94,0.3);
}

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

/* Bottom bar with counter + dots */
.qz-bottom-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; flex-shrink: 0; margin-top: auto;
}
.qz-bottom-counter {
  font-size: 15px; font-weight: 800; color: var(--text-2);
  white-space: nowrap; letter-spacing: -0.02em;
}
.qz-timer-display {
  font-size: 12px; font-weight: 700; color: var(--text-3);
  font-variant-numeric: tabular-nums; white-space: nowrap;
  background: var(--bg-2); padding: 2px 8px; border-radius: var(--r-full);
}

/* Back button */
.qz-back-btn {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  border: none; background: none; color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; transition: all 0.15s; padding: 0;
}
.qz-back-btn:hover { background: rgba(255,255,255,0.06); color: var(--text-1); }

/* 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;
}

/* Multi-select checkbox */
.qz-opt-multi .qz-opt-check {
  width: 22px; height: 22px; border-radius: 6px;
  border: 2px solid var(--border); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.qz-opt-multi.selected .qz-opt-check {
  background: var(--accent); border-color: var(--accent);
}
.qz-opt-multi.selected .qz-opt-check::after {
  content: '\2713'; color: #fff; font-size: 13px; font-weight: 800;
}
.qz-opt-multi.selected { border-color: var(--accent-mid); background: var(--accent-dim); }
.qz-opt-multi.correct .qz-opt-check { background: #22c55e; border-color: #22c55e; }
.qz-opt-multi.correct .qz-opt-check::after { content: '\2713'; color: #fff; font-size: 13px; font-weight: 800; }
.qz-opt-multi.wrong .qz-opt-check { background: #ef4444; border-color: #ef4444; }
.qz-opt-multi.wrong .qz-opt-check::after { content: '\2717'; color: #fff; font-size: 13px; font-weight: 800; }

/* Question nav dots */
.qz-dots {
  display: flex; gap: 5px; flex-wrap: wrap;
  flex: 1; min-width: 0;
}
.qz-dot {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800;
  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: var(--side-w, 64px); 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: 1000;
}
.qz-feedback.visible { transform: translateY(0); }
@media (max-width: 768px) { .qz-feedback { left: 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: 130px; height: 130px; margin: 0 auto 8px; 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); }

/* Review nav */
.qz-review-nav {
  display: flex; gap: 6px; margin-bottom: 16px;
  position: sticky; top: 0; z-index: 5;
  background: var(--bg-1); padding: 8px 0;
}
.qz-rnav-btn {
  padding: 7px 14px; border-radius: var(--r-full);
  border: 1px solid var(--border); background: transparent;
  color: var(--text-2); font-size: 12px; font-weight: 600;
  font-family: inherit; cursor: pointer; transition: all 0.15s;
}
.qz-rnav-btn:hover { border-color: var(--accent-mid); color: var(--accent); background: var(--accent-dim); }

.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
   ═══════════════════════════════════════ */

/* Legacy .planner-* classes removed — migrated to sp-* */


/* ═══════════════════════════════════════
   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 — Redesigned
   ═══════════════════════════════════════ */

/* ── Shared: inputs, pills, spinner ── */
.sp-input {
  width: 100%; padding: 10px 14px; border-radius: var(--r-sm);
  background: var(--bg-input); border: 1px solid var(--border);
  color: var(--text-1); font-family: var(--font); font-size: 13px;
  transition: all 0.15s; outline: none;
}
.sp-input:focus { background: var(--bg-input-focus); border-color: var(--border-focus); }

.sp-pill {
  padding: 8px 16px; border-radius: var(--r-full); font-size: 12px; font-weight: 600;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-2); cursor: pointer; transition: all 0.18s var(--ease);
  font-family: var(--font); white-space: nowrap;
}
.sp-pill:hover { background: var(--bg-card-hover); border-color: var(--border-hover); }
.sp-pill.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.sp-pill-row { display: flex; gap: 6px; flex-wrap: wrap; }
.sp-pill-wrap { flex-wrap: wrap; }

.sp-spinner-sm {
  width: 14px; height: 14px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spSpin 0.6s linear infinite;
}
@keyframes spSpin { to { transform: rotate(360deg); } }

.sp-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--r-sm);
  background: var(--bg-card); border: 1px solid var(--border);
  cursor: pointer; transition: all 0.18s var(--ease); font-family: var(--font);
  font-size: 12px; font-weight: 600; color: var(--text-2);
}
.sp-chip:hover { background: var(--bg-card-hover); border-color: var(--border-hover); }
.sp-chip.active { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }
.sp-chip-dot { width: 8px; height: 8px; border-radius: 3px; flex-shrink: 0; }
.sp-chip-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* ── Landing Page ── */
.sp-landing {
  max-width: 440px; margin: 0 auto; padding: 40px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 20px;
}
.sp-landing-header { text-align: center; }
.sp-landing-icon {
  width: 56px; height: 56px; margin: 0 auto 14px;
  background: var(--accent-dim); border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
}
.sp-landing-icon svg { width: 28px; height: 28px; }
.sp-landing-title {
  font-size: 24px; font-weight: 800; letter-spacing: -0.04em;
  color: var(--text-1); margin-bottom: 6px;
}
.sp-landing-sub { font-size: 13px; color: var(--text-2); line-height: 1.6; max-width: 320px; }

.sp-drop-zone { width: 100%; cursor: pointer; }
.sp-drop-inner {
  padding: 36px 24px; border: 2px dashed var(--border);
  border-radius: var(--r-lg); text-align: center;
  transition: all 0.25s var(--ease); background: var(--bg-card);
}
.sp-drop-zone:hover .sp-drop-inner,
.sp-drop-zone.sp-drop-active .sp-drop-inner {
  border-color: var(--accent); background: var(--accent-dim);
}
.sp-drop-zone.sp-drop-active .sp-drop-inner { animation: spDropPulse 1s ease-in-out infinite; }
.sp-drop-zone.sp-drop-processing .sp-drop-inner { opacity: 0.4; pointer-events: none; }

@keyframes spDropPulse {
  0%, 100% { border-color: var(--accent); box-shadow: 0 0 0 0 rgba(34,197,94,0.15); }
  50% { border-color: var(--accent-bright); box-shadow: 0 0 0 8px rgba(34,197,94,0); }
}

.sp-drop-icon {
  width: 40px; height: 40px; margin: 0 auto 10px;
  color: var(--text-3); transition: color 0.2s;
}
.sp-drop-zone:hover .sp-drop-icon,
.sp-drop-zone.sp-drop-active .sp-drop-icon { color: var(--accent); }
.sp-drop-icon svg { width: 40px; height: 40px; }
.sp-drop-text { font-size: 14px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.sp-drop-hint { font-size: 11px; color: var(--text-3); }

.sp-file-preview { width: 100%; animation: spSlideUp 0.3s var(--ease); }
.sp-file-preview.hidden { display: none; }
.sp-file-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: var(--r-md);
  background: var(--bg-card); border: 1px solid var(--glass-card-border);
}
.sp-file-icon { flex-shrink: 0; }
.sp-file-info { flex: 1; min-width: 0; }
.sp-file-name { font-size: 13px; font-weight: 600; color: var(--text-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-file-size { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.sp-file-status { flex-shrink: 0; }

.sp-landing-divider {
  width: 100%; text-align: center; position: relative;
  color: var(--text-3); font-size: 12px;
}
.sp-landing-divider::before, .sp-landing-divider::after {
  content: ''; position: absolute; top: 50%; width: calc(50% - 20px);
  height: 1px; background: var(--border);
}
.sp-landing-divider::before { left: 0; }
.sp-landing-divider::after { right: 0; }

.sp-blank-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 24px; border-radius: var(--r-full);
  background: transparent; border: 1px solid var(--border);
  color: var(--text-2); font-size: 13px; font-weight: 600;
  font-family: var(--font); cursor: pointer; transition: all 0.18s var(--ease);
}
.sp-blank-btn:hover { background: var(--bg-card); border-color: var(--border-hover); color: var(--text-1); }

@keyframes spSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Parsing Phase ── */
.sp-parsing {
  display: flex; align-items: center; justify-content: center;
  min-height: 60vh; padding: 20px;
}
.sp-parse-card {
  max-width: 360px; width: 100%; padding: 32px 28px;
  background: var(--bg-card); border: 1px solid var(--glass-card-border);
  border-radius: var(--r-xl); text-align: center;
}
.sp-parse-file {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px; border-radius: var(--r-full);
  background: var(--bg-input); font-size: 12px; font-weight: 600;
  color: var(--text-2); margin-bottom: 28px;
}
.sp-parse-size { color: var(--text-3); }

.sp-parse-steps { display: flex; flex-direction: column; gap: 16px; text-align: left; margin-bottom: 24px; }
.sp-parse-step {
  display: flex; align-items: center; gap: 12px;
  font-size: 13px; font-weight: 500; color: var(--text-3);
  transition: color 0.3s;
}
.sp-parse-step.done { color: var(--text-1); }
.sp-parse-dot {
  width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sp-parse-step.done .sp-parse-dot svg { animation: spCheckDraw 0.3s var(--ease); }

@keyframes spCheckDraw {
  from { stroke-dashoffset: 24; stroke-dasharray: 24; }
  to { stroke-dashoffset: 0; stroke-dasharray: 24; }
}

.sp-parse-bar {
  height: 3px; background: var(--border); border-radius: 2px; overflow: hidden;
}
.sp-parse-bar-fill {
  height: 100%; background: var(--accent); border-radius: 2px;
  width: 5%; transition: width 0.8s var(--ease);
}

.sp-parse-error {
  display: flex; align-items: center; gap: 8px; margin-top: 16px;
  padding: 10px 14px; border-radius: var(--r-sm);
  background: var(--danger-dim); border: 1px solid var(--danger-border);
  font-size: 12px; color: var(--danger);
}

/* ── Exam Selection Phase ── */
.sp-exams {
  max-width: 520px; margin: 0 auto; padding: 20px;
  display: flex; flex-direction: column; height: 100%;
}
.sp-exams-header { margin-bottom: 16px; }
.sp-exams-title { font-size: 22px; font-weight: 800; letter-spacing: -0.04em; }
.sp-exams-sub { font-size: 13px; color: var(--text-2); margin-top: 4px; }

.sp-exams-list { flex: 1; overflow-y: auto; padding-bottom: 16px; }

.sp-exam-group { margin-bottom: 14px; animation: spFadeIn 0.35s var(--ease) both; }
.sp-exam-date-hdr {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 0 8px; font-size: 11px; font-weight: 700;
  color: var(--text-3); text-transform: uppercase; letter-spacing: 0.5px;
}
.sp-exam-date-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0;
}

.sp-exam-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--r-md);
  background: var(--bg-card); border: 1px solid var(--glass-card-border);
  cursor: pointer; transition: all 0.18s var(--ease); margin-bottom: 6px;
  animation: spFadeIn 0.35s var(--ease) both;
}
.sp-exam-card:hover { background: var(--bg-card-hover); border-color: var(--border-hover); }
.sp-exam-cb { display: none; }

.sp-exam-tick {
  width: 22px; height: 22px; border-radius: 7px;
  border: 2px solid rgba(255,255,255,0.12); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s var(--ease-spring);
}
.sp-exam-cb:checked + .sp-exam-tick {
  background: var(--c, var(--accent)); border-color: var(--c, var(--accent));
  transform: scale(1.05);
}
.sp-exam-cb:checked + .sp-exam-tick::after {
  content: ''; width: 5px; height: 9px;
  border: solid #fff; border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg); margin-top: -2px;
}
.sp-exam-cb:not(:checked) + .sp-exam-tick { transform: scale(0.95); }

.sp-exam-info { flex: 1; min-width: 0; }
.sp-exam-name { font-size: 13px; font-weight: 600; color: var(--text-1); }
.sp-exam-meta { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.sp-exam-subj-icon { flex-shrink: 0; opacity: 0.5; }

@keyframes spFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.sp-exams-footer {
  padding-top: 12px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 10px; flex-shrink: 0;
}
.sp-exams-actions { display: flex; gap: 6px; }
.sp-action-pill {
  padding: 6px 14px; border-radius: var(--r-full); font-size: 11px; font-weight: 600;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-3); cursor: pointer; transition: all 0.15s; font-family: var(--font);
}
.sp-action-pill:hover { color: var(--text-1); border-color: var(--border-hover); }
.sp-exams-go {
  width: 100%; padding: 14px; font-size: 14px; font-weight: 700;
  border-radius: var(--r-md);
}

/* ── Preferences Phase ── */
.sp-prefs {
  max-width: 480px; margin: 0 auto; padding: 20px;
  display: flex; flex-direction: column; height: 100%;
}
.sp-prefs-header { margin-bottom: 20px; }
.sp-prefs-title { font-size: 22px; font-weight: 800; letter-spacing: -0.04em; }
.sp-prefs-sub { font-size: 13px; color: var(--text-2); margin-top: 4px; }

.sp-prefs-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 20px; padding-bottom: 16px; }

.sp-pref-section { }
.sp-pref-label {
  display: block; font-size: 12px; font-weight: 700; color: var(--text-2);
  text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 8px;
}
.sp-pref-hint { font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--text-3); }

.sp-slider-row { display: flex; align-items: center; gap: 12px; }
.sp-range {
  flex: 1; -webkit-appearance: none; appearance: none;
  height: 4px; background: var(--border); border-radius: 2px; outline: none;
}
.sp-range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px;
  background: var(--accent); border-radius: 50%;
  cursor: pointer; box-shadow: var(--accent-glow-sm);
}
.sp-range-val { font-size: 16px; font-weight: 800; color: var(--accent); width: 30px; text-align: center; }

.sp-days-row { display: flex; gap: 4px; }
.sp-day-btn {
  flex: 1; padding: 10px 4px; border-radius: var(--r-sm); font-size: 11px; font-weight: 600;
  background: var(--bg-card); border: 1px solid var(--border);
  cursor: pointer; transition: all 0.18s var(--ease); font-family: var(--font);
  color: var(--text-2); text-align: center;
}
.sp-day-btn:hover { background: var(--bg-card-hover); border-color: var(--border-hover); }
.sp-day-btn.active { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }

.sp-prefs-footer { padding-top: 12px; border-top: 1px solid var(--border); flex-shrink: 0; }
.sp-build-btn {
  width: 100%; padding: 14px; font-size: 14px; font-weight: 700;
  border-radius: var(--r-md); box-shadow: var(--accent-glow-btn);
  transition: all 0.2s var(--ease);
}
.sp-build-btn:hover { transform: translateY(-1px); box-shadow: var(--accent-glow), 0 4px 16px rgba(0,0,0,0.3); }

/* ── Generating Phase ── */
.sp-generating {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 60vh; padding: 20px; gap: 24px;
}
.sp-gen-ring {
  width: 80px; height: 80px; border-radius: 50%;
  background: conic-gradient(var(--accent), var(--accent-dim), transparent);
  display: flex; align-items: center; justify-content: center;
  animation: spGenSpin 1.2s linear infinite;
}
.sp-gen-ring-inner {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--bg-base);
}
@keyframes spGenSpin { to { transform: rotate(360deg); } }

.sp-gen-title {
  font-size: 18px; font-weight: 700; letter-spacing: -0.03em;
  color: var(--text-1); text-align: center;
}
.sp-gen-steps { display: flex; flex-direction: column; gap: 10px; }
.sp-gen-step {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 500; color: var(--text-3);
  opacity: 0; transform: translateY(8px);
  transition: all 0.35s var(--ease);
}
.sp-gen-step.done { opacity: 1; transform: translateY(0); color: var(--text-2); }
.sp-gen-check {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent-dim); display: flex; align-items: center; justify-content: center;
  transition: background 0.3s;
}
.sp-gen-step.done .sp-gen-check {
  background: var(--accent);
}
.sp-gen-step.done .sp-gen-check::after {
  content: ''; width: 4px; height: 7px;
  border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(45deg); margin-top: -1px;
}

/* ── Calendar Phase ── */
.sp-cal {
  display: flex; flex-direction: column; padding: 12px 16px; gap: 0; overflow: hidden;
}

.sp-cal-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 4px 12px; gap: 16px;
}
.sp-cal-greeting { flex: 1; min-width: 0; }
.sp-cal-greeting-title {
  font-size: 16px; font-weight: 700; letter-spacing: -0.02em;
  color: var(--text-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sp-cal-greeting-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.sp-cal-progress { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.sp-cal-progress-ring { flex-shrink: 0; }
.sp-cal-progress-text { display: flex; flex-direction: column; gap: 1px; }
.sp-cal-progress-pct { font-size: 18px; font-weight: 800; color: var(--accent); letter-spacing: -0.02em; }
.sp-cal-progress-label { font-size: 10px; color: var(--text-3); font-weight: 600; }

.sp-cal-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0 10px; flex-shrink: 0;
}
.sp-cal-nav { display: flex; align-items: center; gap: 4px; }
.sp-nav-btn {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  background: var(--bg-card); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.15s; color: var(--text-2);
}
.sp-nav-btn:hover { background: var(--bg-card-hover); border-color: var(--border-hover); color: var(--text-1); }
.sp-nav-today {
  padding: 6px 12px; border-radius: var(--r-full); font-size: 11px; font-weight: 700;
  background: var(--accent-dim); border: 1px solid rgba(34,197,94,0.2);
  color: var(--accent); cursor: pointer; transition: all 0.15s; font-family: var(--font);
}
.sp-nav-today:hover { background: var(--accent-mid); }
.sp-cal-week-label { font-size: 13px; font-weight: 700; letter-spacing: -0.02em; color: var(--text-2); margin-left: 10px; }

.sp-cal-actions { display: flex; gap: 4px; }
.sp-cal-action-btn {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 10px; border-radius: var(--r-sm); font-size: 11px; font-weight: 600;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-2); cursor: pointer; transition: all 0.15s; font-family: var(--font);
}
.sp-cal-action-btn:hover { background: var(--bg-card-hover); border-color: var(--border-hover); }
.sp-cal-danger-btn { border-color: rgba(239,68,68,0.2); color: var(--danger); }
.sp-cal-danger-btn:hover { background: var(--danger-dim); border-color: var(--danger-border); }

/* Insights bar */
.sp-insights-bar {
  display: flex; gap: 8px; padding: 0 0 10px; flex-shrink: 0; overflow-x: auto;
}
.sp-insight {
  padding: 8px 14px; border-radius: var(--r-sm);
  background: var(--bg-card); border: 1px solid var(--glass-card-border);
  min-width: 200px; flex-shrink: 0;
}
.sp-insight-title { display: block; font-size: 11px; font-weight: 700; color: var(--text-1); }
.sp-insight-detail { display: block; font-size: 10px; color: var(--text-3); margin-top: 2px; }

/* ── 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: var(--bg-card); border: 1px solid var(--glass-card-border);
  border-radius: var(--r-md); overflow: hidden; min-height: 0;
  transition: border-color 0.2s;
}
.sp-week-col.sp-today { border-color: rgba(34,197,94,0.18); background: rgba(34,197,94,0.02); }
.sp-week-col.sp-exam-day { border-top: 2px solid rgba(239,68,68,0.35); }

.sp-week-hdr {
  padding: 8px 8px 6px; text-align: center;
  border-bottom: 1px solid var(--border-subtle); flex-shrink: 0;
}
.sp-week-day-name { font-size: 9px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.6px; }
.sp-week-day-num { font-size: 17px; 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.9;
}
.sp-week-count { font-size: 9px; color: var(--text-3); margin-top: 2px; font-weight: 600; }

.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.06); border-radius: 1px; }

/* ── Task Cards ── */
.sp-task {
  display: flex; align-items: flex-start; gap: 6px;
  padding: 5px 6px; border-radius: 6px;
  cursor: pointer; transition: all 0.15s var(--ease);
  position: relative; overflow: hidden;
}
.sp-task:hover { background: rgba(255,255,255,0.035); }
.sp-task-done { opacity: 0.3; }
.sp-task-completing {
  animation: spTaskComplete 0.3s var(--ease) forwards;
}
@keyframes spTaskComplete {
  0% { transform: scale(1); }
  40% { transform: scale(0.96); opacity: 0.5; }
  100% { transform: scale(0.96); opacity: 0.3; }
}

.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.2s var(--ease-spring);
}
.sp-task-check:hover { transform: scale(1.15); }
.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-icon {
  width: 18px; height: 18px; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; color: var(--text-2); opacity: 0.6;
}
.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 */
.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: 1.5px 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.08);
  background: transparent; display: flex; align-items: center; justify-content: center;
  color: var(--text-3); cursor: pointer; transition: all 0.18s var(--ease);
  border-radius: 5px; font-family: var(--font); margin-top: auto;
}
.sp-week-add:hover { background: rgba(34,197,94,0.06); border-color: rgba(34,197,94,0.25); 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; }
  .sp-cal-top { flex-direction: column; align-items: stretch; gap: 8px; }
  .sp-cal-progress { align-self: flex-start; }
  .sp-cal-toolbar { flex-wrap: wrap; gap: 6px; }
  .sp-cal-week-label { font-size: 12px; }
  .sp-landing { padding: 24px 16px; }
  .sp-landing-title { font-size: 20px; }
  .sp-prefs { padding: 16px; }
  .sp-exams { padding: 16px; }

  /* 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;
}

/* ═══════════════════════════════════════════════════════════════════════════
   ACTIVITY — topbar dropdown + full page
   ═══════════════════════════════════════════════════════════════════════════ */
.activity-panel{
  background:rgba(18,18,24,0.72);
  backdrop-filter:blur(24px) saturate(1.4);
  -webkit-backdrop-filter:blur(24px) saturate(1.4);
  border:1px solid rgba(255,255,255,0.08);
  border-radius:16px;
  box-shadow:0 24px 60px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.04) inset;
  overflow:hidden; display:flex; flex-direction:column;
  animation:actPanelIn 0.18s var(--ease);
}
@supports not ((backdrop-filter:blur(1px)) or (-webkit-backdrop-filter:blur(1px))){
  .activity-panel{ background:var(--bg-card); }
}
@keyframes actPanelIn{
  from{opacity:0;transform:translateY(-6px) scale(0.98)}
  to{opacity:1;transform:translateY(0) scale(1)}
}
.act-panel-header{
  display:flex;align-items:center;justify-content:space-between;
  padding:14px 16px;border-bottom:1px solid rgba(255,255,255,0.06);
}
.act-panel-title{font-size:13px;font-weight:800;letter-spacing:-0.01em}
.act-panel-open{
  font-size:11px;font-weight:700;color:var(--accent);
  background:transparent;border:none;cursor:pointer;padding:2px 6px;border-radius:6px;
}
.act-panel-open:hover{background:var(--accent-dim)}
.act-panel-empty{
  padding:20px;color:var(--text-3);font-size:12px;text-align:center;line-height:1.5;
}
.act-panel-totals{display:flex;gap:10px;padding:14px 16px;border-bottom:1px solid rgba(255,255,255,0.06)}
.act-total{
  flex:1;padding:12px 8px;border-radius:12px;
  background:rgba(255,255,255,0.04);border:1px solid rgba(255,255,255,0.06);
  display:flex;flex-direction:column;align-items:center;gap:4px;
  transition:background 0.15s, border-color 0.15s;
}
.act-total:hover{background:rgba(255,255,255,0.07);border-color:rgba(255,255,255,0.1)}
.act-total svg{width:14px;height:14px;color:var(--acc)}
.act-total-num{font-size:18px;font-weight:800;letter-spacing:-0.02em;color:var(--text-1);font-variant-numeric:tabular-nums}
.act-total-label{font-size:9px;text-transform:uppercase;letter-spacing:0.08em;color:var(--text-3);font-weight:700}
.act-panel-list{overflow-y:auto;padding:4px 0;flex:1}
.act-panel-row{
  display:flex;flex-direction:column;gap:4px;
  padding:10px 14px;cursor:pointer;transition:background 0.1s;
  text-decoration:none;color:inherit;
}
.act-panel-row:hover{background:rgba(255,255,255,0.03)}
.act-panel-row-title{font-size:12px;font-weight:600;color:var(--text-1);line-height:1.35;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.act-panel-row-stats{display:flex;gap:12px;color:var(--text-3);font-size:11px;font-variant-numeric:tabular-nums}
.act-stat{display:inline-flex;align-items:center;gap:4px}

.activity-wrap{max-width:960px;margin:0 auto;padding:20px 16px 40px}
.activity-loading,.activity-empty{padding:40px 16px;text-align:center;color:var(--text-3);font-size:13px}
.activity-hero{margin-bottom:20px}
.activity-hero h2{font-size:24px;font-weight:800;letter-spacing:-0.03em;margin:0 0 4px}
.activity-hero p{color:var(--text-2);font-size:13px;margin:0}
.activity-totals{
  display:grid;grid-template-columns:repeat(4,1fr);gap:12px;margin-bottom:24px;
}
@media (max-width:700px){.activity-totals{grid-template-columns:repeat(2,1fr)}}
.activity-tile{
  padding:18px 16px;border-radius:14px;
  background:var(--bg-card);border:1px solid var(--border);
  display:flex;flex-direction:column;gap:4px;position:relative;overflow:hidden;
  transition:border-color 0.15s;
}
.activity-tile::before{
  content:'';position:absolute;top:0;left:0;right:0;height:2px;
  background:var(--acc);opacity:0.6;
}
.activity-tile:hover{border-color:var(--border-hover)}
.activity-tile-icn{color:var(--acc);margin-bottom:4px}
.activity-tile-icn svg{width:18px;height:18px}
.activity-tile-num{font-size:28px;font-weight:800;letter-spacing:-0.03em;color:var(--text-1);font-variant-numeric:tabular-nums;line-height:1}
.activity-tile-label{font-size:11px;color:var(--text-3);font-weight:600;text-transform:uppercase;letter-spacing:0.06em;margin-top:2px}

.activity-list-label{font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:0.1em;color:var(--text-3);margin-bottom:10px}
.activity-list{display:flex;flex-direction:column;gap:8px}
.activity-card{
  padding:14px 16px;border-radius:12px;
  background:var(--bg-card);border:1px solid var(--border);
  display:flex;align-items:center;justify-content:space-between;gap:16px;
  cursor:pointer;transition:all 0.15s;
}
.activity-card:hover{border-color:var(--border-hover);transform:translateY(-1px)}
.activity-card-main{flex:1;min-width:0}
.activity-card-title{font-size:13px;font-weight:600;color:var(--text-1);line-height:1.4;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.activity-card-date{font-size:10px;color:var(--text-3);margin-top:2px}
.activity-card-stats{display:flex;gap:14px;flex-shrink:0}
.activity-stat{display:inline-flex;align-items:center;gap:4px;font-size:11px;font-variant-numeric:tabular-nums}
.activity-stat-dot{width:6px;height:6px;border-radius:50%}
.activity-stat-num{font-weight:800;color:var(--text-1)}
.activity-stat-label{color:var(--text-3);font-size:10px}
.activity-empty-card{
  padding:32px 20px;border-radius:14px;border:1px dashed var(--border);
  text-align:center;color:var(--text-2);
}
.activity-empty-title{font-size:16px;font-weight:700;margin-bottom:4px}
.activity-empty-sub{font-size:12px;color:var(--text-3);line-height:1.5}

/* ═══════════════════════════════════════════════════════════════════════════
   SHARED QUIZ — social block (likes, views, comments)
   ═══════════════════════════════════════════════════════════════════════════ */
.sq-social{
  margin-top:18px;padding:16px 18px;
  border-radius:16px;
  border:1px solid rgba(255,255,255,0.08);
  background:rgba(255,255,255,0.03);
  backdrop-filter:blur(16px) saturate(1.3);
  -webkit-backdrop-filter:blur(16px) saturate(1.3);
  box-shadow:0 12px 32px rgba(0,0,0,0.25), 0 0 0 1px rgba(255,255,255,0.03) inset;
}
@supports not ((backdrop-filter:blur(1px)) or (-webkit-backdrop-filter:blur(1px))){
  .sq-social{ background:var(--bg-card); }
}
.sq-social-bar{
  display:flex;align-items:center;gap:16px;flex-wrap:wrap;
  padding-bottom:12px;border-bottom:1px solid var(--border-subtle);margin-bottom:12px;
}
.sq-like-btn{
  display:inline-flex;align-items:center;gap:6px;
  padding:6px 12px;border-radius:var(--r-full);
  background:transparent;border:1px solid var(--border);
  color:var(--text-2);font-size:12px;font-weight:700;font-family:inherit;cursor:pointer;
  transition:all 0.15s;
}
.sq-like-btn svg{width:14px;height:14px;transition:transform 0.2s;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.sq-like-btn:hover{border-color:#f43f5e;color:#f43f5e;background:rgba(244,63,94,0.06)}
.sq-like-btn.liked{border-color:#f43f5e;color:#fff;background:#f43f5e}
.sq-like-btn.liked svg{fill:#fff;animation:likePop 0.35s var(--ease)}
@keyframes likePop{0%{transform:scale(1)}40%{transform:scale(1.35)}100%{transform:scale(1)}}
.sq-social-meta{display:inline-flex;gap:16px;color:var(--text-3);font-size:12px;font-variant-numeric:tabular-nums}
.sq-social-meta span{display:inline-flex;align-items:center;gap:5px}
.sq-social-meta svg{width:13px;height:13px}

.sq-comments-title{font-size:13px;font-weight:800;margin-bottom:10px;letter-spacing:-0.01em}
.sq-comment-form{display:flex;flex-direction:column;gap:8px;margin-bottom:16px}
.sq-comment-input{
  width:100%;min-height:44px;resize:vertical;max-height:140px;
  padding:10px 12px;border-radius:10px;
  background:var(--bg-input);border:1px solid var(--border);color:var(--text-1);
  font-family:inherit;font-size:13px;line-height:1.4;
}
.sq-comment-input:focus{outline:none;border-color:var(--accent)}
.sq-comment-row{display:flex;justify-content:space-between;align-items:center;gap:8px}
.sq-comment-count{font-size:11px;color:var(--text-3);font-variant-numeric:tabular-nums}
.sq-comment-count.over{color:var(--danger)}
.sq-comment-submit{
  padding:6px 14px;border-radius:var(--r-full);
  background:var(--accent);color:#000;border:none;cursor:pointer;
  font-weight:700;font-size:12px;font-family:inherit;transition:opacity 0.15s;
}
.sq-comment-submit:disabled{opacity:0.5;cursor:not-allowed}
.sq-comments-list{display:flex;flex-direction:column;gap:10px}
.sq-comment{display:flex;gap:10px;padding:10px 0;border-bottom:1px solid var(--border-subtle)}
.sq-comment:last-child{border-bottom:none}
.sq-comment-avatar{
  width:28px;height:28px;border-radius:50%;flex-shrink:0;
  background:var(--accent-dim);color:var(--accent);
  display:flex;align-items:center;justify-content:center;
  font-size:11px;font-weight:800;overflow:hidden;
}
.sq-comment-avatar img{width:100%;height:100%;object-fit:cover}
.sq-comment-body{flex:1;min-width:0}
.sq-comment-head{display:flex;align-items:baseline;gap:8px;margin-bottom:2px}
.sq-comment-author{font-size:12px;font-weight:700;color:var(--text-1)}
.sq-comment-time{font-size:10px;color:var(--text-3)}
.sq-comment-text{font-size:13px;color:var(--text-1);line-height:1.5;word-break:break-word;white-space:pre-wrap}
.sq-comment-actions{display:flex;gap:12px;margin-top:4px}
.sq-comment-action{
  background:transparent;border:none;cursor:pointer;
  font-size:10px;color:var(--text-3);font-family:inherit;font-weight:600;
  padding:0;transition:color 0.15s;
}
.sq-comment-action:hover{color:var(--text-1)}
.sq-comment-action.danger:hover{color:var(--danger)}
.sq-comments-empty{padding:20px;text-align:center;color:var(--text-3);font-size:12px}
.sq-comments-loadmore{
  align-self:center;margin-top:12px;padding:6px 16px;border-radius:var(--r-full);
  background:transparent;border:1px solid var(--border);
  color:var(--text-2);font-size:11px;font-weight:700;font-family:inherit;cursor:pointer;
}
.sq-comments-loadmore:hover{border-color:var(--border-hover);color:var(--text-1)}
