/* ----------------------------------------------------
   MOSEA - ICE BLUE / FROST SLATE DELUXE THEME
   Mobile & Desktop Optimized Layout System
   ---------------------------------------------------- */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  /* Light Frost Theme Palette */
  --bg-main: #f0f4f8;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-header: rgba(240, 244, 248, 0.96);
  --bg-sidebar: #ffffff;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-inverse: #ffffff;
  
  --border-light: #e2e8f0;
  --border-focus: #38bdf8;
  
  /* Primary Ice Accents */
  --primary: #0ea5e9;
  --primary-hover: #0284c7;
  --primary-light: #e0f2fe;
  --cyan-accent: #0891b2;
  --gradient-ice: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%);
  
  /* Status Colors */
  --correct-bg: #ecfdf5;
  --correct-border: #10b981;
  --correct-text: #065f46;
  
  --wrong-bg: #fff1f2;
  --wrong-border: #f43f5e;
  --wrong-text: #9f1239;
  
  --unanswered-bg: #f1f5f9;
  --unanswered-border: #cbd5e1;
  --unanswered-text: #64748b;
  
  --shadow-sm: 0 1px 3px rgba(14, 165, 233, 0.05);
  --shadow-md: 0 4px 12px -2px rgba(14, 165, 233, 0.08);
  --shadow-lg: 0 8px 20px -4px rgba(14, 165, 233, 0.12);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

[data-theme="dark"] {
  /* Deep Glacier Dark Theme Palette */
  --bg-main: #0b1329;
  --bg-card: #162032;
  --bg-card-hover: #1e2d42;
  --bg-header: rgba(11, 19, 41, 0.96);
  --bg-sidebar: #162032;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-inverse: #0f172a;
  
  --border-light: #1e293b;
  --border-focus: #38bdf8;
  
  --primary-light: rgba(14, 165, 233, 0.18);
  
  --correct-bg: rgba(16, 185, 129, 0.15);
  --correct-border: #10b981;
  --correct-text: #34d399;
  
  --wrong-bg: rgba(244, 63, 94, 0.15);
  --wrong-border: #f43f5e;
  --wrong-text: #fb7185;
  
  --unanswered-bg: #1e293b;
  --unanswered-border: #334155;
  --unanswered-text: #94a3b8;
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 20px -4px rgba(0, 0, 0, 0.6);
}

/* Custom Scrollbar - Matching Theme 100% */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-main);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb {
  background: var(--unanswered-border);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--unanswered-border) var(--bg-main);
}

/* Global Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-family: var(--font-family);
  font-size: 16px;
  background-color: var(--bg-main);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.15s ease, color 0.15s ease;
  overscroll-behavior-y: none;
}

/* Progress Bar Bar */
.progress-bar-wrapper {
  width: 100%;
  height: 4px;
  background: var(--border-light);
  position: relative;
  overflow: hidden;
  transform: translateZ(0);
  will-change: transform;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--gradient-ice);
  transition: width 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Header & Navigation - GPU Layer Isolation */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-light);
  padding: max(0.65rem, env(safe-area-inset-top, 0.65rem)) 1.25rem 0.65rem;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.15s ease, border-color 0.15s ease;
  transform: translateZ(0);
  will-change: transform;
  backface-visibility: hidden;
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.header-top-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  text-decoration: none;
  letter-spacing: 0.04em;
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: var(--gradient-ice);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 3px 10px rgba(14, 165, 233, 0.3);
  flex-shrink: 0;
}

.brand-title {
  background: var(--gradient-ice);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 800;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-grow: 1;
  justify-content: flex-end;
}

/* Vietnam 24h Clock Widget */
.vn-clock-widget {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--bg-card);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 0.35rem 0.65rem;
  box-shadow: var(--shadow-sm);
  user-select: none;
  flex-shrink: 0;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.vn-clock-widget:hover {
  border-color: var(--primary);
}

.vn-clock-icon {
  font-size: 1.05rem;
  color: var(--primary);
  animation: pulse-clock-icon 2s infinite ease-in-out;
}

@keyframes pulse-clock-icon {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.65; transform: scale(0.92); }
}

.vn-clock-details {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  line-height: 1;
}

.vn-clock-time {
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: 0.04em;
}

.vn-clock-date {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  border-left: 1px solid var(--border-light);
  padding-left: 0.45rem;
}

.select-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-grow: 1;
  max-width: 680px;
  justify-content: flex-end;
}

.custom-select {
  background-color: var(--bg-card);
  color: var(--text-main);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
}

