/* ===== wspólne tokeny ===== */
:root,
[data-theme="droga"] {
  --bg: #f7f5f0;
  --card: #ffffff;
  --text: #1a2332;
  --muted: #5c6678;
  --accent: #c45a11;
  --accent-dark: #9e4710;
  --accent-soft: #fdf0e4;
  --accent-secondary: #1e4d6b;
  --green: #2d7a4f;
  --green-bg: #e8f3ec;
  --red: #c0392b;
  --red-bg: #fbeae8;
  --amber: #b45309;
  --border: #e5e0d6;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(26, 35, 50, .06), 0 8px 24px rgba(26, 35, 50, .07);
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body: 'DM Sans', system-ui, -apple-system, sans-serif;
  --mode-exam: #c45a11;
  --mode-learn: #1e4d6b;
  --mode-errors: #c0392b;
  --mode-stats: #2d7a4f;
  --pattern: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 39px,
    rgba(30, 77, 107, .04) 39px,
    rgba(30, 77, 107, .04) 40px
  );
}

[data-theme="urzedowy"] {
  --bg: #faf8f4;
  --card: #ffffff;
  --text: #1c2b24;
  --muted: #5a6b62;
  --accent: #1b6b4a;
  --accent-dark: #145238;
  --accent-soft: #e9f4ee;
  --accent-secondary: #2c5282;
  --green: #1b6b4a;
  --green-bg: #e4f0ea;
  --red: #b83232;
  --red-bg: #faecec;
  --amber: #9a6700;
  --border: #dde5df;
  --shadow: 0 1px 2px rgba(28, 43, 36, .05), 0 6px 20px rgba(28, 43, 36, .06);
  --mode-exam: #1b6b4a;
  --mode-learn: #2c5282;
  --mode-errors: #b83232;
  --mode-stats: #3d7a5c;
  --pattern: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 23px,
    rgba(27, 107, 74, .035) 23px,
    rgba(27, 107, 74, .035) 24px
  );
}

[data-theme="minimal"] {
  --bg: #f8fafb;
  --card: #ffffff;
  --text: #0f2430;
  --muted: #5f7380;
  --accent: #0f4c5c;
  --accent-dark: #0a3a45;
  --accent-soft: #e8f2f5;
  --accent-secondary: #3d6b7a;
  --green: #1a7a5c;
  --green-bg: #e6f5ef;
  --red: #c44536;
  --red-bg: #fdf0ee;
  --amber: #0f4c5c;
  --border: #e2eaee;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(15, 36, 48, .04), 0 4px 14px rgba(15, 36, 48, .05);
  --font-display: 'DM Sans', system-ui, sans-serif;
  --mode-exam: #0f4c5c;
  --mode-learn: #3d6b7a;
  --mode-errors: #c44536;
  --mode-stats: #1a7a5c;
  --pattern: none;
}

[data-theme="czytelny"] {
  --bg: #fffdf7;
  --card: #ffffff;
  --text: #121212;
  --muted: #44403c;
  --accent: #1a4b8c;
  --accent-dark: #133a6d;
  --accent-soft: #e8f0fa;
  --accent-secondary: #0c4a6e;
  --green: #166534;
  --green-bg: #e2f5e9;
  --red: #b91c1c;
  --red-bg: #fde8e8;
  --amber: #1a4b8c;
  --border: #c4c0b8;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 2px 4px rgba(18, 18, 18, .08), 0 6px 20px rgba(18, 18, 18, .06);
  --font-display: 'Libre Baskerville', Georgia, 'Times New Roman', serif;
  --font-body: 'Atkinson Hyperlegible', system-ui, sans-serif;
  --mode-exam: #1a4b8c;
  --mode-learn: #0c4a6e;
  --mode-errors: #b91c1c;
  --mode-stats: #166534;
  --pattern: none;
}

