/* =========================================================================
   Quiz Practice — UI refresh (design language inspired by ExamCademy:
   clean light surface, blue accent, question cards with chips + sidebar
   navigation, sticky toolbar). Light + dark themes.
   ========================================================================= */

:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --surface-3: #eef1f7;
  --border: #e3e7ef;
  --border-strong: #cfd6e4;
  --text: #101322;
  --muted: #6b7280;

  --brand: #2563eb;
  --brand-strong: #1d4ed8;
  --brand-soft: rgba(37, 99, 235, 0.09);

  --ok: #16a34a;
  --ok-soft: rgba(22, 163, 74, 0.1);
  --bad: #dc2626;
  --bad-soft: rgba(220, 38, 38, 0.1);
  --warn: #d97706;
  --warn-soft: rgba(217, 119, 6, 0.12);

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 14px 30px -20px rgba(16, 24, 40, 0.35);
  --focus: 0 0 0 3px var(--brand-soft);

  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0b0e14;
  --surface: #141822;
  --surface-2: #1a1f2b;
  --surface-3: #212734;
  --border: #26303e;
  --border-strong: #3a4759;
  --text: #e8ebf2;
  --muted: #98a2b3;

  --brand: #5b8cff;
  --brand-strong: #7ba3ff;
  --brand-soft: rgba(91, 140, 255, 0.16);

  --ok: #4ade80;
  --ok-soft: rgba(74, 222, 128, 0.14);
  --bad: #f87171;
  --bad-soft: rgba(248, 113, 113, 0.14);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.14);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 18px 40px -24px rgba(0, 0, 0, 0.9);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0e14;
    --surface: #141822;
    --surface-2: #1a1f2b;
    --surface-3: #212734;
    --border: #26303e;
    --text: #e8ebf2;
    --muted: #98a2b3;
    --brand: #5b8cff;
    --brand-strong: #7ba3ff;
    --brand-soft: rgba(91, 140, 255, 0.16);
    --ok: #4ade80;
    --ok-soft: rgba(74, 222, 128, 0.14);
    --bad: #f87171;
    --bad-soft: rgba(248, 113, 113, 0.14);
    --warn: #fbbf24;
    --warn-soft: rgba(251, 191, 36, 0.14);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 18px 40px -24px rgba(0, 0, 0, 0.9);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 26px 22px 80px;
}

h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.muted.small { font-size: 0.84rem; }
.screen { animation: screenIn 0.25s ease; }
@keyframes screenIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- App header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.16rem; font-weight: 800; letter-spacing: -0.02em; }
.brand-icon { font-size: 1.35rem; }
.header-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.mode-badge {
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.mode-badge.study { background: var(--brand-soft); color: var(--brand); }
.mode-badge.exam { background: var(--warn-soft); color: var(--warn); }
.mode-badge.learn { background: var(--ok-soft); color: var(--ok); }

.timer-chip {
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.timer-chip.mid-time { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.timer-chip.low-time { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }

/* ---------- Section rows ---------- */
.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin: 6px 0 4px;
}
.section-row h1 { margin: 0; font-size: 1.7rem; font-weight: 800; }
.section-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.06s, box-shadow 0.15s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled) { background: var(--brand-strong); }

.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(0.93); }

.btn-link { background: none; border: none; color: var(--muted); padding: 6px 4px; font-weight: 600; }
.btn-link:hover { color: var(--brand); }

.btn-icon {
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
  font-size: 1rem;
}
.btn-icon:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.btn-icon-danger:hover:not(:disabled) { border-color: var(--bad); color: var(--bad); background: var(--bad-soft); }

.btn-flag {
  background: var(--surface);
  border-color: var(--border);
  color: var(--muted);
  padding: 5px 11px;
  font-size: 0.79rem;
  border-radius: 999px;
}
.btn-flag:hover:not(:disabled) { border-color: var(--warn); color: var(--warn); }
.btn-flag.active { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }

/* ---------- Chips & badges ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  background: var(--brand-soft);
  color: var(--brand);
  white-space: nowrap;
}
.pill-soft { background: var(--surface-3); color: var(--muted); }

.topic-badge, .done-badge, .flag-badge, .verified-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}
.topic-badge { background: var(--surface-3); color: var(--muted); }
.done-badge { background: var(--ok-soft); color: var(--ok); }
.flag-badge { background: var(--warn-soft); color: var(--warn); }
.verified-badge { background: var(--brand-soft); color: var(--brand); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px;
}

/* ---------- Progress bar ---------- */
.progress-bar { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), var(--brand-strong));
  transition: width 0.35s ease;
}

.empty-state { text-align: center; color: var(--muted); margin-top: 20px; padding: 40px 22px; }

/* ---------- Collections grid ---------- */
.collections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
  margin: 20px 0;
}
.collection-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.collection-card:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--brand) 45%, var(--border));
  box-shadow: var(--shadow);
}
.collection-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.collection-card-head h3 { margin: 0; font-size: 1.06rem; font-weight: 700; }
.collection-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.collection-card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.collection-card-actions .btn { flex: 1 1 auto; }
.collection-card-tools { display: flex; gap: 8px; justify-content: flex-end; }
.collection-progress-bar { margin-top: 2px; }

.topic-card { cursor: default; }

/* ---------- Import panel ---------- */
.import-panel { margin-top: 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-head h2 { margin: 0; font-size: 1.25rem; font-weight: 700; }

.setup-row { display: flex; gap: 16px; flex-wrap: wrap; align-items: stretch; margin: 20px 0; }
.sample-buttons { display: flex; flex-direction: column; gap: 10px; justify-content: center; }
.sample-buttons .btn { width: 100%; }

.file-drop {
  flex: 1 1 260px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  text-align: center;
  color: var(--muted);
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}
.file-drop:hover { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.file-drop-icon { font-size: 1.9rem; }

.paste-details { margin: 10px 0 6px; color: var(--muted); }
.paste-details summary { cursor: pointer; font-weight: 600; color: var(--text); margin-bottom: 10px; }
#paste-area {
  width: 100%;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.85rem;
  resize: vertical;
  margin-bottom: 10px;
}
#paste-area:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }

.status-text { color: var(--ok); font-weight: 600; min-height: 1.2em; }
.error-text {
  color: var(--bad);
  background: var(--bad-soft);
  border: 1px solid color-mix(in srgb, var(--bad) 55%, transparent);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  white-space: pre-wrap;
}
.error-list { margin-top: 10px; color: var(--muted); }
.error-list summary { cursor: pointer; font-weight: 600; color: var(--bad); }
.error-list ul { margin: 10px 0 0; padding-left: 20px; }
.error-list li { margin-bottom: 4px; font-size: 0.85rem; }

/* ---------- Config form ---------- */
.config-form { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.config-form h3 { margin: 0 0 12px; font-size: 1.02rem; }
.config-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.84rem; font-weight: 600; color: var(--muted); }
.field input {
  font: inherit;
  font-weight: 500;
  color: var(--text);
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.field input:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); background: var(--surface); }
.config-actions { display: flex; gap: 10px; margin-top: 16px; }

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(9, 12, 20, 0.55);
  backdrop-filter: blur(3px);
}
.modal-card { width: 100%; max-width: 460px; box-shadow: var(--shadow); }
.modal-card h2 { margin: 0 0 16px; font-size: 1.18rem; }
.modal-card form { display: flex; flex-direction: column; gap: 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }

/* ---------- Quiz toolbar ---------- */
.quiz-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 4px 0 18px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}
.progress-wrap { flex: 1; min-width: 220px; }
.progress-text { display: block; font-size: 0.83rem; color: var(--muted); margin-bottom: 6px; }
.toolbar-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Quiz layout (main + sidebar) ---------- */
.quiz-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 24px;
  align-items: start;
}
.quiz-main { min-width: 0; }

.quiz-sidebar {
  position: sticky;
  top: 84px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.sidebar-card { padding: 18px; }
.sidebar-title { margin: 0; font-size: 0.78rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.sidebar-card .sidebar-title:first-child { margin-bottom: 14px; }
.sidebar-head .sidebar-title { margin-bottom: 0; }

.sidebar-stats { display: flex; gap: 18px; margin-bottom: 14px; }
.sidebar-stat { display: flex; flex-direction: column; gap: 2px; }
.sidebar-stat-label { font-size: 0.76rem; color: var(--muted); }
.sidebar-stat-value { font-size: 1.15rem; font-weight: 800; font-variant-numeric: tabular-nums; }

.flag-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--muted); cursor: pointer; }
.flag-toggle input { width: 15px; height: 15px; accent-color: var(--brand); }

