/* ==========================================================================
   80/20 Design System & Styles (Pass 2)
   Lighter, calmer reading experience with responsive mobile ergonomics
   ========================================================================== */

/* 1. Design Tokens & Theme Variables */
:root {
  /* Color Palette - Light Mode (Default, Plain White Background) */
  --bg-canvas: #ffffff;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-hover: #f1f5f9;

  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;
  --border-accent: #bfdbfe;

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-inverted: #ffffff;

  /* Primary Accent: Deep Refined Indigo */
  --accent-primary: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-active: #1e40af;
  --accent-subtle: #eff6ff;
  --accent-text: #1d4ed8;

  /* Semantic Feedback */
  --success-primary: #059669;
  --success-hover: #047857;
  --success-subtle: #ecfdf5;
  --success-text: #065f46;
  --success-border: #a7f3d0;

  --warning-primary: #d97706;
  --warning-hover: #b45309;
  --warning-subtle: #fffbeb;
  --warning-text: #92400e;
  --warning-border: #fde68a;

  --danger-primary: #dc2626;
  --danger-hover: #b91c1c;
  --danger-subtle: #fef2f2;
  --danger-text: #991b1b;

  --ring-focus: rgba(37, 99, 235, 0.45);

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", Menlo, Consolas, "Liberation Mono", Courier, monospace;

  /* Layout Spacing */
  --max-content-width: 960px;
  --max-reading-width: 680px;
  --header-height: 56px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 9999px;

  /* Transitions */
  --transition-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Tokens (Opt-in toggle in Settings only) */
html.dark, html.theme-dark, body.theme-dark {
  --bg-canvas: #0f172a;
  --bg-surface: #0f172a;
  --bg-surface-elevated: #1e293b;
  --bg-subtle: #1e293b;
  --bg-hover: #334155;

  --border-subtle: #273549;
  --border-strong: #3b4d66;
  --border-accent: #1e3a8a;

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-inverted: #0f172a;

  --accent-primary: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-active: #93c5fd;
  --accent-subtle: rgba(59, 130, 246, 0.15);
  --accent-text: #60a5fa;

  --success-primary: #10b981;
  --success-hover: #34d399;
  --success-subtle: rgba(16, 185, 129, 0.15);
  --success-text: #6ee7b7;
  --success-border: rgba(16, 185, 129, 0.3);

  --warning-primary: #f59e0b;
  --warning-hover: #fbbf24;
  --warning-subtle: rgba(245, 158, 11, 0.15);
  --warning-text: #fcd34d;
  --warning-border: rgba(245, 158, 11, 0.3);

  --danger-primary: #ef4444;
  --danger-hover: #f87171;
  --danger-subtle: rgba(239, 68, 68, 0.15);
  --danger-text: #fca5a5;

  --ring-focus: rgba(59, 130, 246, 0.55);
}

/* 2. Global Resets & Base Styles */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-sans);
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  overflow-x: hidden;
}

a {
  color: var(--accent-text);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  text-decoration: underline;
}

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

/* Focus Visibility & Accessibility */
:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* 3. Header & Navigation (Part C3: 360px safe, bottom nav on mobile) */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-height);
  background-color: var(--bg-canvas);
  border-bottom: 1px solid var(--border-subtle);
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.header-inner {
  max-width: var(--max-content-width);
  margin: 0 auto;
  height: 100%;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand-link {
  display: flex;
  align-items: center;
  text-decoration: none !important;
  color: var(--text-primary);
  flex-shrink: 0;
}

.brand-mark {
  font-weight: 800;
  font-size: 1.1875rem;
  letter-spacing: -0.04em;
  color: var(--accent-primary);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--accent-subtle);
}

/* Desktop Search Form in Top Bar */
.header-search-wrap {
  flex: 1;
  max-width: 240px;
  position: relative;
}