/* Czytelny — większa baza typograficzna (skaluje wszystkie rem) */
html[data-theme="czytelny"] { font-size: 112.5%; }
@media (min-width: 768px) {
  html[data-theme="czytelny"] { font-size: 118.75%; }
}
html[data-theme="czytelny"] body { line-height: 1.65; }
html[data-theme="czytelny"] .answer { min-height: 56px; padding: 16px 18px; }
html[data-theme="czytelny"] .answer .mark { flex: 0 0 26px; height: 26px; }
html[data-theme="czytelny"] .btn { min-height: 52px; }
html[data-theme="czytelny"] .chip { min-height: 48px; }
html[data-theme="czytelny"] .qnav button { width: 44px; height: 44px; }
html[data-theme="czytelny"] .qhint { font-size: .9rem; }

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  background-image: var(--pattern);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

body.in-quiz { padding-bottom: calc(76px + env(safe-area-inset-bottom, 0)); }

h1, h2 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ===== topbar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top, 0));
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
}
.brand:hover { background: var(--accent-soft); }
.brand-text { line-height: 1.2; text-align: left; }
@media (max-width: 480px) {
  .brand-text { font-size: .82rem; max-width: 9.5rem; }
}

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.brand-icon svg {
  width: 20px;
  height: 20px;
  display: block;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-slot { display: flex; align-items: center; }

.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1rem;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-secondary);
  border: 1px solid var(--border);
}
.timer.low {
  color: var(--red);
  background: var(--red-bg);
  border-color: color-mix(in srgb, var(--red) 25%, var(--border));
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  50% { opacity: .75; }
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.icon-btn:hover {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  background: var(--accent-soft);
}

.theme-picker { position: relative; }

.theme-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  padding: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 50;
}
.theme-menu:not(.hidden) { animation: fadeIn .15s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

.theme-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: var(--text);
}
.theme-opt:hover { background: var(--accent-soft); }
.theme-opt.active {
  background: var(--accent-soft);
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
}
.theme-opt strong { display: block; font-size: .92rem; }
.theme-opt small { display: block; color: var(--muted); font-size: .78rem; margin-top: 1px; }

.theme-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid var(--border);
}
.theme-swatch-droga {
  background: linear-gradient(135deg, #c45a11 50%, #1e4d6b 50%);
}
.theme-swatch-urzedowy {
  background: linear-gradient(135deg, #1b6b4a 50%, #faf8f4 50%);
}
.theme-swatch-minimal {
  background: linear-gradient(135deg, #0f4c5c 50%, #f8fafb 50%);
}
.theme-swatch-czytelny {
  background: linear-gradient(135deg, #1a4b8c 50%, #fffdf7 50%);
}

/* ===== layout ===== */
main {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 48px;
  animation: pageIn .2s ease;
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

h1 { font-size: clamp(1.35rem, 4vw, 1.65rem); margin: 8px 0 6px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
.sub { color: var(--muted); margin: 0 0 20px; font-size: .92rem; }
.page-title { margin-bottom: 4px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  padding: 20px;
  margin-bottom: 16px;
}
.card-flush-top { margin-top: 18px; }
.card h2:first-child { margin-top: 0; }

/* ===== hero (strona główna) ===== */
.hero {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 22px 20px;
  margin-bottom: 18px;
}
.hero-ring {
  --pct: 0;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--pct) * 1%), var(--border) 0);
  padding: 5px;
  flex-shrink: 0;
}
.hero-ring-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.hero-text h1 { margin: 0 0 4px; font-size: 1.25rem; }
.hero-text .sub { margin: 0; font-size: .88rem; }

/* ===== menu główne ===== */
.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 560px) { .mode-grid { grid-template-columns: 1fr; } }

.mode-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 18px 18px 18px 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform .12s ease, border-color .12s, box-shadow .12s;
  min-height: 120px;
}
.mode-btn::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--mode-color, var(--accent));
}
.mode-btn:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--mode-color, var(--accent)) 45%, var(--border));
}
.mode-btn:active { transform: translateY(0); }
.mode-exam { --mode-color: var(--mode-exam); }
.mode-learn { --mode-color: var(--mode-learn); }
.mode-errors { --mode-color: var(--mode-errors); }
.mode-stats { --mode-color: var(--mode-stats); }

