/* Stepwise design tokens.
   Shape rule: containers and blocks 12px radius; interactive buttons and chips are pills.
   One accent: emerald. Neutrals: zinc. Theme: auto light/dark. */
:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --text: #18181b;
  --muted: #52525b;
  --faint: #6b6b73;
  --border: #e4e4e7;
  --accent: #047857;
  --accent-ink: #ecfdf5;
  --accent-soft: #d1fae5;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --mark: #fef08a;
  --radius: 12px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101012;
    --surface: #18181b;
    --text: #f4f4f5;
    --muted: #a1a1aa;
    --faint: #9a9aa4;
    --border: #27272a;
    --accent: #34d399;
    --accent-ink: #052e22;
    --accent-soft: #064e3b;
    --danger: #f87171;
    --danger-soft: #450a0a;
    --mark: #713f12;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
/* Reserve space so the fixed flag button never sits over the last on-screen
   content (the persistent disclaimer) once the reader scrolls to the end. */
body.has-guide { padding-bottom: 4.25rem; }

/* ---------- Sticky guide header ---------- */
.guide-head {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.head-row {
  max-width: 760px;
  margin: 0 auto;
  padding: 0.65rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand {
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: 1.05rem;
  color: var(--text);
}
.brand:hover { text-decoration: none; color: var(--accent); }
.head-meta { display: flex; gap: 0.5rem; align-items: center; }
.chip {
  font-size: 0.72rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  white-space: nowrap;
}
.chip-verified { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }

/* Segmented step progress */
.segments {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 1rem 0.55rem;
  display: flex;
  gap: 4px;
}
.seg {
  position: relative;
  overflow: hidden;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.4rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.72rem;
  transition: border-color 0.25s, color 0.25s;
}
.seg:hover { text-decoration: none; border-color: var(--accent); }
/* Per-step fill: width tracks how far scrolled through THIS step's own
   content, independent of the total-progress bar. Done steps sit at 100%,
   the active step grows continuously, later steps stay at 0%. */
.seg-fill {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 0%;
  background: var(--accent-soft);
}
.seg-num, .seg-title { position: relative; z-index: 1; }
.seg-num {
  font-family: var(--mono);
  font-size: 0.68rem;
  flex: none;
  width: 1.15rem;
  height: 1.15rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--border);
  color: var(--muted);
  transition: background 0.2s, color 0.2s;
}
.seg-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.seg-done, .seg-active { border-color: transparent; color: var(--text); }
.seg-active { border-color: var(--accent); }
.seg-done .seg-num, .seg-active .seg-num { background: var(--accent); color: var(--accent-ink); }
@media (max-width: 640px) {
  .seg-title { display: none; }
  .seg { justify-content: center; }
}

/* ---------- Article ---------- */
main { max-width: 760px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.crumb {
  font-size: 0.78rem;
  color: var(--faint);
  text-transform: capitalize;
  margin: 0.5rem 0 0.25rem;
}
h1 {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
}
.summary { color: var(--muted); font-size: 1.05rem; margin: 0 0 2rem; max-width: 60ch; }

.step { padding: 1.25rem 0; border-top: 1px solid var(--border); scroll-margin-top: 110px; }
.step h2 {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  margin: 0 0 0.5rem;
}
.step-num {
  flex: none;
  width: 1.7rem;
  height: 1.7rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--mono);
  font-size: 0.85rem;
}
.step p { margin: 0.5rem 0; max-width: 65ch; }
.step ul { margin: 0.5rem 0; padding-left: 1.2rem; max-width: 60ch; }
.step code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.08em 0.35em;
}
.cite a {
  font-size: 0.7em;
  color: var(--accent);
  padding: 0 0.15em;
  cursor: pointer;
}

/* Citation tooltip: click a [n] marker to see the source without leaving the
   step; "Show in list" performs the same jump the bare link used to do. */
.cite-tip {
  position: fixed;
  z-index: 35;
  max-width: 300px;
  padding: 0.7rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 30px color-mix(in srgb, var(--text) 14%, transparent);
}
.cite-tip p {
  margin: 0 0 0.55rem;
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.4;
  word-break: break-word;
}
.cite-tip-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.cite-tip-actions .btn-ghost { font-size: 0.76rem; padding: 0.3rem 0.7rem; }
.cite-tip-actions a.btn-ghost { text-decoration: none; }
.src-flash { animation: srcflash 1.4s ease-out; }
@keyframes srcflash {
  0%, 40% { background: var(--accent-soft); }
  100% { background: transparent; }
}
.flag-chip {
  font-size: 0.68rem;
  font-weight: 400;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  white-space: nowrap;
}

/* Copy blocks */
.block {
  margin: 0.9rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.block figcaption {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--muted);
}
.copy-btn {
  font: inherit;
  font-size: 0.75rem;
  color: var(--accent);
  background: none;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 999px;
  padding: 0.12rem 0.7rem;
  cursor: pointer;
}
.copy-btn:hover { background: var(--accent-soft); }
.copy-btn:active { transform: scale(0.97); }
.copy-btn.copied { color: var(--text); border-color: var(--border); }
.block pre {
  margin: 0;
  padding: 0.8rem 1rem;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.55;
}

