/* ==========================================================================
   STUDY COMPANION — DESIGN SYSTEM & COMPONENT STYLESHEET
   A focused, calm, high-legibility interface for academic reading and mastery.
   Sections:
     1. Design Tokens & Themes (Light & Dark)
     2. Reset & Base Typography
     3. Layout & Shared Utilities
     4. App Header & Sequential Stepper
     5. Buttons, Controls & Form Elements
     6. Landing & Upload Flow
     7. Study Workspace (Two-Pane Reader & Q&A Chatbot)
     8. Quiz Studio (Config, Active Testing & Scorecard)
     9. Feedback Cards & Toast Notifications
     10. Responsive Breakpoints & Accessibility (Reduced Motion)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. DESIGN TOKENS & THEMES
   -------------------------------------------------------------------------- */
:root {
  /* Typography Scale */
  --font-serif: 'Newsreader', Georgia, Cambria, 'Times New Roman', serif;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', SFMono-Regular, Consolas, Monaco, monospace;

  /* Modular Font Sizes */
  --text-2xs: 0.6875rem; /* 11px */
  --text-xs: 0.75rem;    /* 12px */
  --text-sm: 0.84375rem; /* 13.5px */
  --text-base: 0.9375rem;/* 15px */
  --text-reader: 1.03125rem; /* 16.5px */
  --text-md: 1.0625rem;  /* 17px */
  --text-lg: 1.1875rem;  /* 19px */
  --text-xl: 1.375rem;   /* 22px */
  --text-2xl: 1.625rem;  /* 26px */
  --text-3xl: 2.125rem;  /* 34px */

  /* 4px Base Spacing Scale */
  --space-1: 0.25rem;  /* 4px */
  --space-2: 0.5rem;   /* 8px */
  --space-3: 0.75rem;  /* 12px */
  --space-4: 1rem;     /* 16px */
  --space-5: 1.25rem;  /* 20px */
  --space-6: 1.5rem;   /* 24px */
  --space-8: 2rem;     /* 32px */
  --space-10: 2.5rem;  /* 40px */
  --space-12: 3rem;    /* 48px */
  --space-16: 4rem;    /* 64px */

  /* Radii */
  --radius-xs: 3px;
  --radius-sm: 5px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-pill: 9999px;

  /* Motion & Transitions */
  --duration-fast: 140ms;
  --duration-normal: 200ms;
  --duration-slow: 320ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);

  /* Light Theme — Tactile Paper & Deep Scholar Teal (Default) */
  --bg-canvas: #FAF8F5;
  --bg-surface: #FFFFFF;
  --bg-muted: #F3EFE6;
  --bg-subtle: #ECE6DA;
  --bg-overlay: rgba(250, 248, 245, 0.85);

  --border-subtle: #E5DFC0;
  --border-base: #E2DDD3;
  --border-strong: #CDC6B8;
  --border-focus: #1B524E;

  --accent: #1B524E;
  --accent-hover: #133E3B;
  --accent-active: #0D2C2A;
  --accent-subtle: #EAF2F1;
  --accent-subtle-border: #A9CBC8;
  --accent-fg: #FFFFFF;

  --text-primary: #191C1B;
  --text-secondary: #515655;
  --text-muted: #7A8280;
  --text-faint: #A3ACA9;

  /* Semantic Palettes (Muted, Accessible, Human) */
  --semantic-evidence: #21633F;
  --semantic-evidence-bg: #EDF7F1;
  --semantic-evidence-border: #A6D7BA;

  --semantic-caution: #8C5311;
  --semantic-caution-bg: #FFF8EB;
  --semantic-caution-border: #F0CE9C;

  --semantic-incorrect: #9E2B2B;
  --semantic-incorrect-bg: #FDF2F2;
  --semantic-incorrect-border: #F2B9B9;

  /* Warm Highlighter Effect */
  --highlighter-bg: #FFF099;
  --highlighter-border: #FDE047;
  --highlighter-glow: rgba(253, 224, 71, 0.35);

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(25, 28, 27, 0.04), 0 1px 3px rgba(25, 28, 27, 0.05);
  --shadow-md: 0 4px 12px -2px rgba(25, 28, 27, 0.06), 0 2px 5px -1px rgba(25, 28, 27, 0.04);
  --shadow-lg: 0 12px 28px -6px rgba(25, 28, 27, 0.08), 0 4px 12px -2px rgba(25, 28, 27, 0.04);
}

