/* ==========================================================================
   RANKION - SSC CHSL 2027 AIR 1 PREPARATION SYSTEM
   Design System: Minimal, Distraction-Free, Professional, Responsive
   ========================================================================== */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Light Theme (Default) */
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-hover: #e2e8f0;
  --border: #e2e8f0;
  --border-focus: #94a3b8;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-faint: #94a3b8;

  --accent-primary: #1e3a8a; /* Deep Navy */
  --accent-primary-hover: #1e40af;
  --accent-primary-light: #eff6ff;
  --accent-primary-text: #1d4ed8;

  --status-success: #059669; /* Sage green */
  --status-success-bg: #ecfdf5;
  --status-warning: #d97706; /* Amber */
  --status-warning-bg: #fffbeb;
  --status-danger: #dc2626;  /* Terracotta */
  --status-danger-bg: #fef2f2;

  --sidebar-width: 260px;
  --topbar-height: 56px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] {
  --bg-page: #0b0f19;
  --bg-card: #111827;
  --bg-subtle: #1f2937;
  --bg-hover: #374151;
  --border: #1f2937;
  --border-focus: #4b5563;

  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --text-faint: #6b7280;

  --accent-primary: #3b82f6;
  --accent-primary-hover: #60a5fa;
  --accent-primary-light: #1e293b;
  --accent-primary-text: #93c5fd;

  --status-success: #10b981;
  --status-success-bg: #064e3b;
  --status-warning: #f59e0b;
  --status-warning-bg: #78350f;
  --status-danger: #ef4444;
  --status-danger-bg: #7f1d1d;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
}

/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* ==========================================================================
   Passcode Lock Screen (Lock: 2486)
   ========================================================================== */
#lock-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background-color: var(--bg-page);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lock-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow-md);
  text-align: center;
}

.lock-card h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
  color: var(--text-main);
}

.lock-card p.subtitle {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.lock-input-group {
  margin-bottom: 16px;
}

.lock-input-group input {
  width: 100%;
  padding: 12px 14px;
  text-align: center;
  font-size: 20px;
  letter-spacing: 0.25em;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s ease;
}

.lock-input-group input:focus {
  border-color: var(--accent-primary);
  background: var(--bg-card);
}

.lock-error {
  font-size: 12px;
  color: var(--status-danger);
  min-height: 18px;
  margin-bottom: 12px;
}

/* ==========================================================================
   Application Shell Layout
   ========================================================================== */
#main-app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
}

.sidebar-header {
  height: var(--topbar-height);
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-main);
}

.brand-badge {
  font-size: 10px;
  padding: 2px 6px;
  font-weight: 600;
  background: var(--accent-primary-light);
  color: var(--accent-primary-text);
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  padding: 10px 10px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
  margin-bottom: 2px;
}

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

.nav-item.active {
  background: var(--accent-primary-light);
  color: var(--accent-primary-text);
  font-weight: 600;
}

.nav-badge {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--bg-hover);
  color: var(--text-muted);
  font-weight: 600;
}

.nav-badge.danger {
  background: var(--status-danger-bg);
  color: var(--status-danger);
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.page-breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
}

.page-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
}

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

.content-viewport {
  padding: 24px;
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ==========================================================================
   UI Components (Buttons, Inputs, Cards, Tables, Badges)
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
}

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

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

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

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border-color: var(--border);
}

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

.btn-danger {
  background: var(--status-danger-bg);
  color: var(--status-danger);
  border-color: var(--status-danger);
}

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

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

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

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
}

.card-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Metric / Stat Blocks */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}

.metric-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 6px;
}

.metric-val {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.1;
}

.metric-sub {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 4px;
}

/* Tables */
.table-container {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

th {
  background: var(--bg-subtle);
  padding: 10px 14px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: var(--bg-subtle);
}

/* Badges */
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

.badge-blue { background: var(--accent-primary-light); color: var(--accent-primary-text); }
.badge-green { background: var(--status-success-bg); color: var(--status-success); }
.badge-amber { background: var(--status-warning-bg); color: var(--status-warning); }
.badge-red { background: var(--status-danger-bg); color: var(--status-danger); }
.badge-gray { background: var(--bg-subtle); color: var(--text-muted); }

/* Form Controls */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-main);
  outline: none;
  font-size: 13px;
}

.form-control:focus {
  border-color: var(--accent-primary);
}

textarea.form-control {
  min-height: 90px;
  resize: vertical;
}

/* Modal Dialogs */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
  animation: modalFadeIn 0.15s ease;
}

.modal-dialog.lg {
  max-width: 900px;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

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

.modal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
}

.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* ==========================================================================
   Active Recall Flashcard Revision Interface
   ========================================================================== */