#subjectSelect {
  flex: 1 1 auto;
  min-width: 180px;
}

#chapterSelect {
  flex: 0 0 auto;
  min-width: 105px;
  max-width: 125px;
}

.custom-select:hover, .custom-select:focus {
  border-color: var(--primary);
}

/* Action Buttons & Pills */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  user-select: none;
  min-height: 40px;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-primary {
  background: var(--gradient-ice);
  color: white;
  box-shadow: 0 3px 10px rgba(14, 165, 233, 0.25);
}

.btn-primary:active {
  transform: scale(0.98);
}

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

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1.5px solid var(--border-light);
  color: var(--text-main);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.desktop-only-theme {
  display: flex !important;
}

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

/* Toolbar & Filters (Desktop Default: 1 Single Row) */
.toolbar-bar {
  max-width: 1400px;
  margin: 0.75rem auto 0;
  padding: 0 1.25rem;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
}

@media (min-width: 769px) {
  .toolbar-row {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    width: auto !important;
    overflow: visible !important;
  }

  .btn,
  .mode-btn,
  .filter-pill,
  .toggle-switch-wrapper,
  .exam-timer {
    white-space: nowrap !important;
    flex-shrink: 0 !important;
  }

  .filter-pills {
    overflow: visible !important;
    scrollbar-width: none;
  }

  .filter-pills::-webkit-scrollbar {
    display: none !important;
  }
}

.toolbar-toggles {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.action-buttons {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.mode-switcher {
  display: flex;
  background: var(--bg-card);
  padding: 0.2rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.mode-btn {
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 35px;
  white-space: nowrap;
}

.mode-btn.active {
  background: var(--gradient-ice);
  color: white;
  box-shadow: 0 2px 6px rgba(14, 165, 233, 0.2);
}

.filter-pills {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--bg-card);
  padding: 0.2rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  flex-shrink: 0;
}

.filter-pill {
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  min-height: 36px;
}

.filter-pill.active {
  background: var(--primary-light);
  color: var(--primary-hover);
  font-weight: 700;
}

/* Modern iOS-Style Toggle Switch */
.toggle-switch-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  background: var(--bg-card);
  padding: 0.25rem 0.75rem 0.25rem 0.4rem;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--border-light);
  cursor: pointer;
  user-select: none;
  box-shadow: var(--shadow-sm);
  min-height: 38px;
  transition: border-color 0.15s ease;
}

.toggle-switch-wrapper.highlight-toggle {
  border-color: var(--primary);
}

.toggle-switch-wrapper:hover {
  border-color: var(--primary);
}

.toggle-switch-input {
  display: none;
}

.toggle-switch-slider {
  width: 36px;
  height: 20px;
  background-color: var(--unanswered-border);
  border-radius: 999px;
  position: relative;
  transition: background-color 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
}

.toggle-switch-slider::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.toggle-switch-input:checked + .toggle-switch-slider {
  background: var(--gradient-ice);
}

.toggle-switch-input:checked + .toggle-switch-slider::before {
  transform: translateX(16px);
}

.toggle-switch-text {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

.toggle-switch-input:checked ~ .toggle-switch-text {
  color: var(--text-main);
}

.exam-timer {
  display: none;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-card);
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--primary);
  color: var(--primary);
  font-weight: 800;
  font-size: 0.9rem;
}

.exam-timer.urgent {
  border-color: var(--wrong-border);
  color: var(--wrong-text);
}

.main-wrapper {
  max-width: 1400px;
  width: 100%;
  margin: 0.85rem auto 3rem;
  padding: 0 1.25rem;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1.25rem;
  align-items: start;
  transition: max-width 0.3s cubic-bezier(0.16, 1, 0.3, 1), grid-template-columns 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.main-wrapper.sidebar-collapsed {
  grid-template-columns: 1fr;
  max-width: 880px;
}

.main-wrapper.sidebar-collapsed #sidebarPalette {
  display: none !important;
}

/* Questions Scroll Container */
.questions-container {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

/* Question Card Styling - Hardware Accelerated Isolation */
.question-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 2px solid var(--border-light);
  padding: 1.25rem;
  box-shadow: var(--shadow-md);
  position: relative;
  contain: content;
  transform: translateZ(0);
  transition: border-color 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Active Highlighted Question Card - Ultra Smooth Ice Blue Border Glow */
.question-card.active {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3.5px rgba(14, 165, 233, 0.22), 0 8px 24px -4px rgba(14, 165, 233, 0.2) !important;
}

.question-card.active .question-number-tag {
  background: var(--gradient-ice) !important;
  color: white !important;
  box-shadow: 0 3px 8px rgba(14, 165, 233, 0.35);
}

.question-card.highlight {
  border-color: var(--primary) !important;
}

.question-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}

