/* ════════════════════════════════════════
   MYZ MATH TUTOR — DESIGN SYSTEM
   Supports: Web, Android WebView, iOS WebView
   All colors, spacing, typography defined here.
   Never hardcode values — use these variables.
════════════════════════════════════════ */

:root {

  /* ── Brand Colors ────────────────────── */
  --primary:         #6C3CE1;
  --primary-hover:   #5a2fcb;
  --primary-light:   #f0ebff;
  --primary-dark:    #4a20b0;

  --secondary:       #1a1a2e;
  --surface:         #16213e;
  --surface-raised:  #1f2b47;
  --border:          #2a3a5c;

  /* ── Text ────────────────────────────── */
  --text:            #f1f1f1;
  --text-primary:    #f1f1f1;
  --text-secondary:  #a0aec0;
  --text-muted:      #8899aa;

  /* ── Status ──────────────────────────── */
  --success:         #28a745;
  --success-light:   #d4edda;
  --success-text:    #155724;
  --error:           #dc3545;
  --error-light:     #f8d7da;
  --error-text:      #721c24;
  --warning:         #ffc107;
  --warning-light:   #fff3cd;
  --warning-text:    #856404;
  --info:            #17a2b8;
  --info-light:      #d1ecf1;
  --info-text:       #0c5460;

  /* ── Typography ──────────────────────── */
  --font-main:       'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-mono:       'Fira Code', 'Courier New', monospace;

  /* Mobile-safe font sizes
     Never go below 16px on inputs (prevents iOS auto-zoom on focus) */
  --text-xs:         12px;
  --text-sm:         14px;
  --text-base:       16px;
  --text-lg:         18px;
  --text-xl:         20px;
  --text-2xl:        24px;
  --text-3xl:        30px;

  --font-normal:     400;
  --font-medium:     500;
  --font-semibold:   600;
  --font-bold:       700;

  /* ── Spacing ─────────────────────────── */
  --space-xs:        4px;
  --space-sm:        8px;
  --space-md:        16px;
  --space-lg:        24px;
  --space-xl:        32px;
  --space-2xl:       48px;

  /* ── Touch Targets ───────────────────── */
  /* Apple HIG minimum: 44x44px
     Google Material minimum: 48x48px
     We use 48px to satisfy both */
  --touch-target:    48px;

  /* ── Border Radius ───────────────────── */
  --radius:          12px;
  --radius-sm:       8px;
  --radius-md:       8px;
  --radius-lg:       12px;
  --radius-xl:       16px;
  --radius-full:     9999px;

  /* ── Shadows ─────────────────────────── */
  --shadow-sm:       0 1px 3px rgba(0,0,0,0.3);
  --shadow-md:       0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg:       0 8px 24px rgba(0,0,0,0.4);

  /* ── Transitions ─────────────────────── */
  --transition:      all 0.2s ease;

  /* ── Safe Areas for Mobile ───────────── */
  /* Handles iPhone notch and Android navigation bar padding */
  --safe-top:        env(safe-area-inset-top);
  --safe-bottom:     env(safe-area-inset-bottom);
  --safe-left:       env(safe-area-inset-left);
  --safe-right:      env(safe-area-inset-right);
}

/* ── Reset ───────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  /* Prevent text size adjustment on rotation in iOS Safari */
  -webkit-text-size-adjust: 100%;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  font-family: var(--font-main);
  font-size: var(--text-base);
  color: var(--text-primary);
  background-color: var(--secondary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* Prevent tap highlight on Android */
  -webkit-tap-highlight-color: transparent;
  /* Better font rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Padding for mobile safe areas */
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

/* ── Typography ──────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-bold);
  line-height: 1.3;
  color: var(--text-primary);
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }

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

a:hover { color: var(--primary-hover); }

/* ── Buttons ─────────────────────────── */
/* ALL buttons must meet minimum touch target of 48px for mobile stores */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  min-height: var(--touch-target);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  font-family: var(--font-main);
  cursor: pointer;
  transition: var(--transition);
  border: none;
  text-decoration: none;
  white-space: nowrap;
  /* Prevent double-tap zoom on mobile */
  touch-action: manipulation;
  /* Prevent text selection on tap hold */
  user-select: none;
  -webkit-user-select: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
  width: 100%;
}