.flashcard-session-container {
  max-width: 720px;
  margin: 0 auto;
}

.flashcard-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.flashcard-display-card {
  min-height: 280px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  position: relative;
}

.flashcard-type-tag {
  position: absolute;
  top: 14px;
  left: 18px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}

.flashcard-question-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.4;
  margin-bottom: 16px;
}

.flashcard-answer-box {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
  text-align: left;
}

.flashcard-answer-text {
  font-size: 15px;
  color: var(--text-main);
  line-height: 1.5;
  background: var(--bg-subtle);
  padding: 16px;
  border-radius: var(--radius-md);
  margin-bottom: 8px;
}

.flashcard-source-ref {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.rating-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.btn-rating {
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  transition: all 0.12s ease;
}

.btn-rating .rating-name {
  font-size: 13px;
  font-weight: 600;
}

.btn-rating .rating-sub {
  font-size: 10px;
  color: var(--text-muted);
}

.btn-rating.again:hover { border-color: var(--status-danger); background: var(--status-danger-bg); }
.btn-rating.hard:hover { border-color: var(--status-warning); background: var(--status-warning-bg); }
.btn-rating.good:hover { border-color: var(--accent-primary); background: var(--accent-primary-light); }
.btn-rating.easy:hover { border-color: var(--status-success); background: var(--status-success-bg); }

/* ==========================================================================
   Exam Simulator & Test Interface
   ========================================================================== */
.exam-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
}

.exam-main-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.exam-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.exam-timer {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 15px;
  color: var(--accent-primary-text);
  background: var(--accent-primary-light);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}

.exam-question-text {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 20px;
}

.exam-options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.exam-option-item {
  display: flex;
  align-items: flex-start;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  background: var(--bg-subtle);
  transition: all 0.12s ease;
}

.exam-option-item:hover {
  background: var(--bg-hover);
  border-color: var(--border-focus);
}

.exam-option-item.selected {
  border-color: var(--accent-primary);
  background: var(--accent-primary-light);
}

.exam-option-radio {
  margin-top: 3px;
  margin-right: 12px;
}

.exam-palette-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 14px 0;
}

.palette-btn {
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.palette-btn.current {
  border-color: var(--text-main);
  box-shadow: 0 0 0 1px var(--text-main);
}

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

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

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

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 13px;
  box-shadow: var(--shadow-md);
  min-width: 250px;
  max-width: 380px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: toastIn 0.2s ease;
}

.toast.success { border-left: 4px solid var(--status-success); }
.toast.danger { border-left: 4px solid var(--status-danger); }
.toast.info { border-left: 4px solid var(--accent-primary); }

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


/* ==========================================================================
   Comprehensive Mobile & Phone Responsiveness (<768px & <480px)
   ========================================================================== */

