/* =============================================================================
   LabSimplifier — Premium Lab Exam Preparation Design System
   ============================================================================= */

:root {
  /* Design Tokens - Light Theme Default */
  --bg-light: #f4f5fa;
  --bg-dark: #0b1020;
  --card-light: #ffffff;
  --card-dark: #141a2e;
  --ink-light: #0f172a;
  --ink-dark: #e8ecf8;
  --mut-light: #64748b;
  --mut-dark: #94a3b8;
  --line-light: #e2e8f0;
  --line-dark: #243050;
  --acc: #e5383b;         /* Laser Red */
  --acc-glow: rgba(229, 56, 59, 0.4);
  --acc-subtle: rgba(229, 56, 59, 0.08);
  --acc2: #4f46e5;        /* Indigo */
  --acc2-glow: rgba(79, 70, 229, 0.35);
  --acc2-subtle: rgba(79, 70, 229, 0.1);
  --ok: #16a34a;          /* Success green */
  --ok-bg: #dcfce7;
  --warn: #eab308;
  --warn-bg: #fef9c3;
  --err: #dc2626;
  --err-bg: #fee2e2;

  /* Current Active Theme Variables */
  --bg: var(--bg-light);
  --card: var(--card-light);
  --card-subtle: #f8fafc;
  --ink: var(--ink-light);
  --mut: var(--mut-light);
  --line: var(--line-light);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.12);

  /* Geometry */
  --radius: 18px;
  --radius-btn: 14px;
  --radius-sm: 10px;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-math: "Cambria Math", "Times New Roman", Times, Georgia, serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --nav-height: 64px;
  --max-width: 920px;
}

[data-theme="dark"] {
  --bg: var(--bg-dark);
  --card: var(--card-dark);
  --card-subtle: #19223c;
  --ink: var(--ink-dark);
  --mut: var(--mut-dark);
  --line: var(--line-dark);
  --acc-subtle: rgba(229, 56, 59, 0.15);
  --acc2-subtle: rgba(79, 70, 229, 0.2);
  --ok-bg: rgba(22, 163, 74, 0.2);
  --warn-bg: rgba(234, 179, 8, 0.2);
  --err-bg: rgba(220, 38, 38, 0.2);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.6);
}

/* Base Reset & Typography */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100%;
  transition: background-color 0.25s ease, color 0.25s ease;
}

body {
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 20px);
}

body.auth-mode, body.sim-open {
  padding-bottom: 0;
}

#app {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px 16px calc(var(--nav-height) + 16px);
  position: relative;
}

body.auth-mode #app {
  padding: 16px;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Links, Headings, Text */
a {
  color: var(--acc2);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

h1, h2, h3, h4 {
  color: var(--ink);
  font-weight: 700;
  line-height: 1.25;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }

p {
  color: var(--ink);
}

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

.math-font {
  font-family: var(--font-math);
  font-style: italic;
  letter-spacing: 0.5px;
}

/* Header & Top Bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  padding-top: max(8px, env(safe-area-inset-top));
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--acc), #ff6b6b);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 900;
  font-size: 1.2rem;
  box-shadow: 0 4px 12px var(--acc-glow);
  flex-shrink: 0;
}

.brand-name {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--ink);
}
.brand-name span {
  color: var(--acc);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  min-width: 44px;
  padding: 10px 18px;
  border-radius: var(--radius-btn);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  user-select: none;
}

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

.btn:disabled, .btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
  transform: none;
}

.btn-primary {
  background: var(--acc);
  color: #ffffff;
  box-shadow: 0 4px 14px var(--acc-glow);
}
.btn-primary:hover:not(:disabled) {
  background: #c92a2a;
  box-shadow: 0 6px 18px var(--acc-glow);
  transform: translateY(-1px);
}

.btn-indigo {
  background: var(--acc2);
  color: #ffffff;
  box-shadow: 0 4px 14px var(--acc2-glow);
}
.btn-indigo:hover:not(:disabled) {
  background: #4338ca;
  box-shadow: 0 6px 18px var(--acc2-glow);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}
.btn-outline:hover:not(:disabled) {
  background: var(--card-subtle);
  border-color: var(--mut);
}

.btn-ghost {
  background: transparent;
  color: var(--mut);
}
.btn-ghost:hover:not(:disabled) {
  color: var(--ink);
  background: var(--card-subtle);
}

.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
}
.btn-icon:hover {
  background: var(--card-subtle);
}

/* Card Styles */
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  position: relative;
}

.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(79, 70, 229, 0.3);
}

/* Badges & Chips */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  border-radius: 999px;
  width: fit-content;
}

.badge-ready {
  background: var(--ok-bg);
  color: var(--ok);
}