.mode-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: color-mix(in srgb, var(--mode-color, var(--accent)) 12%, var(--card));
  color: var(--mode-color, var(--accent));
}
.mode-icon svg { width: 20px; height: 20px; }
.mode-btn .title { font-weight: 700; font-size: 1rem; }
.mode-btn .desc { color: var(--muted); font-size: .84rem; line-height: 1.45; }
.mode-btn:disabled {
  opacity: .5;
  cursor: default;
  transform: none;
}

/* ===== statystyki ===== */
.stat-row { display: flex; align-items: center; gap: 10px; margin: 10px 0 4px; }
.stat-row .name {
  flex: 1;
  min-width: 0;
  font-size: .88rem;
  line-height: 1.3;
}
@media (max-width: 560px) { .stat-row .name { flex: 0 0 42%; } }

.bar {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--border) 60%, var(--bg));
  overflow: hidden;
}
.bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent-secondary);
  transition: width .35s ease;
}
.bar > span.green { background: var(--green); }
.stat-row .pct {
  flex: 0 0 48px;
  text-align: right;
  font-size: .82rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.stat-note { margin: 0 0 10px; padding-left: 2px; }

table.hist { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.hist th, table.hist td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
table.hist th {
  color: var(--muted);
  font-weight: 600;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
@media (max-width: 480px) {
  table.hist { font-size: .8rem; }
  table.hist th, table.hist td { padding: 8px 4px; }
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .01em;
}
.badge.pass { background: var(--green-bg); color: var(--green); }
.badge.fail { background: var(--red-bg); color: var(--red); }
.badge.pts {
  background: var(--accent-soft);
  color: var(--accent-secondary);
  font-weight: 600;
}

/* ===== postęp ===== */
.progress-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.progress-wrap {
  flex: 1;
  height: 8px;
  background: color-mix(in srgb, var(--border) 70%, var(--bg));
  border-radius: 999px;
  overflow: hidden;
}
.progress-wrap > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-secondary));
  border-radius: 999px;
  transition: width .25s ease;
}
.progress-label {
  flex-shrink: 0;
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 3.5rem;
  text-align: right;
}

/* ===== ekran pytania ===== */
.qmeta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: .84rem;
  margin-bottom: 12px;
}

.qtext {
  font-size: clamp(1.05rem, 3.5vw, 1.15rem);
  font-weight: 600;
  margin: 0 0 8px;
  line-height: 1.45;
}
.qhint {
  color: var(--muted);
  font-size: .84rem;
  margin: 0 0 14px;
  padding: 8px 12px;
  background: color-mix(in srgb, var(--accent-soft) 50%, var(--card));
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent-secondary);
}

.qimages {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 14px 0;
}
.qfigure {
  margin: 0;
  text-align: center;
}
.qimages img {
  max-width: min(260px, 100%);
  max-height: 210px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fff;
  cursor: zoom-in;
  object-fit: contain;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
  display: block;
}
.zoom-hint {
  display: block;
  font-size: .72rem;
  color: var(--muted);
  margin-top: 4px;
}
@media (max-width: 560px) {
  .qimages { justify-content: center; }
  .qimages img { max-width: 100%; }
}