/* Dark Theme — Soft Graphite Slate & Luminous Sage Teal */
[data-theme="dark"] {
  --bg-canvas: #121516;
  --bg-surface: #1A1E20;
  --bg-muted: #222629;
  --bg-subtle: #2B3135;
  --bg-overlay: rgba(18, 21, 22, 0.88);

  --border-subtle: #292E33;
  --border-base: #30373D;
  --border-strong: #414B53;
  --border-focus: #52B8AC;

  --accent: #52B8AC;
  --accent-hover: #6DC7BC;
  --accent-active: #82D4CA;
  --accent-subtle: rgba(82, 184, 172, 0.12);
  --accent-subtle-border: rgba(82, 184, 172, 0.35);
  --accent-fg: #0E1A18;

  --text-primary: #ECEFED;
  --text-secondary: #A0A9A7;
  --text-muted: #727C7A;
  --text-faint: #4E5655;

  --semantic-evidence: #57BA82;
  --semantic-evidence-bg: rgba(87, 186, 130, 0.12);
  --semantic-evidence-border: rgba(87, 186, 130, 0.32);

  --semantic-caution: #E8A348;
  --semantic-caution-bg: rgba(232, 163, 72, 0.12);
  --semantic-caution-border: rgba(232, 163, 72, 0.32);

  --semantic-incorrect: #E86B6B;
  --semantic-incorrect-bg: rgba(232, 107, 107, 0.12);
  --semantic-incorrect-border: rgba(232, 107, 107, 0.32);

  --highlighter-bg: rgba(255, 229, 107, 0.22);
  --highlighter-border: rgba(255, 229, 107, 0.45);
  --highlighter-glow: rgba(255, 229, 107, 0.2);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.55);
}

/* --------------------------------------------------------------------------
   2. RESET & BASE TYPOGRAPHY
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  line-height: 1.6;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  height: 100%;
}

body.page-body {
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* Clean accessible focus indicators */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

img, svg {
  display: block;
}

/* Base Headings */
h1, h2, h3, h4, h5 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.25;
  color: var(--text-primary);
  letter-spacing: -0.012em;
}

p {
  color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   3. LAYOUT & SHARED UTILITIES
   -------------------------------------------------------------------------- */
.btn-svg, .search-icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  stroke: currentColor;
}

.text-secondary {
  color: var(--text-secondary);
}

.btn-spinner {
  animation: spin 0.9s linear infinite;
  display: inline-block;
  vertical-align: middle;
  stroke: currentColor;
}

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

/* --------------------------------------------------------------------------
   4. APP HEADER & SEQUENTIAL STEPPER
   -------------------------------------------------------------------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 52px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-base);
  padding: 0 var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  transition: background-color var(--duration-normal) var(--ease-out),
              border-color var(--duration-normal) var(--ease-out);
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.brand-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.brand-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background-color: var(--accent-subtle);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent-subtle-border);
}

.brand-title {
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.brand-sep {
  color: var(--text-faint);
  margin: 0 1px;
}

.brand-sub {
  color: var(--text-secondary);
  font-weight: 500;
}

/* Active Topic Pill in Header */
.active-topic-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background-color: var(--bg-muted);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-pill);
  padding: 3px 10px 3px 8px;
  font-size: var(--text-xs);
  max-width: 320px;
}

.topic-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--semantic-evidence);
  flex-shrink: 0;
}

.topic-name {
  color: var(--text-primary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topic-change-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--accent);
  font-weight: 500;
  padding-left: 4px;
  border-left: 1px solid var(--border-strong);
  margin-left: 2px;
  transition: opacity var(--duration-fast) var(--ease-out);
}

.topic-change-btn:hover {
  opacity: 0.8;
}

/* Engine Status Tag */
.engine-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background-color: var(--bg-muted);
  border: 1px solid var(--border-subtle);
}

.status-indicator-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--semantic-evidence);
  flex-shrink: 0;
}

.status-indicator-dot.online {
  background-color: var(--semantic-evidence);
}

/* Minimal Theme Toggle Button */
.theme-toggle-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-muted);
  border: 1px solid var(--border-base);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
}

.theme-toggle-btn:hover {
  background-color: var(--bg-subtle);
  color: var(--text-primary);
}

.theme-toggle-btn:active {
  transform: scale(0.96);
}

.theme-icon-light, .theme-icon-dark {
  display: none;
}

[data-theme="dark"] .theme-icon-light {
  display: block;
}

:root:not([data-theme="dark"]) .theme-icon-dark {
  display: block;
}

/* ==========================================================================
   Sequential Stepper (Calm Journey, Upload -> Study -> Quiz)
   ========================================================================== */
.learning-flow-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-base);
  font-size: var(--text-xs);
}