/* Sources */
.sources-sec { padding: 1.25rem 0; border-top: 1px solid var(--border); }
.sources-sec h2 { font-size: 1.15rem; margin: 0 0 0.25rem; }
.sources-note { color: var(--muted); font-size: 0.88rem; margin: 0 0 0.75rem; }
.sources { margin: 0; padding-left: 1.4rem; font-size: 0.9rem; }
.sources li { margin: 0.3rem 0; overflow-wrap: anywhere; border-radius: 4px; transition: background-color 0.3s; }

/* Ad slot: one static placement, after all guide content, styled like a
   regular card rather than a jarring injected banner. Contained + clipped so
   a network's snippet can never blow out the layout or cause a mobile
   overlap the way the old sticky elements once did. */
.ad-slot {
  margin: 1.25rem 0 0;
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  max-width: 100%;
}
.ad-slot .ad-label {
  margin: 0 0 0.6rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
}
/* Reserve the unit's real size so the slot is visible even when the network
   returns no fill (common on a new domain) instead of collapsing to an
   invisible gap -- otherwise there is no way to tell "no ad sold" apart from
   "ad code broken". The iframe sits on this placeholder. */
.ad-slot .ad-holder {
  position: relative;
  min-height: 250px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: color-mix(in srgb, var(--border) 35%, transparent);
}
.ad-slot .ad-holder::before {
  content: 'Ad space';
  position: absolute;
  font-size: 0.72rem;
  color: var(--faint);
}
.ad-slot iframe, .ad-slot img, .ad-slot ins {
  position: relative;
  max-width: 100%;
  z-index: 1;
}

/* Banners */
.banner {
  max-width: 760px;
  margin: 1rem auto 0;
  padding: 0.75rem 1rem;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  background: var(--accent-soft);
  border-radius: var(--radius);
  font-size: 0.92rem;
}
.banner-error {
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
  background: var(--danger-soft);
}

/* ---------- Flagging ---------- */
.flag-fab {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 20;
  font: inherit;
  font-size: 0.85rem;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 4px 16px color-mix(in srgb, var(--text) 10%, transparent);
}
.flag-fab:hover { border-color: var(--danger); color: var(--danger); }
.flag-fab:active { transform: scale(0.97); }
.flag-fab[disabled] { opacity: 0.6; cursor: default; font-family: var(--mono); }

/* Reward-ad unlock button: sits directly above the flag button, same pill
   language, only shown while the flag button is on cooldown. */
.reward-fab {
  position: fixed;
  right: 1rem;
  bottom: 3.6rem;
  z-index: 20;
  font: inherit;
  font-size: 0.8rem;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  background: var(--surface);
  color: var(--accent);
  cursor: pointer;
  box-shadow: 0 4px 16px color-mix(in srgb, var(--text) 10%, transparent);
}
.reward-fab:hover { background: var(--accent-soft); }
.reward-fab:active { transform: scale(0.97); }
.flag-fab.flagging { border-color: var(--danger); color: var(--danger); }
body.flag-mode .step { cursor: text; }
body.flag-mode ::selection { background: var(--mark); }
.flag-coach {
  position: fixed;
  bottom: 3.6rem;
  right: 1rem;
  z-index: 20;
  background: var(--text);
  color: var(--bg);
  font-size: 0.8rem;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
}
.flag-pop {
  position: fixed;
  z-index: 30;
  width: min(340px, calc(100vw - 2rem));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem;
  box-shadow: 0 8px 30px color-mix(in srgb, var(--text) 15%, transparent);
}
.flag-quote {
  font-size: 0.82rem;
  color: var(--muted);
  border-left: 3px solid var(--danger);
  padding-left: 0.6rem;
  margin: 0 0 0.6rem;
  max-height: 4.5em;
  overflow: hidden;
}
.flag-pop label { display: block; font-size: 0.8rem; margin-bottom: 0.3rem; }
.flag-pop .opt { color: var(--faint); }
.flag-pop input {
  width: 100%;
  font: inherit;
  font-size: 0.88rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}
.flag-pop input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.flag-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.7rem; }
.flag-status { font-size: 0.8rem; margin: 0.5rem 0 0; color: var(--muted); min-height: 1em; }

.btn {
  font: inherit;
  font-size: 0.88rem;
  padding: 0.45rem 1.1rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(0.97); }
