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

:root {
  --bg: #f1f5f9;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-solid: #ffffff;
  --surface-soft: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #4f46e5;
  --primary-2: #7c3aed;
  --primary-soft: #eef2ff;
  --success: #10b981;
  --success-soft: #dcfce7;
  --danger: #ef4444;
  --danger-soft: #fee2e2;
  --warning: #f59e0b;
  --warning-soft: #fef3c7;
  --shadow: 0 10px 30px -10px rgba(15, 23, 42, 0.1);
  --radius: 18px;
}

[data-theme="dark"] {
  --bg: #0b1120;
  --surface: rgba(15, 23, 42, 0.88);
  --surface-solid: #0f172a;
  --surface-soft: #1e293b;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --border: #1e293b;
  --primary: #6366f1;
  --primary-2: #a855f7;
  --primary-soft: rgba(99, 102, 241, 0.16);
  --success-soft: rgba(16, 185, 129, 0.16);
  --danger-soft: rgba(239, 68, 68, 0.16);
  --warning-soft: rgba(245, 158, 11, 0.16);
  --shadow: 0 14px 36px -10px rgba(0, 0, 0, 0.55);
}

body {
  font-family: "Plus Jakarta Sans", "Noto Sans Gujarati", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.25s ease, color 0.25s ease;
}

/* Ambient Background Orbs */
.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  z-index: -1;
  opacity: 0.35;
  pointer-events: none;
}

.orb-1 {
  width: 420px;
  height: 420px;
  background: #6366f1;
  top: -120px;
  left: -100px;
}

.orb-2 {
  width: 380px;
  height: 380px;
  background: #a855f7;
  bottom: -120px;
  right: -100px;
}

.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 18px;
}

/* Navbar */
.navbar {
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  display: grid;
  place-items: center;
  font-size: 22px;
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.3);
}

.brand h1 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.gradient-text {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  cursor: pointer;
  font-size: 1.1rem;
  display: grid;
  place-items: center;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover {
  transform: translateY(-1px);
  border-color: var(--primary);
}

.timer-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--warning-soft);
  color: #b45309;
  border: 1px solid rgba(245, 158, 11, 0.4);
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.95rem;
}

[data-theme="dark"] .timer-badge {
  color: #fbbf24;
}

.timer-badge.danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.45);
  animation: pulseBadge 1s infinite;
}

@keyframes pulseBadge {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

.progress-bar-wrap {
  height: 4px;
  background: var(--border);
  width: 100%;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  transition: width 0.3s ease;
}

/* Main */
main {
  padding: 26px 0 60px;
}

.hidden {
  display: none !important;
}

.fade-in {
  animation: fadeIn 0.35s ease;
}

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

/* Hero Banner */
.hero-banner {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 60%, #9333ea 100%);
  color: #ffffff;
  border-radius: 22px;
  padding: 30px 28px;
  margin-bottom: 22px;
  box-shadow: 0 18px 40px -15px rgba(79, 70, 229, 0.45);
  position: relative;
  overflow: hidden;
}

.hero-pill {
  display: inline-block;
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.hero-banner h2 {
  font-size: 1.85rem;
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 8px;
}

.hero-highlight {
  color: #fde047;
}

.hero-banner p {
  font-size: 0.96rem;
  color: rgba(255, 255, 255, 0.9);
  max-width: 680px;
}

/* Glass Card */
.card {
  background: var(--surface);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.center {
  text-align: center;
  padding: 54px 24px;
}

/* Sections */
.section-block {
  margin-bottom: 26px;
}

.section-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 14px;
}

.step-num {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}

/* Exam Cards Grid */
.exam-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.exam-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 10px;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  background: var(--surface-solid);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.18s ease;
}

.exam-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.exam-card.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.14);
}

.exam-icon {
  font-size: 1.45rem;
}

.exam-name {
  font-size: 0.84rem;
  font-weight: 600;
  text-align: center;
}

.custom-exam-wrap {
  margin-top: 12px;
}

/* Input */
.input-icon-wrap {
  position: relative;
}

.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  pointer-events: none;
}

input[type="text"] {
  width: 100%;
  padding: 13px 14px 13px 42px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 0.96rem;
  font-family: inherit;
  background: var(--surface-solid);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.custom-exam-wrap input[type="text"] {
  padding-left: 14px;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.14);
}

/* Topic Chips */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-soft);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 13px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip-count {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--border);
  color: var(--muted);
}

.chip:hover,
.chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: translateY(-1px);
}

.chip:hover .chip-count,
.chip.active .chip-count {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

/* Settings Grid */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.setting-box {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

.setting-box label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  flex: 1;
  min-width: 54px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pill:hover {
  border-color: var(--primary);
}

.pill.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.28);
}

/* Buttons */
.btn {
  padding: 11px 20px;
  border-radius: 12px;
  border: none;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.18s ease;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: 0 8px 20px -6px rgba(79, 70, 229, 0.5);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px -6px rgba(79, 70, 229, 0.6);
}

.btn-hero {
  width: 100%;
  padding: 16px 24px;
  font-size: 1.05rem;
  border-radius: 14px;
}

.btn-secondary {
  background: var(--surface-soft);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--primary);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px dashed var(--border);
}

.btn-ghost:hover {
  color: var(--danger);
  border-color: var(--danger);
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  box-shadow: 0 8px 18px -6px rgba(16, 185, 129, 0.5);
}

