/* ═══════════════════════════════════════════════════════
   Klaro PH — Stylesheet
   Modern, mobile-responsive exam reviewer & simulation UI
   ═══════════════════════════════════════════════════════ */

/* ── CSS Variables ── */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --primary-50: #eff6ff;
  --accent: #7c3aed;
  --accent-light: #ede9fe;
  --success: #059669;
  --success-light: #d1fae5;
  --success-bg: #ecfdf5;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --danger-bg: #fef2f2;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --warning-bg: #fffbeb;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --surface: #ffffff;
  --bg: #f1f5f9;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
  --transition: 0.2s ease;
  --header-h: 60px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

.screen.active { flex: 1; }

/* ── HEADER ── */
#app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--gray-900);
  font-weight: 700;
  font-size: 1.2rem;
}

.logo-icon { font-size: 1.5rem; }
.logo-ph { color: var(--primary); }

.header-nav {
  display: flex;
  gap: 0.25rem;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border: none;
  background: transparent;
  color: var(--gray-500);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.nav-btn:hover {
  background: var(--gray-100);
  color: var(--gray-700);
}

.nav-btn.active {
  background: var(--primary-light);
  color: var(--primary);
}

.nav-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn-discord:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ── FOOTER ── */
#app-footer {
  border-top: 1px solid var(--gray-200);
  background: var(--surface);
  padding: 1rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--gray-500);
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
}

#app-footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

#app-footer a:hover {
  text-decoration: underline;
}

/* ── SCREENS ── */
.screen { display: none; padding-top: 2rem; padding-bottom: 4rem; }
.screen.active { display: block; }

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ── HOME SCREEN ── */
.hero {
  text-align: center;
  margin-bottom: 2.5rem;
}

.hero h1 {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--gray-900);
  margin-bottom: 0.5rem;
}

.hero-sub {
  color: var(--gray-500);
  font-size: 1.05rem;
  max-width: 500px;
  margin: 0 auto;
}

/* Subject Cards */
.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.subject-card {
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1.5rem;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.subject-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.subject-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.subject-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 0.25rem;
  padding-right: 2rem;
}
.subject-card-subtitle {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-bottom: 0.75rem;
  line-height: 1.3;
}

.subject-card-meta {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.subject-meta-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--gray-500);
}

.subject-meta-item svg { flex-shrink: 0; }

.subject-best-score {
  position: absolute;
  top: 1rem;
  right: 1rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.best-score-pass {
  background: var(--success-light);
  color: var(--success);
}

.best-score-fail {
  background: var(--warning-light);
  color: var(--warning);
}

/* Loading / Error */
.loading-msg, .error-msg {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--gray-500);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

.app-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.app-loading-overlay[hidden] { display: none; }
.app-loading-inner { text-align: center; }
.app-loading-spinner { width: 48px; height: 48px; border-width: 4px; }
.app-loading-text {
  margin-top: 1rem;
  font-size: 1rem;
  font-weight: 500;
  color: var(--gray-500);
}
.app-loading-error {
  margin-top: 1rem;
  color: var(--danger);
  font-size: 0.9rem;
}
.app-loading-error button {
  margin-top: 0.5rem;
  padding: 0.4rem 1rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.85rem;
}

.error-msg { color: var(--danger); }
.error-msg code {
  background: var(--gray-100);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  font-size: 0.9em;
}

/* ── MODALS ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  position: relative;
  animation: slideUp 0.25s ease;
}

.modal-sm { max-width: 400px; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--gray-100);
  color: var(--gray-600);
  font-size: 1.25rem;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.modal-close:hover { background: var(--gray-200); color: var(--gray-800); }

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 0.25rem;
  padding-right: 2.5rem;
}

.modal-subtitle {
  color: var(--gray-500);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
  justify-content: flex-end;
}

.timesup-icon {
  font-size: 3rem;
  text-align: center;
  margin-bottom: 0.5rem;
}

/* ── FORMS ── */
.form-group { margin-bottom: 1.25rem; }

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.form-input {
  width: 100px;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-xs);
  font-size: 1rem;
  color: var(--gray-800);
  background: var(--surface);
  transition: border-color var(--transition);
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.input-hint {
  font-size: 0.85rem;
  color: var(--gray-400);
}

/* Mode Toggle */
.mode-toggle {
  display: flex;
  gap: 0.5rem;
}

.mode-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem;
  border: 2px solid var(--gray-200);
  background: var(--surface);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gray-600);
  cursor: pointer;
  transition: all var(--transition);
}

.mode-btn:hover { border-color: var(--gray-300); }

.mode-btn.active {
  border-color: var(--primary);
  background: var(--primary-50);
  color: var(--primary);
}

/* Checkboxes */
.checkbox-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  color: var(--gray-700);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.25rem;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn-lg { padding: 0.8rem 2rem; font-size: 1rem; width: 100%; }

.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-success {
  background: var(--success);
  color: white;
  border-color: var(--success);
}
.btn-success:hover { background: #047857; border-color: #047857; }

.btn-outline {
  background: transparent;
  color: var(--gray-700);
  border-color: var(--gray-300);
}
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-400); }

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

/* ── QUIZ SCREEN ── */
.quiz-topbar {
  position: sticky;
  top: var(--header-h);
  z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--gray-200);
}

.quiz-topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.quiz-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.quiz-mode-badge {
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.quiz-mode-badge.mode-practice {
  background: var(--accent-light);
  color: var(--accent);
}

.quiz-mode-badge.mode-exam {
  background: var(--warning-light);
  color: var(--warning);
}

.quiz-subject-label {
  font-size: 0.85rem;
  color: var(--gray-500);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quiz-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

.quiz-progress-text {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-700);
}

.quiz-timer {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gray-700);
  font-variant-numeric: tabular-nums;
}

.quiz-timer.timer-warning { color: var(--warning); }
.quiz-timer.timer-danger { color: var(--danger); animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.quiz-progress-bar {
  height: 3px;
  background: var(--gray-100);
}

.quiz-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.3s ease;
  width: 0%;
}

/* Quiz Layout */
.quiz-layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.quiz-main { flex: 1; min-width: 0; }

/* Question Card */
.question-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
}

.question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.question-number {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.flag-btn {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--gray-300);
  background: transparent;
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--gray-500);
  cursor: pointer;
  transition: all var(--transition);
}

.flag-btn:hover { border-color: var(--warning); color: var(--warning); }
.flag-btn.flagged {
  border-color: var(--warning);
  background: var(--warning-light);
  color: var(--warning);
}

.flag-text { display: none; }
@media (min-width: 480px) { .flag-text { display: inline; } }

.question-prompt {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--gray-800);
  margin-bottom: 1.25rem;
}

/* Options */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.option-btn {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  width: 100%;
  padding: 0.85rem 1rem;
  border: 2px solid var(--gray-200);
  background: var(--surface);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  color: var(--gray-700);
  cursor: pointer;
  text-align: left;
  transition: all var(--transition);
  line-height: 1.5;
}

.option-btn:hover:not(.disabled) {
  border-color: var(--primary);
  background: var(--primary-50);
}

.option-btn.selected {
  border-color: var(--primary);
  background: var(--primary-50);
  color: var(--primary-dark);
  font-weight: 600;
}

.option-btn.correct {
  border-color: var(--success);
  background: var(--success-bg);
  color: var(--success);
}

.option-btn.incorrect {
  border-color: var(--danger);
  background: var(--danger-bg);
  color: var(--danger);
}

.option-btn.disabled { cursor: default; opacity: 0.8; }
.option-btn.disabled:hover { border-color: var(--gray-200); background: var(--surface); }
.option-btn.correct.disabled:hover { border-color: var(--success); background: var(--success-bg); }
.option-btn.incorrect.disabled:hover { border-color: var(--danger); background: var(--danger-bg); }

.option-letter {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--gray-100);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  flex-shrink: 0;
  transition: all var(--transition);
}

.option-btn.selected .option-letter { background: var(--primary); color: white; }
.option-btn.correct .option-letter { background: var(--success); color: white; }
.option-btn.incorrect .option-letter { background: var(--danger); color: white; }

.option-text { flex: 1; padding-top: 0.15rem; }

/* Feedback */
.feedback-area {
  margin-top: 1.25rem;
  padding: 1rem;
  border-radius: var(--radius-sm);
  animation: slideUp 0.3s ease;
}

.feedback-area.feedback-correct {
  background: var(--success-bg);
  border: 1px solid var(--success-light);
}

.feedback-area.feedback-incorrect {
  background: var(--danger-bg);
  border: 1px solid var(--danger-light);
}

.feedback-badge {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
}

.feedback-area.feedback-correct .feedback-badge { color: var(--success); }
.feedback-area.feedback-incorrect .feedback-badge { color: var(--danger); }

.feedback-explanation {
  font-size: 0.9rem;
  color: var(--gray-700);
  line-height: 1.6;
}

/* Quiz Navigation */
.quiz-nav {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
  justify-content: space-between;
}

/* Quiz Sidebar / Navigator */
.quiz-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1rem;
  position: sticky;
  top: calc(var(--header-h) + 60px);
  box-shadow: var(--shadow-sm);
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.sidebar-header h3 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--gray-700);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.sidebar-close {
  display: none;
  width: 28px;
  height: 28px;
  border: none;
  background: var(--gray-100);
  border-radius: 50%;
  font-size: 1.1rem;
  color: var(--gray-600);
  cursor: pointer;
}

.navigator-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  color: var(--gray-500);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.legend-current { background: var(--primary); }
.legend-answered { background: var(--success); }
.legend-flagged { background: var(--warning); }
.legend-unanswered { background: var(--gray-200); border: 1px solid var(--gray-300); }

/* Navigator Grid */
.navigator-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 1rem;
}

.nav-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-xs);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  transition: all var(--transition);
  background: var(--surface);
  position: relative;
}

.nav-cell:hover { border-color: var(--gray-400); }