.flow-step-link {
  text-decoration: none;
  color: inherit;
  display: inline-flex;
  align-items: center;
}

.flow-step {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  transition: background-color var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}

.flow-step-link:hover .flow-step {
  color: var(--text-primary);
  background-color: var(--bg-muted);
}

.flow-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-2xs);
  font-weight: 600;
  font-family: var(--font-mono);
  background-color: var(--bg-muted);
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
}

.flow-title {
  font-weight: 500;
  letter-spacing: -0.005em;
}

.flow-divider {
  color: var(--border-strong);
  font-size: var(--text-xs);
  user-select: none;
}

/* Completed Step */
.flow-step.completed {
  color: var(--text-secondary);
}

.flow-step.completed .flow-num {
  background-color: var(--semantic-evidence-bg);
  border-color: var(--semantic-evidence-border);
  color: var(--semantic-evidence);
}

/* Active Current Step */
.flow-step.active {
  color: var(--text-primary);
  background-color: var(--accent-subtle);
  border: 1px solid var(--accent-subtle-border);
}

.flow-step.active .flow-num {
  background-color: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

.flow-step.active .flow-title {
  font-weight: 600;
  color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   5. BUTTONS, CONTROLS & FORM ELEMENTS
   -------------------------------------------------------------------------- */
.btn-primary, .btn-secondary, .btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-weight: 500;
  font-size: var(--text-sm);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  transition: background-color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
  white-space: nowrap;
}

.btn-primary:active, .btn-secondary:active, .btn-ghost:active {
  transform: scale(0.98);
}

/* Primary Button — Confident, visually dominant */
.btn-primary {
  background-color: var(--accent);
  color: var(--accent-fg);
  border: 1px solid var(--accent);
  box-shadow: var(--shadow-sm);
}

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

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* Secondary Button — Subdued, clear boundary */
.btn-secondary {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--bg-muted);
  border-color: var(--text-muted);
}

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

/* Ghost Button — Flat, quiet */
.btn-ghost {
  background-color: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
}

.btn-ghost:hover:not(:disabled) {
  background-color: var(--bg-muted);
  color: var(--text-primary);
}

/* Sizing Modifiers */
.btn-large {
  padding: 12px 24px;
  font-size: var(--text-base);
  border-radius: var(--radius-md);
}

.btn-sm {
  padding: 5px 11px;
  font-size: var(--text-xs);
  border-radius: var(--radius-xs);
}

.btn-xs {
  padding: 3px 8px;
  font-size: var(--text-2xs);
  border-radius: var(--radius-xs);
}

.btn-full {
  width: 100%;
}

/* Form Inputs & Textareas */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.form-label {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text-primary);
}

.form-input, .form-textarea, .config-select {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: var(--text-base);
  line-height: 1.5;
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}

.form-input:focus, .form-textarea:focus, .config-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.form-textarea {
  resize: vertical;
  line-height: 1.65;
}

/* --------------------------------------------------------------------------
   6. LANDING & UPLOAD FLOW
   -------------------------------------------------------------------------- */
.landing-main, .home-container {
  max-width: 1140px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-6);
  width: 100%;
  flex: 1;
}

.landing-hero, .home-hero {
  max-width: 760px;
  margin-bottom: var(--space-8);
}

.landing-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  background-color: var(--accent-subtle);
  border: 1px solid var(--accent-subtle-border);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  margin-bottom: var(--space-3);
}

.landing-title, .home-hero-title {
  font-size: var(--text-3xl);
  font-weight: 600;
  margin-bottom: var(--space-3);
  letter-spacing: -0.02em;
}

.landing-desc, .home-hero-desc {
  font-size: var(--text-md);
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: var(--space-6);
}

.landing-actions-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* How It Works Row on Landing (Linear / Notion Style, Clean Timeline) */
.landing-steps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-5);
  margin-top: var(--space-10);
  padding-top: var(--space-8);
  border-top: 1px solid var(--border-base);
}

.landing-step-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-5);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.landing-step-badge {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-muted);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.landing-step-title {
  font-size: var(--text-lg);
  font-weight: 600;
}

.landing-step-text {
  font-size: var(--text-sm);
  line-height: 1.6;
}

/* Home / Upload Grid Layout */
.home-grid {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: var(--space-6);
  align-items: start;
}

.home-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.card-header-clean {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}

.card-icon-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-primary);
}

.card-heading {
  font-size: var(--text-lg);
  font-weight: 600;
}