.search-form {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.search-form-icon {
  position: absolute;
  inset-inline-start: 0.625rem;
  color: var(--text-muted);
  pointer-events: none;
  width: 16px;
  height: 16px;
}

.global-search-input {
  width: 100%;
  height: 36px;
  padding: 0.25rem 0.75rem;
  padding-inline-start: 2rem;
  font-size: 0.875rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.global-search-input:focus {
  background: var(--bg-surface-elevated);
  border-color: var(--accent-primary);
  outline: none;
}

/* Main Navigation */
.app-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.4375rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none !important;
  transition: background-color var(--transition-fast), color var(--transition-fast);
  min-height: 44px; /* Accessible tap target */
}

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

.nav-link.active {
  background-color: var(--accent-subtle);
  color: var(--accent-primary);
  font-weight: 600;
}

.badge-review-count {
  font-size: 0.75rem;
  font-weight: 700;
  background-color: var(--warning-primary);
  color: #ffffff;
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-pill);
  min-width: 1.125rem;
  text-align: center;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.mobile-search-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
}

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

.streak-pill {
  display: flex;
  align-items: center;
  gap: 0.3125rem;
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-pill);
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  height: 34px;
  white-space: nowrap;
}

.streak-pill.active-streak {
  background-color: var(--warning-subtle);
  border-color: var(--warning-border);
  color: var(--warning-text);
}

.streak-number {
  font-weight: 700;
}

.streak-label {
  font-size: 0.75rem;
  font-weight: 500;
}

/* Mobile search expandable drawer */
.mobile-search-bar {
  padding: 0.5rem 1rem 0.75rem;
  background: var(--bg-canvas);
  border-bottom: 1px solid var(--border-subtle);
}

.mobile-search-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mobile-search-input {
  flex: 1;
  height: 44px;
  padding: 0.5rem 0.875rem;
  font-size: 1rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.mobile-search-close {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--text-muted);
}

/* Responsive Top Bar & Mobile Bottom Nav (C3) */
@media (max-width: 640px) {
  .header-search-wrap {
    display: none;
  }

  .mobile-search-btn {
    display: flex;
  }

  .streak-label {
    display: none;
  }

  /* Fixed bottom bar for the 5 destinations */
  .app-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    z-index: 50;
    background-color: var(--bg-canvas);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0;
  }

  .nav-link {
    flex: 1 1 0;
    min-width: 0;
    flex-direction: column;
    gap: 2px;
    padding: 0.25rem 0.125rem;
    font-size: 0.75rem;
    min-height: 44px;
    justify-content: center;
    text-align: center;
  }

  .nav-link span {
    font-size: 11px !important;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .nav-link .svg-icon {
    width: 18px;
    height: 18px;
  }

  /* Main container bottom padding to avoid bottom bar overlap */
  .app-main {
    padding-bottom: 72px !important;
  }

  /* On question reading page, hide bottom nav bar so rating bar owns the bottom */
  body.route-question .app-nav {
    display: none !important;
  }

  body.route-question .app-main {
    padding-bottom: 84px !important;
  }
}

/* 4. Main App Container */
.app-main {
  flex: 1;
  max-width: var(--max-content-width);
  width: 100%;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 3.5rem;
}

@media (max-width: 640px) {
  .app-main {
    padding: 1.25rem 1rem 3.5rem;
  }
}

.view-container {
  width: 100%;
}

/* 5. Typography Standards */
h1, .h1 {
  font-size: 1.875rem;
  line-height: 1.28;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  margin-bottom: 0.625rem;
  overflow-wrap: break-word;
}

h2, .h2 {
  font-size: 1.25rem;
  line-height: 1.35;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.625rem;
  overflow-wrap: break-word;
}

h3, .h3 {
  font-size: 1.0625rem;
  line-height: 1.4;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  overflow-wrap: break-word;
}

p {
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 1rem;
  overflow-wrap: break-word;
}

p:last-child {
  margin-bottom: 0;
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background-color: var(--bg-subtle);
  color: var(--text-primary);
  padding: 0.15em 0.35em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

pre {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.875rem 1rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.5;
  margin: 0.75rem 0;
  color: var(--text-primary);
}

pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

strong {
  font-weight: 600;
  color: var(--text-primary);
}

kbd {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  display: inline-block;
  line-height: 1;
}

/* 6. Buttons & Interactive Elements (44px min tap target) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5625rem 1.125rem;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none !important;
  border: 1px solid transparent;
  min-height: 44px; /* Accessible tap target */
  user-select: none;
}

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

.btn-primary {
  background-color: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
}

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

.btn-secondary {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

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

.btn-ghost {
  background-color: transparent;
  color: var(--text-secondary);
}

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

.btn-success {
  background-color: var(--success-primary);
  color: #ffffff;
  border-color: var(--success-primary);
}

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

.btn-warning {
  background-color: var(--warning-primary);
  color: #ffffff;
  border-color: var(--warning-primary);
}

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

.btn-danger {
  background-color: var(--danger-primary);
  color: #ffffff;
  border-color: var(--danger-primary);
}

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

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  min-height: 48px;
}

