/* Quize — C# study quiz */
:root {
  --bg: #0b0d10;
  --bg-elev: #12151a;
  --bg-elev-2: #181c22;
  --bg-soft: #1f242c;
  --border: #262c35;
  --border-soft: #1c2128;
  --text: #e7ebf0;
  --text-dim: #9aa3ad;
  --text-faint: #6b7380;
  --accent: #7aa2ff;
  --accent-soft: rgba(122, 162, 255, 0.12);
  --accent-border: rgba(122, 162, 255, 0.35);
  --success: #6ee7a7;
  --success-soft: rgba(110, 231, 167, 0.12);
  --danger: #ff8a8a;
  --danger-soft: rgba(255, 138, 138, 0.12);
  --hint: #ffd84d;
  --hint-glow: rgba(255, 216, 77, 0.55);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  background:
    radial-gradient(circle at 15% 0%, rgba(122, 162, 255, 0.06), transparent 45%),
    radial-gradient(circle at 85% 100%, rgba(110, 231, 167, 0.04), transparent 40%),
    var(--bg);
  background-attachment: fixed;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
a { color: var(--accent); text-decoration: none; }

/* ===== Layout ===== */
.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-mark {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #7aa2ff, #6ee7a7);
  display: grid; place-items: center;
  font-family: var(--mono);
  font-weight: 700;
  color: #0b0d10;
  font-size: 16px;
}
.brand-text h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.brand-text p {
  font-size: 12px;
  color: var(--text-faint);
  font-family: var(--mono);
}

.header-actions { display: flex; gap: 8px; }

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 24px;
  overflow-x: auto;
}
.tab {
  flex: 1;
  min-width: 0;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  display: flex; align-items: center; justify-content: center;
  gap: 8px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active {
  background: var(--bg-soft);
  color: var(--text);
  box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset;
}
.tab .tab-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  padding: 2px 6px;
  background: var(--bg);
  border-radius: 6px;
}
.tab.active .tab-count { color: var(--accent); }

/* ===== Cards ===== */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.card + .card { margin-top: 16px; }

