/* Michigan Permit Practice — styles. Themes via [data-theme]; RTL via logical properties. */
:root {
  --bg: #f5f7fb; --surface: #ffffff; --surface-2: #eef2f8; --text: #172033; --muted: #5b667a; --border: #d9e0ea;
  --primary: #0b4ea2; --primary-ink: #ffffff; --primary-soft: #e3edfb;
  --ok: #157f3b; --ok-soft: #e3f5e9; --bad: #c8102e; --bad-soft: #fde8eb; --warn: #9a6400; --warn-soft: #fff4d6;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 16px rgba(16,24,40,.06);
  --radius: 14px; --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
:root[data-theme="dark"] {
  --bg: #0e1420; --surface: #161e2e; --surface-2: #1d2739; --text: #e7ecf5; --muted: #9aa6bb; --border: #2b374d;
  --primary: #5b9cf5; --primary-ink: #0b1220; --primary-soft: #1c2c47;
  --ok: #4cc47a; --ok-soft: #133523; --bad: #ff6b7f; --bad-soft: #3a1820; --warn: #f2c14e; --warn-soft: #3a2f12;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
}
:root { color-scheme: light; }
:root[data-mode="dark"] { color-scheme: dark; }
/* Comfort themes. Softer than pure white or bright black-on-white, and every text color
   keeps a contrast of at least 4.5:1 so reading stays easy. */
:root[data-theme="sepia"] {
  --bg: #f4ecd8; --surface: #fbf5e6; --surface-2: #ece2c8; --text: #3b2f20; --muted: #63533d; --border: #d9ccae;
  --primary: #85460f; --primary-ink: #fff8ec; --primary-soft: #efdcc0;
  --ok: #2f6b2f; --ok-soft: #e0ecd0; --bad: #a32a1f; --bad-soft: #f6ddd2; --warn: #744d00; --warn-soft: #f5e6bb;
  --shadow: 0 1px 2px rgba(80,55,20,.08), 0 4px 16px rgba(80,55,20,.07);
}
:root[data-theme="sage"] {
  --bg: #e8efe6; --surface: #f4f8f1; --surface-2: #dde8da; --text: #24332a; --muted: #4a5d51; --border: #c5d3c3;
  --primary: #2a6348; --primary-ink: #f4fbf6; --primary-soft: #d3e6da;
  --ok: #1f6635; --ok-soft: #d5ecd9; --bad: #a32f2a; --bad-soft: #f5dedb; --warn: #6f5100; --warn-soft: #f2e7bf;
  --shadow: 0 1px 2px rgba(30,60,40,.08), 0 4px 16px rgba(30,60,40,.06);
}
:root[data-theme="mist"] {
  --bg: #e6e9ef; --surface: #f0f2f6; --surface-2: #dde1e9; --text: #2b3240; --muted: #4f5969; --border: #c9cfda;
  --primary: #3a568f; --primary-ink: #f7f9fd; --primary-soft: #d6dff0;
  --ok: #216838; --ok-soft: #d9ebdf; --bad: #a62e38; --bad-soft: #f3dfe2; --warn: #6e5000; --warn-soft: #efe6c8;
  --shadow: 0 1px 2px rgba(30,40,60,.07), 0 4px 16px rgba(30,40,60,.06);
}
:root[data-theme="dusk"] {
  --bg: #211c19; --surface: #2b2521; --surface-2: #352e29; --text: #e6dccd; --muted: #b8aa99; --border: #463d36;
  --primary: #e0a96d; --primary-ink: #241a10; --primary-soft: #43342a;
  --ok: #9ccc8a; --ok-soft: #2c3a27; --bad: #f0998a; --bad-soft: #452723; --warn: #e9c46a; --warn-soft: #423619;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
}
:root[data-theme="midnight"] {
  --bg: #000000; --surface: #0c0e12; --surface-2: #151820; --text: #d6dbe3; --muted: #9aa3b2; --border: #262b35;
  --primary: #7fb2f0; --primary-ink: #03101f; --primary-soft: #12233a;
  --ok: #5fcf8b; --ok-soft: #0d2a1a; --bad: #ff8796; --bad-soft: #331419; --warn: #f2c14e; --warn-soft: #2e2509;
  --shadow: none;
}
html[dir="rtl"] { --font: "Noto Kufi Arabic", Tahoma, system-ui, sans-serif; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.6 var(--font); min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: clamp(1.5rem, 4vw, 2.2rem); }
h2 { font-size: 1.25rem; }
.wrap { width: 100%; max-width: 1140px; margin: 0 auto; padding: 0 16px; }
.main { flex: 1; padding-block: 24px 48px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 70ch; }
.eyebrow { text-transform: uppercase; letter-spacing: .06em; font-size: .78rem; font-weight: 700; color: var(--primary); margin: 0 0 .4em; }
html[dir="rtl"] .eyebrow { text-transform: none; letter-spacing: 0; }
.skip-link { position: absolute; inset-inline-start: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; }
.skip-link:focus { inset-inline-start: 8px; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
[hidden] { display: none !important; }
code { font-size: .8rem; word-break: break-all; }

/* Top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar-inner { display: flex; align-items: center; gap: 12px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); text-decoration: none; margin-inline-end: auto; }
.brand-mark svg { width: 34px; height: 34px; display: block; }
.nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nav a { color: var(--text); text-decoration: none; padding: 8px 10px; border-radius: 8px; }
.nav a:hover, .nav a.active { background: var(--surface-2); }
.nav a.btn { color: var(--primary-ink); }
.menu-btn { display: none; }
@media (max-width: 760px) {
  .menu-btn { display: inline-flex; }
  .nav { display: none; width: 100%; flex-direction: column; align-items: stretch; padding-bottom: 12px; }
  .nav.open { display: flex; }
  .nav .inline, .nav .icon-btn { width: 100%; }
}
.inline { display: inline; margin: 0; }
.icon-btn, .link-btn { background: none; border: 1px solid transparent; color: var(--text); cursor: pointer; font: inherit; padding: 8px 10px; border-radius: 8px; }
.icon-btn { border-color: var(--border); }
.icon-btn:hover { background: var(--surface-2); }
.link-btn { padding: 4px 6px; color: var(--primary); }
.link-btn:hover { text-decoration: underline; }
:root[data-mode="dark"] .theme-icon-light, :root:not([data-mode="dark"]) .theme-icon-dark { display: none; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--primary); color: var(--primary-ink); border: 1px solid var(--primary);
  padding: 10px 18px; border-radius: 10px; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; transition: transform .05s, filter .15s; }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-sm { padding: 6px 12px; font-size: .9rem; }
.btn-lg { padding: 14px 24px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.row-end { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.row-between { display: flex; gap: 12px; justify-content: space-between; align-items: center; flex-wrap: wrap; }

/* Cards & layout */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px; }
.grid-2 { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); margin-bottom: 20px; }
.grid-2 > .card { margin-bottom: 0; }
.grid-4 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.narrow { max-width: 520px; }
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; border: 1px solid; }
.flash-success { background: var(--ok-soft); border-color: var(--ok); }
.flash-error { background: var(--bad-soft); border-color: var(--bad); }
.flash-info { background: var(--primary-soft); border-color: var(--primary); }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; }
.pill-ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.pill-bad { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.pill-warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.badge { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 1.2rem; margin-bottom: 10px; }

/* Forms */
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .95rem; margin-bottom: 14px; }
input, select, textarea { font: inherit; font-weight: 400; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; width: 100%; }
input:disabled { background: var(--surface-2); color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
label.check input { width: auto; }
.err { color: var(--bad); font-weight: 500; font-size: .88rem; }
.auth { max-width: 440px; margin: 20px auto; }
.seg { display: flex; gap: 8px; }
.seg-opt { flex: 1; flex-direction: row; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin: 0; cursor: pointer; font-weight: 500; }
.seg-opt input { width: auto; }
.seg-opt:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
fieldset { border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; margin: 0; min-width: 0; }
legend { font-weight: 700; padding: 0 6px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters input, .filters select { width: auto; flex: 1 1 160px; }
.filters label.check { margin: 0; }
.search { margin-bottom: 20px; }

/* Home */
.hero { display: grid; grid-template-columns: 1.4fr 1fr; gap: 32px; align-items: center; padding: 24px 0 36px; }
.hero-signs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; max-width: 320px; justify-self: center; }
.hero-signs svg { width: 100%; height: auto; filter: drop-shadow(0 4px 10px rgba(0,0,0,.15)); }
@media (max-width: 760px) { .hero { grid-template-columns: 1fr; } .hero-signs { max-width: 220px; } }
.features { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.feature { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.feature h3 { font-size: 1rem; margin-bottom: .3em; }
.feature p { margin: 0; color: var(--muted); }
.level-card.locked { opacity: .75; }
.locked-msg { background: var(--surface-2); padding: 10px 12px; border-radius: 10px; margin: 0; }
.mini-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 10px; margin: 14px 0; }
.mini-stats div { background: var(--surface-2); border-radius: 10px; padding: 10px; }
.mini-stats dt { font-size: .78rem; color: var(--muted); }
.mini-stats dd { margin: 0; font-size: 1.2rem; font-weight: 700; }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: start; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .78rem; color: var(--muted); font-weight: 700; white-space: nowrap; }
table.num td:not(:first-child), table.num th:not(:first-child) { text-align: end; }
.bar { display: inline-block; width: 70px; height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; vertical-align: middle; }
.bar span { display: block; height: 100%; background: var(--primary); }

/* Quiz */
.quiz { max-width: 820px; margin: 0 auto; }
.quiz-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
.quiz-progress { font-size: 1.3rem; margin: 0; }
.quiz-score { display: flex; gap: 16px; color: var(--muted); }
.quiz-score strong { color: var(--text); }
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-bottom: 10px; }
.progress-bar { height: 100%; width: 0; background: var(--primary); transition: width .3s; }
.dots { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 16px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.dot-ok { background: var(--ok); } .dot-bad { background: var(--bad); } .dot-skip { background: var(--warn); }
.dot-current { outline: 2px solid var(--primary); outline-offset: 1px; }
.question-card { padding: 24px; }
.q-meta { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.report-btn { margin-inline-start: auto; font-size: .88rem; }
.q-sign { display: flex; justify-content: center; margin: 4px 0 16px; }
.q-sign svg, .q-sign img { width: 170px; height: 170px; }
.q-sign.small svg, .q-sign.small img { width: 110px; height: 110px; }
.q-text { font-size: 1.2rem; margin-bottom: 16px; }
.options { display: grid; gap: 10px; }
.option { display: flex; align-items: center; gap: 12px; text-align: start; width: 100%; padding: 14px 16px; border: 2px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer; transition: border-color .15s, background .15s; }
.option:hover:not(:disabled) { border-color: var(--primary); }
.option.selected { border-color: var(--primary); background: var(--primary-soft); }
.option.correct { border-color: var(--ok); background: var(--ok-soft); }
.option.wrong { border-color: var(--bad); background: var(--bad-soft); }
.option.eliminated { opacity: .4; text-decoration: line-through; }
.option:disabled { cursor: default; }
.opt-letter { flex: none; display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--surface-2); font-weight: 700; font-size: .9rem; }
.option.selected .opt-letter { background: var(--primary); color: var(--primary-ink); }
.hint-box { background: var(--warn-soft); border: 1px solid var(--warn); border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; }
.feedback { margin-top: 14px; padding: 12px 14px; border-radius: 10px; }
.feedback.ok { background: var(--ok-soft); color: var(--text); border: 1px solid var(--ok); }
.feedback.bad { background: var(--bad-soft); color: var(--text); border: 1px solid var(--bad); }
.feedback p { margin: 6px 0 0; }
.q-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }
.q-footer { margin-top: 14px; text-align: center; font-size: .88rem; }
@media (max-width: 520px) { .q-actions .btn { flex: 1 1 100%; } .q-sign svg { width: 140px; height: 140px; } }