.btn-sm {
  padding: 0.3125rem 0.625rem;
  font-size: 0.875rem;
  min-height: 44px;
}

/* 7. Lighter Cards & Containers (C3: Fewer boxes, thin dividers) */
.card {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.5rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3125rem;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.2;
}

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

.badge-subtle {
  background-color: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.badge-success {
  background-color: var(--success-subtle);
  color: var(--success-text);
  border: 1px solid var(--success-border);
}

.badge-warning {
  background-color: var(--warning-subtle);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
}

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

.badge-neutral {
  background-color: var(--bg-subtle);
  color: var(--text-muted);
}

/* Progress Bars */
.progress-bar-container {
  width: 100%;
  height: 6px;
  background-color: var(--bg-subtle);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background-color: var(--accent-primary);
  border-radius: var(--radius-pill);
  transition: width var(--transition-fast);
}

.progress-fill.fill-success {
  background-color: var(--success-primary);
}

/* 8. Specific Screens */

/* --- Onboarding View (Part B3) --- */
.onboarding-step-indicator {
  display: inline-block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--accent-text);
  background-color: var(--accent-subtle);
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-pill);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.areas-selection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 640px) {
  .areas-selection-grid {
    grid-template-columns: 1fr !important;
  }
}

.area-choice-card {
  min-height: 64px;
}

.area-choice-card .field-choice-name {
  font-size: 1.0625rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.onboarding-area-group {
  margin-bottom: 2rem;
}

.onboarding-area-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.875rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.onboarding-area-header h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.area-bulk-actions {
  display: inline-flex;
  gap: 0.375rem;
  align-items: center;
}

.onboarding-step-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 2.5rem 0 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.topic-actions-bar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.onboarding-hero {
  text-align: center;
  max-width: 600px;
  margin: 1.5rem auto 2.5rem;
}

.onboarding-hero h1 {
  font-size: 2rem;
  letter-spacing: -0.03em;
  margin-bottom: 0.75rem;
}

.onboarding-hero p {
  font-size: 1.0625rem;
  color: var(--text-secondary);
}

.onboarding-section {
  margin-bottom: 2rem;
}

.onboarding-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.875rem;
}

.onboarding-filter-bar {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.filter-pills {
  display: flex;
  gap: 0.375rem;
  flex-wrap: wrap;
}

.filter-pill {
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-pill);
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.filter-pill:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.filter-pill.active {
  background-color: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
}

.onboarding-search-box {
  width: 100%;
  max-width: 240px;
}

.onboarding-search-box input {
  width: 100%;
  height: 44px;
  padding: 0.375rem 0.75rem;
  font-size: 0.9375rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
}

.onboarding-filter-actions {
  display: flex;
  gap: 0.625rem;
  align-items: center;
  flex-wrap: wrap;
}

.sort-control-group {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.sort-toggle-btn {
  height: 44px;
  min-height: 44px;
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  transition: all var(--transition-fast);
  user-select: none;
}

.sort-toggle-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

.sort-toggle-btn.active {
  background-color: var(--accent-subtle);
  color: var(--accent-primary);
  border-color: var(--accent-primary);
  font-weight: 600;
}

.sort-btn-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.sort-select-control {
  height: 44px;
  min-height: 44px;
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface-elevated);
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.sort-select-control:focus {
  border-color: var(--accent-primary);
  outline: none;
}

@media (max-width: 640px) {
  .onboarding-filter-actions {
    width: 100%;
    justify-content: space-between;
  }
  .onboarding-search-box {
    flex: 1 1 140px;
    max-width: none;
  }
  .sort-control-group {
    flex-shrink: 0;
  }
}

.fields-selection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 0.75rem;
}

@media (max-width: 640px) {
  .fields-selection-grid {
    grid-template-columns: 1fr !important; /* C4: single column on mobile */
  }
}

.field-choice-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface-elevated);
  cursor: pointer;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
  user-select: none;
  min-height: 52px;
}

.field-choice-card:hover:not(.disabled) {
  border-color: var(--accent-primary);
}