.header-pill {
  font-size: var(--text-2xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background-color: var(--bg-muted);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

/* Drag & Drop Zone */
.drop-zone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-6) var(--space-4);
  text-align: center;
  background-color: var(--bg-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-out),
              background-color var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
  margin-bottom: var(--space-4);
}

.drop-zone:hover {
  border-color: var(--text-muted);
  background-color: var(--bg-subtle);
}

.drop-zone.dragover {
  border-color: var(--accent);
  background-color: var(--accent-subtle);
  transform: scale(1.01);
}

.drop-icon {
  color: var(--text-muted);
  stroke-width: 1.75;
}

.drop-text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.drop-browse-btn {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  margin-left: 3px;
}

/* Textarea live counters */
.textarea-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-1);
}

.live-metrics-bar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.metric-pill {
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  background-color: var(--bg-muted);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.card-action-row {
  margin-top: var(--space-4);
}

/* Presets Card (Curated Academic Reference) */
.presets-intro-text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: var(--space-4);
}

.preset-cards-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.preset-topic-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}

.preset-topic-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.preset-topic-card.active-preset {
  border-color: var(--accent-subtle-border);
  background-color: var(--accent-subtle);
}

.preset-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}

.preset-badge {
  font-size: var(--text-2xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-base);
  padding: 2px 7px;
  border-radius: var(--radius-xs);
}

.preset-pages {
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  color: var(--text-muted);
}

.preset-card-title {
  font-size: var(--text-base);
  font-weight: 600;
  margin-bottom: var(--space-2);
}

.preset-card-summary {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: var(--space-3);
}

.preset-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--space-2);
  border-top: 1px solid var(--border-subtle);
}

