/* ============================================================
   Tests Administrativo GVA C1-01 — Edición 2026
   Estilo limpio, enfocado al estudio. Mobile-first responsive.
   ============================================================ */

:root {
  --c-bg: #f6f7fb;
  --c-bg-elev: #ffffff;
  --c-text: #1a2030;
  --c-text-soft: #4d5a73;
  --c-muted: #828ea3;
  --c-border: #e5e9f0;
  --c-primary: #2856e6;
  --c-primary-dark: #1c43c4;
  --c-primary-soft: #e6edff;
  --c-success: #1f8a4c;
  --c-success-soft: #e3f6ec;
  --c-error: #c5293a;
  --c-error-soft: #fbe6e9;
  --c-warning: #b07206;
  --c-warning-soft: #fff5dc;
  --c-shadow: 0 1px 2px rgba(20,30,60,.04), 0 4px 16px rgba(20,30,60,.06);
  --c-shadow-up: 0 -2px 12px rgba(20,30,60,.08);
  --r: 12px;
  --space: 1rem;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --c-bg: #11151c;
    --c-bg-elev: #1a212c;
    --c-text: #e9edf3;
    --c-text-soft: #b0b9c8;
    --c-muted: #7e8a9b;
    --c-border: #2a323f;
    --c-primary: #5d8cff;
    --c-primary-dark: #4172e0;
    --c-primary-soft: rgba(93,140,255,.16);
    --c-success: #4dc683;
    --c-success-soft: rgba(77,198,131,.15);
    --c-error: #ff7080;
    --c-error-soft: rgba(255,112,128,.15);
    --c-warning: #f0b85a;
    --c-warning-soft: rgba(240,184,90,.18);
    --c-shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 24px rgba(0,0,0,.35);
    --c-shadow-up: 0 -4px 20px rgba(0,0,0,.5);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.5;
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  overflow-wrap: break-word;
}

h1, h2, h3, h4 { color: var(--c-text); }
p { color: var(--c-text-soft); }
.muted { color: var(--c-muted); font-size: .92em; }

a { color: var(--c-primary); }

/* =================== Header =================== */
.topbar {
  background: var(--c-bg-elev);
  border-bottom: 1px solid var(--c-border);
  padding: .7rem 1.25rem;
  padding-top: calc(.7rem + var(--safe-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
.brand { display: flex; align-items: center; gap: .85rem; min-width: 0; }
.logo {
  font-size: 1.7rem;
  background: var(--c-primary-soft);
  width: 42px; height: 42px;
  border-radius: 10px;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.brand h1 { margin: 0; font-size: 1.05rem; line-height: 1.2; }
.subtitle { margin: 0; font-size: .8rem; color: var(--c-muted); }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.nav-btn {
  background: transparent;
  border: 0;
  padding: .55rem .9rem;
  border-radius: 8px;
  font-size: .92rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--c-text-soft);
  font-family: inherit;
  min-height: 40px;
}
.nav-btn:hover { background: var(--c-primary-soft); color: var(--c-primary); }
.nav-btn.active { background: var(--c-primary-soft); color: var(--c-primary); }

/* =================== Container =================== */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.4rem 1rem 4rem;
}

.card {
  background: var(--c-bg-elev);
  border: 1px solid var(--c-border);
  border-radius: var(--r);
  padding: 1.4rem 1.4rem 1.6rem;
  box-shadow: var(--c-shadow);
}

.loading { text-align: center; padding: 3rem; }
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--c-border);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =================== Grid =================== */
.grid { display: grid; gap: 1.4rem; }
.grid-2 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
@media (min-width: 800px) {
  .grid-2 { grid-template-columns: 1.1fr .9fr; }
}

.block h3 { margin: 0 0 .8rem; font-size: 1rem; }

/* =================== Tema selectors =================== */
.row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.row > h2 { margin: 0; flex: 1; }
.btn-link {
  background: transparent; border: 0;
  color: var(--c-primary);
  cursor: pointer;
  font-size: .9rem;
  padding: .35rem .55rem;
  font-weight: 600;
  font-family: inherit;
  min-height: 36px;
}
.btn-link:hover { text-decoration: underline; }
.btn-link.danger { color: var(--c-error); }

.parte-list { display: flex; flex-direction: column; gap: .85rem; }
.parte {
  border: 1px solid var(--c-border);
  border-radius: var(--r);
  padding: .9rem 1rem;
  background: var(--c-bg-elev);
}
.parte-head {
  display: flex; align-items: center; gap: .6rem;
  margin: -.4rem -.5rem .55rem;
  padding: .4rem .5rem;
  cursor: pointer;
  user-select: none;
  border-radius: 8px;
}
.parte-head:hover { background: var(--c-bg); }
.parte-head h4 { margin: 0; font-size: 1rem; }
.parte-head .parte-sub { font-size: .8rem; color: var(--c-muted); margin-left: auto; }
.parte-head .toggle { color: var(--c-muted); font-size: .85rem; transition: transform .15s; }
.parte.collapsed .toggle { transform: rotate(-90deg); }
.tema-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: .25rem;
}
@media (min-width: 720px) {
  .tema-grid { grid-template-columns: 1fr 1fr; }
}
.parte.collapsed .tema-grid { display: none; }
.tema-row {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .55rem .55rem;
  border-radius: 8px;
  font-size: .94rem;
  cursor: pointer;
  min-height: 44px;
}
.tema-row:hover { background: var(--c-primary-soft); }
.tema-row input { margin: 0; width: 18px; height: 18px; flex-shrink: 0; accent-color: var(--c-primary); }
.tema-row .num {
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: 6px;
  padding: .15rem .45rem;
  font-size: .75rem;
  color: var(--c-text-soft);
  font-weight: 700;
  min-width: 36px;
  text-align: center;
  flex-shrink: 0;
}
.tema-row .ttl { flex: 1; min-width: 0; }
.tema-row .count { color: var(--c-muted); font-size: .78rem; flex-shrink: 0; }