.field-choice-card.selected {
  border-color: var(--accent-primary);
  background-color: var(--accent-subtle);
}

.field-choice-card.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.field-checkbox-custom {
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 0.125rem;
  transition: all var(--transition-fast);
}

.field-choice-card.selected .field-checkbox-custom {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.field-choice-card.selected .field-checkbox-custom::after {
  content: "";
  width: 5px;
  height: 9px;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-bottom: 2px;
}

.field-choice-info {
  flex: 1;
}

.field-choice-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.125rem;
}

.field-choice-meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* More options details (Part B3) */
.more-options-details {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.875rem 1.125rem;
  background: var(--bg-subtle);
  margin-bottom: 2rem;
}

.more-options-summary {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
  min-height: 44px;
}

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

.more-options-summary-meta {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
}

.more-options-body {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

.more-options-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.more-options-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.segmented-control {
  display: flex;
  background-color: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.1875rem;
  gap: 0.25rem;
}

.segmented-btn {
  flex: 1;
  text-align: center;
  padding: 0.5rem 0.75rem;
  border-radius: calc(var(--radius-sm) - 2px);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  min-height: 44px;
}

.segmented-btn:hover {
  color: var(--text-primary);
}

.segmented-btn.active {
  background-color: var(--accent-primary);
  color: #ffffff;
  font-weight: 600;
}

/* --- Dashboard View (Part B2: No Locked wording) --- */
.dashboard-grid {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.today-banner {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.75rem;
}

.today-banner-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.today-date {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent-text);
  margin-bottom: 0.25rem;
}

.today-headline {
  font-size: 1.625rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.today-progress-bar {
  margin: 1rem 0 1.25rem;
}

.today-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.my-fields-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.fields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1rem;
}

.field-dashboard-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.field-card-header {
  margin-bottom: 0.875rem;
}

.field-card-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.1875rem;
}

.field-card-meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.field-card-progress {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  margin-bottom: 1rem;
}

.progress-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.field-card-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

/* --- Field Detail Page --- */
.page-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.topics-list {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.topic-row-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface-elevated);
  transition: border-color var(--transition-fast);
  text-decoration: none !important;
  color: inherit;
  min-height: 48px;
}

.topic-row-card:hover {
  border-color: var(--accent-primary);
}

.topic-main-info {
  flex: 1;
}

.topic-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.125rem;
}

.topic-index-number {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  width: 1.375rem;
}

.topic-row-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.topic-covers-summary {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-inline-start: 1.875rem;
  max-width: 580px;
}

.topic-progress-pills {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* --- Topic Detail Page & Reading Mode Accordion (Part A1) --- */
.topic-tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 1.25rem;
}

.topic-tab-btn {
  padding: 0.625rem 1.125rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--transition-fast);
  min-height: 44px;
}

.topic-tab-btn:hover {
  color: var(--text-primary);
}

.topic-tab-btn.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

.topic-expand-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
}

.questions-accordion-list {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.topic-question-item {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-surface-elevated);
  overflow: hidden;
  transition: border-color var(--transition-fast);
}

.topic-question-item.expanded {
  border-color: var(--border-strong);
}

.topic-question-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 1rem;
  cursor: pointer;
  user-select: none;
  min-height: 48px;
}

.topic-question-header:hover {
  background: var(--bg-subtle);
}

.topic-question-header-left {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  flex: 1;
}

.topic-question-title-text {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.45;
}

.topic-chevron-icon {
  color: var(--text-muted);
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.topic-question-body {
  padding: 1.25rem 1rem;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-canvas);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.topic-q-section {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.topic-question-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding-top: 0.875rem;
  border-top: 1px solid var(--border-subtle);
}

/* Question Rows (used in lists & searches) */
.questions-list {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.question-row-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface-elevated);
  text-decoration: none !important;
  color: inherit;
  transition: border-color var(--transition-fast);
  min-height: 48px;
}

.question-row-card:hover {
  border-color: var(--accent-primary);
}

.question-row-left {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  flex: 1;
}

.question-status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-pill);
  background-color: var(--border-strong);
  margin-top: 0.4375rem;
  flex-shrink: 0;
}

.question-status-dot.dot-done {
  background-color: var(--success-primary);
}

.question-status-dot.dot-review {
  background-color: var(--warning-primary);
}

.question-text-snippet {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.45;
}