/* Mobile Close Button inside Sidebar */
.mobile-close-sidebar-btn {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

/* Dark Backdrop for Mobile Sidebar */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
  z-index: 1050;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

@media (max-width: 900px) {
  .exam-layout {
    grid-template-columns: 1fr;
    display: flex;
    flex-direction: column;
  }
  .exam-palette-panel {
    order: 2;
    max-height: 220px;
    overflow-y: auto;
  }
  .exam-main-panel {
    order: 1;
    min-height: auto;
  }
}

@media (max-width: 768px) {
  /* 1. Mobile Sidebar Navigation */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    z-index: 1100;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .mobile-close-sidebar-btn {
    display: flex;
  }
  .main-wrapper {
    margin-left: 0;
    width: 100%;
    min-width: 0;
  }
  .mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 12px;
    font-size: 13px;
    font-weight: 600;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    cursor: pointer;
  }

  /* 2. Topbar on Mobile */
  .topbar {
    height: auto;
    min-height: 56px;
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 90;
  }
  .topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    justify-content: space-between;
  }
  .topbar-left > div {
    min-width: 0;
  }
  .page-breadcrumb {
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .page-title {
    font-size: 16px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .topbar-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }
  .topbar-actions .btn {
    font-size: 11px;
    padding: 6px 10px;
    white-space: nowrap;
    flex: 1 1 auto;
    text-align: center;
  }

  /* 3. Content Viewport & Padding */
  .content-viewport {
    padding: 12px 10px;
  }

  /* 4. Cards & Card Headers */
  .card {
    padding: 14px 12px;
    margin-bottom: 16px;
    border-radius: var(--radius-md);
  }
  .card-header {
    flex-direction: column;
    align-items: stretch !important;
    gap: 10px;
    margin-bottom: 12px;
  }
  .card-header > div:last-child {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
  }
  .card-header select.form-control {
    width: 100% !important;
  }
  .card-header .btn {
    flex: 1 1 auto;
    text-align: center;
  }

  /* 5. Grids and Settings */
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  #view-settings div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }
  #view-settings .card[style*="grid-column: span 2"] {
    grid-column: span 1 !important;
  }
  #subjects-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* 6. Collapse all 2-column inline form grids on mobile */
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  /* 7. Tables on Mobile */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    margin-bottom: 12px;
    border-radius: var(--radius-sm);
  }
  .table-container table {
    min-width: 580px;
    font-size: 12px;
  }
  .table-container th,
  .table-container td {
    padding: 8px 10px;
  }

  /* 8. Modals on Mobile - Bottom Sheet Style */
  .modal-backdrop {
    padding: 0;
    align-items: flex-end;
  }
  .modal-dialog {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 16px 16px 0 0 !important;
    max-height: 94vh !important;
    margin: 0 !important;
    border-bottom: none !important;
  }
  .modal-dialog.lg {
    max-width: 100% !important;
  }
  .modal-header {
    padding: 12px 16px;
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 10;
    border-bottom: 1px solid var(--border);
  }
  .modal-body {
    padding: 14px 16px;
    max-height: 75vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .modal-footer {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 8px;
    position: sticky;
    bottom: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
  }
  .modal-footer .btn {
    flex: 1 1 auto;
    padding: 10px;
  }

  /* 9. Flashcard Study & Ratings */
  .flashcard-display-card {
    min-height: 180px;
    padding: 16px;
  }
  .flashcard-question-text {
    font-size: 16px;
  }
  .flashcard-answer-text {
    font-size: 14px;
  }
  .rating-bar {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }
  .btn-rating {
    padding: 10px 6px;
  }

  /* 10. Exam Simulator on Mobile */
  #modal-exam-simulator {
    padding: 0;
  }
  #modal-exam-simulator .modal-dialog {
    height: 100vh !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
  }
  .exam-option-card {
    padding: 10px 12px;
  }
}

@media (max-width: 480px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }
  .topbar-actions .btn {
    font-size: 10px;
    padding: 5px 8px;
  }
  .rating-bar {
    grid-template-columns: 1fr;
  }
  .lock-card {
    padding: 24px 18px;
    margin: 14px;
  }
}


/* Bulk Upload Dropzone & Toolbar Styles */
.bulk-upload-dropzone {
  border: 2px dashed var(--border);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 14px;
}

.bulk-upload-dropzone:hover,
.bulk-upload-dropzone.drag-over {
  border-color: var(--accent-primary);
  background: rgba(37, 99, 235, 0.05);
}

.bulk-upload-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.bulk-upload-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* ==========================================================================
   ENHANCED SCORECARD & DETAILED SOLUTIONS
   ========================================================================== */
.scorecard-banner {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.scorecard-banner-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}
.scorecard-banner-sub {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
  align-items: center;
}
.scorecard-ssc-formula {
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.25);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent-primary-text);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.scorecard-filter-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.scorecard-pill {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}
.scorecard-pill:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}
.scorecard-pill.active {
  background: var(--accent-primary);
  color: #fff;
  border-color: var(--accent-primary);
}

/* Complete MCQ Option Display (for Scorecard & Mistake Notebook) */
.mcq-options-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 10px 0;
}
@media (min-width: 640px) {
  .mcq-options-grid {
    grid-template-columns: 1fr 1fr;
  }
}
.mcq-option-box {
  display: flex;
  align-items: flex-start;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  font-size: 12px;
  line-height: 1.4;
  transition: all 0.15s ease;
}
.mcq-option-box .opt-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  min-width: 22px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 11px;
  margin-right: 10px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.mcq-option-box .opt-text {
  flex: 1;
  word-break: break-word;
}
.mcq-option-box .opt-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 8px;
  white-space: nowrap;
}
/* States */
.mcq-option-box.is-correct {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.08);
}
.mcq-option-box.is-correct .opt-letter {
  background: #10b981;
  color: #fff;
  border-color: #10b981;
}
.mcq-option-box.is-correct .opt-text {
  font-weight: 600;
  color: #065f46;
}
.theme-dark .mcq-option-box.is-correct .opt-text {
  color: #34d399;
}
.mcq-option-box.is-user-wrong {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
}
.mcq-option-box.is-user-wrong .opt-letter {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}
.mcq-option-box.is-user-wrong .opt-text {
  font-weight: 600;
  color: #991b1b;
}
.theme-dark .mcq-option-box.is-user-wrong .opt-text {
  color: #f87171;
}

/* Answers Summary Bar */
.answers-summary-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 12px;
  align-items: center;
  margin-bottom: 8px;
}
.answers-summary-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

