/* ==========================================================================
   DESIGN SYSTEM - UNTITLED UI INSPIRED (ULTRA-MINIMAL & UTILITY-FIRST)
   ========================================================================== */

:root {
  color-scheme: light;
  
  /* Primary & Brand Colors */
  --brand: #4f46e5;            /* Digital Indigo */
  --brand-light: #f5f3ff;      /* Indigo 50 */
  --brand-border: #c7d2fe;     /* Indigo 200 */
  --brand-hover: #4338ca;      /* Indigo 700 */
  
  /* Neutral Palette (Slate System) */
  --bg: #f8fafc;               /* Slate 50 */
  --surface: #ffffff;          /* White */
  --surface-soft: #f1f5f9;     /* Slate 100 */
  --ink: #0f172a;              /* Slate 900 - Deep read text */
  --muted: #475569;            /* Slate 600 - Secondary text */
  --line: #e2e8f0;             /* Slate 200 - Borders */
  --line-hover: #cbd5e1;       /* Slate 300 */
  
  /* Semantic Colors */
  --green: #10b981;            /* Emerald 500 */
  --green-soft: #ecfdf5;       /* Emerald 50 */
  --green-border: #a7f3d0;     /* Emerald 200 */
  --green-ink: #065f46;        /* Emerald 800 */
  
  /* Error / Wrong States */
  --red: #f43f5e;              /* Rose 500 */
  --red-soft: #fff1f2;         /* Rose 50 */
  --red-border: #fecdd3;       /* Rose 200 */
  --red-ink: #9f1239;          /* Rose 800 */
  
  /* Bookmark / Marked States */
  --amber: #f59e0b;            /* Amber 500 */
  --amber-soft: #fffbeb;       /* Amber 50 */
  --amber-border: #fde68a;     /* Amber 200 */
  --amber-ink: #b45309;        /* Amber 800 */

  /* Spacing & Borders */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 14px;
  
  /* Soft, Layered Premium Shadows (Untitled UI style) */
  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.03), 0 2px 4px -2px rgba(15, 23, 42, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.04), 0 4px 6px -4px rgba(15, 23, 42, 0.02);
  --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 20px 25px -5px rgba(0, 0, 0, 0.015), 0 8px 10px -6px rgba(0, 0, 0, 0.015);
  
  /* Layout limits */
  --page: min(1000px, calc(100vw - 40px));
  
  /* Fonts */
  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-display: 'Inter', var(--font-sans);
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

/* ==========================================================================
   BASE & RESET STYLES
   ========================================================================== */

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--ink);
  margin-top: 0;
  letter-spacing: 0;
}

a {
  color: var(--brand);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--brand-hover);
}

button,
input {
  font-family: inherit;
  font-size: inherit;
}

button {
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* ==========================================================================
   LAYOUT SHELL (TOPBAR & MAIN CONTAINER)
   ========================================================================== */

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  width: 100%;
  max-width: var(--page);
  margin: 0 auto;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 0 4px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0;
}

/* Minimal Overlapping Dot Icon */
.brand-mark {
  position: relative;
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, var(--brand), var(--brand-hover));
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
}

.brand-mark::after {
  content: "";
  position: absolute;
  top: 6px;
  left: 6px;
  width: 12px;
  height: 12px;
  background: #ffffff;
  border-radius: 50%;
  opacity: 0.85;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app {
  width: 100%;
  max-width: var(--page);
  margin: 0 auto 80px;
  flex-grow: 1;
  outline: none;
}

/* ==========================================================================
   HERO / HEADERS
   ========================================================================== */

.home-hero,
.test-header,
.result-panel {
  padding: 40px 0 24px;
}

.home-hero h1,
.test-header h1,
.result-panel h1 {
  margin: 0 0 10px;
  font-size: clamp(28px, 5vw, 40px);
  line-height: 1.22;
  font-weight: 700;
  letter-spacing: 0;
}

.home-hero p,
.test-header p,
.result-panel p {
  max-width: 620px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
  margin: 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */

.primary-button,
.secondary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  padding: 8px 16px;
  font-weight: 600;
  font-size: 14px;
  outline: none;
}

.primary-button {
  background-color: var(--brand);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.primary-button:hover:not(:disabled) {
  background-color: var(--brand-hover);
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.15);
}

.secondary-button {
  background-color: var(--surface);
  color: var(--ink);
  border-color: var(--line);
  box-shadow: var(--shadow-sm);
}

.secondary-button:hover:not(:disabled) {
  background-color: var(--surface-soft);
  border-color: var(--line-hover);
}

.ghost-button {
  background-color: transparent;
  color: var(--muted);
  border-color: transparent;
}

.ghost-button:hover:not(:disabled) {
  background-color: var(--surface-soft);
  color: var(--ink);
}

/* Focus Ring for Keyboard Access */
.primary-button:focus-visible,
.secondary-button:focus-visible,
.ghost-button:focus-visible,
.option:focus-within,
.nav-dot:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.test-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 18px;
  width: 100%;
  margin: 24px auto 0;
}

