/* ----- Змінні теми ----- */
:root {
  --nmt-bg: #f0f4f8;
  --nmt-surface: #ffffff;
  --nmt-border: #e2e8f0;
  --nmt-text: #1e293b;
  --nmt-text-muted: #64748b;
  --nmt-primary: #0f766e;
  --nmt-primary-hover: #0d9488;
  --nmt-primary-light: #ccfbf1;
  --nmt-accent: #0d9488;
  --nmt-shadow: 0 2px 12px rgba(15, 118, 110, 0.08);
  --nmt-card-radius: 14px;
}
body.theme-dark {
  --nmt-bg: #1e293b;
  --nmt-surface: #334155;
  --nmt-border: #475569;
  --nmt-text: #f1f5f9;
  --nmt-text-muted: #94a3b8;
  --nmt-primary: #2dd4bf;
  --nmt-primary-hover: #5eead4;
  --nmt-primary-light: #134e4a;
  --nmt-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}
body.theme-dark .header-text h1,
body.theme-dark .header-text p,
body.theme-dark .header-subtitle,
body.theme-dark .start-back-link,
body.theme-dark .choice-panel-title,
body.theme-dark .choice-panel-desc { color: var(--nmt-text); }
body.theme-dark .info-link { background: var(--nmt-border); color: var(--nmt-text); }
body.theme-dark .info-link:hover { background: #5e7289; color: var(--nmt-text); }
body.theme-dark .btn-secondary { background: var(--nmt-border); color: var(--nmt-text); }
body.theme-dark .btn-secondary:hover { background: #5e7289; }

body.theme-contrast {
  --nmt-bg: #ffffff;
  --nmt-surface: #ffffff;
  --nmt-border: #000000;
  --nmt-text: #000000;
  --nmt-text-muted: #1a1a1a;
  --nmt-primary: #000000;
  --nmt-primary-hover: #333333;
  --nmt-primary-light: #e6e6e6;
  --nmt-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
body.theme-contrast .btn-primary { color: #fff; background: #000; border-color: #000; }
body.theme-contrast .header-logo { background: #000; color: #fff; }
body.theme-contrast .info-link { background: #fff; color: #000; border: 2px solid #000; }
body.theme-contrast .info-link:hover { background: #e6e6e6; color: #000; }
body.theme-contrast .btn-secondary { background: #fff; color: #000; border: 2px solid #000; }
body.theme-contrast .btn-secondary:hover { background: #e6e6e6; }

body.font-large {
  font-size: 1.125rem;
}

/* ----- Базові стилі ----- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--nmt-text);
  background: var(--nmt-bg);
}

body {
  line-height: 1.55;
}

.app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 32px 40px;
}

.hidden {
  display: none !important;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 100;
  padding-top: 40px;
  overflow-y: auto;
}
.report-option {
  display: block;
  margin: 8px 0;
  cursor: pointer;
  font-size: 0.95rem;
}
.report-option input { margin-right: 8px; }

.card {
  background: var(--nmt-surface);
  border-radius: var(--nmt-card-radius);
  padding: 24px 26px;
  box-shadow: var(--nmt-shadow);
  border: 1px solid var(--nmt-border);
}

.muted {
  color: var(--nmt-text-muted);
  font-size: 0.94rem;
}

/* ----- Шапка ----- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 24px;
  margin-bottom: 24px;
  border-radius: var(--nmt-card-radius);
  background: var(--nmt-surface);
  border: 1px solid var(--nmt-border);
  box-shadow: var(--nmt-shadow);
}

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

.header-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--nmt-primary) 0%, #0d9488 100%);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.15s;
}
.header-logo:hover {
  opacity: 0.9;
  transform: scale(1.03);
}
.header-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.header-nav .info-link,
.header-nav .btn { margin: 0; }

.herb-wrap {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.herb-img {
  display: block;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
}

.header-text {
  flex: 1;
  min-width: 0;
}

.header-text h1 {
  margin: 0 0 6px 0;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--nmt-text);
  line-height: 1.35;
}

.header-subtitle {
  margin: 0 0 4px 0;
  font-size: 0.9rem;
  color: var(--nmt-text-muted);
}

.herb-credit {
  margin: 0;
  font-size: 0.75rem;
}

.herb-credit a {
  color: #6b7a8c;
  text-decoration: none;
}

.herb-credit a:hover {
  text-decoration: underline;
  color: #4a5568;
}

.header-right {
  flex-shrink: 0;
}

.info-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--nmt-primary-light);
  color: var(--nmt-primary);
  text-decoration: none;
  font-size: 0.9rem;
  transition: background 0.2s ease, color 0.2s ease;
}

.info-link:hover {
  background: var(--nmt-border);
  color: var(--nmt-text);
}

.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
}
.info-icon svg {
  color: currentColor;
  width: 100%;
  height: 100%;
}

/* Під час тесту верхня панель без кнопок (Вчитель/Адмін) */
body.test-active .app-header .header-right {
  display: none !important;
}

.info-text {
  white-space: nowrap;
}

/* ----- Екран вибору (дві панелі на весь екран) ----- */
.choice-screen {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  min-height: 0;
  align-content: start;
}

#choice-cards-wrap {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  width: 100%;
}

.choice-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 32px;
  border-radius: 16px;
  text-decoration: none;
  color: inherit;
  border: 2px solid transparent;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  min-height: 280px;
}

.choice-panel:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
}

.choice-panel-personal {
  background: linear-gradient(160deg, #f0f9ff 0%, #e0f2fe 100%);
  border-color: #bae6fd;
}

.choice-panel-personal:hover {
  border-color: #0ea5e9;
}

.choice-panel-school {
  background: linear-gradient(160deg, #fefce8 0%, #fef9c3 100%);
  border-color: #fde047;
}

.choice-panel-school:hover {
  border-color: #eab308;
}

.choice-panel-disabled {
  cursor: default;
  opacity: 0.85;
  pointer-events: none;
}
.choice-panel-disabled:hover {
  transform: none;
  box-shadow: none;
}
.choice-panel-personal.choice-panel-disabled {
  background: linear-gradient(160deg, #f1f5f9 0%, #e2e8f0 100%);
  border-color: #cbd5e1;
}
.choice-panel-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--nmt-text-muted);
  background: #e2e8f0;
  padding: 4px 10px;
  border-radius: 999px;
}

.choice-panel-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  line-height: 1;
}

.choice-panel-title {
  margin: 0 0 12px 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--nmt-text);
}

.choice-panel-desc {
  margin: 0;
  font-size: 0.95rem;
  color: var(--nmt-text-muted);
  line-height: 1.5;
  max-width: 320px;
}

/* ----- Dashboard (залогінений користувач) ----- */
.dashboard-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  align-items: start;
  width: 100%;
  box-sizing: border-box;
  grid-column: 1 / -1; /* на всю ширину батька .choice-screen */
}
.dashboard-main {
  min-width: 0;
  overflow: visible;
}
.dashboard-header {
  margin-bottom: 20px;
}
.dashboard-welcome {
  margin: 0 0 6px 0;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--nmt-text);
  letter-spacing: -0.02em;
}
.dashboard-welcome span {
  color: var(--nmt-primary);
}
.dashboard-sub {
  margin: 0;
  font-size: 1rem;
  color: var(--nmt-text-muted);
}
.dashboard-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin-bottom: 16px;
}
.dashboard-filter-label {
  font-size: 0.9rem;
  color: var(--nmt-text-muted);
  font-weight: 500;
}
.dashboard-filter-select {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--nmt-border);
  background: var(--nmt-surface);
  color: var(--nmt-text);
  font-size: 0.9rem;
  cursor: pointer;
}
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  min-width: 0;
  background: var(--nmt-surface);
  border-radius: var(--nmt-card-radius);
  padding: 16px 12px;
  border: 1px solid var(--nmt-border);
  box-shadow: var(--nmt-shadow);
  text-align: center;
  transition: box-shadow 0.2s, transform 0.2s;
}
.stat-card:hover {
  box-shadow: 0 6px 20px rgba(15, 118, 110, 0.12);
  transform: translateY(-2px);
}
.stat-card-highlight {
  border-color: var(--nmt-primary);
  background: linear-gradient(180deg, var(--nmt-primary-light) 0%, var(--nmt-surface) 100%);
}
.stat-value {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--nmt-text);
  line-height: 1.2;
}
.stat-card-highlight .stat-value {
  color: var(--nmt-primary);
}
.stat-label {
  display: block;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--nmt-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Заблокована статистика (превʼю без Ультра-преміум) — сірий вигляд і CTA */
.dashboard-stats.is-locked,
.dashboard-section.is-locked,
.dashboard-chart-card.is-locked {
  opacity: 0.72;
  position: relative;
  filter: saturate(0.65);
}
.dashboard-stats.is-locked .stat-card,
.dashboard-chart-card.is-locked .dashboard-chart-value {
  color: var(--nmt-text-muted);
}
.dashboard-stats.is-locked .stat-card-highlight .stat-value {
  color: var(--nmt-text-muted);
}
.dashboard-stats.is-locked .stat-card:hover,
.dashboard-chart-card.is-locked:hover {
  transform: none;
  box-shadow: var(--nmt-shadow);
}
.dashboard-stats-ultra-cta {
  margin: -8px 0 20px 0;
  padding: 12px 16px;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--nmt-text-muted);
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.06) 0%, rgba(15, 118, 110, 0.02) 100%);
  border: 1px dashed var(--nmt-primary);
  border-radius: var(--nmt-card-radius);
}
.dashboard-stats-ultra-cta .stats-ultra-cta-text {
  display: inline;
}
.dashboard-stats-ultra-cta .stats-ultra-cta-link {
  display: inline-block;
  margin-left: 6px;
  font-weight: 600;
  color: var(--nmt-primary);
  text-decoration: none;
}
.dashboard-stats-ultra-cta .stats-ultra-cta-link:hover {
  text-decoration: underline;
}
.dashboard-stats-locked-msg {
  margin: 12px 0 0 0;
  font-size: 0.9rem;
  color: var(--nmt-text-muted);
  line-height: 1.45;
}
.dashboard-stats-locked-msg a {
  font-weight: 600;
  color: var(--nmt-primary);
  text-decoration: none;
}
.dashboard-stats-locked-msg a:hover {
  text-decoration: underline;
}