.preset-meta-tag {
  font-size: var(--text-2xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.preset-loading-skeleton {
  font-size: var(--text-sm);
  color: var(--text-muted);
  padding: var(--space-4);
  text-align: center;
}

/* App Footer */
.app-footer {
  border-top: 1px solid var(--border-base);
  background-color: var(--bg-surface);
  padding: var(--space-4) var(--space-6);
  margin-top: auto;
}

.footer-inner {
  max-width: 1140px;
  margin: 0 auto;
  font-size: var(--text-xs);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* --------------------------------------------------------------------------
   7. STUDY WORKSPACE (TWO-PANE READER & Q&A CHATBOT)
   -------------------------------------------------------------------------- */
.study-workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: calc(100vh - 52px - 37px); /* header (52px) + stepper (37px) */
  min-height: 480px;
  overflow: hidden;
  background-color: var(--bg-canvas);
}

/* Common Pane Styling */
.reader-column, .qa-column {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.reader-column {
  border-right: 1px solid var(--border-base);
  background-color: var(--bg-surface);
}

.qa-column {
  background-color: var(--bg-canvas);
}

/* Left Pane: Document Reader Header */
.reader-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-base);
  padding: var(--space-3) var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.reader-title-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.reader-icon {
  color: var(--accent);
}

.reader-heading {
  font-size: var(--text-base);
  font-weight: 600;
  margin: 0;
}

.reader-sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Pinned Search Input */
.reader-search-wrap {
  position: relative;
  width: 240px;
}

.reader-search-wrap .search-icon {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.reader-search-input {
  width: 100%;
  background-color: var(--bg-muted);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-sm);
  padding: 6px 10px 6px 28px;
  font-size: var(--text-xs);
  color: var(--text-primary);
  transition: background-color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}

.reader-search-input:focus {
  outline: none;
  background-color: var(--bg-surface);
  border-color: var(--border-focus);
}

.reader-meta-bar {
  background-color: var(--bg-muted);
  border-bottom: 1px solid var(--border-subtle);
  padding: 6px var(--space-6);
  font-size: var(--text-2xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Scrollable Document Container */
.notes-document-reader {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6) var(--space-8);
  font-family: var(--font-serif);
  font-size: var(--text-reader);
  line-height: 1.74;
  color: var(--text-primary);
  scroll-behavior: smooth;
}

/* Custom Slim Scrollbars */
.notes-document-reader::-webkit-scrollbar,
.chat-thread-container::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.notes-document-reader::-webkit-scrollbar-track,
.chat-thread-container::-webkit-scrollbar-track {
  background: transparent;
}

.notes-document-reader::-webkit-scrollbar-thumb,
.chat-thread-container::-webkit-scrollbar-thumb {
  background-color: var(--border-strong);
  border-radius: var(--radius-pill);
}

.notes-document-reader::-webkit-scrollbar-thumb:hover,
.chat-thread-container::-webkit-scrollbar-thumb:hover {
  background-color: var(--text-muted);
}

.reader-empty {
  padding: var(--space-8);
  text-align: center;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
}

/* Sections & Headings inside Reader */
.reader-section {
  margin-bottom: var(--space-8);
}

.reader-section-title {
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  font-weight: 600;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

/* Reader Paragraph with § Marker in Gutter */
.reader-paragraph {
  position: relative;
  margin-bottom: var(--space-4);
  padding: var(--space-2) var(--space-2) var(--space-2) 26px;
  border-radius: var(--radius-sm);
  transition: background-color var(--duration-fast) var(--ease-out);
}

.para-marker {
  position: absolute;
  left: 2px;
  top: 9px;
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  color: var(--text-muted);
  user-select: none;
  opacity: 0.6;
}

.reader-paragraph:hover .para-marker {
  opacity: 1;
  color: var(--accent);
}

.para-line {
  display: block;
  margin-bottom: var(--space-1);
}

.para-line.is-bullet {
  padding-left: 18px;
  position: relative;
}

.bullet-dot {
  position: absolute;
  left: 4px;
  color: var(--text-muted);
  font-size: var(--text-xs);
}

/* Note Sentence: Interactive styling */
.note-sentence {
  display: inline;
  padding: 1px 2px;
  border-radius: var(--radius-xs);
  cursor: text;
  transition: background-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}

.note-sentence:hover {
  background-color: var(--bg-muted);
  text-decoration-line: underline;
  text-decoration-style: dotted;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 3px;
}

/* Search Term Match */
.note-sentence.search-match {
  background-color: rgba(253, 224, 71, 0.35);
  outline: 1px solid var(--highlighter-border);
}

/* Realistic Warm Highlighter (for Verbatim Evidence) */
.note-sentence.evidence-highlighted,
.note-sentence.highlighted-sentence {
  background-color: var(--highlighter-bg);
  border-radius: 2px;
  padding: 2px 4px;
  box-shadow: 0 0 0 1px var(--highlighter-border);
  animation: pulseHighlight 1.3s var(--ease-out) 1;
}

.reader-paragraph.para-highlighted {
  background-color: var(--accent-subtle);
  border-left: 3px solid var(--accent);
}

@keyframes pulseHighlight {
  0% {
    background-color: rgba(253, 224, 71, 0.9);
    box-shadow: 0 0 10px var(--highlighter-glow);
  }
  50% {
    background-color: var(--highlighter-bg);
    box-shadow: 0 0 6px var(--highlighter-glow);
  }
  100% {
    background-color: var(--highlighter-bg);
    box-shadow: 0 0 0 1px var(--highlighter-border);
  }
}

/* --------------------------------------------------------------------------
   Right Pane: AI Study Chatbot Console
   -------------------------------------------------------------------------- */
.qa-console-card.chatbot-card {
  height: 100%;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-canvas);
}

/* Chatbot Sticky Header */
.qa-card-header.chatbot-header {
  padding: var(--space-3) var(--space-5);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-base);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.qa-header-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.chatbot-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background-color: var(--accent-subtle);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent-subtle-border);
}

.chatbot-status-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.chatbot-engine-tag {
  font-size: var(--text-2xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Chat Mode Switcher */
.chat-mode-toggle-group {
  display: inline-flex;
  align-items: center;
  background-color: var(--bg-muted);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}

.chat-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--text-2xs);
  font-weight: 500;
  padding: 4px 9px;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  transition: background-color var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
}

.chat-mode-btn.active {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.btn-clear-chat {
  margin-left: 2px;
  border-left: 1px solid var(--border-subtle);
  padding-left: 6px;
}

/* Chat Mode Guidance Banner */
.chat-mode-banner {
  padding: 6px var(--space-5);
  font-size: var(--text-xs);
  line-height: 1.45;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}

.chat-mode-banner.strict-banner {
  background-color: var(--accent-subtle);
  color: var(--text-primary);
  border-bottom-color: var(--accent-subtle-border);
}

.chat-mode-banner.general-banner {
  background-color: var(--bg-muted);
  color: var(--text-secondary);
}

/* Scrollable Message Thread */
.chat-thread-container {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  scroll-behavior: smooth;
}

.chat-msg {
  display: flex;
  gap: var(--space-3);
  max-width: 88%;
  animation: messageEntrance var(--duration-normal) var(--ease-out);
}

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

.chat-msg.user-msg {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-msg.assistant-msg {
  align-self: flex-start;
}

.msg-avatar {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-2xs);
  font-weight: 600;
  font-family: var(--font-mono);
  flex-shrink: 0;
  background-color: var(--bg-muted);
  border: 1px solid var(--border-base);
  color: var(--text-secondary);
}

.user-msg .msg-avatar {
  background-color: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

.msg-bubble {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  line-height: 1.6;
  box-shadow: var(--shadow-sm);
}

.user-msg .msg-bubble {
  background-color: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

.user-msg .msg-bubble p {
  color: var(--accent-fg);
}

/* Refusal Box (Calm, Informative Amber) */
.msg-bubble.msg-refusal-box {
  background-color: var(--semantic-caution-bg);
  border: 1px solid var(--semantic-caution-border);
  color: var(--text-primary);
}

.msg-bubble.msg-refusal-box p {
  color: var(--text-primary);
}

/* Evidence Footer inside Assistant Bubble */
.chat-evidence-footer {
  margin-top: var(--space-3);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.evidence-chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--text-2xs);
  font-weight: 500;
  background-color: var(--semantic-evidence-bg);
  color: var(--semantic-evidence);
  border: 1px solid var(--semantic-evidence-border);
  padding: 4px 9px;
  border-radius: var(--radius-xs);
  transition: transform var(--duration-fast) var(--ease-out),
              background-color var(--duration-fast) var(--ease-out);
}

.evidence-chip-btn:hover {
  transform: translateY(-1px);
  background-color: var(--semantic-evidence-bg);
  box-shadow: var(--shadow-sm);
}

.evidence-chip-btn:active {
  transform: scale(0.97);
}

/* Typing Indicator */
.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 12px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.typing-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background-color: var(--text-muted);
  animation: typingBounce 1.2s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }
.typing-dot:nth-child(4) { animation-delay: 0.45s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-4px); opacity: 1; }
}