.test-card {
  display: flex;
  flex-direction: column;
  background-color: var(--surface);
  border: 1px solid #d9e2f0;
  border-radius: 22px;
  box-shadow:
    0 26px 56px -36px rgba(15, 23, 42, 0.38),
    0 8px 22px -18px rgba(79, 70, 229, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.92);
  overflow: hidden;
  transition-property: transform, box-shadow, border-color;
  transition-duration: 220ms;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.test-card:hover {
  transform: translateY(-3px);
  border-color: #cbd7eb;
  box-shadow:
    0 32px 64px -38px rgba(15, 23, 42, 0.44),
    0 12px 28px -20px rgba(79, 70, 229, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

.test-card.is-disabled {
  box-shadow: none;
  background-color: rgba(248, 250, 252, 0.6);
  border-color: #e2e8f0;
  opacity: 0.7;
}

.test-card.is-disabled:hover {
  transform: none;
  border-color: #e2e8f0;
  box-shadow: none;
}

.card-body {
  padding: clamp(20px, 2.4vw, 26px);
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.card-header-row {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 18px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border-radius: 99px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1;
}

.status-badge.is-ready {
  background-color: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  box-shadow: 0 8px 20px -14px rgba(16, 185, 129, 0.8);
}

.status-badge.is-ready .badge-dot {
  width: 8px;
  height: 8px;
  background-color: #10b981;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
}

.status-badge.is-planned {
  background-color: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.status-badge.is-planned .badge-dot {
  width: 8px;
  height: 8px;
  background-color: #94a3b8;
  border-radius: 50%;
  display: inline-block;
}

.card-icon-container {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background:
    radial-gradient(circle at 28% 18%, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0) 36%),
    #eef2ff;
  border: 1px solid #dbe2ff;
  border-radius: 16px;
  color: #1e3a8a;
  margin-bottom: 20px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.78),
    0 18px 38px -28px rgba(30, 58, 138, 0.55);
}

.card-icon-container svg {
  width: 28px;
  height: 28px;
  stroke-width: 1.8;
}

.test-card h2 {
  margin: 0 0 8px;
  font-size: clamp(25px, 2.5vw, 31px);
  font-weight: 800;
  line-height: 1.12;
  color: #0b1024;
  letter-spacing: 0;
  text-wrap: balance;
}

.card-focus {
  margin: 0 0 18px;
  color: #64708a;
  font-size: 14.5px;
  line-height: 1.42;
  font-weight: 500;
  text-wrap: pretty;
}

.card-divider {
  border: 0;
  height: 1px;
  background-color: #dfe5ef;
  margin: 0 0 18px 0;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  margin-top: auto;
  position: relative;
}

.meta-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
}

.meta-col:not(:last-child)::after {
  content: "";
  position: absolute;
  right: 0;
  top: 6px;
  bottom: 2px;
  width: 1px;
  background-color: #dfe5ef;
}

.meta-icon-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background-color: #f1f0ff;
  border-radius: 50%;
  color: #1e3a8a;
  margin-bottom: 7px;
}

.meta-icon-wrapper svg {
  width: 17px;
  height: 17px;
  stroke-width: 2.5;
}

.meta-label {
  font-size: 12.5px;
  color: #64708a;
  font-weight: 500;
  line-height: 1.1;
  margin-bottom: 2px;
}

.meta-value {
  font-size: 16px;
  line-height: 1.1;
  font-weight: 800;
  color: #0b1024;
  font-variant-numeric: tabular-nums;
}

.card-footer {
  background:
    linear-gradient(180deg, rgba(249, 250, 255, 0.96), rgba(245, 247, 255, 0.98));
  padding: 16px 20px 14px;
  border-top: 1px solid #dce3f1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
}

.card-footer .primary-button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 46px;
  border: none;
  background: linear-gradient(135deg, #503cf1 0%, #4837f2 52%, #3f32df 100%);
  color: #ffffff;
  font-size: 17px;
  font-weight: 700;
  border-radius: 12px;
  cursor: pointer;
  transition-property: transform, box-shadow, background-color;
  transition-duration: 180ms;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
  box-shadow:
    0 16px 30px -18px rgba(67, 56, 202, 0.72),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  text-transform: none;
  letter-spacing: 0;
}

.card-footer .primary-button:hover:not(:disabled) {
  background: linear-gradient(135deg, #5b48f5 0%, #4d3cf4 52%, #4338ca 100%);
  transform: translateY(-2px);
  box-shadow:
    0 22px 38px -20px rgba(67, 56, 202, 0.84),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.card-footer .primary-button:active:not(:disabled) {
  transform: scale(0.96);
}

.card-footer .primary-button:disabled {
  background-color: #cbd5e1;
  color: #94a3b8;
  cursor: not-allowed;
  box-shadow: none;
}

.card-footer .primary-button .btn-arrow {
  position: absolute;
  right: 18px;
  width: 22px;
  height: 22px;
  color: #ffffff;
  transition-property: transform;
  transition-duration: 180ms;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.card-footer .primary-button:hover .btn-arrow {
  transform: translateX(5px);
}

.footer-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 12px;
  color: #64708a;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
}

.footer-meta svg {
  width: 13px;
  height: 13px;
  color: #64708a;
}

.footer-separator {
  color: #94a3b8;
}

/* ==========================================================================
   QUIZ ACTIVE STATE Layout & Containers
   ========================================================================== */

.test-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.test-progress-bar {
  width: 100%;
  height: 4px;
  background-color: var(--line);
  margin-top: 12px;
  margin-bottom: 24px;
  border-radius: 99px;
  position: relative;
  overflow: hidden;
}

.test-progress-bar::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: var(--progress);
  background: linear-gradient(90deg, var(--brand), var(--brand-hover));
  border-radius: 99px;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.secondary-button.is-marked {
  background-color: var(--amber-soft);
  color: var(--amber-ink);
  border-color: var(--amber-border);
}

.secondary-button.is-marked:hover {
  background-color: #fef3c7;
  border-color: #fcd34d;
}

.question-card {
  padding: clamp(20px, 4vw, 36px);
  background-color: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  animation: fadeIn 0.3s ease;
}

.question-card.no-enter-animation {
  animation: none;
}

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

.question-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.question-prompt {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(20px, 3vw, 25px);
  line-height: 1.3;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0;
}

/* Question Split Prompt System */
.question-prompt-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 4px;
}

.question-context {
  display: block;
  font-size: 16.5px;
  line-height: 1.6;
  color: #334155; /* Slate 700 for solid contrast */
  font-weight: 500; /* Gives presence without being overly bold */
  background-color: #f8fafc; /* Very subtle slate tint background */
  border-left: 4px solid var(--brand); /* Thick brand left accent border */
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 12px 18px; /* Comfortable breathing room */
  font-style: normal; /* Keep upright for a professional textbook layout */
  margin: 8px 0 16px 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.review-item .question-prompt {
  font-size: 18px;
  line-height: 1.4;
  letter-spacing: 0;
  margin-bottom: 12px;
}

/* Monospace stimuli & formulas */
.stimulus-text {
  display: block;
  font-size: 16.5px;
  line-height: 1.6;
  color: #334155;
  font-weight: 500;
  background-color: #f8fafc;
  border-left: 4px solid var(--brand);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 12px 18px;
  margin: 8px 0 16px 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

/* Premium Math Formula Beautification */
.math {
  font-family: 'EB Garamond', Georgia, serif;
  color: var(--ink);
  font-variant-numeric: lining-nums tabular-nums;
  -webkit-font-smoothing: antialiased;
}

.math-inline {
  display: inline-flex;
  align-items: baseline;
  gap: 0.02em;
  white-space: nowrap;
  vertical-align: baseline;
}

.question-prompt .math-inline,
.option .math-inline,
.feedback .math-inline,
.review-item .math-inline {
  font-size: 1.15em; /* Match LaTeX textbook proportions */
}

.option .math-inline {
  line-height: 1.2;
}

.math-display {
  display: inline-flex;
  align-items: baseline;
  gap: 0.02em;
  white-space: nowrap;
}

.formula-box {
  width: fit-content;
  max-width: 100%;
  padding: 16px 24px;
  background-color: #f7f5f0; /* Warm textbook eggshell/cream background (LaTeX style) */
  border: 1px solid #e3dec3; /* Soft warm border */
  border-left: 4px solid var(--brand); /* Premium left brand accent */
  border-radius: var(--radius-lg);
  font-family: 'EB Garamond', Georgia, serif;
  font-size: clamp(17px, 2.2vw, 19px); /* Generous sizing for reading complexity */
  color: #1c1917; /* Warm deep slate/stone */
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
  margin: 12px 0;
}

.math-equation {
  display: flex;
  align-items: center;
  line-height: 1.6;
  white-space: nowrap;
}

.math-equation + .math-equation {
  margin-top: 10px;
  border-top: 1px dashed #e3dec3;
  padding-top: 10px;
}

.math var {
  font-family: 'EB Garamond', Georgia, serif;
  font-style: italic;
  font-weight: 400; /* Regular weight is essential for elegant LaTeX rendering */
  color: inherit;
  padding-right: 0.05em; /* Prevent italic letter collision with brackets */
}

.math sub {
  font-size: 0.72em;
  vertical-align: sub;
  margin-left: 0.05em;
  font-style: normal;
  font-family: 'EB Garamond', Georgia, serif;
  font-weight: 400;
  color: inherit;
}

.math-op {
  color: #475569; /* Balanced slate for operators, not overly colored */
  font-weight: 400;
  font-family: 'EB Garamond', Georgia, serif;
  margin: 0 0.35em; /* Classic wide LaTeX binary spacing */
  font-style: normal;
}

.math-number {
  font-family: 'EB Garamond', Georgia, serif;
  font-weight: 400;
  color: inherit;
}

.math-text {
  font-family: var(--font-sans);
  font-style: normal;
  font-weight: 500;
  color: var(--ink);
  font-size: 0.9em;
}

.math-frac {
  display: inline-grid;
  grid-template-rows: auto auto;
  align-items: center;
  justify-items: center;
  min-width: 1.5em;
  margin: 0 0.25em;
  vertical-align: middle;
  transform: translateY(0.08em);
}

.math-num,
.math-den {
  display: block;
  padding: 0 0.25em;
  line-height: 1.1;
  font-size: 0.85em;
  font-family: 'EB Garamond', Georgia, serif;
}

.math-num {
  border-bottom: 1px solid currentColor; /* Ultra-thin horizontal fraction bar */
  padding-bottom: 2px;
}

.math-den {
  padding-top: 2px;
}

.math-sqrt-container {
  display: inline-flex;
  align-items: baseline;
  position: relative;
  margin: 0 0.1em;
}

.math-sqrt-symbol {
  font-size: 1.25em;
  font-family: 'EB Garamond', Georgia, serif;
  margin-right: -0.04em;
  font-style: normal;
  font-weight: 300;
  color: #475569;
  transform: translateY(0.05em);
}

.math-sqrt-content {
  border-top: 1px solid currentColor;
  padding-top: 1.5px;
  margin-top: 0.1em;
  display: inline-block;
  padding-left: 0.15em;
  padding-right: 0.2em;
}

.math-paren {
  font-family: 'EB Garamond', Georgia, serif;
  font-style: normal;
  font-weight: 400;
  color: #475569;
  margin: 0 0.05em;
}

/* Image containment */
.visual {
  margin: 10px 0 0;
  width: 100%;
  max-width: 580px;
}

.visual img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background-color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.visual figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  font-style: italic;
}

.visual-placeholder {
  padding: 0;
}

.image-slot {
  min-height: 200px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-hover);
  border-radius: var(--radius-lg);
  background-color: var(--bg);
  color: var(--muted);
  font-size: 14px;
}

/* Dynamic Tables inside questions */
.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 480px;
  background-color: var(--surface);
  font-size: 13px;
}

caption {
  caption-side: top;
  padding: 8px 12px;
  font-weight: 600;
  color: var(--muted);
  text-align: left;
  border-bottom: 1px solid var(--line);
  background-color: var(--bg);
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 14px;
  text-align: left;
}

th {
  background-color: var(--bg);
  color: var(--ink);
  font-weight: 600;
  font-family: var(--font-display);
}

tr:last-child td {
  border-bottom: none;
}

/* ==========================================================================
   UTILITY-FIRST CLICK TARGETS: INTERACTIVE OPTION CARDS
   ========================================================================== */

.options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 30px;
}