.badge-soon {
  background: var(--card-subtle);
  color: var(--mut);
  border: 1px solid var(--line);
}

.badge-acc {
  background: var(--acc-subtle);
  color: var(--acc);
}

.badge-indigo {
  background: var(--acc2-subtle);
  color: var(--acc2);
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--card-subtle);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 38px;
}

.chip:hover {
  border-color: var(--acc2);
}

.chip.active {
  background: var(--acc2);
  color: #ffffff;
  border-color: var(--acc2);
  box-shadow: 0 2px 8px var(--acc2-glow);
}

/* =============================================================================
   Auth Screen
   ============================================================================= */
.auth-container {
  width: 100%;
  max-width: 440px;
  margin: auto;
}

.auth-header {
  text-align: center;
  margin-bottom: 24px;
}

.auth-header .brand-logo-icon {
  margin: 0 auto 12px;
  width: 52px;
  height: 52px;
  font-size: 1.6rem;
}

.auth-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 28px 24px;
  box-shadow: var(--shadow-lg);
}

.auth-tabs {
  display: flex;
  background: var(--card-subtle);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 24px;
  gap: 4px;
}

.auth-tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 4px;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 8px;
  color: var(--mut);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.auth-tab-btn.active {
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.form-group {
  margin-bottom: 18px;
  position: relative;
}

.form-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink);
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 14px;
  color: var(--mut);
  pointer-events: none;
  font-size: 1.1rem;
}

.form-control {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  padding-left: 42px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-btn);
  background: var(--card);
  color: var(--ink);
  font-size: 0.95rem;
  font-family: var(--font-sans);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control.has-toggle {
  padding-right: 48px;
}

.form-control:focus {
  outline: none;
  border-color: var(--acc2);
  box-shadow: 0 0 0 3px var(--acc2-subtle);
}

/* Eye button toggle */
.btn-toggle-eye {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--mut);
  cursor: pointer;
  border-radius: 8px;
  font-size: 1.1rem;
  transition: color 0.15s ease;
}
.btn-toggle-eye:hover {
  color: var(--ink);
  background: var(--card-subtle);
}

.form-helper {
  font-size: 0.78rem;
  color: var(--mut);
  margin-top: 4px;
}

.auth-links {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  font-size: 0.85rem;
}

/* =============================================================================
   Home View & Bento Grid
   ============================================================================= */
.greeting-section {
  margin-bottom: 24px;
}

.greeting-text {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.greeting-subtitle {
  color: var(--mut);
  font-size: 0.95rem;
  margin-top: 2px;
}

/* Search Bar */
.search-container {
  margin-bottom: 24px;
  position: relative;
}

.search-input-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-box .search-icon {
  position: absolute;
  left: 16px;
  font-size: 1.15rem;
  color: var(--mut);
  pointer-events: none;
}

.search-input {
  width: 100%;
  min-height: 50px;
  padding: 12px 18px 12px 48px;
  border-radius: 16px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-size: 1rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--acc2);
  box-shadow: 0 0 0 4px var(--acc2-subtle);
}

.search-clear-btn {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--mut);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
}

.search-results {
  margin-top: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow-md);
}

.search-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.search-item:hover {
  background: var(--card-subtle);
}
.search-item.disabled {
  opacity: 0.6;
  cursor: default;
}

/* Bento Grid */
.bento-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 640px) {
  .bento-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .bento-col-span-2 {
    grid-column: span 2;
  }
}

.bento-card {
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.bento-for-you {
  background: linear-gradient(135deg, var(--card) 0%, var(--card-subtle) 100%);
  border: 2px solid var(--line);
  position: relative;
  overflow: hidden;
}

.bento-for-you::after {
  content: "";
  position: absolute;
  right: -40px;
  top: -40px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--acc-glow), transparent 70%);
  pointer-events: none;
}

.bento-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-top: 8px;
  margin-bottom: 6px;
}

.bento-desc {
  font-size: 0.9rem;
  color: var(--mut);
  margin-bottom: 16px;
}

.progress-track {
  width: 100%;
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin: 10px 0;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--acc), #ff6b6b);
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* Upcoming list items */
.upcoming-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}
.upcoming-item:last-child {
  border-bottom: none;
}

/* =============================================================================
   Experiment Flow & Step Bar
   ============================================================================= */
.exp-header {
  margin-bottom: 20px;
}

.exp-nav-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.exp-step-indicator {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.step-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--mut);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.step-dots {
  display: flex;
  gap: 6px;
}

.step-dot {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  transition: background 0.3s ease;
}

.step-dot.active {
  background: var(--acc);
}

.step-dot.done {
  background: var(--ok);
}

