/* ===================================================
   Microsoft Windows 11 Fluent Design System
   Quiz Application Theme
   =================================================== */

/* Import Windows 11 System Font (Segoe UI Variable) */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap");

/* ==================== DESIGN TOKENS ==================== */
:root {
  color-scheme: light dark;
  /* ===== Windows 11 Color Palette ===== */

  /* Background Layers (Mica-inspired) */
  --bg-solid-base: #202020;
  --bg-solid-secondary: #1c1c1c;
  --bg-solid-tertiary: #282828;
  --bg-mica: linear-gradient(
    135deg,
    rgba(32, 32, 36, 0.95) 0%,
    rgba(24, 24, 28, 0.98) 50%,
    rgba(20, 20, 24, 1) 100%
  );

  /* Beautiful ambient background */
  --bg-color: #0a0a0c;
  --bg-image:
    radial-gradient(
      ellipse 150% 100% at 25% 0%,
      rgba(96, 165, 250, 0.08) 0%,
      transparent 50%
    ),
    radial-gradient(
      ellipse 100% 150% at 80% 100%,
      rgba(168, 85, 247, 0.06) 0%,
      transparent 50%
    ),
    linear-gradient(180deg, #0f0f12 0%, #0a0a0c 100%);

  /* Acrylic/Glass Layers */
  --acrylic-bg: rgba(32, 32, 32, 0.75);
  --acrylic-bg-elevated: rgba(44, 44, 44, 0.85);
  --acrylic-blur: 20px;

  /* Card/Surface Layers */
  --card-bg: rgba(255, 255, 255, 0.05);
  --card-bg-hover: rgba(255, 255, 255, 0.08);
  --card-bg-pressed: rgba(255, 255, 255, 0.03);
  --card-bg-elevated: rgba(255, 255, 255, 0.07);

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-default: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.18);
  --border-focus: var(--accent-default);

  /* Stroke (Top highlight for depth) */
  --stroke-card-top: rgba(255, 255, 255, 0.12);

  /* Text Colors */
  --text-primary: rgba(255, 255, 255, 0.95);
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-tertiary: rgba(255, 255, 255, 0.5);
  --text-disabled: rgba(255, 255, 255, 0.35);
  --text-on-accent: #000000;

  /* Accent Colors (Windows 11 Default Blue) */
  --accent-default: #60cdff;
  --accent-secondary: rgba(96, 205, 255, 0.15);
  --accent-tertiary: rgba(96, 205, 255, 0.1);
  --accent-hover: #76d6ff;
  --accent-pressed: #4bc5ff;
  --accent-glow: rgba(96, 205, 255, 0.25);

  /* System Colors */
  --success-default: #6ccb5f;
  --success-bg: rgba(108, 203, 95, 0.15);
  --error-default: #ff6b6b;
  --error-bg: rgba(255, 107, 107, 0.15);
  --warning-default: #ffb938;
  --warning-bg: rgba(255, 185, 56, 0.15);
  --info-default: #60cdff;
  --info-bg: rgba(96, 205, 255, 0.15);

  /* Subject Badge custom colors */
  --badge-bg: var(--accent-tertiary);
  --badge-text: var(--accent-default);

  /* Legacy Aliases */
  --accent-color: var(--accent-default);
  --success-color: var(--success-default);
  --success: var(--success-default);
  --danger-color: var(--error-default);
  --error: var(--error-default);
  --warning-color: var(--warning-default);
  --warning: var(--warning-default);

  /* Shadows (Windows 11 Style) */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.24), 0 0 1px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.28), 0 0 1px rgba(0, 0, 0, 0.12);
  --shadow-xl: 0 16px 32px rgba(0, 0, 0, 0.32), 0 0 1px rgba(0, 0, 0, 0.12);
  --shadow-flyout: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 1px rgba(0, 0, 0, 0.2);

  /* Border Radius (Windows 11) */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-pill: 9999px;
  --radius-circular: 50%;

  /* Animation Curves (Fluent Motion) */
  --ease-standard: cubic-bezier(0.33, 0, 0.67, 1);
  --ease-decelerate: cubic-bezier(0, 0, 0, 1);
  --ease-accelerate: cubic-bezier(1, 0, 1, 1);
  --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);

  /* New Dynamic Background Animation */
  --anim-breathing-bg: breathing-gradient 15s ease infinite alternate;

  /* Durations */
  --duration-fast: 100ms;
  --duration-normal: 200ms;
  --duration-slow: 300ms;
  --duration-slower: 400ms;

  /* Layout */
  --sidebar-width: 280px;
  --sidebar-collapsed-width: 64px;
  --right-sidebar-width: 320px;
  --header-height: 64px;

  /* Typography */
  --font-family:
    "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system,
    BlinkMacSystemFont, sans-serif;
  --font-size-caption: 0.778rem; /* 14px */
  --font-size-body: 0.889rem; /* 16px */
  --font-size-subtitle: 1rem; /* 18px */
  --font-size-title: 1.222rem; /* 22px */
  --font-size-display: 1.667rem; /* 30px */

  /* Scrollbar */
  --scrollbar-size: 10px;
  --scrollbar-thumb: rgba(255, 255, 255, 0.2);
  --scrollbar-thumb-hover: rgba(255, 255, 255, 0.35);
  --scrollbar-track: transparent;

  /* Modal */
  --modal-bg: rgba(32, 32, 32, 0.95);

  /* Legacy compatibility */
  --glass-base: var(--acrylic-bg);
  --glass-border: var(--border-subtle);
  --glass-shadow: var(--shadow-lg);
  --container-bg: var(--card-bg);
  --container-hover-bg: var(--card-bg-hover);
  --item-bg: var(--card-bg);
  --item-hover-bg: var(--card-bg-hover);
  --item-active-bg: var(--card-bg-pressed);
  --header-bg: var(--acrylic-bg-elevated);
}