.nav-cell.current {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

.nav-cell.answered {
  border-color: var(--success);
  background: var(--success-light);
  color: var(--success);
}

.nav-cell.flagged {
  border-color: var(--warning);
  background: var(--warning-light);
  color: var(--warning);
}

.nav-cell.flagged::after {
  content: '⚑';
  position: absolute;
  top: -2px;
  right: 1px;
  font-size: 0.55rem;
}

.sidebar-footer {
  border-top: 1px solid var(--gray-200);
  padding-top: 0.75rem;
}

.answered-count {
  text-align: center;
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-bottom: 0.75rem;
}

.sidebar-footer .btn { width: 100%; }

/* Navigator FAB (Mobile) */
.navigator-fab {
  display: none;
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  z-index: 60;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.navigator-fab:hover { background: var(--primary-dark); transform: scale(1.05); }

/* ── RESULTS SCREEN ── */
.results-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2rem 0;
  gap: 1.5rem;
}

.score-ring {
  position: relative;
  width: 140px;
  height: 140px;
}

.score-ring svg { transform: rotate(-90deg); }

.score-ring-bg {
  fill: none;
  stroke: var(--gray-100);
  stroke-width: 8;
}

.score-ring-fill {
  fill: none;
  stroke: var(--primary);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 339.292;
  stroke-dashoffset: 339.292;
  transition: stroke-dashoffset 1.5s ease;
}

.score-ring-fill.passed { stroke: var(--success); }
.score-ring-fill.failed { stroke: var(--danger); }

.score-ring-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.score-pct {
  font-size: 2rem;
  font-weight: 800;
  color: var(--gray-900);
}

.results-headline h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--gray-800);
  margin-top: 0.5rem;
}

.results-subject {
  font-size: 0.9rem;
  color: var(--gray-500);
  margin-top: 0.25rem;
}

.pass-fail-badge {
  display: inline-block;
  padding: 0.35rem 1.25rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pass-fail-badge.passed {
  background: var(--success-light);
  color: var(--success);
}

.pass-fail-badge.failed {
  background: var(--danger-light);
  color: var(--danger);
}

/* Stats Row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 1rem;
  text-align: center;
}

.stat-number {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 0.2rem;
}

.stat-correct .stat-number { color: var(--success); }
.stat-incorrect .stat-number { color: var(--danger); }
.stat-unanswered-result .stat-number { color: var(--gray-400); }
.stat-time .stat-number { color: var(--primary); }

.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Section Card */
.section-card {
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 1rem;
}

/* Topic Breakdown */
.topic-breakdown {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.topic-row {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.topic-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
}

.topic-name {
  color: var(--gray-700);
  font-weight: 500;
}

.topic-score {
  color: var(--gray-500);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.topic-bar {
  height: 8px;
  background: var(--gray-100);
  border-radius: 999px;
  overflow: hidden;
}

.topic-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.8s ease;
  min-width: 2px;
}

.topic-bar-fill.bar-pass { background: var(--success); }
.topic-bar-fill.bar-fail { background: var(--danger); }
.topic-bar-fill.bar-warn { background: var(--warning); }

/* Review Controls */
.review-controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--gray-300);
  background: var(--surface);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  transition: all var(--transition);
}

.filter-btn:hover { border-color: var(--gray-400); }
.filter-btn.active { border-color: var(--primary); background: var(--primary-50); color: var(--primary); }

/* Review List */
.review-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.review-item {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.review-item-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background var(--transition);
}

.review-item-header:hover { background: var(--gray-50); }

.review-status-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.review-status-icon.status-correct {
  background: var(--success-light);
  color: var(--success);
}

.review-status-icon.status-incorrect {
  background: var(--danger-light);
  color: var(--danger);
}

.review-status-icon.status-unanswered {
  background: var(--gray-200);
  color: var(--gray-500);
}

.review-item-title {
  flex: 1;
  font-size: 0.9rem;
  color: var(--gray-700);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.review-item-flag {
  color: var(--warning);
  font-size: 0.85rem;
  flex-shrink: 0;
}

.review-expand-icon {
  color: var(--gray-400);
  font-size: 1rem;
  transition: transform var(--transition);
  flex-shrink: 0;
}

.review-item.expanded .review-expand-icon { transform: rotate(180deg); }

.review-item-body {
  display: none;
  padding: 0 1rem 1rem;
  border-top: 1px solid var(--gray-100);
}

.review-item.expanded .review-item-body { display: block; }

.review-question-text {
  font-size: 0.9rem;
  color: var(--gray-700);
  margin-bottom: 0.75rem;
  margin-top: 0.75rem;
  line-height: 1.6;
}

.review-answer-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.4rem 0;
  font-size: 0.85rem;
}

.review-answer-label {
  font-weight: 600;
  flex-shrink: 0;
  min-width: 100px;
}

.review-answer-label.label-yours { color: var(--gray-600); }
.review-answer-label.label-correct { color: var(--success); }

.review-explanation {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: var(--primary-50);
  border-radius: var(--radius-xs);
  font-size: 0.85rem;
  color: var(--gray-700);
  line-height: 1.6;
}

.review-explanation strong {
  color: var(--primary);
}

/* Results Actions */
.results-actions {
  display: flex;
  gap: 0.75rem;
  max-width: 500px;
  margin: 0 auto;
}

.results-actions .btn { flex: 1; }

/* ── HISTORY SCREEN ── */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.section-header h2 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--gray-900);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.history-item {
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: all var(--transition);
}

.history-item:hover { box-shadow: var(--shadow-sm); }

.history-score-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.history-score-circle.h-pass {
  background: var(--success-light);
  color: var(--success);
}

.history-score-circle.h-fail {
  background: var(--danger-light);
  color: var(--danger);
}

.history-details { flex: 1; min-width: 0; }

.history-subject {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-800);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-meta {
  display: flex;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--gray-500);
  flex-wrap: wrap;
}

.history-badge {
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.history-badge.h-exam { background: var(--warning-light); color: var(--warning); }
.history-badge.h-practice { background: var(--accent-light); color: var(--accent); }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--gray-400);
}

.empty-icon { margin-bottom: 1rem; }

/* ── MOBILE RESPONSIVE ── */
@media (max-width: 768px) {
  .hero h1 { font-size: 1.4rem; }
  .hero-sub { font-size: 0.95rem; }

  .subject-grid {
    grid-template-columns: 1fr;
  }

  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Quiz sidebar → drawer */
  .quiz-sidebar {
    position: fixed;
    top: 0;
    right: -300px;
    bottom: 0;
    width: 280px;
    border-radius: 0;
    z-index: 150;
    transition: right 0.3s ease;
    box-shadow: var(--shadow-xl);
    overflow-y: auto;
    padding-top: 1.5rem;
  }

  .quiz-sidebar.open { right: 0; }
  .sidebar-close { display: flex; align-items: center; justify-content: center; }
  .navigator-fab { display: flex; }

  /* Backdrop when sidebar open */
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 140;
    display: none;
  }

  .sidebar-backdrop.open { display: block; }

  .quiz-subject-label {
    display: none;
  }

  .results-actions {
    flex-direction: column;
  }

  .review-item-title {
    font-size: 0.85rem;
  }
}

@media (max-width: 480px) {
  .modal { padding: 1.5rem; }
  .question-card { padding: 1rem; }
  .quiz-nav { flex-wrap: wrap; }
  .quiz-nav .btn { font-size: 0.85rem; padding: 0.5rem 0.8rem; }

  .stats-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  .stat-number { font-size: 1.25rem; }

  .score-ring { width: 120px; height: 120px; }
  .score-pct { font-size: 1.6rem; }
}

/* ── UTILITIES ── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Smooth scroll for the whole page */
html { scroll-behavior: smooth; }

/* Selection styling */
::selection {
  background: var(--primary-light);
  color: var(--primary-dark);
}

/* ═══════════════════════════════════════════════════════
   Klaro PH — Extended SaaS & Simulation Styles
   ═══════════════════════════════════════════════════════ */

/* ── Discord Community Button (hidden until reimplemented) ── */
.btn-discord {
  display: none !important;
}
.btn-discord--visible {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: #5865F2;
  color: #ffffff !important;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 0.85rem;
  transition: background 0.2s ease, transform 0.15s ease;
  border: none;
  cursor: pointer;
}
.btn-discord:hover {
  background: #4752c4;
  transform: translateY(-1px);
}
.btn-discord svg {
  fill: currentColor;
  flex-shrink: 0;
}

/* ── Header Right Section & Auth ── */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-profile-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.6rem;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 20px;
  font-size: 0.85rem;
}
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--primary);
  font-size: 0.8rem;
}
.user-name {
  font-weight: 600;
  max-width: 110px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tier-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.tier-free {
  background: var(--gray-200);
  color: var(--gray-700);
}
.tier-pro, .tier-premium {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(217, 119, 6, 0.4);
}
.tier-expired {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(220, 38, 38, 0.4);
}

.btn-upgrade-nav {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  font-weight: 700;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.8rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  animation: pulse-gold 2.5s infinite;
}
@keyframes pulse-gold {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.5); }
  50% { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
}

/* ── 3-Hour Quota Meter Banner ── */
.quota-banner {
  background: #f8fafc;
  border-bottom: 1px solid var(--gray-200);
  padding: 0.45rem 1rem;
  font-size: 0.82rem;
  color: var(--gray-700);
}
.quota-banner-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.quota-items {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.quota-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: #fff;
  border: 1px solid var(--gray-300);
  border-radius: 12px;
  padding: 0.15rem 0.5rem;
  font-weight: 500;
}
.quota-pill strong {
  color: var(--primary);
}

/* ── LANDING / AUTH SCREEN ── */
.landing-hero {
  text-align: center;
  padding: 3.5rem 1rem 2.5rem;
  max-width: 900px;
  margin: 0 auto;
}
.landing-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--primary-50);
  color: var(--primary);
  border: 1px solid var(--primary-light);
  padding: 0.35rem 0.85rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
}
.landing-title {
  font-size: 2.75rem;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1.2;
  margin-bottom: 1rem;
}
.landing-title-brand {
  display: block;
  white-space: nowrap;
  color: var(--primary);
}
.landing-sub {
  font-size: 1.15rem;
  color: var(--gray-600);
  max-width: 680px;
  margin: 0 auto 2rem;
}

.auth-card-box {
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-width: 440px;
  margin: 0 auto 3rem;
  padding: 2rem;
  text-align: center;
}
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  background: #ffffff;
  color: #374151;
  border: 1px solid #d1d5db;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.btn-google:hover {
  background: #f9fafb;
  border-color: #9ca3af;
  box-shadow: var(--shadow-sm);
}
.auth-divider {
  display: flex;
  align-items: center;
  margin: 1.25rem 0;
  color: var(--gray-400);
  font-size: 0.8rem;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--gray-200);
}
.auth-divider span {
  padding: 0 0.75rem;
}
.demo-auth-actions {
  display: flex;
  gap: 0.5rem;
}
.demo-auth-btn {
  flex: 1;
  padding: 0.5rem;
  font-size: 0.8rem;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-xs);
  cursor: pointer;
  color: var(--gray-700);
  transition: var(--transition);
}
.demo-auth-btn:hover {
  background: var(--gray-200);
  color: var(--gray-900);
}