/* ===== Setup panel ===== */
.setup { display: grid; gap: 20px; }
.setup-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 16px;
  align-items: center;
}
.setup-label {
  font-size: 13px;
  color: var(--text-dim);
  font-family: var(--mono);
}
.setup-control { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.num-field {
  display: flex;
  align-items: center;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.num-field button {
  padding: 8px 12px;
  color: var(--text-dim);
  font-size: 16px;
  transition: background 0.15s;
}
.num-field button:hover { background: var(--border); color: var(--text); }
.num-field input {
  width: 64px;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
  text-align: center;
  outline: none;
  padding: 8px 0;
  -moz-appearance: textfield;
}
.num-field input::-webkit-outer-spin-button,
.num-field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.num-max {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-faint);
}

/* Custom module dropdown */
.mod-dropdown {
  position: relative;
  width: 100%;
}
.mod-dropdown-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-align: left;
  gap: 10px;
}
.mod-dropdown-trigger:hover {
  background: var(--bg-elev-2);
  border-color: #333a45;
}
.mod-dropdown-trigger.open {
  border-color: var(--accent-border);
  background: var(--bg-elev-2);
}
.mod-dropdown-trigger .mod-dd-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.mod-dropdown-trigger .mod-dd-chevron {
  flex-shrink: 0;
  color: var(--text-faint);
  transition: transform 0.2s ease;
}
.mod-dropdown-trigger.open .mod-dd-chevron {
  transform: rotate(180deg);
}
.mod-dropdown-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,0.35), 0 2px 6px rgba(0,0,0,0.2);
  max-height: 280px;
  overflow-y: auto;
  padding: 4px;
}
.mod-dropdown-item {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.mod-dropdown-item:hover {
  background: var(--bg-soft);
  color: var(--text);
}
.mod-dropdown-item.active {
  color: var(--accent);
  font-weight: 600;
  background: var(--accent-soft);
}
.mod-dropdown-item.active:hover {
  background: var(--accent-soft);
}
/* scrollbar inside dropdown */
.mod-dropdown-list::-webkit-scrollbar { width: 6px; }
.mod-dropdown-list::-webkit-scrollbar-track { background: transparent; }
.mod-dropdown-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.mod-dropdown-list::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

.mix-row { display: flex; flex-direction: column; gap: 10px; }
.mix-row .mix-total {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
}

.btn {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn:hover { background: var(--border); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b0d10;
  font-weight: 600;
}
.btn-primary:hover { background: #8db3ff; border-color: #8db3ff; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-soft); }
.btn-danger { color: var(--danger); border-color: rgba(255,138,138,0.25); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.toggle-group {
  display: inline-flex;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}
.toggle-group button {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--mono);
}
.toggle-group button.active {
  background: var(--bg-elev-2);
  color: var(--text);
}

/* ===== Quiz ===== */
.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}
.quiz-progress {
  display: flex; align-items: center; gap: 12px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
}
.progress-bar {
  width: 180px; height: 6px;
  background: var(--bg-soft);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  transition: width 0.3s;
}

.q-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  flex-wrap: wrap;
}
.source-tag {
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
}
.source-tag.theoretical { color: #b5c4ff; border-color: rgba(181,196,255,0.2); background: rgba(181,196,255,0.05); }
.source-tag.practical { color: #a9ecc7; border-color: rgba(169,236,199,0.2); background: rgba(169,236,199,0.05); }

.q-text {
  font-size: 18px;
  line-height: 1.45;
  font-weight: 500;
  margin-bottom: 20px;
  letter-spacing: -0.01em;
}
.q-text code {
  font-family: var(--mono);
  font-size: 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  color: #b5c4ff;
}
.q-text pre {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-top: 12px;
  overflow-x: auto;
}
.q-text pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: #e7ebf0;
  white-space: pre;
  font-size: 14px;
  line-height: 1.5;
}

.options { display: grid; gap: 8px; }
.option {
  display: grid;
  grid-template-columns: 32px 1fr;
  column-gap: 14px;
  align-items: center;
  padding: 16px 18px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
  text-align: left;
  width: 100%;
  font-family: inherit;
}
.option:hover { background: var(--bg-elev-2); border-color: #333a45; }
.option:active { transform: scale(0.998); }
.option-letter {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-faint);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  font-weight: 600;
  line-height: 1;
  text-transform: lowercase;
  align-self: center;
  padding: 0;
  margin: 0;
}
.option-text {
  font-size: 14px;
  line-height: 1.5;
  align-self: center;
  margin: 0;
  padding: 0;
}
.option-text code { vertical-align: baseline; }

/* ===== Pill toggle (iOS-style) ===== */
.pill-toggle {
  position: relative;
  width: 52px;
  height: 28px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 99px;
  cursor: pointer;
  transition: background 0.25s ease, border-color 0.25s ease;
  padding: 0;
  flex-shrink: 0;
}
.pill-toggle:hover { border-color: #333a45; }
.pill-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.25s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.pill-toggle.on {
  background: var(--accent);
  border-color: var(--accent);
}
.pill-toggle.on .pill-toggle-thumb {
  transform: translateX(24px);
  background: #0b0d10;
}
.pill-toggle-row {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.pill-toggle-state {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  min-width: 28px;
}
.pill-toggle-state.on { color: var(--accent); }

/* ===== Finish celebration ===== */
@keyframes celebrateIn {
  0% { transform: scale(0.7); opacity: 0; }
  60% { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes ringIn {
  from { stroke-dashoffset: 490; }
}
.celebrate-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(12px);
  z-index: 200;
  display: grid; place-items: center;
  padding: 24px;
  animation: toastIn 0.3s ease-out;
}
.celebrate-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 32px 32px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  animation: celebrateIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
}
.celebrate-card::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 16px;
  padding: 1px;
  background: linear-gradient(135deg, var(--accent), var(--success), transparent);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.4;
  pointer-events: none;
}
.celebrate-emoji {
  margin-bottom: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  animation: celebrateIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s both;
}
.celebrate-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}
.celebrate-sub {
  font-size: 13px;
  color: var(--text-dim);
  font-family: var(--mono);
  margin-bottom: 24px;
}
.celebrate-score {
  font-family: var(--mono);
  font-size: 56px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  margin: 8px 0 4px;
}
.celebrate-score .pct-sm { font-size: 24px; color: var(--text-dim); margin-left: 4px; }
.celebrate-breakdown {
  display: flex; justify-content: center; gap: 18px;
  margin-top: 16px; padding: 14px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 12px;
}
.celebrate-breakdown .cb-item { display: flex; flex-direction: column; gap: 2px; }
.celebrate-breakdown .cb-val { font-size: 18px; font-weight: 600; }
.celebrate-breakdown .cb-lbl { color: var(--text-faint); font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; }
.celebrate-breakdown .cb-item.good .cb-val { color: var(--success); }
.celebrate-breakdown .cb-item.bad .cb-val { color: var(--danger); }
.celebrate-breakdown .cb-item.skip .cb-val { color: var(--text-dim); }

.celebrate-actions {
  display: flex; gap: 8px; justify-content: center; margin-top: 24px;
  flex-wrap: wrap;
}

/* Confetti */
.confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.confetti-piece {
  position: absolute;
  width: 8px; height: 12px;
  top: -20px;
  opacity: 0;
  animation: confettiFall 2.2s ease-out forwards;
}
@keyframes confettiFall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(480px) rotate(720deg); opacity: 0; }
}