/* Demo Chips Bar */
.demo-chips-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px var(--space-5);
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
}

.chips-label {
  font-size: var(--text-2xs);
  color: var(--text-muted);
  font-weight: 600;
}

.demo-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--text-2xs);
  padding: 4px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-base);
  background-color: var(--bg-muted);
  color: var(--text-secondary);
  transition: background-color var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}

.demo-chip:hover {
  background-color: var(--bg-subtle);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.chip-supported {
  color: var(--semantic-evidence);
  border-color: var(--semantic-evidence-border);
  background-color: var(--semantic-evidence-bg);
}

.chip-unsupported {
  color: var(--semantic-caution);
  border-color: var(--semantic-caution-border);
  background-color: var(--semantic-caution-bg);
}

/* Chat Input Area */
.chat-input-area {
  padding: var(--space-3) var(--space-5);
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-base);
  display: flex;
  gap: var(--space-2);
  align-items: flex-end;
}

.chat-textarea {
  flex: 1;
  background-color: var(--bg-muted);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: var(--text-sm);
  line-height: 1.5;
  resize: none;
  min-height: 38px;
  max-height: 120px;
  transition: background-color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}

.chat-textarea:focus {
  outline: none;
  background-color: var(--bg-surface);
  border-color: var(--border-focus);
}

.btn-submit-qa {
  flex-shrink: 0;
  height: 38px;
  padding: 0 16px;
}

/* --------------------------------------------------------------------------
   8. QUIZ STUDIO (CONFIG, ACTIVE TESTING & SCORECARD)
   -------------------------------------------------------------------------- */
.quiz-studio-container {
  max-width: 820px;
  margin: var(--space-8) auto;
  padding: 0 var(--space-6);
  width: 100%;
  flex: 1;
}

/* PANEL 1: Quiz Configuration Card */
.quiz-config-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  box-shadow: var(--shadow-sm);
}

.config-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}

.config-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background-color: var(--accent-subtle);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent-subtle-border);
  flex-shrink: 0;
}

.config-title {
  font-size: var(--text-2xl);
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.config-desc {
  font-size: var(--text-sm);
  line-height: 1.6;
}

.config-section {
  margin-bottom: var(--space-6);
}

.config-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.config-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.count-display-badge {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--accent);
  background-color: var(--accent-subtle);
  border: 1px solid var(--accent-subtle-border);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}

/* Polished Slider Track & Thumb */
.slider-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.limit-bound-marker {
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  color: var(--text-muted);
}

.quiz-range-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: var(--radius-pill);
  background-color: var(--bg-subtle);
  outline: none;
  cursor: pointer;
}

.quiz-range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background-color: var(--accent);
  border: 2px solid var(--bg-surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-out),
              background-color var(--duration-fast) var(--ease-out);
}

.quiz-range-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  background-color: var(--accent-hover);
}