.btn-primary:hover,
.btn-primary:active {
  background: var(--primary-hover);
  color: white;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
  width: 100%;
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-google {
  background: white;
  color: #333;
  border: 1px solid #dadce0;
  width: 100%;
  font-weight: var(--font-medium);
}

.btn-google:hover {
  background: #f8f9fa;
  box-shadow: var(--shadow-sm);
  color: #333;
}

/* Small button — still meets touch target by adding padding */
.btn-sm {
  min-height: 36px;
  padding: 6px 14px;
  font-size: var(--text-sm);
  width: auto;
}

.btn-danger {
  background: var(--error);
  color: white;
}

.btn-danger:hover {
  background: #c82333;
  color: white;
}

.btn-success {
  background: var(--success);
  color: white;
}

/* ── Form Elements ───────────────────── */
/* Input font-size MUST be 16px minimum
   to prevent iOS Safari auto-zoom on focus */

.form-group {
  margin-bottom: var(--space-md);
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  min-height: var(--touch-target);
  padding: 12px 14px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  /* CRITICAL: 16px prevents iOS zoom */
  font-size: 16px;
  font-family: var(--font-main);
  transition: var(--transition);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108,60,225,0.15);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-input-wrapper {
  position: relative;
}

.form-input-wrapper .form-input {
  padding-right: 48px;
}

.input-toggle-btn {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: 48px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  touch-action: manipulation;
}

.input-toggle-btn:hover {
  color: var(--text-secondary);
}

.form-help {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 4px;
}

.form-error {
  font-size: var(--text-xs);
  color: var(--error);
  margin-top: 4px;
}

/* ── Cards ───────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  box-shadow: var(--shadow-md);
}

/* ── Auth Layout ─────────────────────── */
/* Centered layout for login and register
   Works as a native-feeling screen on mobile */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
}

@media (max-height: 700px) {
  .auth-page {
    align-items: flex-start;
    padding-top: var(--space-xl);
  }
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl);
  box-shadow: var(--shadow-lg);
}

/* On mobile auth card goes full width
   with no border radius — looks native */
@media (max-width: 480px) {
  .auth-page {
    padding: 0;
    align-items: flex-start;
  }
  .auth-card {
    max-width: 100%;
    min-height: 100vh;
    border-radius: 0;
    border: none;
    padding: var(--space-xl) var(--space-lg);
  }
}

.auth-logo {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.auth-title {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  text-align: center;
  margin-bottom: var(--space-xs);
}

.auth-subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: var(--space-xl);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin: var(--space-lg) 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-footer {
  text-align: center;
  margin-top: var(--space-lg);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* ── Navigation ──────────────────────── */
.myz-navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--space-xl);
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  padding-left: calc(var(--space-xl) + var(--safe-left));
  padding-right: calc(var(--space-xl) + var(--safe-right));
}

.myz-navbar-brand {
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  text-decoration: none;
}

.myz-navbar-brand:hover {
  color: var(--primary);
}

.myz-navbar-nav {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  list-style: none;
}

.myz-navbar-nav a {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  padding: 8px 12px;
  min-height: var(--touch-target);
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  touch-action: manipulation;
}

.myz-navbar-nav a:hover {
  color: var(--text-primary);
  background: var(--surface-raised);
}

.navbar-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 2px solid var(--primary);
}

/* Mobile hamburger menu */
.navbar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 24px;
  cursor: pointer;
  min-width: var(--touch-target);
  min-height: var(--touch-target);
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