/* ==================== LIGHT THEME ==================== */
:root[data-theme="light"] {
  --bg-solid-base: #f3f3f3;
  --bg-solid-secondary: #fafafa;
  --bg-solid-tertiary: #ebebeb;
  --bg-mica: linear-gradient(
    135deg,
    rgba(250, 250, 252, 0.98) 0%,
    rgba(243, 243, 245, 0.99) 50%,
    rgba(240, 240, 242, 1) 100%
  );

  --bg-color: #f0f0f2;
  --bg-image:
    radial-gradient(
      ellipse 150% 100% at 25% 0%,
      rgba(96, 165, 250, 0.06) 0%,
      transparent 50%
    ),
    radial-gradient(
      ellipse 100% 150% at 80% 100%,
      rgba(168, 85, 247, 0.04) 0%,
      transparent 50%
    ),
    linear-gradient(180deg, #f5f5f7 0%, #e8e8ea 100%);

  --acrylic-bg: rgba(255, 255, 255, 0.8);
  --acrylic-bg-elevated: rgba(255, 255, 255, 0.9);

  --card-bg: rgba(255, 255, 255, 0.6);
  --card-bg-hover: rgba(255, 255, 255, 0.8);
  --card-bg-pressed: rgba(255, 255, 255, 0.5);
  --card-bg-elevated: rgba(255, 255, 255, 0.85);

  --border-subtle: rgba(0, 0, 0, 0.06);
  --border-default: rgba(0, 0, 0, 0.1);
  --border-strong: rgba(0, 0, 0, 0.15);
  --stroke-card-top: rgba(255, 255, 255, 0.6);

  --text-primary: rgba(0, 0, 0, 0.9);
  --text-secondary: rgba(0, 0, 0, 0.65);
  --text-tertiary: rgba(0, 0, 0, 0.45);
  --text-disabled: rgba(0, 0, 0, 0.3);
  --text-on-accent: #ffffff;

  --accent-default: #005fb8;
  --accent-secondary: rgba(0, 95, 184, 0.12);
  --accent-tertiary: rgba(0, 95, 184, 0.08);
  --accent-hover: #0067c0;
  --accent-pressed: #005299;
  --accent-glow: rgba(0, 95, 184, 0.2);

  --success-default: #107c10;
  --success-bg: rgba(16, 124, 16, 0.12);
  --error-default: #c42b1c;
  --error-bg: rgba(196, 43, 28, 0.12);
  --warning-default: #9d5d00;
  --warning-bg: rgba(157, 93, 0, 0.12);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.08), 0 0 1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.1), 0 0 1px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 8px 16px rgba(0, 0, 0, 0.12), 0 0 1px rgba(0, 0, 0, 0.04);
  --shadow-flyout: 0 8px 24px rgba(0, 0, 0, 0.14), 0 0 1px rgba(0, 0, 0, 0.06);

  --scrollbar-thumb: rgba(0, 0, 0, 0.2);
  --scrollbar-thumb-hover: rgba(0, 0, 0, 0.35);

  --modal-bg: rgba(255, 255, 255, 0.95);

  --glass-base: var(--acrylic-bg);
  --glass-border: var(--border-subtle);
  --container-bg: var(--card-bg);
  --container-hover-bg: var(--card-bg-hover);
  --item-bg: var(--card-bg);
  --item-hover-bg: var(--card-bg-hover);
  --item-active-bg: var(--card-bg-pressed);
  --header-bg: var(--acrylic-bg-elevated);
}

/* ==================== BASE RESET ==================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: calc(18px * (var(--font-scale, 100) / 100));
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-body);
  background-color: var(--bg-color);
  background-image: var(--bg-image);
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==================== SCROLLBARS ==================== */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

*::-webkit-scrollbar {
  width: var(--scrollbar-size);
  height: var(--scrollbar-size);
}

*::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: var(--radius-pill);
}

*::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  background-clip: content-box;
  transition: background var(--duration-fast);
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
  background-clip: content-box;
}

/* ==================== APP LAYOUT ==================== */
.app-container {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--acrylic-bg);
  backdrop-filter: blur(var(--acrylic-blur)) saturate(120%);
  -webkit-backdrop-filter: blur(var(--acrylic-blur)) saturate(120%);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width var(--duration-slow) var(--ease-decelerate);
  box-shadow: var(--shadow-md);
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