.dashboard-sidebar-cta {
  margin-bottom: 20px;
}
.dashboard-email-msg {
  margin: 0 0 10px 0;
  padding: 10px 12px;
  font-size: 0.9rem;
  line-height: 1.4;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 8px;
  color: #92400e;
}
.dashboard-email-msg a {
  color: #b45309;
  text-decoration: underline;
}
.btn-dashboard-cta-large:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}
.btn-dashboard-cta-large {
  width: 100%;
  padding: 18px 24px;
  font-size: 1.2rem;
  font-weight: 600;
  border-radius: 12px;
  background: var(--nmt-primary);
  border-color: var(--nmt-primary);
  box-shadow: 0 4px 14px rgba(15, 118, 110, 0.35);
  cursor: pointer;
}
.btn-dashboard-cta-large:hover {
  background: var(--nmt-primary-hover);
  border-color: var(--nmt-primary-hover);
}
/* Кнопка «Вийти» — характерний колір на всіх сторінках */
.btn-logout {
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 500;
  background: transparent;
  border: 1px solid #b91c1c;
  color: #b91c1c;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.btn-logout:hover {
  background: #b91c1c;
  color: #fff;
  border-color: #b91c1c;
}
body.theme-dark .btn-logout {
  border-color: #f87171;
  color: #f87171;
}
body.theme-dark .btn-logout:hover {
  background: #f87171;
  color: #1e293b;
  border-color: #f87171;
}
body.theme-contrast .btn-logout {
  border-color: #000;
  color: #000;
}
body.theme-contrast .btn-logout:hover {
  background: #000;
  color: #fff;
}
.header-right.header-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}
/* ── Messages widget ──────────────────────────────────── */
.header-msg-wrap {
  position: relative;
}
.header-msg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--nmt-text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  position: relative;
  flex-shrink: 0;
}
.header-msg-btn:hover { background: var(--nmt-hover, #f1f5f9); color: var(--nmt-text); }
.header-msg-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  pointer-events: none;
}
.header-msg-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 300px;
  background: var(--nmt-surface);
  border: 1px solid var(--nmt-border);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.12);
  z-index: 500;
  overflow: hidden;
}
.msg-drop-head {
  padding: 12px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--nmt-text);
  border-bottom: 1px solid var(--nmt-border);
}
.msg-drop-list { max-height: 320px; overflow-y: auto; }
.msg-drop-empty { padding: 20px 16px; font-size: 0.85rem; color: var(--nmt-text-muted); text-align: center; }
.msg-drop-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.12s;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--nmt-border);
}
.msg-drop-item:last-child { border-bottom: none; }
.msg-drop-item:hover { background: var(--nmt-hover, #f8fafc); }
.msg-drop-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--nmt-primary, #0f766e);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.msg-drop-info { flex: 1; min-width: 0; }
.msg-drop-name { font-size: 0.88rem; font-weight: 600; color: var(--nmt-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-drop-preview { font-size: 0.8rem; color: var(--nmt-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.msg-drop-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; }
.msg-drop-unread { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: #ef4444; color: #fff; font-size: 0.72rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.msg-drop-time { font-size: 0.72rem; color: var(--nmt-text-muted); }
.msg-drop-footer {
  display: block;
  padding: 10px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--nmt-primary, #0f766e);
  text-align: center;
  text-decoration: none;
  border-top: 1px solid var(--nmt-border);
  transition: background 0.12s;
}
.msg-drop-footer:hover { background: var(--nmt-hover, #f8fafc); }
/* ──────────────────────────────────────────────────────── */
.header-streak {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 11px;
  border-radius: 20px;
  background: rgba(249, 115, 22, 0.12);
  color: #ea580c;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: default;
  user-select: none;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}
.header-streak .streak-fire { font-size: 1.05rem; line-height: 1; }
.header-streak.streak-30  { background: rgba(245, 158, 11, 0.14); color: #b45309; }
.header-streak.streak-60  { background: rgba(239, 68, 68, 0.12);  color: #dc2626; }
.header-streak.streak-90  { background: rgba(234, 179, 8, 0.16);  color: #92400e; }
.header-streak.streak-paused { background: rgba(100, 116, 139, 0.10); color: #64748b; }
.header-streak.streak-paused .streak-fire { filter: grayscale(1); opacity: 0.55; }
.dashboard-section {
  background: var(--nmt-surface);
  border-radius: var(--nmt-card-radius);
  padding: 24px;
  border: 1px solid var(--nmt-border);
  box-shadow: var(--nmt-shadow);
}
.dashboard-section-title {
  margin: 0 0 16px 0;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--nmt-text);
}
.dashboard-empty {
  margin: 0;
  padding: 24px;
  text-align: center;
  color: var(--nmt-text-muted);
  font-size: 0.95rem;
}
.dashboard-sidebar {
  position: sticky;
  top: 24px;
}
.dashboard-chart-card {
  background: var(--nmt-surface);
  border-radius: var(--nmt-card-radius);
  padding: 24px;
  border: 1px solid var(--nmt-border);
  box-shadow: var(--nmt-shadow);
  margin-bottom: 16px;
  text-align: center;
}
.dashboard-chart-title {
  margin: 0 0 16px 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--nmt-text);
}
.dashboard-chart-wrap {
  position: relative;
  width: 140px;
  height: 140px;
  margin: 0 auto 12px;
}
.dashboard-circle-chart {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.dashboard-circle-chart .chart-bg {
  stroke: var(--nmt-border);
}
.dashboard-circle-chart .chart-fill {
  stroke: var(--nmt-primary);
  stroke-linecap: round;
  transition: stroke-dasharray 0.6s ease;
}
.dashboard-chart-value {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--nmt-primary);
}
.dashboard-chart-caption {
  margin: 0;
  font-size: 0.85rem;
  color: var(--nmt-text-muted);
}
.dashboard-tip {
  padding: 16px;
}
.dashboard-tip-text {
  margin: 0;
  font-size: 0.9rem;
  color: var(--nmt-text-muted);
  line-height: 1.5;
}
.attempts-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.attempts-list .attempt-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 18px;
  background: var(--nmt-bg);
  border: 1px solid var(--nmt-border);
  border-radius: 12px;
  transition: background 0.15s, border-color 0.15s;
}
.attempts-list .attempt-item:hover {
  border-color: var(--nmt-primary);
}
.attempts-list .attempt-item .attempt-meta {
  font-size: 0.95rem;
  color: var(--nmt-text-muted);
}
.attempts-list .attempt-item .attempt-score {
  font-weight: 600;
  font-size: 1rem;
  color: var(--nmt-text);
}
.attempts-list .attempt-item .attempt-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--nmt-primary-light);
  color: var(--nmt-primary);
  margin-left: 8px;
}
@media (max-width: 900px) {
  .dashboard-layout {
    grid-template-columns: 1fr;
  }
  .dashboard-sidebar {
    order: -1;
    position: static;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
  .dashboard-tip { margin-bottom: 0; }
}
@media (max-width: 640px) {
  .dashboard-stats {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 600px) {
  .dashboard-sidebar { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .choice-screen {
    grid-template-columns: 1fr;
    min-height: auto;
    padding: 16px 0;
  }
  #choice-cards-wrap {
    grid-template-columns: 1fr;
  }
  .choice-panel {
    min-height: 220px;
    padding: 32px 24px;
  }
}

/* ----- Стартовий екран ----- */
.start-screen {
  max-width: 560px;
  margin: 0 auto;
}

.start-screen-back-wrap {
  margin: 0 0 16px 0;
}

.start-back-link {
  color: var(--nmt-text-muted);
  font-size: 0.9rem;
  text-decoration: none;
}

.start-back-link:hover {
  color: #475569;
  text-decoration: underline;
}

.start-screen h2 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--nmt-text);
}

.field-label {
  display: block;
  margin-top: 20px;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--nmt-text-muted);
}

.text-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #d0d5dc;
  font-size: 1rem;
  background: #fff;
  transition: border-color 0.15s ease;
}

.text-input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.input-error {
  margin: 8px 0 0 0;
  color: #c53030;
  font-size: 0.9rem;
  min-height: 1.2em;
}

.start-actions {
  margin-top: 24px;
}

.start-screen-link {
  margin-top: 16px;
}

.link-teacher {
  color: #2563eb;
  text-decoration: none;
  font-size: 0.95rem;
}

.link-teacher:hover {
  text-decoration: underline;
}

.test-meta {
  margin-top: 20px;
  font-size: 0.9rem;
  color: var(--nmt-text-muted);
}

/* ----- Кнопки ----- */
.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.btn-primary {
  background: var(--nmt-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--nmt-primary-hover);
}

.btn-secondary {
  background: #e8eaed;
  color: var(--nmt-text);
}

.btn-secondary:hover {
  background: #dce0e5;
}

.btn-danger {
  background: #dc2626;
  color: #fff;
}

.btn-danger:hover {
  background: #b91c1c;
}

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

/* ----- Макет тесту ----- */
.test-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
  align-items: start;
}

.sidebar {
  background: #fff;
  border-radius: 12px;
  padding: 18px 16px 20px;
  border: 1px solid #e8eaed;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 20px;
}

.student-info {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e8eaed;
}

.student-name-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--nmt-text-muted);
}

.student-name-value {
  font-weight: 500;
  margin-top: 4px;
  color: var(--nmt-text);
  word-break: break-word;
}

.legend {
  display: grid;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--nmt-text-muted);
  margin: 12px 0 14px;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.legend-dot.unanswered {
  background: #c8cdd6;
}

.legend-dot.answered {
  background: #10b981;
}

.legend-dot.flagged {
  background: #f59e0b;
}

.question-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.question-tile {
  border-radius: 8px;
  padding: 8px 4px;
  font-size: 0.85rem;
  border: 1px solid #dce0e5;
  text-align: center;
  cursor: pointer;
  background: #f5f6f8;
  color: var(--nmt-text-muted);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.question-tile:hover {
  background: #eef0f3;
  border-color: #c8cdd6;
}

.question-tile.current {
  border-color: #2563eb;
  background: #dbeafe;
  font-weight: 500;
  color: #1e40af;
}

.question-tile.answered {
  background: #d1fae5;
  border-color: #34d399;
}

.question-tile.flagged {
  border-color: #f59e0b;
  background: #fef3c7;
}

.question-tile.unanswered {
  color: var(--nmt-text-muted);
}

.finish-btn {
  width: 100%;
  margin-top: 8px;
}

.finish-note {
  margin-top: 8px;
  font-size: 0.8rem;
}

.question-area {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.focus-lost-toast {
  padding: 10px 14px;
  border-radius: 8px;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  color: #92400e;
  font-size: 0.9rem;
  margin-bottom: 8px;
}
.focus-lost-toast.hidden {
  display: none !important;
}

.focus-lost-modal {
  border-color: #f59e0b;
  box-shadow: 0 4px 20px rgba(245, 158, 11, 0.2);
}

/* Ускладнення копіювання умови завдання під час тесту */
body.test-active .question-card {
  user-select: none;
  -webkit-user-select: none;
}
body.test-active .question-card input,
body.test-active .question-card textarea,
body.test-active .question-card [contenteditable="true"] {
  user-select: text;
  -webkit-user-select: text;
}

.question-area-top {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.timer {
  padding: 8px 12px;
  border-radius: 8px;
  background: #eef1f5;
  font-size: 0.9rem;
  color: var(--nmt-text-muted);
}
.timer.timer-expired {
  background: #fef3c7;
  color: #92400e;
  font-weight: 600;
}

.btn-formula-ref {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid #93c5fd;
  background: #dbeafe;
  color: #1e40af;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-formula-ref:hover {
  background: #bfdbfe;
  border-color: #2563eb;
}
.formula-ref-icon {
  font-size: 1.1rem;
  font-weight: 700;
}

/* Довідка формул — модальне вікно */
.formula-ref-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
}
.formula-ref-overlay.hidden {
  display: none;
}

.formula-ref-modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  min-width: 420px;
  max-width: 92vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  border: 1px solid #e2e8f0;
  resize: horizontal;
  overflow: auto;
  position: relative;
}
.formula-ref-modal::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 12px;
  background: linear-gradient(90deg, transparent 0%, rgba(0,0,0,0.06) 100%);
  border-radius: 0 12px 12px 0;
  pointer-events: none;
}

.formula-ref-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid #e8eaed;
  flex-shrink: 0;
}
.formula-ref-title {
  margin: 0;
  font-size: 1.1rem;
  color: #1e293b;
}
.formula-ref-actions {
  display: flex;
  gap: 6px;
}
.btn-formula-ref-small {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  color: var(--nmt-text-muted);
  transition: background 0.15s, color 0.15s;
}
.btn-formula-ref-small:hover {
  background: #e2e8f0;
  color: #1e293b;
}

.formula-ref-tabs {
  display: flex;
  gap: 4px;
  padding: 12px 18px 0;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}
.formula-tab {
  padding: 8px 14px;
  border: none;
  border-radius: 8px 8px 0 0;
  background: transparent;
  font-size: 0.9rem;
  color: var(--nmt-text-muted);
  cursor: pointer;
  margin-bottom: -1px;
  transition: background 0.15s, color 0.15s;
}
.formula-tab:hover {
  color: #2563eb;
  background: #f1f5f9;
}
.formula-tab.active {
  background: #fff;
  color: #2563eb;
  font-weight: 600;
  border: 1px solid #e2e8f0;
  border-bottom-color: #fff;
}

.formula-ref-body {
  overflow-y: auto;
  padding: 18px;
  flex: 1;
  min-height: 0;
}
.formula-panel {
  display: none;
}
.formula-panel.active {
  display: block;
}
.formula-panel-desc {
  margin: 0 0 14px 0;
  font-size: 0.9rem;
  color: var(--nmt-text-muted);
}
.formula-block {
  margin-bottom: 18px;
  padding: 12px 14px;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}
.formula-block h4 {
  margin: 0 0 8px 0;
  font-size: 0.95rem;
  color: var(--nmt-text);
}
.formula-block p {
  margin: 0 0 6px 0;
  font-size: 0.9rem;
  line-height: 1.6;
  color: #475569;
}
.formula-block p:last-child {
  margin-bottom: 0;
}

.formula-table-block { overflow-x: auto; }
.formula-table-wrap { margin-top: 6px; }
.formula-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  color: #475569;
}
.formula-table th, .formula-table td {
  border: 1px solid #e2e8f0;
  padding: 6px 10px;
  text-align: center;
}
.formula-table th { background: #f1f5f9; color: var(--nmt-text); font-weight: 600; }
.formula-table-squares th:first-child { min-width: 2em; }
.formula-table-trig th { white-space: nowrap; }
.formula-table-caption {
  margin: 8px 0 0 0 !important;
  font-size: 0.8rem !important;
  color: var(--nmt-text-muted) !important;
  text-align: left;
}

.formula-ref-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1001;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  border: 1px solid #e2e8f0;
  font-size: 0.9rem;
  color: #475569;
}
.formula-ref-bar.hidden {
  display: none;
}
.formula-ref-bar .btn-formula-ref-small {
  width: 28px;
  height: 28px;
}