@media (max-width: 768px) {
  .navbar-toggle {
    display: flex;
  }
  .myz-navbar-nav {
    display: none;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: var(--space-md);
    gap: var(--space-xs);
  }
  .myz-navbar-nav.open {
    display: flex;
  }
  .myz-navbar-nav a {
    width: 100%;
    justify-content: flex-start;
  }
}

/* ── Page Layout ─────────────────────── */
.page-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-xl);
}

@media (max-width: 768px) {
  .page-wrapper {
    padding: var(--space-md);
  }
}

.page-header {
  margin-bottom: var(--space-xl);
}

.page-title {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
}

.page-subtitle {
  color: var(--text-secondary);
  margin-top: var(--space-xs);
}

/* ── Stats Grid ──────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

.stat-value {
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  color: var(--primary);
}

.stat-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: var(--space-xs);
}

/* ── Tables ──────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
}

/* ── Badges ──────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  white-space: nowrap;
}

.badge-success {
  background: var(--success-light);
  color: var(--success-text);
}
.badge-error {
  background: var(--error-light);
  color: var(--error-text);
}
.badge-warning {
  background: var(--warning-light);
  color: var(--warning-text);
}
.badge-info {
  background: var(--info-light);
  color: var(--info-text);
}
.badge-primary {
  background: var(--primary-light);
  color: var(--primary);
}

/* ── Flash Messages ──────────────────── */
#flash-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  max-width: 360px;
  width: calc(100% - 40px);
}

.flash-message {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: 12px 16px;
  margin-bottom: 8px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  box-shadow: var(--shadow-md);
  opacity: 1;
  transition: opacity 0.4s ease, transform 0.4s ease;
  transform: translateX(0);
  border-left: 4px solid;
}

.flash-success {
  background: var(--success-light);
  color: var(--success-text);
  border-color: var(--success);
}
.flash-error {
  background: var(--error-light);
  color: var(--error-text);
  border-color: var(--error);
}
.flash-info {
  background: var(--info-light);
  color: var(--info-text);
  border-color: var(--info);
}
.flash-warning {
  background: var(--warning-light);
  color: var(--warning-text);
  border-color: var(--warning);
}

.flash-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  opacity: 0.6;
  color: inherit;
  padding: 0;
  min-width: 24px;
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  touch-action: manipulation;
}

.flash-close:hover { opacity: 1; }