/* Sidebar Logo */
.logo {
  display: flex;
  align-items: center;
  padding: 12px 20px; /* 20px left matches nav-item (8px container + 12px item) */
  border-bottom: 1px solid var(--border-subtle);
  height: var(--header-height);
  min-height: var(--header-height);
  overflow: hidden;
  white-space: nowrap;
}

/* Logo Text Animation */
.logo span {
  font-size: var(--font-size-subtitle);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin-left: 12px;
  opacity: 1;
  max-width: 150px; /* Arbitrary large width */
  transition:
    opacity 0.2s var(--ease-standard),
    max-width 0.3s var(--ease-standard),
    margin-left 0.3s var(--ease-standard);
}

.sidebar.collapsed .logo span {
  opacity: 0;
  max-width: 0;
  margin-left: 0;
  pointer-events: none;
  cursor: default;
}

/* Sidebar Toggle Button & Icons */
/* Sidebar Toggle Button & Icons */
.sidebar-toggle-btn-inner,
.nav-item .icon,
.nav-item i {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  font-size: 1.222rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  color: var(--text-secondary);
}

/* Sidebar Toggle Button Specifics */
.sidebar-toggle-btn-inner {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  border-radius: var(--radius-md);
  transition: background var(--duration-normal);
}

.sidebar-toggle-btn-inner:hover {
  background: var(--card-bg-hover);
  color: var(--text-primary);
}

/* Navigation Links Container */
.nav-links {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden; /* Prevent horizontal scroll causing shifts */
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 8px 12px;
}

.sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--border-subtle);
  margin-top: auto;
}

/* Nav Item Layout */
.nav-item {
  display: flex;
  align-items: center;
  justify-content: flex-start; /* Explicitly align left */
  padding: 10px 12px; /* 12px internal horizontal padding */
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: var(--font-size-body);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-standard);
  text-align: left;
  width: 100%;
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  gap: 12px; /* Restored gap for consistent spacing */
}

/* Nav Item Text Animation */
.nav-item > span:not(.icon) {
  margin-left: 0; /* Remove margin since we use gap now */
  opacity: 1;
  max-width: 150px;
  transition:
    opacity 0.2s var(--ease-standard),
    max-width 0.3s var(--ease-standard);
}

.sidebar.collapsed .nav-item > span:not(.icon) {
  opacity: 0;
  max-width: 0;
}

/* Active Indicator */
.nav-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%) scaleY(0);
  width: 3px;
  height: 16px;
  background: var(--accent-default);
  border-radius: var(--radius-pill);
  transition: transform var(--duration-normal) var(--ease-decelerate);
}

.nav-item.active::before {
  transform: translateY(-50%) scaleY(1);
}

.nav-item:hover {
  background: var(--card-bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-tertiary);
  color: var(--accent-default);
}

.nav-item .icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-size: 1.111rem;
  flex-shrink: 0;
}

/* ==================== STATS CARD ==================== */
.stats-card {
  margin: 12px;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-top: 1px solid var(--stroke-card-top);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.sidebar.collapsed .stats-card {
  display: none;
}

.stat-group {
  margin-bottom: 16px;
}

.stat-group:last-child {
  margin-bottom: 0;
}

.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--font-size-caption);
  color: var(--text-tertiary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.stat-value {
  color: var(--text-primary);
  font-weight: 600;
}

/* Progress Bar */
.progress-bar-container {
  height: 4px;
  background: var(--border-subtle);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(
    90deg,
    var(--accent-default),
    var(--accent-hover)
  );
  border-radius: var(--radius-pill);
  transition: width var(--duration-slow) var(--ease-decelerate);
}

/* Pie Chart */
.pie-container {
  display: flex;
  gap: 16px;
  align-items: center;
}

.pie-chart {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-circular);
  background: conic-gradient(
    var(--success-default) 0%,
    var(--error-default) 0%
  );
  position: relative;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.pie-inner {
  position: absolute;
  inset: 6px;
  background: var(--bg-solid-base);
  border-radius: var(--radius-circular);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-caption);
  font-weight: 600;
  color: var(--text-primary);
}

.pie-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.722rem;
  color: var(--text-secondary);
}

.legend-item .dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-circular);
}

.legend-item .dot.correct {
  background: var(--success-default);
}

.legend-item .dot.incorrect {
  background: var(--error-default);
}

/* ==================== MAIN CONTENT ==================== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px 24px;
  overflow-y: auto;
  position: relative;
  background: transparent;
  transition:
    margin-left var(--duration-slow) var(--ease-decelerate),
    margin-right var(--duration-slow) var(--ease-decelerate);
}

@media (min-width: 769px) {
  .main-content.right-sidebar-open {
    margin-right: var(--right-sidebar-width);
  }
}

/* ==================== TOP BAR ==================== */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 16px;

  /* Premium Glass Bar */
  background: var(--card-bg);
  backdrop-filter: blur(var(--acrylic-blur));
  -webkit-backdrop-filter: blur(var(--acrylic-blur));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: var(--shadow-sm);
  padding: 12px 20px;
  border-radius: var(--radius-lg);
}