/* --- Question View (Part C1: Calm Reading Page) --- */
.question-viewport {
  max-width: var(--max-reading-width);
  margin: 0 auto;
}

.question-view-card {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 2rem 1.75rem;
  margin-bottom: 1.25rem;
  touch-action: pan-y;
}

@media (max-width: 640px) {
  .question-view-card {
    padding: 1.5rem 1.125rem;
  }
}

.question-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.question-field-topic {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}

.question-field-topic a {
  color: inherit;
}

.question-field-topic a:hover {
  color: var(--text-primary);
}

.question-headline {
  font-size: 1.5rem;
  line-height: 1.4;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 1.75rem;
}

@media (max-width: 640px) {
  .question-headline {
    font-size: 1.25rem;
  }
}

.reveal-trigger-area {
  padding: 2.25rem 1rem;
  text-align: center;
  background-color: var(--bg-subtle);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-strong);
}

.reveal-hint-text {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.625rem;
}

/* Immediate Reveal (Transition <= 150ms per C1) */
.revealed-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  opacity: 1;
}

.answer-section, .example-section, .source-section {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

/* Plain section labels per C1 */
.section-label {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Larger body text, line length ~60-70ch, generous line height per C1 */
.answer-body {
  font-size: 1.125rem; /* ~18px desktop */
  line-height: 1.75;
  max-width: 68ch;
  color: var(--text-primary);
}

@media (max-width: 640px) {
  .answer-body {
    font-size: 1.0625rem; /* ~17px mobile */
    line-height: 1.7;
  }
}

.example-box {
  background-color: var(--bg-subtle);
  border-inline-start: 3px solid var(--accent-primary);
  padding: 0.875rem 1.125rem;
  border-start-start-radius: 0;
  border-end-start-radius: 0;
  border-start-end-radius: var(--radius-sm);
  border-end-end-radius: var(--radius-sm);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text-secondary);
  max-width: 68ch;
}

.source-link-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.source-link {
  color: var(--accent-text);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.9375rem;
}

/* Rating bar (Large buttons, fixed to bottom on mobile per C1) */
.question-rating-bar {
  margin-top: 1.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 0.875rem;
  flex-wrap: wrap;
}

.rating-btn {
  flex: 1;
  min-width: 130px;
  min-height: 48px; /* Large, easy to tap */
  font-size: 1rem;
}

@media (max-width: 640px) {
  .question-rating-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--bg-canvas);
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-subtle);
    z-index: 50;
    margin-top: 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  }
}

.navigation-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

/* --- Search View (Part A2) --- */
.search-meta-matches {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
}

.search-meta-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.search-chips {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.search-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  font-size: 0.875rem;
  color: var(--text-primary);
  text-decoration: none !important;
  min-height: 44px;
}

.search-chip:hover {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
}

