/* ═══════════════════════════════════════════════════════════
   QUIZ BUZZERS — Question Bank
   Custom CSS — Dark/Light Theme
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700;900&family=DM+Mono:wght@300;400;500&family=DM+Sans:wght@300;400;500;600&display=swap');

:root {
  --bg-base:       #0e0f14;
  --bg-surface:    #15161d;
  --bg-elevated:   #1c1e28;
  --bg-hover:      #23253200;
  --bg-row-alt:    #13141a;
  --bg-row-hover:  #1e2130;

  --accent:        #f0a500;
  --accent-dim:    #c48400;
  --accent-glow:   rgba(240,165,0,0.15);
  --accent-text:   #fff8e6;

  --text-primary:  #e8eaf0;
  --text-secondary:#8b90a8;
  --text-muted:    #4a4f66;
  --text-inverse:  #0e0f14;

  --border:        rgba(255,255,255,0.07);
  --border-strong: rgba(255,255,255,0.14);

  --correct:       #22c55e;
  --incorrect:     #ef4444;
  --correct-bg:    rgba(34,197,94,0.1);
  --incorrect-bg:  rgba(239,68,68,0.1);

  --info-accent:   #38bdf8;
  --info-bg:       rgba(56,189,248,0.08);
  --info-border:   rgba(56,189,248,0.25);

  /* Audio icon / player */
  --audio-accent:  #10b981;
  --audio-bg:      rgba(16,185,129,0.09);
  --audio-border:  rgba(16,185,129,0.28);

  /* Local image icon / popup */
  --localimg-accent: #a78bfa;
  --localimg-bg:     rgba(167,139,250,0.09);
  --localimg-border: rgba(167,139,250,0.28);

  /* TTS / language badges */
  --tts-accent:    #f59e0b;
  --tts-bg:        rgba(245,158,11,0.09);
  --tts-border:    rgba(245,158,11,0.28);

  --shadow-sm:     0 2px 8px rgba(0,0,0,0.4);
  --shadow-md:     0 4px 20px rgba(0,0,0,0.5);
  --shadow-lg:     0 8px 40px rgba(0,0,0,0.6);
  --shadow-tooltip:0 8px 32px rgba(0,0,0,0.7), 0 2px 8px rgba(0,0,0,0.5);

  --font-display:  'Playfair Display', Georgia, serif;
  --font-body:     'DM Sans', system-ui, sans-serif;
  --font-mono:     'DM Mono', 'Courier New', monospace;

  --radius-sm:     6px;
  --radius-md:     10px;
  --radius-lg:     16px;

  --transition:    0.18s ease;
}

[data-theme="light"] {
  --bg-base:       #f4f5f9;
  --bg-surface:    #ffffff;
  --bg-elevated:   #f0f1f7;
  --bg-row-alt:    #f8f9fc;
  --bg-row-hover:  #eef0f8;

  --accent:        #d4890a;
  --accent-dim:    #b37208;
  --accent-glow:   rgba(212,137,10,0.12);
  --accent-text:   #3d2000;

  --text-primary:  #1a1c2e;
  --text-secondary:#505470;
  --text-muted:    #9499b8;
  --text-inverse:  #ffffff;

  --border:        rgba(0,0,0,0.08);
  --border-strong: rgba(0,0,0,0.16);

  --shadow-sm:     0 2px 8px rgba(0,0,0,0.08);
  --shadow-md:     0 4px 20px rgba(0,0,0,0.12);
  --shadow-lg:     0 8px 40px rgba(0,0,0,0.16);
  --shadow-tooltip:0 8px 32px rgba(0,0,0,0.2), 0 2px 8px rgba(0,0,0,0.1);

  --info-accent:   #0284c7;
  --info-bg:       rgba(2,132,199,0.07);
  --info-border:   rgba(2,132,199,0.22);

  --audio-accent:  #059669;
  --audio-bg:      rgba(5,150,105,0.07);
  --audio-border:  rgba(5,150,105,0.22);

  --localimg-accent: #7c3aed;
  --localimg-bg:     rgba(124,58,237,0.07);
  --localimg-border: rgba(124,58,237,0.22);

  --tts-accent:    #d97706;
  --tts-bg:        rgba(217,119,6,0.07);
  --tts-border:    rgba(217,119,6,0.22);
}