/* =================== Form fields =================== */
.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .9rem; }
.field span { font-size: .9rem; color: var(--c-text-soft); }
.field.checkbox { flex-direction: row; align-items: center; gap: .6rem; padding: .35rem 0; }
.field.checkbox input { width: 18px; height: 18px; accent-color: var(--c-primary); }
.field.checkbox span { color: var(--c-text); font-size: .94rem; }
select, input[type="number"], input[type="text"] {
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  color: var(--c-text);
  padding: .65rem .75rem;
  border-radius: 8px;
  font-size: 16px; /* prevents iOS zoom */
  font-family: inherit;
  min-height: 44px;
}
select:focus, input:focus { outline: 2px solid var(--c-primary); outline-offset: 1px; }

/* =================== Buttons =================== */
.btn-primary, .btn-secondary, .btn-ghost {
  border: 1px solid transparent;
  padding: .65rem 1.1rem;
  border-radius: 10px;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
}
.btn-primary { background: var(--c-primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--c-primary-dark); }
.btn-primary:active:not(:disabled) { transform: scale(.98); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary { background: var(--c-primary-soft); color: var(--c-primary); }
.btn-secondary:hover { background: rgba(40,86,230,.18); }
.btn-ghost {
  background: transparent;
  color: var(--c-text-soft);
  border-color: var(--c-border);
}
.btn-ghost:hover { background: var(--c-bg); color: var(--c-text); }
.btn-ghost:disabled { opacity: .4; cursor: not-allowed; }
.btn-icon { width: 44px; padding: 0; }

.action-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; flex-wrap: wrap;
  margin-top: 1.4rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--c-border);
}
.action-bar .meta-info { color: var(--c-muted); font-size: .92rem; flex: 1; min-width: 180px; }

/* =================== Test view =================== */
.test-view { display: flex; flex-direction: column; gap: 1rem; }