/* Hide default browser radio inputs visually but keep accessible */
.option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.option {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  width: 100%;
  padding: 16px 20px;
  background-color: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-lg);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Custom interactive Radio Circle */
.option::before {
  content: "";
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border: 2px solid var(--line-hover);
  border-radius: 50%;
  background-color: var(--surface);
  margin-top: 3px;
  box-sizing: border-box;
  transition: all 0.15s ease;
}

/* Option Typography */
.option span {
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  font-weight: 500;
}

/* Interactive States: Hover */
.option:hover:not(.is-correct):not(.is-wrong) {
  border-color: var(--brand-border);
  background-color: var(--brand-light);
  transform: translateY(-1px);
}

.option:hover::before {
  border-color: var(--brand);
}

/* Selected State */
.option.is-selected {
  border-color: var(--brand);
  background-color: var(--brand-light);
}

.option.is-selected::before {
  border-color: var(--brand);
  background-color: var(--brand);
  box-shadow: inset 0 0 0 4px var(--surface);
}

/* Checked Correct State */
.option.is-correct {
  border-color: var(--green-border);
  background-color: var(--green-soft);
}

.option.is-correct span {
  color: var(--green-ink);
  font-weight: 600;
}

.option.is-correct::before {
  border-color: var(--green);
  background-color: var(--green);
  box-shadow: inset 0 0 0 4px var(--surface);
}

