/* dmat.css – Dedicated Styling for dMAT Subtests, Exam Simulator & Submissions */

html, body {
  max-width: 100vw;
  overflow-x: hidden;
}

/* ─── Header & Nav Additions ─── */
.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.portal-badge {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 50px;
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.dmat-btn-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  border-radius: 50px;
  border: 1px solid var(--border-md);
  background: var(--bg-02);
  color: var(--t-100);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--ease);
}
.dmat-btn-sub:hover {
  background: var(--bg-03);
  border-color: var(--border-hi);
  transform: translateY(-1px);
}
.badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: #10b981;
  color: #000;
  font-size: 11px;
  font-weight: 900;
}

/* ─── Hero Additions ─── */
.hero-stats-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 24px;
}
.h-stat-item {
  display: flex;
  flex-direction: column;
  padding: 10px 18px;
  border-radius: var(--r-md);
  background: var(--bg-01);
  border: 1px solid var(--border-lo);
}
.h-stat-num {
  font-size: 20px;
  font-weight: 900;
  color: var(--t-100);
  line-height: 1.1;
}
.h-stat-lbl {
  font-size: 11px;
  font-weight: 600;
  color: var(--t-45);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-top: 2px;
}
.h-stat-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--r-md);
  background: var(--bg-02);
  border: 1px solid var(--border-md);
  color: var(--t-100);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--ease);
}
.h-stat-btn:hover {
  background: var(--bg-03);
  border-color: var(--border-hi);
}

/* ─── Categories Grid ─── */
.cols-2-dmat {
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 20px;
}
.dmat-cat-card {
  position: relative;
  text-align: left;
  align-items: flex-start;
  padding: 32px 26px 24px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 250px;
}
.card-num-pill {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--t-08);
  border: 1px solid var(--border-lo);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 900;
  color: var(--t-70);
}
.featured-ribbon {
  position: absolute;
  top: 16px;
  left: 24px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 50px;
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.35);
}
.dmat-cat-card.dmat-featured-card {
  border-color: rgba(16, 185, 129, 0.4);
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.05) 0%, var(--bg-01) 100%);
}
.dmat-cat-card.dmat-featured-card:hover {
  border-color: #10b981;
  box-shadow: 0 8px 30px rgba(16, 185, 129, 0.15);
}

.dmat-icon-blue { background: rgba(59, 130, 246, 0.1); border-color: rgba(59, 130, 246, 0.3); color: #60a5fa; }
.dmat-icon-emerald { background: rgba(16, 185, 129, 0.1); border-color: rgba(16, 185, 129, 0.3); color: #34d399; }
.dmat-icon-purple { background: rgba(168, 85, 247, 0.1); border-color: rgba(168, 85, 247, 0.3); color: #c084fc; }
.dmat-icon-amber { background: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.3); color: #fbbf24; }

.cat-content {
  margin-top: 16px;
  flex: 1;
}
.dmat-cat-card .card-level {
  font-size: 22px;
  text-align: left;
  line-height: 1.2;
}
.dmat-cat-card .card-title {
  font-size: 13px;
  color: var(--t-45);
  margin-top: 3px;
  margin-bottom: 12px;
}
.dmat-cat-card .card-desc {
  font-size: 13px;
  text-align: left;
  line-height: 1.6;
}
.cat-footer {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border-lo);
}
.cat-arrow {
  font-size: 16px;
  color: var(--t-70);
  transition: transform .2s ease;
}
.dmat-cat-card:hover .cat-arrow {
  transform: translateX(4px);
  color: var(--t-100);
}
.tag-primary {
  background: var(--t-100);
  color: #000 !important;
  border-color: var(--t-100) !important;
}

/* ─── Difficulties View ─── */
.back-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 50px;
  background: var(--t-08);
  border: 1px solid var(--border-md);
  color: var(--t-70);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--ease);
}
.back-link-btn:hover {
  background: var(--bg-02);
  border-color: var(--border-hi);
  color: var(--t-100);
}
.cards-grid.cols-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding-bottom: 64px;
}
@media (max-width: 1200px) {
  .cards-grid.cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 640px) {
  .cards-grid.cols-4 {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}
.diff-card {
  padding: 32px 24px 28px;
  text-align: left;
  align-items: flex-start;
  display: flex;
  flex-direction: column;
}
.diff-badge {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 50px;
  margin-bottom: 16px;
}
.badge-easy { background: rgba(59, 130, 246, 0.15); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.3); }
.badge-medium { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-hard { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-sim { background: rgba(168, 85, 247, 0.15); color: #c084fc; border: 1px solid rgba(168, 85, 247, 0.3); }
.diff-card-sim {
  border-color: rgba(168, 85, 247, 0.35);
}
.diff-card-sim:hover {
  border-color: rgba(168, 85, 247, 0.7);
  box-shadow: 0 0 25px rgba(168, 85, 247, 0.18);
}
.btn-sim-primary {
  background: rgba(168, 85, 247, 0.18);
  color: #d8b4fe;
  border: 1px solid rgba(168, 85, 247, 0.45);
}
.btn-sim-primary:hover {
  background: rgba(168, 85, 247, 0.35);
  border-color: #c084fc;
  color: #fff;
}

/* ── Sets Grid Layout (shared between figures and math) ── */
.fig-sets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}
.fig-sets-grid .diff-card {
  display: flex !important;
  flex-direction: column !important;
}
.fig-sets-grid .diff-desc {
  min-height: 48px !important;
  margin-bottom: 16px !important;
}
.fig-sets-grid .diff-specs {
  margin-top: auto !important;
  margin-bottom: 20px !important;
}
.fig-sets-grid .btn-diff-action {
  margin-top: 0 !important;
}

.diff-title {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -.03em;
  color: var(--t-100);
}
.diff-desc {
  font-size: 13px;
  color: var(--t-45);
  line-height: 1.55;
  margin: 10px 0 20px;
  min-height: 42px;
}
.diff-specs {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  background: var(--bg-02);
  border: 1px solid var(--border-lo);
  border-radius: var(--r-md);
  margin-bottom: 24px;
}
.spec-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}
.spec-row span { color: var(--t-45); }
.spec-row strong { color: var(--t-100); }
.text-glow { color: #10b981 !important; font-weight: 800; }

.btn-diff-action {
  width: 100%;
  padding: 14px 20px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-md);
  background: var(--t-08);
  color: var(--t-100);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: var(--ease);
}
.btn-diff-action:hover {
  background: var(--bg-03);
  border-color: var(--border-hi);
  transform: translateY(-2px);
}
.btn-hard-primary {
  background: var(--t-100);
  color: #000;
  border: none;
}
.btn-hard-primary:hover {
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 20px rgba(255, 255, 255, 0.2);
}
.diff-card-hard {
  border-color: rgba(16, 185, 129, 0.35);
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.04) 0%, var(--bg-01) 100%);
}
.diff-card-hard:hover {
  border-color: #10b981;
}