.quiz-range-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background-color: var(--accent);
  border: 2px solid var(--bg-surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.quiz-number-input {
  width: 58px;
  text-align: center;
  font-family: var(--font-mono);
  font-weight: 600;
  padding: 6px 4px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface);
  color: var(--text-primary);
}

/* Quick Count Pills Segmented Control */
.count-pills-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.pills-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.count-pill {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  background-color: var(--bg-muted);
  border: 1px solid var(--border-base);
  color: var(--text-secondary);
  transition: background-color var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}

.count-pill:hover {
  background-color: var(--bg-subtle);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.count-pill.active-pill {
  background-color: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
  font-weight: 600;
}

.config-action-row {
  margin-top: var(--space-6);
}

/* PANEL 2: Active Question Card */
.quiz-active-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  box-shadow: var(--shadow-sm);
  animation: cardEntrance var(--duration-normal) var(--ease-out);
}

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

.active-quiz-header {
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}

.progress-info-group {
  margin-bottom: var(--space-3);
}

.progress-count-text {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  font-family: var(--font-mono);
  display: block;
  margin-bottom: var(--space-2);
}

.progress-bar-track {
  width: 100%;
  height: 5px;
  border-radius: var(--radius-pill);
  background-color: var(--bg-muted);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background-color: var(--accent);
  border-radius: var(--radius-pill);
  transition: width 240ms var(--ease-out);
}

.learner-profile-bar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.profile-stat-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--text-xs);
}

.profile-label {
  color: var(--text-muted);
}

.profile-val {
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.profile-val.diff-tag {
  color: var(--accent);
}

/* Question Content */
.question-body-card {
  margin-bottom: var(--space-6);
}

.q-meta-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.q-concept-badge, .q-difficulty-badge {
  font-size: var(--text-2xs);
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.q-concept-badge {
  background-color: var(--bg-muted);
  border: 1px solid var(--border-base);
  color: var(--text-secondary);
}

.q-difficulty-badge {
  background-color: var(--accent-subtle);
  border: 1px solid var(--accent-subtle-border);
  color: var(--accent);
}

.q-text {
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  font-weight: 600;
  line-height: 1.45;
  color: var(--text-primary);
  margin-bottom: var(--space-6);
}

/* Option Cards (A, B, C, D) */
.q-options-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.quiz-option-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  text-align: left;
  transition: background-color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}

.quiz-option-btn:hover:not(:disabled) {
  background-color: var(--bg-muted);
  border-color: var(--text-muted);
  transform: translateY(-1px);
}

.quiz-option-btn:active:not(:disabled) {
  transform: scale(0.99);
}

.option-letter {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-muted);
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.option-text {
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--text-primary);
  flex: 1;
}

/* Selected State */
.quiz-option-btn.selected-option {
  background-color: var(--accent-subtle);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.quiz-option-btn.selected-option .option-letter {
  background-color: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

/* Correct State (Green) */
.quiz-option-btn.option-correct {
  background-color: var(--semantic-evidence-bg);
  border-color: var(--semantic-evidence);
  box-shadow: 0 0 0 1px var(--semantic-evidence);
}

.quiz-option-btn.option-correct .option-letter {
  background-color: var(--semantic-evidence);
  border-color: var(--semantic-evidence);
  color: #FFFFFF;
}

.correct-answer-tag {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--semantic-evidence);
  background-color: var(--bg-surface);
  border: 1px solid var(--semantic-evidence-border);
  padding: 2px 7px;
  border-radius: var(--radius-xs);
}

/* Incorrect State (Rose) */
.quiz-option-btn.option-incorrect {
  background-color: var(--semantic-incorrect-bg);
  border-color: var(--semantic-incorrect);
  box-shadow: 0 0 0 1px var(--semantic-incorrect);
}

.quiz-option-btn.option-incorrect .option-letter {
  background-color: var(--semantic-incorrect);
  border-color: var(--semantic-incorrect);
  color: #FFFFFF;
}

.incorrect-answer-tag {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--semantic-incorrect);
  background-color: var(--bg-surface);
  border: 1px solid var(--semantic-incorrect-border);
  padding: 2px 7px;
  border-radius: var(--radius-xs);
}

/* Progressive Hints Accordion */
.hints-accordion {
  margin-bottom: var(--space-6);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
}

.hints-btn-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.hints-intro-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 500;
}

.btn-hint-toggle {
  background-color: var(--bg-muted);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-xs);
}

.btn-hint-toggle.hint-opened {
  background-color: var(--accent-subtle);
  border-color: var(--accent-subtle-border);
  color: var(--accent);
}