.sync-status-wrap {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  margin-bottom: 14px;
  padding: 10px 12px;
  min-height: 44px;
  box-sizing: border-box;
  background: #f0f9ff;
  border-radius: 10px;
  border: 1px solid #bae6fd;
  font-size: 0.85rem;
}
.sync-status-left { min-width: 0; }
.sync-status-center {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  white-space: nowrap;
}
.sync-status-text {
  line-height: 34px;
  vertical-align: middle;
}
.sync-status-right { min-width: 0; }
.sync-status-text.synced { color: #059669; font-weight: 500; }
.sync-status-text.pending { color: #d97706; }
.sync-status-text.saving { color: #2563eb; }
.sync-status-text.error { color: #dc2626; }
.btn-sync {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid #7dd3fc;
  background: #e0f2fe;
  color: #0369a1;
  font-size: 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
  vertical-align: middle;
  transition: background 0.2s, border-color 0.2s;
}
.btn-sync:hover { background: #bae6fd; border-color: #38bdf8; }
.btn-sync:disabled { opacity: 0.7; cursor: not-allowed; }
.btn-sync .sync-icon { display: block; line-height: 1; }
.result-save-error {
  margin-top: 12px;
  padding: 14px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: #991b1b;
}
.result-save-error p { margin: 0 0 10px 0; font-size: 0.9rem; }
.result-save-error .btn { margin-right: 8px; }

.question-card {
  min-height: 280px;
  scroll-margin-top: 20px;
}

.question-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e8eaed;
}

.question-index {
  font-weight: 600;
  color: #2563eb;
  margin-bottom: 4px;
  font-size: 0.95rem;
}

.question-source-line {
  font-size: 0.875rem;
  color: #64748b;
  margin-top: 4px;
}

.question-source-line.hidden {
  display: none;
}

.btn-inline-source {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  font: inherit;
  color: #2563eb;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.btn-inline-source:hover {
  color: #1d4ed8;
}

.question-source-line .question-source-label {
  color: #64748b;
  text-decoration: none;
}

.flag-btn {
  border-radius: 8px;
  border: 1px solid #e0d4a8;
  padding: 8px 12px;
  background: #faf6e8;
  color: #7a6b3a;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.flag-btn .flag-icon {
  color: #f59e0b;
}

.flag-btn.active {
  background: #fef3c7;
  border-color: #f59e0b;
}

.flag-btn:hover {
  background: #f0e8c8;
}

.question-content {
  margin-bottom: 16px;
}

.question-content .question-text {
  font-size: 1rem;
  margin-bottom: 8px;
  color: var(--nmt-text);
  line-height: 1.6;
}

.question-content .question-latex {
  font-size: 1rem;
  margin-bottom: 0;
  color: var(--nmt-text);
  margin-top: 8px;
}

.question-content .question-latex .MathJax {
  display: inline-block;
}

.question-image-container {
  margin: 12px 0 16px;
  text-align: center;
}

.question-image-container img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid #e8eaed;
}

.question-body {
  margin-bottom: 20px;
}

.question-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e8eaed;
}

/* ----- Варіанти відповідей ----- */
.options-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.option-item {
  border-radius: 8px;
  border: 1px solid #dce0e5;
  padding: 12px 14px;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #fafbfc;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.option-item:hover {
  background: #f0f2f5;
  border-color: #c8cdd6;
}

.option-item.selected {
  border-color: #2563eb;
  background: #dbeafe;
}

.option-label-badge {
  min-width: 28px;
  height: 28px;
  border-radius: 6px;
  background: #e8eaed;
  color: var(--nmt-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.option-content {
  flex: 1;
  min-width: 0;
}

.option-main-text {
  margin: 0;
  font-size: 1.08rem;
  color: var(--nmt-text);
  line-height: 1.5;
}

/* LaTeX у варіантах відповідей */
.option-main-text mjx-container {
  font-size: 0.95em !important;
  display: inline !important;
  vertical-align: middle;
}

.option-latex {
  margin-top: 4px;
  font-size: 0.9rem;
  color: #4a5568;
}

/* ----- Завдання на відповідність ----- */
.matching-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

.matching-table th,
.matching-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #e8eaed;
  vertical-align: top;
  font-size: 1.05rem;
}

.matching-table th {
  text-align: left;
  color: var(--nmt-text-muted);
  font-weight: 500;
}

.matching-label {
  font-weight: 500;
  margin-right: 4px;
}

.matching-select {
  width: 100%;
  max-width: 280px;
  margin-top: 6px;
  border-radius: 6px;
  border: 1px solid #d0d5dc;
  padding: 8px 10px;
  font-size: 1.02rem;
  background: #fff;
}

/* Кастомний випадаючий список для LaTeX у відповідях */
.matching-select-custom {
  position: relative;
  max-width: 320px;
  margin-top: 6px;
}

.matching-select-trigger {
  width: 100%;
  text-align: left;
  border-radius: 8px;
  border: 1px solid #d0d5dc;
  padding: 10px 12px;
  font-size: 1.12rem;
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.matching-select-trigger:hover {
  border-color: #2563eb;
  background: #f8fafc;
}

.matching-select-trigger-label {
  flex-shrink: 0;
  font-size: 1.12rem;
  font-weight: 500;
}

/* Обрана відповідь у кнопці */
.matching-select-trigger-math {
  display: inline-flex;
  align-items: center;
  font-size: 1.12rem;
  line-height: 1.4;
  vertical-align: middle;
  min-height: 1.4em;
}
.matching-select-trigger-math mjx-container {
  font-size: 1.12rem !important;
  display: inline-block !important;
  vertical-align: middle;
  line-height: 1.35;
}
.matching-select-trigger-math mjx-container svg {
  display: block;
  max-height: 1.5em;
  width: auto !important;
  height: auto !important;
  vertical-align: middle;
}
.matching-select-trigger-math .mjx-chtml {
  font-size: 1.12rem !important;
}

/* У випадаючому списку відповідностей */
.matching-select-dropdown .matching-select-option {
  padding: 8px 12px;
  min-height: 2.25em;
  align-items: center;
  font-size: 1.05rem;
}
.matching-select-option .matching-option-label {
  font-size: 1.05rem;
  flex-shrink: 0;
  font-weight: 500;
}
.matching-option-math {
  display: inline-flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  font-size: 1.05rem;
}
.matching-option-math mjx-container {
  font-size: 1em !important;
  display: inline-block !important;
  vertical-align: middle;
  line-height: 1.3;
}
.matching-option-math mjx-container svg {
  display: block;
  transform: scale(0.9);
  transform-origin: 0 50%;
  width: auto !important;
  height: auto !important;
  vertical-align: middle;
}
.matching-option-math .mjx-chtml {
  font-size: 0.95em !important;
}

.matching-select-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 4px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 10;
  max-height: 240px;
  overflow-y: auto;
}

.matching-select-option {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  font-size: 0.875rem;
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 1px solid #f0f2f5;
}

.matching-select-option:last-child {
  border-bottom: none;
}

.matching-select-option:hover {
  background: #e8eef7;
}

.matching-option-label {
  flex-shrink: 0;
}

/* ----- Коротка відповідь ----- */
.short-answer-wrapper {
  margin-top: 12px;
}

.short-answer-label {
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--nmt-text-muted);
}

.short-answer-input {
  width: 220px;
  max-width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #d0d5dc;
  font-size: 0.95rem;
}

.short-answer-input:focus {
  outline: none;
  border-color: #2563eb;
}

/* ----- Результати ----- */
.result-card {
  margin-top: 0;
  width: 100%;
}

.result-card h2 {
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 1.25rem;
  color: var(--nmt-text);
}

.result-score-block {
  background: #f0f4f8;
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 20px;
  border: 1px solid #e2e8f0;
}

.result-student-name {
  font-size: 0.95rem;
  color: var(--nmt-text-muted);
  margin-bottom: 12px;
}

.score-line {
  font-size: 1.15rem;
  margin-bottom: 8px;
  color: var(--nmt-text);
}

.score-line strong {
  color: #2563eb;
}

#score-comment.result-comment {
  margin-top: 12px;
  margin-bottom: 0;
  font-size: 0.98rem;
}

.incorrect-section {
  margin-top: 20px;
  margin-bottom: 24px;
  padding: 16px;
  border: 1px solid #e8c8c8;
  border-radius: 10px;
  background: #fdf8f8;
}

.incorrect-section h3 {
  margin: 0 0 12px 0;
  font-size: 1.1rem;
  color: #b91c1c;
}

.details-incorrect {
  margin-top: 20px;
  border-top: 1px solid #e8eaed;
  padding-top: 16px;
}

.details-incorrect summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--nmt-text-muted);
}