/* ─── Category Info View ─── */
.info-card-wrap {
  background: var(--bg-01);
  border: 1px solid var(--border-lo);
  border-radius: var(--r-xl);
  padding: 40px;
  max-width: 840px;
  margin: 20px auto 0;
}
.info-card-wrap h2 {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: -.03em;
  margin-bottom: 12px;
}
.info-lead {
  font-size: 16px;
  color: var(--t-70);
  line-height: 1.7;
  margin-bottom: 28px;
}
.info-features-box, .info-sample-box {
  background: var(--bg-02);
  border: 1px solid var(--border-lo);
  border-radius: var(--r-lg);
  padding: 24px;
  margin-bottom: 24px;
}
.info-features-box h3, .info-sample-box h3 {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--t-45);
  margin-bottom: 14px;
}
.info-features-box ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.info-features-box li {
  font-size: 14px;
  color: var(--t-100);
  display: flex;
  align-items: center;
  gap: 10px;
}
.info-features-box li::before {
  content: '•';
  color: #10b981;
  font-size: 20px;
  line-height: 1;
}
.sample-content {
  font-size: 14px;
  color: var(--t-70);
  line-height: 1.65;
  font-family: monospace;
  background: var(--bg-03);
  padding: 16px 20px;
  border-radius: var(--r-md);
  border-left: 3px solid #10b981;
}
.info-action-row {
  margin-top: 32px;
}

/* ─── Exam Sticky Topbar ─── */
.exam-topbar {
  position: sticky;
  top: 3px;
  z-index: 100;
  background: rgba(0, 0, 0, 0.94);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-lo);
  padding: 14px 0;
}
.exam-topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.exam-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}
.exam-badge {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 50px;
  background: var(--t-08);
  border: 1px solid var(--border-md);
  color: var(--t-100);
}
.candidate-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--t-70);
  padding: 4px 12px;
  background: var(--bg-02);
  border-radius: 50px;
  border: 1px solid var(--border-lo);
}

/* 25-Minute Timer Display */
.timer-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 140px;
}
.timer-display {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: .06em;
  font-variant-numeric: tabular-nums;
  color: var(--t-100);
  transition: color .3s ease;
}
.timer-display.timer-warning {
  color: #f59e0b;
}
.timer-display.timer-urgent {
  color: #ef4444;
  animation: pulseTimer 1s infinite alternate;
}
@keyframes pulseTimer {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.08); opacity: 0.8; }
}
.timer-progress-wrap {
  width: 100%;
  height: 4px;
  background: var(--t-08);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}
.timer-progress-fill {
  height: 100%;
  background: #10b981;
  border-radius: 3px;
  transition: width 1s linear;
}
.timer-warning + .timer-progress-wrap .timer-progress-fill { background: #f59e0b; }
.timer-urgent + .timer-progress-wrap .timer-progress-fill { background: #ef4444; }

.btn-submit-exam {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 20px;
  border-radius: 50px;
  border: 1px solid #10b981;
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: var(--ease);
}
.btn-submit-exam:hover {
  background: #10b981;
  color: #000;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.3);
}

/* ─── Exam Layout ─── */
.exam-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}
.exam-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  align-items: start;
}
@media(max-width: 900px) {
  .exam-layout {
    grid-template-columns: 1fr;
  }
}

/* Question Palette */
.exam-palette-sidebar {
  background: var(--bg-01);
  border: 1px solid var(--border-lo);
  border-radius: var(--r-xl);
  padding: 22px;
  position: sticky;
  top: 90px;
}
.palette-head h3 {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--t-70);
}
.palette-sub {
  font-size: 11px;
  color: var(--t-45);
}
.palette-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 16px 0;
}
.palette-btn {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--r-sm);
  background: var(--bg-02);
  border: 1px solid var(--border-lo);
  color: var(--t-70);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--ease);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.palette-btn:hover {
  border-color: var(--border-hi);
  color: var(--t-100);
}
.palette-btn.current {
  border-color: var(--t-100) !important;
  background: var(--bg-03);
  color: var(--t-100);
  font-weight: 900;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}
.palette-btn.answered {
  background: rgba(16, 185, 129, 0.2);
  border-color: #10b981;
  color: #10b981;
}
.palette-btn.partial {
  background: rgba(245, 158, 11, 0.15);
  border-color: #f59e0b;
  color: #f59e0b;
}
.palette-btn.flagged::after {
  content: '';
  position: absolute;
  top: 3px;
  right: 3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #a855f7;
}