.search-questions-results {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.search-field-group {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.search-field-heading {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--border-subtle);
}

.search-field-heading a {
  color: inherit;
  text-decoration: none;
}

.search-field-heading a:hover {
  color: var(--accent-primary);
}

mark.search-match {
  background-color: #fef08a;
  color: #854d0e;
  padding: 0.1em 0.25em;
  border-radius: 2px;
  font-weight: 600;
}

html.dark mark.search-match, html.theme-dark mark.search-match {
  background-color: #854d0e;
  color: #fef08a;
}

/* --- Celebration Screen --- */
.celebration-card {
  text-align: center;
  padding: 2.5rem 1.5rem;
}

.celebration-icon-box {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-pill);
  background-color: var(--success-subtle);
  color: var(--success-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
}

.celebration-title {
  font-size: 1.625rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.celebration-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  margin: 1.75rem 0;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.stat-number {
  font-size: 1.875rem;
  font-weight: 800;
  color: var(--accent-primary);
}

.stat-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* --- Review & Saved Screen --- */
.review-group {
  margin-bottom: 1.75rem;
}

.review-group-title {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  padding-bottom: 0.375rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* --- Settings Screen --- */
.settings-section {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.settings-section-header {
  margin-bottom: 1rem;
}

.settings-section-title {
  font-size: 1.0625rem;
  font-weight: 600;
  margin-bottom: 0.1875rem;
}

.settings-section-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.settings-actions-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Toggle Switch */
.switch-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
  min-height: 44px;
}

.toggle-track {
  width: 44px;
  height: 24px;
  background-color: var(--bg-hover);
  border-radius: var(--radius-pill);
  position: relative;
  transition: background-color var(--transition-fast);
}

.toggle-track.active {
  background-color: var(--accent-primary);
}

.toggle-thumb {
  width: 18px;
  height: 18px;
  border-radius: var(--radius-pill);
  background-color: #ffffff;
  position: absolute;
  top: 3px;
  left: 3px;
  transition: transform var(--transition-fast);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.toggle-track.active .toggle-thumb {
  transform: translateX(20px);
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-card {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  max-width: 440px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.625rem;
  margin-top: 1.5rem;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  inset-inline-end: 2rem;
  z-index: 100;
  background-color: var(--text-primary);
  color: var(--bg-canvas);
  padding: 0.625rem 1.125rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transform: translateY(60px);
  opacity: 0;
  transition: all var(--transition-fast);
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 90vw;
}

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

.btn-undo-toast {
  background-color: var(--accent-primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.625rem;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--transition-fast);
}

.btn-undo-toast:hover {
  background-color: var(--accent-hover);
}

/* --- Field Reading Mode & Browse Styles --- */
.read-sticky-bar {
  position: sticky;
  top: var(--header-height);
  z-index: 40;
  background-color: var(--bg-canvas);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.75rem 0;
  margin-bottom: 1.5rem;
}

.read-sticky-inner {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.read-sticky-row-top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
}

.read-sticky-row-bottom {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
}

.read-sticky-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.read-select-control {
  height: 44px;
  min-height: 44px;
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  max-width: 100%;
}

.read-select-control:focus {
  border-color: var(--accent-primary);
  outline: none;
}

.read-filter-control {
  display: flex;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.125rem;
  gap: 0.125rem;
}

.read-filter-btn {
  padding: 0.375rem 0.625rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: calc(var(--radius-sm) - 2px);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.read-filter-btn:hover {
  color: var(--text-primary);
}

.read-filter-btn.active {
  background-color: var(--accent-primary);
  color: #ffffff;
  font-weight: 600;
}

.read-shown-count {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.read-topic-section {
  margin-bottom: 2.25rem;
  scroll-margin-top: 145px;
}

.read-topic-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.625rem;
  margin-bottom: 0.75rem;
  border-bottom: 2px solid var(--border-subtle);
  flex-wrap: wrap;
}

.read-topic-title-area {
  display: flex;
  align-items: baseline;
  gap: 0.625rem;
  flex-wrap: wrap;
}

.read-topic-title {
  font-size: 1.1875rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0;
}

.read-topic-done-count {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
}

.read-questions-list {
  display: flex;
  flex-direction: column;
}

.read-deep-divider {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0.875rem 0 0.375rem;
  margin-top: 0.625rem;
  border-top: 1px dashed var(--border-subtle);
}

.read-question-row {
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.75rem 0.25rem;
  outline: none;
  transition: background-color var(--transition-fast);
}

.read-question-row:last-child {
  border-bottom: none;
}

.read-question-row.row-focused {
  background-color: var(--accent-subtle);
  border-radius: var(--radius-sm);
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

.read-question-row.row-hidden {
  display: none !important;
}

.read-question-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
  min-height: 44px;
}

.read-question-header-left {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  flex: 1;
  min-width: 0;
}

.read-question-text {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.45;
}

.read-question-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.quiet-done-mark {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--success-primary);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.4rem;
}

.read-question-body-slot {
  margin-top: 0.75rem;
}

.read-question-body-slot.collapsed {
  display: none;
}

.read-chevron-icon {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast);
}

.read-question-row.expanded .read-chevron-icon {
  transform: rotate(180deg);
}

/* Browse Screen List */
.browse-field-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface-elevated);
  text-decoration: none !important;
  color: inherit;
  transition: border-color var(--transition-fast);
  min-height: 48px;
}

.browse-field-item:hover {
  border-color: var(--accent-primary);
}

@media (max-width: 640px) {
  .read-sticky-bar {
    top: var(--header-height);
  }

  .read-sticky-row-top,
  .read-sticky-row-bottom {
    flex-direction: column;
    align-items: stretch;
  }

  .read-sticky-group {
    width: 100%;
    justify-content: space-between;
  }

  .read-select-control {
    width: 100%;
  }

  .read-filter-control {
    width: 100%;
    display: flex;
    justify-content: space-between;
  }

  .read-filter-btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 0.375rem 0.25rem;
    font-size: 0.75rem;
    text-align: center;
  }

  .read-topic-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .read-question-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .read-question-header-right {
    justify-content: flex-start;
    padding-inline-start: 1.25rem;
  }
}

/* Loading State */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  gap: 0.75rem;
  color: var(--text-muted);
}