.landing-features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
  max-width: 1000px;
  margin: 0 auto;
}
.landing-feature-card {
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: left;
  box-shadow: var(--shadow-sm);
}
.feature-icon-wrapper {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--primary-50);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  font-size: 1.4rem;
}
.landing-feature-card h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 0.5rem;
}
.landing-feature-card p {
  font-size: 0.9rem;
  color: var(--gray-600);
  line-height: 1.5;
}

/* ── SMART STUDY MODULE ── */
.smart-study-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.smart-study-title-block h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-900);
}
.smart-study-title-block p {
  color: var(--gray-600);
  font-size: 0.9rem;
}
.smart-subject-selector {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.75rem;
  margin-bottom: 1.5rem;
  scrollbar-width: thin;
}
.subject-chip {
  flex-shrink: 0;
  padding: 0.45rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--gray-300);
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  color: var(--gray-700);
}
.subject-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.subject-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  font-weight: 600;
}

.smart-study-card {
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  max-width: 800px;
  margin: 0 auto 2rem;
  position: relative;
  will-change: opacity, transform;
}
.smart-study-card.ss-fade-out {
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 200ms ease-out, transform 200ms ease-out;
}
.smart-study-card.ss-fade-in {
  transition: opacity 260ms ease-in, transform 260ms ease-in;
}
.smart-study-card.ss-fade-out,
.smart-study-card[data-ss-held] { pointer-events: none; }
@media (prefers-reduced-motion: reduce) {
  .smart-study-card.ss-fade-out,
  .smart-study-card.ss-fade-in {
    transform: none !important;
    transition-duration: 1ms !important;
  }
}

/* Smart Study: answer awaiting server verification */
.option-btn.pending {
  border-color: var(--primary);
  background: var(--primary-50);
  color: var(--primary-dark);
  animation: ssPendingPulse 1.2s ease-in-out infinite;
}
.option-btn.pending .option-letter { background: var(--primary); color: white; }
.option-btn.disabled.pending:hover { border-color: var(--primary); background: var(--primary-50); }
@keyframes ssPendingPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
@media (prefers-reduced-motion: reduce) {
  .option-btn.pending { animation: none; }
}

.feedback-area.feedback-neutral {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
}
.feedback-area.feedback-neutral .feedback-badge { color: var(--gray-600); }

/* Smart Study: report an issue */
.ss-report {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--gray-200);
  font-size: 0.8rem;
}
.ss-report-toggle,
.ss-report-btn {
  padding: 0.25rem 0.65rem;
  border: 1px solid var(--gray-300);
  border-radius: 999px;
  background: var(--surface);
  color: var(--gray-600);
  font-size: 0.78rem;
  cursor: pointer;
  transition: var(--transition);
}
.ss-report-toggle {
  border-color: transparent;
  background: transparent;
  padding-left: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.ss-report-toggle:hover:not(:disabled),
.ss-report-btn:hover:not(:disabled) { color: var(--primary); border-color: var(--primary); }
.ss-report-toggle:hover:not(:disabled) { border-color: transparent; }
.ss-report-toggle:focus-visible,
.ss-report-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.ss-report-toggle:disabled,
.ss-report-btn:disabled { cursor: default; opacity: 0.6; }
.ss-report-options { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.ss-report-options[hidden] { display: none; }
.ss-report-status { color: var(--gray-500); }
.smart-study-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  font-size: 0.85rem;
}
.smart-study-subject-tag {
  background: var(--gray-100);
  color: var(--gray-700);
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-xs);
  font-weight: 600;
}

.smart-question-prompt {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.smart-study-actions-bar {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--gray-200);
  padding: 1rem;
  margin-top: 2rem;
  box-shadow: 0 -4px 10px rgba(0,0,0,0.05);
  z-index: 50;
}
.smart-study-actions-inner {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.smart-session-stats {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-700);
}
.stat-item-correct { color: var(--success); }
.stat-item-wrong { color: var(--danger); }
.stat-item-selection { color: var(--gray-500); font-weight: 400; font-size: 0.8rem; font-style: italic; }


.smart-mastery-indicator {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 1rem;
  padding: 0.5rem 0;
}
.mastery-row { display: flex; align-items: center; gap: 0.75rem; }
.mastery-row-stats { gap: 1rem; }
.mastery-label { font-size: 0.8rem; font-weight: 600; color: var(--gray-600); white-space: nowrap; }
.mastery-bar { flex: 1; height: 6px; background: var(--gray-200); border-radius: 3px; overflow: hidden; }
.mastery-fill { height: 100%; background: var(--primary); border-radius: 3px; transition: width 0.5s ease; }
.mastery-level { font-size: 0.8rem; font-weight: 600; color: var(--primary); white-space: nowrap; }
.mastery-stat { font-size: 0.75rem; color: var(--gray-500); }
.mastery-reset-btn {
  padding: 0.15rem 0.6rem;
  border: 1px solid var(--gray-300);
  border-radius: 999px;
  background: var(--surface);
  color: var(--gray-600);
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: var(--transition);
}
.mastery-reset-btn:hover:not(:disabled) { color: var(--danger); border-color: var(--danger); }
.mastery-reset-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.mastery-reset-btn:disabled { cursor: default; opacity: 0.6; }

/* ── CLINICAL SIMULATIONS MODULE ── */
.simulations-header {
  margin-bottom: 2rem;
}
.simulations-header h2 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 0.25rem;
}
.simulations-header p {
  color: var(--gray-600);
}
.sim-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}
.sim-filter-btn {
  padding: 0.4rem 1rem;
  border: 1px solid var(--gray-300);
  border-radius: 999px;
  background: var(--surface);
  color: var(--gray-700);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}
.sim-filter-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.sim-filter-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.sim-filter-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.simulations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.sim-card {
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.sim-card:not(.sim-locked):hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.sim-preview-box {
  height: 160px;
  background: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #38bdf8;
  position: relative;
  overflow: hidden;
}
.sim-preview-icon {
  font-size: 3.5rem;
}
.sim-badge-pro {
  position: absolute;
  top: 10px;
  right: 10px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  box-shadow: var(--shadow-sm);
}
.sim-badge-free {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--success);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
}

.sim-body {
  padding: 1.25rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.sim-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 0.4rem;
}
.sim-desc {
  font-size: 0.88rem;
  color: var(--gray-600);
  line-height: 1.5;
  margin-bottom: 1.25rem;
  flex: 1;
}
.sim-btn {
  width: 100%;
}

.sim-locked .sim-preview-box {
  filter: grayscale(0.5) opacity(0.85);
}
.sim-locked-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  padding: 1.5rem;
  text-align: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  cursor: pointer;
}
.sim-locked:hover .sim-locked-overlay {
  opacity: 1;
}
.sim-lock-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}
.sim-lock-text {
  font-weight: 700;
  font-size: 1rem;
}

/* ── LENSOMETRY SIMULATOR VIEW (MODERN) ── */
.sim-view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.sim-view-title-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.sim-view-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gray-900);
  margin: 0;
}

.lensometer-modern-container {
  display: grid;
  grid-template-columns: minmax(360px, 460px) 1fr;
  gap: 1.75rem;
  align-items: start;
  margin-bottom: 3rem;
}

@media (max-width: 960px) {
  .lensometer-modern-container {
    grid-template-columns: 1fr;
  }
}

.lensometer-viewport-card {
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  position: sticky;
  top: calc(var(--header-h) + 1rem);
}

.eyepiece-housing-modern {
  width: 380px;
  height: 380px;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #1e293b 0%, #0b1120 70%, #030712 100%);
  padding: 14px;
  box-shadow: inset 0 4px 16px rgba(0,0,0,0.85), 0 12px 28px -4px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.08);
  border: 6px solid #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  cursor: crosshair;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.eyepiece-housing-modern:hover {
  box-shadow: inset 0 4px 16px rgba(0,0,0,0.85), 0 16px 36px -4px rgba(37,99,235,0.25), 0 0 0 1px rgba(59,130,246,0.3);
}

#lensometer-canvas {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  border-radius: 50%;
  display: block;
  background: #061c10;
}

.viewport-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 0.75rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.segmented-control {
  display: inline-flex;
  background: var(--gray-100);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
}

.segmented-btn {
  border: none;
  background: transparent;
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gray-600);
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all 0.15s ease;
}

.segmented-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

.reticle-readout-pill {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 20px;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  color: var(--gray-600);
}

.reticle-readout-pill strong {
  color: #ef4444;
  font-family: monospace;
}

.viewport-hint {
  font-size: 0.78rem;
  color: var(--gray-500);
  margin-top: 0.85rem;
  text-align: center;
  line-height: 1.45;
}

.lensometer-panel-stack {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.lens-card {
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.lens-card:hover {
  border-color: var(--gray-300);
  box-shadow: var(--shadow);
}

.lens-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--gray-100);
  background: #fafbfc;
}

.lens-card-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.lens-card-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--gray-900);
  margin: 0;
}

.lens-card-subtitle {
  font-size: 0.78rem;
  color: var(--gray-500);
  margin: 0.15rem 0 0;
}

.lens-card-body {
  padding: 1.25rem;
}

.form-group-sim {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-700);
}

.sim-select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-300);
  font-size: 0.88rem;
  background: var(--surface);
  color: var(--gray-800);
  outline: none;
  font-weight: 500;
  cursor: pointer;
}

.btn-cluster {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.reveal-box {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  background: #fefce8;
  border: 1px solid #fef08a;
  border-radius: var(--radius-sm);
  animation: fadeIn 0.2s ease;
}

.reveal-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: #854d0e;
}

.reveal-rx {
  font-size: 1.05rem;
  font-weight: 800;
  font-family: monospace;
  color: #713f12;
  margin-top: 0.2rem;
}

.slider-control-row {
  margin-bottom: 1.1rem;
}

.slider-control-row:last-child {
  margin-bottom: 0;
}

.slider-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}

.slider-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--gray-700);
}

.slider-badge {
  font-size: 0.88rem;
  font-weight: 800;
  font-family: monospace;
  color: var(--primary);
  background: var(--primary-50);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-xs);
  border: 1px solid var(--primary-light);
}

.stepper-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.stepper-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--gray-300);
  background: var(--gray-100);
  border-radius: var(--radius-xs);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-700);
  user-select: none;
  transition: background 0.15s ease;
  flex-shrink: 0;
}

.stepper-btn:hover {
  background: var(--gray-200);
}

.sim-range {
  flex: 1;
  accent-color: var(--primary);
  cursor: pointer;
}

.stage-control-group {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--gray-200);
}

.stage-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 0.4rem;
}

.stage-pad-modern {
  display: grid;
  grid-template-columns: repeat(3, 36px);
  gap: 4px;
  margin: 0.25rem auto 0;
  justify-content: center;
}