.palette-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border-lo);
  font-size: 11px;
  color: var(--t-45);
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.leg-box {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}
.leg-answered { background: #10b981; }
.leg-partial { background: #f59e0b; }
.leg-flagged { background: #a855f7; }
.leg-current { border: 1px solid #fff; }

/* ─── Main Question Stage ─── */
.exam-stage-card {
  background: var(--bg-01);
  border: 1px solid var(--border-lo);
  border-radius: var(--r-xl);
  padding: 36px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
@media(max-width: 600px) {
  .exam-stage-card { padding: 24px 16px; }
}

.q-stage-head {
  border-bottom: 1px solid var(--border-lo);
  padding-bottom: 20px;
}
.q-stage-sub {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #10b981;
}
.q-stage-title {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: -.03em;
  color: var(--t-100);
  margin: 6px 0 10px;
}
.q-stage-instruction {
  font-size: 15px;
  color: var(--t-70);
  font-weight: 500;
  line-height: 1.6;
}

/* Equations Box (PDF Style) */
.equations-stage-box {
  background: var(--bg-02);
  border: 1px solid var(--border-lo);
  border-radius: var(--r-xl);
  padding: 40px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin: 6px 0;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.4);
}
.equation-line {
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  font-weight: 800;
  letter-spacing: .04em;
  font-family: var(--font);
  color: var(--t-100);
  text-align: center;
  user-select: none;
}

/* Answer Inputs Grid (A, B, C, D in numbers) */
.answer-entry-card {
  background: var(--bg-02);
  border: 1px solid var(--border-md);
  border-radius: var(--r-lg);
  padding: 24px;
}
.entry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}
.entry-header h4 {
  font-size: 14px;
  font-weight: 800;
  color: var(--t-100);
}
.entry-note {
  font-size: 12px;
  font-weight: 600;
  color: var(--t-45);
}

.inputs-row-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
@media(max-width: 600px) {
  .inputs-row-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.var-input-group {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-03);
  border: 1px solid var(--border-lo);
  border-radius: var(--r-md);
  padding: 10px 16px;
  transition: var(--ease);
}
.var-input-group.hidden-var,
.var-input-group.d-none,
.var-input-group[style*="display: none"],
.var-input-group[style*="display:none"] {
  display: none !important;
}
.inputs-row-grid.has-3-vars {
  grid-template-columns: repeat(3, 1fr);
}
.inputs-row-grid.has-2-vars {
  grid-template-columns: repeat(2, 1fr) !important;
}
.var-input-group:focus-within {
  border-color: #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
  background: #000;
}
.var-input-group label {
  font-size: 20px;
  font-weight: 900;
  color: var(--t-70);
  user-select: none;
}
.var-input-group input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font);
  font-size: 22px;
  font-weight: 800;
  color: var(--t-100);
  text-align: center;
  -moz-appearance: textfield;
}
.var-input-group input::-webkit-outer-spin-button,
.var-input-group input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.var-input-group input::placeholder {
  color: var(--t-20);
}

/* Exam Actions Bar */
.exam-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border-lo);
  flex-wrap: wrap;
}
.exam-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: 50px;
  background: var(--bg-02);
  border: 1px solid var(--border-md);
  color: var(--t-100);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--ease);
}
.exam-btn:hover:not(:disabled) {
  background: var(--bg-03);
  border-color: var(--border-hi);
  transform: translateY(-1px);
}
.exam-btn:disabled {
  opacity: .25;
  cursor: not-allowed;
}
.btn-flag,
.btn-flag-q,
#btn-flag-q {
  color: #a855f7;
  border-color: rgba(168, 85, 247, 0.3);
}
.btn-flag.flagged-active,
.btn-flag-q.flagged-active,
#btn-flag-q.flagged-active {
  background: rgba(168, 85, 247, 0.2);
  border-color: #a855f7;
}
.btn-next {
  background: var(--t-100);
  color: #000;
  border: none;
}
.btn-next:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.88);
}

/* ─── Results View ─── */
.results-hero-card {
  background: var(--bg-01);
  border: 1px solid var(--border-lo);
  border-radius: var(--r-xl);
  padding: 44px;
  text-align: center;
  margin-bottom: 40px;
}
.res-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 4px 14px;
  border-radius: 50px;
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
  margin-bottom: 16px;
}
.results-hero-card h1 {
  font-size: clamp(2.4rem, 6vw, 4rem);
  font-weight: 900;
  letter-spacing: -.03em;
}
.res-candidate-name {
  font-size: 15px;
  color: var(--t-70);
  margin-top: 4px;
}

.results-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin: 32px auto;
  max-width: 820px;
}
.metric-card {
  background: var(--bg-02);
  border: 1px solid var(--border-lo);
  border-radius: var(--r-lg);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.m-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--t-45);
}
.m-val {
  font-size: 28px;
  font-weight: 900;
  color: var(--t-100);
}

.results-actions-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 10px;
}

/* Breakdown List */
.results-breakdown-section h3 {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -.02em;
}
.breakdown-subtitle {
  font-size: 13px;
  color: var(--t-45);
  margin-bottom: 24px;
}
.breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.breakdown-card {
  background: var(--bg-01);
  border: 1px solid var(--border-lo);
  border-radius: var(--r-lg);
  padding: 24px;
  transition: var(--ease);
}
.breakdown-card.correct-card {
  border-left: 4px solid #10b981;
}
.breakdown-card.wrong-card {
  border-left: 4px solid #ef4444;
}
.breakdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.breakdown-q-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 800;
}
.breakdown-status-badge {
  font-size: 11px;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 50px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.badge-correct { background: rgba(16, 185, 129, 0.2); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.4); }
.badge-wrong { background: rgba(239, 68, 68, 0.2); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.4); }

.breakdown-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.breakdown-eqs {
  background: var(--bg-02);
  padding: 16px 20px;
  border-radius: var(--r-md);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.breakdown-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media(max-width: 600px) {
  .breakdown-comparison { grid-template-columns: 1fr; }
}
.col-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--t-45);
  display: block;
  margin-bottom: 8px;
}
.ans-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.ans-grid span {
  padding: 5px 12px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 800;
}
.var-correct { background: rgba(16, 185, 129, 0.15); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.3); }
.var-wrong { background: rgba(239, 68, 68, 0.15); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.3); }
.var-sol { background: var(--bg-02); color: var(--t-100); border: 1px solid var(--border-md); }