/* Sticky Footer Navigation */
.exp-footer-nav {
  position: sticky;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 8px);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--card);
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  margin-top: 30px;
}

.exp-footer-buttons {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.gate-helper-text {
  font-size: 0.82rem;
  color: var(--acc);
  font-weight: 600;
  text-align: center;
}

/* Step 1: Intro */
.apparatus-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.apparatus-card {
  background: var(--card-subtle);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
  font-size: 0.88rem;
  font-weight: 600;
}

.apparatus-icon {
  font-size: 1.8rem;
  margin-bottom: 6px;
}

/* Step 2: Formula */
.formula-hero {
  background: var(--card-subtle);
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  margin-bottom: 20px;
}

.formula-main {
  font-family: var(--font-math);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--acc);
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.formula-sub {
  font-family: var(--font-math);
  font-size: 1.3rem;
  color: var(--mut);
}

.symbols-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.92rem;
}

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

.symbols-table th {
  color: var(--mut);
  font-weight: 600;
  background: var(--card-subtle);
}

.accordion {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  margin-top: 16px;
}

.accordion-header {
  padding: 14px 18px;
  background: var(--card-subtle);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.accordion-body {
  padding: 18px;
  background: var(--card);
  font-size: 0.92rem;
  border-top: 1px solid var(--line);
  display: none;
}

.accordion.open .accordion-body {
  display: block;
}

/* =============================================================================
   Step 3: Simulation (FULL-SCREEN MODE)
   ============================================================================= */
.sim-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow-y: auto;
}

.sim-top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.sim-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sim-title {
  font-size: 1.05rem;
  font-weight: 700;
}

.sim-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 14px;
  gap: 14px;
  max-width: 1020px;
  margin: 0 auto;
  width: 100%;
}

/* Split view canvas cards */
.sim-canvas-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.sim-canvas-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background: var(--card-subtle);
  border-bottom: 1px solid var(--line);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--mut);
}

.sim-canvas-wrapper {
  position: relative;
  width: 100%;
  height: 200px;
  background: #090d16;
}

.sim-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Wall view container */
.sim-wall-wrapper {
  position: relative;
  width: 100%;
  height: 140px;
  background: #060911;
  overflow: hidden;
}

/* Procedure Step Banner */
.procedure-banner {
  background: var(--card);
  border: 1.5px solid var(--acc2);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  box-shadow: var(--shadow-sm);
}

.procedure-text {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
}

.procedure-step-badge {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--acc2);
  text-transform: uppercase;
  margin-bottom: 2px;
}

/* Controls Panel */
.sim-controls-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.controls-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 600px) {
  .controls-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.control-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--mut);
  display: flex;
  justify-content: space-between;
}

.control-val-badge {
  color: var(--acc);
  font-weight: 700;
}

.slider-custom {
  width: 100%;
  height: 6px;
  background: var(--line);
  border-radius: 999px;
  outline: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.slider-custom::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--acc);
  box-shadow: 0 2px 8px var(--acc-glow);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.slider-custom::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.segmented-control {
  display: flex;
  background: var(--card-subtle);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
}

.segmented-btn {
  flex: 1;
  padding: 8px 4px;
  border: none;
  background: transparent;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 8px;
  color: var(--mut);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}

.segmented-btn.active {
  background: var(--card);
  color: var(--acc2);
  box-shadow: var(--shadow-sm);
}

/* Simulation Readings Summary */
.sim-readings-box {
  background: var(--card-subtle);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.readings-counter {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink);
}

.readings-chips-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.reading-pill {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  background: var(--card);
  border: 1px solid var(--line);
  padding: 4px 8px;
  border-radius: 6px;
}

/* =============================================================================
   Step 4: Observation Table & Result
   ============================================================================= */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.obs-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
  font-size: 0.88rem;
}

.obs-table th {
  background: var(--card-subtle);
  color: var(--mut);
  font-weight: 600;
  padding: 12px 10px;
  border-bottom: 1.5px solid var(--line);
  text-align: center;
  white-space: nowrap;
}

.obs-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: center;
  color: var(--ink);
  font-family: var(--font-mono);
}

.obs-input {
  width: 76px;
  text-align: center;
  padding: 6px 4px;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card-subtle);
  color: var(--ink);
}

.obs-input:focus {
  border-color: var(--acc2);
  outline: none;
  background: var(--card);
}