.pad-center-btn {
  background: var(--primary-50) !important;
  color: var(--primary) !important;
  border-color: var(--primary-light) !important;
}

.findings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.75rem;
}

.finding-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.finding-field label {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.input-unit-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-unit-wrap input {
  width: 100%;
  padding: 0.45rem 1.6rem 0.45rem 0.55rem;
  border-radius: var(--radius-xs);
  border: 1px solid var(--gray-300);
  font-size: 0.88rem;
  font-family: monospace;
  font-weight: 600;
  color: var(--gray-900);
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s ease;
}

.input-unit-wrap input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.unit-tag {
  position: absolute;
  right: 0.5rem;
  font-size: 0.75rem;
  color: var(--gray-400);
  font-weight: 700;
  pointer-events: none;
}

.finding-feedback-box {
  margin-top: 0.85rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  line-height: 1.5;
  animation: fadeIn 0.2s ease;
}

.finding-feedback-success,
.finding-feedback-pass {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.finding-feedback-error,
.finding-feedback-fail {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.feedback-status-badge {
  font-weight: 800;
  font-size: 0.88rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.feedback-status-badge.pass { color: #047857; }
.feedback-status-badge.fail { color: #b91c1c; }

.feedback-rx-row {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: var(--radius-xs);
  padding: 0.5rem 0.75rem;
  font-size: 0.82rem;
  margin-bottom: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.feedback-rx-row code {
  font-family: monospace;
  font-weight: 700;
}

.feedback-details-table {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px dashed rgba(0, 0, 0, 0.08);
  padding: 0.2rem 0;
}

.detail-row:last-child {
  border-bottom: none;
}

.instructions-modal-card {
  max-width: 600px;
  width: 100%;
  padding: 1.75rem;
  border-radius: var(--radius);
  background: var(--surface);
  position: relative;
  box-shadow: var(--shadow-xl);
}

.instructions-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--gray-200);
}

.instructions-content {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 65vh;
  overflow-y: auto;
}

.guide-step-card {
  display: flex;
  gap: 0.85rem;
  padding: 0.75rem 0.9rem;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
}

.guide-step-badge {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.guide-step-text {
  font-size: 0.85rem;
  color: var(--gray-700);
}

.guide-step-text strong {
  color: var(--gray-900);
  display: block;
  margin-bottom: 0.2rem;
}

.guide-step-text p {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.45;
}

/* ── PAYMONGO UPGRADE MODAL ── */
.upgrade-modal-card {
  max-width: 580px;
  width: 100%;
  padding: 2.25rem;
  border-radius: var(--radius);
  background: var(--surface);
  position: relative;
  box-shadow: var(--shadow-xl);
}
.upgrade-badge {
  display: inline-block;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 800;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  margin-bottom: 0.75rem;
  letter-spacing: 0.05em;
}
.upgrade-price-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.3rem;
  margin: 1rem 0 1.5rem;
}
.price-currency {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-800);
}
.price-amount {
  font-size: 3rem;
  font-weight: 900;
  color: var(--gray-900);
}
.price-period {
  font-size: 0.9rem;
  color: var(--gray-500);
}
.upgrade-features-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1.75rem 0;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.upgrade-feature-item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.95rem;
  color: var(--gray-700);
}
.feature-check {
  color: var(--success);
  font-weight: 900;
  font-size: 1.1rem;
  line-height: 1;
}

.payment-methods-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-top: 1rem;
}
.payment-logo-badge {
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  font-weight: 600;
  color: var(--gray-700);
  font-size: 0.75rem;
}

/* ═══════════════════════════════════════════════════════
   Conoid of Sturm (3D Astigmatic Optics) Styles
   ═══════════════════════════════════════════════════════ */
.conoid-viewport-card {
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: calc(var(--header-h) + 1rem);
}

.conoid-canvas-wrap {
  width: 100%;
  height: 480px;
  min-height: 440px;
  border-radius: var(--radius-sm);
  background: radial-gradient(circle at 50% 30%, #0f172a 0%, #090d16 65%, #030712 100%);
  border: 1px solid #1e293b;
  box-shadow: inset 0 4px 20px rgba(0, 0, 0, 0.75), 0 8px 24px -4px rgba(0, 0, 0, 0.25);
  position: relative;
  overflow: hidden;
  cursor: grab;
}

.conoid-canvas-wrap:active {
  cursor: grabbing;
}

#conoid-three-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Viewport HUD */
.conoid-hud-top {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  pointer-events: none;
}

.conoid-hud-hint {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.3rem 0.65rem;
  border-radius: 20px;
  font-size: 0.72rem;
  color: #94a3b8;
  pointer-events: auto;
  user-select: none;
}

.conoid-hud-actions {
  display: flex;
  gap: 0.4rem;
  pointer-events: auto;
}

.hud-btn {
  background: rgba(15, 23, 42, 0.85) !important;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.18) !important;
  color: #f8fafc !important;
  font-size: 0.74rem !important;
  padding: 0.3rem 0.65rem !important;
  border-radius: var(--radius-xs) !important;
  cursor: pointer;
  transition: all 0.15s ease;
}

.hud-btn:hover {
  background: rgba(30, 41, 59, 0.95) !important;
  border-color: var(--primary) !important;
}

/* Picture-in-Picture 2D Cross-Section Card */
.conoid-pip-card {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 156px;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.65);
  padding: 0.5rem;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  pointer-events: auto;
}

.conoid-pip-header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.pip-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
}

.beam-state-badge {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.18rem 0.5rem;
  border-radius: 12px;
  text-align: center;
  background: #083344;
  color: #22d3ee;
  border: 1px solid #06b6d4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.beam-state-colc {
  background: #022c22 !important;
  color: #34d399 !important;
  border-color: #10b981 !important;
}

.beam-state-line {
  background: #451a03 !important;
  color: #fbbf24 !important;
  border-color: #f59e0b !important;
}

.beam-state-point {
  background: #1e1b4b !important;
  color: #a78bfa !important;
  border-color: #8b5cf6 !important;
}

.pip-canvas-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  background: #020617;
  border-radius: var(--radius-xs);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 4px;
}

#conoid-crosssection-canvas {
  width: 130px;
  height: 130px;
  display: block;
}

.pip-metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem 0.5rem;
  font-size: 0.7rem;
  padding-top: 0.35rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.pip-metric-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.metric-label {
  color: #94a3b8;
}

.metric-val {
  font-family: monospace;
  font-weight: 700;
  color: #f8fafc;
}

/* Preset Chips */
.preset-chips-wrap {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.preset-chip {
  padding: 0.3rem 0.65rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--gray-300);
  background: var(--surface);
  color: var(--gray-700);
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.preset-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

/* Quick-Snap Focal Buttons */
.focal-jump-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.focal-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.3rem;
  border: 1px solid var(--gray-200);
  background: var(--gray-50);
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}

.focal-btn:hover {
  background: var(--gray-100);
  border-color: var(--gray-300);
}

.focal-btn.highlight-colc {
  background: #ecfeff;
  border-color: #a5f3fc;
}

.focal-btn.highlight-colc:hover {
  background: #cffafe;
  border-color: #67e8f9;
}

.focal-btn-title {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--gray-800);
}

.focal-btn.highlight-colc .focal-btn-title {
  color: #0891b2;
}

.focal-btn-sub {
  font-size: 0.68rem;
  font-family: monospace;
  color: var(--gray-500);
  margin-top: 2px;
}

/* Interval of Sturm Metrics Strip */
.focal-metrics-strip {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.35rem 0.75rem;
  background: #fafbfc;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-xs);
  padding: 0.55rem 0.75rem;
  margin-top: 0.75rem;
}

.metric-block {
  display: flex;
  justify-content: space-between;
  font-size: 0.76rem;
}

.m-label {
  color: var(--gray-600);
}

.m-value {
  font-family: monospace;
  font-weight: 700;
  color: var(--gray-900);
}

/* Display & Ray Toggles */
.toggles-column {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.sim-toggle-label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--gray-700);
  cursor: pointer;
  user-select: none;
}

.sim-toggle-label input {
  accent-color: var(--primary);
  cursor: pointer;
}

.color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.hidden-pip {
  display: none !important;
}

/* ═══════════════════════════════════════════════════════
   Geometrical Ray Tracing (Thin Lenses) Styles
   ═══════════════════════════════════════════════════════ */
.raytracing-viewport-card {
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: calc(var(--header-h) + 1rem);
}

.raytracing-svg-wrap {
  width: 100%;
  height: 480px;
  min-height: 440px;
  border-radius: var(--radius-sm);
  background: radial-gradient(circle at 50% 50%, #0b1120 0%, #060b18 65%, #020617 100%);
  border: 1px solid #1e293b;
  box-shadow: inset 0 4px 20px rgba(0, 0, 0, 0.75), 0 8px 24px -4px rgba(0, 0, 0, 0.25);
  position: relative;
  overflow: hidden;
}

#raytracing-svg {
  width: 100%;
  height: 100%;
  display: block;
  user-select: none;
}

/* Status Badges */
.rt-status-badge {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.2rem 0.55rem;
  border-radius: 12px;
  text-align: center;
  white-space: nowrap;
}

.rt-badge-real {
  background: #022c22;
  color: #34d399;
  border: 1px solid #10b981;
}

.rt-badge-virt {
  background: #2e1065;
  color: #c084fc;
  border: 1px solid #8b5cf6;
}

.rt-badge-inf {
  background: #1e1b4b;
  color: #a78bfa;
  border: 1px solid #6366f1;
}

.rt-badge-inverted {
  background: #451a03;
  color: #fbbf24;
  border: 1px solid #f59e0b;
}

.rt-badge-upright {
  background: #082f49;
  color: #38bdf8;
  border: 1px solid #0284c7;
}

.rt-badge-mag {
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid #475569;
}

/* Live Formula Calculation Box */
.rt-formula-card {
  margin-top: 0.75rem;
  background: #020617;
  border: 1px solid #1e293b;
  border-radius: var(--radius-xs);
  padding: 0.55rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.rt-formula-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #94a3b8;
}

.rt-formula-math {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.75rem;
  color: #38bdf8;
  word-break: break-all;
}

/* Draggable Object Arrow interactivity */
#rt-object-group {
  transition: opacity 0.15s ease;
}

#rt-object-group:hover {
  filter: drop-shadow(0 0 6px rgba(245, 158, 11, 0.8));
}

/* =============================================================================
   KERATOMETER SIMULATION (OPHTHALMOMETRY) STYLES
   ============================================================================= */