.breakdown-steps {
  margin-top: 8px;
  background: var(--bg-02);
  border-radius: var(--r-md);
  padding: 12px 16px;
  border: 1px solid var(--border-lo);
}
.breakdown-steps summary {
  font-size: 12px;
  font-weight: 700;
  color: var(--t-70);
  cursor: pointer;
  user-select: none;
}
.breakdown-steps ol {
  margin: 12px 0 0 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--t-70);
}

/* ─── Figure Answer Comparison (Breakdown + Admin) ─── */
.bd-compare-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  margin-bottom: 10px;
  border: 1px solid var(--border-md);
  background: var(--bg-02);
}
.bd-compare-block.ans-pass {
  border-color: rgba(16,185,129,0.4);
  background: rgba(16,185,129,0.06);
}
.bd-compare-block.ans-fail {
  border-color: rgba(239,68,68,0.35);
  background: rgba(239,68,68,0.05);
}
.bd-compare-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.bd-compare-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--t-50);
  min-width: 130px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.bd-compare-matrix {
  font-size: 13px;
  font-weight: 600;
  color: var(--t-80);
  min-width: 110px;
}
.bd-fig-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 8px;
  border: 1px solid var(--border-md);
  background: var(--bg-01);
  overflow: hidden;
  flex-shrink: 0;
}
.bd-sol-fig-box {
  border-color: rgba(16,185,129,0.5);
  background: rgba(16,185,129,0.06);
}
.bd-verdict {
  font-size: 18px;
  font-weight: 800;
  margin-left: auto;
}
.verdict-pass { color: #10b981; }
.verdict-fail  { color: #ef4444; }
.bd-no-fig {
  color: var(--t-30);
  font-size: 20px;
}
.bd-solution-row {
  padding-top: 6px;
  border-top: 1px dashed var(--border-lo);
  margin-top: 4px;
}
.bd-same-opt .bd-compare-label { opacity: .6; }
.q-detail-figures-compare {
  margin-top: 10px;
}

/* ─── Modals (Name, Submissions, Details) ─── */
.dmat-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.dmat-modal-overlay.hidden {
  display: none !important;
}
.dmat-modal-card {
  background: var(--bg-01);
  border: 1px solid var(--border-md);
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 480px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
  animation: modalIn .2s ease;
}
.dmat-modal-card.modal-large {
  max-width: 960px;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 24px 28px 18px;
  border-bottom: 1px solid var(--border-lo);
}
.modal-header-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -.02em;
  color: var(--t-100);
}
.modal-sub {
  font-size: 12px;
  color: var(--t-45);
  margin-top: 3px;
  display: block;
}
.modal-close-x {
  background: none;
  border: none;
  color: var(--t-45);
  font-size: 18px;
  cursor: pointer;
  padding: 6px;
  transition: color .2s ease;
}
.modal-close-x:hover { color: var(--t-100); }

.modal-body {
  padding: 24px 28px;
}
.modal-specs-strip {
  display: flex;
  gap: 16px;
  font-size: 13px;
  background: var(--bg-02);
  padding: 12px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-lo);
}
.modal-specs-strip span { color: var(--t-45); }
.modal-specs-strip strong { color: var(--t-100); }

.form-group label {
  font-size: 13px;
  font-weight: 700;
  color: var(--t-70);
  display: block;
  margin-bottom: 8px;
}
.modal-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-02);
  border: 1px solid var(--border-md);
  border-radius: var(--r-md);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  color: var(--t-100);
  outline: none;
  transition: var(--ease);
}

/* Test Set Selector in Start Modal */
.test-set-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.test-set-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-02);
  border: 1.5px solid var(--border-lo);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: var(--ease);
  user-select: none;
}
.test-set-label:hover {
  background: var(--bg-03);
  border-color: var(--border-md);
}
.test-set-label.active {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.08);
}
.modal-input:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}
.modal-note {
  font-size: 12px;
  color: var(--t-45);
  line-height: 1.5;
  margin-top: 14px;
}
.error-msg {
  color: #ef4444;
  font-size: 12px;
  margin-top: 6px;
  font-weight: 600;
}

.modal-footer {
  padding: 18px 28px;
  background: var(--bg-02);
  border-top: 1px solid var(--border-lo);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: 50px;
  background: var(--t-100);
  color: #000;
  border: none;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: var(--ease);
}
.btn-primary:hover {
  background: rgba(255, 255, 255, 0.88);
  transform: translateY(-1px);
}
.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 50px;
  background: var(--t-08);
  color: var(--t-70);
  border: 1px solid var(--border-md);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--ease);
}
.btn-secondary:hover {
  color: var(--t-100);
  border-color: var(--border-hi);
  background: var(--bg-03);
}

/* ─── Submissions Table ─── */
.sub-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-wrap input {
  padding: 8px 14px;
  border-radius: var(--r-sm);
  background: var(--bg-02);
  border: 1px solid var(--border-md);
  color: var(--t-100);
  font-family: var(--font);
  font-size: 13px;
  width: 280px;
  outline: none;
}
.search-wrap input:focus {
  border-color: var(--border-hi);
}
.sub-export-btns {
  display: flex;
  gap: 8px;
}
.btn-sm {
  padding: 7px 14px;
  border-radius: var(--r-sm);
  background: var(--bg-02);
  border: 1px solid var(--border-md);
  color: var(--t-100);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-sm:hover {
  background: var(--bg-03);
  border-color: var(--border-hi);
}
.btn-danger {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: #ef4444;
}

.sub-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-lo);
  border-radius: var(--r-lg);
  max-height: 480px;
}
.sub-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}
.sub-table th {
  padding: 12px 16px;
  background: var(--bg-02);
  color: var(--t-45);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-md);
  position: sticky;
  top: 0;
  z-index: 10;
}
.sub-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-lo);
  vertical-align: middle;
}
.sub-table tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.rank-num {
  font-weight: 800;
  color: var(--t-45);
  font-size: 12px;
}
.candidate-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}
.c-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--t-08);
  border: 1px solid var(--border-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 900;
  color: var(--t-100);
}
.c-name {
  font-weight: 800;
  color: var(--t-100);
}
.diff-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--r-xs);
  text-transform: uppercase;
}
.diff-tag.hard { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.diff-tag.medium { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.diff-tag.easy { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }

.badge-tag-diff {
  display: inline-block;
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-lo);
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 600;
  color: var(--t-80);
  white-space: nowrap;
}

/* Real-Time Live Sync Status Pill */
.live-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 50px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  font-size: 11px;
  font-weight: 700;
  color: #10b981;
}