/* ===== History chart ===== */
.history-chart {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px;
  margin-bottom: 16px;
}
.chart-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap; gap: 8px;
}
.chart-title { font-size: 13px; font-weight: 600; letter-spacing: -0.01em; }
.chart-sub { font-size: 11px; color: var(--text-faint); font-family: var(--mono); }
.chart-body {
  position: relative;
  height: 160px;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 0 4px;
}
.chart-grid {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}
.chart-grid-line {
  border-top: 1px dashed var(--border-soft);
  height: 1px;
  position: relative;
}
.chart-grid-line::before {
  content: attr(data-label);
  position: absolute;
  left: -2px;
  top: -6px;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text-faint);
  background: var(--bg-soft);
  padding: 0 4px;
}
.chart-bar {
  flex: 1;
  min-width: 6px;
  max-width: 28px;
  background: var(--bg-elev-2);
  border-radius: 3px 3px 0 0;
  position: relative;
  transition: background 0.15s;
  cursor: pointer;
  min-height: 2px;
}
.chart-bar:hover { background: var(--accent) !important; }
.chart-bar.high { background: var(--success); }
.chart-bar.mid { background: var(--hint); }
.chart-bar.low { background: var(--danger); }
.chart-bar-tip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  font-family: var(--mono);
  font-size: 11px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 10;
}
.chart-bar:hover .chart-bar-tip { opacity: 1; }

.stat-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.stat-card .sc-label {
  font-size: 10px;
  color: var(--text-faint);
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.stat-card .sc-value {
  font-size: 22px;
  font-weight: 600;
  font-family: var(--mono);
  letter-spacing: -0.02em;
}
.stat-card .sc-sub {
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--mono);
  margin-top: 2px;
}
.stat-card.accent .sc-value { color: var(--accent); }
.stat-card.success .sc-value { color: var(--success); }
.stat-card.warn .sc-value { color: var(--hint); }
@media (max-width: 720px) {
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
}
.option-text code {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 4px;
}

.option.selected {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}
.option.selected .option-letter {
  background: var(--accent);
  color: #0b0d10;
  border-color: var(--accent);
}

.option.correct {
  background: var(--success-soft) !important;
  border-color: rgba(110,231,167,0.4) !important;
}
.option.correct .option-letter {
  background: var(--success);
  color: #0b0d10;
  border-color: var(--success);
}
.option.wrong {
  background: var(--danger-soft) !important;
  border-color: rgba(255,138,138,0.4) !important;
}
.option.wrong .option-letter {
  background: var(--danger);
  color: #0b0d10;
  border-color: var(--danger);
}