.header-left h2 {
  font-size: var(--font-size-title);
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

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

.btn-label {
  display: none;
}

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

/* Base Button (Windows 11 Standard) */
.fluent-btn,
.primary-btn,
.secondary-btn,
.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 32px;
  padding: 6px 12px;
  background: var(--card-bg);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: var(--font-size-body);
  font-weight: 400;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-standard);
  position: relative;
  overflow: hidden;
}

/* Reveal effect on hover */
.fluent-btn::before,
.secondary-btn::before,
.nav-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle 80px at var(--mouse-x, 50%) var(--mouse-y, 50%),
    rgba(255, 255, 255, 0.12),
    transparent 40%
  );
  opacity: 0;
  transition: opacity var(--duration-fast);
  pointer-events: none;
}

.fluent-btn:hover::before,
.secondary-btn:hover::before,
.nav-btn:hover:not(:disabled)::before {
  opacity: 1;
}

.fluent-btn:hover,
.secondary-btn:hover,
.nav-btn:hover:not(:disabled) {
  background: var(--card-bg-hover);
  border-color: var(--border-strong);
}

.fluent-btn:active,
.secondary-btn:active,
.nav-btn:active:not(:disabled) {
  background: var(--card-bg-pressed);
  transform: scale(0.98);
}

/* Toggle Button Active States */
.secondary-btn.active {
  background: var(--accent-tertiary);
  border-color: var(--accent-default);
  color: var(--accent-default);
}

/* Mark button active state - warning/yellow theme */
#mark-btn.active {
  background: var(--warning-bg);
  border-color: var(--warning-default);
  color: var(--warning-default);
}

/* See explanation button active state - accent/blue theme */
#see-explanation-btn.active {
  background: var(--accent-tertiary);
  border-color: var(--accent-default);
  color: var(--accent-default);
}

/* Primary Button (Accent) */
.primary-btn {
  background: var(--accent-default);
  border: 1px solid transparent;
  color: var(--text-on-accent);
  font-weight: 500;
  padding: 8px 16px;
}

.primary-btn::before {
  display: none;
}

.primary-btn:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 16px var(--accent-glow);
}

.primary-btn:active {
  background: var(--accent-pressed);
  transform: scale(0.98);
}

/* Disabled State */
button:disabled,
.fluent-btn:disabled,
.primary-btn:disabled,
.secondary-btn:disabled,
.nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.primary-btn:disabled {
  background: var(--card-bg);
  color: var(--text-disabled);
  border: 1px solid var(--border-subtle);
  box-shadow: none;
}

/* Icon Button */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-standard);
}

.icon-btn:hover {
  background: var(--card-bg-hover);
  color: var(--text-primary);
}

.icon-btn:active {
  background: var(--card-bg-pressed);
  transform: scale(0.92);
}

/* ==================== MOBILE STATS BAR ==================== */
.stats-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 20px;
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-top: 1px solid var(--stroke-card-top);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(var(--acrylic-blur));
  box-shadow: var(--shadow-sm);
  max-width: 900px;
  width: 100%;
  margin: 0 auto 24px auto;
}

.stats-bar.hidden {
  display: none !important;
}

.stat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.compact-row {
  justify-content: space-between;
}

.stat-group-mobile {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-label-inline {
  color: var(--text-tertiary);
  font-size: var(--font-size-caption);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.accuracy-bar-container {
  height: 6px;
  background: var(--border-subtle);
  border-radius: var(--radius-pill);
  display: flex;
  overflow: visible;
  min-width: 120px;
  flex: 1;
  position: relative;
}

.acc-bar-segment {
  height: 100%;
  transition: width var(--duration-slow) var(--ease-decelerate);
}

.acc-bar-segment.correct {
  background: var(--success-default);
  border-radius: var(--radius-pill) 0 0 var(--radius-pill);
}

.acc-bar-segment.correct.winning {
  box-shadow: 0 0 10px var(--success-default);
  z-index: 2;
}

.acc-bar-segment.incorrect {
  background: var(--error-default);
  border-radius: 0 var(--radius-pill) var(--radius-pill) 0;
}

.acc-bar-segment.incorrect.winning {
  box-shadow: 0 0 10px var(--error-default);
  z-index: 2;
}

/* Progress outline - shows completion progress as the bar's border */
.progress-outline {
  position: absolute;
  top: -3px;
  left: -3px;
  height: calc(100% + 6px);
  width: 0%;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: var(--radius-pill);
  pointer-events: none;
  transition: width var(--duration-slow) var(--ease-decelerate);
  box-sizing: border-box;
  z-index: 0;
}

/* Ensure segments are above the outline */
.acc-bar-segment {
  position: relative;
  z-index: 1;
}

/* Light mode - dark outline for contrast */
[data-theme="light"] .progress-outline {
  border-color: rgba(0, 0, 0, 0.6);
}

.count-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  font-size: var(--font-size-body);
}

.count-item.correct {
  color: var(--success-default);
}

.count-item.incorrect {
  color: var(--error-default);
}

/* ==================== STREAK COUNTER - FIRE THEME ==================== */
.streak-counter {
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-md);
  transition: all var(--duration-normal) var(--ease-standard);
}