.live-status-pill.syncing {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
  color: #fbbf24;
}

.live-status-pill.offline {
  background: rgba(148, 163, 184, 0.1);
  border-color: rgba(148, 163, 184, 0.3);
  color: #94a3b8;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: livePulse 1.8s infinite ease-in-out;
}

.live-dot.syncing {
  background: #fbbf24;
  box-shadow: 0 0 8px #fbbf24;
}

.live-dot.offline {
  background: #94a3b8;
  box-shadow: none;
  animation: none;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.8); }
}

.score-badge {
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 50px;
  font-size: 12px;
}
.pill-green { background: rgba(16, 185, 129, 0.15); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.3); }
.pill-yellow { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.pill-red { background: rgba(239, 68, 68, 0.15); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.3); }

.time-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--t-100);
  font-variant-numeric: tabular-nums;
}
.time-cell svg { color: var(--t-45); }
.time-sub {
  color: var(--t-45);
  font-size: 11px;
}
.date-txt {
  color: var(--t-45);
  font-size: 12px;
  white-space: nowrap;
}
.action-btns {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.btn-sm-view {
  padding: 4px 10px;
  border-radius: var(--r-xs);
  background: var(--bg-03);
  border: 1px solid var(--border-md);
  color: var(--t-100);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.btn-sm-view:hover {
  background: var(--t-100);
  color: #000;
}
.btn-sm-del {
  padding: 4px 8px;
  border-radius: var(--r-xs);
  background: transparent;
  border: 1px solid transparent;
  color: var(--t-45);
  cursor: pointer;
}
.btn-sm-del:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.sub-empty {
  padding: 40px;
  text-align: center;
  color: var(--t-45);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* Detail Inspection Modal */
.sub-details-meta {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--t-70);
  margin-top: 4px;
  flex-wrap: wrap;
}
.sub-q-detail {
  background: var(--bg-02);
  border: 1px solid var(--border-lo);
  border-radius: var(--r-md);
  padding: 16px;
  margin-bottom: 12px;
}
.sub-q-detail.q-correct { border-left: 3px solid #10b981; }
.sub-q-detail.q-wrong { border-left: 3px solid #ef4444; }
.q-detail-head {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 8px;
}
.q-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 50px;
  text-transform: uppercase;
}
.q-detail-eqs {
  font-family: monospace;
  font-size: 13px;
  line-height: 1.5;
  color: var(--t-70);
  margin-bottom: 10px;
  background: var(--bg-03);
  padding: 8px 12px;
  border-radius: var(--r-xs);
}
.q-detail-ans {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  flex-wrap: wrap;
  gap: 8px;
}

/* Hide footer during exam on mobile */
body.exam-active .site-footer { display: none; }

/* ═══════════════════════════════════════
   MOBILE-FIRST RESPONSIVE DESIGN
   Full coverage: 900px → 380px
═══════════════════════════════════════ */

/* ── Tablet / Small Desktop (≤900px) ── */
@media (max-width: 900px) {
  .exam-container {
    padding: 10px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
  }
  .exam-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  .exam-palette-sidebar {
    position: static;
    padding: 10px 12px;
    border-radius: var(--r-md);
    order: -1;
    min-width: 0;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
  }
  .palette-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  .palette-head h3 { font-size: 10px; margin: 0; }
  .palette-grid {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    padding: 6px 0 4px;
    margin: 4px 0 0;
    scrollbar-width: none;
    min-width: 0;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
  }
  .palette-grid::-webkit-scrollbar { display: none; }
  .palette-btn {
    min-width: 38px; width: 38px; height: 38px;
    flex-shrink: 0; border-radius: 8px; font-size: 13px;
  }
  .palette-legend { display: none; }
  .palette-sub { display: none; }
  .exam-topbar-inner { padding: 0 12px; gap: 8px; }
  .timer-display { font-size: 22px; }
}

/* ── Mobile (≤640px) ── */
@media (max-width: 640px) {
  /* ─ Header ─ */
  .site-header { padding: 6px 0; }
  .header-inner { padding: 0 10px; gap: 6px; }
  .logo-text { font-size: 14px; }
  .portal-badge { display: none; }
  .dmat-btn-sub span:not(.badge-count) { display: none; }
  .dmat-btn-sub { padding: 6px 8px; gap: 4px; min-height: 36px; }
  .back-btn { padding: 6px 10px; font-size: 11px; min-height: 36px; }

  /* ─ Hero ─ */
  .page-hero { padding: 20px 12px 12px; }
  .page-hero h1 { font-size: clamp(1.5rem, 7vw, 2rem); }
  .page-hero p { font-size: 12px; }
  .hero-stats-row {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 6px; width: 100%; margin-top: 12px;
  }
  .h-stat-item { padding: 8px 10px; }
  .h-stat-num { font-size: 16px; }
  .h-stat-btn {
    grid-column: 1 / -1; width: 100%; justify-content: center;
    padding: 10px 12px; font-size: 11px; min-height: 40px;
  }

  /* ─ Category Cards ─ */
  .cols-2-dmat { grid-template-columns: 1fr; gap: 10px; }
  .dmat-cat-card { padding: 18px 14px 12px; min-height: auto; }
  .card-num-pill { top: 10px; right: 10px; width: 22px; height: 22px; font-size: 10px; }
  .featured-ribbon { top: 8px; left: 14px; font-size: 8px; padding: 2px 7px; }
  .dmat-cat-card .card-level { font-size: 17px; }
  .dmat-cat-card .card-desc { font-size: 12px; }

  /* ─ Difficulty Cards ─ */
  .cards-grid.cols-3,
  .cards-grid.cols-4 { grid-template-columns: 1fr; gap: 10px; }
  .diff-card { padding: 18px 14px; }
  .diff-title { font-size: 20px; }
  .diff-specs { padding: 8px 12px; font-size: 11px; }
  .btn-diff-action { padding: 12px 14px; font-size: 13px; min-height: 44px; }

  /* ─ Exam Topbar: compact 3-row stack ─ */
  .exam-topbar { padding: 5px 0; }
  .exam-topbar-inner {
    padding: 0 10px; flex-wrap: wrap; gap: 4px; row-gap: 4px;
  }
  .exam-meta {
    order: 1; width: 100%;
    justify-content: space-between; gap: 6px;
  }
  .exam-badge {
    font-size: 9px; padding: 2px 7px;
    white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; max-width: 55%;
  }
  .candidate-pill { font-size: 10px; padding: 2px 8px; }
  .timer-box {
    order: 2; width: 100%;
    flex-direction: row; align-items: center;
    gap: 8px; min-width: 0;
  }
  .timer-display { font-size: 18px; letter-spacing: .03em; white-space: nowrap; }
  .timer-progress-wrap { flex: 1; height: 4px; }
  .exam-topbar-actions { order: 3; width: 100%; }
  .btn-submit-exam {
    width: 100%; justify-content: center;
    padding: 8px 12px; font-size: 12px;
    min-height: 40px; border-radius: var(--r-md);
  }

  /* ─ Palette: ultra-compact ─ */
  .exam-palette-sidebar { padding: 8px 10px; }
  .palette-head h3 { font-size: 9px; }
  .palette-btn { min-width: 36px; width: 36px; height: 36px; font-size: 13px; }

  /* ─ Exam Stage ─ */
  .exam-stage {
    min-width: 0;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
  }
  .exam-stage-card {
    padding: 12px 10px; gap: 10px; border-radius: var(--r-md);
    overflow: hidden; width: 100%; max-width: 100%; box-sizing: border-box;
  }
  .q-stage-head { padding-bottom: 10px; }
  .q-stage-sub { font-size: 9px; }
  .q-stage-title { font-size: 18px; margin: 2px 0 4px; }
  .q-stage-instruction { font-size: 11px; line-height: 1.4; }

  /* ─ Equations Box: tighter + centered ─ */
  .equations-stage-box {
    padding: 16px 10px;
    gap: 8px;
    border-radius: var(--r-md);
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
  }
  .equation-line {
    font-size: clamp(1.05rem, 5vw, 1.5rem);
    text-align: center;
    width: 100%;
    margin: 0 auto;
    letter-spacing: .02em;
    display: block;
  }

  /* ─ Answer Inputs: ALWAYS 2×2 equal grid ─ */
  .answer-entry-card {
    padding: 12px 10px;
    border-radius: var(--r-md);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  .entry-header { margin-bottom: 8px; }
  .entry-header h4 { font-size: 12px; }
  .entry-note { font-size: 10px; }
  .inputs-row-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }
  .inputs-row-grid.has-3-vars {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .inputs-row-grid.has-3-vars .var-input-group:nth-child(3) {
    grid-column: span 2 !important;
  }
  .var-input-group.hidden-var,
  .var-input-group.d-none,
  .var-input-group[style*="display: none"],
  .var-input-group[style*="display:none"] {
    display: none !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  .var-input-group {
    display: flex;
    align-items: center !important;
    justify-content: center !important;
    padding: 8px 10px !important;
    gap: 8px !important;
    border-radius: 8px !important;
    min-width: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .var-input-group label {
    font-size: 15px !important;
    font-weight: 800 !important;
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    width: auto !important;
    display: inline-flex !important;
    align-items: center !important;
  }
  .var-input-group input {
    font-size: 18px !important;
    min-width: 0 !important;
    width: 100% !important;
    flex: 1 !important;
    text-align: center !important;
    padding: 2px 0 !important;
  }

  /* ─ Nav Buttons: flex row, no overflow ─ */
  .exam-actions-bar {
    gap: 6px; padding-top: 8px;
    flex-wrap: nowrap; overflow: hidden;
  }
  .exam-btn {
    padding: 9px 0; font-size: 11px; gap: 4px;
    min-height: 40px; flex: 1; justify-content: center;
    white-space: nowrap; border-radius: 10px;
  }
  .btn-flag span,
  .btn-flag-q span,
  #btn-flag-q span { display: none; }
  .btn-next span { display: inline; }

  /* ─ Hide footer during exam ─ */
  #view-exam ~ .site-footer { display: none; }
  .site-footer { padding: 12px 10px; font-size: 11px; }

  /* ─ Results ─ */
  .results-hero-card { padding: 18px 12px; }
  .results-hero-card h1 { font-size: clamp(1.8rem, 8vw, 2.6rem); }
  .results-metrics-grid { grid-template-columns: 1fr 1fr; gap: 6px; margin: 14px auto; }
  .metric-card { padding: 10px 8px; }
  .m-val { font-size: 18px; }
  .results-actions-row { flex-direction: column; gap: 6px; }
  .results-actions-row .btn-primary,
  .results-actions-row .btn-secondary { width: 100%; justify-content: center; min-height: 44px; }
  .breakdown-card { padding: 12px 10px; }
  .breakdown-header { flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
  .breakdown-q-title { font-size: 13px; }
  .breakdown-eqs { font-size: 12px; padding: 10px 12px; }
  .breakdown-comparison { grid-template-columns: 1fr; gap: 10px; }

  /* ─ Modals: centered on mobile ─ */
  .dmat-modal-overlay {
    align-items: center;
    justify-content: center;
    padding: 16px;
  }
  .dmat-modal-overlay.hidden {
    display: none !important;
  }
  .dmat-modal-card {
    max-height: 90vh;
    width: 100% !important;
    max-width: 420px !important;
    margin: auto !important;
    border-radius: 16px !important;
    display: flex;
    flex-direction: column;
  }
  .modal-large { max-height: 95vh; }
  .modal-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px; flex: 1; }
  .modal-header { padding: 12px 14px; }
  .modal-header h3 { font-size: 16px; }
  .modal-footer { padding: 10px 14px; flex-wrap: wrap; gap: 6px; }
  .modal-footer .btn-primary,
  .modal-footer .btn-secondary { flex: 1; min-height: 44px; justify-content: center; }
  .sub-controls-row { flex-direction: column; align-items: stretch; gap: 6px; }
  .search-wrap input { width: 100%; }
  .sub-export-btns { display: flex; }
  .sub-export-btns .btn-sm { flex: 1; justify-content: center; min-height: 38px; }
  .sub-table { font-size: 12px; }

  /* Info card */
  .info-card-wrap { padding: 16px 14px; border-radius: var(--r-lg); }
  .info-card-wrap h2 { font-size: 20px; }
  .info-action-row .btn-primary { width: 100%; text-align: center; }
}

/* ── Extra-small phones (≤380px) ── */
@media (max-width: 380px) {
  .exam-badge { max-width: 50%; font-size: 8px; }
  .timer-display { font-size: 16px; }
  .equation-line { font-size: clamp(0.95rem, 5.5vw, 1.25rem); }
  .page-hero h1 { font-size: 1.4rem; }
  .q-stage-title { font-size: 16px; }
  .dmat-modal-card { max-height: 92vh; border-radius: 16px !important; margin: auto !important; }
  .sub-table th:nth-child(6),
  .sub-table td:nth-child(6) { display: none; }
  .m-val { font-size: 16px; }
  .palette-btn { min-width: 34px; width: 34px; height: 34px; font-size: 12px; }
}

/* ══════════════════════════════════════════
   FIGURE SEQUENCES (FORMENREIHEN) ENGINE
══════════════════════════════════════════ */
.figures-stage-wrap {
  margin: 20px 0 24px;
}

/* Sequence Strip (Matrices 1 to 6) */
.figures-sequence-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  background: var(--bg-01);
  border: 1px solid var(--border-lo);
  border-radius: var(--r-md);
  margin-bottom: 24px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.matrix-seq-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.matrix-seq-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--t-60);
}

.matrix-seq-item.highlight-unknown .matrix-seq-title {
  color: #38bdf8;
}

.matrix-svg-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  transition: transform 0.2s, border-color 0.2s;
}

.matrix-seq-unknown-box {
  width: 90px;
  height: 90px;
  border-radius: 6px;
  border: 2px dashed rgba(56, 189, 248, 0.4);
  background: rgba(56, 189, 248, 0.04);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.matrix-seq-unknown-box .unknown-qmark {
  font-size: 32px;
  font-weight: 900;
  color: #38bdf8;
  line-height: 1;
}

.matrix-seq-unknown-box .unknown-sub {
  font-size: 9px;
  font-weight: 700;
  color: var(--t-45);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.seq-arrow-divider {
  color: var(--border-md);
  font-size: 16px;
  font-weight: 700;
  user-select: none;
  flex-shrink: 0;
}

/* Options Section */
.figures-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.figures-opt-col {
  background: var(--bg-01);
  border: 1px solid var(--border-lo);
  border-radius: var(--r-md);
  padding: 16px 18px;
}

.figures-opt-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-lo);
}

.figures-opt-col-head h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  color: var(--t-90);
  display: flex;
  align-items: center;
  gap: 8px;
}

.figures-opt-col-head .opt-hint {
  font-size: 11px;
  color: var(--t-45);
  font-weight: 500;
}

.figures-opts-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.figure-opt-card {
  background: var(--bg-02);
  border: 2px solid var(--border-lo);
  border-radius: 8px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  user-select: none;
}

.figure-opt-card:hover {
  border-color: rgba(255,255,255,0.3);
  background: var(--bg-03);
  transform: translateY(-2px);
}

.figure-opt-card.selected {
  border-color: #10b981 !important;
  background: rgba(16, 185, 129, 0.12) !important;
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.3) !important;
  transform: translateY(-2px);
}

.figure-opt-card .opt-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 800;
  background: rgba(255,255,255,0.08);
  color: var(--t-80);
  border: 1px solid var(--border-md);
  transition: all 0.2s;
}