/* ── Divider ─────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-lg) 0;
}

/* ── Utility Classes ─────────────────── */
.text-muted     { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-primary   { color: var(--primary); }
.text-success   { color: var(--success); }
.text-error     { color: var(--error); }
.text-sm        { font-size: var(--text-sm); }
.text-center    { text-align: center; }
.font-bold      { font-weight: var(--font-bold); }
.mt-sm          { margin-top: var(--space-sm); }
.mt-md          { margin-top: var(--space-md); }
.mt-lg          { margin-top: var(--space-lg); }
.mb-md          { margin-bottom: var(--space-md); }
.mb-lg          { margin-bottom: var(--space-lg); }
.w-full         { width: 100%; }

/* ── Scrollbar Styling ───────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--secondary);
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ════════════════════════════════════════
   CHAT PAGE — Preserved styles
   These support the existing chat interface
   and Bootstrap overrides for chat.html
════════════════════════════════════════ */

[data-bs-theme="dark"] {
  --chat-bg-color: #1a1d21;
  --chat-border-color: #2d3339;
  --assistant-bg-color: rgba(29, 78, 216, 0.2);
  --assistant-border-color: #3b82f6;
  --user-bg-color: rgba(30, 58, 138, 0.3);
}

.chat-container {
  max-height: 500px;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid var(--bs-border-color, var(--border));
  border-radius: 0.375rem;
  background-color: var(--chat-bg-color, var(--surface));
}

.message {
  margin-bottom: 15px;
  padding: 10px;
  border-radius: 10px;
  max-width: 85%;
}

.user-message {
  margin-left: auto;
  background-color: var(--user-bg-color, rgba(30,58,138,0.3));
  border-top-right-radius: 0;
  border-right: 4px solid #6c757d;
  box-shadow: 0 3px 10px rgba(0,0,0,0.15);
  padding: 15px;
}

.assistant-message {
  margin-right: auto;
  background-color: var(--assistant-bg-color, rgba(13,110,253,0.15));
  border-top-left-radius: 0;
  border-left: 4px solid var(--assistant-border-color, #3b82f6);
  box-shadow: 0 3px 10px rgba(0,0,0,0.15);
  padding: 15px;
}

.message-content { word-wrap: break-word; }

.message-sender {
  font-size: 1rem;
  margin-bottom: 8px;
  font-weight: 700;
  color: var(--primary);
}

.message-text {
  font-size: 1.05rem;
  line-height: 1.6;
  font-family: var(--font-main);
  letter-spacing: 0.015em;
}

.MathJax {
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
}

@keyframes pulse {
  0%   { opacity: 1; }
  50%  { opacity: 0.5; }
  100% { opacity: 1; }
}

.thinking-dot { animation: pulse 1s infinite; }

textarea {
  resize: none;
  overflow: hidden;
  min-height: 60px;
}

@media (max-width: 768px) {
  .message {
    max-width: 95%;
    padding: 12px;
    font-size: 0.9rem;
  }
  .chat-container {
    max-height: 350px;
    padding: 8px;
  }
  .message-sender { font-size: 0.85rem; }
  .message-text   { font-size: 0.95rem; line-height: 1.5; }
}

@media (max-width: 576px) {
  .message {
    max-width: 98%;
    padding: 10px;
    margin-bottom: 10px;
  }
  .chat-container {
    max-height: 300px;
    padding: 6px;
  }
}

@media (min-width: 1200px) {
  .chat-container { max-height: 600px; }
  .message        { max-width: 80%; }
}

/* ── Bootstrap utility-class overrides → Design System ──────────────
   These ensure all templates that still use Bootstrap color utilities
   (bg-primary, bg-dark, text-primary, etc.) render with brand colours.
   !important is required to win over Bootstrap's own !important utilities. */

/* Background utilities */
.bg-primary                     { background-color: var(--primary)        !important; }
.bg-dark, .bg-body-secondary    { background-color: var(--surface-raised)  !important; }
.bg-secondary                   { background-color: var(--surface-raised)  !important; }
.bg-success                     { background-color: #16a34a                !important; }
.bg-warning                     { background-color: #f59e0b                !important; }
.bg-info                        { background-color: #06b6d4                !important; }
.bg-danger                      { background-color: #dc2626                !important; }
.bg-light                       { background-color: var(--surface-raised)  !important; }
.bg-white                       { background-color: var(--surface)         !important; }

/* Text utilities */
.text-primary   { color: var(--primary)   !important; }
.text-success   { color: #16a34a          !important; }
.text-warning   { color: #f59e0b          !important; }
.text-info      { color: #06b6d4          !important; }
.text-danger    { color: #dc2626          !important; }
.text-muted, .text-secondary { color: var(--text-muted) !important; }
.text-light, .text-white     { color: var(--text)       !important; }
.text-dark      { color: var(--text)      !important; }

/* Border utilities */
.border-primary   { border-color: var(--primary) !important; }
.border-secondary { border-color: var(--border)  !important; }
.border-success   { border-color: #16a34a        !important; }
.border-warning   { border-color: #f59e0b        !important; }
.border-info      { border-color: #06b6d4        !important; }
.border-danger    { border-color: #dc2626        !important; }

/* Bootstrap button colour variants */
.btn-primary {
  background-color: var(--primary) !important;
  border-color: var(--primary)     !important;
  color: #fff                      !important;
}
.btn-primary:hover, .btn-primary:focus {
  background-color: var(--primary-dark) !important;
  border-color: var(--primary-dark)     !important;
}
.btn-outline-primary {
  border-color: var(--primary) !important;
  color: var(--primary)        !important;
}
.btn-outline-primary:hover {
  background-color: var(--primary) !important;
  color: #fff                      !important;
}

/* Card component */
.card {
  background-color: var(--surface)      !important;
  border-color: var(--border)           !important;
  color: var(--text)                    !important;
}
.card-header {
  background-color: var(--surface-raised) !important;
  border-color: var(--border)             !important;
  color: var(--text)                      !important;
}
.card-body, .card-footer {
  background-color: var(--surface)      !important;
  border-color: var(--border)           !important;
  color: var(--text)                    !important;
}

/* Dropdown */
.dropdown-menu {
  background-color: var(--surface-raised) !important;
  border-color: var(--border)             !important;
}
.dropdown-item { color: var(--text) !important; }
.dropdown-item:hover {
  background-color: var(--surface) !important;
  color: var(--primary)            !important;
}
.dropdown-divider { border-color: var(--border) !important; }

/* Navbar */
.navbar {
  background-color: var(--surface-raised) !important;
  border-bottom: 1px solid var(--border)  !important;
}
.navbar-brand, .nav-link { color: var(--text) !important; }
.nav-link:hover          { color: var(--primary) !important; }

/* Table */
.table { color: var(--text) !important; }
.table th, .table td {
  border-color: var(--border) !important;
  color: var(--text)          !important;
}
.table-striped > tbody > tr:nth-of-type(odd) > * {
  background-color: rgba(255,255,255,0.03) !important;
}

/* Form controls */
.form-control, .form-select, input, textarea, select {
  background-color: var(--surface-raised) !important;
  border-color: var(--border)             !important;
  color: var(--text)                      !important;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary)                    !important;
  box-shadow: 0 0 0 3px rgba(108,60,225,0.18)    !important;
}
.form-control::placeholder, .form-select::placeholder {
  color: var(--text-muted) !important;
}
.form-label { color: var(--text) !important; }
.form-text  { color: var(--text-muted) !important; }
select option { background-color: var(--surface-raised); color: var(--text); }

/* Alert tweaks */
.alert {
  border: 1px solid var(--border);
}
.alert-success { background-color: rgba(22,163,74,0.15) !important; color: #4ade80 !important; border-color: rgba(22,163,74,0.3) !important; }
.alert-danger  { background-color: rgba(220,38,38,0.15) !important; color: #f87171 !important; border-color: rgba(220,38,38,0.3) !important; }
.alert-warning { background-color: rgba(245,158,11,0.15) !important; color: #fbbf24 !important; border-color: rgba(245,158,11,0.3) !important; }
.alert-info    { background-color: rgba(6,182,212,0.15) !important; color: #67e8f9 !important; border-color: rgba(6,182,212,0.3) !important; }

/* Badge */
.badge.bg-primary   { background-color: var(--primary) !important; }
.badge.bg-warning   { background-color: #f59e0b        !important; color: #111 !important; }
.badge.bg-success   { background-color: #16a34a        !important; }
.badge.bg-danger    { background-color: #dc2626        !important; }
.badge.bg-secondary { background-color: var(--surface-raised) !important; }

/* Input group border */
.input-group .btn-outline-secondary {
  border-color: var(--border) !important;
  color: var(--text-muted)    !important;
}
.input-group .btn-outline-secondary:hover {
  background-color: var(--surface-raised) !important;
  color: var(--text)                      !important;
}

/* Modal */
.modal-content {
  background-color: var(--surface)      !important;
  border-color: var(--border)           !important;
  color: var(--text)                    !important;
}
.modal-header, .modal-footer {
  border-color: var(--border) !important;
}

/* Page wrapper spacing */
.page-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px;
}

/* Final specificity fix: bg-* applied to card-header/card must still win */
.card-header.bg-primary, .card-header.bg-primary.text-white {
  background-color: var(--primary) !important;
  color: #fff !important;
}
.card.bg-dark, .card.bg-secondary, .card.bg-body-secondary {
  background-color: var(--surface-raised) !important;
}

/* ── WebView Google Button Handling ─────
   JavaScript handles hiding in WebView.
   This is a fallback safety rule only.
────────────────────────────────────── */
.google-auth-section {
  /* Visible by default on all platforms */
  display: block;
}

/* ── Footer — GitHub style ───────────────
   Minimal. Quiet. Out of the way.
   Single line at bottom of every page.
─────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border, rgba(255,255,255,0.08));
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--text-muted, #6b7280);
  font-size: 12px;
  margin-top: auto;
}

.site-footer a {
  color: var(--text-muted, #6b7280);
  text-decoration: none;
  transition: color 0.2s ease;
}

.site-footer a:hover {
  color: var(--text-secondary, #9ca3af);
  text-decoration: underline;
}

.site-footer .footer-links {
  display: flex;
  align-items: center;
  gap: 16px;
  list-style: none;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}

.site-footer .footer-links li {
  display: flex;
  align-items: center;
}

.site-footer .footer-links li + li::before {
  content: '·';
  margin-right: 16px;
  color: var(--text-muted, #6b7280);
}

@media (max-width: 480px) {
  .site-footer {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 12px 16px;
  }
  .site-footer .footer-links li + li::before {
    display: none;
  }
}


/* ── Diagram / ASCII art display ─────────────────────────────────────────────
   Applied to code blocks inside solution content.
   Preserves ASCII spacing and uses monospace font.
──────────────────────────────────────────────────────────────────────────── */
.solution-content pre,
.solution-content code,
.explanation-body pre,
.explanation-body code {
  font-family: var(--font-mono);
  background: var(--surface-raised);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 6px;
  padding: 1rem;
  overflow-x: auto;
  white-space: pre;
  line-height: 1.4;
  font-size: 13px;
  margin: 0.75rem 0;
  display: block;
  -webkit-overflow-scrolling: touch;
}

.solution-content pre::before,
.explanation-body pre::before {
  content: '📐 Diagram';
  display: block;
  font-size: 11px;
  color: var(--primary, #6366f1);
  font-weight: 600;
  margin-bottom: 0.5rem;
  font-family: var(--font-main, sans-serif);
  letter-spacing: 0.04em;
}

.solution-content pre + p,
.explanation-body pre + p {
  font-size: 0.85rem;
  text-align: center;
  margin-top: -0.25rem;
  margin-bottom: 0.75rem;
  display: block;
  opacity: 0.75;
}

@media (max-width: 768px) {
  .solution-content pre,
  .explanation-body pre {
    font-size: 11px;
    padding: 0.6rem;
  }
}

/* ════════════════════════════════════
   HIDE QUESTION BANK — DO NOT REMOVE
   Question bank selector hidden from
   users. Internal use only.
   Applied globally as a safety net
   in case element exists anywhere.
   ════════════════════════════════════ */

label[for="source"],
label[for="question_bank"],
label[for="question-bank"] {
  display: none !important;
}

select#source,
select[name="source"],
select#question_bank,
select[name="question_bank"],
select#question-bank,
select[name="question-bank"] {
  display: none !important;
}

.form-group:has(select[name="source"]),
.form-group:has(select#source),
.form-group:has(label[for="source"]) {
  display: none !important;
}

.mb-3:has(select[name="source"]),
.mb-3:has(select#source),
.mb-3:has(label[for="source"]) {
  display: none !important;
}

.source-info,
.question-bank-info,
#source-info,
#question-bank-info,
[class*="source-info"],
[class*="bank-info"],
[data-field="source"],
[data-field="question_bank"],
[data-field="question-bank"] {
  display: none !important;
}

/* ── END QUESTION BANK HIDE ─────── */