.navigator-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.nav-chip {
  min-width: 36px;
  height: 34px;
  padding: 0 8px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.nav-chip:hover { border-color: var(--brand); color: var(--brand); }
.nav-chip.answered { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 55%, transparent); color: var(--ok); }
.nav-chip.flagged { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 55%, transparent); color: var(--warn); }
.nav-chip.current { box-shadow: 0 0 0 2px var(--brand) inset; }

.navigator-legend { margin: 14px 0 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.legend-dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.legend-dot.answered { background: var(--ok-soft); border-color: var(--ok); }
.legend-dot.flagged { background: var(--warn-soft); border-color: var(--warn); }

/* ---------- Question block ---------- */
.question-list { display: flex; flex-direction: column; gap: 16px; }
.question-block {
  padding: 22px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.question-block:hover { border-color: color-mix(in srgb, var(--brand) 30%, var(--border)); box-shadow: var(--shadow); }
.question-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.question-number {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  font-weight: 800;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.question-id-badge { font-weight: 600; color: var(--muted); font-size: 0.76rem; text-transform: none; letter-spacing: 0; }
.question-header-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.question-text { font-size: 1.06rem; line-height: 1.65; margin-bottom: 18px; }
.question-text p { margin: 0 0 12px; }
.question-text p:last-child { margin-bottom: 0; }
.question-text ul { margin: 0 0 12px; padding-left: 22px; }
.question-text li { margin-bottom: 5px; }
.question-text strong { font-weight: 700; }
.question-text code {
  background: var(--surface-3);
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 0.88em;
  font-family: "Cascadia Code", Consolas, monospace;
}

.md-image { max-width: 100%; height: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); margin: 10px 0; display: block; }
.md-link { color: var(--brand); }

/* ---------- Options ---------- */
.options-list { display: flex; flex-direction: column; gap: 10px; }
.option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.option:hover { border-color: var(--brand); background: var(--surface); }
.option-static { cursor: default; }
.option-static:hover { border-color: var(--border); background: var(--surface-2); }
.option input { margin-top: 2px; accent-color: var(--brand); width: 18px; height: 18px; flex-shrink: 0; }
.option-marker { font-size: 1.05rem; line-height: 1.4; }

.option-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface-3);
  font-weight: 800;
  font-size: 0.78rem;
  color: var(--muted);
  margin-right: 10px;
  flex-shrink: 0;
}
.option-text { flex: 1; min-width: 0; }
.option-text p { margin: 0 0 8px; }
.option-text p:last-child { margin-bottom: 0; }