.test-head {
  display: flex; align-items: center; gap: .8rem;
  padding: .8rem 1rem;
  background: var(--c-bg-elev);
  border: 1px solid var(--c-border);
  border-radius: var(--r);
  position: sticky;
  top: calc(var(--safe-top) + 60px); /* below the topbar */
  z-index: 50;
  box-shadow: var(--c-shadow);
}
.progress { flex: 1; min-width: 0; }
.progress-text {
  font-size: .82rem;
  color: var(--c-muted);
  margin-bottom: .3rem;
  font-weight: 600;
}
.progress-bar {
  height: 8px;
  background: var(--c-border);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--c-primary), var(--c-primary-dark));
  border-radius: 4px;
  width: 0;
  transition: width .25s;
}
.test-controls { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.timer {
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  padding: .45rem .8rem;
  border-radius: 8px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: .95rem;
  white-space: nowrap;
  min-height: 40px;
  display: inline-flex; align-items: center; gap: .25rem;
}
.timer.warn { background: var(--c-warning-soft); color: var(--c-warning); border-color: var(--c-warning); }
.timer.urgent { background: var(--c-error-soft); color: var(--c-error); border-color: var(--c-error); animation: pulse 1.2s infinite; }
@keyframes pulse {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

.question-card { padding: 1.3rem 1.3rem 1.6rem; }
.tema-tag {
  display: inline-block;
  background: var(--c-primary-soft);
  color: var(--c-primary);
  font-size: .78rem;
  padding: .3rem .65rem;
  border-radius: 6px;
  font-weight: 700;
  margin-bottom: .9rem;
  letter-spacing: .02em;
}
.question-text {
  margin: 0 0 1.3rem;
  font-size: 1.08rem;
  line-height: 1.55;
  font-weight: 500;
}
.options { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .55rem; }
.option {
  border: 1.5px solid var(--c-border);
  border-radius: 12px;
  padding: .85rem 1rem;
  display: flex; align-items: flex-start; gap: .85rem;
  cursor: pointer;
  background: var(--c-bg-elev);
  transition: border-color .15s, background .15s, transform .08s;
  user-select: none;
  -webkit-user-select: none;
  min-height: 56px;
}
.option:hover { border-color: var(--c-primary); }
.option:active { transform: scale(.99); }
.option.selected { border-color: var(--c-primary); background: var(--c-primary-soft); }
.option .letter {
  background: var(--c-bg);
  color: var(--c-text-soft);
  border: 1.5px solid var(--c-border);
  width: 32px; height: 32px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700;
  font-size: .9rem;
  flex-shrink: 0;
}
.option.selected .letter { background: var(--c-primary); color: white; border-color: var(--c-primary); }
.option .opt-text { flex: 1; line-height: 1.45; padding-top: .2rem; }
.option.locked { cursor: default; }
.option.locked:hover { border-color: var(--c-border); }
.option.locked.selected:hover { border-color: var(--c-primary); }
.option.correct { border-color: var(--c-success); background: var(--c-success-soft); }
.option.correct .letter { background: var(--c-success); color: white; border-color: var(--c-success); }
.option.correct .opt-text { color: var(--c-text); }
.option.incorrect { border-color: var(--c-error); background: var(--c-error-soft); }
.option.incorrect .letter { background: var(--c-error); color: white; border-color: var(--c-error); }

.feedback {
  margin-top: 1rem;
  padding: .85rem 1rem;
  border-radius: 10px;
  font-size: .92rem;
}
.feedback.correct { background: var(--c-success-soft); color: var(--c-success); border-left: 3px solid var(--c-success); }
.feedback.incorrect { background: var(--c-error-soft); color: var(--c-error); border-left: 3px solid var(--c-error); }
.feedback small { opacity: .85; display: block; margin-top: .3rem; }

/* Test bottom action bar — sticky at bottom on mobile */
.test-bottombar {
  display: flex; align-items: center; gap: .55rem;
  padding-top: 1rem;
}
.test-bottombar > * { flex: 0 0 auto; }
.test-bottombar .nav-toggle {
  flex: 1;
  font-weight: 600;
}
.test-bottombar .btn-primary { padding-left: 1.4rem; padding-right: 1.4rem; }

/* Quick-nav as bottom-sheet on mobile, inline panel on desktop */
.quick-nav-sheet {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,.45);
  display: flex; flex-direction: column; justify-content: flex-end;
  animation: fadein .15s ease;
}
.quick-nav-sheet[hidden] { display: none; }
.quick-nav-sheet .qn-panel {
  background: var(--c-bg-elev);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  padding: 1rem 1rem calc(1.2rem + var(--safe-bottom));
  max-height: 75vh;
  display: flex; flex-direction: column;
  animation: slideup .2s ease;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideup { from { transform: translateY(20%); } to { transform: translateY(0); } }
.qn-sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .8rem; }
.qn-sheet-head h3 { margin: 0; font-size: 1rem; }
.qn-handle {
  width: 40px; height: 4px;
  background: var(--c-border);
  border-radius: 2px;
  margin: 0 auto .8rem;
}
.qn-legend {
  display: flex; flex-wrap: wrap; gap: .8rem;
  font-size: .8rem; color: var(--c-muted);
  margin-bottom: .8rem;
}
.qn-legend .dot {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 4px;
  vertical-align: middle;
  margin-right: .25rem;
  border: 1px solid var(--c-border);
}
.qn-legend .dot.answered { background: var(--c-primary-soft); border-color: var(--c-primary); }
.qn-legend .dot.current { background: transparent; outline: 2px solid var(--c-primary); }
.qn-legend .dot.blank { background: transparent; }

.quick-nav {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: .35rem;
  overflow-y: auto;
  padding: .25rem 0 .5rem;
  max-height: 55vh;
}
.qn-btn {
  width: 100%; height: 44px;
  border: 1.5px solid var(--c-border);
  background: transparent;
  border-radius: 8px;
  font-size: .85rem;
  cursor: pointer;
  color: var(--c-text-soft);
  font-family: inherit;
  font-weight: 600;
}
.qn-btn.answered { background: var(--c-primary-soft); color: var(--c-primary); border-color: var(--c-primary); }
.qn-btn.current { outline: 2px solid var(--c-primary); outline-offset: 1px; }
.qn-btn.correct-after { background: var(--c-success-soft); color: var(--c-success); border-color: var(--c-success); }
.qn-btn.wrong-after { background: var(--c-error-soft); color: var(--c-error); border-color: var(--c-error); }

/* =================== Results =================== */
.results .score-summary {
  display: flex; align-items: center; gap: 1.5rem;
  padding: 1.2rem 0;
  border-bottom: 1px solid var(--c-border);
  margin-bottom: 1.4rem;
  flex-wrap: wrap;
}
.score-big {
  font-size: 3.2rem;
  font-weight: 800;
  line-height: 1;
  color: var(--c-primary);
}
.score-big.warn { color: var(--c-warning); }
.score-big.bad { color: var(--c-error); }
.score-big.good { color: var(--c-success); }
.score-big .pct { font-size: 1.6rem; opacity: .65; font-weight: 600; }
.score-details { display: flex; flex-direction: column; gap: .3rem; font-size: .95rem; color: var(--c-text-soft); }
.score-details strong { color: var(--c-text); }

.tema-summary { display: flex; flex-direction: column; gap: .35rem; }
.tema-bar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 1rem;
  align-items: center;
  padding: .65rem .8rem;
  background: var(--c-bg);
  border-radius: 8px;
  border: 1px solid var(--c-border);
  font-size: .9rem;
}
.tema-bar .ttl { color: var(--c-text); }
.tema-bar .pct-bar { width: 100px; height: 6px; background: var(--c-border); border-radius: 3px; overflow: hidden; }
.tema-bar .pct-fill { height: 100%; background: var(--c-success); border-radius: 3px; }
.tema-bar .pct-fill.bad { background: var(--c-error); }
.tema-bar .pct-fill.warn { background: var(--c-warning); }
.tema-bar .num { color: var(--c-muted); font-size: .82rem; min-width: 60px; text-align: right; }