/* ── RESET & BASE ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  transition: background var(--transition), color var(--transition);
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }


/* ═══════════════════════════════════
   HEADER
   ═══════════════════════════════════ */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-sm);
}
.header-left { display: flex; align-items: center; gap: 14px; }
.logo-mark {
  width: 40px; height: 40px;
  background: var(--accent); color: var(--text-inverse);
  font-family: var(--font-display); font-size: 15px; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); letter-spacing: -0.5px; flex-shrink: 0;
}
.site-title {
  font-family: var(--font-display); font-size: 1.35rem; font-weight: 700;
  color: var(--text-primary); letter-spacing: -0.3px; line-height: 1.1;
}
.site-subtitle {
  font-family: var(--font-mono); font-size: 0.7rem;
  color: var(--text-secondary); letter-spacing: 0.1em; text-transform: uppercase;
}
.header-right { display: flex; align-items: center; gap: 10px; }
.stats-pill {
  font-family: var(--font-mono); font-size: 0.75rem;
  color: var(--accent); background: var(--accent-glow);
  border: 1px solid var(--accent-dim); padding: 4px 12px; border-radius: 999px;
}
.icon-btn {
  width: 36px; height: 36px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-secondary);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 1rem; transition: all var(--transition);
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }
.theme-icon { line-height: 1; }


/* ═══════════════════════════════════
   TOOLBAR
   ═══════════════════════════════════ */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 28px; background: var(--bg-surface);
  border-bottom: 1px solid var(--border); gap: 12px; flex-wrap: wrap;
}
.mode-tabs { display: flex; gap: 4px; }
.mode-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent;
  color: var(--text-secondary); font-family: var(--font-body);
  font-size: 0.85rem; font-weight: 500; cursor: pointer;
  transition: all var(--transition);
}
.mode-tab:hover { background: var(--bg-elevated); color: var(--text-primary); }
.mode-tab.active { background: var(--accent-glow); border-color: var(--accent); color: var(--accent); }
.tab-icon { font-size: 0.9rem; }
.toolbar-right { display: flex; gap: 8px; }
.action-btn {
  padding: 7px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--bg-elevated);
  color: var(--text-secondary); font-family: var(--font-body);
  font-size: 0.82rem; font-weight: 500; cursor: pointer;
  transition: all var(--transition); white-space: nowrap;
}
.action-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }
.action-btn:active { transform: scale(0.97); }

/* Thin vertical divider between toolbar button groups */
.toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border-strong);
  align-self: center;
  flex-shrink: 0;
}

/* Buttons that only make sense in table mode */
.tbl-only-btn { display: none; }
.tbl-mode-active .tbl-only-btn { display: flex; }

/* Active / toggled-on state for toolbar toggle buttons */
.action-btn.toggle-active {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
}
.action-btn#readAllBtn.toggle-active {
  background: var(--tts-bg);
  border-color: var(--tts-accent);
  color: var(--tts-accent);
}


/* ═══════════════════════════════════
   FILTERS BAR
   ═══════════════════════════════════ */
.filters-bar {
  display: flex; align-items: flex-end; gap: 12px;
  padding: 14px 28px; background: var(--bg-surface);
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-label {
  font-family: var(--font-mono); font-size: 0.65rem;
  text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted);
}
.filter-input, .filter-select {
  height: 34px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--bg-elevated);
  color: var(--text-primary); font-family: var(--font-body);
  font-size: 0.84rem; padding: 0 10px; transition: border-color var(--transition); outline: none;
}
.filter-input:focus, .filter-select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow);
}
.filter-select {
  padding-right: 28px; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238b90a8'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}
.search-wrap { position: relative; }
.search-input { width: 240px; padding-right: 28px; }
.search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-size: 0.75rem; color: var(--text-muted); cursor: pointer; display: none;
}
.search-clear.visible { display: block; }
.search-clear:hover { color: var(--accent); }
.clear-btn {
  height: 34px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: transparent;
  color: var(--text-muted); font-family: var(--font-body); font-size: 0.82rem;
  cursor: pointer; transition: all var(--transition); align-self: flex-end;
}
.clear-btn:hover { color: var(--incorrect); border-color: var(--incorrect); background: var(--incorrect-bg); }


/* ═══════════════════════════════════
   COLUMN PANEL
   ═══════════════════════════════════ */
.col-panel {
  padding: 14px 28px; background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  animation: slideDown 0.15s ease;
}
@keyframes slideDown { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:translateY(0); } }
.col-panel-title {
  font-family: var(--font-mono); font-size: 0.68rem;
  text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); margin-bottom: 10px;
}
.col-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.col-check-label {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--bg-elevated);
  color: var(--text-secondary); font-size: 0.8rem; cursor: pointer;
  transition: all var(--transition); user-select: none;
}
.col-check-label:hover { border-color: var(--accent); color: var(--accent); }
.col-check-label input { display: none; }
.col-check-label.checked { background: var(--accent-glow); border-color: var(--accent); color: var(--accent); }


/* ═══════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════ */
.main-content { padding: 20px 28px 40px; }
.mode-section { display: none; }
.mode-section.active { display: block; }


/* ═══════════════════════════════════
   TABLE MODE
   ═══════════════════════════════════ */