.hint-box {
  background-color: var(--bg-muted);
  border: 1px solid var(--border-base);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-xs);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-2);
  animation: cardEntrance var(--duration-fast) var(--ease-out);
}

.hint-header {
  font-size: var(--text-2xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin-bottom: 3px;
}

.hint-text {
  font-size: var(--text-sm);
  color: var(--text-primary);
  line-height: 1.5;
}

.q-actions-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* Diagnostic Feedback Card */
.quiz-feedback-card {
  margin-top: var(--space-6);
  padding: var(--space-5);
  border-radius: var(--radius-md);
  animation: cardEntrance var(--duration-normal) var(--ease-out);
}

.quiz-feedback-card.feedback-correct {
  background-color: var(--semantic-evidence-bg);
  border: 1px solid var(--semantic-evidence-border);
  border-left: 4px solid var(--semantic-evidence);
}

.quiz-feedback-card.feedback-incorrect {
  background-color: var(--semantic-incorrect-bg);
  border: 1px solid var(--semantic-incorrect-border);
  border-left: 4px solid var(--semantic-incorrect);
}

.feedback-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.feedback-badge {
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
}

.badge-correct {
  background-color: var(--semantic-evidence);
  color: #FFFFFF;
}

.badge-misconception {
  background-color: var(--semantic-incorrect);
  color: #FFFFFF;
}

.feedback-headline {
  font-size: var(--text-base);
  font-weight: 600;
}

.feedback-body {
  font-size: var(--text-sm);
  line-height: 1.6;
  color: var(--text-primary);
  margin-bottom: var(--space-4);
}

.feedback-evidence-box {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
}

.feedback-ev-label {
  font-size: var(--text-2xs);
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-1);
}

.feedback-blockquote {
  font-family: var(--font-serif);
  font-size: var(--text-sm);
  line-height: 1.6;
  color: var(--text-primary);
  font-style: italic;
  margin-bottom: var(--space-1);
}

.feedback-ev-meta {
  font-size: var(--text-2xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* PANEL 3: Scorecard Summary */
.quiz-summary-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-lg);
  padding: var(--space-10) var(--space-8);
  text-align: center;
  box-shadow: var(--shadow-sm);
  animation: cardEntrance var(--duration-normal) var(--ease-out);
}

.summary-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: var(--semantic-evidence-bg);
  border: 1px solid var(--semantic-evidence-border);
  color: var(--semantic-evidence);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-4);
}

.summary-title {
  font-size: var(--text-2xl);
  font-weight: 600;
  margin-bottom: var(--space-2);
}

.summary-score-large {
  font-family: var(--font-mono);
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--accent);
  margin-bottom: var(--space-1);
}

.summary-score-sub {
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-bottom: var(--space-6);
}

.summary-breakdown {
  max-width: 540px;
  margin: 0 auto var(--space-8);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text-secondary);
}

.summary-actions-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   9. FEEDBACK CARDS & TOAST NOTIFICATIONS
   -------------------------------------------------------------------------- */
.app-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-size: var(--text-sm);
  font-weight: 500;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
  max-width: 400px;
}

.app-toast.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.app-toast.toast-success {
  border-left: 4px solid var(--semantic-evidence);
}

.app-toast.toast-error {
  border-left: 4px solid var(--semantic-incorrect);
}

.app-toast.toast-info {
  border-left: 4px solid var(--accent);
}

/* --------------------------------------------------------------------------
   10. RESPONSIVE BREAKPOINTS & ACCESSIBILITY
   -------------------------------------------------------------------------- */
@media (max-width: 960px) {
  .study-workspace {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .reader-column {
    height: 60vh;
    border-right: none;
    border-bottom: 1px solid var(--border-base);
  }

  .qa-column {
    height: 65vh;
  }

  .home-grid {
    grid-template-columns: 1fr;
  }

  .landing-steps-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-header {
    padding: 0 var(--space-3);
  }

  .active-topic-badge {
    display: none;
  }

  .learning-flow-stepper .flow-title {
    display: none;
  }

  .learning-flow-stepper .flow-step {
    padding: 4px 6px;
  }

  .landing-main, .home-container, .quiz-studio-container {
    padding: var(--space-4) var(--space-3);
  }

  .quiz-config-card, .quiz-active-card, .quiz-summary-card, .home-card {
    padding: var(--space-5) var(--space-4);
  }

  .app-toast {
    left: 16px;
    right: 16px;
    bottom: 16px;
    max-width: none;
  }
}

/* Accessibility: Respect Reduced Motion Preferences */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