/* =================== Review =================== */
.review-view { display: flex; flex-direction: column; gap: 1rem; }
.review-head { align-items: flex-start; }
.review-head > div { margin-left: auto; display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.filter-toggle { display: flex; align-items: center; gap: .4rem; font-size: .9rem; color: var(--c-text-soft); cursor: pointer; }
.filter-toggle input { width: 18px; height: 18px; accent-color: var(--c-primary); }
.review-item {
  background: var(--c-bg-elev);
  border: 1px solid var(--c-border);
  border-radius: var(--r);
  padding: 1rem 1.1rem;
  box-shadow: var(--c-shadow);
}
.review-item.correct { border-left: 4px solid var(--c-success); }
.review-item.incorrect { border-left: 4px solid var(--c-error); }
.review-item.blank { border-left: 4px solid var(--c-warning); }
.review-item h4 {
  margin: 0 0 .55rem;
  font-size: 1rem;
  color: var(--c-text);
  line-height: 1.45;
}
.review-item .review-tema { font-size: .78rem; color: var(--c-muted); margin-bottom: .55rem; }
.review-item ul { list-style: none; padding: 0; margin: .5rem 0 0; display: flex; flex-direction: column; gap: .3rem; }
.review-item li {
  padding: .55rem .7rem;
  border-radius: 6px;
  font-size: .92rem;
  display: flex; gap: .6rem;
  background: var(--c-bg);
  line-height: 1.45;
}
.review-item li.right { background: var(--c-success-soft); color: var(--c-success); font-weight: 500; }
.review-item li.wrong { background: var(--c-error-soft); color: var(--c-error); font-weight: 500; }
.review-item li .letter {
  font-weight: 700;
  text-transform: uppercase;
  flex-shrink: 0;
  min-width: 18px;
}

/* =================== Footer =================== */
.footer {
  text-align: center;
  padding: 1.5rem 1rem 2rem;
  padding-bottom: calc(2rem + var(--safe-bottom));
  font-size: .82rem;
  color: var(--c-muted);
  border-top: 1px solid var(--c-border);
  background: var(--c-bg-elev);
}
.footer p { margin: 0; color: var(--c-muted); }

/* =================== History tiles =================== */
.tile {
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--r);
  padding: 1rem;
  text-align: center;
}
.tile .num { font-size: 1.7rem; font-weight: 800; color: var(--c-primary); }
.tile .lbl { font-size: .82rem; color: var(--c-muted); margin-top: .2rem; }