/* Checked Wrong State */
.option.is-wrong {
  border-color: var(--red-border);
  background-color: var(--red-soft);
}

.option.is-wrong span {
  color: var(--red-ink);
}

.option.is-wrong::before {
  border-color: var(--red);
  background-color: var(--red);
  box-shadow: inset 0 0 0 4px var(--surface);
}

/* Fade out other options when test question is answered & checked */
.options:has(.is-correct) .option:not(.is-correct):not(.is-wrong) {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ==========================================================================
   FEEDBACK & SOURCES CARDS
   ========================================================================== */

.feedback {
  margin-top: 24px;
  padding: 24px;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02);
  animation: fadeIn 0.25s ease;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.feedback.is-correct {
  background-color: #f0fdf4;
  border: 1px solid #d3f9d8;
  color: #1e293b;
}

.feedback.is-wrong {
  background-color: #fff5f5;
  border: 1px solid #ffe3e3;
  color: #c92a2a;
}

.feedback p {
  margin: 0;
}

.feedback-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.feedback-header .feedback-status-svg {
  flex-shrink: 0;
}

.feedback.is-wrong .feedback-status-svg {
  color: #fa5252;
}

.feedback-title-text {
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-family: var(--font-display);
}

.feedback.is-wrong .feedback-title-text {
  color: #c92a2a;
}

.feedback-pill-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 600;
}

