/* Researchy Interactive v1.1 · engine styles
   Same design language as researchy.org: warm paper, serif headings,
   indigo for actions, gold for milestones. Light and dark follow the device. */

/* ---------- Fonts (self-hosted, SIL Open Font Licence) ---------- */
@font-face { font-family: "Inter"; src: url("fonts/inter-latin-wght-normal.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Inter"; src: url("fonts/inter-latin-ext-wght-normal.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Source Serif 4"; src: url("fonts/source-serif-4-latin-wght-normal.woff2") format("woff2"); font-weight: 200 900; font-style: normal; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Source Serif 4"; src: url("fonts/source-serif-4-latin-ext-wght-normal.woff2") format("woff2"); font-weight: 200 900; font-style: normal; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Source Serif 4"; src: url("fonts/source-serif-4-latin-wght-italic.woff2") format("woff2"); font-weight: 200 900; font-style: italic; font-display: swap; }

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --paper: #FBF8F2; --paper-2: #F4EFE4; --surface: #FFFFFF; --surface-2: #FDFBF7;
  --ink: #1C1A17; --ink-2: #48433B; --ink-3: #6E665A;
  --rule: #E7E0D3; --rule-2: #D6CCBA;
  --accent: #2E3A8C; --accent-ink: #FFFFFF; --accent-hover: #222C70; --accent-soft: #ECEEF8; --accent-text: #2E3A8C;
  --gold: #845816; --gold-strong: #B07A28; --gold-soft: #F7EEDC; --gold-rule: #E9D6AE;
  --success: #2F6B4E; --success-soft: #E5F1EA;
  --danger: #A23B2D; --danger-soft: #F8E7E3;

  --font-serif: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --r-sm: 6px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px; --r-full: 999px;
  --shadow-1: 0 1px 2px rgba(28, 26, 23, 0.05), 0 1px 1px rgba(28, 26, 23, 0.03);
  --shadow-2: 0 1px 2px rgba(28, 26, 23, 0.04), 0 12px 32px -12px rgba(28, 26, 23, 0.16);
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --d-fast: 140ms; --d-base: 220ms; --d-slow: 420ms;
  --col: 680px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #16140F; --paper-2: #1D1A14; --surface: #211E18; --surface-2: #1B1813;
    --ink: #F1ECE2; --ink-2: #CFC7B8; --ink-3: #A39A8A;
    --rule: #34302A; --rule-2: #4A443A;
    --accent: #A9B4F5; --accent-ink: #12172F; --accent-hover: #C3CBFA; --accent-soft: #252B4A; --accent-text: #B9C2F7;
    --gold: #E2B66C; --gold-strong: #E9C27F; --gold-soft: #2E2616; --gold-rule: #5A4724;
    --success: #8FD3AE; --success-soft: #1E3328;
    --danger: #F0A396; --danger-soft: #3A221E;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 1px 2px rgba(0, 0, 0, 0.35), 0 12px 32px -12px rgba(0, 0, 0, 0.6);
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
  font-family: var(--font-sans); font-size: 1rem; line-height: 1.6;
  color: var(--ink); background: var(--paper);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  font-feature-settings: "cv11", "ss01";
}
a { color: var(--accent-text); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }
[tabindex="-1"]:focus, [tabindex="-1"]:focus-visible { box-shadow: none; outline: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.icon { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }
[hidden] { display: none !important; }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 100; padding: 8px 14px; background: var(--ink); color: var(--paper); border-radius: var(--r-md); }
.skip-link:focus { top: 12px; }
.sink { position: absolute; width: 0; height: 0; border: 0; visibility: hidden; }

/* ---------- Header and progress ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px); backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--rule);
}
.top-row {
  max-width: calc(var(--col) + 32px); margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right));
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.bm-bg { fill: var(--ink); }
.bm-lens { fill: none; stroke: var(--paper); stroke-width: 2.2; }
.bm-handle { stroke: var(--gold-strong); stroke-width: 3; stroke-linecap: round; }
.bm-plus { stroke: var(--paper); stroke-width: 1.6; stroke-linecap: round; opacity: .85; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-family: var(--font-serif); font-weight: 650; font-size: 1.08rem; letter-spacing: -0.01em; }
.brand-sub { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold); }
.top-status { font-size: 0.82rem; font-weight: 500; color: var(--ink-2); text-align: right; font-variant-numeric: tabular-nums; }
.top-status .sep { color: var(--rule-2); margin: 0 6px; }
.top-status strong { color: var(--ink); font-weight: 650; }

.track {
  max-width: calc(var(--col) + 32px); margin: 0 auto; padding: 0 16px 10px;
  display: flex; gap: 4px;
}
.track:empty { display: none; }
.seg { flex: 1; height: 4px; border-radius: var(--r-full); background: var(--rule); overflow: hidden; }
.seg > i { display: block; height: 100%; width: 100%; background: var(--accent); border-radius: inherit; transform-origin: left center; transform: scaleX(0); transition: transform var(--d-slow) var(--ease-out); }
.seg.is-done > i { background: var(--gold-strong); }

/* ---------- Stage and cards ---------- */
.stage {
  flex: 1; width: 100%; max-width: calc(var(--col) + 32px); margin: 0 auto;
  padding: clamp(16px, 4vw, 40px) 16px 40px;
  padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right));
  outline: none;
}
.card {
  position: relative;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-xl);
  box-shadow: var(--shadow-2);
  padding: clamp(22px, 5vw, 44px);
}
.enter-fwd { animation: enterFwd var(--d-slow) var(--ease-out) both; }
.enter-back { animation: enterBack var(--d-slow) var(--ease-out) both; }
.enter-up { animation: enterUp 520ms var(--ease-out) both; }
@keyframes enterFwd { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: none; } }
@keyframes enterBack { from { opacity: 0; transform: translateX(-28px); } to { opacity: 1; transform: none; } }
@keyframes enterUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.kicker { display: inline-flex; align-items: center; gap: 8px; font-size: 0.75rem; font-weight: 650; letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold); }
.kicker .dot { width: 4px; height: 4px; border-radius: 50%; background: var(--rule-2); }
.display {
  font-family: var(--font-serif); font-weight: 620; letter-spacing: -0.015em;
  font-size: clamp(1.85rem, 1.35rem + 2.2vw, 2.6rem); line-height: 1.15; margin-top: 12px;
  text-wrap: balance;
}
.lead { font-size: 1.04rem; color: var(--ink-2); margin-top: 18px; line-height: 1.7; }
.muted { color: var(--ink-3); }

