.quiz-container {
  min-height: 100vh;
  padding: 1.5rem;
  max-width: 800px;
  margin: 0 auto;
}

.quiz-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border);
  flex-wrap: wrap;
}

.quiz-topbar > * {
  flex-shrink: 0;
}

.quiz-back {
  border: 2px solid var(--border);
  background: var(--bg);
  padding: 8px 16px;
  cursor: pointer;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  letter-spacing: 1px;
  transition: all 0.12s;
}

.quiz-back:hover { background: var(--fg); color: var(--bg); }

.progress-wrap { 
  flex: 1; 
  min-width: 200px;
  max-width: 300px; 
  margin: 0 auto;
  order: 3;
}

@media (min-width: 600px) {
  .progress-wrap {
    margin: 0 1.5rem;
    order: unset;
  }
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}

.progress-bar {
  height: 4px;
  background: var(--highlight);
  position: relative;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--fg);
  transition: width 0.4s cubic-bezier(0.4,0,0.2,1);
}

.score-chip {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  border: 1.5px solid var(--border);
  padding: 4px 10px;
  white-space: nowrap;
}

.jump-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
}

.jump-wrap input {
  width: 80px;
  padding: 4px 6px;
  border-radius: 4px;
  border: 1px solid #ccc;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  height: 30px;
  box-sizing: border-box;
}

.jump-go-btn {
  padding: 0 10px;
  height: 30px;
  border-radius: 4px;
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.12s;
}

.jump-go-btn:hover { background: var(--fg); color: var(--bg); }

/* Fixed zone so nav buttons never shift position */
.action-zone {
  min-height: 62px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  margin-top: 12px;
}

.q-card {
  border: 2px solid var(--border);
  padding: 2rem;
  margin-bottom: 1.5rem;
  position: relative;
  animation: fadeUp 0.25s ease both;
}

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

.q-num {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--muted);
  margin-bottom: 1rem;
  text-transform: uppercase;
}

.q-text {
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.65;
  margin-bottom: 2rem;
}

.options { 
  display: flex; 
  flex-direction: column; 
  gap: 10px; 
}

.option {
  border: 2px solid var(--border);
  padding: 14px 18px;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: all 0.1s;
  background: var(--bg);
  text-align: left;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.92rem;
  line-height: 1.5;
  width: 100%;
}

.option:hover:not(:disabled) { 
  background: var(--highlight); 
  transform: translateX(4px); 
}

.option:disabled { cursor: not-allowed; }
.option.disabled { cursor: default; }

.option.selected {
  background: #e0e7ff;
  border-color: #4f46e5;
  transform: translateX(4px);
}

.option.selected .opt-key {
  color: #4f46e5;
}

.opt-key {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  min-width: 20px;
  margin-top: 1px;
  flex-shrink: 0;
}

.option.correct { 
  background: #f0fdf4; 
  border-color: var(--correct); 
}

.option.correct .opt-key { 
  color: var(--correct); 
}

.option.wrong { 
  background: #fef2f2; 
  border-color: var(--wrong); 
}

.option.wrong .opt-key { 
  color: var(--wrong); 
}

.multi-note {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 1rem;
  text-transform: uppercase;
}

.submit-btn {
  margin-top: 0;
  border: 2px solid var(--border);
  background: var(--fg);
  color: var(--bg);
  padding: 0 24px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  transition: all 0.12s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  max-width: 160px;
  height: 46px;
  box-sizing: border-box;
}

.submit-btn:hover { 
  background: var(--bg); 
  color: var(--fg); 
}
.submit-btn.visible { display: block; }

.action-buttons {
  display: flex;
  gap: 10px;
  align-items: stretch;
  justify-content: center;
  margin-top: 0;
  flex-wrap: wrap;
}

.clear-btn, .submit-btn {
  height: 46px;
  box-sizing: border-box;
}

.clear-btn {
  border: 2px solid var(--muted);
  background: var(--bg);
  color: var(--muted);
  padding: 0 20px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  transition: all 0.12s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  max-width: 160px;
}

.clear-btn:hover {
  border-color: var(--fg);
  color: var(--fg);
  background: var(--highlight);
}

.ai-toggle-btn {
  margin-top: 0;
  width: 100%;
  border: 2px solid #4f46e5;
  background: var(--bg);
  color: #4f46e5;
  padding: 14px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  transition: all 0.12s;
  display: block;
}

.ai-toggle-btn:hover {
  background: #4f46e5;
  color: var(--bg);
}

.ai-box {
  border: 2px solid var(--border);
  margin-top: 0;
  animation: fadeUp 0.3s ease both;
  display: none;
}

.ai-box.visible { display: block; }

.ai-header {
  background: var(--fg);
  color: var(--bg);
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.ai-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #4ade80;
  animation: pulse 1.4s infinite;
}

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }

.ai-body {
  padding: 1.5rem;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--fg);
}

.ai-body strong { font-weight: 700; }

.ai-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--muted);
}

.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--muted);
  border-top-color: var(--fg);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.next-btn {
  margin-top: 0.5rem;
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  padding: 12px 16px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.12s;
  height: 44px;
  box-sizing: border-box;
}

.next-btn:hover { background: var(--fg); color: var(--bg); }
.next-btn.hidden { display: none; }
.skip-btn { border-style: dashed; color: var(--muted); border-color: var(--muted); }
.skip-btn:hover { background: var(--muted); color: var(--bg); border-color: var(--muted); }

.nav-buttons {
  display: flex;
  gap: 10px;
  margin-top: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.nav-buttons button {
  flex: 1;
  min-width: 120px;
}

.prev-btn {
  flex: 1;
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  padding: 12px 16px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.12s;
  height: 44px;
  box-sizing: border-box;
}

.prev-btn:hover:not(:disabled) { background: var(--fg); color: var(--bg); }
.prev-btn.hidden { display: none; }
.prev-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.loading {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'DM Mono', monospace;
  color: var(--muted);
}

@media(max-width:520px) {
  .quiz-topbar { flex-wrap: wrap; gap: 10px; }
  .progress-wrap { max-width: 100%; flex: 0 0 100%; order: 3; margin: 0; }
}
html.dark .option.selected,
html.dark .option.correct,
html.dark .option.wrong {
  background: transparent;
}

.q-text p, .option p { margin: 0; }