/* Joystick D-Pad */
.dpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 38px);
  gap: 5px;
  margin: 0.35rem auto 0;
  justify-content: center;
}

.dpad-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-xs);
  font-size: 0.85rem;
  color: var(--gray-700);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.dpad-btn:hover {
  background: var(--gray-100);
  border-color: var(--gray-400);
  color: var(--primary);
  transform: translateY(-1px);
}

.dpad-btn:active {
  transform: translateY(0);
  background: var(--gray-200);
}

.dpad-center {
  background: var(--primary-50) !important;
  color: var(--primary) !important;
  border-color: var(--primary-light) !important;
  font-size: 1.05rem;
}

/* Keratometer Canvas Eyepiece */
#keratometer-canvas {
  background: radial-gradient(circle at center, #0a0f1d 0%, #030712 100%);
  cursor: crosshair;
  transition: filter 0.1s ease;
}

/* Radius of curvature note */
.k-radius-note {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Findings feedback layout */
.k-feedback-section {
  border-top: 1px dashed rgba(255, 255, 255, 0.12);
  padding-top: 0.6rem;
  margin-top: 0.6rem;
}

/* ═══════════════════════════════════════════════════════
   MOBILE RESPONSIVE ENHANCEMENTS
   Breakpoints: 960 / 768 / 640 / 480 / 360
   ═══════════════════════════════════════════════════════ */

html { overflow-x: hidden; }

img, video { max-width: 100%; height: auto; }

.sim-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

/* ── Intermediate desktop (≤1100px): compact header actions ── */
@media (max-width: 1100px) {
  .user-name { display: none; }
  .btn-discord span { display: none; }
  .btn-discord { padding: 0.4rem 0.5rem; gap: 0; }
  .header-actions { gap: 0.5rem; }
}

/* ── Tablet & small desktop (≤960px) ── */
@media (max-width: 960px) {
  .lensometer-viewport-card {
    top: calc(var(--header-h) + 0.5rem);
  }

  #conoid-view .lensometer-modern-container,
  #raytracing-view .lensometer-modern-container {
    display: flex;
    flex-direction: column;
  }

  .conoid-viewport-card,
  .raytracing-viewport-card {
    top: calc(var(--header-h) + 0.5rem);
    z-index: 10;
  }

  /* --- Header: hide nav text labels, keep icons --- */
  .nav-btn span { display: none; }
  .nav-btn { padding: 0.5rem 0.75rem; }
  .nav-btn svg { width: 20px; height: 20px; }

  .btn-discord span { display: none; }
  .btn-discord { padding: 0.4rem 0.5rem; gap: 0; }
}

/* ── Tablet & large phone (≤768px) ── */
@media (max-width: 768px) {
  /* --- Header: wrap nav to second row --- */
  .header-inner {
    flex-wrap: wrap;
    height: auto;
    min-height: var(--header-h);
    padding: 0.5rem 0.75rem;
  }

  .header-nav {
    order: 3;
    width: 100%;
    justify-content: space-around;
    padding-top: 0.4rem;
    margin-top: 0.25rem;
    border-top: 1px solid var(--gray-100);
  }

  .nav-btn span { display: none; }
  .nav-btn { padding: 0.5rem 0.75rem; }
  .nav-btn svg { width: 20px; height: 20px; }

  .nav-btn.active {
    border-bottom: 2px solid var(--primary);
    padding-bottom: calc(0.5rem - 2px);
  }

  .btn-discord span { display: none; }
  .btn-discord { padding: 0.4rem 0.5rem; gap: 0; }

  .user-name { display: none; }

  .btn-upgrade-nav { font-size: 0.72rem; padding: 0.3rem 0.55rem; }

  .header-actions { gap: 0.4rem; }

  /* --- Quota banner: wrap pills --- */
  .quota-banner-inner {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.35rem;
  }

  .quota-items {
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: center;
  }

  /* --- Landing page --- */
  .landing-title { font-size: 1.85rem; }
  .landing-sub { font-size: 1rem; }
  .landing-hero { padding: 2rem 0.5rem 1.5rem; }

  /* --- Smart study --- */
  .smart-study-header { flex-direction: column; align-items: flex-start; }

  .smart-study-actions-inner {
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch;
  }

  .smart-session-stats { justify-content: center; }

  .smart-study-card { padding: 1.25rem; }
  .smart-question-prompt { font-size: 1.05rem; }

  /* --- Simulations --- */
  .simulations-header h2 { font-size: 1.35rem; }

  .sim-header { flex-direction: column; text-align: center; }

  .lensometer-viewport-card { padding: 0.75rem; }

  .sim-view-title { font-size: 1.05rem; }

  .sim-view-title-group {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }

  /* Conoid HUD: stack controls below hint */
  .conoid-hud-top {
    flex-direction: column;
    gap: 0.35rem;
    align-items: flex-start;
  }

  .conoid-hud-hint { font-size: 0.65rem; max-width: 100%; }

  .conoid-hud-actions { flex-wrap: wrap; }

  /* Conoid canvas height */
  .conoid-canvas-wrap,
  .raytracing-svg-wrap {
    height: 380px;
    min-height: 320px;
  }

  /* --- Quiz topbar --- */
  .quiz-topbar-inner {
    flex-wrap: wrap;
    padding: 0.5rem 0.75rem;
    gap: 0.5rem;
  }

  /* --- Grids: enforce single column below 768 --- */
  .subject-grid,
  .simulations-grid,
  .landing-features-grid {
    grid-template-columns: 1fr;
  }

  /* --- Keratometer keyboard guide: wrap --- */
  .sim-header + .lensometer-modern-container .lens-canvas-wrap + div {
    font-size: 0.7rem;
  }

  /* --- History --- */
  .history-item { flex-wrap: wrap; }
}

/* ── Medium phone (≤640px) ── */
@media (max-width: 640px) {
  .landing-title { font-size: 1.6rem; }

  .auth-card-box { padding: 1.25rem; margin-bottom: 2rem; }

  .eyepiece-housing-modern {
    width: 240px;
    height: 240px;
  }

  /* Focal jump grid: stack on small screens */
  .focal-jump-grid {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }

  .focal-btn { flex-direction: row; gap: 0.5rem; }

  /* Focal metrics: single column */
  .focal-metrics-strip {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  /* Upgrade modal */
  .upgrade-modal-card { padding: 1.25rem; }
  .price-amount { font-size: 2.25rem; }
  .upgrade-feature-item { font-size: 0.88rem; }

  /* Payment strip: wrap */
  .payment-methods-strip { flex-wrap: wrap; }

  /* Section header: stack */
  .section-header {
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
  }

  /* History */
  .history-item { padding: 0.75rem; gap: 0.75rem; }
  .history-score-circle { width: 42px; height: 42px; font-size: 0.8rem; }

  /* Results actions: stack */
  .results-actions { flex-direction: column; }
  .results-actions .btn { width: 100%; }

  /* Quiz nav: equal width buttons */
  .quiz-nav { flex-wrap: wrap; }
  .quiz-nav .btn { flex: 1; min-width: 0; }
}

/* ── Small phone (≤480px) ── */
@media (max-width: 480px) {
  .logo-text { display: none; }

  .landing-title { font-size: 1.4rem; }
  .landing-sub { font-size: 0.88rem; }

  .lensometer-viewport-card {
    position: relative;
    top: auto;
    z-index: auto;
  }

  .eyepiece-housing-modern {
    width: 200px;
    height: 200px;
    padding: 8px;
    border-width: 4px;
  }

  .conoid-canvas-wrap {
    height: 220px;
    min-height: 180px;
  }

  .raytracing-svg-wrap {
    height: 220px;
    min-height: 180px;
  }

  .conoid-viewport-card,
  .raytracing-viewport-card {
    padding: 0.75rem;
  }

  .conoid-viewport-card .viewport-hint,
  .raytracing-viewport-card .viewport-hint {
    display: none;
  }

  /* Lensometer container: remove min column width */
  .lensometer-modern-container {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .viewport-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .segmented-control { width: 100%; justify-content: center; }

  .reticle-readout-pill { text-align: center; }

  /* Smart study subject chips: smaller */
  .subject-chip { padding: 0.35rem 0.65rem; font-size: 0.78rem; }

  /* Preset chips */
  .preset-chips-wrap { gap: 0.3rem; }
  .preset-chip { font-size: 0.7rem; padding: 0.25rem 0.5rem; }

  /* Instructions modal */
  .instructions-modal-card { padding: 1rem; }
  .guide-step-card { padding: 0.6rem 0.7rem; gap: 0.6rem; }
  .guide-step-text p { font-size: 0.78rem; }

  /* D-pad: slightly smaller */
  .dpad-grid { grid-template-columns: repeat(3, 34px); gap: 4px; }
  .dpad-btn { width: 34px; height: 34px; font-size: 0.8rem; }

  /* Stepper buttons: touch-friendly */
  .stepper-btn { width: 32px; height: 32px; }

  /* Findings grid: stack */
  .findings-grid { grid-template-columns: 1fr 1fr; }

  /* Modal: tighter */
  .modal { padding: 1.25rem; }
  .modal-title { font-size: 1.1rem; }

  /* Stats row: always 2 columns */
  .stats-row { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
  .stat-number { font-size: 1.2rem; }

  /* Score ring */
  .score-ring { width: 110px; height: 110px; }
  .score-pct { font-size: 1.5rem; }

  /* Review items */
  .review-item-title { font-size: 0.82rem; }
  .review-answer-label { min-width: 80px; }

  /* PIP card: responsive width */
  .conoid-pip-card { width: 130px; }
  #conoid-crosssection-canvas { width: 100px; height: 100px; }

  /* Hero */
  .hero h1 { font-size: 1.25rem; }
  .hero-sub { font-size: 0.88rem; }

  /* Lens card header: wrap on small */
  .lens-card-header { flex-wrap: wrap; gap: 0.5rem; padding: 0.75rem 1rem; }
  .lens-card-body { padding: 1rem; }

  /* Slider controls */
  .slider-label { font-size: 0.78rem; }
  .slider-badge { font-size: 0.8rem; }

  /* Sim toggle labels */
  .sim-toggle-label { font-size: 0.78rem; gap: 0.4rem; }
}

/* ── Extra small phone (≤360px) ── */
@media (max-width: 360px) {
  .header-inner { padding: 0.35rem 0.5rem; }
  .logo { font-size: 0.95rem; gap: 0.3rem; }
  .logo-icon { font-size: 1.1rem; }
  .nav-btn { padding: 0.4rem 0.5rem; }
  .btn-upgrade-nav { padding: 0.25rem 0.4rem; font-size: 0.65rem; }

  .landing-title { font-size: 1.25rem; }
  .hero h1 { font-size: 1.1rem; }

  .auth-card-box { padding: 0.85rem; margin-bottom: 1.5rem; }
  .demo-auth-actions { flex-direction: column; }

  .eyepiece-housing-modern {
    width: 170px;
    height: 170px;
    padding: 6px;
    border-width: 3px;
  }

  .conoid-viewport-card,
  .raytracing-viewport-card {
    position: relative;
    top: auto;
    z-index: auto;
  }

  .conoid-canvas-wrap {
    height: 200px;
    min-height: 160px;
  }

  .raytracing-svg-wrap {
    height: 200px;
    min-height: 160px;
  }

  .smart-study-card { padding: 1rem; }
  .smart-question-prompt { font-size: 0.95rem; }

  .question-card { padding: 0.85rem; }
  .question-prompt { font-size: 0.95rem; }
  .option-btn { padding: 0.7rem 0.85rem; font-size: 0.88rem; gap: 0.5rem; }
  .option-letter { width: 24px; height: 24px; font-size: 0.72rem; }

  .findings-grid { grid-template-columns: 1fr; }

  .conoid-pip-card { width: 110px; padding: 0.35rem; }
  #conoid-crosssection-canvas { width: 80px; height: 80px; }

  .upgrade-modal-card { padding: 1rem; }
  .price-amount { font-size: 2rem; }
  .price-currency { font-size: 1.2rem; }

}

/* ═══════════════════════════════════════════════════════
   STREAK RETINOSCOPY SIMULATOR
   ═══════════════════════════════════════════════════════ */
.retinoscopy-left-col {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: sticky;
  top: calc(var(--header-h) + 1rem);
  align-self: start;
}

.retinoscopy-viewport-card {
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-md);
}

.ret-sleeve-card {
  position: static;
}

.retinoscopy-canvas-wrap {
  position: relative;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  overflow: hidden;
  background: #050505;
  box-shadow: 0 0 28px rgba(0, 0, 0, 0.8), inset 0 0 20px rgba(0, 0, 0, 0.95);
}

.retinoscopy-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
  user-select: none;
}

.retinoscopy-canvas-wrap canvas:active {
  cursor: grabbing;
}

/* Beam Lock Overlay Toggle */
.ret-lock-btn {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 9999px;
  padding: 4px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
  text-align: center;
}

.ret-lock-btn:hover {
  background: rgba(15, 23, 42, 0.92);
  border-color: rgba(255, 255, 255, 0.45);
  transform: translateX(-50%) scale(1.02);
}

.ret-lock-btn.locked {
  background: rgba(220, 38, 38, 0.88);
  border-color: rgba(255, 255, 255, 0.5);
}

.ret-lock-badge {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #38bdf8;
  line-height: 1.1;
}

.ret-lock-btn.locked .ret-lock-badge {
  color: #ffffff;
}

.ret-lock-subtext {
  font-size: 0.58rem;
  color: #cbd5e1;
  margin-top: 1px;
  line-height: 1.1;
}

/* Live Feedback Strip */
.retinoscopy-readout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  margin-top: 0.75rem;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-family: monospace;
  flex-wrap: wrap;
}