/* Level 1: Warm (5-9 streak) - Deep red, cooler flame */
.streak-counter.streak-warm {
  color: #e63946;
  text-shadow: 0 0 8px rgba(230, 57, 70, 0.5);
}

/* Level 2: Hot (10-19 streak) - Orange flame, getting hotter */
.streak-counter.streak-hot {
  color: #ff7b00;
  background: linear-gradient(
    135deg,
    rgba(255, 123, 0, 0.15),
    rgba(230, 57, 70, 0.1)
  );
  text-shadow: 0 0 12px rgba(255, 123, 0, 0.6);
}

/* Level 3: Blazing (20-29 streak) - Yellow-orange, very hot */
.streak-counter.streak-blazing {
  color: #1a1a1a;
  background: linear-gradient(135deg, #ffbe0b, #ff9500);
  text-shadow: 0 0 10px rgba(255, 190, 11, 0.6);
}

/* Level 4: Inferno (30+ streak) - White-blue core, hottest flame */
.streak-counter.streak-inferno {
  color: #1a1a1a;
  background: linear-gradient(135deg, #fff8e7, #ffe066, #ffbe0b);
  background-size: 200% 200%;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.9);
  font-weight: 700;
}

/* Level 5: Plasma (50+ streak) - Blue/White, absolute hottest */
.streak-counter.streak-plasma {
  color: #003049; /* Dark blue text for contrast against bright core */
  background: linear-gradient(135deg, #e0faff, #4cc9f0, #4361ee);
  background-size: 200% 200%;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
  font-weight: 800;
  border: 1px solid rgba(255, 255, 255, 0.8);
}

/* One-time Pulse Animation Class */
.streak-animate {
  animation: streak-pulse-once 0.6s ease-out forwards;
}

@keyframes streak-pulse-once {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(255, 165, 0, 0.7);
  }
  50% {
    transform: scale(1.15);
    box-shadow: 0 0 20px 10px rgba(255, 165, 0, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(255, 165, 0, 0);
  }
}

/* ==================== QUIZ CARD ==================== */
.question-card,
.glass-panel {
  background: var(--card-bg);
  /* Premium Glass Effect: combining border with inner-highlight */
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    var(--shadow-lg),
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    /* Top edge light catch */ inset 0 0 20px rgba(255, 255, 255, 0.02); /* Inner depth */
  backdrop-filter: blur(25px) saturate(160%); /* Frosted & Vibrant */
  -webkit-backdrop-filter: blur(25px) saturate(160%);
  border-radius: var(--radius-xl);
  padding: 28px;
  position: relative;
  overflow: hidden; /* For shine effects */
  transition:
    transform 0.3s var(--ease-standard),
    box-shadow 0.3s var(--ease-standard);
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

/* Feedback Pulse Animations on Card */
.question-card.feedback-correct {
  animation: pulse-success 0.5s var(--ease-bounce);
  border-color: rgba(76, 201, 240, 0.5); /* Blue-ish success tint */
  box-shadow: 0 0 30px rgba(76, 201, 240, 0.2);
}

.question-card.feedback-incorrect {
  animation: shake-error 0.4s var(--ease-bounce);
  border-color: rgba(255, 107, 107, 0.5);
  box-shadow: 0 0 30px rgba(255, 107, 107, 0.2);
}

@keyframes pulse-success {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.02);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes shake-error {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}

/* Primary Button Shimmer */
.primary-btn {
  position: relative;
  overflow: hidden;
}

/* Only shimmer when active/enabled */
.primary-btn:not(:disabled):not(.disabled)::after {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transform: skewX(-20deg);
  animation: sheen 3s infinite;
}

.primary-btn:disabled,
.primary-btn.disabled {
  /* Ensure no shimmer on disabled */
  cursor: not-allowed;
  opacity: 0.6;
}

@keyframes sheen {
  0%,
  60% {
    left: -100%;
  }
  100% {
    left: 200%;
  }
}

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

/* Question Header */
.question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.q-badge {
  background: var(--badge-bg);
  color: var(--badge-text);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: var(--font-size-caption);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: 1px solid var(--badge-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  flex-shrink: 1;
}

.q-number {
  color: var(--text-tertiary);
  font-size: var(--font-size-body);
}

/* Marked Question */
.question-card.marked {
  border-color: var(--warning-default);
  box-shadow:
    var(--shadow-lg),
    0 0 20px var(--warning-bg);
  animation: pulseGlow 3s infinite ease-in-out;
}

@keyframes pulseGlow {
  0%,
  100% {
    box-shadow:
      var(--shadow-lg),
      0 0 12px var(--warning-bg);
  }
  50% {
    box-shadow:
      var(--shadow-lg),
      0 0 24px rgba(255, 185, 56, 0.25);
  }
}

/* Question Body */
.question-body {
  margin-bottom: 28px;
}

.question-text {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text-primary);
  animation: slideIn var(--duration-slower) var(--ease-decelerate);
}

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

.question-image-container {
  margin-top: 20px;
}

.question-image-container img {
  max-width: 100%;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-md);
  cursor: zoom-in;
  transition: transform var(--duration-normal) var(--ease-standard);
}

.question-image-container img:hover {
  transform: scale(1.02);
}

/* ==================== OPTIONS ==================== */
.options-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 28px;
}

.option-card {
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 1rem;
  color: var(--text-primary);
  font-family: inherit;
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-standard);
  position: relative;
  overflow: hidden;
}