/* ----- Футер ----- */
.page-footer {
  margin-top: 16px;
  padding-top: 8px;
  border-top: 1px solid var(--nmt-border);
  text-align: center;
  font-size: 0.75rem;
  color: var(--nmt-text-muted);
}

.page-footer p {
  margin: 0;
  line-height: 1.4;
}

.page-footer a {
  color: #2563eb;
  text-decoration: none;
}

.page-footer a:hover {
  text-decoration: underline;
}

.footer-links {
  margin-top: 6px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.footer-sep {
  color: var(--nmt-border);
  font-size: 0.9em;
}

.page-footer .footer-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1em;
  height: 1.1em;
  margin-right: 0.2em;
  font-size: 0.95em;
  color: inherit;
  border: 1px solid currentColor;
  border-radius: 50%;
  vertical-align: middle;
}

/* ----- Індикатор завантаження сторінки ----- */
.page-loader {
  position: fixed;
  inset: 0;
  background: var(--nmt-bg);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.page-loader.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.page-loader-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--nmt-border);
  border-top-color: var(--nmt-primary);
  border-radius: 50%;
  animation: page-loader-spin 0.7s linear infinite;
}
@keyframes page-loader-spin {
  to { transform: rotate(360deg); }
}

.incorrect-list {
  margin-top: 12px;
  display: grid;
  gap: 12px;
}