.btn[disabled] { opacity: 0.55; cursor: default; }
.btn-ghost {
  font: inherit;
  font-size: 0.88rem;
  padding: 0.45rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.btn-ghost:hover { color: var(--text); }

/* ---------- Home ---------- */
.home-hero { padding: 3.5rem 0 1.5rem; }
.home-hero h1 {
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  max-width: 22ch;
}
.home-hero .summary { margin-bottom: 1.5rem; }
.ask-row { display: flex; gap: 0.5rem; align-items: stretch; }
.ask-row input {
  flex: 1;
  font: inherit;
  font-size: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
}
.ask-row input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.ask-hint { font-size: 0.8rem; color: var(--muted); margin: 0.5rem 0 0 1rem; }
.ask-hint.error { color: var(--danger); }

.results { margin-top: 1.25rem; display: grid; gap: 0.5rem; }
.result-card, .guide-card {
  display: block;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
.result-card:hover, .guide-card:hover { text-decoration: none; border-color: var(--accent); }
.result-card h3, .guide-card h3 { margin: 0 0 0.15rem; font-size: 0.98rem; letter-spacing: -0.01em; }
.result-card p, .guide-card p { margin: 0; font-size: 0.84rem; color: var(--muted); }
.result-status { font-size: 0.72rem; color: var(--accent); font-family: var(--mono); }
.new-guide-row { margin-top: 0.9rem; display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.new-guide-row p { margin: 0; font-size: 0.85rem; color: var(--muted); }

.home-sec { margin-top: 2.5rem; }
.home-sec h2 { font-size: 1rem; color: var(--muted); font-weight: 600; margin: 0 0 0.75rem; }
.guide-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0.6rem; }
.empty-note { color: var(--faint); font-size: 0.88rem; }

/* ---------- Pending / progress ---------- */
.pending { padding: 2.5rem 0; }
.phases { list-style: none; margin: 2rem 0 0; padding: 0; display: grid; gap: 1.4rem; }
.phase { display: flex; gap: 0.9rem; align-items: flex-start; }
.phase h2 { margin: 0; font-size: 1rem; }
.phase p { margin: 0.15rem 0 0; font-size: 0.88rem; color: var(--muted); max-width: 55ch; }
.phase-dot {
  flex: none;
  margin-top: 0.3rem;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--surface);
}
.phase-done .phase-dot { background: var(--accent); border-color: var(--accent); }
.phase-active .phase-dot { border-color: var(--accent); }
@media (prefers-reduced-motion: no-preference) {
  .phase-active .phase-dot { animation: pulse 1.6s ease-in-out infinite; }
  @keyframes pulse {
    50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 25%, transparent); }
  }
}
.phase-idle { opacity: 0.45; }

.foot {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.5rem 1rem 2.5rem;
  border-top: 1px solid var(--border);
  color: var(--faint);
  font-size: 0.82rem;
}
.foot p { margin: 0; max-width: 65ch; }
.foot-links { margin-top: 0.5rem !important; }
.foot-links a { color: var(--muted); }

/* Per-guide disclaimer */
.disclaimer {
  margin: 0 0 2rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--faint);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
  max-width: 65ch;
}
.disclaimer a { color: var(--muted); text-decoration: underline; }

/* Persistent per-page disclaimer: a real footer line on every page (not a
   floating overlay), so it never collides with fixed UI like the flag button
   on small screens, and is seen on every page load rather than dismissed once. */
.persist-disclaimer {
  position: static;
  margin: 0;
  padding: 0.6rem 1rem 1.5rem;
  text-align: center;
  font-size: 0.74rem;
  color: var(--muted);
  background: none;
  border-top: 1px solid var(--border);
}
.persist-disclaimer a { color: var(--muted); text-decoration: underline; }

/* One-time clickwrap gate: blocking overlay, no backdrop/Escape dismissal. */
html.consent-locked { overflow: hidden; }
.consent-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: color-mix(in srgb, #000 55%, transparent);
  backdrop-filter: blur(2px);
}
.consent-card {
  max-width: 460px;
  width: 100%;
  padding: 1.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px color-mix(in srgb, #000 30%, transparent);
}
.consent-title { font-weight: 700; font-size: 1.05rem; margin: 0 0 0.6rem; }
.consent-card p:not(.consent-title) { font-size: 0.88rem; color: var(--muted); line-height: 1.55; margin: 0 0 1rem; }
.consent-card a { color: var(--text); text-decoration: underline; }
.consent-card .btn { width: 100%; font-size: 0.95rem; padding: 0.6rem 1rem; }

/* Inline point-of-risk hazard callout, attached to the specific step. */
.hazard {
  margin: 0.6rem 0;
  padding: 0.55rem 0.8rem;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  background: var(--danger-soft);
  border-radius: 8px;
  font-size: 0.88rem;
  color: var(--text);
  max-width: 65ch;
}
.hazard strong { color: var(--danger); }

/* Legal pages */
.legal { padding: 1.5rem 0 2rem; }
.legal h1 { margin-bottom: 1rem; }
.legal h2 { font-size: 1.05rem; margin: 1.6rem 0 0.4rem; }
.legal p, .legal li { max-width: 65ch; color: var(--text); }
.legal ul { padding-left: 1.3rem; }
.legal li { margin: 0.3rem 0; }
.legal-draft {
  padding: 0.7rem 0.9rem;
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
  background: var(--danger-soft);
  border-radius: 8px;
  font-size: 0.88rem;
}
.legal-eff { color: var(--faint); font-size: 0.85rem; }