/* ---------- Welcome ---------- */
.byline { display: flex; align-items: center; gap: 12px; margin-top: 18px; padding-bottom: 22px; border-bottom: 1px solid var(--rule); }
.byline-mark { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); flex: none; }
.byline-name { font-weight: 650; line-height: 1.3; }
.byline-role { font-size: 0.88rem; color: var(--ink-3); line-height: 1.35; }
.facts { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 22px; }
.fact { display: flex; flex-direction: column; gap: 6px; padding: 14px; border: 1px solid var(--rule); border-radius: var(--r-lg); background: var(--surface-2); }
.fact .icon { color: var(--gold); width: 20px; height: 20px; }
.fact .text { display: flex; flex-direction: column; gap: 2px; }
.fact strong { font-size: 0.95rem; font-weight: 650; line-height: 1.25; }
.fact span { font-size: 0.8rem; color: var(--ink-3); line-height: 1.35; }
.note {
  display: flex; gap: 12px; align-items: flex-start;
  margin-top: 20px; padding: 14px 16px; border-radius: var(--r-lg);
  background: var(--gold-soft); border: 1px solid var(--gold-rule); color: var(--ink-2); font-size: 0.92rem; line-height: 1.55;
}
.note .icon { color: var(--gold); margin-top: 2px; }
.note.is-accent { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.note.is-accent .icon { color: var(--accent-text); }
.before { margin-top: 26px; }
.before h2 { font-family: var(--font-serif); font-size: 1.2rem; font-weight: 620; letter-spacing: -0.01em; }
.ticks { list-style: none; padding: 0; margin-top: 12px; display: grid; gap: 10px; }
.ticks li { display: grid; grid-template-columns: 22px 1fr; gap: 10px; color: var(--ink-2); font-size: 0.95rem; line-height: 1.55; }
.ticks .icon { color: var(--success); margin-top: 3px; }
.consent { margin-top: 22px; font-size: 0.86rem; color: var(--ink-3); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 18px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px; border-radius: var(--r-md);
  border: 1px solid transparent; background: none;
  font-weight: 600; font-size: 1rem; line-height: 1; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color var(--d-fast), border-color var(--d-fast), color var(--d-fast), transform var(--d-fast), box-shadow var(--d-fast);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 0 rgba(0,0,0,.06), 0 6px 16px -8px color-mix(in srgb, var(--accent) 70%, transparent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { border-color: var(--rule-2); color: var(--ink-2); background: var(--surface); }
.btn-ghost:hover { border-color: var(--ink-3); color: var(--ink); }
.btn-quiet { color: var(--ink-2); padding: 0 14px; }
.btn-quiet:hover { color: var(--ink); background: var(--paper-2); }
.btn-danger { background: var(--danger); color: #fff; }
@media (prefers-color-scheme: dark) { .btn-danger { color: #2A1410; } }
.btn-lg { min-height: 54px; padding: 0 28px; font-size: 1.05rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: inherit; }

/* ---------- Section intro ---------- */
.sec-done { display: flex; width: fit-content; align-items: center; gap: 6px; padding: 5px 12px 5px 8px; border-radius: var(--r-full); background: var(--gold-soft); color: var(--gold); font-size: 0.8rem; font-weight: 600; margin-bottom: 18px; }
.sec-done .icon { width: 16px; height: 16px; }
.sec-desc { margin-top: 14px; color: var(--ink-2); }
.scale-box { margin-top: 22px; padding: 18px; border-radius: var(--r-lg); background: var(--surface-2); border: 1px solid var(--rule); }
.scale-box p { font-size: 0.9rem; color: var(--ink-2); }
.scale-box .instruction { font-weight: 650; color: var(--ink); font-size: 0.95rem; margin-bottom: 4px; }
.scale-demo { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 14px; }
.scale-demo span { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 0.72rem; color: var(--ink-3); text-align: center; line-height: 1.25; }
.scale-demo b { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--rule-2); font-size: 0.82rem; color: var(--ink-2); background: var(--surface); }
.sec-meta { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 22px; font-size: 0.88rem; color: var(--ink-3); }
.sec-meta span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Questions ---------- */
.q-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.tag { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 11px; border-radius: var(--r-full); background: var(--gold-soft); color: var(--gold); border: 1px solid var(--gold-rule); font-size: 0.76rem; font-weight: 600; line-height: 1.35; }
.q-count { font-size: 0.8rem; color: var(--ink-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.q-title { outline: none; }
.q-code { display: block; font-family: var(--font-sans); font-size: 0.78rem; font-weight: 650; letter-spacing: 0.06em; color: var(--ink-3); margin-bottom: 6px; }
.q-text { display: block; font-family: var(--font-serif); font-weight: 560; font-size: clamp(1.32rem, 1.1rem + 1vw, 1.62rem); line-height: 1.32; letter-spacing: -0.01em; text-wrap: pretty; }
.q-help { margin-top: 10px; color: var(--ink-2); font-size: 0.95rem; }
.q-flag { display: inline-block; margin-top: 10px; font-size: 0.8rem; font-weight: 600; color: var(--ink-3); }
.q-body { margin-top: 26px; }
fieldset { border: 0; padding: 0; min-width: 0; }

/* Shared option look */
.opt { position: relative; display: flex; align-items: center; gap: 14px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.opt input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.opt-face {
  flex: 1; display: flex; align-items: center; gap: 14px;
  min-height: 56px; padding: 14px 16px; border-radius: var(--r-lg);
  border: 1.5px solid var(--rule); background: var(--surface-2);
  transition: border-color var(--d-fast), background-color var(--d-fast), box-shadow var(--d-fast), transform var(--d-fast);
}
.opt:hover .opt-face { border-color: color-mix(in srgb, var(--accent) 45%, var(--rule)); background: var(--surface); }
.opt input:focus-visible + .opt-face { box-shadow: var(--ring); border-color: var(--accent); }
.opt input:checked + .opt-face { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 0.5px var(--accent); }
.opt-label { flex: 1; font-size: 1rem; line-height: 1.4; }
.opt input:checked + .opt-face .opt-label { font-weight: 600; }
.ind { width: 22px; height: 22px; flex: none; display: grid; place-items: center; border: 2px solid var(--rule-2); background: var(--surface); transition: background-color var(--d-fast), border-color var(--d-fast); }
.ind-radio { border-radius: 50%; }
.ind-radio::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-ink); transform: scale(0); transition: transform var(--d-base) var(--ease-out); }
.ind-check { border-radius: 7px; color: var(--accent-ink); }
.ind-check svg { width: 14px; height: 14px; transform: scale(0); transition: transform var(--d-base) var(--ease-out); }
.opt input:checked + .opt-face .ind { background: var(--accent); border-color: var(--accent); }
.opt input:checked + .opt-face .ind-radio::after,
.opt input:checked + .opt-face .ind-check svg { transform: scale(1); }
.opt.is-picked .opt-face { animation: pick 360ms var(--ease-out); }
@keyframes pick { 0% { transform: scale(1); } 40% { transform: scale(0.985); } 100% { transform: scale(1); } }

.choices { display: grid; gap: 10px; }
@media (min-width: 560px) { .choices.cols-2 { grid-template-columns: 1fr 1fr; } }
.multi-hint { font-size: 0.85rem; color: var(--ink-3); margin-bottom: 12px; display: flex; align-items: center; gap: 6px; }

/* Likert: stacked on phones, a five-point row on wider screens */
.likert-grid { display: grid; gap: 10px; }
.lk-n { width: 34px; height: 34px; flex: none; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--rule-2); background: var(--surface); font-weight: 650; font-size: 0.9rem; color: var(--ink-2); font-variant-numeric: tabular-nums; transition: background-color var(--d-fast), border-color var(--d-fast), color var(--d-fast), transform var(--d-base) var(--ease-out); }
.opt input:checked + .opt-face .lk-n { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); transform: scale(1.06); }
.scale-ends { display: none; }
@media (min-width: 640px) {
  .likert-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
  .likert-grid .opt-face { flex-direction: column; justify-content: flex-start; text-align: center; gap: 10px; min-height: 124px; padding: 16px 8px 14px; }
  .likert-grid .opt-label { flex: none; font-size: 0.86rem; line-height: 1.3; }
  .lk-n { width: 40px; height: 40px; font-size: 1rem; }
  .scale-ends { display: flex; justify-content: space-between; margin-top: 10px; font-size: 0.74rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
  .scale-ends span { display: inline-flex; align-items: center; gap: 6px; }
}

/* Text fields */
.field + .field { margin-top: 18px; }
.field-label { display: block; font-weight: 600; font-size: 0.95rem; margin-bottom: 8px; }
.field-label .opt-tag { font-weight: 500; color: var(--ink-3); font-size: 0.85rem; margin-left: 6px; }
.input, .textarea {
  width: 100%; min-height: 54px; padding: 14px 16px; border-radius: var(--r-md);
  border: 1.5px solid var(--rule-2); background: var(--surface); font-size: 1.02rem; line-height: 1.4;
  transition: border-color var(--d-fast), box-shadow var(--d-fast);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-3); opacity: .8; }
.input:hover, .textarea:hover { border-color: var(--ink-3); }
.input:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.textarea { min-height: 150px; resize: vertical; line-height: 1.6; }
.count { margin-top: 6px; text-align: right; font-size: 0.78rem; color: var(--ink-3); }

.q-error { display: flex; align-items: center; gap: 8px; margin-top: 16px; padding: 10px 14px; border-radius: var(--r-md); background: var(--danger-soft); color: var(--danger); font-size: 0.92rem; font-weight: 500; }
.q-error.shake { animation: shake 360ms var(--ease-out); }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-5px); } 60% { transform: translateX(4px); } }

/* Card footer: navigation. On phones it sticks to the bottom of the screen. */
.card-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--rule);
}
.card-foot .spacer { flex: 1; }
.skip-inline { display: none; margin-top: 18px; }
.skip-inline .btn { width: 100%; }
.kbd-hint { display: none; font-size: 0.78rem; color: var(--ink-3); align-items: center; gap: 6px; }
.kbd-hint kbd { font-family: var(--font-sans); font-size: 0.72rem; font-weight: 650; padding: 1px 6px; border: 1px solid var(--rule-2); border-bottom-width: 2px; border-radius: 5px; background: var(--surface-2); color: var(--ink-2); }
@media (hover: hover) and (pointer: fine) and (min-width: 640px) { .kbd-hint { display: inline-flex; } }
@media (max-width: 639px) {
  .card-foot {
    position: sticky; bottom: 0; z-index: 5;
    margin: 26px calc(-1 * clamp(22px, 5vw, 44px)) calc(-1 * clamp(22px, 5vw, 44px));
    padding: 12px clamp(22px, 5vw, 44px) calc(12px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    border-radius: 0 0 var(--r-xl) var(--r-xl);
  }
  .card-foot .btn-primary { flex: 1; }
  .card-foot .btn { padding: 0 16px; }
  .card-foot .lbl-back { display: none; }
  .card-foot #backBtn { padding: 0; width: 48px; }
  .card-foot .btn-quiet { display: none; }
  .skip-inline { display: block; }
}

/* ---------- Completion ---------- */
.done { text-align: center; }
.medal { width: 76px; height: 76px; margin: 4px auto 18px; border-radius: 50%; display: grid; place-items: center; background: var(--success-soft); color: var(--success); box-shadow: 0 0 0 8px color-mix(in srgb, var(--success-soft) 55%, transparent); }
.medal .icon { width: 38px; height: 38px; }
.medal.pop { animation: pop 620ms var(--ease-out) both; }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 60% { transform: scale(1.06); opacity: 1; } 100% { transform: scale(1); } }
.status { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: var(--r-full); font-size: 0.86rem; font-weight: 600; background: var(--paper-2); color: var(--ink-2); }
.status.is-sent { background: var(--success-soft); color: var(--success); }
.status.is-warn { background: var(--gold-soft); color: var(--gold); }
.status .icon { width: 16px; height: 16px; }
.spin { animation: spin 900ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.done .display { margin-top: 18px; }
.done .lead { max-width: 52ch; margin-left: auto; margin-right: auto; }
.retry-row { margin-top: 14px; display: flex; justify-content: center; }

.code-card { margin: 28px auto 0; max-width: 460px; padding: 20px; border-radius: var(--r-lg); border: 1.5px dashed var(--gold-rule); background: var(--gold-soft); text-align: center; }
.code-card .kicker { justify-content: center; }
.code-row { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.code { font-family: var(--font-mono); font-size: clamp(1.3rem, 1rem + 1.6vw, 1.7rem); font-weight: 700; letter-spacing: 0.08em; color: var(--ink); }
.code-card p { margin-top: 10px; font-size: 0.88rem; color: var(--ink-2); }

.tips { margin-top: 34px; text-align: left; border-top: 1px solid var(--rule); padding-top: 28px; }
.tips h2 { font-family: var(--font-serif); font-size: 1.28rem; font-weight: 620; letter-spacing: -0.01em; }
.tip-list { list-style: none; padding: 0; margin-top: 16px; display: grid; gap: 12px; counter-reset: tip; }
.tip { display: grid; grid-template-columns: 34px 1fr; gap: 14px; padding: 16px; border-radius: var(--r-lg); border: 1px solid var(--rule); background: var(--surface-2); counter-increment: tip; }
.tip::before { content: counter(tip); width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--gold-soft); color: var(--gold); font-family: var(--font-serif); font-weight: 700; }
.tip strong { display: block; font-weight: 650; line-height: 1.35; }
.tip p { font-size: 0.92rem; color: var(--ink-2); margin-top: 4px; line-height: 1.55; }
.done-actions { margin-top: 28px; display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.contact { margin-top: 22px; font-size: 0.88rem; color: var(--ink-3); }

/* ---------- Footer, toast, dialog ---------- */
.foot { text-align: center; padding: 22px 16px calc(26px + env(safe-area-inset-bottom)); font-size: 0.82rem; color: var(--ink-3); border-top: 1px solid var(--rule); }
.foot-links { margin-top: 6px; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 10px; }
.foot a, .foot .linkish { color: var(--ink-2); }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 50;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 10px 18px; border-radius: var(--r-full); background: var(--ink); color: var(--paper);
  font-size: 0.9rem; font-weight: 500; box-shadow: var(--shadow-2);
  transition: opacity var(--d-base), transform var(--d-base) var(--ease-out);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.dlg { margin: auto; border: 1px solid var(--rule); border-radius: var(--r-xl); padding: 26px; max-width: min(440px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-2); }
.dlg::backdrop { background: rgba(20, 18, 14, 0.45); }
.dlg-title { font-family: var(--font-serif); font-size: 1.3rem; font-weight: 620; }
.dlg-body { margin-top: 10px; color: var(--ink-2); font-size: 0.95rem; }
.dlg-actions { margin-top: 22px; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }

/* ---------- Sharing (v1.1) ---------- */
.top-status { margin-left: auto; }
.top-share {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  min-height: 36px; padding: 0 12px; border-radius: var(--r-full);
  border: 1px solid var(--rule-2); background: var(--surface); color: var(--ink-2);
  font-size: 0.84rem; font-weight: 600; cursor: pointer;
  transition: border-color var(--d-fast), color var(--d-fast);
}
.top-share:hover { border-color: var(--ink-3); color: var(--ink); }
.top-share .icon { width: 16px; height: 16px; }

.share {
  margin: 30px auto 0; max-width: 560px; padding: 22px; text-align: left;
  border-radius: var(--r-lg); border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--rule));
  background: var(--accent-soft);
}
.share-title { display: flex; align-items: center; gap: 10px; font-family: var(--font-serif); font-size: 1.22rem; font-weight: 640; letter-spacing: -0.01em; line-height: 1.3; }
.share-title .icon { color: var(--accent-text); width: 22px; height: 22px; }
.share-sub { margin-top: 6px; font-size: 0.92rem; color: var(--ink-2); }
.share-label { display: block; margin-top: 16px; font-size: 0.86rem; font-weight: 600; }
.share-label span { font-weight: 500; color: var(--ink-3); }
.share-msg {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px; resize: vertical; min-height: 92px;
  border: 1px solid var(--rule-2); border-radius: var(--r-md); background: var(--surface);
  font-size: 0.92rem; line-height: 1.5;
}
.share-msg:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.share-link { display: flex; align-items: flex-start; gap: 8px; margin-top: 8px; font-size: 0.82rem; color: var(--ink-3); }
.share-link .icon { width: 15px; height: 15px; margin-top: 2px; }
.share-url { overflow-wrap: anywhere; }
.btn-block { width: 100%; }
.share-native { margin-top: 16px; }
.share-hint { margin-top: 6px; font-size: 0.8rem; color: var(--ink-3); }
.share-grid { list-style: none; padding: 0; margin-top: 16px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.share-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  width: 100%; min-height: 70px; padding: 10px 6px; border-radius: var(--r-md);
  border: 1px solid var(--rule); background: var(--surface); color: var(--ink);
  font-size: 0.8rem; font-weight: 600; line-height: 1.2; text-align: center; text-decoration: none; cursor: pointer;
  transition: border-color var(--d-fast), transform var(--d-fast), box-shadow var(--d-fast);
}
.share-btn .icon { width: 20px; height: 20px; color: var(--accent-text); }
.share-btn:hover { border-color: var(--accent); box-shadow: var(--shadow-1); }
.share-btn:active { transform: translateY(1px); }
.share-qr { margin-top: 16px; padding: 16px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--rule); text-align: center; }
.qr-box { width: 200px; height: 200px; margin: 0 auto; }
.qr-box svg { width: 100%; height: 100%; display: block; border-radius: var(--r-sm); }
.share-qr .btn { margin-top: 12px; }