.history-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 1rem;
  padding: .7rem .85rem;
  border-bottom: 1px solid var(--c-border);
  font-size: .9rem;
  align-items: center;
}
.history-row:last-child { border-bottom: 0; }
.history-row .pct {
  font-weight: 800;
  padding: .2rem .55rem;
  border-radius: 6px;
}
.history-row .pct.good { background: var(--c-success-soft); color: var(--c-success); }
.history-row .pct.warn { background: var(--c-warning-soft); color: var(--c-warning); }
.history-row .pct.bad { background: var(--c-error-soft); color: var(--c-error); }

/* =================== Stats =================== */
.stat-tema {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: .8rem;
  align-items: center;
  padding: .55rem .7rem;
  border-radius: 8px;
  font-size: .9rem;
}
.stat-tema:nth-child(odd) { background: var(--c-bg); }
.stat-tema .ttl { color: var(--c-text); min-width: 0; }
.stat-tema .pct-bar { width: 120px; height: 6px; background: var(--c-border); border-radius: 3px; overflow: hidden; }
.stat-tema .pct-fill { height: 100%; border-radius: 3px; }
.stat-tema .nums { color: var(--c-muted); font-size: .82rem; min-width: 70px; text-align: right; }

/* =====================================================
   MOBILE OVERRIDES (≤ 700px)
   ===================================================== */