.spinner {
  width: 2rem;
  height: 2rem;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem 1.25rem;
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-md);
  background-color: var(--bg-subtle);
}

.empty-state-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 0.75rem;
  color: var(--text-muted);
}

/* Mobile font hygiene (C4: text not smaller than 15px on mobile) */
@media (max-width: 640px) {
  p, span, div, a, button, input, label, summary {
    font-size: 15px;
  }
  
  .topic-covers-summary,
  .field-choice-meta,
  .question-field-topic,
  .stat-label,
  .today-date,
  .section-label,
  .badge {
    font-size: 15px !important;
  }

  .answer-body {
    font-size: 17px !important;
  }
  
  .question-headline {
    font-size: 20px !important;
  }
}

/* Inline icons follow the size of the text they sit in, unless a more specific rule sizes them. */
:where(.svg-icon) {
  width: 1.15em;
  height: 1.15em;
  flex-shrink: 0;
  vertical-align: -0.2em;
}


/* ==========================================================================
   Arabic (right-to-left) mode
   ========================================================================== */
.download-apk-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  height: 34px;
  padding: 0 0.625rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  background-color: var(--bg-canvas);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.download-apk-btn:hover {
  background-color: var(--bg-subtle);
  color: var(--brand-primary, #3b82f6);
  border-color: var(--brand-primary, #3b82f6);
  text-decoration: none;
}

.download-apk-btn .svg-icon {
  width: 15px;
  height: 15px;
}

.lang-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 34px;
  padding: 0 0.625rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  background-color: var(--bg-canvas);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

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

.lang-toggle-btn:lang(ar) {
  font-family: "IBM Plex Sans Arabic", var(--font-sans);
}

:root {
  --font-sans-en: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[lang="ar"] {
  --font-sans: "IBM Plex Sans Arabic", -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, Arial, sans-serif;
}

/* English content shown inside the Arabic interface (topics not translated yet) */
:root[lang="ar"] [lang="en"] {
  font-family: var(--font-sans-en);
}

/* Arabic reading text needs a little more line height */
:root[lang="ar"] .question-headline:lang(ar) {
  line-height: 1.6;
}

:root[lang="ar"] .answer-body:lang(ar),
:root[lang="ar"] .example-box:lang(ar) {
  line-height: 1.9;
}

/* Code, commands and formulas stay left to right inside Arabic text */
:root[dir="rtl"] code,
:root[dir="rtl"] kbd {
  direction: ltr;
  unicode-bidi: isolate;
}

:root[dir="rtl"] pre {
  direction: ltr;
  text-align: left;
}

/* Directional arrows point the other way in right-to-left mode */
:root[dir="rtl"] .icon-dir {
  transform: scaleX(-1);
}

:root[dir="rtl"] .toggle-thumb {
  left: auto;
  right: 3px;
}

:root[dir="rtl"] .toggle-track.active .toggle-thumb {
  transform: translateX(-20px);
}

/* Topic study counter (e.g. 3 / 20) stays on one line on narrow screens */
#topic-question-counter {
  white-space: nowrap;
  flex-shrink: 0;
  direction: ltr;
  unicode-bidi: isolate;
}

/* "Next from" switch next to the Next question button (same field / all my fields) */
.next-from-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.next-from-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.segmented-control-sm .segmented-btn {
  padding: 0.25rem 0.625rem;
  font-size: 0.8125rem;
  min-height: 36px;
  white-space: nowrap;
}

/* Small "Archived copy" link under a source (Internet Archive fallback) */
.archive-link {
  display: inline-block;
  margin-top: 0.35rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-decoration: underline;
}
.archive-link:hover {
  color: var(--text-primary);
}

/* Put the archived-copy link on its own line under the source */
.source-link-box:has(.archive-link) {
  flex-wrap: wrap;
}
.source-link-box .archive-link,
.topic-q-section .archive-link {
  display: block;
  flex-basis: 100%;
  width: 100%;
}