.promo {
  margin: 30px auto 0; max-width: 560px; padding: 20px; text-align: left;
  display: grid; grid-template-columns: 44px 1fr; gap: 14px;
  border-radius: var(--r-lg); border: 1px solid var(--gold-rule); background: var(--surface-2);
}
.promo-mark { width: 44px; height: 44px; border-radius: var(--r-md); display: grid; place-items: center; background: var(--gold-soft); color: var(--gold); }
.promo-mark .icon { width: 22px; height: 22px; }
.promo h2 { font-family: var(--font-serif); font-size: 1.12rem; font-weight: 640; }
.promo p { margin-top: 4px; font-size: 0.9rem; color: var(--ink-2); }
.promo .btn { margin-top: 12px; min-height: 42px; }

.dlg-share { margin: auto; position: relative; max-width: min(560px, calc(100vw - 24px)); padding: 6px; max-height: calc(100dvh - 24px); overflow: auto; }
.dlg-share .share { margin: 0; border: 0; }
.dlg-close {
  position: absolute; top: 14px; right: 14px; z-index: 1; width: 40px; height: 40px; display: grid; place-items: center;
  border: 1px solid var(--rule-2); border-radius: 50%; background: var(--surface); color: var(--ink-2); cursor: pointer;
}
.dlg-close:hover { color: var(--ink); border-color: var(--ink-3); }
.dlg-share .share-title { padding-right: 48px; }

/* ---------- Small screens ---------- */
@media (max-width: 560px) {
  .facts { grid-template-columns: 1fr; }
  .fact { flex-direction: row; align-items: center; gap: 12px; padding: 12px 14px; }
  .top-status .hide-sm { display: none; }
  .brand-name { font-size: 1rem; }
  .actions .btn-primary { width: 100%; }
  .share { padding: 18px 16px; }
  .share-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .share-btn { flex-direction: row; justify-content: flex-start; min-height: 48px; padding: 0 14px; font-size: 0.88rem; }
  .top-share span { display: none; }
  .top-share { width: 40px; padding: 0; justify-content: center; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .spin { animation: none !important; }
}