.table-wrapper {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-md);
}
.data-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.data-table thead { background: var(--bg-elevated); position: sticky; top: 0; z-index: 10; }
.data-table th {
  padding: 12px 14px; text-align: left;
  font-family: var(--font-mono); font-size: 0.68rem;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-secondary); border-bottom: 1px solid var(--border-strong);
  white-space: nowrap; user-select: none;
}
.data-table th.sortable { cursor: pointer; }
.data-table th.sortable:hover { color: var(--accent); background: var(--accent-glow); }
.sort-indicator { display: inline-block; margin-left: 5px; opacity: 0.3; font-size: 0.7rem; }
th.sort-asc .sort-indicator, th.sort-desc .sort-indicator { opacity: 1; color: var(--accent); }
.data-table tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition); }
.data-table tbody tr:nth-child(even) { background: var(--bg-row-alt); }
.data-table tbody tr:hover { background: var(--bg-row-hover); }
.data-table td { padding: 11px 14px; color: var(--text-primary); vertical-align: middle; max-width: 400px; }
.data-table td.col-num { font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; }
.data-table td.col-question { max-width: 480px; line-height: 1.5; vertical-align: top; padding-top: 13px; }
.data-table td.col-answer {
  /* Use flex to place answer text and icon side by side */
  display: flex; align-items: center; gap: 8px;
  font-weight: 500; color: var(--accent);
}
.subject-badge {
  display: inline-block; font-family: var(--font-mono); font-size: 0.68rem;
  padding: 2px 8px; border-radius: 999px; background: var(--bg-elevated);
  border: 1px solid var(--border-strong); color: var(--text-secondary); white-space: nowrap;
}
.highlight { background: var(--accent); color: var(--text-inverse); border-radius: 2px; padding: 0 1px; }

/* ── INFO ICON BUTTON ── */
/*
  The ⓘ icon sits inline in the Answer cell.
  It is a small circular button with a distinct info-accent colour
  so it stands out from the answer text without competing with it.
*/
.info-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; flex-shrink: 0;
  border-radius: 50%;
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  color: var(--info-accent);
  font-size: 0.7rem; font-family: var(--font-mono); font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  outline: none;
  line-height: 1;
  /* Reset default button styles */
  padding: 0; appearance: none;
  /* Prevent table row hover from being the main visual cue */
  position: relative; z-index: 1;
}
.info-icon:hover,
.info-icon:focus-visible {
  background: var(--info-accent);
  color: var(--text-inverse);
  border-color: var(--info-accent);
  transform: scale(1.15);
  box-shadow: 0 0 0 3px var(--info-bg);
}

/* ── QUESTION CELL WITH ICONS ── */
/*
  The <td> itself stays as a normal table cell — applying display:flex
  directly to a <td> disrupts the browser's table layout engine and causes
  adjacent cells to visually shift. Instead, an inner <div class="q-cell-inner">
  carries the flex layout so the td boundary is never disturbed.
*/
.q-cell-inner {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.q-text {
  flex: 1;
  min-width: 0; /* allow text to shrink and wrap */
}
.q-icons {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  padding-top: 1px; /* optical alignment with first line of text */
}

/* ── AUDIO ICON BUTTON ── */
.audio-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; flex-shrink: 0;
  border-radius: 50%;
  background: var(--audio-bg);
  border: 1px solid var(--audio-border);
  color: var(--audio-accent);
  font-size: 0.72rem; font-family: var(--font-mono); font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  outline: none;
  line-height: 1;
  padding: 0; appearance: none;
  position: relative; z-index: 1;
}
.audio-icon:hover,
.audio-icon:focus-visible {
  background: var(--audio-accent);
  color: var(--text-inverse);
  border-color: var(--audio-accent);
  transform: scale(1.15);
  box-shadow: 0 0 0 3px var(--audio-bg);
}
/* Playing state — pulsing ring to signal active playback */
.audio-icon.playing {
  background: var(--audio-accent);
  color: var(--text-inverse);
  border-color: var(--audio-accent);
  animation: audioPulse 1.4s ease-in-out infinite;
}
@keyframes audioPulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--audio-border); }
  50%       { box-shadow: 0 0 0 5px transparent; }
}

/* ── LOCAL IMAGE ICON BUTTON ── */
.local-img-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; flex-shrink: 0;
  border-radius: 50%;
  background: var(--localimg-bg);
  border: 1px solid var(--localimg-border);
  color: var(--localimg-accent);
  font-size: 0.72rem; font-family: var(--font-mono); font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  outline: none;
  line-height: 1;
  padding: 0; appearance: none;
  position: relative; z-index: 1;
}
.local-img-icon:hover,
.local-img-icon:focus-visible {
  background: var(--localimg-accent);
  color: var(--text-inverse);
  border-color: var(--localimg-accent);
  transform: scale(1.15);
  box-shadow: 0 0 0 3px var(--localimg-bg);
}
/* Active state — when popup is open for this icon */
.local-img-icon.active {
  background: var(--localimg-accent);
  color: var(--text-inverse);
  border-color: var(--localimg-accent);
}