.retinoscopy-readout-divider {
  color: var(--gray-400);
  font-size: 0.75rem;
}

.ret-badge-with {
  color: #1d4ed8;
  background: #eff6ff;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #bfdbfe;
  font-weight: 700;
}

.ret-badge-against {
  color: #b91c1c;
  background: #fef2f2;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #fecaca;
  font-weight: 700;
}

.ret-badge-neutral {
  color: #15803d;
  background: #f0fdf4;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #bbf7d0;
  font-weight: 700;
}

/* Sleeve Dial Rotation Section */
.ret-sleeve-section {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.ret-dial-container {
  position: relative;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: linear-gradient(145deg, #ffffff, var(--gray-100));
  border: 2px solid var(--gray-300);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08), inset 0 2px 4px rgba(255, 255, 255, 0.9);
  cursor: grab;
  user-select: none;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0.35rem auto;
}

.ret-dial-container:active {
  cursor: grabbing;
}

.ret-dial-ticks-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.ret-dial-needle {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ret-dial-needle-bar {
  width: 3px;
  height: 100%;
  background: linear-gradient(to bottom, #ef4444 0%, #ef4444 32%, transparent 32%, transparent 68%, #3b82f6 68%, #3b82f6 100%);
  border-radius: 2px;
}

.ret-dial-hub {
  position: relative;
  z-index: 2;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--gray-200);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.ret-dial-angle-text {
  font-size: 0.9rem;
  font-weight: 800;
  font-family: monospace;
  color: var(--gray-900);
  line-height: 1;
}

.ret-dial-label {
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--gray-500);
  margin-top: 2px;
}

.ret-dial-controls-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.4rem;
}

.ret-quick-angles {
  display: flex;
  gap: 0.25rem;
}

.quick-angle-btn.active {
  background: var(--primary-50);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 700;
}

/* Motion Card & Banner */
.ret-motion-card {
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--gray-50);
  border: 2px solid var(--gray-200);
  transition: all var(--transition);
}

.ret-motion-card.motion-with {
  border-color: #3b82f6;
  background: #eff6ff;
}

.ret-motion-card.motion-with #ret-motion-title {
  color: #1d4ed8;
}

.ret-motion-card.motion-against {
  border-color: #ef4444;
  background: #fef2f2;
}

.ret-motion-card.motion-against #ret-motion-title {
  color: #b91c1c;
}

.ret-motion-card.motion-neutral {
  border-color: #10b981;
  background: #f0fdf4;
}

.ret-motion-card.motion-neutral #ret-motion-title {
  color: #15803d;
}

/* Hidden Rx Mask Cover */
.ret-hidden-mask {
  padding: 1.5rem 1rem;
  text-align: center;
  background: var(--gray-50);
  border: 1px dashed var(--gray-300);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ret-answer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.6rem;
}

.ret-answer-field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 0.25rem;
}

.sim-input {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: monospace;
  background: var(--surface);
  color: var(--gray-800);
  transition: border-color var(--transition);
}

.sim-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 960px) {
  #retinoscopy-view .lensometer-modern-container {
    display: flex;
    flex-direction: column;
  }

  .retinoscopy-left-col {
    display: contents;
  }

  .retinoscopy-viewport-card {
    position: sticky;
    top: calc(var(--header-h) + 0.25rem);
    z-index: 20;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
  }

  .ret-sleeve-card {
    position: static;
  }

  .retinoscopy-canvas-wrap {
    max-width: 280px;
  }
}

@media (max-width: 480px) {
  .retinoscopy-viewport-card {
    padding: 0.5rem 0.65rem;
  }

  .retinoscopy-viewport-card .lens-card-header {
    padding-bottom: 0.25rem;
    margin-bottom: 0.25rem;
  }

  .retinoscopy-viewport-card .lens-card-icon {
    display: none;
  }

  .retinoscopy-viewport-card .lens-card-title {
    font-size: 0.95rem;
  }

  .retinoscopy-viewport-card .lens-card-subtitle {
    display: none;
  }

  .retinoscopy-canvas-wrap {
    max-width: 190px;
    box-shadow: 0 0 16px rgba(0, 0, 0, 0.7);
  }

  .ret-lock-btn {
    bottom: 6px;
    padding: 2px 10px;
  }

  .ret-lock-badge {
    font-size: 0.58rem;
  }

  .ret-lock-subtext {
    display: none;
  }

  .retinoscopy-readout {
    margin-top: 0.35rem;
    padding: 0.25rem 0.4rem;
    font-size: 0.72rem;
    gap: 0.25rem;
  }

  .ret-badge-with,
  .ret-badge-against,
  .ret-badge-neutral {
    padding: 1px 4px;
    font-size: 0.68rem;
  }

  .ret-answer-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 360px), (max-height: 520px) {
  .retinoscopy-viewport-card {
    position: relative;
    top: auto;
    z-index: auto;
    box-shadow: var(--shadow-sm);
  }

  .retinoscopy-canvas-wrap {
    max-width: 170px;
  }

  .ret-answer-grid {
    grid-template-columns: 1fr;
  }
}

/* ═══════════════════════════════════════════════════════
   SLIT LAMP BIOMICROSCOPY SIMULATOR
   ═══════════════════════════════════════════════════════ */
.slitlamp-viewport-card {
  flex: 1 1 55%;
  min-width: 0;
  position: sticky;
  top: calc(var(--header-h) + 1rem);
  z-index: 10;
}

.slitlamp-viewport {
  width: 100%;
  max-width: 720px;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--radius);
  background: #0a0e17;
  border: 2px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.7), 0 4px 24px rgba(0, 0, 0, 0.3);
  position: relative;
  margin: 0 auto;
}

.slitlamp-viewport canvas {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
}

.slitlamp-status-bar {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-color, rgba(255,255,255,0.1));
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.85rem;
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: #94a3b8;
  text-align: center;
  line-height: 1.5;
}

.slitlamp-case-info {
  margin-top: 0.65rem;
  padding: 0.65rem 0.75rem;
  background: var(--primary-50, #eff6ff);
  border-radius: var(--radius-sm);
  border: 1px solid var(--primary-light, #dbeafe);
}

.slitlamp-case-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--gray-800);
  margin-bottom: 0.2rem;
}

.slitlamp-case-context {
  font-size: 0.8rem;
  color: var(--gray-600);
  line-height: 1.45;
}