/* Reveal Effect */
.option-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle 120px at var(--mouse-x, 50%) var(--mouse-y, 50%),
    rgba(255, 255, 255, 0.08),
    transparent 40%
  );
  opacity: 0;
  transition: opacity var(--duration-fast);
  pointer-events: none;
}

.option-card:hover:not(.disabled)::before {
  opacity: 1;
}

.option-card:hover:not(.disabled) {
  background: var(--card-bg-hover);
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.option-card.selected {
  background: var(--accent-tertiary);
  border-color: var(--accent-default);
  box-shadow:
    inset 0 0 0 1px var(--accent-default),
    0 0 15px var(--accent-glow);
  animation: option-pulse 2s infinite;
  z-index: 2; /* Ensure glow shows over siblings */
}

@keyframes option-pulse {
  0% {
    box-shadow:
      inset 0 0 0 1px var(--accent-default),
      0 0 10px var(--accent-glow);
  }
  50% {
    box-shadow:
      inset 0 0 0 1px var(--accent-default),
      0 0 20px var(--accent-glow);
  }
  100% {
    box-shadow:
      inset 0 0 0 1px var(--accent-default),
      0 0 10px var(--accent-glow);
  }
}

.option-card:active:not(.disabled) {
  transform: scale(0.99);
  background: var(--card-bg-pressed);
}

/* Option Marker */
.option-marker,
.option-letter {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card-bg-hover);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 18px;
  flex-shrink: 0;
  transition: all var(--duration-normal) var(--ease-standard);
}

.option-card.selected .option-marker,
.option-card.selected .option-letter {
  background: var(--accent-default);
  color: var(--text-on-accent);
  box-shadow: 0 2px 8px var(--accent-glow);
}

.option-card.correct .option-marker,
.option-card.correct .option-letter {
  background: var(--success-default);
  color: var(--text-on-accent);
}

.option-card.incorrect .option-marker,
.option-card.incorrect .option-letter {
  background: var(--error-default);
  color: #fff;
}

/* Feedback States */
.option-card.correct {
  background: var(--success-bg);
  border-color: var(--success-default);
}

.option-card.incorrect {
  background: var(--error-bg);
  border-color: var(--error-default);
}

.option-card.disabled {
  cursor: default;
  pointer-events: none;
}

/* ==================== FEEDBACK SECTION ==================== */
.feedback-section {
  margin-bottom: 24px;
  padding: 20px;
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border-left: 4px solid var(--accent-default);
  animation: slideIn var(--duration-slow) var(--ease-decelerate);
}

.feedback-section.correct {
  border-left-color: var(--success-default);
  background: var(--success-bg);
}

.feedback-section.incorrect {
  border-left-color: var(--error-default);
  background: var(--error-bg);
}

.feedback-section.info {
  border-left-color: var(--accent-default);
  background: var(--info-bg);
}

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

.feedback-icon {
  font-size: 1.3em;
}

.feedback-title {
  font-weight: 600;
  font-size: var(--font-size-subtitle);
}

.feedback-title.feedback-success {
  color: var(--success-default);
}

.feedback-title.feedback-error {
  color: var(--error-default);
}

.explanation-box {
  line-height: 1.7;
  color: var(--text-secondary);
}

/* ==================== ACTION BAR ==================== */
.action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

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

/* ==================== RIGHT SIDEBAR ==================== */
.right-sidebar {
  position: fixed;
  right: 0;
  top: 0;
  height: 100vh;
  width: var(--right-sidebar-width);
  background: var(--acrylic-bg);
  backdrop-filter: blur(var(--acrylic-blur)) saturate(120%);
  -webkit-backdrop-filter: blur(var(--acrylic-blur)) saturate(120%);
  border-left: 1px solid var(--border-subtle);
  transform: translateX(100%);
  transition: transform var(--duration-slow) var(--ease-decelerate);
  z-index: 200;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
}

.right-sidebar.open {
  transform: translateX(0);
}

.right-sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: var(--header-height);
}

.right-sidebar-header h3 {
  font-size: var(--font-size-subtitle);
  font-weight: 600;
  margin: 0;
}

.sidebar-input {
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-bottom: 2px solid var(--border-default);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  width: 64px;
  text-align: center;
  font-family: inherit;
  font-size: var(--font-size-body);
  transition: all var(--duration-fast);
}

select.sidebar-input {
  text-align: left;
  cursor: pointer;
  background-color: var(--bg-solid-base);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
}

select.sidebar-input option {
  background-color: var(--bg-solid-base);
  color: var(--text-primary);
}

.sidebar-input:hover {
  background: var(--card-bg-hover);
  border-bottom-color: var(--border-strong);
}

.sidebar-input:focus {
  border-bottom-color: var(--accent-default);
  background: var(--card-bg-hover);
  outline: none;
}