/* ── LOCAL IMAGE POPUP ── */
/*
  A lightbox-style fixed panel. Shares the same header/pin/close/drag/resize
  conventions as the info-tooltip but is wider and designed around displaying
  a single image at a comfortable viewport-relative size with no scrolling.
*/
.local-img-popup {
  position: fixed;
  z-index: 9999;
  width: 560px;
  min-width: 280px;
  min-height: 120px;
  max-width: calc(100vw - 16px);
  background: var(--bg-elevated);
  border: 1px solid var(--localimg-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-tooltip);
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px) scale(0.97);
  transition: opacity 0.18s ease, transform 0.18s ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.local-img-popup.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}
.local-img-popup.is-dragging,
.local-img-popup.is-resizing {
  transition: none !important;
}
.local-img-popup.is-dragging { cursor: grabbing !important; }
.local-img-popup.is-resizing { cursor: se-resize !important; }
.local-img-popup.pinned {
  border-color: var(--localimg-accent);
  box-shadow: var(--shadow-tooltip), 0 0 0 2px var(--localimg-bg);
}

.local-img-popup-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px 8px 14px;
  border-bottom: 1px solid var(--localimg-border);
  background: var(--localimg-bg);
  cursor: grab;
  flex-shrink: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.local-img-popup-header:active { cursor: grabbing; }
.local-img-popup-icon {
  font-size: 0.9rem; color: var(--localimg-accent); flex-shrink: 0;
}
.local-img-popup-title {
  font-family: var(--font-mono); font-size: 0.65rem;
  text-transform: uppercase; letter-spacing: 0.12em; color: var(--localimg-accent);
  font-weight: 500; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.local-img-popup-actions {
  display: flex; align-items: center; gap: 4px; flex-shrink: 0; margin-left: auto;
}

/* The popup body fills available height between header and resize handle */
.local-img-popup-body {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: var(--bg-base);
  overflow: hidden;
}

/* The image itself — fills the popup without requiring scroll */
.local-img-popup-img {
  display: block;
  max-width: 100%;
  max-height: calc(75vh - 64px); /* 64px ≈ header + resize handle */
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

/* Reuse tooltip-resize-handle styles but as a separate class for the popup */
.local-img-resize-handle {
  position: absolute;
  bottom: 0; right: 0;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
  color: var(--text-muted);
  cursor: se-resize;
  touch-action: none;
  user-select: none; -webkit-user-select: none;
  opacity: 0.5;
  transition: opacity var(--transition), color var(--transition);
  border-radius: 0 0 var(--radius-md) 0;
  z-index: 1;
}
.local-img-resize-handle:hover,
.local-img-popup.is-resizing .local-img-resize-handle {
  opacity: 1;
  color: var(--localimg-accent);
}

/* ══════════════════════════════════════
   LANGUAGE TAGS & TTS
   ══════════════════════════════════════ */

/*
  Inline language segment — the text inside <fr>…</fr> etc.
  A subtle underline distinguishes it from surrounding English text
  without being visually noisy.
*/
.lang-segment {
  border-bottom: 1.5px dotted var(--tts-border);
  padding-bottom: 1px;
}

/*
  Language speaker badge — appears immediately after a delimited segment.
  Styled as a small pill with the 2-letter language code (FR, ES, PT …).
  Clicking speaks only that segment in its language.
*/
.lang-speak-btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 16px; padding: 0 5px;
  border-radius: 999px;
  background: var(--tts-bg);
  border: 1px solid var(--tts-border);
  color: var(--tts-accent);
  font-size: 0.58rem; font-family: var(--font-mono); font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all var(--transition);
  outline: none;
  line-height: 1;
  margin-left: 3px;
  vertical-align: middle;
  position: relative; z-index: 1;
  /* Reset default button styles */
  appearance: none;
}
.lang-speak-btn:hover,
.lang-speak-btn:focus-visible {
  background: var(--tts-accent);
  color: var(--text-inverse);
  border-color: var(--tts-accent);
  transform: scale(1.1);
}
/* Speaking state — amber pulse */
.lang-speak-btn.speaking {
  background: var(--tts-accent);
  color: var(--text-inverse);
  border-color: var(--tts-accent);
  animation: ttsPulse 1.2s ease-in-out infinite;
}

/*
  TTS read-question icon — sits in q-icons cluster alongside ♪ and ◫.
  Reads the entire question (or just foreign segments, depending on ReadAll state).
*/
.tts-read-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; flex-shrink: 0;
  border-radius: 50%;
  background: var(--tts-bg);
  border: 1px solid var(--tts-border);
  color: var(--tts-accent);
  font-size: 0.65rem; font-family: var(--font-mono); font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  outline: none;
  line-height: 1;
  padding: 0; appearance: none;
  position: relative; z-index: 1;
}
.tts-read-btn:hover,
.tts-read-btn:focus-visible {
  background: var(--tts-accent);
  color: var(--text-inverse);
  border-color: var(--tts-accent);
  transform: scale(1.15);
  box-shadow: 0 0 0 3px var(--tts-bg);
}
.tts-read-btn.speaking {
  background: var(--tts-accent);
  color: var(--text-inverse);
  border-color: var(--tts-accent);
  animation: ttsPulse 1.2s ease-in-out infinite;
}
@keyframes ttsPulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--tts-border); }
  50%       { box-shadow: 0 0 0 5px transparent; }
}