.incorrect-item {
  padding: 14px 16px;
  border-radius: 8px;
  background: #fdf5f5;
  border: 1px solid #e8c8c8;
}

.incorrect-title {
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--nmt-text);
}

.incorrect-question {
  font-size: 0.94rem;
  margin-bottom: 8px;
  color: #4a5568;
}

.incorrect-answer-line {
  font-size: 0.9rem;
  margin: 0 0 4px 0;
  color: var(--nmt-text-muted);
}

.incorrect-answer-line strong {
  font-weight: 600;
  color: var(--nmt-text);
}

/* ----- Адаптивність ----- */
@media (max-width: 900px) {
  .app-header {
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px 18px;
  }

  .header-left {
    flex: 1 1 100%;
    min-width: 0;
  }

  .header-text {
    min-width: 0;
  }

  .header-text h1 {
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  .header-right {
    width: 100%;
    flex: 1 1 100%;
    justify-content: flex-start;
    min-width: 0;
  }

  .header-nav {
    flex-wrap: wrap;
    gap: 6px;
  }

  .header-nav .info-link {
    flex-shrink: 0;
  }

  .test-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    order: 2;
  }

  .question-area {
    order: 1;
  }
}

@media (max-width: 600px) {
  .app-container {
    padding: 14px 16px 24px;
  }

  .question-grid {
    grid-template-columns: repeat(5, 1fr);
  }

  .app-header {
    padding: 12px 14px 14px;
    gap: 10px;
  }

  .header-left {
    gap: 12px;
  }

  .herb-wrap,
  .herb-img {
    width: 48px;
    height: 48px;
  }

  .header-text h1 {
    font-size: 1.05rem;
    line-height: 1.3;
  }

  .header-subtitle {
    font-size: 0.8rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .header-nav .info-link {
    padding: 8px 12px;
    font-size: 0.85rem;
    white-space: normal;
    text-align: center;
    min-width: 0;
  }

  .info-link .info-text {
    white-space: normal;
  }

  .card {
    padding: 18px 16px;
  }
}

/* ═══════════════════════════════════════
   Subject selector tabs
═══════════════════════════════════════ */
.subject-selector { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--nmt-border); }
.subject-tab { display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px; border-radius: 999px; font-size: 0.88rem; font-weight: 500; cursor: pointer; border: 2px solid var(--nmt-border); background: var(--nmt-surface); color: var(--nmt-text-muted); transition: border-color 0.18s, color 0.18s, background 0.18s, box-shadow 0.18s; user-select: none; }
.subject-tab:hover:not(.subject-tab-locked):not(.active) { border-color: var(--nmt-primary); color: var(--nmt-primary); }
.subject-tab.active:hover { color: #fff; }
.subject-tab.active { background: var(--nmt-primary); color: #fff; border-color: var(--nmt-primary); box-shadow: 0 2px 8px rgba(15,118,110,0.25); }
.subject-tab-locked { cursor: default; opacity: 0.65; }
.subject-soon { font-size: 0.68rem; font-weight: 600; padding: 2px 7px; border-radius: 999px; background: #e2e8f0; color: #64748b; letter-spacing: 0.02em; }
.subject-tab.active .subject-soon { background: rgba(255,255,255,0.22); color: rgba(255,255,255,0.9); }

/* ═══════════════════════════════════════
   Dashboard extra stat card
═══════════════════════════════════════ */
.stat-card-today { border-left: 3px solid var(--nmt-primary); }
.stat-card-streak .stat-value { color: #f59e0b; }
.stat-card-weakest .stat-value { font-size: 0.85rem !important; font-weight: 600; color: #dc2626; line-height: 1.2; }

/* ═══════════════════════════════════════
   Onboarding welcome card
═══════════════════════════════════════ */
.onboarding-card { background: linear-gradient(135deg, #f0fdfa 0%, #e0f2fe 100%); border: 2px solid var(--nmt-primary); border-radius: 14px; padding: 24px 28px; margin-bottom: 20px; display: flex; flex-wrap: wrap; align-items: center; gap: 20px; }
.onboarding-card-icon { font-size: 2.5rem; }
.onboarding-card-text h3 { margin: 0 0 6px 0; font-size: 1.1rem; color: var(--nmt-text); }
.onboarding-card-text p { margin: 0; font-size: 0.9rem; color: var(--nmt-text-muted); }
body.theme-dark .onboarding-card { background: linear-gradient(135deg, rgba(45,212,191,0.1) 0%, rgba(14,165,233,0.1) 100%); }

/* ═══════════════════════════════════════
   Avatar picker
═══════════════════════════════════════ */
.avatar-section { display: flex; align-items: center; gap: 20px; margin-bottom: 24px; padding-bottom: 24px; border-bottom: 1px solid var(--nmt-border); }
.avatar-circle { width: 72px; height: 72px; border-radius: 50%; background: var(--nmt-bg); border: 3px solid var(--nmt-primary); display: flex; align-items: center; justify-content: center; font-size: 2.2rem; cursor: pointer; transition: transform 0.18s, box-shadow 0.18s; flex-shrink: 0; }
.avatar-circle:hover { transform: scale(1.06); box-shadow: 0 4px 16px rgba(15,118,110,0.25); }
.avatar-section-info p { margin: 0 0 6px 0; font-size: 0.9rem; color: var(--nmt-text-muted); }
.avatar-picker-wrap { margin-top: 12px; }
.avatar-picker-grid { display: flex; flex-wrap: wrap; gap: 8px; max-width: 340px; margin-top: 8px; }
.avatar-option { font-size: 1.4rem; width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; cursor: pointer; border: 2px solid transparent; transition: all 0.15s; background: var(--nmt-surface); }
.avatar-option:hover, .avatar-option.selected { border-color: var(--nmt-primary); background: var(--nmt-bg); transform: scale(1.1); }
.avatar-picker-wrap.hidden { display: none; }

/* ═══════════════════════════════════════
   Achievement Badges
═══════════════════════════════════════ */
.badges-section { margin-bottom: 28px; padding-bottom: 24px; border-bottom: 1px solid var(--nmt-border); }
.badges-section-title { font-size: 1rem; font-weight: 600; color: var(--nmt-text); margin: 0 0 14px 0; }
.badges-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.badge-item { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 16px; background: var(--nmt-surface); border: 2px solid var(--nmt-border); border-radius: 14px; min-width: 88px; text-align: center; transition: transform 0.2s, border-color 0.2s; }
.badge-item:not(.badge-locked):hover { transform: translateY(-2px); border-color: var(--nmt-primary); }
.badge-item.badge-locked { opacity: 0.35; filter: grayscale(1); }
.badge-icon { font-size: 1.8rem; line-height: 1; }
.badge-label { font-size: 0.72rem; font-weight: 600; color: var(--nmt-text-muted); line-height: 1.25; max-width: 80px; }
.badge-item:not(.badge-locked) .badge-label { color: var(--nmt-text); }

/* ═══════════════════════════════════════
   Activity heatmap (GitHub style)
═══════════════════════════════════════ */
.activity-section { }
.activity-section-title { font-size: 1rem; font-weight: 600; color: var(--nmt-text); margin: 0 0 12px 0; }
.activity-calendar { overflow-x: auto; padding-bottom: 8px; }
.activity-months { display: flex; gap: 0; margin-bottom: 4px; padding-left: 20px; min-height: 16px; }
.activity-month-label { font-size: 0.7rem; color: var(--nmt-text-muted); flex: 0 0 auto; }
.activity-body { display: flex; gap: 6px; }
.activity-days-label { display: flex; flex-direction: column; justify-content: space-around; padding-right: 4px; min-width: 16px; }
.activity-day-label { font-size: 0.65rem; color: var(--nmt-text-muted); line-height: 1; height: 13px; display: flex; align-items: center; }
.activity-grid { display: grid; grid-template-rows: repeat(7, 13px); grid-auto-columns: 13px; grid-auto-flow: column; gap: 2px; }
.activity-cell { width: 13px; height: 13px; border-radius: 3px; background: var(--nmt-border); transition: opacity 0.1s; cursor: default; }
.activity-cell:hover { opacity: 0.7; }
.activity-cell[data-count="1"] { background: #bbf7d0; }
.activity-cell[data-count="2"] { background: #4ade80; }
.activity-cell[data-count="3"] { background: #16a34a; }
.activity-cell[data-count="4"] { background: #15803d; }
.activity-legend { display: flex; align-items: center; gap: 5px; margin-top: 8px; font-size: 0.72rem; color: var(--nmt-text-muted); }
.activity-legend-cell { width: 11px; height: 11px; border-radius: 2px; }
body.theme-dark .activity-cell { background: #334155; }
body.theme-dark .activity-cell[data-count="1"] { background: #166534; }
body.theme-dark .activity-cell[data-count="2"] { background: #15803d; }
body.theme-dark .activity-cell[data-count="3"] { background: #22c55e; }
body.theme-dark .activity-cell[data-count="4"] { background: #4ade80; }

/* ═══════════════════════════════════════
   Progress chart (Statistics tab)
═══════════════════════════════════════ */
.stats-chart-wrap { background: var(--nmt-surface); border: 1px solid var(--nmt-border); border-radius: var(--nmt-card-radius); padding: 20px; margin-bottom: 24px; }
.stats-chart-title { margin: 0 0 16px 0; font-size: 1rem; font-weight: 600; color: var(--nmt-text); }
.stats-chart-canvas { max-height: 260px; }
.stats-empty { color: var(--nmt-text-muted); font-size: 0.95rem; padding: 20px 0; text-align: center; }

/* ═══════════════════════════════════════
   Nickname field in profile
═══════════════════════════════════════ */
.nickname-edit-row { margin-bottom: 20px; }
.nickname-edit-label { display: block; font-weight: 500; color: var(--nmt-text); margin-bottom: 6px; font-size: 0.95rem; }
.nickname-edit-input { width: 100%; max-width: 420px; padding: 10px 14px; border-radius: 10px; border: 1.5px solid var(--nmt-border); font-size: 1rem; box-sizing: border-box; background: var(--nmt-surface); color: var(--nmt-text); transition: border-color 0.18s, box-shadow 0.18s; }
.nickname-edit-input:focus { outline: none; border-color: var(--nmt-primary); box-shadow: 0 0 0 3px var(--nmt-primary-light); }

/* dark theme for new components */
body.theme-dark .avatar-circle { background: var(--nmt-surface); }
body.theme-dark .avatar-option { background: var(--nmt-bg); }
body.theme-dark .badge-item { background: var(--nmt-surface); border-color: var(--nmt-border); }
body.theme-dark .stats-chart-wrap { background: var(--nmt-surface); }
body.theme-dark .onboarding-card { border-color: var(--nmt-primary); }
body.theme-dark .subject-tab { background: var(--nmt-surface); border-color: var(--nmt-border); color: var(--nmt-text-muted); }
body.theme-dark .nickname-edit-input { background: var(--nmt-surface); color: var(--nmt-text); border-color: var(--nmt-border); }

@media (max-width: 640px) {
  .subject-selector { gap: 6px; }
  .subject-tab { padding: 7px 12px; font-size: 0.82rem; }
  .onboarding-card { padding: 16px 18px; gap: 14px; }
  .badges-grid { gap: 8px; }
  .badge-item { min-width: 76px; padding: 12px; }
}

/* ═══════════════════════════════════════════════════════════
   DARK THEME — комплексні overrides для всіх компонентів
═══════════════════════════════════════════════════════════ */

/* Inputs & forms */
body.theme-dark .text-input,
body.theme-dark .short-answer-input { background: var(--nmt-bg); border-color: var(--nmt-border); color: var(--nmt-text); }
body.theme-dark .text-input:focus,
body.theme-dark .short-answer-input:focus { border-color: var(--nmt-primary); box-shadow: 0 0 0 3px rgba(45,212,191,0.18); }
body.theme-dark .text-input::placeholder,
body.theme-dark .short-answer-input::placeholder { color: var(--nmt-text-muted); }
body.theme-dark .matching-select { background: var(--nmt-bg); border-color: var(--nmt-border); color: var(--nmt-text); }
body.theme-dark .matching-select-trigger { background: var(--nmt-surface); border-color: var(--nmt-border); color: var(--nmt-text); }
body.theme-dark .matching-select-trigger:hover { background: #3d5068; border-color: var(--nmt-primary); }
body.theme-dark .matching-select-dropdown { background: var(--nmt-surface); border-color: var(--nmt-border); box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
body.theme-dark .matching-select-option { border-bottom-color: var(--nmt-border); color: var(--nmt-text); background: none; }
body.theme-dark .matching-select-option:hover { background: #3d5068; }
body.theme-dark .matching-table th,
body.theme-dark .matching-table td { border-bottom-color: var(--nmt-border); color: var(--nmt-text); }

/* Buttons */
body.theme-dark .btn-formula-ref { background: #1a2f4a; border-color: #2a5470; color: #93c5fd; }
body.theme-dark .btn-formula-ref:hover { background: #22385a; border-color: #60a5fa; }
body.theme-dark .btn-formula-ref-small { background: var(--nmt-surface); border-color: var(--nmt-border); color: var(--nmt-text-muted); }
body.theme-dark .btn-formula-ref-small:hover { background: #3d5068; color: var(--nmt-text); }
body.theme-dark .btn-sync { background: #1a2f4a; border-color: #2a5470; color: #93c5fd; }
body.theme-dark .btn-sync:hover { background: #22385a; border-color: #60a5fa; }

/* Test sidebar & navigation tiles */
body.theme-dark .sidebar { background: var(--nmt-surface); border-color: var(--nmt-border); box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
body.theme-dark .question-tile { background: var(--nmt-bg); border-color: var(--nmt-border); color: var(--nmt-text-muted); }
body.theme-dark .question-tile:hover { background: #28384f; border-color: var(--nmt-text-muted); }
body.theme-dark .question-tile.current { background: #1a3456; border-color: var(--nmt-primary); color: var(--nmt-primary); }
body.theme-dark .question-tile.answered { background: #14432d; border-color: #22c55e; color: #4ade80; }
body.theme-dark .question-tile.flagged { background: #3a2a0a; border-color: #f59e0b; color: #fbbf24; }

/* Answer options */
body.theme-dark .option-item { background: var(--nmt-bg); border-color: var(--nmt-border); }
body.theme-dark .option-item:hover { background: #28384f; border-color: var(--nmt-text-muted); }
body.theme-dark .option-item.selected { background: #1a3456; border-color: #60a5fa; }
body.theme-dark .option-label-badge { background: var(--nmt-border); color: var(--nmt-text); }
body.theme-dark .option-latex { color: var(--nmt-text-muted); }

/* Question card internals */
body.theme-dark .question-header { border-bottom-color: var(--nmt-border); }
body.theme-dark .question-footer { border-top-color: var(--nmt-border); }
body.theme-dark .question-index { color: var(--nmt-primary); }
body.theme-dark .question-source-line { color: var(--nmt-text-muted); }
body.theme-dark .question-image-container img { border-color: var(--nmt-border); filter: brightness(0.9); }
body.theme-dark .details-incorrect { border-top-color: var(--nmt-border); }
body.theme-dark .flag-btn { background: #2a2510; border-color: #4a3f1c; color: #c4a84a; }
body.theme-dark .flag-btn.active { background: #3a300c; border-color: #f59e0b; color: #fbbf24; }
body.theme-dark .flag-btn:hover { background: #332c12; }

/* Formula reference modal */
body.theme-dark .formula-ref-modal { background: var(--nmt-surface); border-color: var(--nmt-border); }
body.theme-dark .formula-ref-modal-header { border-bottom-color: var(--nmt-border); background: var(--nmt-bg); }
body.theme-dark .formula-ref-title { color: var(--nmt-text); }
body.theme-dark .formula-block { background: var(--nmt-bg); border-color: var(--nmt-border); }
body.theme-dark .formula-block p { color: var(--nmt-text-muted); }
body.theme-dark .formula-table { color: var(--nmt-text-muted); }
body.theme-dark .formula-table th,
body.theme-dark .formula-table td { border-color: var(--nmt-border); }
body.theme-dark .formula-table th { background: var(--nmt-bg); color: var(--nmt-text); }
body.theme-dark .formula-ref-bar { background: var(--nmt-surface); border-color: var(--nmt-border); color: var(--nmt-text-muted); box-shadow: 0 4px 20px rgba(0,0,0,0.4); }

/* Sync & timer */
body.theme-dark .sync-status-wrap { background: #1a2f4a; border-color: #2a5470; }
body.theme-dark .sync-status-text.synced { color: #34d399; }
body.theme-dark .sync-status-text.pending { color: #fbbf24; }
body.theme-dark .sync-status-text.saving { color: #60a5fa; }
body.theme-dark .sync-status-text.error { color: #f87171; }
body.theme-dark .timer { background: var(--nmt-bg); color: var(--nmt-text-muted); border: 1px solid var(--nmt-border); }
body.theme-dark .timer.timer-expired { background: #3a2a0a; border-color: #f59e0b; color: #fbbf24; }
body.theme-dark .focus-lost-toast { background: #3a2a0a; border-color: #f59e0b; color: #fbbf24; }

/* Results */
body.theme-dark .result-score-block { background: var(--nmt-bg); border-color: var(--nmt-border); }
body.theme-dark .score-line strong { color: var(--nmt-primary); }
body.theme-dark .incorrect-section { background: #2a1a1a; border-color: #7f1d1d; }
body.theme-dark .incorrect-section h3 { color: #f87171; }
body.theme-dark .result-save-error { background: #2a1a1a; border-color: #7f1d1d; color: #fca5a5; }

/* Choice panels */
body.theme-dark .choice-panel-personal { background: linear-gradient(160deg, #1b3044 0%, #16283c 100%); border-color: #2a4a64; }
body.theme-dark .choice-panel-personal:hover { border-color: #38bdf8; }
body.theme-dark .choice-panel-school { background: linear-gradient(160deg, #2a2710 0%, #22200c 100%); border-color: #433d14; }
body.theme-dark .choice-panel-school:hover { border-color: #eab308; }
body.theme-dark .choice-panel-badge { background: var(--nmt-border); color: var(--nmt-text-muted); }

/* Footer & links */
body.theme-dark .page-footer { border-top-color: var(--nmt-border); color: var(--nmt-text-muted); }
body.theme-dark .page-footer a { color: var(--nmt-primary); }
body.theme-dark .herb-credit a { color: var(--nmt-text-muted); }
body.theme-dark .link-teacher { color: var(--nmt-primary); }
body.theme-dark .btn-inline-source { color: var(--nmt-primary); }
body.theme-dark .btn-inline-source:hover { color: var(--nmt-primary-hover); }
body.theme-dark .subject-soon { background: var(--nmt-border); color: var(--nmt-text-muted); }

/* Modal overlay */
body.theme-dark .modal-overlay { background: rgba(0,0,0,0.65); }
body.theme-dark .formula-ref-overlay { background: rgba(0,0,0,0.65); }


/* ═══════════════════════════════════════════════════════════
   CONTRAST THEME — комплексні overrides для всіх компонентів
═══════════════════════════════════════════════════════════ */

/* Inputs */
body.theme-contrast .text-input,
body.theme-contrast .short-answer-input { background: #fff; border: 2px solid #000; color: #000; }
body.theme-contrast .text-input:focus,
body.theme-contrast .short-answer-input:focus { border-color: #000; box-shadow: 0 0 0 3px rgba(0,0,0,0.3); }
body.theme-contrast .matching-select { background: #fff; border: 2px solid #000; color: #000; }
body.theme-contrast .matching-select-trigger { background: #fff; border: 2px solid #000; color: #000; }
body.theme-contrast .matching-select-trigger:hover { background: #e6e6e6; }
body.theme-contrast .matching-select-dropdown { background: #fff; border: 2px solid #000; }
body.theme-contrast .matching-select-option { border-bottom: 1px solid #000; color: #000; background: none; }
body.theme-contrast .matching-select-option:hover { background: #e6e6e6; }

/* Buttons */
body.theme-contrast .btn-formula-ref { background: #fff; border: 2px solid #000; color: #000; }
body.theme-contrast .btn-formula-ref:hover { background: #e6e6e6; }
body.theme-contrast .btn-formula-ref-small { background: #fff; border: 2px solid #000; color: #000; }
body.theme-contrast .btn-formula-ref-small:hover { background: #e6e6e6; }
body.theme-contrast .btn-sync { background: #fff; border: 2px solid #000; color: #000; }
body.theme-contrast .btn-sync:hover { background: #e6e6e6; }

/* Test sidebar */
body.theme-contrast .sidebar { background: #fff; border: 2px solid #000; }
body.theme-contrast .question-tile { background: #fff; border: 2px solid #000; color: #000; }
body.theme-contrast .question-tile:hover { background: #e6e6e6; }
body.theme-contrast .question-tile.current { background: #000; border-color: #000; color: #fff; }
body.theme-contrast .question-tile.answered { background: #e6e6e6; border: 2px solid #000; color: #000; }
body.theme-contrast .question-tile.flagged { background: #e6e6e6; border: 2px solid #000; color: #000; }

/* Answer options */
body.theme-contrast .option-item { background: #fff; border: 2px solid #000; color: #000; }
body.theme-contrast .option-item:hover { background: #e6e6e6; border-color: #000; }
body.theme-contrast .option-item.selected { background: #000; border-color: #000; color: #fff; }
body.theme-contrast .option-item.selected .option-main-text { color: #fff; }
body.theme-contrast .option-item.selected .option-latex { color: #ddd; }
body.theme-contrast .option-label-badge { background: #e6e6e6; color: #000; border: 1px solid #000; }
body.theme-contrast .option-item.selected .option-label-badge { background: #fff; color: #000; }

/* Question card */
body.theme-contrast .question-header { border-bottom: 2px solid #000; }
body.theme-contrast .question-footer { border-top: 2px solid #000; }
body.theme-contrast .question-index { color: #000; font-weight: 700; }
body.theme-contrast .question-image-container img { border: 2px solid #000; }
body.theme-contrast .details-incorrect { border-top: 2px solid #000; }
body.theme-contrast .matching-table th,
body.theme-contrast .matching-table td { border-bottom: 1px solid #000; }
body.theme-contrast .flag-btn { background: #fff; border: 2px solid #000; color: #000; }
body.theme-contrast .flag-btn.active { background: #000; color: #fff; border-color: #000; }
body.theme-contrast .flag-btn:hover { background: #e6e6e6; }

/* Formula reference modal */
body.theme-contrast .formula-ref-modal { background: #fff; border: 2px solid #000; }
body.theme-contrast .formula-ref-modal-header { border-bottom: 2px solid #000; }
body.theme-contrast .formula-ref-title { color: #000; }
body.theme-contrast .formula-block { background: #f0f0f0; border: 1px solid #000; }
body.theme-contrast .formula-block p { color: #000; }
body.theme-contrast .formula-table { color: #000; }
body.theme-contrast .formula-table th { background: #000; color: #fff; }
body.theme-contrast .formula-table th,
body.theme-contrast .formula-table td { border: 1px solid #000; }
body.theme-contrast .formula-ref-bar { background: #fff; border: 2px solid #000; color: #000; box-shadow: none; }

/* Sync & timer */
body.theme-contrast .sync-status-wrap { background: #f0f0f0; border: 2px solid #000; }
body.theme-contrast .sync-status-text.synced { color: #005500; font-weight: 700; }
body.theme-contrast .sync-status-text.pending { color: #7a4400; font-weight: 700; }
body.theme-contrast .sync-status-text.saving { color: #00008b; font-weight: 700; }
body.theme-contrast .sync-status-text.error { color: #880000; font-weight: 700; }
body.theme-contrast .timer { background: #f0f0f0; border: 2px solid #000; color: #000; }
body.theme-contrast .timer.timer-expired { background: #000; border-color: #000; color: #fff; }
body.theme-contrast .focus-lost-toast { background: #f0f0f0; border: 2px solid #000; color: #000; }

/* Results */
body.theme-contrast .result-score-block { background: #f0f0f0; border: 2px solid #000; }
body.theme-contrast .score-line strong { color: #000; font-weight: 900; }
body.theme-contrast .incorrect-section { background: #f0f0f0; border: 2px solid #000; }
body.theme-contrast .incorrect-section h3 { color: #000; font-weight: 900; }
body.theme-contrast .result-save-error { background: #f0f0f0; border: 2px solid #000; color: #000; }

/* Choice panels */
body.theme-contrast .choice-panel-personal { background: #fff; border: 2px solid #000; }
body.theme-contrast .choice-panel-personal:hover { border-color: #000; }
body.theme-contrast .choice-panel-school { background: #fff; border: 2px solid #000; }
body.theme-contrast .choice-panel-school:hover { border-color: #000; }
body.theme-contrast .choice-panel-badge { background: #000; color: #fff; }

/* Footer & links */
body.theme-contrast .page-footer { border-top: 2px solid #000; }
body.theme-contrast .page-footer a { color: #000; text-decoration: underline; }
body.theme-contrast .herb-credit a { color: #000; text-decoration: underline; }
body.theme-contrast .link-teacher { color: #000; text-decoration: underline; }
body.theme-contrast .btn-inline-source { color: #000; }
body.theme-contrast .btn-inline-source:hover { color: #333; }
body.theme-contrast .subject-soon { background: #000; color: #fff; }

/* Activity heatmap */
body.theme-contrast .activity-cell { background: #e6e6e6; border: 1px solid #999; }
body.theme-contrast .activity-cell[data-count="1"] { background: #999; }
body.theme-contrast .activity-cell[data-count="2"] { background: #666; }
body.theme-contrast .activity-cell[data-count="3"] { background: #333; }
body.theme-contrast .activity-cell[data-count="4"] { background: #000; }

/* Badges */
body.theme-contrast .badge-item { background: #fff; border: 2px solid #000; color: #000; }
body.theme-contrast .badge-item.badge-locked { background: #f0f0f0; opacity: 0.7; }
body.theme-contrast .badge-icon { filter: grayscale(1); }
body.theme-contrast .badge-item:not(.badge-locked) .badge-icon { filter: none; }

/* Onboarding */
body.theme-contrast .onboarding-card { background: #f0f0f0; border: 2px solid #000; }

/* Modal overlay */
body.theme-contrast .modal-overlay { background: rgba(0,0,0,0.7); }
body.theme-contrast .formula-ref-overlay { background: rgba(0,0,0,0.7); }