.answers { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

.answer {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  width: 100%;
  min-height: 52px;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  cursor: pointer;
  font: inherit;
  text-align: left;
  color: inherit;
  transition: border-color .12s, background .12s, transform .08s;
  -webkit-tap-highlight-color: transparent;
}
.answer:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.answer:active:not(:disabled) { transform: scale(.99); }

.answer .mark {
  flex: 0 0 24px;
  height: 24px;
  margin-top: 2px;
  border: 2px solid var(--border);
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  color: #fff;
  transition: background .12s, border-color .12s;
}
.answer.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.answer.selected .mark {
  background: var(--accent);
  border-color: var(--accent);
}
.answer.correct { border-color: var(--green); background: var(--green-bg); }
.answer.correct .mark { background: var(--green); border-color: var(--green); }
.answer.wrong { border-color: var(--red); background: var(--red-bg); }
.answer.wrong .mark { background: var(--red); border-color: var(--red); }
.answer.missed {
  border-color: var(--green);
  border-style: dashed;
  background: color-mix(in srgb, var(--green-bg) 60%, var(--card));
}
.answer:disabled { cursor: default; }
.answer img { max-width: 140px; border-radius: 8px; margin-top: 6px; }

/* ===== akcje ===== */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.actions-center { justify-content: center; }
.spacer { flex: 1; }

.sticky-actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0));
  background: color-mix(in srgb, var(--card) 94%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, .06);
}
.sticky-actions .actions {
  max-width: 720px;
  margin: 0 auto;
}

.btn {
  padding: 12px 22px;
  min-height: 48px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  font: inherit;
  font-weight: 600;
  font-size: .92rem;
  cursor: pointer;
  color: var(--text);
  transition: border-color .12s, background .12s, transform .08s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 30%, var(--border)); }
.btn.danger:hover { background: var(--red-bg); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }

.feedback {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: .92rem;
}
.feedback.ok { color: var(--green); background: var(--green-bg); }
.feedback.bad { color: var(--red); background: var(--red-bg); }

/* nawigacja egzaminu */
.qnav-scroll {
  margin-top: 18px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
  scrollbar-width: thin;
}
.qnav {
  display: flex;
  gap: 8px;
  width: max-content;
  min-width: 100%;
  padding: 2px 0;
}
.qnav button {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
  font: inherit;
  font-size: .85rem;
  font-weight: 500;
  color: var(--muted);
  flex-shrink: 0;
  transition: border-color .1s, background .1s;
}
.qnav button.answered {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  color: var(--accent);
  font-weight: 700;
}
.qnav button.current {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  color: var(--text);
  font-weight: 700;
}

/* ===== podsumowanie ===== */
.result-hero { text-align: center; padding: 32px 20px; }
.result-hero h1 { margin: 0 0 12px; }
.result-hero .score {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 8vw, 3.2rem);
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}
.result-hero .score-sub {
  color: var(--muted);
  font-size: 1.5rem;
  font-weight: 500;
}
.result-hero .verdict {
  font-size: 1.2rem;
  font-weight: 700;
  margin-top: 10px;
  letter-spacing: .06em;
}
.result-hero .verdict.pass { color: var(--green); }
.result-hero .verdict.fail { color: var(--red); }

.review-q {
  border-top: 1px solid var(--border);
  padding: 18px 0;
}
.review-q:first-child { border-top: 0; padding-top: 0; }
.review-q .rq-text { font-weight: 600; line-height: 1.4; }
.review-q ul { margin: 10px 0 0; padding: 0; list-style: none; }
.review-q li {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin: 4px 0;
  font-size: .9rem;
}
.review-q li.c { background: var(--green-bg); }
.review-q li.w { background: var(--red-bg); text-decoration: line-through; }
.review-q .qimages img { max-width: 150px; max-height: 120px; }

/* ===== opcje nauki ===== */
.opt-group { margin: 16px 0; }
.opt-group .label {
  font-size: .78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 10px;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 10px 16px;
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
  font: inherit;
  font-size: .88rem;
  transition: background .12s, border-color .12s, color .12s;
}
.chip:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.chip.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* ===== lightbox ===== */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 25, .88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  padding-top: calc(20px + env(safe-area-inset-top, 0));
}
.lightbox img {
  max-width: min(92vw, 900px);
  max-height: 85vh;
  border-radius: var(--radius-sm);
  background: #fff;
  box-shadow: 0 8px 40px rgba(0, 0, 0, .35);
}
.lb-close {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top, 0));
  right: 16px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .15);
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lb-close:hover { background: rgba(255, 255, 255, .25); }

.hidden { display: none !important; }
.note { font-size: .85rem; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