/* ══════════════════════════════════════
   ROW TOGGLE COLUMN
   ══════════════════════════════════════ */

/*
  A narrow fixed column prepended to every row in table mode.
  Not in state.columns — handled separately in buildTableHead/renderTable.
  Contains a small circular toggle button that controls per-row visibility.
*/
.row-toggle-th {
  width: 28px;
  padding: 8px 4px !important;
  text-align: center;
  cursor: default !important;
  user-select: none;
}
.row-toggle-cell {
  width: 28px;
  padding: 6px 4px !important;
  text-align: center;
  vertical-align: middle;
}
.row-toggle-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  font-size: 0.5rem;
  cursor: pointer;
  transition: all var(--transition);
  outline: none;
  padding: 0; appearance: none;
  flex-shrink: 0;
}
.row-toggle-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}
/* When the row is explicitly hidden by this button */
.row-toggle-btn.row-is-hidden {
  background: var(--incorrect-bg);
  border-color: var(--incorrect);
  color: var(--incorrect);
}

/* ══════════════════════════════════════
   ROW CONTENT/ANSWER HIDING
   ══════════════════════════════════════ */

/*
  When content is hidden for a row, everything except the row-toggle-cell
  is visually hidden. The row retains its height so the layout doesn't jump.
  pointer-events:none prevents accidental interaction with hidden elements.
*/
tr.row-content-hidden td:not(.row-toggle-cell) {
  visibility: hidden;
  pointer-events: none;
  user-select: none;
}
/* Ensure the toggle button itself stays interactive even when content is hidden */
tr.row-content-hidden td.row-toggle-cell {
  visibility: visible;
  pointer-events: auto;
}

/*
  Answer-only hiding: hides just the answer text span.
  The ⓘ info icon remains visible so the user can still open the tooltip.
*/
tr.row-answer-hidden td.col-answer > span:first-child {
  visibility: hidden;
  user-select: none;
}

/* ── INFO TOOLTIP (global floating widget) ── */
/*
  Positioned at body level via JS (getBoundingClientRect + fixed positioning).
  Uses opacity + transform for smooth fade-in/out.
  pointer-events:none when hidden so it doesn't interfere with mouse events.
  Drag and resize are handled entirely in JS using the Pointer Events API
  (pointerdown/pointermove/pointerup) which works on mouse, touch, and stylus
  across desktop, laptop, tablet, and mobile without any separate handlers.
*/
.info-tooltip {
  position: fixed;
  z-index: 9999;
  width: 320px;
  min-width: 240px;
  min-height: 80px;
  max-width: calc(100vw - 16px);
  background: var(--bg-elevated);
  border: 1px solid var(--info-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-tooltip);
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px) scale(0.97);
  transition: opacity 0.18s ease, transform 0.18s ease;
  overflow: hidden;        /* body handles its own scroll */
  display: flex;
  flex-direction: column;  /* header fixed, body fills rest, handle at bottom */
}
.info-tooltip.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}
/* Suppress transitions while dragging or resizing to eliminate lag */
.info-tooltip.is-dragging,
.info-tooltip.is-resizing {
  transition: none !important;
}
.info-tooltip.is-dragging  { cursor: grabbing !important; }
.info-tooltip.is-resizing  { cursor: se-resize !important; }

.info-tooltip-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px 8px 14px;
  border-bottom: 1px solid var(--info-border);
  background: var(--info-bg);
  cursor: grab;
  flex-shrink: 0;
  /* Prevent browser scroll/zoom from hijacking pointer during drag */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.info-tooltip-header:active { cursor: grabbing; }
.info-tooltip-icon { font-size: 0.9rem; color: var(--info-accent); flex-shrink: 0; }
.info-tooltip-title {
  font-family: var(--font-mono); font-size: 0.65rem;
  text-transform: uppercase; letter-spacing: 0.12em; color: var(--info-accent);
  font-weight: 500; flex: 1; min-width: 0;
}

/* ── Tooltip header action buttons (pin + close) ── */
.info-tooltip-actions {
  display: flex; align-items: center; gap: 4px; flex-shrink: 0; margin-left: auto;
}