.option.correct { border-color: var(--ok); background: var(--ok-soft); }
.option.correct .option-key { background: var(--ok); color: #fff; }
.option.incorrect { border-color: var(--bad); background: var(--bad-soft); }
.option.incorrect .option-key { background: var(--bad); color: #fff; }
/* Selected (pre-reveal) state — guarded so it never overrides correct/incorrect. */
.option:not(.correct):not(.incorrect):has(input:checked) { border-color: var(--brand); background: var(--surface); }
.option:not(.correct):not(.incorrect):has(input:checked) .option-key { background: var(--brand); color: #fff; }

.question-actions { margin-top: 18px; }

/* ---------- Explanation ---------- */
.explanation {
  margin-top: 18px;
  padding: 16px;
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
  border: 1px solid color-mix(in srgb, var(--brand) 40%, transparent);
}
.explanation h4 {
  margin: 0 0 8px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--brand);
}
.explanation p { margin: 0 0 8px; }
.explanation p:last-child { margin-bottom: 0; }
.explanation ul { margin: 0; padding-left: 20px; }

/* ---------- Pagination ---------- */
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; margin-top: 24px; }
.page-btn {
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.page-btn:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-btn.current { background: var(--brand); border-color: var(--brand); color: #fff; }
.page-btn.done { border-color: color-mix(in srgb, var(--ok) 55%, transparent); background: var(--ok-soft); color: var(--ok); }
.page-btn.current.done { background: var(--ok); border-color: var(--ok); color: #fff; }
.page-ellipsis { padding: 0 6px; color: var(--muted); }

/* ---------- Results ---------- */
.results-summary { text-align: center; margin-bottom: 18px; padding: 30px 22px; }
.results-summary h1 { margin: 0 0 10px; font-size: 1.55rem; font-weight: 800; }
.results-summary .score-big { font-size: 3.2rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.results-summary .score-big.pass { color: var(--ok); }
.results-summary .score-big.fail { color: var(--bad); }

.results-filter { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-bottom: 18px; }
.filter-btn {
  padding: 8px 15px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.83rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.filter-btn:hover { border-color: var(--brand); color: var(--brand); }
.filter-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.results-list { display: flex; flex-direction: column; gap: 14px; }
.result-item { padding: 20px; }
.result-item-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.result-item-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.result-tag { font-weight: 800; font-size: 0.78rem; padding: 4px 12px; border-radius: 999px; }
.result-tag.correct { color: var(--ok); background: var(--ok-soft); }
.result-tag.incorrect { color: var(--bad); background: var(--bad-soft); }
.empty-filter { text-align: center; padding: 24px; }
.results-actions { display: flex; justify-content: center; gap: 12px; margin-top: 24px; flex-wrap: wrap; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(90vw, 480px);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 999;
  font-weight: 600;
  background: #111827;
  color: #f9fafb;
  animation: screenIn 0.2s ease;
}
.toast[data-type="error"] { background: var(--bad); color: #fff; }
.toast[data-type="success"] { background: var(--ok); color: #fff; }

/* ---------- Responsive ---------- */
@media (min-width: 1081px) {
  #btn-toggle-navigator { display: none; }
}

@media (max-width: 1080px) {
  .quiz-layout { grid-template-columns: 1fr; }
  .quiz-sidebar { position: static; display: none; }
  .quiz-sidebar.sidebar-open { display: flex; }
}

@media (max-width: 640px) {
  #app { padding: 18px 14px 60px; }
  .app-header { padding: 12px 14px; }
  .card, .question-block { padding: 16px; }
  .section-row h1 { font-size: 1.35rem; }
  .results-summary .score-big { font-size: 2.4rem; }
  .quiz-toolbar { padding: 12px; }
  .toolbar-actions { width: 100%; }
  .toolbar-actions .btn { flex: 1; }
  .question-text { font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}

/* ---------- Question action buttons (save / notes / copy / flag) ---------- */
.q-actions { display: inline-flex; align-items: center; gap: 6px; }
.btn-sm {
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border-radius: 9px;
  font-size: 0.95rem;
  line-height: 1;
}
.btn-sm.is-on { border-color: var(--brand); background: var(--brand-soft); }
.btn-sm.btn-flag.active { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }

/* ---------- Notes panel ---------- */
.notes-panel {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
}
.notes-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.notes-input {
  width: 100%;
  min-height: 78px;
  resize: vertical;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.notes-input::placeholder { color: var(--muted); }
.notes-input:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }

/* ---------- Toolbar widgets (filters row) ---------- */
.quiz-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin: -6px 0 18px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.toolbar-field {
  display: inline-flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--muted);
}
.toolbar-field > span { text-transform: uppercase; letter-spacing: 0.05em; }
.toolbar-field select,
.toolbar-field input {
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 10px;
  min-width: 120px;
}
.toolbar-field select:focus,
.toolbar-field input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus);
  background: var(--surface);
}
.search-field { flex: 1 1 200px; }
.search-field input { width: 100%; min-width: 160px; }

.sidebar-toggles { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Topic progress bars (home cards) ---------- */
.topic-bars { display: flex; flex-direction: column; gap: 8px; margin-top: 2px; }
.topic-bar { display: flex; flex-direction: column; gap: 4px; }
.topic-bar-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.topic-bar-name { font-size: 0.78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topic-bar-pct { font-size: 0.75rem; font-weight: 800; color: var(--brand); font-variant-numeric: tabular-nums; }
.topic-bar .progress-bar { height: 6px; }

/* ---------- Question focus (keyboard target) ---------- */
.question-block.focused { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand) inset, var(--shadow-sm); }

.mode-badge.review { background: var(--ok-soft); color: var(--ok); }