.feedback-pill-badge.is-correct {
  background-color: #d3f9d8;
  color: #2b8a3e;
}

.feedback-explanation {
  font-size: 15.5px;
  line-height: 1.65;
  margin: 0;
}

.feedback.is-correct .feedback-explanation {
  color: #334155;
}

.feedback.is-wrong .feedback-explanation {
  color: #b91c1c;
}

/* Accordion Sources Details Container */
.sources-details {
  width: 100%;
  margin-top: 8px;
}

.sources-summary::-webkit-details-marker {
  display: none;
}

.sources-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
  cursor: pointer;
  outline: none;
  user-select: none;
}

/* Correct feedback Sources Card style */
.feedback.is-correct .sources-details {
  border-top: 1px dashed rgba(43, 138, 62, 0.15);
  padding-top: 18px;
  margin-top: 14px;
}

.feedback.is-correct .sources-summary {
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 18px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.feedback.is-correct .sources-summary:hover {
  border-color: #cbd5e1;
}

/* Icon / Badges in Correct Sources box */
.sources-book-wrapper {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background-color: #eef2ff;
  border-radius: 8px;
  color: #4f46e5;
  margin-right: 10px;
}

.sources-title-text {
  font-size: 14.5px;
  font-weight: 700;
  color: #1e293b;
}

.sources-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background-color: #eef2ff;
  color: #4f46e5;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 700;
  margin-left: 8px;
}