.slitlamp-guided-hint {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  margin-top: 0.65rem;
  padding: 0.55rem 0.7rem;
  background: var(--warning-bg, #fffbeb);
  border: 1px solid var(--warning-light, #fef3c7);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--gray-700);
  line-height: 1.45;
}

.slitlamp-question-box {
  padding: 0.65rem 0.75rem;
  background: var(--gray-50, #f8fafc);
  border: 1px solid var(--gray-200, #e2e8f0);
  border-radius: var(--radius-sm);
}

.slitlamp-question-text {
  font-size: 0.88rem;
  color: var(--gray-700);
  line-height: 1.5;
  margin: 0;
}

@media (max-width: 960px) {
  .slitlamp-viewport-card {
    flex: 1 1 100%;
    top: calc(var(--header-h) + 0.5rem);
    background: var(--surface, #fff);
    border-bottom: 1px solid var(--gray-200, #e2e8f0);
    padding-bottom: 0.4rem;
  }
  .slitlamp-viewport {
    max-height: 240px;
  }
}

@media (max-width: 480px) {
  .slitlamp-viewport-card {
    position: relative;
    top: auto;
    z-index: auto;
    background: none;
    border-bottom: none;
    padding-bottom: 0;
  }
  .slitlamp-viewport {
    aspect-ratio: 4 / 3;
    max-height: 220px;
  }
}

/* Van Herick Assessment Styles */
.vh-exam-type-card {
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: var(--radius);
  background: var(--gray-50, #f8fafc);
}

.vh-param-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.vh-param-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.5rem 0.6rem;
  background: var(--gray-50, #f8fafc);
  border: 1px solid var(--gray-200, #e2e8f0);
  border-radius: var(--radius-sm);
}

.vh-param-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-500, #64748b);
}

.vh-param-value {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--gray-800, #1e293b);
}

.vh-clinical-note {
  margin-top: 0.5rem;
  padding: 0.55rem 0.7rem;
  background: var(--warning-bg, #fffbeb);
  border: 1px solid var(--warning-light, #fef3c7);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  color: var(--gray-700, #334155);
  line-height: 1.45;
}

@media (max-width: 480px) {
  .vh-param-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
  }
}

/* ═══════════════════════════════════════════════════════
   PHOROMETRY CORE EXAMINATION SIMULATOR
   ═══════════════════════════════════════════════════════ */

/* Progress Bar */
.phoro-progress-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding: 0 0.25rem;
}

.phoro-progress-track {
  flex: 1;
  height: 8px;
  background: var(--gray-200);
  border-radius: 99px;
  overflow: hidden;
}

.phoro-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 99px;
  transition: width 0.4s ease;
}

.phoro-progress-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gray-600);
  white-space: nowrap;
}

/* Left Column: Sticky Viewport */
.phoro-left-col {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: calc(var(--header-h) + 1rem);
  align-self: start;
}

.phoro-viewport-card {
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-md);
}

/* Canvas */
.phoro-canvas-wrap {
  position: relative;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: #f8f9fa;
  border: 2px solid var(--gray-200);
}

.phoro-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Patient Speech Bubble */
.phoro-speech-bubble {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.6rem 0.8rem;
  margin-top: 0.75rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: #1e40af;
  line-height: 1.4;
}

.phoro-speech-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

/* Test Chips */
.phoro-test-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.phoro-test-chip {
  padding: 0.35rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--gray-300);
  border-radius: 99px;
  background: var(--surface);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.phoro-test-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.phoro-test-chip.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.phoro-test-chip.completed {
  background: #f0fdf4;
  border-color: #86efac;
  color: #15803d;
}

.phoro-test-chip.completed::after {
  content: ' \2713';
}

/* Prism Stepper Row */
.phoro-stepper-row {
  display: flex;
  gap: 0.35rem;
  justify-content: center;
  margin-top: 0.5rem;
}

/* Endpoint Buttons */
.phoro-endpoint-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.phoro-endpoint-buttons .btn {
  text-align: left;
  justify-content: flex-start;
}

.phoro-endpoint-buttons .btn.recorded {
  background: #f0fdf4;
  border-color: #86efac;
  color: #15803d;
  pointer-events: none;
}

/* Endpoint Summary */
.phoro-endpoint-summary {
  padding: 0.5rem 0.75rem;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
}

/* Feedback Styling */
.phoro-feedback-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin-top: 0.5rem;
}

.phoro-feedback-table th,
.phoro-feedback-table td {
  padding: 0.4rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
}

.phoro-feedback-table th {
  font-weight: 700;
  color: var(--gray-600);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.phoro-pass { color: #15803d; font-weight: 700; }
.phoro-fail { color: #dc2626; font-weight: 700; }

.phoro-pass-row td { background: #f0fdf4; }
.phoro-fail-row td { background: #fef2f2; }

.phoro-summary-score {
  text-align: center;
  padding: 1rem 0 0.5rem;
}
.phoro-summary-pct {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}
.phoro-summary-label {
  font-size: 0.85rem;
  color: var(--gray-600);
  margin-top: 0.25rem;
}

/* Mobile: single column, sticky canvas only */
@media (max-width: 960px) {
  #phorometry-view .lensometer-modern-container {
    display: flex;
    flex-direction: column;
  }

  .phoro-left-col {
    display: contents;
  }

  .phoro-viewport-card {
    position: sticky;
    top: calc(var(--header-h) + 0.25rem);
    z-index: 20;
    max-width: 100%;
  }

  .phoro-canvas-wrap {
    max-width: 280px;
  }
}

/* Very narrow or short: release sticky */
@media (max-width: 360px), (max-height: 520px) {
  .phoro-viewport-card {
    position: relative !important;
    top: auto !important;
    z-index: auto !important;
  }

  .phoro-canvas-wrap {
    max-width: 240px;
  }
}

/* ═══════════════════════════════════════════════════════
   COVER TEST (STRABISMUS ASSESSMENT) SIMULATOR
   ═══════════════════════════════════════════════════════ */
.cover-test-viewport-card {
  position: sticky;
  top: calc(var(--header-h) + 1rem);
  z-index: 10;
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-md);
  align-self: start;
}

.cover-test-mode-toggle {
  display: flex;
  gap: 0.25rem;
  background: var(--gray-100);
  padding: 2px;
  border-radius: var(--radius-sm);
}

.cover-test-mode-btn {
  border: none;
  background: transparent;
  padding: 3px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gray-600);
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition);
}

.cover-test-mode-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  font-weight: 700;
}

.cover-test-eye-stage {
  position: relative;
  width: 100%;
  max-width: 440px;
  margin: 0.5rem auto 0;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1rem 0.75rem 0.5rem;
  overflow: hidden;
}

.cover-test-eyes-row {
  display: flex;
  justify-content: space-around;
  align-items: center;
  gap: 1rem;
  width: 100%;
}

.cover-test-eye-col {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.cover-test-eye-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gray-600);
  margin-bottom: 0.35rem;
  letter-spacing: 0.02em;
}

.cover-test-eye-frame {
  position: relative;
  width: 150px;
  height: 100px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--gray-300);
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.06);
  overflow: hidden;
}

.cover-test-sclera {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, #ffffff 60%, #e2e8f0 100%);
}

.cover-test-iris {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #60a5fa 0%, #2563eb 50%, #1e3a8a 85%, #0f172a 100%);
  box-shadow: 0 0 4px rgba(0,0,0,0.3);
  transform: translate(-50%, -50%);
  transition: transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1);
  will-change: transform;
}

.cover-test-pupil {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #09090b;
  transform: translate(-50%, -50%);
}

.cover-test-corneal-reflex {
  position: absolute;
  top: 38%;
  left: 40%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 2px rgba(255,255,255,0.8);
}

.cover-test-eye-occluded-overlay {
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.92);
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

.cover-test-snap-zone {
  position: absolute;
  inset: -15px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 5;
}

.cover-test-occluder-dock {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 0.85rem;
  padding-bottom: 0.25rem;
  min-height: 90px;
}

.cover-test-occluder {
  position: relative;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: #0f172a;
  border: 2px solid rgba(255,255,255,0.3);
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
  cursor: grab;
  touch-action: none;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  transition: box-shadow 0.2s ease;
}

.cover-test-occluder:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,0.45);
  border-color: rgba(255,255,255,0.6);
}

.cover-test-occluder.dragging {
  cursor: grabbing !important;
  box-shadow: 0 12px 28px rgba(0,0,0,0.55);
  z-index: 25;
  transition: none;
}

.cover-test-occluder.docked {
  position: absolute;
  z-index: 12;
}

.cover-test-occluder-disc {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}

.cover-test-occluder-text {
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #94a3b8;
  line-height: 1.1;
}

.cover-test-fallback-controls {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  margin-top: 0.65rem;
  flex-wrap: wrap;
}

.cover-test-observation-card {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  margin-top: 0.65rem;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--gray-800);
  line-height: 1.4;
}

.cover-test-obs-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.cover-test-case-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.cover-test-case-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--gray-800);
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
}

.cover-test-case-btn:hover {
  border-color: var(--primary-light);
  background: var(--gray-50);
}

.cover-test-case-btn.active {
  border-color: var(--primary);
  background: var(--primary-50);
  color: var(--primary);
  font-weight: 700;
}

.cover-test-form-group {
  margin-bottom: 0.85rem;
}

.cover-test-form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--gray-700);
  margin-bottom: 0.35rem;
}

.cover-test-segmented {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.cover-test-seg-btn {
  flex: 1 1 auto;
  padding: 0.4rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--gray-700);
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}

.cover-test-seg-btn:hover {
  background: var(--gray-50);
}

.cover-test-seg-btn.active {
  background: var(--primary-50);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 700;
  box-shadow: 0 0 0 1px var(--primary);
}

@media (max-width: 960px) {
  #cover-test-view .lensometer-modern-container {
    display: flex;
    flex-direction: column;
  }

  .cover-test-viewport-card {
    position: sticky;
    top: calc(var(--header-h) + 0.25rem);
    z-index: 20;
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .cover-test-eye-frame {
    width: 125px;
    height: 85px;
  }

  .cover-test-iris {
    width: 48px;
    height: 48px;
  }

  .cover-test-pupil {
    width: 18px;
    height: 18px;
  }

  .cover-test-occluder {
    width: 76px;
    height: 76px;
  }

  .cover-test-viewport-card {
    padding: 0.75rem;
  }
}

@media (max-width: 360px), (max-height: 520px) {
  .cover-test-viewport-card {
    position: relative !important;
    top: auto !important;
    z-index: auto !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   ERROR OF REFRACTION SIMULATOR
   ═══════════════════════════════════════════════════════════════════════════════ */
.refractive-error-viewport-card {
  position: sticky;
  top: calc(var(--header-h) + 1rem);
  z-index: 10;
  max-height: calc(100vh - var(--header-h) - 2rem);
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
}

.refractive-error-stage-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.4rem;
  margin-bottom: 0.15rem;
}

.refractive-error-zoom-group {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.refractive-error-zoom-readout {
  display: inline-block;
  min-width: 42px;
  text-align: center;
  font-family: monospace;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gray-700);
}

.refractive-error-stage-wrap {
  position: relative;
  width: 100%;
  max-width: 520px;
  margin: 0.5rem auto 0;
  background: linear-gradient(180deg, #0b1329 0%, #172554 100%);
  border: 1px solid var(--gray-700);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.4);
}

.refractive-error-stage-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-origin: center center;
  transition: transform 0.15s ease-out;
}

.refractive-error-svg {
  width: 100%;
  height: auto;
  display: block;
}

.refractive-error-patient-view {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 112px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  z-index: 15;
  overflow: hidden;
  backdrop-filter: blur(4px);
}