.question-number-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  background: var(--primary-light);
  color: var(--primary-hover);
  border-radius: var(--radius-full);
  font-size: 0.775rem;
  font-weight: 800;
  transition: background 0.3s cubic-bezier(0.16, 1, 0.3, 1), color 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.source-tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 800;
  border-radius: var(--radius-full);
  margin-left: 0.4rem;
  letter-spacing: 0.02em;
}

.source-tag-pill.source-lms {
  background: rgba(16, 185, 129, 0.14);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.source-tag-pill.source-de-cuong,
.source-tag-pill.source-đề-cương {
  background: rgba(245, 158, 11, 0.14);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.source-tag-pill.source-wot {
  background: rgba(99, 102, 241, 0.14);
  color: #6366f1;
  border: 1px solid rgba(99, 102, 241, 0.35);
}

.bookmark-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 36px;
}

.bookmark-btn.active {
  color: #f59e0b;
}

.question-text {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.5;
  color: var(--text-main);
  margin-bottom: 1rem;
}

/* Options Container */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.option-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-light);
  background: var(--bg-card);
  cursor: pointer;
  user-select: none;
  min-height: 48px;
  touch-action: manipulation;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.option-radio {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--unanswered-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.option-radio-inner {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: transparent;
  transform: scale(0);
  transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.option-key {
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--text-muted);
  min-width: 20px;
}

.option-content {
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text-main);
}

/* Option Selected State */
.option-item.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

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

.option-item.selected .option-radio-inner {
  background: white;
  transform: scale(1);
}

/* Practice Feedback States */
.option-item.is-correct {
  background: var(--correct-bg) !important;
  border-color: var(--correct-border) !important;
}

.option-item.is-correct .option-radio {
  border-color: var(--correct-border) !important;
  background: var(--correct-border) !important;
}

.option-item.is-correct .option-radio-inner {
  background: white !important;
  transform: scale(1) !important;
}

.option-item.is-correct .option-content,
.option-item.is-correct .option-key {
  color: var(--correct-text) !important;
  font-weight: 700;
}

.option-item.is-wrong {
  background: var(--wrong-bg) !important;
  border-color: var(--wrong-border) !important;
}

.option-item.is-wrong .option-radio {
  border-color: var(--wrong-border) !important;
  background: var(--wrong-border) !important;
}

.option-item.is-wrong .option-radio-inner {
  background: white !important;
  transform: scale(1) !important;
}

.option-item.is-wrong .option-content,
.option-item.is-wrong .option-key {
  color: var(--wrong-text) !important;
  font-weight: 700;
}

/* Explanation Container & Memory Tip Card */
.explanation-container {
  margin-top: 0.9rem;
  display: none;
  flex-direction: column;
  gap: 0.65rem;
}

.explanation-container.show {
  display: flex;
}

.explanation-box {
  padding: 0.8rem 1rem;
  background: var(--primary-light);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-md);
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--text-main);
}

.explanation-title {
  font-weight: 700;
  color: var(--primary-hover);
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.83rem;
}

.memory-tip-card {
  padding: 0.75rem 1rem;
  background: rgba(245, 158, 11, 0.08);
  border: 1.5px dashed rgba(245, 158, 11, 0.45);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--text-main);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.08);
}

[data-theme="dark"] .memory-tip-card {
  background: rgba(251, 191, 36, 0.09);
  border-color: rgba(251, 191, 36, 0.4);
}

.tip-title {
  font-weight: 700;
  color: #d97706;
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

[data-theme="dark"] .tip-title {
  color: #fbbf24;
}

.tip-content-lines {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.tip-line {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.86rem;
  line-height: 1.4;
  flex-wrap: wrap;
}

.tip-tag-ask {
  font-weight: 800;
  color: #d97706;
  white-space: nowrap;
}

[data-theme="dark"] .tip-tag-ask {
  color: #fbbf24;
}

.tip-val {
  font-weight: 600;
  color: var(--text-main);
}

.tip-arrow {
  font-weight: 900;
  color: var(--primary);
  font-size: 1rem;
}

.tip-tag-ans {
  font-weight: 800;
  color: var(--primary-hover);
  white-space: nowrap;
}

.tip-val-ans {
  font-weight: 700;
  color: var(--primary-hover);
}

.tip-ans-badge {
  background: var(--gradient-ice);
  color: white;
  padding: 0.08rem 0.5rem;
  border-radius: var(--radius-full);
  font-weight: 800;
  font-size: 0.78rem;
  margin-left: 0.2rem;
  box-shadow: 0 2px 6px rgba(14, 165, 233, 0.25);
}

/* Question Footer Navigation */
.card-footer-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-light);
}