/* ==================== QUESTION GRID ==================== */
.grid-container {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 6px;
  overflow-y: auto;
  padding-bottom: 80px;
}

.grid-item {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card-bg);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: var(--font-size-caption);
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-standard);
}

.grid-item:hover {
  background: var(--card-bg-hover);
  color: var(--text-primary);
  transform: scale(1.08);
  box-shadow: var(--shadow-sm);
}

.grid-item.current {
  background: var(--accent-default);
  color: var(--text-on-accent);
  box-shadow: 0 0 12px var(--accent-glow);
  font-weight: 600;
}

.grid-item.correct {
  background: var(--success-default);
  color: var(--text-on-accent);
}

.grid-item.incorrect {
  background: var(--error-default);
  color: #fff;
}

.grid-item.marked {
  border: 2px solid var(--warning-default);
  box-shadow: 0 0 8px var(--warning-bg);
}

/* ==================== MODALS ==================== */
/* Sidebar Backdrop (Mobile Overlay) */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1350; /* Above header (1300), below sidebar (1400) */
  transition: opacity var(--duration-normal) var(--ease-standard);
  display: block;
}

.sidebar-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn var(--duration-normal) var(--ease-standard);
}

.modal.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-content {
  background: var(--modal-bg);
  border: 1px solid var(--border-subtle);
  border-top: 1px solid var(--stroke-card-top);
  box-shadow: var(--shadow-flyout);
  backdrop-filter: blur(var(--acrylic-blur));
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalSlideIn var(--duration-slow) var(--ease-decelerate);
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: var(--font-size-subtitle);
  font-weight: 600;
  margin: 0;
}

#close-settings-btn {
  width: 40px;
  height: 40px;
  font-size: 1.5rem;
}

/* Settings Modal */
.settings-content {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.setting-group label {
  display: block;
  color: var(--text-secondary);
  font-size: var(--font-size-caption);
  text-transform: uppercase;
  margin-bottom: 10px;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.btn-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Lightbox Modal */
#lightbox-modal {
  cursor: zoom-out;
}

#lightbox-modal .modal-content {
  background: transparent;
  border: none;
  box-shadow: none;
  max-width: 95vw;
  backdrop-filter: none;
}

#lightbox-image {
  max-width: 100%;
  max-height: 90vh;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
}

/* ==================== TOAST ==================== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--acrylic-bg-elevated);
  color: var(--text-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-flyout);
  backdrop-filter: blur(var(--acrylic-blur));
  border: 1px solid var(--border-subtle);
  z-index: 3000;
  animation: toastSlideUp var(--duration-slow) var(--ease-decelerate);
}

@keyframes toastSlideUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes toastSlideDown {
  from {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
}

/* ==================== EMPTY STATE ==================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 24px;
  max-width: 400px;
  margin: 0 auto;
}

.empty-icon {
  font-size: 64px;
  margin-bottom: 20px;
  animation: bounce 2s infinite;
}

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

.empty-state h3 {
  font-size: var(--font-size-title);
  font-weight: 600;
  margin-bottom: 8px;
}

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

/* ==================== LOADING & ERROR ==================== */
.loading-spinner {
  text-align: center;
  color: var(--text-tertiary);
  padding: 40px;
}

.loading-spinner::before {
  content: "";
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 2px solid var(--accent-default);
  border-top-color: transparent;
  border-radius: var(--radius-circular);
  animation: spin 1s linear infinite;
  margin-right: 12px;
  vertical-align: middle;
}

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

.error-msg {
  color: var(--error-default);
  text-align: center;
  padding: 24px;
  background: var(--error-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--error-default);
}

.error-msg small {
  display: block;
  margin-top: 8px;
  color: var(--text-tertiary);
}

/* ==================== KEYBOARD SHORTCUTS ==================== */
.shortcuts-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.shortcut-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--font-size-body);
  color: var(--text-secondary);
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 4px 10px;
  background: var(--card-bg);
  border: 1px solid var(--border-default);
  border-bottom: 2px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: var(--font-size-caption);
  font-weight: 600;
  color: var(--text-primary);
}

/* ==================== UTILITIES ==================== */
.hidden {
  display: none !important;
}

.margin-top-sm {
  margin-top: 12px;
}

.margin-left-sm {
  margin-left: 8px;
}

.mobile-only {
  display: none !important;
}

/* ==================== KATEX OVERRIDES ==================== */
.katex {
  font-size: 1.1em;
}