/* Hint blink animation */
@keyframes hintBlink {
  0%, 100% { background: var(--bg-soft); border-color: var(--border); box-shadow: 0 0 0 0 var(--hint-glow); }
  50% {
    background: rgba(255, 216, 77, 0.18);
    border-color: var(--hint);
    box-shadow: 0 0 24px 0 var(--hint-glow);
  }
}
.option.hint-blink {
  animation: hintBlink 0.6s ease-in-out;
  animation-iteration-count: 5;
}
.option.hint-blink .option-letter {
  background: var(--hint);
  color: #0b0d10;
  border-color: var(--hint);
  transition: all 0.3s;
}

.q-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  gap: 12px;
  flex-wrap: wrap;
}
.q-actions-left, .q-actions-right { display: flex; gap: 8px; flex-wrap: wrap; }

.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--bg-elev-2); color: var(--text); }
.icon-btn.active { color: var(--hint); border-color: rgba(255,216,77,0.3); background: rgba(255,216,77,0.08); }

/* Source reveal popover */
.source-pop {
  position: absolute;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  min-width: 220px;
}
.source-pop-label { color: var(--text-faint); margin-bottom: 2px; font-size: 11px; }

/* ===== Results ===== */
.result-hero {
  text-align: center;
  padding: 32px 24px;
}
.score-ring {
  width: 180px; height: 180px;
  margin: 0 auto 20px;
  position: relative;
}
.score-ring svg { transform: rotate(-90deg); }
.score-ring .score-value {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 40px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.score-value .pct { font-size: 20px; color: var(--text-dim); margin-left: 2px; }
.score-label {
  font-size: 14px;
  color: var(--text-dim);
  font-family: var(--mono);
}
.result-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 24px;
}
.stat {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
}
.stat-label { font-size: 11px; color: var(--text-faint); font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 22px; font-weight: 600; margin-top: 4px; font-family: var(--mono); }
.stat.correct .stat-value { color: var(--success); }
.stat.wrong .stat-value { color: var(--danger); }
.stat.skipped .stat-value { color: var(--text-dim); }

.result-review { margin-top: 16px; }
.review-item {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.review-item.is-wrong { border-left: 3px solid var(--danger); }
.review-item.is-correct { border-left: 3px solid var(--success); }
.review-item.is-skipped { border-left: 3px solid var(--text-dim); }
.review-q { font-size: 14px; font-weight: 500; margin-bottom: 8px; }
.review-q code { font-family: var(--mono); font-size: 12px; background: var(--bg); padding: 1px 5px; border-radius: 4px; }
.review-meta { font-family: var(--mono); font-size: 11px; color: var(--text-faint); margin-bottom: 8px; display: flex; gap: 8px; flex-wrap: wrap; }
.review-ans { font-size: 13px; display: grid; gap: 4px; }
.review-ans .line { display: flex; gap: 8px; align-items: flex-start; font-family: var(--mono); font-size: 12px; }
.review-ans .line .lbl { color: var(--text-faint); width: 60px; flex-shrink: 0; }
.review-ans .line.correct .val { color: var(--success); }
.review-ans .line.wrong .val { color: var(--danger); }
.review-ans .line.skipped .val { color: var(--text-dim); font-style: italic; }

/* Review — full (non-trimmed) options view */
.review-ans-full { display: grid; gap: 6px; margin-top: 2px; }
.review-ans-full .line-full {
  display: flex; gap: 10px; align-items: flex-start;
  font-family: var(--mono); font-size: 12px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  line-height: 1.45;
}
.review-ans-full .line-full .lbl { color: var(--text-faint); width: 20px; flex-shrink: 0; text-transform: uppercase; font-weight: 600; }
.review-ans-full .line-full .val { flex: 1; color: var(--text); }
.review-ans-full .line-full.neutral { opacity: 0.68; }
.review-ans-full .line-full.correct {
  background: color-mix(in oklab, var(--success) 10%, var(--bg));
  border-color: color-mix(in oklab, var(--success) 35%, var(--border));
}
.review-ans-full .line-full.correct .val { color: var(--success); }
.review-ans-full .line-full.wrong {
  background: color-mix(in oklab, var(--danger) 10%, var(--bg));
  border-color: color-mix(in oklab, var(--danger) 35%, var(--border));
}
.review-ans-full .line-full.wrong .val { color: var(--danger); }
.review-ans-full .line-full .mini-tag {
  font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 3px;
  background: var(--bg-soft); color: var(--text-faint);
  align-self: center; white-space: nowrap; font-weight: 600;
}
.review-ans-full .line-full.correct .mini-tag { background: var(--success); color: var(--bg); }
.review-ans-full .line-full.wrong .mini-tag { background: var(--danger); color: var(--bg); }

/* Pill toggle — trim options control */
.pill-toggle {
  appearance: none; background: var(--bg-soft); border: 1px solid var(--border);
  width: 34px; height: 20px; border-radius: 999px;
  position: relative; cursor: pointer; padding: 0; flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
.pill-toggle.on { background: var(--accent); border-color: var(--accent); }
.pill-toggle-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--text); transition: transform 0.15s, background 0.15s;
}
.pill-toggle.on .pill-toggle-thumb { background: var(--bg); transform: translateX(14px); }
.pill-toggle-state { font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; color: var(--text-faint); font-weight: 600; }
.pill-toggle-state.on { color: var(--accent); }