.tooltip-pin-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 999px;
  border: 1px solid var(--info-border);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-mono); font-size: 0.6rem;
  font-weight: 500; letter-spacing: 0.06em;
  cursor: pointer;
  transition: all var(--transition);
  line-height: 1;
  touch-action: manipulation; /* fast tap, no double-tap zoom */
}
.tooltip-pin-btn:hover {
  border-color: var(--info-accent);
  color: var(--info-accent);
  background: var(--info-bg);
}
.tooltip-pin-btn.pinned {
  background: var(--info-accent);
  border-color: var(--info-accent);
  color: var(--text-inverse);
}
.tooltip-pin-btn .pin-icon { font-size: 0.7rem; line-height: 1; }

.tooltip-close-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.65rem;
  cursor: pointer;
  transition: all var(--transition);
  line-height: 1; padding: 0;
  touch-action: manipulation;
}
.tooltip-close-btn:hover {
  border-color: var(--incorrect);
  background: var(--incorrect-bg);
  color: var(--incorrect);
}

/* ── Pinned state — accent border signals the panel is locked ── */
.info-tooltip.pinned {
  border-color: var(--info-accent);
  box-shadow: var(--shadow-tooltip), 0 0 0 2px var(--info-bg);
}

.info-tooltip-body {
  padding: 0;
  font-family: var(--font-body); font-size: 0.82rem;
  color: var(--text-primary); line-height: 1.65;
  flex: 1;        /* fills all height between header and resize handle */
  min-height: 0;  /* essential — flex children won't shrink below content without this */
  overflow-y: auto;
}

/* ── Custom resize handle (bottom-right corner) ──
   Works on all devices via Pointer Events in JS.
   touch-action:none prevents browser scroll/zoom from consuming the gesture.
   The ⤡ glyph is a visual affordance that works at any size/DPI.
*/
.tooltip-resize-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: var(--text-muted);
  cursor: se-resize;
  touch-action: none;        /* critical — hands pointer control to JS */
  user-select: none;
  -webkit-user-select: none;
  opacity: 0.5;
  transition: opacity var(--transition), color var(--transition);
  border-radius: 0 0 var(--radius-md) 0;
  z-index: 1;
}
.tooltip-resize-handle:hover,
.info-tooltip.is-resizing .tooltip-resize-handle {
  opacity: 1;
  color: var(--info-accent);
}

/* ── Tooltip: image section ── */
.tooltip-media-wrap {
  width: 100%;
  background: #000;
  border-bottom: 1px solid var(--info-border);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  max-height: 220px;
}
.tooltip-media-img {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  display: block;
}

/* ── Tooltip: YouTube embed (responsive 16:9) ── */
.tooltip-youtube-wrap {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 ratio */
  height: 0;
  overflow: hidden;
  background: #000;
  border-bottom: 1px solid var(--info-border);
}
.tooltip-youtube-wrap iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border: none;
}

/* ── Tooltip: info/comments text section ── */
.tooltip-info-section {
  padding: 12px 14px;
}
.tooltip-info-section p { margin-bottom: 6px; }
.tooltip-info-section p:last-child { margin-bottom: 0; }

/* ── Shared inline media (flashcard back + quiz reveal) ── */

/* Image */
.media-image-wrap {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 10px;
  max-height: 260px;
}
.media-img {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  display: block;
}

/* YouTube embed (responsive 16:9) */
.media-youtube-wrap {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: #000;
  margin-bottom: 10px;
}
.media-youtube-wrap iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border: none;
}

/* Info / comments section */
.media-info-section {
  border-top: 1px solid var(--info-border);
  padding-top: 10px;
  margin-top: 2px;
}
/* Give the info section some breathing room when inside the quiz reveal box */
.quiz-reveal-info .media-info-section,
.quiz-reveal-info .media-image-wrap,
.quiz-reveal-info .media-youtube-wrap {
  margin-left: 0;
  margin-right: 0;
}
.quiz-reveal-info .media-info-section {
  padding: 12px 14px;
  border-top: none;
  margin-top: 0;
}
.quiz-reveal-info .media-image-wrap,
.quiz-reveal-info .media-youtube-wrap {
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-top: none;
  margin-bottom: 0;
}
.media-info-label {
  font-family: var(--font-mono); font-size: 0.62rem;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--info-accent); margin-bottom: 6px;
  display: flex; align-items: center; gap: 5px;
}
.media-info-section p {
  font-family: var(--font-body); font-size: 0.78rem;
  color: var(--text-secondary); line-height: 1.6; margin-bottom: 4px;
}
.media-info-section p:last-child { margin-bottom: 0; }

/* Empty state */
.empty-state { padding: 60px 20px; text-align: center; color: var(--text-muted); }
.empty-icon { font-size: 2.5rem; display: block; margin-bottom: 12px; }