/* Wrong feedback Sources Accordion line style */
.feedback.is-wrong .sources-details {
  border-top: 1px solid rgba(185, 28, 28, 0.15);
  padding-top: 14px;
  margin-top: 12px;
}

.feedback.is-wrong .sources-summary {
  padding: 4px 0;
  color: #c92a2a;
}

.feedback.is-wrong .sources-title-text {
  color: #1e293b;
}

.toggle-action-text {
  font-size: 14.5px;
  font-weight: 600;
  color: #1e293b;
  margin-right: 8px;
}

.chevron-icon {
  color: #64748b;
  transition: transform 0.2s ease;
}

.feedback.is-wrong .chevron-icon {
  color: #1e293b;
}

.sources-details[open] .chevron-icon {
  transform: rotate(180deg);
}

/* Sources Expanded Content List */
.sources-content {
  padding: 14px 18px;
}

.feedback.is-correct .sources-content {
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-top: none;
  border-radius: 0 0 12px 12px;
  margin-top: -8px;
  padding-top: 20px;
}

.sources-details[open] .sources-summary {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.sources-content ul {
  margin: 0;
  padding-left: 20px;
  color: #475569;
  font-size: 14.5px;
}

.sources-content li {
  margin-bottom: 6px;
  line-height: 1.5;
}

.sources-content li a {
  color: #4f46e5;
  text-decoration: none;
  font-weight: 500;
}

.sources-content li a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   ACTIONS BAR & QUESTION NAVIGATION PAGINATION
   ========================================================================== */

.question-actions,
.result-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 28px;
}

.question-actions button {
  min-width: 100px;
}

.question-actions #check-button {
  flex-grow: 1.5;
}

.question-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 32px;
  padding: 14px;
  background-color: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.nav-dot {
  position: relative;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background-color: var(--surface);
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-dot:hover {
  border-color: var(--brand-border);
  color: var(--brand);
  background-color: var(--brand-light);
  transform: scale(1.05);
}

.nav-dot.is-active {
  border-color: var(--brand);
  color: var(--brand);
  background-color: var(--brand-light);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}

.nav-dot.is-answered {
  background-color: var(--surface-soft);
  color: var(--ink);
}

.nav-dot.is-correct {
  background-color: var(--green-soft);
  border-color: var(--green-border);
  color: var(--green-ink);
}

.nav-dot.is-wrong {
  background-color: var(--red-soft);
  border-color: var(--red-border);
  color: var(--red-ink);
}

/* Beautiful Amber Bookmark Corner for Marked Items */
.nav-dot.is-marked::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  border-style: solid;
  border-width: 0 7px 7px 0;
  border-color: transparent var(--amber) transparent transparent;
}

/* ==========================================================================
   RESULTS / COMPLETION VIEW & METRICS METER
   ========================================================================== */

.result-panel {
  max-width: 600px;
}

.result-meter {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background-color: var(--line);
  margin: 20px 0;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

.result-meter span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--green), #34d399);
  border-radius: 999px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Results Review Checklist styling */
.review-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 36px;
}

.review-item {
  padding: 24px;
  background-color: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  transition: border-color 0.15s ease;
}

.review-item h2 {
  margin: 0 0 12px;
  font-size: 18px;
  line-height: 1.4;
}

.review-item p {
  margin: 6px 0;
  font-size: 14px;
  line-height: 1.5;
}

.review-item.is-correct {
  border-left: 4px solid var(--green);
}

.review-item.is-wrong {
  border-left: 4px solid var(--red);
}

.review-kicker {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0;
  font-weight: 700;
  margin-bottom: 6px;
}

/* ==========================================================================
   LOADER & STATIC SCREENS
   ========================================================================== */

.quiet-state {
  min-height: 50vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  padding: 20px;
}

.quiet-state h2 {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
}