.card-nav-btn {
  background: var(--bg-main);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 36px;
}

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

/* Sidebar Question Palette */
.sidebar-palette {
  position: sticky;
  top: 75px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-height: calc(100vh - 90px);
  overflow-y: auto;
  contain: content;
  transform: translateZ(0);
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.palette-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  border-radius: var(--radius-md);
  transition: background-color 0.15s ease;
  user-select: none;
}

.palette-header:hover {
  background: var(--primary-light);
}

.sidebar-collapse-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease, background-color 0.15s ease;
}

.sidebar-collapse-btn:hover {
  color: var(--primary);
  background: var(--primary-light);
}

/* Palette Bubble Button (Messenger Chat Bubble Style) */
.btn-palette-bubble {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.83rem;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  cursor: pointer;
}

.btn-palette-bubble:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-hover);
}

.btn-palette-bubble.active-bubble {
  background: var(--gradient-ice);
  color: white !important;
  border-color: transparent !important;
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.35);
}

.btn-palette-bubble.active-bubble i {
  color: white !important;
}

.bubble-badge {
  background: rgba(14, 165, 233, 0.15);
  color: var(--primary-hover);
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 800;
}

.btn-palette-bubble.active-bubble .bubble-badge {
  background: rgba(255, 255, 255, 0.25);
  color: white;
}

.palette-title {
  font-size: 0.95rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.palette-stats {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 700;
}

.mobile-toggle-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-main);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.2rem;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.4rem;
}

.palette-btn {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: var(--unanswered-bg);
  color: var(--unanswered-text);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.825rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.25s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.palette-btn.current-active {
  box-shadow: 0 0 0 2.5px rgba(14, 165, 233, 0.35) !important;
  border-color: var(--primary) !important;
  transform: scale(1.1);
  font-weight: 800;
  z-index: 2;
}

.palette-btn.answered {
  background: var(--primary-light);
  color: var(--primary-hover);
  border-color: var(--primary);
}

.palette-btn.correct {
  background: var(--correct-bg);
  color: var(--correct-text);
  border-color: var(--correct-border);
}

.palette-btn.wrong {
  background: var(--wrong-bg);
  color: var(--wrong-text);
  border-color: var(--wrong-border);
}

.palette-legend {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-light);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend-dot.dot-unanswered { background: var(--unanswered-border); }
.legend-dot.dot-answered { background: var(--primary); }
.legend-dot.dot-correct { background: var(--correct-border); }
.legend-dot.dot-wrong { background: var(--wrong-border); }

/* Quick Answer Key Section */
.answer-key-section {
  display: none;
  flex-direction: column;
  gap: 0.6rem;
  padding-top: 0.85rem;
  border-top: 1.5px dashed var(--correct-border);
  margin-top: 0.35rem;
}

.answer-key-section.show {
  display: flex;
}

.answer-key-header {
  font-size: 0.85rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--correct-text);
}

.answer-key-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.35rem;
}

.answer-key-btn {
  background: var(--correct-bg);
  color: var(--correct-text);
  border: 1.5px solid var(--correct-border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.2rem;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.825rem;
  cursor: pointer;
  text-align: center;
  transition: transform 0.15s ease, background-color 0.15s ease;
  box-shadow: 0 1px 3px rgba(16, 185, 129, 0.12);
}

.answer-key-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(16, 185, 129, 0.25);
}

.answer-key-btn:active {
  transform: scale(0.95);
}

/* Compact Floating Back-To-Top Button */
.btn-scroll-top {
  position: fixed;
  bottom: 25px;
  right: 25px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--gradient-ice);
  color: white;
  border: none;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.35);
  z-index: 140;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.btn-scroll-top.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.btn-scroll-top:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 18px rgba(14, 165, 233, 0.45);
}

.btn-scroll-top:active {
  transform: scale(0.95);
}

/* Custom Reset Confirmation Modal Styling */
.confirm-modal-card {
  max-width: 360px;
  padding: 1.5rem;
  text-align: center;
}

.confirm-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 0.85rem;
  box-shadow: 0 3px 10px rgba(14, 165, 233, 0.2);
}

.confirm-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.confirm-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 1.25rem;
}

.confirm-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.confirm-actions .btn {
  flex: 1;
}