/* Result */
.result-hero { text-align: center; }
.result-hero.is-pass { border-top: 6px solid var(--ok); }
.result-hero.is-fail { border-top: 6px solid var(--bad); }
.result-hero .actions { justify-content: center; }
.result-emoji { font-size: 3rem; }
.review-list { list-style: none; padding: 0; }
.review-item.ok { border-inline-start: 5px solid var(--ok); }
.review-item.bad { border-inline-start: 5px solid var(--bad); }
.review-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.review-opts { list-style: none; padding: 0; margin: 0 0 10px; display: grid; gap: 6px; }
.review-opts li { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); }
.review-opts li.is-correct { border-color: var(--ok); background: var(--ok-soft); }
.review-opts li.is-wrong { border-color: var(--bad); background: var(--bad-soft); }
.explain { background: var(--surface-2); padding: 10px 12px; border-radius: 8px; margin: 0; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: 6px 14px; cursor: pointer; font: inherit; font-size: .9rem; text-decoration: none; }
.chip.active { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }

/* Sign library */
.sign-group { margin-bottom: 28px; }
.sign-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.sign-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.sign-pic { display: flex; justify-content: center; padding: 10px; background: var(--surface-2); border-radius: 10px; margin-bottom: 10px; }
.sign-pic svg, .sign-pic img { width: 110px; height: 110px; }
.sign-card h3 { font-size: 1rem; margin-bottom: .3em; }
.sign-card p { margin: 0; font-size: .9rem; color: var(--muted); }
.blink { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: .15; } }
@media (prefers-reduced-motion: reduce) { .blink { animation: none; } }
svg text { direction: ltr; unicode-bidi: plaintext; }