.quiet-state p {
  max-width: 460px;
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.loader {
  width: 32px;
  height: 32px;
  border: 3.5px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s cubic-bezier(0.5, 0.1, 0.4, 0.9) infinite;
}

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

/* ==========================================================================
   RESPONSIVE DESIGN (MOBILE ADAPTATION)
   ========================================================================== */

@media (max-width: 720px) {
  :root {
    --page: min(100vw - 24px, 1000px);
  }

  .topbar {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
    padding: 16px 8px 12px;
    min-height: auto;
  }

  .topbar-actions {
    width: 100%;
    justify-content: center;
    gap: 8px;
  }

  .ghost-button {
    padding: 0 10px;
    font-size: 13px;
    min-height: 36px;
  }

  .primary-button,
  .secondary-button {
    min-height: 38px;
    font-size: 13px;
    padding: 6px 12px;
  }

  .home-hero,
  .test-header,
  .result-panel {
    padding-top: 20px;
    padding-bottom: 12px;
  }

  .home-hero h1,
  .test-header h1,
  .result-panel h1 {
    font-size: 26px !important;
    line-height: 1.25;
  }

  .test-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .test-header button {
    width: 100%;
    align-self: stretch;
  }

  .question-card {
    padding: 16px;
  }

  .question-prompt {
    font-size: 19px;
  }

  .option {
    padding: 14px 16px;
    gap: 12px;
  }

  .option span {
    font-size: 14.5px;
  }

  .option::before {
    width: 18px;
    height: 18px;
  }

  .meta-row {
    grid-template-columns: 1fr;
    gap: 8px;
    margin: 16px 0;
  }
  
  .meta-row div {
    padding-top: 6px;
  }

  .question-actions {
    flex-direction: column;
    width: 100%;
  }

  .question-actions button {
    width: 100%;
  }
}

/* ==========================================================================
   SPACED REPETITION DESIGN SYSTEM STYLES
   ========================================================================== */

.test-card.is-sr {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: row;
  background: linear-gradient(135deg, var(--surface) 0%, #fffdf9 100%);
  border: 1.5px solid var(--amber-border);
  border-radius: 24px;
  box-shadow:
    0 26px 56px -36px rgba(217, 119, 6, 0.2),
    0 8px 22px -18px rgba(217, 119, 6, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
  animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
  gap: 24px;
  padding: 24px;
  align-items: stretch;
  position: relative;
  overflow: hidden;
}

.test-card.is-sr::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 6px;
  height: 100%;
  background: linear-gradient(to bottom, #f59e0b, #d97706);
  border-radius: 24px 0 0 24px;
}

.test-card.is-sr:hover {
  border-color: #fcd34d;
  box-shadow:
    0 32px 64px -38px rgba(217, 119, 6, 0.25),
    0 12px 28px -20px rgba(217, 119, 6, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
  transform: translateY(-3px);
}

.sr-card-left {
  flex: 1.6;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
}

.sr-card-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  padding-left: 24px;
  border-left: 1px dashed rgba(217, 119, 6, 0.15);
  text-align: right;
}

.sr-content-group {
  display: flex;
  gap: 18px;
  align-items: flex-start;
}

.sr-text-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.test-card.is-sr h2 {
  font-size: clamp(20px, 1.8vw, 24px);
  font-weight: 700;
  color: var(--ink);
  margin: 0;
}

.test-card.is-sr .card-focus {
  font-size: clamp(14px, 1.1vw, 15px);
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

.card-icon-container.is-sr {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 1px solid var(--amber-border);
  color: var(--amber-ink);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 8px 16px -8px rgba(217, 119, 6, 0.3);
}

.card-icon-container.is-sr svg {
  width: 26px;
  height: 26px;
}

.status-badge.is-sr-active {
  background-color: #fffbeb;
  color: var(--amber-ink);
  border: 1px solid var(--amber-border);
  box-shadow: 0 4px 10px -4px rgba(217, 119, 6, 0.2);
  align-self: flex-start;
}

.status-badge.is-sr-active .badge-dot {
  width: 8px;
  height: 8px;
  background-color: #d97706;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 4px rgba(217, 119, 6, 0.15);
  animation: pulse-orange 2s infinite;
}

.sr-stats-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
}

.sr-stats-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
}

.sr-stats-value {
  font-size: clamp(26px, 2.4vw, 34px);
  font-weight: 800;
  color: #d97706;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.sr-actions-group {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  width: 100%;
}

.primary-button.is-sr-btn {
  background: linear-gradient(185deg, #f59e0b 0%, #d97706 100%);
  border: 1px solid #b45309;
  box-shadow:
    0 4px 12px -2px rgba(217, 119, 6, 0.35),
    0 1px 2px rgba(0, 0, 0, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  color: #ffffff;
  padding: 10px 20px;
  width: auto;
  border-radius: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.primary-button.is-sr-btn:hover {
  background: linear-gradient(185deg, #fbbf24 0%, #d97706 100%);
  box-shadow:
    0 6px 16px -2px rgba(217, 119, 6, 0.45),
    0 1px 2px rgba(0, 0, 0, 0.05);
  transform: translateY(-1px);
}

.test-card.is-sr .footer-meta {
  color: var(--muted);
  justify-content: flex-end;
}

.test-card.is-sr .footer-meta svg {
  color: #d97706;
}

/* Responsive SR Card rules */
@media (max-width: 768px) {
  .test-card.is-sr {
    flex-direction: column;
    padding: 20px;
    gap: 20px;
  }
  
  .test-card.is-sr::before {
    width: 100%;
    height: 6px;
    border-radius: 24px 24px 0 0;
  }
  
  .sr-card-left, .sr-card-right {
    flex: none;
    width: 100%;
  }
  
  .sr-card-right {
    padding-left: 0;
    border-left: none;
    border-top: 1px dashed rgba(217, 119, 6, 0.15);
    padding-top: 20px;
    align-items: stretch;
    text-align: left;
  }
  
  .sr-stats-group {
    align-items: flex-start;
    margin-bottom: 12px;
  }
  
  .sr-actions-group {
    align-items: stretch;
  }
  
  .primary-button.is-sr-btn {
    width: 100%;
    justify-content: center;
  }
  
  .test-card.is-sr .footer-meta {
    justify-content: flex-start;
  }
}

@keyframes pulse-orange {
  0% {
    box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.4);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(217, 119, 6, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(217, 119, 6, 0);
  }
}

/* Custom Spaced Repetition Results Screen Styles */
.sr-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  width: 100%;
  margin: 32px 0 24px;
}

.sr-result-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px;
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  text-align: left;
}

.sr-result-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Green / Graduated state */
.sr-result-card.is-graduated {
  background: linear-gradient(135deg, var(--green-soft) 0%, #ffffff 100%);
  border: 1px solid var(--green-border);
  color: var(--green-ink);
}
.sr-result-card.is-graduated .sr-result-icon {
  background-color: var(--green-soft);
  color: var(--green);
  border: 1px solid var(--green-border);
}

/* Blue-Purple / Halfway state */
.sr-result-card.is-halfway {
  background: linear-gradient(135deg, var(--brand-light) 0%, #ffffff 100%);
  border: 1px solid var(--brand-border);
  color: var(--brand-hover);
}
.sr-result-card.is-halfway .sr-result-icon {
  background-color: var(--brand-light);
  color: var(--brand);
  border: 1px solid var(--brand-border);
}

/* Red-Amber / Learning state */
.sr-result-card.is-learning {
  background: linear-gradient(135deg, var(--amber-soft) 0%, #ffffff 100%);
  border: 1px solid var(--amber-border);
  color: var(--amber-ink);
}
.sr-result-card.is-learning .sr-result-icon {
  background-color: var(--amber-soft);
  color: #d97706;
  border: 1px solid var(--amber-border);
}

.sr-result-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sr-result-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sr-result-count {
  font-size: clamp(24px, 2.2vw, 30px);
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.sr-result-label {
  font-size: 14px;
  font-weight: 700;
}

.sr-result-desc {
  font-size: 12px;
  opacity: 0.8;
  margin-top: 4px;
  line-height: 1.4;
}

/* Circle progress ring */
.progress-ring-svg {
  transform: rotate(-90deg);
  overflow: visible;
}

.progress-ring-bg {
  stroke: #e2e8f0;
}

.progress-ring-active {
  stroke: var(--brand);
  transition: stroke-dashoffset 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Feedback Mastery Badge */
.feedback-header.is-mastered {
  display: flex;
  align-items: center;
  gap: 8px;
}

.feedback-pill-badge.is-mastered-badge {
  background-color: var(--brand-light);
  color: var(--brand);
  border: 1px solid var(--brand-border);
  animation: pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.08);
  font-weight: 700;
}

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

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.4);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(79, 70, 229, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(79, 70, 229, 0);
  }
}

@keyframes pop {
  0% {
    transform: scale(0.85);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}