/* ==================== ACCESSIBILITY ==================== */
button:focus-visible,
.option-card:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent-default);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==================== MOBILE RESPONSIVE ==================== */
/* ==================== MOBILE RESPONSIVE ==================== */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 280px; /* Standard width for drawer */
    --header-height: 56px;
  }

    /* Fix for address bar hiding content */
    .app-container {
      flex-direction: column;
      height: 100vh;
      height: 100dvh;
      overflow: hidden;
      position: relative;
    }

          /* Mobile Header */

          .mobile-app-header {

            display: flex !important;

            align-items: center;

            height: var(--header-height);

            box-sizing: content-box;

            padding: env(safe-area-inset-top, 0px) 20px 0 20px;

            background: var(--acrylic-bg-elevated);

            backdrop-filter: blur(var(--acrylic-blur));

            border-bottom: 1px solid var(--border-subtle);

            position: fixed;

            top: 0;

            left: 0;

            right: 0;

            z-index: 1300;

            box-shadow: var(--shadow-sm);

            flex-shrink: 0;

            transition: transform var(--duration-normal) var(--ease-standard);

          }

          .mobile-app-header.header-hidden {

            transform: translateY(-100%);

          }

          .mobile-app-header .logo {

            height: 100%;

            display: flex;

            align-items: center;

            width: 100%;

          }

          /* Sidebar - Vertical Drawer */

          .sidebar {

            position: fixed;

            top: 0;

            left: 0;

            bottom: 0;

            width: var(--sidebar-width);

            height: 100%;

            transform: translateX(-100%);

            transition: transform var(--duration-normal) var(--ease-standard);

            z-index: 1400;

            flex-direction: column;

            border-right: 1px solid var(--border-subtle);

            box-shadow: var(--shadow-xl);

            padding: 0;

            overflow-x: hidden;

            background: var(--bg-solid-base);

          }

          .sidebar.open {

            transform: translateX(0);

          }

          .sidebar.collapsed {

            width: var(--sidebar-width);

          }

            /* Main Content */

                  .main-content {
                    padding: 16px;
                    padding-top: 16px; /* Reset to standard */
                    padding-bottom: calc(80px + env(safe-area-inset-bottom));
                    margin-left: 0 !important;
                    overflow-y: auto;
                    flex: 1;
                    -webkit-overflow-scrolling: touch;
                  }
            /* Swipe Animations */

            .swipe-left {

              animation: swipeLeft 0.3s forwards;

            }

            .swipe-right {

              animation: swipeRight 0.3s forwards;

            }

                @keyframes swipeLeft {

                  to { transform: translateX(-30px); opacity: 0.4; }

                }

                

                @keyframes swipeRight {

                  to { transform: translateX(30px); opacity: 0.4; }

                }

                                          /* Restore Top Bar (Stats) on Mobile */

                                          .top-bar {
                                            display: flex !important;
                                            flex-wrap: wrap;
                                            gap: 12px;
                                            padding: 12px;
                                            margin-top: 0px;
                                            margin-bottom: 16px;
                                            justify-content: center;
                                            background: var(--card-bg);
                                            border-radius: var(--radius-lg);
                                            position: relative;
                                            z-index: 10;
                                          }

  /* Right Controls: Move to top row, full width */
  .top-bar > .controls {
    order: -1;
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-shrink: 1 !important;
  }

  /* Stats Rows */
  .top-bar > div:not(.controls) {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Nav Links - Restore Vertical */
  .nav-links {
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px;
    gap: 2px;
  }

  /* Show Button Labels on Mobile */
  .btn-label {
    display: inline;
    font-size: 0.75rem;
  }

  .controls {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    width: 100%;
    justify-content: flex-start;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .controls::-webkit-scrollbar {
    display: none;
  }

  #grid-btn {
    font-size: var(--font-size-body);
    gap: 8px;
    padding: 6px 12px;
  }

  #grid-btn i {
    font-size: inherit;
  }

  .nav-item {
    white-space: nowrap;
    width: 100%;
    padding: 10px 12px;
  }

  .nav-item::before {
    display: block; /* Restore active indicator */
  }

  /* Utilities */
  .mobile-only {
    display: block !important;
  }

  .question-card {
    padding: 20px;
    border-radius: var(--radius-lg);
  }

  /* Right Sidebar (Grid) */
  .right-sidebar {
    width: 100%;
    top: auto;
    bottom: 0;
    transform: translateY(100%);
    border-left: none;
    border-top: 1px solid var(--border-subtle);
    z-index: 2000;
    max-height: 70vh;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .right-sidebar.open {
    transform: translateY(0);
  }

  .action-bar {
    flex-direction: column;
    gap: 10px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
  }

  .center-actions {
    grid-column: 1 / -1;
    grid-row: 1;
    justify-content: center;
    width: 100%;
  }

  #prev-btn, #next-btn {
    grid-row: 2;
    min-height: 48px;
    font-size: 1rem;
    font-weight: 600;
  }

  #prev-btn {
    grid-column: 1;
  }

  #next-btn {
    grid-column: 2;
  }
}

/* ==================== TABLET ==================== */
@media (max-width: 1024px) {
  .top-bar {
    flex-wrap: wrap !important;
  }
}

/* ==================== SMALL MOBILE ==================== */
@media (max-width: 480px) {
  .main-content {
    padding: 12px;
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
  }

  .question-card {
    padding: 16px;
  }

  .option-card {
    padding: 12px 14px;
    gap: 12px;
  }

  .option-marker,
  .option-letter {
    width: 32px;
    height: 32px;
    font-size: 0.833rem;
  }

  .controls {
    gap: 6px;
  }

  .secondary-btn,
  .nav-btn {
    padding: 6px 10px;
    font-size: 0.833rem;
  }
}