/* Bulk action bar */
.bulk-bar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap;
  padding: 10px 12px; margin: 0 0 12px;
  background: color-mix(in oklab, var(--accent) 8%, var(--bg));
  border: 1px solid color-mix(in oklab, var(--accent) 30%, var(--border));
  border-radius: 8px;
}
.bulk-info { font-size: 13px; color: var(--text); }
.bulk-info strong { color: var(--accent); font-weight: 600; }
.bulk-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* Selectable table */
.records-table.selectable .check-col { width: 34px; padding-left: 14px; padding-right: 0; }
.records-table.selectable input[type="checkbox"] {
  appearance: none; width: 15px; height: 15px; border-radius: 3px;
  border: 1.5px solid var(--border); background: var(--bg);
  cursor: pointer; position: relative; transition: all 0.15s;
  flex-shrink: 0; vertical-align: middle;
}
.records-table.selectable input[type="checkbox"]:hover { border-color: var(--accent); }
.records-table.selectable input[type="checkbox"]:checked {
  background: var(--accent); border-color: var(--accent);
}
.records-table.selectable input[type="checkbox"]:checked::after {
  content: ''; position: absolute; left: 4px; top: 1px;
  width: 4px; height: 8px;
  border: solid var(--bg); border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.records-table tr.row-selected td { background: color-mix(in oklab, var(--accent) 6%, var(--bg)); }

/* Wide modal for merged review */
.modal.modal-wide { max-width: 900px; }

/* Merged review source hint */
.merged-source-hint {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.04em;
  color: var(--text-faint); padding: 0 4px 4px; text-transform: uppercase;
}
.merged-source-hint strong { color: var(--text-dim); font-weight: 600; text-transform: none; letter-spacing: 0; }

/* ===== Records table ===== */
.records-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap; gap: 12px;
}
.records-head h2 { font-size: 15px; font-weight: 600; }
.records-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.records-table th {
  text-align: left;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}