/* Modal & toast */
.modal { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 22px; width: min(520px, calc(100vw - 32px)); box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(10,15,25,.55); }
.toast { position: fixed; inset-inline: 16px; bottom: 20px; margin: 0 auto; max-width: 420px; background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 10px;
  opacity: 0; transform: translateY(10px); transition: opacity .25s, transform .25s; z-index: 200; text-align: center; }
.toast.show { opacity: 1; transform: none; }
.toast-error { background: var(--bad); color: #fff; }
.toast-success { background: var(--ok); color: #fff; }

/* Admin */
.admin-tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.admin-tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.admin-tabs a.active { color: var(--text); border-bottom-color: var(--primary); font-weight: 600; }
.kpis { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--text); }
.kpi span { font-size: .82rem; color: var(--muted); }
.kpi strong { font-size: 1.6rem; }
.kpi-warn { border-color: var(--warn); background: var(--warn-soft); }
.opt-edit { flex-direction: row; align-items: center; gap: 8px; }
.opt-edit > span { flex: none; display: flex; align-items: center; gap: 4px; min-width: 48px; }
.opt-edit > span input { width: auto; }
.revision { border-top: 1px solid var(--border); padding: 8px 0; }
.revision summary { cursor: pointer; }
.report-comment { white-space: pre-wrap; }

/* Question photos */
.q-photos { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: 10px; overflow-x: auto; margin: 0 0 16px; padding-bottom: 4px; scroll-snap-type: x mandatory; }
.q-photos.single { grid-auto-columns: 100%; }
.q-photos figure { margin: 0; scroll-snap-align: start; min-width: 0; }
.q-photos img { display: block; width: 100%; max-height: 300px; object-fit: cover; border-radius: 10px; background: var(--surface-2); }
.q-photos.small { grid-auto-columns: minmax(160px, 220px); }
.q-photos.small img { max-height: 160px; }
.q-photos figcaption { font-size: .85rem; color: var(--muted); margin-top: 4px; }
.q-photos figure.is-missing img { display: none; }
.photo-btn { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: 10px; }
.lightbox { width: min(960px, calc(100vw - 24px)); padding: 12px; }
.lightbox img { display: block; width: 100%; max-height: 78vh; object-fit: contain; border-radius: 8px; }
.lightbox p { margin: 8px 0 0; text-align: center; }
.lightbox-close { float: inline-end; margin-bottom: 8px; }
.sign-photo { object-fit: contain; border-radius: 6px; }

/* Admin: photo management */
.photo-admin { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); margin-bottom: 16px; }
.photo-item { border: 1px solid var(--border); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.photo-item img { width: 100%; height: 170px; object-fit: cover; border-radius: 8px; display: block; }
.photo-item label { margin-bottom: 4px; }
.upload-box { border: 2px dashed var(--border); border-radius: 12px; padding: 14px; }
.preview-row { display: flex; gap: 8px; flex-wrap: wrap; }
.preview-row img { width: 90px; height: 70px; object-fit: cover; border-radius: 6px; }
.file-btn { position: relative; overflow: hidden; flex-direction: row; align-items: center; margin: 0; cursor: pointer; color: var(--primary); font-weight: 600; }
.file-btn.btn { color: var(--primary-ink); }
.file-btn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.replace-form { margin: 0; }
.sign-admin-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.sign-admin { margin: 0; }
.sign-admin h3 { font-size: 1rem; margin: 0; }
.sign-admin p { margin: 0; font-size: .85rem; }
.sign-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sign-compare figure { margin: 0; text-align: center; }
.sign-compare .sign-pic { height: 130px; align-items: center; margin-bottom: 4px; }
.sign-compare .sign-pic img, .sign-compare .sign-pic svg { max-width: 100%; max-height: 110px; width: auto; height: 110px; object-fit: contain; }
.sign-compare figcaption { font-size: .78rem; color: var(--muted); }
.sign-compare .is-empty .sign-pic { border: 2px dashed var(--border); background: transparent; }

/* About / legal pages */
.prose { max-width: 760px; margin: 0 auto 20px; padding: clamp(20px, 4vw, 40px); }
.prose h1 { margin-bottom: .4em; }
.prose h2 { margin: 1.6em 0 .5em; font-size: 1.15rem; }
.prose p, .prose li { max-width: 68ch; }
.prose p { margin: 0 0 .9em; }
.prose ul { padding-inline-start: 1.3em; margin: 0 0 1em; }
.prose li { margin-bottom: .35em; }
.promise-list { list-style: none; padding: 0 !important; display: grid; gap: 8px; }
.promise-list li { background: var(--ok-soft); border: 1px solid var(--ok); border-radius: 10px; padding: 10px 14px; }
.signoff { font-weight: 600; margin-top: 1.5em; }
.story-teaser { margin-top: 20px; }
label.check.agree { align-items: flex-start; font-size: .92rem; }
label.check.agree input { margin-top: 5px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; }
.footer-links a { color: var(--muted); }
.footer-links span { margin-inline-start: auto; }

/* Footer */
.footer { border-top: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: .85rem; padding: 16px 0; }
.footer p { margin: 0; }

/* ---------- Official signs and test markers ---------- */
.sign-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.sign-pair.one { grid-template-columns: 1fr; }
.sign-pair figure { margin: 0; min-width: 0; }
.sign-pair .sign-pic { height: 104px; align-items: center; margin-bottom: 4px; padding: 8px; }
.sign-pair .sign-pic svg, .sign-pair .sign-pic img { width: 100%; height: 88px; object-fit: contain; }
.sign-pair figcaption { font-size: .72rem; color: var(--muted); text-align: center; }
.q-sign .sign-pair { max-width: 440px; margin-inline: auto; width: 100%; }
.q-sign .sign-pair.one { max-width: 240px; }
.q-sign .sign-pair .sign-pic { height: 170px; }
.q-sign .sign-pair .sign-pic svg, .q-sign .sign-pair .sign-pic img { height: 150px; }
.q-sign.small .sign-pair { max-width: 260px; }
.q-sign.small .sign-pair .sign-pic { height: 92px; }
.q-sign.small .sign-pair .sign-pic svg, .q-sign.small .sign-pair .sign-pic img { height: 76px; }
.sign-card.is-test { border-color: var(--primary); }
.test-badge, .extra-badge { display: inline-block; font-size: .74rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; margin-bottom: 6px; }
.test-badge { background: var(--primary); color: var(--primary-ink); }
.extra-badge { background: var(--surface-2); color: var(--muted); }
.sign-code { font-size: .78rem !important; margin-top: 6px !important; }
.signs-note { background: var(--surface-2); border-radius: 10px; padding: 10px 14px; font-size: .92rem; }
.signs-note .test-badge { margin: 0 4px 0 0; }
.signs-source { font-size: .8rem; color: var(--muted); margin-top: 14px; }
.extra-link { display: grid; gap: 4px; margin-top: 26px; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: inherit; text-decoration: none; }
.extra-link:hover { border-color: var(--primary); }
.extra-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
.extra-filters .search { flex: 1 1 240px; margin: 0; }
.extra-filters select { font: inherit; padding: 9px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); max-width: 100%; }
.extra-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); }
.extra-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; min-width: 0; }
.extra-card .sign-pic { height: 124px; align-items: center; margin-bottom: 8px; padding: 8px; background: #aeb4bd; }
.extra-card .sign-pic img { width: 100%; height: 106px; object-fit: contain; }
.extra-card h3 { font-size: .92rem; margin: 0 0 .15em; }
.extra-card p { margin: 0 0 4px; font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 22px 0; }

/* ---------- Theme picker (profile) ---------- */
.theme-picker { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
.theme-picker legend { font-weight: 600; padding: 0; margin-bottom: 2px; }
.theme-picker .muted { font-size: .85rem; margin: 0 0 10px; }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.theme-opt { position: relative; display: grid; gap: 2px; padding: 10px; margin: 0; border: 2px solid var(--border); border-radius: 12px; cursor: pointer; background: var(--surface); }
.theme-opt:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.theme-opt:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }
.theme-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.theme-opt strong { font-size: .92rem; }
.theme-opt small { font-size: .78rem; color: var(--muted); line-height: 1.3; font-weight: 400; }
.theme-swatch { display: flex; align-items: center; gap: 5px; height: 38px; padding: 0 9px; border-radius: 8px; border: 1px solid rgba(128,128,128,.35); margin-bottom: 5px; }
.theme-swatch i { display: block; height: 7px; border-radius: 4px; flex: 1; }
.theme-swatch i:last-child { flex: .5; }
.swatch-system { background: linear-gradient(135deg, #f5f7fb 50%, #0e1420 50%); }
.swatch-light { background: #f5f7fb; } .swatch-light i { background: #172033; } .swatch-light i:last-child { background: #0b4ea2; }
.swatch-dark { background: #0e1420; } .swatch-dark i { background: #e7ecf5; } .swatch-dark i:last-child { background: #5b9cf5; }
.swatch-sepia { background: #f4ecd8; } .swatch-sepia i { background: #3b2f20; } .swatch-sepia i:last-child { background: #85460f; }
.swatch-sage { background: #e8efe6; } .swatch-sage i { background: #24332a; } .swatch-sage i:last-child { background: #2a6348; }
.swatch-mist { background: #e6e9ef; } .swatch-mist i { background: #2b3240; } .swatch-mist i:last-child { background: #3a568f; }
.swatch-dusk { background: #211c19; } .swatch-dusk i { background: #e6dccd; } .swatch-dusk i:last-child { background: #e0a96d; }
.swatch-midnight { background: #000; } .swatch-midnight i { background: #d6dbe3; } .swatch-midnight i:last-child { background: #7fb2f0; }
.swatch-system i { display: none; }

/* Long app names (Spanish) must not push the menu button onto a second row. */
@media (max-width: 640px) {
  .topbar-inner { flex-wrap: nowrap; }
  .brand { min-width: 0; font-size: .92rem; }
  .brand span { white-space: normal; line-height: 1.15; }
  .menu-btn { flex: none; }
  .theme-grid { grid-template-columns: 1fr 1fr; }
}