/* Pagination */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0 0; flex-wrap: wrap; gap: 10px;
}
.page-info { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-muted); }
.page-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-btn {
  height: 32px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--bg-elevated);
  color: var(--text-secondary); font-family: var(--font-body); font-size: 0.8rem;
  cursor: pointer; transition: all var(--transition);
}
.page-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.page-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.page-nums { display: flex; gap: 4px; }
.page-num-btn {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--bg-elevated);
  color: var(--text-secondary); font-size: 0.8rem; font-family: var(--font-mono);
  cursor: pointer; transition: all var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.page-num-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-num-btn.active { background: var(--accent); border-color: var(--accent); color: var(--text-inverse); font-weight: 500; }
.page-ellipsis { padding: 0 4px; color: var(--text-muted); font-size: 0.8rem; display:flex; align-items:center; }


/* ═══════════════════════════════════
   FLASHCARD MODE
   ═══════════════════════════════════ */
.flashcard-container { max-width: 700px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.fc-header { display: flex; align-items: center; justify-content: space-between; }
.fc-counter { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-secondary); }
.fc-controls { display: flex; gap: 8px; }
.flashcard { height: 360px; perspective: 1200px; cursor: pointer; outline: none; }
.flashcard:focus { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: var(--radius-lg); }
.fc-inner {
  width: 100%; height: 100%; position: relative;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: var(--radius-lg);
}
.flashcard.flipped .fc-inner { transform: rotateY(180deg); }
.fc-front, .fc-back {
  position: absolute; inset: 0;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: var(--radius-lg); border: 1px solid var(--border-strong);
  padding: 28px 36px; display: flex; flex-direction: column; gap: 10px;
  box-shadow: var(--shadow-md); overflow-y: auto;
}
.fc-front { background: linear-gradient(135deg, var(--bg-surface) 0%, var(--bg-elevated) 100%); }
.fc-back {
  background: linear-gradient(135deg, var(--accent-glow) 0%, var(--bg-elevated) 100%);
  border-color: var(--accent); transform: rotateY(180deg);
}
.fc-label { font-family: var(--font-mono); font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.14em; color: var(--text-muted); }
.fc-back .fc-label { color: var(--accent-dim); }
.fc-meta { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-secondary); display: flex; gap: 10px; flex-wrap: wrap; }
.meta-tag { padding: 2px 8px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 999px; }
.fc-text { font-size: 1.05rem; color: var(--text-primary); line-height: 1.6; }
.fc-back .fc-text { font-size: 1.2rem; font-weight: 600; color: var(--accent); }

/* ── FC INFO (media panel on back of card) ── */
.fc-info {
  border-top: 1px solid var(--info-border);
  padding-top: 12px;
  margin-top: 4px;
}

.fc-hint { font-family: var(--font-mono); font-size: 0.68rem; color: var(--text-muted); text-align: center; margin-top: auto; }
.fc-nav { display: flex; align-items: center; gap: 14px; }
.fc-nav-btn { flex-shrink: 0; }
.fc-progress { flex: 1; height: 4px; background: var(--bg-elevated); border-radius: 2px; overflow: hidden; }
.fc-progress-bar { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.3s ease; }
.fc-footer { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-muted); text-align: center; }


/* ═══════════════════════════════════
   QUIZ MODE
   ═══════════════════════════════════ */
.quiz-container { max-width: 680px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.quiz-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.quiz-score-board {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-surface); border: 1px solid var(--border);
  padding: 10px 18px; border-radius: var(--radius-md);
}
.score-item { text-align: center; }
.score-num { font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; line-height: 1; color: var(--accent); display:block; }
.score-lbl { font-family: var(--font-mono); font-size: 0.62rem; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.1em; }
.score-sep { font-size: 1.4rem; color: var(--text-muted); }
.score-pct { font-family: var(--font-mono); font-size: 1rem; font-weight: 500; color: var(--correct); min-width: 50px; text-align: center; }
.quiz-controls { display: flex; gap: 8px; }
.quiz-progress-bar-wrap { height: 4px; background: var(--bg-elevated); border-radius: 2px; overflow: hidden; }
.quiz-progress-bar { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.4s ease; }
.quiz-card {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 32px; box-shadow: var(--shadow-md);
  display: flex; flex-direction: column; gap: 20px;
}
.quiz-q-meta { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-secondary); display: flex; gap: 8px; flex-wrap: wrap; }
.quiz-q-num { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-muted); }
.quiz-question { font-size: 1.1rem; line-height: 1.65; color: var(--text-primary); font-weight: 400; }
.quiz-input-area { display: flex; gap: 10px; }
.quiz-input {
  flex: 1; height: 44px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--bg-elevated); color: var(--text-primary);
  font-family: var(--font-body); font-size: 0.95rem; padding: 0 14px; outline: none;
  transition: border-color var(--transition);
}
.quiz-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
.quiz-submit-btn {
  height: 44px; padding: 0 20px; border-radius: var(--radius-sm); border: none;
  background: var(--accent); color: var(--text-inverse);
  font-family: var(--font-body); font-size: 0.9rem; font-weight: 600;
  cursor: pointer; transition: background var(--transition), transform var(--transition);
}
.quiz-submit-btn:hover { background: var(--accent-dim); }
.quiz-submit-btn:active { transform: scale(0.97); }
.quiz-reveal {
  background: var(--bg-elevated); border-radius: var(--radius-md); padding: 18px;
  display: flex; flex-direction: column; gap: 10px;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }
.quiz-reveal-label { font-family: var(--font-mono); font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); }
.quiz-reveal-answer { font-size: 1.1rem; font-weight: 600; color: var(--accent); }

/* ── QUIZ REVEAL INFO (media panel shown after answer) ── */
.quiz-reveal-info {
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  animation: fadeIn 0.25s ease;
}

.quiz-feedback {
  font-size: 0.9rem; font-weight: 500;
  padding: 6px 12px; border-radius: var(--radius-sm);
}
.quiz-feedback.correct { background: var(--correct-bg); color: var(--correct); }
.quiz-feedback.incorrect { background: var(--incorrect-bg); color: var(--incorrect); }
.quiz-next-btn {
  align-self: flex-start; padding: 8px 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--bg-surface);
  color: var(--text-secondary); font-family: var(--font-body); font-size: 0.85rem;
  cursor: pointer; transition: all var(--transition);
}
.quiz-next-btn:hover { border-color: var(--accent); color: var(--accent); }
.quiz-finished {
  text-align: center; padding: 50px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  animation: fadeIn 0.3s ease;
}
.finished-icon { font-size: 3rem; color: var(--accent); }
.quiz-finished h2 { font-family: var(--font-display); font-size: 1.8rem; }
.finished-score { font-family: var(--font-mono); font-size: 1.1rem; color: var(--text-secondary); }


/* ═══════════════════════════════════
   STATS MODE
   ═══════════════════════════════════ */
.stats-container { display: flex; flex-direction: column; gap: 24px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.stat-card {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px; text-align: center; box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.stat-card:hover { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
.stat-num { font-family: var(--font-display); font-size: 2.4rem; font-weight: 700; color: var(--accent); line-height: 1; }
.stat-lbl { font-family: var(--font-mono); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-secondary); margin-top: 6px; }
.charts-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; }
.chart-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow-sm); }
.chart-card.chart-wide { grid-column: 1 / -1; }
.chart-title { font-family: var(--font-display); font-size: 0.95rem; font-weight: 700; color: var(--text-primary); margin-bottom: 18px; }
.bar-chart { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 170px 1fr 44px; align-items: center; gap: 10px; }
.bar-label { font-family: var(--font-body); font-size: 0.78rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 10px; background: var(--bg-elevated); border-radius: 5px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent-dim), var(--accent)); border-radius: 5px; transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1); width: 0; }
.bar-count { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-muted); text-align: right; }


/* ═══════════════════════════════════
   LOADING OVERLAY
   ═══════════════════════════════════ */
.loading-overlay {
  position: fixed; inset: 0; background: var(--bg-base); z-index: 999;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px;
  transition: opacity 0.3s ease;
}
.loading-overlay.hidden { opacity: 0; pointer-events: none; }
.loading-spinner {
  width: 40px; height: 40px; border: 3px solid var(--border-strong);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-secondary); letter-spacing: 0.05em; }


/* ═══════════════════════════════════
   TOAST
   ═══════════════════════════════════ */
.toast {
  position: fixed; bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  color: var(--text-primary); padding: 10px 22px; border-radius: 999px;
  font-family: var(--font-mono); font-size: 0.78rem;
  opacity: 0; pointer-events: none; transition: all 0.25s ease;
  z-index: 9998; white-space: nowrap; box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }


/* ═══════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════ */
@media (max-width: 768px) {
  .site-header { padding: 12px 16px; }
  .toolbar { padding: 8px 16px; }
  .filters-bar { padding: 12px 16px; }
  .main-content { padding: 16px; }
  .search-input { width: 180px; }
  .site-title { font-size: 1.1rem; }
  .fc-front, .fc-back { padding: 22px; }
  .quiz-card { padding: 22px; }
  .bar-row { grid-template-columns: 120px 1fr 36px; }
  .mode-tab span:not(.tab-icon) { display: none; }
  .mode-tab { padding: 7px 12px; }
  .info-tooltip { width: calc(100vw - 24px); }
}

@media (max-width: 480px) {
  .flashcard { height: 320px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .charts-row { grid-template-columns: 1fr; }
  .quiz-input-area { flex-direction: column; }
  .quiz-submit-btn { width: 100%; }
}