.figure-opt-card.selected .opt-badge {
  background: #10b981;
  color: #000;
  border-color: #10b981;
}

.figure-opt-card .opt-status {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--t-45);
  height: 14px;
}

.figure-opt-card.selected .opt-status {
  color: #10b981;
}

/* 5 Test selector in modal */
.test-set-grid-5 {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.test-set-btn-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 6px;
  background: var(--bg-02);
  border: 1.5px solid var(--border-lo);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.test-set-btn-card:hover {
  border-color: rgba(255,255,255,0.3);
}

.test-set-btn-card.active {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.1);
}

.test-set-btn-card input[type="radio"] {
  display: none;
}

.test-set-btn-title {
  font-size: 13px;
  font-weight: 800;
  color: #fff;
}

.test-set-btn-sub {
  font-size: 10px;
  color: var(--t-45);
  margin-top: 2px;
}

@media (max-width: 768px) {
  .figures-options-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .test-set-grid-5 {
    grid-template-columns: repeat(3, 1fr);
  }
  .figures-sequence-strip {
    justify-content: flex-start;
    padding: 12px 10px;
  }
}




/* ─── Latin Squares Grid Styling ─── */
.latin-grid-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 18px auto;
  user-select: none;
}

.latin-grid-table {
  border-collapse: collapse;
  background: rgba(15, 23, 42, 0.7);
  border: 2px solid rgba(168, 85, 247, 0.4);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

.latin-grid-table th,
.latin-grid-table td {
  width: 52px;
  height: 52px;
  text-align: center;
  vertical-align: middle;
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 1.25rem;
  font-weight: 700;
  color: #f8fafc;
  box-sizing: border-box;
}

.latin-grid-table th {
  background: rgba(30, 41, 59, 0.7);
  color: #a855f7;
  font-size: 1rem;
  font-weight: 800;
}

.latin-grid-table th.row-idx {
  background: rgba(30, 41, 59, 0.7);
  color: #94a3b8;
  font-size: 0.95rem;
  width: 38px;
}

.latin-grid-table td.cell-filled {
  color: #f1f5f9;
  font-size: 1.35rem;
  font-weight: 800;
}

.latin-grid-table td.cell-empty {
  background: rgba(15, 23, 42, 0.4);
}

.latin-grid-table td.cell-target {
  background: #fef08a !important; /* Yellow target matching the PDF */
  color: #0f172a !important;
  font-size: 1.45rem;
  font-weight: 900;
  box-shadow: inset 0 0 12px rgba(234, 179, 8, 0.5);
  animation: pulse-target 2s infinite ease-in-out;
}

@keyframes pulse-target {
  0%, 100% { background: #fef08a; }
  50% { background: #fef9c3; }
}

/* Response Options Row (A - E) */
.latin-options-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin: 18px 0 10px;
}

.latin-opt-btn {
  width: 54px;
  height: 54px;
  border-radius: 12px;
  background: rgba(30, 41, 59, 0.7);
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  color: #f8fafc;
  font-size: 1.3rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.latin-opt-btn:hover {
  background: rgba(168, 85, 247, 0.25);
  border-color: #c084fc;
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(168, 85, 247, 0.3);
}

.latin-opt-btn.selected {
  background: #a855f7 !important;
  border-color: #c084fc !important;
  color: #ffffff !important;
  box-shadow: 0 0 14px rgba(168, 85, 247, 0.5) !important;
  transform: scale(1.05);
}

/* Breakdown Mini Grid for Latin Squares */
.latin-breakdown-grid {
  border-collapse: collapse;
  margin: 8px 0;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  overflow: hidden;
}

.latin-breakdown-grid th,
.latin-breakdown-grid td {
  width: 32px;
  height: 32px;
  text-align: center;
  vertical-align: middle;
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.85rem;
  font-weight: 700;
}

.latin-breakdown-grid th {
  background: rgba(30, 41, 59, 0.8);
  color: #c084fc;
  font-size: 0.75rem;
}

.latin-breakdown-grid td.cell-target {
  background: #fef08a !important;
  color: #0f172a !important;
  font-weight: 900;
}

@media (max-width: 480px) {
  .latin-grid-table th,
  .latin-grid-table td {
    width: 40px;
    height: 40px;
    font-size: 1.05rem;
  }
  .latin-grid-table th.row-idx {
    width: 30px;
    font-size: 0.85rem;
  }
  .latin-opt-btn {
    width: 44px;
    height: 44px;
    font-size: 1.15rem;
  }
}


/* ══════════════════════════════════════════════
   LATIN SQUARES BREAKDOWN ENHANCED STYLING
   ══════════════════════════════════════════════ */
.latin-breakdown-grid {
  border-collapse: separate !important;
  border-spacing: 2px !important;
  margin: 6px 0 !important;
  background: rgba(15, 23, 42, 0.85) !important;
  border: 1px solid rgba(168, 85, 247, 0.3) !important;
  border-radius: 8px !important;
  padding: 6px !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5) !important;
}

.latin-breakdown-grid th,
.latin-breakdown-grid td {
  width: 34px !important;
  height: 34px !important;
  min-width: 34px !important;
  min-height: 34px !important;
  text-align: center !important;
  vertical-align: middle !important;
  border-radius: 4px !important;
  font-family: inherit !important;
  transition: all 0.2s ease !important;
}

.latin-breakdown-grid th {
  background: rgba(30, 41, 59, 0.9) !important;
  color: #c084fc !important;
  font-size: 12px !important;
  font-weight: 800 !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.latin-breakdown-grid td {
  background: rgba(255, 255, 255, 0.04) !important;
  color: #f1f5f9 !important;
  font-size: 14px !important;
  font-weight: 700 !important;
  border: 1px solid rgba(255, 255, 255, 0.06) !important;
}

.latin-breakdown-grid td.cell-target {
  background: linear-gradient(135deg, #fef08a, #facc15) !important;
  color: #0f172a !important;
  font-weight: 900 !important;
  font-size: 16px !important;
  box-shadow: 0 0 10px rgba(250, 204, 21, 0.5) !important;
  border: 2px solid #ca8a04 !important;
}

.comparison-col {
  background: rgba(255, 255, 255, 0.03);
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.comp-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--t-45);
  display: block;
  margin-bottom: 6px;
}

.comp-values {
  display: flex;
  align-items: center;
  gap: 8px;
}

.comp-values span {
  font-size: 15px;
  font-weight: 800;
  padding: 6px 14px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
}

.breakdown-card .breakdown-steps {
  background: rgba(168, 85, 247, 0.04) !important;
  border: 1px solid rgba(168, 85, 247, 0.2) !important;
  border-left: 3px solid #a855f7 !important;
  border-radius: 8px !important;
  padding: 12px 16px !important;
}

.breakdown-card .breakdown-steps summary {
  font-size: 12px !important;
  font-weight: 800 !important;
  color: #c084fc !important;
  cursor: pointer !important;
}