.records-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border-soft);
  font-family: var(--mono);
  font-size: 12px;
}
.records-table tr:hover td { background: var(--bg-soft); }
.records-table .score-cell { font-weight: 600; }
.records-table .score-cell.high { color: var(--success); }
.records-table .score-cell.mid { color: var(--hint); }
.records-table .score-cell.low { color: var(--danger); }
.mode-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.mode-pill.theoretical { color: #b5c4ff; border-color: rgba(181,196,255,0.2); }
.mode-pill.practical { color: #a9ecc7; border-color: rgba(169,236,199,0.2); }
.mode-pill.mix { color: #ffd89a; border-color: rgba(255,216,154,0.2); }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 13px;
}

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: grid; place-items: center;
  padding: 24px;
}
.modal {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 600px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
}
.modal-head {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-head h3 { font-size: 15px; font-weight: 600; }
.modal-body { padding: 20px; }
.modal-foot { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* Hint toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text);
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: toastIn 0.2s ease-out;
}
@keyframes toastIn {
  from { transform: translate(-50%, 10px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

/* Nav drawer for question browser */
.q-nav-drawer {
  margin-bottom: 16px;
}
.q-nav-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.q-nav-toggle:hover {
  background: var(--bg-elev-2);
  border-color: #333a45;
}
.q-nav-summary {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
}
.q-nav-current {
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
}
.q-nav-sep { color: var(--text-faint); }
.q-nav-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-left: 6px;
}
.q-nav-dot.answered-dot { background: var(--success); }
.q-nav-dot.skipped-dot { background: var(--hint); }
.q-nav-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
  padding: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 200px;
  overflow-y: auto;
}
.q-nav-pill {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  font-family: var(--mono);
  font-size: 11px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  border-radius: 6px;
  color: var(--text-dim);
  transition: all 0.15s;
  cursor: pointer;
}
.q-nav-pill:hover { background: var(--bg-elev-2); color: var(--text); }
.q-nav-pill.current { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.q-nav-pill.answered { color: var(--success); border-color: rgba(110,231,167,0.3); }
.q-nav-pill.answered.current { color: var(--accent); }

/* ===== Responsive ===== */
@media (max-width: 820px) {
  .setup-row { grid-template-columns: 1fr; gap: 10px; align-items: flex-start; }
  .setup-label { font-size: 11px; }
  .setup-control { width: 100%; }
  .modal { max-height: 90vh; }
  .modal-foot { flex-direction: column-reverse; align-items: stretch; }
  .modal-foot .btn { width: 100%; justify-content: center; }
}

@media (max-width: 720px) {
  .app { padding: 16px 12px 60px; }
  .card { padding: 16px; }
  .header { margin-bottom: 18px; }
  .brand-text h1 { font-size: 15px; }
  .brand-text p { font-size: 11px; }
  .brand-mark { width: 32px; height: 32px; font-size: 14px; }

  .tabs { margin-bottom: 16px; padding: 3px; }
  .tab { font-size: 12px; padding: 8px 10px; }

  .q-text { font-size: 15px; line-height: 1.4; margin-bottom: 16px; }
  .option { padding: 12px 14px; grid-template-columns: 28px 1fr; column-gap: 10px; }
  .option-letter { width: 24px; height: 24px; font-size: 11px; }
  .option-text { font-size: 13px; line-height: 1.4; }

  .progress-bar { width: 90px; height: 5px; }
  .quiz-progress { font-size: 11px; gap: 8px; }
  .q-nav-pill { width: 26px; height: 26px; font-size: 10px; }
  .q-nav-grid { gap: 3px; }

  .q-actions { gap: 8px; }
  .q-actions .btn { flex: 1; justify-content: center; }

  .result-stats { grid-template-columns: repeat(2, 1fr); }
  .stat-cards { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-card { padding: 12px; }
  .stat-card .sc-value { font-size: 18px; }

  .score-ring { width: 140px; height: 140px; }
  .score-ring svg { width: 140px; height: 140px; }
  .score-ring .score-value { font-size: 30px; }

  /* Records table becomes card list */
  .records-table thead { display: none; }
  .records-table, .records-table tbody, .records-table tr, .records-table td { display: block; width: 100%; }
  .records-table tr {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
  }
  .records-table td {
    border: none;
    padding: 3px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
  }
  .records-table td::before {
    content: attr(data-label);
    font-family: var(--mono);
    font-size: 10px;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.06em;
  }
  .records-table td:last-child { justify-content: flex-end; gap: 6px; padding-top: 8px; }
  .records-table td:last-child::before { display: none; }

  /* Selectable checkbox on mobile */
  .records-table.selectable .check-col {
    width: auto; padding: 4px 0;
    display: flex; justify-content: flex-start;
  }
  .records-table.selectable .check-col::before { display: none; }
  .bulk-bar { flex-direction: column; align-items: stretch; }
  .bulk-actions { justify-content: stretch; }
  .bulk-actions .btn { flex: 1; justify-content: center; }

  .records-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .records-head > div:last-child { width: 100%; flex-wrap: wrap; }
  .toggle-group { flex-wrap: wrap; }

  .history-chart { padding: 14px; }
  .chart-body { height: 120px; }
  .chart-bar { max-width: 16px; }
  .chart-bar-tip { font-size: 10px; padding: 3px 6px; }

  .celebrate-card { padding: 28px 20px 24px; }
  .celebrate-score { font-size: 44px; }
  .celebrate-title { font-size: 18px; }
  .celebrate-breakdown { gap: 12px; padding: 10px 0; }
  .celebrate-actions { flex-direction: column; }
  .celebrate-actions .btn { width: 100%; justify-content: center; }

  .review-item { padding: 12px; }
  .review-q { font-size: 13px; }
  .review-ans .line { flex-direction: column; gap: 2px; }
  .review-ans .line .lbl { width: auto; }

  .num-field input { width: 52px; font-size: 14px; }
  .num-max { font-size: 11px; }

  .modal-head { padding: 14px 16px; }
  .modal-body { padding: 16px; }
  .modal-foot { padding: 14px 16px; }
  .modal-head h3 { font-size: 14px; }

  .toast { left: 12px; right: 12px; transform: none; bottom: 16px; text-align: center; font-size: 12px; }
}

@media (max-width: 420px) {
  .q-nav-pill { width: 24px; height: 24px; font-size: 10px; }
  .option-text { font-size: 12.5px; }
  .tab .tab-count { display: none; }
  .header-actions { display: none; }
}

/* ===== Quiz action bar (Pause / Review / Quit) ===== */
.quiz-header-wrap {
  margin-bottom: 16px;
}
.quiz-action-bar {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
.quiz-action-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--sans);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.quiz-action-btn:hover { background: var(--bg-elev-2); color: var(--text); }
.quiz-action-btn--danger { color: var(--danger); border-color: rgba(255,138,138,0.2); }
.quiz-action-btn--danger:hover { background: var(--danger-soft); }

@media (max-width: 420px) {
  .quiz-action-btn { padding: 8px 6px; font-size: 11.5px; }
}

/* Hidden util */
.hidden { display: none !important; }

/* ===== Themed scrollbars ===== */
/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* Webkit (Chrome, Safari, Edge) */
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: var(--bg-soft);
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: 8px;
  transition: background 0.15s;
}
*::-webkit-scrollbar-thumb:hover {
  background: color-mix(in oklab, var(--accent) 35%, var(--bg-soft));
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:active {
  background: var(--accent);
  background-clip: padding-box;
}
*::-webkit-scrollbar-corner {
  background: transparent;
}

/* Modal scrollbars — a bit more prominent + slight inset on track */
.modal::-webkit-scrollbar,
.modal-body::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}
.modal::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track {
  background: color-mix(in oklab, var(--bg) 60%, var(--bg-elev));
  border-radius: 0 12px 12px 0;
}
.modal::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border: 3px solid color-mix(in oklab, var(--bg) 60%, var(--bg-elev));
  background-clip: padding-box;
  border-radius: 10px;
}
.modal::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover {
  background: color-mix(in oklab, var(--accent) 50%, var(--border));
  background-clip: padding-box;
}
.modal::-webkit-scrollbar-thumb:active,
.modal-body::-webkit-scrollbar-thumb:active {
  background: var(--accent);
  background-clip: padding-box;
}

/* Firefox-specific tweak for modals */
.modal, .modal-body {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}


/* Study Hint Panel */
.study-hint-panel {
  margin-top: 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  animation: slideDownFade 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.study-hint-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.study-hint-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-dim);
}

.study-hint-text code {
  background: var(--bg);
  padding: 2px 4px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
}