.refractive-error-pv-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem 0.45rem;
  background: var(--gray-100);
  border-bottom: 1px solid var(--gray-200);
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--gray-700);
  user-select: none;
}

.refractive-error-pv-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0;
  line-height: 1;
}

.refractive-error-pv-target-box {
  width: 100%;
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  padding: 0.25rem;
  overflow: hidden;
}

.refractive-error-snellen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #000000;
  font-family: 'Arial Black', Impact, sans-serif;
  font-weight: 900;
  line-height: 1;
  transition: filter 0.08s linear;
}

.snellen-letter-xl {
  font-size: 2.2rem;
  letter-spacing: -0.05em;
}

.snellen-row-sm {
  font-size: 1.05rem;
  letter-spacing: 0.22rem;
  margin-top: 0.18rem;
}

.snellen-row-xs {
  font-size: 0.72rem;
  letter-spacing: 0.16rem;
  margin-top: 0.18rem;
}

.refractive-clock-svg {
  width: 86px;
  height: 86px;
  display: block;
  transition: filter 0.08s linear;
}

.refractive-error-status-card {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  margin-top: 0.65rem;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--gray-800);
  line-height: 1.4;
}

.refractive-error-status-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.refractive-error-case-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.refractive-error-case-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--gray-800);
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
}

.refractive-error-case-btn:hover {
  border-color: var(--primary-light);
  background: var(--gray-50);
}

.refractive-error-case-btn.active {
  border-color: var(--primary);
  background: var(--primary-50);
  color: var(--primary);
  font-weight: 700;
}

.refractive-error-slider-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.refractive-error-slider-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--gray-700);
  font-weight: 600;
}

.refractive-error-metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.refractive-error-metric-card {
  padding: 0.5rem 0.6rem;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
}

.refractive-error-metric-lbl {
  font-size: 0.68rem;
  color: var(--gray-500);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.refractive-error-metric-val {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-top: 0.15rem;
  font-family: monospace;
}

.refractive-error-dial-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

@media (max-width: 960px) {
  #refractive-error-view .lensometer-modern-container {
    display: flex;
    flex-direction: column;
  }

  .refractive-error-viewport-card {
    position: sticky;
    top: calc(var(--header-h) + 0.25rem);
    z-index: 20;
    max-width: 100%;
    padding: 0.85rem;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
  }
}

@media (max-width: 480px) {
  .refractive-error-viewport-card {
    padding: 0.65rem;
  }

  .refractive-error-patient-view {
    width: 96px;
  }

  .refractive-error-pv-target-box {
    height: 80px;
  }

  .snellen-letter-xl {
    font-size: 1.8rem;
  }

  .snellen-row-sm {
    font-size: 0.9rem;
  }

  .snellen-row-xs {
    font-size: 0.65rem;
  }
}

@media (max-width: 360px), (max-height: 520px) {
  .refractive-error-viewport-card {
    position: relative !important;
    top: auto !important;
    z-index: auto !important;
  }
}


/* ═══════════════════ TIER 0: SERVER-BACKED STATES ═══════════════════ */

/* Status banners (session, offline, connection, membership, payment) */
.app-banners { display: flex; flex-direction: column; }
.app-banners[hidden] { display: none; }
.app-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  background: var(--warning-bg);
  color: var(--gray-800);
  border-bottom: 1px solid var(--warning-light);
}
.app-banner-session { background: var(--danger-bg); border-bottom-color: var(--danger-light); }
.app-banner-payment { background: var(--success-bg); border-bottom-color: var(--success-light); }
.app-banner-action {
  padding: 0.2rem 0.7rem;
  border: 1px solid var(--gray-300);
  border-radius: 999px;
  background: var(--surface);
  color: var(--gray-700);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.app-banner-action:hover { border-color: var(--primary); color: var(--primary); }

/* Global resume banner (open exams and practice sets) */
.resume-banner {
  background: var(--primary-50);
  border-bottom: 1px solid var(--primary-light);
  padding: 0.4rem 1rem;
}
.resume-banner[hidden] { display: none; }
.resume-row {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.2rem 0;
  font-size: 0.85rem;
  color: var(--gray-800);
}
.resume-time { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--primary-dark); }
.resume-actions { display: inline-flex; gap: 0.5rem; }

/* Toast */
.app-toast {
  position: fixed;
  left: 50%;
  bottom: 5.5rem;
  transform: translateX(-50%);
  max-width: calc(100% - 2rem);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--gray-900);
  color: #fff;
  font-size: 0.85rem;
  box-shadow: var(--shadow-lg);
  z-index: 10001;
}
.app-toast[hidden] { display: none; }

/* Notice dialog and preview notice */
.notice-body:empty { display: none; }
.notice-body { margin-top: 0.75rem; }
.open-attempts-list { display: flex; flex-direction: column; gap: 0.5rem; }
.open-attempt-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.85rem;
}
.open-attempt-row span { flex: 1 1 12rem; }
.preview-denied {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: var(--bg);
  z-index: 10002;
}
.preview-denied[hidden] { display: none; }
.preview-denied-card {
  max-width: 420px;
  padding: 2rem;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.preview-denied-card h2 { margin-bottom: 0.5rem; }
.preview-denied-card p { color: var(--gray-600); margin-bottom: 1.25rem; }
.upgrade-reason {
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--warning-bg);
  color: var(--gray-800);
  font-size: 0.88rem;
}
.upgrade-reason[hidden] { display: none; }

/* Header badge while membership cannot be verified */
.tier-badge.tier-unknown { opacity: 0.55; filter: grayscale(1); }

/* Landing: OLE subjects (minimalist expandable cards, no counts) */
.landing-subjects {
  max-width: 1000px;
  margin: 3.5rem auto 0;
  text-align: left;
}
.landing-subjects-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1.25;
  text-align: center;
  margin-bottom: 0.4rem;
}
.landing-subjects-intro {
  max-width: 560px;
  margin: 0 auto 1.75rem;
  font-size: 0.95rem;
  color: var(--gray-600);
  text-align: center;
}
.landing-subjects-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  align-items: start;
}
.landing-subject-card {
  --subject-pad: 1.15rem;
  --subject-icon: 48px;
  --subject-gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--gray-100);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 6px 20px rgba(15, 23, 42, 0.06);
  transition: box-shadow var(--transition), border-color var(--transition);
}
.landing-subject-card.is-open {
  border-color: var(--gray-200);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 10px 28px rgba(15, 23, 42, 0.09);
}
@media (hover: hover) {
  .landing-subject-card:hover {
    border-color: var(--gray-200);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 10px 28px rgba(15, 23, 42, 0.09);
  }
}
.landing-subject-heading {
  margin: 0;
  font: inherit;
}
.landing-subject-toggle {
  display: flex;
  align-items: center;
  gap: var(--subject-gap);
  width: 100%;
  min-height: 72px;
  padding: var(--subject-pad);
  background: none;
  border: 0;
  border-radius: 16px;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.landing-subject-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.landing-subject-icon {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--subject-icon);
  height: var(--subject-icon);
  border-radius: 12px;
  background: var(--primary-50);
  color: var(--primary);
}
.landing-subject-icon svg {
  width: 26px;
  height: 26px;
}
.landing-subject-name {
  flex: 1;
  min-width: 0;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--gray-900);
  overflow-wrap: anywhere;
}
.landing-subject-chevron {
  flex: none;
  width: 20px;
  height: 20px;
  color: var(--gray-500);
  transition: transform 0.25s ease, color var(--transition);
}
.landing-subject-card.is-open .landing-subject-chevron {
  transform: rotate(180deg);
  color: var(--primary);
}
/* Collapsed panels are hidden from assistive tech via visibility; height animates via grid rows. */
.landing-subject-panel {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  visibility: hidden;
  transition: grid-template-rows 0.28s ease, opacity 0.2s ease, visibility 0s linear 0.28s;
}
.landing-subject-card.is-open .landing-subject-panel {
  grid-template-rows: 1fr;
  opacity: 1;
  visibility: visible;
  transition: grid-template-rows 0.28s ease, opacity 0.25s ease 0.05s, visibility 0s;
}
.landing-subject-panel-inner {
  min-height: 0;
  overflow: hidden;
}
.landing-subject-desc {
  padding: 0 var(--subject-pad) var(--subject-pad) calc(var(--subject-pad) + var(--subject-icon) + var(--subject-gap));
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--gray-600);
}
@media (prefers-reduced-motion: reduce) {
  .landing-subject-card,
  .landing-subject-chevron,
  .landing-subject-panel,
  .landing-subject-card.is-open .landing-subject-panel {
    transition: none;
  }
}
@media (max-width: 640px) {
  .landing-subjects { margin-top: 2.5rem; }
  .landing-subjects-title { font-size: 1.3rem; }
  .landing-subjects-intro { font-size: 0.88rem; margin-bottom: 1.25rem; }
  .landing-subjects-grid { grid-template-columns: minmax(0, 1fr); gap: 0.75rem; }
  .landing-subject-card { --subject-pad: 0.9rem; --subject-icon: 44px; --subject-gap: 0.85rem; border-radius: 14px; }
  .landing-subject-toggle { min-height: 64px; border-radius: 14px; }
  .landing-subject-icon { border-radius: 11px; }
  .landing-subject-icon svg { width: 24px; height: 24px; }
  .landing-subject-name { font-size: 1rem; }
  .landing-subject-desc { padding-left: var(--subject-pad); font-size: 0.88rem; }
}
@media (max-width: 360px) {
  .landing-subject-card { --subject-pad: 0.8rem; --subject-icon: 40px; --subject-gap: 0.7rem; }
  .landing-subject-icon svg { width: 22px; height: 22px; }
}

/* Smart Study load status */
.smart-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: var(--gray-50);
  color: var(--gray-700);
  font-size: 0.88rem;
}
.smart-status[hidden] { display: none; }

/* Test flow */
.quiz-answer-status {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.75rem;
  color: var(--danger);
  font-size: 0.88rem;
}
.quiz-answer-status[hidden] { display: none; }
.nav-cell.unavailable { opacity: 0.4; text-decoration: line-through; }
.review-removed { color: var(--gray-500); font-style: italic; font-size: 0.88rem; margin-top: 0.4rem; }
.review-updated-tag {
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}
.review-unavailable { text-align: center; color: var(--gray-500); padding: 1rem; }
.results-save-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0 0 1rem;
  color: var(--gray-600);
  font-size: 0.88rem;
}
.results-save-status[hidden] { display: none; }

/* History */
.history-source-tag {
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--gray-100);
  color: var(--gray-600);
  font-size: 0.72rem;
}
.history-load-more-row { display: flex; justify-content: center; margin-top: 1rem; }