/* Score Modal */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(11, 19, 41, 0.8);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

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

.modal-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  max-width: 440px;
  width: 100%;
  padding: 1.75rem;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.modal-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--gradient-ice);
  color: white;
  font-size: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
}

.modal-score {
  font-size: 2.75rem;
  font-weight: 800;
  background: var(--gradient-ice);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0.4rem 0;
}

.modal-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin: 1.25rem 0;
}

.stat-box {
  background: var(--bg-main);
  padding: 0.65rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}

.stat-val {
  font-size: 1.1rem;
  font-weight: 800;
}

.stat-label {
  font-size: 0.725rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.empty-notice {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px dashed var(--border-light);
  padding: 2.5rem 1.25rem;
  text-align: center;
  color: var(--text-muted);
}

.empty-notice-icon {
  font-size: 2.2rem;
  margin-bottom: 0.5rem;
  color: var(--primary);
}

/* Responsive Design */
@media (max-width: 992px) {
  .main-wrapper {
    grid-template-columns: 1fr;
    padding-bottom: 70px;
  }

  .sidebar-palette {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    max-height: 60px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    z-index: 150;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    padding: 0.75rem 1.25rem;
    overflow: hidden;
    transition: max-height 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }
  
  .sidebar-palette.expanded {
    max-height: 480px;
    overflow-y: auto;
  }
  
  .mobile-toggle-btn {
    display: block;
  }
  
  .palette-grid {
    grid-template-columns: repeat(8, 1fr);
    padding-top: 0.5rem;
  }

  .answer-key-grid {
    grid-template-columns: repeat(6, 1fr);
  }

  .btn-scroll-top {
    bottom: 75px;
    right: 18px;
    width: 40px;
    height: 40px;
    font-size: 1.15rem;
  }
}

@media (max-width: 768px) {
  html, body {
    max-width: 100vw;
    overflow-x: hidden;
  }

  .btn-text-desktop,
  .desktop-only-theme {
    display: none !important;
  }

  .mobile-only-theme {
    display: flex !important;
  }

  .header {
    padding: max(0.65rem, env(safe-area-inset-top, 0.65rem)) 0.75rem 0.45rem !important;
  }

  .header-container {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
  }

  .brand {
    font-size: 1.15rem;
    flex-shrink: 0;
  }

  .select-wrapper {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    width: 100%;
    max-width: 100%;
    margin-top: 0.1rem;
  }

  .vn-clock-widget {
    padding: 0.25rem 0.45rem;
    gap: 0.25rem;
    flex-shrink: 0;
  }

  .vn-clock-date {
    display: none !important;
  }

  .vn-clock-time {
    font-size: 0.78rem;
  }

  #subjectSelect {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.78rem;
    padding: 0.38rem 0.5rem;
  }

  #chapterSelect {
    flex: 0 0 95px;
    font-size: 0.78rem;
    padding: 0.38rem 0.45rem;
  }

  /* Mobile Toolbar Horizontal Smooth Touch Scroll Rows */
  .toolbar-bar {
    padding: 0 0.75rem;
    gap: 0.45rem;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    overflow: hidden;
  }

  .toolbar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
    width: 100% !important;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }

  .toolbar-row::-webkit-scrollbar {
    display: none;
  }

  .mode-switcher,
  .exam-timer,
  .toolbar-toggles,
  .filter-pills,
  .action-buttons,
  .toggle-switch-wrapper,
  .btn,
  .filter-pill,
  .mode-btn {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
  }

  .btn {
    white-space: nowrap !important;
    min-height: 34px;
    padding: 0.35rem 0.6rem;
    font-size: 0.78rem;
    line-height: 1;
  }

  .mode-btn {
    white-space: nowrap !important;
    min-height: 34px;
    padding: 0.35rem 0.55rem;
    font-size: 0.78rem;
  }

  .filter-pill {
    white-space: nowrap !important;
    min-height: 33px;
    padding: 0.3rem 0.5rem;
    font-size: 0.75rem;
  }

  .toggle-switch-wrapper {
    white-space: nowrap !important;
    min-height: 34px;
    padding: 0.2rem 0.4rem;
    gap: 0.3rem;
  }

  .question-card {
    padding: 1rem;
  }

  .question-text {
    font-size: 0.95rem;
  }

  .option-item {
    padding: 0.65rem 0.85rem;
  }

  .option-content {
    font-size: 0.85rem;
  }

  .palette-grid {
    grid-template-columns: repeat(6, 1fr);
  }

  .answer-key-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