.btn-success:hover {
  transform: translateY(-1px);
}

.btn-block {
  width: 100%;
  margin-top: 16px;
}

.btn-link {
  background: none;
  border: none;
  color: var(--danger);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}

/* Alert */
.alert {
  padding: 13px 16px;
  border-radius: 12px;
  margin-bottom: 18px;
  font-size: 0.92rem;
  font-weight: 600;
}

.alert-error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.35);
}

/* Loader */
.loader-ring {
  display: inline-block;
  position: relative;
  width: 64px;
  height: 64px;
  margin-bottom: 18px;
}

.loader-ring div {
  box-sizing: border-box;
  display: block;
  position: absolute;
  width: 50px;
  height: 50px;
  margin: 7px;
  border: 5px solid var(--primary);
  border-radius: 50%;
  animation: loaderRing 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
  border-color: var(--primary) transparent transparent transparent;
}

.loader-ring div:nth-child(1) { animation-delay: -0.45s; }
.loader-ring div:nth-child(2) { animation-delay: -0.3s; }
.loader-ring div:nth-child(3) { animation-delay: -0.15s; }

@keyframes loaderRing {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-tip {
  margin: 22px auto 0;
  max-width: 520px;
  background: var(--primary-soft);
  color: var(--primary);
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.86rem;
  font-weight: 600;
}

/* Test Layout */
.test-layout {
  display: grid;
  grid-template-columns: 1fr 290px;
  gap: 20px;
  align-items: start;
}

.question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.badge {
  background: var(--primary-soft);
  color: var(--primary);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.q-counter {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--muted);
}

.question-text {
  font-size: 1.18rem;
  font-weight: 700;
  line-height: 1.65;
  margin-bottom: 22px;
}

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

.option-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  padding: 15px 16px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: var(--surface-solid);
  color: var(--text);
  cursor: pointer;
  font-size: 0.98rem;
  font-family: inherit;
  transition: all 0.16s ease;
}

.option-btn:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  transform: translateX(3px);
}

.option-btn.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.14);
  font-weight: 600;
}

.option-label {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.option-btn.selected .option-label {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  border-color: transparent;
}

.question-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

/* Palette */
.palette-panel {
  position: sticky;
  top: 86px;
}

.palette-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.attempted-pill {
  background: var(--success-soft);
  color: var(--success);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 16px 0;
  max-height: 360px;
  overflow-y: auto;
  padding-right: 4px;
}

.palette-item {
  height: 38px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}

.palette-item:hover {
  border-color: var(--primary);
}

.palette-item.answered {
  background: var(--success-soft);
  border-color: var(--success);
  color: var(--success);
}

.palette-item.current {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  border-color: transparent;
  color: #fff;
  transform: scale(1.06);
}

.palette-legend {
  display: flex;
  justify-content: space-between;
  font-size: 0.76rem;
  color: var(--muted);
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 4px;
}

.dot-answered { background: var(--success); }
.dot-unanswered { background: var(--border); }
.dot-current { background: var(--primary); }

/* Result Dashboard */
.result-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.result-tag {
  display: inline-block;
  background: var(--success-soft);
  color: var(--success);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 6px;
}

.result-actions {
  display: flex;
  gap: 10px;
}

.result-dashboard {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 20px;
  align-items: center;
  margin-top: 22px;
}

.score-ring-card {
  position: relative;
  width: 144px;
  height: 144px;
  margin: 0 auto;
}

.score-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 10;
}

.ring-fg {
  fill: none;
  stroke: var(--primary);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 326.7;
  stroke-dashoffset: 326.7;
  transition: stroke-dashoffset 0.9s ease;
}

.score-ring-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.score-ring-text strong {
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--primary);
}

.score-ring-text span {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.stat-box {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 15px;
  text-align: center;
}

.stat-label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 4px;
}

.stat-box strong {
  font-size: 1.35rem;
  font-weight: 800;
}

.stat-score strong { color: var(--primary); }
.stat-correct strong { color: var(--success); }
.stat-wrong strong { color: var(--danger); }
.stat-skipped strong { color: var(--warning); }

/* Review */
.review-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.filter-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tab {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.review-item {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 14px;
}

.review-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.status-pill {
  font-size: 0.76rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
}

.status-correct { background: var(--success-soft); color: var(--success); }
.status-wrong { background: var(--danger-soft); color: var(--danger); }
.status-skipped { background: var(--warning-soft); color: #b45309; }

.review-q-text {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 12px;
}

.review-options {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 12px;
}

.review-opt {
  padding: 9px 13px;
  border-radius: 10px;
  font-size: 0.92rem;
  background: var(--surface-soft);
  border: 1px solid var(--border);
}

.review-opt.is-correct {
  background: var(--success-soft);
  border-color: var(--success);
  color: var(--success);
  font-weight: 700;
}

.review-opt.is-wrong {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
  font-weight: 600;
}

.explanation-box {
  background: var(--primary-soft);
  border-left: 4px solid var(--primary);
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.6;
}

/* History */
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

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

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 16px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  gap: 12px;
}

.history-score {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 800;
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 0.9rem;
  white-space: nowrap;
}

@media (max-width: 820px) {
  .exam-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .settings-grid,
  .test-layout,
  .result-dashboard {
    grid-template-columns: 1fr;
  }
  .palette-panel {
    position: static;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .hero-banner h2 {
    font-size: 1.45rem;
  }
}