/* css/components/dashboard.css */

/* ── Mode toggle ── */
.mode-toggle {
  display: flex;
  gap: 4px;
  background: rgba(45, 46, 95, 0.04);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 16px;
  border: 1px solid rgba(45, 46, 95, 0.06);
}

.mode-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  background: transparent;
  color: var(--text-medium);
}

.mode-btn:hover {
  background: rgba(255, 255, 255, 0.5);
}

.mode-btn.active {
  background: var(--white);
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.mode-btn.active[data-mode="exam"] {
  background: linear-gradient(135deg, #2D2E5F, #1E9D8E);
  color: white;
}

.mode-btn i {
  font-size: 1rem;
}

/* ── Dashboard reset buttons ── */
.dashboard-reset-btn {
  background: transparent;
  border: none;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.85rem;
  border-radius: 50%;
  flex-shrink: 0;
  opacity: 0.6;
}

.dashboard-reset-btn:hover {
  opacity: 1;
  transform: scale(1.15);
}

.reset-test-btn {
  color: rgba(45, 46, 95, 0.4);
  margin-right: 4px;
}

.reset-test-btn:hover {
  color: #2D2E5F;
  background: rgba(45, 46, 95, 0.08);
}

.reset-section-btn {
  color: var(--text-light);
}

.reset-section-btn:hover {
  color: var(--incorrect);
  background: rgba(239, 68, 68, 0.1);
}

.reset-section-btn i,
.reset-test-btn i {
  font-size: 0.8rem;
  background: transparent;
  color: inherit;
}

/* ── Confirmation dialog (Duolingo-style, Sune orange + blue) ── */
.confirm-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30000;
  padding: 20px;
  box-sizing: border-box;
  animation: confirmOverlayIn 0.18s ease;
}

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

.confirm-dialog {
  --confirm-duo-orange: #f47417;
  --confirm-duo-orange-dark: #d45f0a;
  --confirm-duo-orange-hover: #f6802a;
  --confirm-duo-blue: #1cb0f6;
  --confirm-duo-blue-light: #ddf4ff;
  --confirm-duo-border: #e5e5e5;
  --confirm-duo-text: #4b4b4b;

  position: relative;
  background: #fff;
  border-radius: 24px;
  border: 2px solid var(--confirm-duo-border);
  border-bottom-width: 5px;
  border-bottom-color: #d0d0d0;
  max-width: 400px;
  width: 100%;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.14);
  font-family: 'Nunito', sans-serif;
  animation: confirmDialogIn 0.22s ease;
}

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

.confirm-dialog-header {
  display: none;
}

.confirm-dialog-prompt {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 22px 22px 8px;
}

.confirm-dialog-mascot {
  flex-shrink: 0;
  width: 72px;
  height: auto;
  pointer-events: none;
}

.confirm-dialog-bubble {
  position: relative;
  flex: 1;
  min-width: 0;
  background: #fff;
  border: 2px solid var(--confirm-duo-border);
  border-radius: 18px;
  padding: 14px 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.confirm-dialog-bubble::before {
  content: '';
  position: absolute;
  left: -10px;
  bottom: 20px;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-right: 12px solid var(--confirm-duo-border);
}

.confirm-dialog-bubble::after {
  content: '';
  position: absolute;
  left: -7px;
  bottom: 21px;
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-right: 10px solid #fff;
}

.confirm-dialog-bubble p {
  font-size: 1rem;
  font-weight: 700;
  color: var(--confirm-duo-text);
  margin: 0;
  line-height: 1.5;
  text-align: left;
}

.confirm-dialog-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--confirm-duo-orange);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 0 var(--confirm-duo-orange-dark);
}

.confirm-dialog-icon .material-symbols-outlined {
  font-size: 1.6rem;
}

.confirm-dialog-buttons {
  display: flex;
  gap: 10px;
  padding: 16px 20px 22px;
}

.confirm-dialog-btn {
  flex: 1;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  min-height: 44px;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s, border-color 0.15s, color 0.15s;
}

.confirm-cancel {
  background: #fff;
  border: 2px solid var(--confirm-duo-border);
  color: #777;
  box-shadow: 0 3px 0 #e5e5e5;
}

.confirm-cancel:hover {
  color: #555;
  border-color: #cfcfcf;
  background: #fafafa;
}

.confirm-cancel:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #e5e5e5;
}

.confirm-ok {
  background: var(--confirm-duo-orange);
  color: #fff;
  border: none;
  box-shadow: 0 4px 0 var(--confirm-duo-orange-dark);
}

.confirm-ok:hover {
  background: var(--confirm-duo-orange-hover);
}

.confirm-ok:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--confirm-duo-orange-dark);
}

/* ── Section complete screen ── */
.section-complete-screen {
  max-width: 640px;
  margin: 40px auto;
  text-align: center;
  background: var(--white);
  border-radius: 20px;
  padding: 48px 36px;
  box-shadow: 0 4px 16px rgba(45, 46, 95, 0.08);
  animation: fadeInUp 0.4s ease;
}

.section-complete-icon {
  font-size: 4rem;
  color: var(--completed);
  margin-bottom: 16px;
}

.section-complete-icon.final {
  color: #f59e0b;
}

.section-complete-screen h2 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 8px;
}

.section-complete-screen p {
  color: var(--text-medium);
  margin-bottom: 24px;
}

.section-complete-score {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 24px 0;
  padding: 16px 24px;
  background: #f0fdf4;
  border-radius: 14px;
  border: 1px solid #bbf7d0;
}

.section-complete-score.final-total {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border-color: #fbbf24;
}

.section-complete-label {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-dark);
}

.section-complete-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--completed);
}

.final-total .section-complete-value {
  color: #b45309;
}

.section-complete-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 28px;
}

.btn-next-section,
.btn-final-results {
  padding: 14px 28px;
  border: none;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
}

.btn-next-section:hover,
.btn-final-results:hover {
  filter: brightness(1.1);
  transform: translateY(-2px);
}

.btn-back-dashboard {
  padding: 12px 24px;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  background: transparent;
  color: var(--text-medium);
}

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

.final-results-breakdown {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 20px 0;
}

.final-results-section-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: #f8fafc;
  border-radius: 10px;
}

.final-results-section-name {
  font-weight: 600;
  color: var(--text-dark);
}

.final-results-section-score {
  font-weight: 700;
  color: var(--primary);
}

/* ── Section complete per-part breakdown ── */
.section-complete-parts-breakdown {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0;
  text-align: left;
}

.section-complete-part-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #f8fafc;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
}

.section-complete-part-name {
  flex: 1;
  font-weight: 600;
  color: var(--text-dark);
  font-size: 0.9rem;
}

.section-complete-part-score {
  font-weight: 700;
  color: var(--primary);
  min-width: 48px;
  text-align: right;
}

.btn-review-part {
  padding: 5px 12px;
  border: 1.5px solid var(--primary);
  border-radius: 8px;
  background: transparent;
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-review-part:hover {
  background: var(--primary);
  color: white;
}

/* ── Exam mode badge ── */
.exam-mode-badge,
.practice-mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 12px;
  font-family: 'Fredoka', 'Nunito', sans-serif;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-left: 8px;
  vertical-align: middle;
  white-space: nowrap;
  border: 2px solid transparent;
}

.exam-mode-badge {
  background: #f3e8ff;
  color: #6b21a8;
  border-color: #ce82ff;
  box-shadow: 0 2px 0 #a855f7;
}

.exam-mode-badge .material-symbols-outlined,
.practice-mode-badge .material-symbols-outlined {
  font-size: 0.95rem;
}

.practice-mode-badge {
  background: #d7ffb8;
  color: #166534;
  border-color: #58cc02;
  box-shadow: 0 2px 0 #58a700;
}