.result-summary-card {
  background: linear-gradient(135deg, var(--card) 0%, var(--card-subtle) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
}

.result-val-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.result-val-row:last-child {
  border-bottom: none;
}

/* =============================================================================
   Step 5: Quiz
   ============================================================================= */
.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.quiz-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.quiz-q-num {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--acc2);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.quiz-q-text {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 16px;
}

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

.quiz-option {
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  text-align: left;
  font-size: 0.92rem;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.quiz-option:hover:not(:disabled) {
  border-color: var(--acc2);
  background: var(--card-subtle);
  transform: translateX(2px);
}

.quiz-option.correct {
  background: var(--ok-bg) !important;
  border-color: var(--ok) !important;
  color: var(--ok) !important;
  font-weight: 600;
}

.quiz-option.incorrect {
  background: var(--err-bg) !important;
  border-color: var(--err) !important;
  color: var(--err) !important;
  font-weight: 600;
}

.quiz-score-banner {
  background: var(--card-subtle);
  border: 2px solid var(--acc2);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
  margin-top: 20px;
}

/* =============================================================================
   Step 6: Viva 3D Flip Card
   ============================================================================= */
.viva-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.viva-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 580px;
}

.flip-card {
  perspective: 800px;
  width: 100%;
  max-width: 580px;
  height: 320px;
  cursor: pointer;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.flip-card.flipped .flip-card-inner {
  transform: rotateY(180deg);
}

.flip-card-front, .flip-card-back {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius);
  padding: 28px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 1.5px solid var(--line);
}

.flip-card-front {
  background: var(--card);
}

.flip-card-back {
  background: linear-gradient(135deg, var(--card) 0%, var(--card-subtle) 100%);
  transform: rotateY(180deg);
  border-color: var(--acc2);
}

.viva-badge {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--mut);
  text-transform: uppercase;
}

.viva-q-text {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--ink);
}

.viva-a-text {
  font-size: 1.1rem;
  font-weight: 500;
  line-height: 1.5;
  color: var(--ink);
}

.viva-hint {
  font-size: 0.8rem;
  color: var(--mut);
  display: flex;
  align-items: center;
  gap: 6px;
}

.viva-nav-controls {
  display: flex;
  align-items: center;
  gap: 14px;
}

.viva-pills-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 580px;
}

.viva-pill {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--mut);
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.viva-pill.active {
  background: var(--acc2);
  color: #fff;
  border-color: var(--acc2);
}

/* =============================================================================
   Step 7: Overview & Celebration
   ============================================================================= */
.celebrate-card {
  text-align: center;
  padding: 32px 20px;
  background: linear-gradient(135deg, var(--card) 0%, var(--card-subtle) 100%);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  margin-bottom: 24px;
}

.celebrate-emoji {
  font-size: 3.5rem;
  margin-bottom: 12px;
  display: inline-block;
  animation: bounce 1.2s infinite ease-in-out;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.calc-breakdown-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
}

.calc-step {
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
}
.calc-step:last-child {
  border-bottom: none;
}

.statement-box {
  background: var(--ok-bg);
  border: 1.5px solid var(--ok);
  border-radius: var(--radius-btn);
  padding: 16px 20px;
  color: var(--ink);
  font-weight: 600;
  margin-top: 16px;
}

/* =============================================================================
   Bottom Navigation
   ============================================================================= */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card);
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 99;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.05);
}

#bottom-nav[hidden] {
  display: none !important;
}

#bottom-nav button {
  flex: 1;
  height: 100%;
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--mut);
  cursor: pointer;
  transition: color 0.15s ease;
  font-family: var(--font-sans);
}

#bottom-nav button .nav-icon {
  font-size: 1.3rem;
  line-height: 1;
}

#bottom-nav button .nav-label {
  font-size: 0.72rem;
  font-weight: 600;
}

#bottom-nav button.active {
  color: var(--acc);
}

#bottom-nav button:focus-visible {
  outline: 2px solid var(--acc2);
  outline-offset: -2px;
}

/* =============================================================================
   Toast Notifications
   ============================================================================= */
.toast-container {
  position: fixed;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: 90%;
  max-width: 420px;
}

.toast {
  background: #0f172a;
  color: #ffffff;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  pointer-events: auto;
}

[data-theme="dark"] .toast {
  background: #1e293b;
  border: 1px solid var(--line);
}

.toast.toast-error {
  border-left: 4px solid var(--err);
}
.toast.toast-success {
  border-left: 4px solid var(--ok);
}

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

.toast.fade-out {
  opacity: 0;
  transform: translateY(-8px);
  transition: all 0.3s ease;
}

/* =============================================================================
   Accessibility & Reduced Motion
   ============================================================================= */
:focus-visible {
  outline: 2px solid var(--acc2);
  outline-offset: 2px;
}

body { user-select: none; }
input, textarea, select { user-select: text; }
@media print { body { display: none !important; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .flip-card-inner {
    transition: none !important;
  }
}