@media (max-width: 700px) {
  body { font-size: 16px; }

  /* Topbar: compact */
  .topbar {
    padding: .55rem .85rem;
    padding-top: calc(.55rem + var(--safe-top));
    gap: .5rem;
  }
  .brand { gap: .65rem; }
  .logo { width: 38px; height: 38px; font-size: 1.5rem; border-radius: 9px; }
  .brand h1 { font-size: .95rem; }
  .subtitle { display: none; }
  .nav { width: 100%; gap: .15rem; }
  .nav-btn {
    padding: .5rem .55rem;
    font-size: .82rem;
    flex: 1;
    text-align: center;
    justify-content: center;
    min-height: 38px;
  }

  .container { padding: 1rem .75rem 6rem; }

  .card { padding: 1.1rem 1.05rem 1.3rem; border-radius: 14px; }

  /* Home: tighter blocks */
  .grid { gap: 1rem; }
  .parte { padding: .75rem .85rem; border-radius: 12px; }
  .parte-head h4 { font-size: .95rem; }
  .tema-row { padding: .65rem .55rem; min-height: 48px; font-size: .92rem; }
  .tema-row .ttl { font-size: .9rem; line-height: 1.35; }
  .tema-row .num { font-size: .73rem; min-width: 32px; }

  .field { margin-bottom: .8rem; }

  /* Action bar: stack the meta info */
  .action-bar { gap: .8rem; }
  .action-bar .meta-info { flex-basis: 100%; min-width: 0; }
  .action-bar .btn-primary { width: 100%; }

  /* TEST view — sticky top + sticky bottom */
  body[data-view="test"] .footer { display: none; }
  body[data-view="test"] .container { padding-bottom: 7rem; }

  .test-view { gap: .85rem; }
  .test-head {
    padding: .7rem .85rem;
    border-radius: 12px;
    /* On mobile the topbar wraps to two rows, sticky offset is unreliable.
       Drop the sticky behavior — the fixed bottom bar carries navigation. */
    position: static;
  }
  .test-controls { gap: .35rem; }
  .timer {
    padding: .4rem .65rem;
    font-size: .9rem;
  }
  .question-card { padding: 1.1rem 1.05rem 1.3rem; }
  .question-text { font-size: 1.04rem; line-height: 1.5; }
  .option {
    padding: .8rem .9rem;
    gap: .75rem;
    border-radius: 11px;
  }
  .option .letter { width: 30px; height: 30px; font-size: .88rem; }
  .option .opt-text { font-size: .96rem; line-height: 1.4; }

  /* Sticky bottom action bar during test */
  .test-bottombar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 80;
    padding: .65rem .85rem calc(.65rem + var(--safe-bottom));
    background: var(--c-bg-elev);
    border-top: 1px solid var(--c-border);
    box-shadow: var(--c-shadow-up);
    margin: 0;
  }
  .test-bottombar .btn-primary,
  .test-bottombar .btn-ghost {
    padding-left: .8rem; padding-right: .8rem;
    min-height: 46px;
  }
  .test-bottombar .nav-toggle { font-size: .9rem; }

  /* Score summary stacks */
  .results .score-summary { gap: 1rem; align-items: flex-start; }
  .score-big { font-size: 2.6rem; }

  /* Review */
  .review-head { flex-direction: column; align-items: stretch; }
  .review-head > div { margin-left: 0; }
  .review-item h4 { font-size: .98rem; }

  /* History condensed */
  .history-row {
    grid-template-columns: 1fr auto;
    gap: .35rem;
    padding: .75rem .65rem;
  }
  .history-row .when { grid-column: 1 / 2; font-weight: 600; }
  .history-row .meta { grid-column: 1 / -1; font-size: .8rem; color: var(--c-muted); }
  .history-row .pct { grid-column: 2 / 3; grid-row: 1 / 2; }
  .history-row .net { grid-column: 1 / -1; font-size: .8rem; color: var(--c-muted); }

  /* Stats - mobile compact */
  .tema-bar, .stat-tema {
    grid-template-columns: 1fr auto;
    gap: .35rem;
    padding: .55rem .65rem;
  }
  .tema-bar .pct-bar, .stat-tema .pct-bar {
    grid-column: 1 / -1; width: 100%; order: 3;
  }
  .tema-bar .num, .stat-tema .nums { font-size: .8rem; }
  .tema-bar .ttl, .stat-tema .ttl { font-size: .88rem; line-height: 1.35; }

  .footer { padding: 1.2rem 1rem 1.5rem; padding-bottom: calc(1.5rem + var(--safe-bottom)); font-size: .78rem; }
}

/* Inline action bar for desktop test (no sticky bottom needed) */
@media (min-width: 701px) {
  .test-bottombar { margin-top: .5rem; }
  .test-bottombar .nav-toggle { max-width: 280px; }
}

/* Prevent body scroll when sheet is open */
body.sheet-open { overflow: hidden; }