.mode-header {
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 1.5px;
  color: var(--text-light);
  font-weight: 600;
  margin: 32px 0 16px;
}

.no-exams {
  background: rgba(255, 255, 255, 0.98);
  border-radius: 20px;
  padding: 60px 40px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(45, 46, 95, 0.05);
  border: 1px solid rgba(45, 46, 95, 0.04);
  animation: fadeInUp 0.5s ease;
}

.no-exams i {
  font-size: 5rem;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 20px;
}

.no-exams h3 {
  font-size: 2rem;
  color: var(--text-dark);
  margin-bottom: 10px;
  font-weight: 700;
}

.no-exams p {
  font-size: 1.2rem;
  color: var(--text-medium);
  background: rgba(45, 46, 95, 0.06);
  display: inline-block;
  padding: 8px 24px;
  border-radius: 40px;
}

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

.exams-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 40px;
}

.exam-item {
  background: var(--white);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.exam-header {
  padding: 20px 24px;
  background: linear-gradient(135deg, #e8f0ff 0%, #d8d0f0 100%);
  color: #2D2E5F;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.2s;
}

.exam-header:hover {
  filter: brightness(1.05);
}

.exam-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
}

.exam-number {
  font-size: 1.8rem;
  font-weight: 800;
  opacity: 0.8;
}

.exam-title {
  font-family: 'Mileast', sans-serif;
  font-size: 1.3rem;
  font-weight: 600;
}

.exam-subtitle {
  font-family: 'Mileast', sans-serif;
  font-style: italic;
  font-size: 0.9rem;
  opacity: 0.8;
  margin-top: 4px;
}

.exam-progress-badge {
  padding: 6px 12px;
  border-radius: 30px;
  background: rgba(45, 46, 95, 0.08);
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.exam-arrow {
  font-size: 1.2rem;
  transition: transform 0.3s;
}

.exam-header.active .exam-arrow {
  transform: rotate(180deg);
}

.exam-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
  background: var(--bg-light);
}

.exam-content.show {
  max-height: 2000px;
  padding: 24px;
}

.exam-sections {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.exam-section {
  background: white;
  border-radius: 16px;
  padding: 20px;
  padding-top: 0;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.reset-section-corner-btn {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: transparent;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: 0.7rem;
  padding: 4px 6px;
  border-radius: 6px;
  transition: all 0.2s;
  opacity: 0.5;
}

.reset-section-corner-btn:hover {
  opacity: 1;
  color: var(--primary);
  background: rgba(45, 46, 95, 0.06);
}


.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  position: relative;
}

.section-header i {
  font-size: 1.5rem;
  padding: 12px;
  border-radius: 16px;
  color: white;
  background: linear-gradient(135deg, #b39ddb 0%, #ce93d8 100%);
}

.section-icon {
  font-size: 1.3rem !important;
  color: white !important;
  padding: 8px;
  border-radius: 12px;
  background: transparent;
  border: none;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.section-icon.reading {
  background: linear-gradient(135deg, #b39ddb 0%, #ce93d8 100%) !important;
  border-color: #b39ddb;
}

.section-icon.listening {
  background: linear-gradient(135deg, #ffcc80 0%, #ffab91 100%) !important;
  border-color: #ffcc80;
}

.section-icon.writing {
  background: linear-gradient(135deg, #a5d6a7 0%, #81c784 100%) !important;
  border-color: #a5d6a7;
}

.section-icon.speaking {
  background: linear-gradient(135deg, #f48fb1 0%, #ef9a9a 100%) !important;
  border-color: #f48fb1;
}

.section-icon:hover {
  transform: scale(1.1);
  filter: brightness(1.15);
}

.section-header h4 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-dark);
  margin-right: auto;
}

.section-play {
  background: transparent;
  color: var(--primary);
  border: none;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1.1rem;
  margin-left: 8px;
}

.section-play:hover {
  transform: scale(1.2);
  color: var(--secondary);
}

.section-play i {
  font-size: 1.1rem;
  background: transparent;
  color: inherit;
}

.section-parts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.part-number {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1rem;
  background: #f1f5f9;
  color: var(--text-medium);
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
  position: relative;
}

.part-number:hover {
  background: var(--primary);
  color: white;
  transform: scale(1.05);
}

.part-number.completed {
  background: var(--completed);
  color: white;
}

.part-number.in-progress {
  background: var(--in-progress);
  color: white;
  border-color: var(--primary-dark);
  animation: pulseBorder 2s infinite;
}

.part-number.exam-locked {
  cursor: not-allowed;
  opacity: 0.45;
}

.part-number.exam-locked:hover {
  background: #f1f5f9;
  color: var(--text-medium);
  transform: none;
}

.part-number.completed.exam-locked {
  opacity: 1;
  cursor: pointer;
}

.part-number.completed.exam-locked:hover {
  background: var(--completed);
  color: white;
  filter: brightness(1.1);
  transform: scale(1.05);
}

@keyframes pulseBorder {
  0% {
    border-color: var(--primary-dark);
  }
  50% {
    border-color: transparent;
  }
  100% {
    border-color: var(--primary-dark);
  }
}

.section-progress {
  font-size: 0.9rem;
  color: var(--text-light);
  margin-left: 8px;
  font-weight: 500;
}

.section-progress--scale {
  color: #2D2E5F;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ── Results buttons ── */
.exam-play-btn {
  background: rgba(45, 46, 95, 0.08);
  color: #2D2E5F;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1rem;
  margin-right: 4px;
  flex-shrink: 0;
}

.exam-play-btn:hover {
  background: rgba(49, 27, 146, 0.2);
  transform: scale(1.1);
}

.exam-results-btn {
  background: rgba(49, 27, 146, 0.1);
  color: #2D2E5F;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1rem;
  margin-right: 4px;
  flex-shrink: 0;
}

.exam-results-btn:hover {
  background: rgba(49, 27, 146, 0.2);
  transform: scale(1.1);
}

.section-results-btn {
  background: transparent;
  color: var(--primary);
  border: none;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1rem;
}

.section-results-btn:hover {
  transform: scale(1.2);
  color: var(--secondary);
}

.section-results-btn i {
  font-size: 1rem;
  background: transparent;
  color: inherit;
}

/* ── Results modal ── */
.results-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(60, 60, 60, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20000;
  padding: 16px;
  box-sizing: border-box;
}

.results-modal-content {
  background: #fff;
  width: 100%;
  max-width: 960px;
  padding: 28px 24px 24px;
  border-radius: 24px;
  position: relative;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
  animation: fadeInUp 0.3s ease;
  box-sizing: border-box;
  max-height: 92vh;
  overflow-y: auto;
  font-family: 'Nunito', sans-serif;
}

.results-modal-content.results-modal-section {
  max-width: 640px;
}

.results-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: #f0f0f0;
  border: none;
  border-radius: 50%;
  color: #afafaf;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  z-index: 10;
}

.results-modal-close:hover {
  background: #e5e5e5;
  color: #4b4b4b;
}

/* ── Duolingo-style hero summary ── */
.results-modal-content .results-hero {
  text-align: center;
  padding: 8px 12px 20px;
  margin-bottom: 4px;
}

.results-modal-content .results-exam-level {
  display: inline-block;
  background: #e5f7ff;
  color: #1cb0f6;
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.results-modal-content .results-hero-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #777;
  margin: 0 0 6px;
}

.results-modal-content .results-hero-grade {
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  font-weight: 900;
  color: #3c3c3c;
  line-height: 1.15;
  margin-bottom: 14px;
}

.results-modal-content .results-hero-meta {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.results-modal-content .results-hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f7f7f7;
  border: 2px solid #e5e5e5;
  border-radius: 14px;
  padding: 8px 16px;
  font-size: 0.85rem;
  color: #777;
  line-height: 1;
}

.results-modal-content .results-hero-pill strong {
  display: inline-flex;
  align-items: center;
  font-weight: 900;
  color: #3c3c3c;
  font-size: 1rem;
  line-height: 1;
}

.results-modal-content .results-hero-pill-label {
  display: inline-flex;
  align-items: center;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  line-height: 1;
}

/* ── Chart section ── */
.results-modal-content .results-chart-section {
  margin-top: 4px;
}

.results-modal-content .cb-chart-toggle {
  display: flex;
  gap: 0;
  margin: 0 auto 14px;
  background: #f0f0f0;
  border: none;
  border-radius: 14px;
  padding: 4px;
  width: fit-content;
}

.results-modal-content .cb-toggle-btn {
  padding: 8px 20px;
  border: none;
  background: transparent;
  color: #afafaf;
  font-family: 'Nunito', sans-serif;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  border-radius: 11px;
  transition: all 0.15s;
}

.results-modal-content .cb-toggle-btn:hover {
  color: #777;
}

.results-modal-content .cb-toggle-btn.cb-toggle-active {
  background: #fff;
  color: #1cb0f6;
  box-shadow: 0 2px 6px rgba(45, 46, 95, 0.08);
}

/* ── Cambridge chart (modal) ── */
.results-modal-content .cb-chart {
  margin-bottom: 0;
  padding: 12px 12px 16px;
  background: var(--white, #fff);
  border: 1px solid var(--border-light, #e8ecf4);
  border-radius: 16px;
  box-shadow: var(--shadow-md, 0 2px 8px rgba(45, 46, 95, 0.06));
  font-family: 'Nunito', sans-serif;
}

.results-modal-content .cb-chart-columns {
  gap: 10px;
}

.results-modal-content .cb-column {
  gap: 8px;
  border: none;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

.results-modal-content .cb-hdr {
  flex: 0 0 var(--cb-hdr-height, 48px);
  height: var(--cb-hdr-height, 48px);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.62rem;
  font-weight: 800;
  color: var(--text-light, #7b7ca0);
  padding: 4px 6px;
  line-height: 1.15;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid var(--border-light, #e8ecf4);
  border-radius: 10px;
  background: #eef1f8;
  box-sizing: border-box;
}

.results-modal-content .cb-column-scale .cb-hdr,
.results-modal-content .cb-column-grades .cb-hdr {
  font-size: 0.52rem;
  letter-spacing: 0.02em;
  padding: 4px 3px;
  line-height: 1.1;
}

.results-modal-content .cb-col-body {
  border: 1px solid var(--border-light, #e8ecf4);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(45, 46, 95, 0.04);
  overflow: visible;
  padding-bottom: 12px;
  background: transparent;
}

.results-modal-content .cb-col-inner {
  top: 0;
  bottom: 0;
}

.results-modal-content .cb-column-scale .cb-col-body {
  background: linear-gradient(to right, #eef1f8, #fff);
}

.results-modal-content .cb-column-scale .cb-col-inner {
  background: transparent;
}

.results-modal-content .cb-column-cefr .cb-col-body,
.results-modal-content .cb-column-grades .cb-col-body,
.results-modal-content .cb-column-skill .cb-col-body {
  background: rgba(28, 176, 246, 0.14);
}

.results-modal-content .cb-scale-num {
  font-size: 0.58rem;
  color: var(--text-light, #7b7ca0);
  font-weight: 800;
  background: transparent;
}

.results-modal-content .cb-column-grades .cb-grade-band:nth-child(1) {
  background: rgba(28, 176, 246, 0.14);
}
.results-modal-content .cb-column-grades .cb-grade-band:nth-child(2) {
  background: rgba(28, 176, 246, 0.08);
}
.results-modal-content .cb-column-grades .cb-grade-band:nth-child(3) {
  background: rgba(28, 176, 246, 0.05);
}
.results-modal-content .cb-column-grades .cb-grade-band:nth-child(4) {
  background: rgba(45, 46, 95, 0.03);
}
.results-modal-content .cb-column-grades .cb-grade-band:nth-child(5) {
  background: rgba(45, 46, 95, 0.02);
}
.results-modal-content .cb-column-grades .cb-grade-band:nth-child(1) .cb-grade-band-text,
.results-modal-content .cb-column-grades .cb-grade-band:nth-child(2) .cb-grade-band-text,
.results-modal-content .cb-column-grades .cb-grade-band:nth-child(3) .cb-grade-band-text {
  color: #1a8fc7;
}
.results-modal-content .cb-column-grades .cb-grade-band:nth-child(4) .cb-grade-band-text,
.results-modal-content .cb-column-grades .cb-grade-band:nth-child(5) .cb-grade-band-text {
  color: var(--text-light, #7b7ca0);
}

.results-modal-content .cb-grade-band.cb-grade-active {
  background: #1cb0f6 !important;
  border: 2px solid #1899d6;
  box-shadow: 0 2px 8px rgba(28, 176, 246, 0.25);
}
.results-modal-content .cb-grade-band.cb-grade-below.cb-grade-active {
  border-radius: 0;
}
.results-modal-content .cb-grade-band.cb-grade-active .cb-grade-band-text {
  color: #fff !important;
}

.results-modal-content .cb-cefr-band strong {
  font-size: 0.9rem;
  font-weight: 900;
  color: var(--text-light, #7b7ca0);
}

.results-modal-content .cb-cefr-band.cb-cefr-active {
  background: #e5f7ff;
  border: 2px solid #1cb0f6;
  border-radius: 0;
}
.results-modal-content .cb-cefr-band.cb-cefr-active strong {
  color: #1cb0f6;
}

.results-modal-content .cb-scale-overall-tag span {
  background: #f97316;
  border-radius: 6px 0 0 6px;
  box-shadow: 0 2px 6px rgba(249, 115, 22, 0.28);
  font-weight: 900;
}
.results-modal-content .cb-scale-overall-tag span::after {
  border-left-color: #f97316;
}

.results-modal-content .cb-score-badge span {
  background: #1cb0f6;
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(28, 176, 246, 0.25);
  font-weight: 800;
}

.results-modal-content .cb-band:nth-child(1) { background: rgba(28, 176, 246, 0.14); }
.results-modal-content .cb-band:nth-child(2) { background: rgba(28, 176, 246, 0.08); }
.results-modal-content .cb-band:nth-child(3) { background: rgba(28, 176, 246, 0.05); }
.results-modal-content .cb-band:nth-child(4) { background: rgba(45, 46, 95, 0.03); }
.results-modal-content .cb-band:nth-child(5) { background: rgba(45, 46, 95, 0.02); }

/* ── Raw chart (modal) ── */
.results-modal-content .cb-raw-chart {
  gap: 8px;
}

.results-modal-content .cb-raw-row {
  align-items: center;
  padding: 10px 14px;
  background: #fafafa;
  border: 2px solid #e5e5e5;
  border-radius: 14px;
}

.results-modal-content .cb-raw-label {
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  color: #4b4b4b;
  min-width: 100px;
}

.results-modal-content .cb-raw-label i {
  color: #1cb0f6;
}

.results-modal-content .cb-raw-bar-wrap {
  background: #e5e5e5;
  border: none;
  border-radius: 999px;
  min-height: 12px;
  box-shadow: none;
}

.results-modal-content .cb-raw-bar {
  background: #1cb0f6;
  border-radius: 999px;
  min-height: 12px;
  box-shadow: none;
}

.results-modal-content .cb-raw-value {
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  color: #3c3c3c;
}

/* Legacy header (score calculator page) */
.results-modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 2px solid transparent;
  border-image: linear-gradient(90deg, #683020, #E86810) 1;
}

.results-modal-header h3 {
  font-size: 1.3rem;
  font-weight: 700;
  color: #602008;
  margin: 0;
}

.results-exam-level {
  background: linear-gradient(135deg, #E86810, #683020);
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
}

.results-skills-detail {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 0;
}

.results-skill-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  background: #F4F7FF;
  border-radius: 10px;
  border: 1px solid #e8ecf4;
}

.results-skill-row i {
  font-size: 1rem;
  color: #2D2E5F;
  width: 20px;
  text-align: center;
}

.results-skill-name {
  font-weight: 600;
  color: var(--text-dark, #333);
  flex: 1;
}

.results-skill-raw {
  font-size: 0.85rem;
  color: var(--text-light, #999);
  font-weight: 500;
}

.results-skill-scale {
  font-weight: 800;
  font-size: 1.1rem;
  color: #2D2E5F;
  min-width: 36px;
  text-align: right;
}



/* ── Dashboard 3-column layout (Duolingo-style) ── */
:root {
  --dashboard-left-sidebar-width: 256px;
  --dashboard-right-sidebar-width: 360px;
  --dashboard-exercise-tools-width: 340px;
  --dashboard-exercise-tools-min-width: 320px;
  --dashboard-exercise-tools-gap: 16px;
  --dashboard-exercise-tools-bg: #fff4eb;
  --dashboard-top-spacing: 28px;
  --dashboard-layout-right-gutter: 160px;
  --dashboard-center-offset: 80px;
  --dashboard-right-sidebar-inset: 86px;
  --brand-orange: #f47417;
  --brand-orange-dark: #d46110;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--dashboard-right-sidebar-width);
  gap: 24px;
  align-items: start;
  max-width: none;
  margin: 0;
  padding: var(--dashboard-top-spacing) 0 0 12px;
  width: 100%;
  box-sizing: border-box;
}

.dashboard-left-sidebar,
.dashboard-right-sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.dashboard-left-sidebar {
  overflow-y: auto;
}

.dashboard-right-sidebar {
  overflow: visible;
  padding-right: 16px;
  padding-top: 4px;
}

.dashboard-right-sidebar .main-nav-stats-bar {
  width: 100%;
  justify-content: flex-end;
  align-self: stretch;
  padding-top: 0;
  margin-bottom: 4px;
  position: relative;
  z-index: 1500;
}

.dashboard-sidebar-shell {
  transition: width 0.2s ease;
}

.dashboard-sidebar-toggle-left {
  align-self: flex-end;
}

.dashboard-sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid rgba(45, 46, 95, 0.1);
  background: rgba(255, 255, 255, 0.96);
  color: var(--text-medium);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(45, 46, 95, 0.08);
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}

.dashboard-sidebar-toggle:hover {
  background: #fff;
  color: var(--primary);
  transform: translateY(-1px);
}

.dashboard-sidebar-toggle .material-symbols-outlined {
  font-size: 1.2rem;
}

.dashboard-sidebar-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

@media (min-width: 901px) {
  .dashboard-right-sidebar .dashboard-sidebar-content {
    min-height: calc(100vh - var(--dashboard-top-spacing, 28px) - 4px);
  }
}

.dashboard-sidebar-shell.is-collapsed {
  overflow: visible;
  gap: 0;
}

.dashboard-sidebar-shell.is-collapsed .dashboard-sidebar-content {
  display: none;
}

.dashboard-sidebar-shell.is-collapsed .dashboard-sidebar-toggle {
  position: sticky;
  top: 10px;
}

.dashboard-left-sidebar > *,
.dashboard-right-sidebar > * {
  margin-top: 0;
  margin-bottom: 0;
}

.dashboard-center {
  min-width: 0;
  padding-top: 4px;
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: none;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.dashboard-center-header {
  margin-bottom: 20px;
  padding: 0 4px;
}

.dashboard-center-title {
  font-family: 'Nunito', sans-serif;
  font-size: 1.75rem;
  font-weight: 800;
  color: #3c3c3c;
  margin: 0 0 4px;
  line-height: 1.2;
}

.dashboard-center-subtitle {
  font-family: 'Nunito', sans-serif;
  font-size: 0.92rem;
  font-weight: 600;
  color: #777;
  margin: 0;
  line-height: 1.35;
}

/* Narrow desktop: keep center content wide; trim decorative gutters & sidebars */
@media (min-width: 901px) and (max-width: 1600px) {
  :root {
    --dashboard-right-sidebar-width: 280px;
    --dashboard-layout-right-gutter: 32px;
    --dashboard-center-offset: 24px;
    --dashboard-right-sidebar-inset: 32px;
    --dashboard-exercise-tools-width: 300px;
    --dashboard-exercise-tools-min-width: 280px;
  }
}

/* Unified 3-column desktop layout (left nav + center content + right widgets) */
@media (min-width: 901px) {
  .dashboard-layout:not(.dashboard-layout--crossword-play):not(.dashboard-layout--exercise):not(.dashboard-layout-right-closed) {
    grid-template-columns: minmax(0, 1fr);
    padding-right: calc(var(--dashboard-right-sidebar-width) + var(--dashboard-layout-right-gutter));
    padding-bottom: 48px;
  }

  .dashboard-layout:not(.dashboard-layout--crossword-play):not(.dashboard-layout--exercise):not(.dashboard-layout-right-closed) .dashboard-center {
    margin-left: var(--dashboard-center-offset);
    width: calc(100% - var(--dashboard-center-offset));
    max-width: calc(100% - var(--dashboard-center-offset));
    box-sizing: border-box;
  }

  .dashboard-layout:not(.dashboard-layout--crossword-play):not(.dashboard-layout--exercise):not(.dashboard-layout-right-closed) > .dashboard-right-sidebar,
  .dashboard-layout:not(.dashboard-layout--crossword-play):not(.dashboard-layout--exercise):not(.dashboard-layout-right-closed) > .dashboard-right-sidebar.dashboard-sidebar-shell {
    position: fixed;
    right: 0;
    top: 0;
    height: 100vh;
    width: calc(var(--dashboard-right-sidebar-width) + var(--dashboard-right-sidebar-inset));
    padding-left: var(--dashboard-right-sidebar-inset);
    overflow-y: auto;
    z-index: 50;
    background: #f7f7f7;
    padding-top: var(--dashboard-top-spacing, 28px);
    box-sizing: border-box;
    align-self: auto;
    max-height: none;
  }

  .dashboard-layout-right-closed {
    grid-template-columns: minmax(0, 1fr);
    padding-right: 24px;
    padding-bottom: 48px;
  }

  .dashboard-layout--crossword-play {
    grid-template-columns: minmax(0, 1fr);
    padding-right: 24px;
  }
}

@media (max-width: 900px) {
  body:has(.dashboard-layout) .app-container {
    padding-left: 0;
  }

  .dashboard-layout,
  .dashboard-layout.dashboard-layout-right-closed {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 16px;
    max-width: 100%;
    padding: 0;
  }

  .dashboard-center {
    order: 1;
  }

  .dashboard-left-sidebar {
    order: 2;
  }

  .dashboard-right-sidebar {
    order: 3;
  }

  .dashboard-left-sidebar,
  .dashboard-right-sidebar,
  .dashboard-sidebar-shell {
    width: auto !important;
    overflow: visible;
  }

  .dashboard-sidebar-toggle {
    display: none;
  }

  .dashboard-sidebar-shell.is-collapsed .dashboard-sidebar-content {
    display: flex;
  }

  .dashboard-sidebar-content {
    gap: 12px;
  }

  .sidebar-widget {
    position: static;
    padding: 16px;
    margin-bottom: 0;
  }
}

@media (max-width: 768px), (max-height: 520px) and (orientation: landscape) and (max-width: 1024px) {
  .dashboard-layout,
  .dashboard-layout.dashboard-layout-right-closed {
    display: block;
    padding: 0;
  }

  .dashboard-left-sidebar,
  .dashboard-right-sidebar {
    display: none !important;
  }

  .dashboard-center {
    width: 100%;
    max-width: 430px;
    margin: 0 auto;
  }

  .subpage-header {
    align-items: flex-start;
    padding: 14px;
    border-radius: 18px;
    gap: 10px;
  }

  .subpage-title {
    font-size: 1.05rem;
    overflow-wrap: anywhere;
  }

  .subpage-subtitle {
    overflow-wrap: anywhere;
  }

  .exam-header {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 12px;
  }

  .exam-header-left {
    min-width: 0;
  }

  .exam-title,
  .exam-subtitle {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .exam-progress-badge {
    flex: 1 1 100%;
    min-width: 0;
  }

  .exam-play-btn,
  .exam-results-btn,
  .exam-arrow {
    flex-shrink: 0;
  }

  .section-header {
    flex-wrap: wrap;
  }

  .section-header h4 {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .results-modal-overlay {
    align-items: flex-end;
    padding: 0;
    backdrop-filter: none;
  }

  .results-modal-content {
    width: 100%;
    max-height: calc(100dvh - 16px);
    border-radius: 24px 24px 0 0;
    overflow-y: auto;
    padding: 24px 16px max(20px, env(safe-area-inset-bottom));
  }

  .results-modal-content .results-hero {
    padding: 4px 4px 16px;
  }

  .results-modal-content .results-hero-grade {
    font-size: 1.8rem;
  }

  .results-modal-content .results-hero-pill {
    padding: 6px 12px;
    font-size: 0.8rem;
  }

  .results-modal-content .cb-chart {
    margin: 0 -4px;
    padding: 8px 6px;
  }

  .results-modal-content .cb-chart-columns {
    min-width: 520px;
    gap: 8px;
  }

  .results-modal-content .cb-raw-row {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .results-modal-content .cb-raw-label,
  .results-modal-content .cb-raw-value {
    min-width: 0;
    text-align: left;
  }

  .results-modal-header {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .results-modal-header h3 {
    min-width: 0;
    font-size: 1.05rem;
    overflow-wrap: anywhere;
  }

  .grade-carousel-cefr {
    font-size: 2.6rem;
  }
}

/* Sidebar widgets */
.sidebar-widget {
  background: #fff;
  border-radius: 20px;
  padding: 20px;
  border: 2px solid #e5e5e5;
  border-bottom: 4px solid #d0d0d0;
  margin-bottom: 16px;
  position: sticky;
  top: 10px;
  z-index: 10;
}

.sidebar-widget-title {
  font-size: 0.82rem;
  font-weight: 800;
  color: #afafaf;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 14px;
}

.sidebar-calculator-widget .sidebar-widget-title i {
  color: #1E9D8E;
  margin-right: 4px;
}

.sidebar-calc-btn {
  background: linear-gradient(135deg, #2D2E5F, #1E9D8E) !important;
}

/* ── Grade Tracker Carousel ── */
.grade-carousel-shell {
  display: flex;
  align-items: center;
  gap: 4px;
}

.grade-carousel-viewport {
  position: relative;
  min-height: 96px;
  flex: 1;
  min-width: 0;
}

.grade-carousel-slide {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 6px 0;
  animation: gradeCarouselFadeIn 0.35s ease;
}

.grade-carousel-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.grade-carousel-data {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-align: center;
}

.grade-carousel-body {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.grade-carousel-metrics {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.grade-carousel-cefr {
  font-size: 3.2rem;
  font-weight: 900;
  font-family: 'Nunito', sans-serif;
  line-height: 0.95;
  text-align: center;
}

.grade-carousel-raw {
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  color: #94a3b8;
}

.grade-carousel-skill {
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 2px;
}

.grade-carousel-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 8px;
}

.grade-carousel-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d1d5db;
  transition: background 0.3s, transform 0.3s;
}

.grade-carousel-dot.active {
  background: #1cb0f6;
  transform: scale(1.3);
}

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

/* Level subpage header */
.subpage-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  padding: 0 4px;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
}

.subpage-title {
  font-family: 'Nunito', sans-serif;
  font-size: 1.75rem;
  font-weight: 800;
  text-transform: none;
  letter-spacing: 0;
  color: #3c3c3c;
}

.subpage-subtitle {
  font-family: 'Nunito', sans-serif;
  font-size: 0.92rem;
  font-weight: 600;
  color: #777;
}

.subpage-back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 40px;
  border: 2px solid rgba(45, 46, 95, 0.12);
  background: rgba(45, 46, 95, 0.04);
  color: var(--text-medium);
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.25s;
  flex-shrink: 0;
  white-space: nowrap;
}

.subpage-back-btn .material-symbols-outlined {
  font-size: 1.2rem;
  line-height: 1;
}

.subpage-back-btn:hover {
  background: rgba(45, 46, 95, 0.08);
  border-color: rgba(45, 46, 95, 0.2);
  transform: translateY(-1px);
}

@media (max-width: 768px), (max-height: 520px) and (orientation: landscape) and (max-width: 1024px) {
  .subpage-back-btn {
    gap: 0;
    min-width: 42px;
    width: 42px;
    height: 42px;
    padding: 0;
    border-radius: 14px;
  }

  .subpage-back-btn .icon-btn-label {
    display: none;
  }

  .subpage-back-btn .material-symbols-outlined {
    font-size: 1.25rem;
  }
}

.subpage-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px 0 8px;
  border-top: 1px solid var(--border-light, #e5e7eb);
  margin-top: 8px;
  flex-wrap: wrap;
}

.pagination-btn {
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border: 2px solid var(--border-light, #e5e7eb);
  background: var(--white);
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-medium);
  cursor: pointer;
  transition: all 0.2s;
}

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

.pagination-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ── Level Selector Widget ── */
.level-selector-widget {
  padding: 0 !important;
  overflow: hidden;
}

.level-selector-current {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px;
  background: #f7f7f7;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.2s;
  position: relative;
}

.level-selector-current:hover {
  background: #eff0f0;
}

.level-selector-current-icon {
  font-size: 2rem;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1cb0f6;
  color: white;
  border-radius: 14px;
  flex-shrink: 0;
}

.level-selector-current-code {
  font-size: 1.6rem;
  font-weight: 800;
  color: #3c3c3c;
  line-height: 1.1;
}

.level-selector-current-label {
  font-size: 0.82rem;
  color: #64748b;
  font-weight: 500;
}

.level-selector-chevron {
  margin-left: auto;
  color: #2D2E5F;
  font-size: 0.9rem;
  transition: transform 0.3s ease;
}

.level-selector-current[aria-expanded="true"] .level-selector-chevron {
  transform: rotate(180deg);
}

.level-selector-hint {
  font-size: 0.7rem;
  color: #94a3b8;
  text-align: center;
  padding: 4px 0 0;
  letter-spacing: 0.02em;
}

.level-selector-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 14px 14px;
  margin-top: 4px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 14px;
  backdrop-filter: blur(8px);
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.3s ease,
              padding 0.3s ease,
              margin 0.3s ease;
  overflow: hidden;
}

.level-selector-changing-to {
  font-size: 0.72rem;
  font-weight: 700;
  color: #5a7a9a;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: center;
  margin-bottom: 6px;
}

.level-selector-carousel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.level-selector-carousel .sidebar-level-badge {
  margin-bottom: 0;
  flex: 1;
}

.level-selector-arrow {
  background: none;
  border: none;
  cursor: pointer;
  color: #5a7a9a;
  padding: 4px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.level-selector-arrow:hover {
  background: rgba(45, 46, 95, 0.1);
  color: #2D2E5F;
}

.level-selector-arrow .material-symbols-outlined {
  font-size: 1.6rem;
}

.level-selector-preview-badge {
  transition: background 0.2s, color 0.2s;
}

.level-selector-options.level-selector-collapsed {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin-top: 0;
}

.level-selector-options.level-selector-expanded {
  max-height: 300px;
  opacity: 1;
}

.level-selector-option {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1.5px solid rgba(45, 46, 95, 0.10);
  background: rgba(45, 46, 95, 0.03);
  color: var(--text-medium);
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
}

.level-selector-option i {
  width: 20px;
  text-align: center;
  font-size: 0.85rem;
  color: #2D2E5F;
  opacity: 0.7;
}

.level-selector-option:hover {
  background: rgba(45, 46, 95, 0.09);
  border-color: rgba(45, 46, 95, 0.22);
  transform: translateX(3px);
}

.level-selector-option:active {
  transform: translateX(1px) scale(0.98);
}

.level-selector-option.level-selector-active {
  background: #ddf4ff;
  color: #1899d6;
  border-color: #84d8ff;
  box-shadow: 0 2px 8px rgba(28, 176, 246, 0.15);
}

.level-selector-option.level-selector-active i {
  color: #1899d6;
  opacity: 1;
}



/* ── Guest locked section ─────────────────────────────────────────────── */
.exam-section.guest-locked {
  position: relative;
  opacity: 0.55;
  pointer-events: none;
  user-select: none;
}
.exam-section.guest-locked::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 12px;
  pointer-events: all;
  cursor: pointer;
  z-index: 2;
}
.guest-locked-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #b45309;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 50px;
  padding: 3px 10px;
  margin-left: 8px;
  vertical-align: middle;
}
.guest-locked-badge i {
  font-size: 0.68rem;
}

/* ── Guest exam locked overlay (non-first exams) ──────────────────────── */
.exam-item.guest-exam-locked {
  position: relative;
  opacity: 0.45;
  pointer-events: none;
}
.exam-item.guest-exam-locked::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: all;
  cursor: pointer;
  z-index: 2;
}

/* ── Premium upgrade banner ───────────────────────────────────────────── */
.premium-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 1px solid #fde68a;
  border-radius: 16px;
  padding: 18px 22px;
  margin-bottom: 20px;
}
.premium-banner-icon {
  font-size: 2rem;
  flex-shrink: 0;
}
.premium-banner-text {
  flex: 1;
  min-width: 0;
}
.premium-banner-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 3px;
}
.premium-banner-desc {
  font-size: 0.82rem;
  color: var(--text-medium);
  line-height: 1.4;
}
.premium-banner-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  border: none;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.25);
  white-space: nowrap;
}
.premium-banner-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.35);
}
.premium-banner-btn i {
  font-size: 0.8rem;
}

/* ── Sign-in prompt modal (guest gate) ────────────────────────────────── */
.guest-gate-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(45, 46, 95, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}
.guest-gate-card {
  background: #fff;
  border-radius: 20px;
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  margin: 16px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(45, 46, 95, 0.15);
  animation: authCardIn 0.3s cubic-bezier(0.34,1.56,0.64,1) both;
}
.guest-gate-card .guest-gate-icon {
  font-size: 2.4rem;
  margin-bottom: 12px;
}
.guest-gate-card h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-dark);
  margin: 0 0 8px;
}
.guest-gate-card p {
  font-size: 0.88rem;
  color: var(--text-medium);
  margin: 0 0 24px;
  line-height: 1.5;
}
.guest-gate-btns {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.guest-gate-btns .btn-gate-signin {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 50px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.guest-gate-btns .btn-gate-signin:hover {
  background: var(--secondary);
  transform: translateY(-1px);
}
.guest-gate-btns .btn-gate-close {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  background: transparent;
  color: var(--text-light);
  border: 1px solid #e2e8f0;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.guest-gate-btns .btn-gate-close:hover {
  background: #f8fafc;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Subpage view toggle (By Test / By Exercise Type) ─────────────────── */
.subpage-view-toggle {
  display: flex;
  gap: 4px;
  justify-content: center;
  align-items: stretch;
  background: rgba(45, 46, 95, 0.04);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 20px;
  border: 1px solid rgba(45, 46, 95, 0.06);
}

.subpage-view-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  border: none;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  background: transparent;
  color: var(--text-medium);
}

.subpage-view-btn:hover {
  background: rgba(255, 255, 255, 0.5);
}

.subpage-view-btn.active {
  background: var(--white);
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ── Section type tiles ───────────────────────────────────────────────── */
.section-type-tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.section-type-tile {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px 20px;
  background: var(--white);
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: all 0.22s;
  border: 2px solid transparent;
  position: relative;
  overflow: hidden;
}

.section-type-tile:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.section-type-tile-icon {
  font-size: 2rem !important;
  color: white !important;
  padding: 14px;
  border-radius: 16px;
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.section-type-tile.reading .section-type-tile-icon {
  background: linear-gradient(135deg, #b39ddb 0%, #ce93d8 100%);
  box-shadow: 0 4px 12px rgba(179, 157, 219, 0.4);
}

.section-type-tile.listening .section-type-tile-icon {
  background: linear-gradient(135deg, #ffcc80 0%, #ffab91 100%);
  box-shadow: 0 4px 12px rgba(255, 204, 128, 0.4);
}

.section-type-tile.writing .section-type-tile-icon {
  background: linear-gradient(135deg, #a5d6a7 0%, #81c784 100%);
  box-shadow: 0 4px 12px rgba(165, 214, 167, 0.4);
}

.section-type-tile.speaking .section-type-tile-icon {
  background: linear-gradient(135deg, #f48fb1 0%, #ef9a9a 100%);
  box-shadow: 0 4px 12px rgba(244, 143, 177, 0.4);
}

.section-type-tile-label {
  font-family: 'Mileast', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-dark);
  flex: 1;
}

.section-type-tile-arrow {
  font-size: 0.9rem;
  color: var(--text-light);
  transition: transform 0.2s;
}

.section-type-tile:hover .section-type-tile-arrow {
  transform: translateX(4px);
  color: var(--primary);
}

/* ── Section exercise list header (back btn + icon + title) ───────────── */
.section-ex-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
}

.section-ex-back-btn {
  background: rgba(45, 46, 95, 0.06);
  border: none;
  color: var(--text-medium);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
  flex-shrink: 0;
}

.section-ex-back-btn:hover {
  background: rgba(45, 46, 95, 0.12);
  color: var(--primary);
}

.section-ex-title {
  font-family: 'Mileast', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-dark);
  text-transform: none;
  letter-spacing: 0.03em;
}

/* ── Section exercise item (compact, single-section card) ─────────────── */
.section-ex-item {
  box-shadow: var(--shadow-sm);
}

.section-ex-item-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px 8px;
}

.section-ex-item-info {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.section-ex-item .section-parts {
  padding: 0 20px 14px;
}

@media (max-width: 540px) {
  .mode-toggle,
  .subpage-view-toggle {
    justify-content: center;
    flex-wrap: wrap;
    overflow-x: visible;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
  }

  .mode-btn,
  .subpage-view-btn {
    flex: 1 1 auto;
    min-width: min(160px, 46vw);
    max-width: 100%;
    padding: 10px 14px;
  }

  .subpage-header {
    align-items: flex-start;
    gap: 10px;
  }

  .subpage-title {
    font-size: 1.2rem;
  }

  .exam-header {
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
  }

  .exam-header-left {
    min-width: 0;
    gap: 12px;
  }

  .exam-number {
    font-size: 1.35rem;
  }

  .exam-number-random {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 14px;
  }

  .random-test-icon {
    font-size: 1.15rem !important;
  }

  .random-test-pill {
    margin-left: 6px;
    font-size: 0.58rem;
  }

  .random-test-empty {
    padding: 22px 16px;
    font-size: 0.85rem;
  }

  .exam-title {
    font-size: 1.05rem;
  }

  .exam-subtitle {
    font-size: 0.82rem;
  }

  .exam-progress-badge {
    align-self: stretch;
    justify-content: center;
    font-size: 0.78rem;
    padding: 5px 8px;
  }

  .exam-content.show {
    padding: 14px;
  }

  .exam-section {
    padding: 16px;
    padding-top: 12px;
  }

  .section-header {
    align-items: flex-start;
    gap: 10px;
  }

  .section-header h4 {
    font-size: 1rem;
  }

  .section-parts {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
  }

  .part-number {
    width: 32px;
    height: 32px;
    min-width: 32px;
    font-size: 0.85rem;
    border-radius: 10px;
  }

  .section-progress {
    width: 100%;
    margin-left: 0;
  }

  .section-ex-item-header {
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 10px 14px 8px;
  }

  .section-ex-item-info {
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    flex: 1;
    min-width: 0;
    gap: 8px;
  }

  .section-ex-item .exam-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.98rem;
  }

  .section-ex-item .section-progress {
    width: auto;
    flex-shrink: 0;
    font-size: 0.82rem;
    white-space: nowrap;
  }

  .section-ex-item .exam-number {
    flex-shrink: 0;
  }

  .section-ex-item .section-play,
  .section-ex-item .section-results-btn {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    min-height: 36px !important;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .exam-section .section-header {
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
  }

  .exam-section .section-header h4 {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.25;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .exam-section .section-header .section-progress {
    width: auto;
    flex-shrink: 0;
    margin-left: 0;
    white-space: nowrap;
    font-size: 0.78rem;
  }

  .exam-section .section-play,
  .exam-section .section-results-btn {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    min-height: 34px !important;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .section-ex-item .section-parts {
    padding: 0 14px 14px;
  }

  .section-type-tiles {
    grid-template-columns: 1fr;
  }
}

/* ── Mixed-test badge (shown in exercise header) ── */
.mixed-mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 12px;
  font-family: 'Fredoka', 'Nunito', sans-serif;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-left: 8px;
  vertical-align: middle;
  white-space: nowrap;
  border: 2px solid transparent;
  background: #e0f2fe;
  color: #0369a1;
  border-color: #1cb0f6;
  box-shadow: 0 2px 0 #1899d6;
}

.mixed-mode-badge .material-symbols-outlined {
  font-size: 0.95rem;
}

.mixed-mode-badge--simulation {
  background: #f3e8ff;
  color: #6b21a8;
  border-color: #ce82ff;
  box-shadow: 0 2px 0 #a855f7;
}

/* ── Mixed-test progress bar (exercise-info row) ── */
.mixed-progress-bar {
  position: relative;
  height: 22px;
  background: #e0e8f8;
  border-radius: 12px;
  overflow: hidden;
  min-width: 140px;
  max-width: 320px;
  flex: 1;
}

.mixed-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #8b5cf6);
  border-radius: 12px;
  transition: width 0.3s ease;
}

.mixed-progress-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: #1e293b;
  padding: 0 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Mixed-test finish screen ── */
.mixed-test-finish {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  padding: 40px 24px;
  gap: 16px;
}

.mixed-test-finish-icon .material-symbols-outlined {
  font-size: 4rem;
  color: #8b5cf6;
}

.mixed-test-finish h2 {
  font-size: 2rem;
  font-weight: 800;
  color: #1e293b;
  margin: 0;
}

.mixed-test-finish p {
  color: #475569;
  font-size: 1rem;
  line-height: 1.6;
  margin: 0;
}

.mixed-test-finish-btns {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 8px;
}

.btn-mixed-again,
.btn-mixed-home {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-mixed-again {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: white;
}

.btn-mixed-home {
  background: #f1f5f9;
  color: #334155;
}

.btn-mixed-again:hover,
.btn-mixed-home:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

@media (max-width: 768px), (max-height: 520px) and (orientation: landscape) and (max-width: 1024px) {
  .btn-mixed-home .icon-btn-label {
    display: none;
  }
}

/* ── Random Test card ── */
.random-test-item .exam-header {
  background: linear-gradient(135deg, #e8eeff 0%, #e4e0f8 55%, #ebe4ff 100%);
}

.random-test-item.guest-exam-locked .exam-header {
  background: linear-gradient(135deg, #e8f0ff 0%, #d8d0f0 100%);
}

.exam-number-random {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  min-width: 52px;
  border-radius: 16px;
  font-size: 0;
  opacity: 1;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.28);
}

.random-test-icon {
  font-size: 1.35rem !important;
  line-height: 1;
  color: #fff;
}

.random-test-pill {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.14);
  color: #4f46e5;
  font-family: 'Nunito', sans-serif;
  font-size: 0.62rem;
  font-weight: 800;
  font-style: normal;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: middle;
}

.random-test-lock-icon {
  margin-right: 4px;
  font-size: 0.75rem;
}

.random-test-progress-badge {
  background: rgba(99, 102, 241, 0.12);
  color: #4338ca;
}

.random-test-item .random-test-btn-generate {
  background: rgba(99, 102, 241, 0.14);
  color: #4f46e5;
}

.random-test-item .random-test-btn-generate:hover {
  background: rgba(99, 102, 241, 0.26);
}

.random-test-item .random-test-btn-repeat {
  background: rgba(45, 46, 95, 0.08);
  color: #2D2E5F;
}

.random-test-item .random-test-btn-repeat:hover {
  background: rgba(45, 46, 95, 0.16);
}

.random-test-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 28px 24px;
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  color: #64748b;
  font-size: 0.92rem;
  text-align: center;
}

.random-test-empty-icon {
  font-size: 1.75rem !important;
  color: #a5b4fc;
}

.random-test-empty p {
  margin: 0;
  max-width: 28ch;
  line-height: 1.45;
  font-style: italic;
}

.random-test-empty strong {
  color: #4f46e5;
  font-weight: 700;
  font-style: normal;
}

@media (max-width: 768px), (max-height: 520px) and (orientation: landscape) and (max-width: 1024px) {
  .section-icon {
    width: 26px;
    height: 26px;
    min-height: 26px !important;
    padding: 4px;
    border-radius: 9px;
    font-size: 0.92rem !important;
  }

  .exam-section .section-parts,
  .section-ex-item .section-parts {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
  }

  .exam-section .part-number,
  .section-ex-item .part-number {
    width: 32px;
    height: 32px;
    min-width: 32px;
    font-size: 0.85rem;
    border-radius: 10px;
  }

  .exam-section {
    padding-top: 12px;
  }

  .section-type-tile {
    background: transparent;
    box-shadow: none;
    border: 1px solid rgba(45, 46, 95, 0.1);
    min-height: 68px;
    justify-content: center;
    padding: 10px 8px;
    border-radius: 18px;
  }

  .section-type-tiles {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
  }

  .section-type-tile-icon {
    width: 46px;
    height: 46px;
    min-height: 46px !important;
    padding: 10px;
    border-radius: 15px;
    font-size: 1.55rem !important;
  }

  .section-type-tile-label,
  .section-type-tile-arrow {
    display: none;
  }

  .section-ex-title {
    flex: 1;
    min-width: 0;
    font-size: 1.05rem;
    line-height: 1.2;
  }

  .section-ex-header {
    gap: 8px;
    padding: 10px;
  }

  .subpage-pagination {
    position: sticky;
    bottom: max(8px, env(safe-area-inset-bottom));
    z-index: 20;
    justify-content: flex-start;
    flex-wrap: nowrap;
    gap: 6px;
    margin: 8px auto 0;
    padding: 8px;
    max-width: 100%;
    overflow-x: auto;
    border: 1px solid rgba(45, 46, 95, 0.08);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 8px 24px rgba(45, 46, 95, 0.12);
    -webkit-overflow-scrolling: touch;
  }

  .pagination-btn {
    flex: 0 0 auto;
    min-width: 34px;
    width: 34px;
    height: 34px;
    min-height: 34px !important;
    padding: 0;
    border-radius: 50%;
    font-size: 0.82rem;
  }
}

@media (max-width: 540px) {
  .section-type-tiles {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 768px), (max-height: 520px) and (orientation: landscape) and (max-width: 1024px) {
  .dashboard-layout .dashboard-center--subpage:has(.mobile-bottom-nav--duo) {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }

  .dashboard-layout .dashboard-center--subpage:not(:has(.mobile-bottom-nav--duo)) {
    padding-bottom: calc(52px + env(safe-area-inset-bottom));
  }

  .dashboard-center--subpage:has(.mobile-bottom-nav--duo) .subpage-pagination {
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }

  .dashboard-center--subpage:not(:has(.mobile-bottom-nav--duo)) .subpage-pagination {
    bottom: calc(52px + env(safe-area-inset-bottom));
  }
}

/* ── Test exercise 3-column layout (nav + exercise + tools) ───────────── */

.dashboard-layout--exercise {
  align-items: stretch;
}

.dashboard-center--exercise {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

.dashboard-center--exercise .exercise-page-wrapper {
  width: 100%;
}

.dashboard-center--exercise .exercise-container {
  margin-bottom: 0;
}

.exercise-tools-sidebar-wrap {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.exercise-tools-sidebar-wrap--mobile {
  display: none;
}

.exercise-bottom-stack {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin-top: 28px;
}

@media (min-width: 769px) {
  .exercise-tools-sidebar-wrap--mobile {
    display: none !important;
  }

  /* Pin footer to viewport bottom; horizontal bounds synced to dashboard-center--exercise via JS */
  .dashboard-layout--exercise .exercise-bottom-stack {
    position: fixed;
    bottom: 0;
    left: 0;
    right: auto;
    width: 100%;
    max-width: none;
    margin: 0;
    z-index: 120;
    gap: 0;
    padding: 0 0 calc(16px + env(safe-area-inset-bottom));
    box-sizing: border-box;
    pointer-events: none;
  }

  .dashboard-layout--exercise .exercise-bottom-stack .exercise-footer {
    pointer-events: auto;
  }
}

@media (min-width: 901px) {
  .dashboard-layout--exercise:not(.dashboard-layout-right-closed) {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--dashboard-exercise-tools-gap, 16px);
    padding-right: calc(var(--dashboard-exercise-tools-width, 340px) + var(--dashboard-exercise-tools-gap, 16px));
    padding-bottom: 48px;
  }

  .dashboard-layout--exercise:not(.dashboard-layout-right-closed) .dashboard-center,
  .dashboard-layout--exercise:not(.dashboard-layout-right-closed) .dashboard-center--exercise {
    margin-left: 0;
    padding-right: 0;
    padding-left: 8px;
    width: 100%;
    max-width: none;
  }

  .dashboard-layout--exercise:not(.dashboard-layout-right-closed) > .dashboard-right-sidebar,
  .dashboard-layout--exercise:not(.dashboard-layout-right-closed) > .dashboard-right-sidebar.dashboard-sidebar-shell,
  .dashboard-layout--exercise:not(.dashboard-layout-right-closed) .dashboard-right-sidebar--tools,
  .dashboard-layout--exercise:not(.dashboard-layout-right-closed) #dashboardRightSidebarTools {
    position: fixed;
    right: 0;
    top: 0;
    height: 100vh;
    width: var(--dashboard-exercise-tools-width, 340px);
    min-width: var(--dashboard-exercise-tools-min-width, 320px);
    padding-left: 0;
    padding-right: 0;
    overflow-y: auto;
    z-index: 50;
    background: transparent;
    padding-top: var(--dashboard-top-spacing, 28px);
    box-sizing: border-box;
    align-self: auto;
    max-height: none;
    border-left: none;
    box-shadow: none;
  }

  .dashboard-layout--exercise:not(.dashboard-layout-right-closed) .exercise-tools-sidebar-wrap--desktop {
    position: fixed;
    right: 0;
    top: 0;
    height: 100vh;
    width: var(--dashboard-exercise-tools-width, 340px);
    min-width: var(--dashboard-exercise-tools-min-width, 320px);
    padding-left: 0;
    padding-right: 0;
    overflow-y: auto;
    z-index: 50;
    background: var(--dashboard-exercise-tools-bg, #fff4e5);
    padding-top: var(--dashboard-top-spacing, 28px);
    box-sizing: border-box;
    border-left: none;
    box-shadow: inset 1px 0 0 rgba(255, 150, 0, 0.12);
    min-height: calc(100vh - var(--dashboard-top-spacing, 28px) - 24px);
  }

  .dashboard-layout--exercise .exercise-tools-sidebar-wrap--desktop .tools-sidebar--right-column {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0 16px 20px;
    box-sizing: border-box;
    min-height: calc(100vh - var(--dashboard-top-spacing, 28px) - 24px);
  }
}

@media (max-width: 768px), (max-height: 520px) and (orientation: landscape) and (max-width: 1024px) {
  .exercise-tools-sidebar-wrap--desktop {
    display: none !important;
  }

  .dashboard-layout--exercise .exercise-bottom-stack {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: none;
    margin: 0;
    z-index: 140;
    gap: 0;
  }

  .dashboard-layout--exercise .exercise-tools-sidebar-wrap--mobile {
    width: 100%;
    max-width: none;
    min-width: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    box-sizing: border-box;
    background: #fff;
    border: 2px solid var(--ex-duo-orange, #f47417);
    border-top: 4px solid var(--ex-duo-orange, #f47417);
    border-bottom: none;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -3px 0 color-mix(in srgb, var(--ex-duo-orange-dark, #d45f0a) 35%, #e5e5e5);
  }

  .dashboard-layout--exercise .exercise-tools-sidebar-wrap--mobile.is-open {
    display: block;
  }
}

/* Tests hub: use wider max-width on tablets/large phones to fill the screen better */
@media (min-width: 431px) and (max-width: 768px) {
  .dashboard-center--tests-hub {
    max-width: 100%;
  }
}

/* Mobile subpage header improvements for tests hub */
@media (max-width: 768px) {
  .dashboard-center--tests-hub .cw-section-header {
    padding: 12px 14px;
    gap: 8px;
    border-radius: 16px;
    justify-content: space-between;
    text-align: left;
  }

  .dashboard-center--tests-hub .cw-section-header-text {
    flex: 1;
    min-width: 0;
    width: auto;
    padding: 0;
    text-align: left;
  }

  .dashboard-center--tests-hub .cw-section-header--level .cw-section-header-text {
    padding-left: 48px;
  }

  .dashboard-center--tests-hub .cw-section-title {
    font-size: 1rem;
    text-align: left;
  }

  .tests-sections-container,
  .tests-path-map {
    padding-bottom: 20px;
  }
}
