:root {
  color-scheme: light;
  --bg: #f4f3ef; --surface: #fcfcfb; --ink: #0b0b0b; --ink2: #52514e; --ink3: #7a7972; --line: #e2e0d9; --track: #ecebe6;
  --accent: #2a78d6; --muted-fill: #b9b7ae; --ok: #0a6b3a; --warn-bg: #fff3cd; --warn-ink: #5c4400;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --radius: 14px; --tabbar: 60px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #111110; --surface: #1a1a19; --ink: #f0efec; --ink2: #c3c2b7; --ink3: #98978e; --line: #30302c; --track: #262624;
    --accent: #3987e5; --muted-fill: #5d5c56; --ok: #5fd39a; --warn-bg: #3f3200; --warn-ink: #ffe08a;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom));
}
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
button, select, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- header and tabs ---------- */
.top { position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line); }
.top-in { max-width: 720px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 10px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; text-decoration: none; letter-spacing: -0.01em; }
.brand img { border-radius: 7px; }
.country { font-size: 12px; font-weight: 600; color: var(--ink2); border: 1px solid var(--line); border-radius: 99px; padding: 2px 9px; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex;
  background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  flex: 1; height: var(--tabbar); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 12px; font-weight: 600; color: var(--ink3); text-decoration: none;
}
.tabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.tabs a[aria-current="page"] { color: var(--ink); }
@media (min-width: 720px) {
  body { padding-bottom: 0; }
  .tabs { position: static; margin-left: auto; border: 0; padding: 0; gap: 4px; background: none; }
  .tabs a { flex: none; height: 40px; flex-direction: row; gap: 6px; padding: 0 14px; border-radius: 99px; font-size: 14px; }
  .tabs svg { width: 18px; height: 18px; }
  .tabs a[aria-current="page"] { background: var(--track); }
}

.demo { background: var(--warn-bg); color: var(--warn-ink); text-align: center; font-size: 13px; font-weight: 600; padding: 6px 16px; }

/* ---------- ad slots: an empty slot is not on the page at all; a filled one is labelled ---------- */
.ad { display: flex; flex-direction: column; align-items: center; gap: 4px; margin: 12px auto; max-width: calc(100% - 32px); }
.ad span { color: var(--ink3); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; }
.ad a { display: block; line-height: 0; }
.ad img { display: block; max-width: 100%; height: auto; border-radius: 8px; }
.ad-banner img { max-height: 50px; }
.ad-box img { max-width: min(300px, 100%); max-height: 250px; }
@media (min-width: 760px) { .ad-banner img { max-height: 90px; } }

/* ---------- layout ---------- */
main { max-width: 720px; margin: 0 auto; padding: 4px 16px 24px; outline: none; }
.hero { padding: 12px 2px 16px; }
.hero h1 { font-size: clamp(26px, 7.4vw, 36px); line-height: 1.1; letter-spacing: -0.02em; font-weight: 800; }
.hero p { color: var(--ink2); margin-top: 8px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { font-size: 20px; letter-spacing: -0.01em; }
.card-head span { color: var(--ink2); font-size: 14px; white-space: nowrap; }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink2); margin: 22px 2px 8px; }
.note { color: var(--ink2); font-size: 14px; }
.note.ok { color: var(--ok); font-weight: 600; }
.note.err { color: var(--warn-ink); background: var(--warn-bg); border-radius: 8px; padding: 8px 10px; }
.stack > * + * { margin-top: 10px; }

/* ---------- ballot ---------- */
.options { display: grid; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.opt { position: relative; display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 14px; border: 1.5px solid var(--line); border-radius: 12px; cursor: pointer; }
.opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.opt .dot { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--ink3); display: grid; place-items: center; }
.opt .who { min-width: 0; }
.opt b { display: block; font-weight: 650; overflow-wrap: anywhere; }
.opt small { color: var(--ink2); font-size: 13px; }
.opt:has(input:checked) { border-color: var(--ink); background: var(--track); }
.opt:has(input:checked) .dot { border-color: var(--ink); }
.opt:has(input:checked) .dot::after { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--ink); }
.opt:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 18px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--surface); font-weight: 650; cursor: pointer; text-decoration: none;
}
.btn.primary { width: 100%; min-height: 54px; font-size: 17px; background: var(--ink); color: var(--surface); border-color: var(--ink); margin-top: 12px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.small { min-height: 40px; padding: 0 12px; font-size: 14px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

select, input[type="text"], input[type="password"], input[type="email"], input[type="tel"], textarea {
  width: 100%; min-height: 50px; padding: 0 12px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface);
}
label.field { display: block; font-size: 14px; font-weight: 600; color: var(--ink2); }
label.field > * { margin-top: 4px; font-weight: 400; color: var(--ink); }
details.suggest { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
details.suggest summary, details.table summary { cursor: pointer; color: var(--ink2); font-size: 14px; font-weight: 600; min-height: 32px; display: flex; align-items: center; }
details.suggest form { margin-top: 8px; }

/* ---------- result bars ---------- */
.bars { display: grid; gap: 12px; }
.bar-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.bar-top b { font-weight: 650; overflow-wrap: anywhere; }
.bar-top small { color: var(--ink2); font-weight: 400; }
.bar-top .val { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 700; }
.bar-top .val small { margin-left: 6px; }
.track { height: 10px; background: var(--track); border-radius: 4px; margin-top: 5px; overflow: hidden; }
.fill { height: 100%; width: 0; background: var(--accent); border-radius: 0 4px 4px 0; transition: width 0.5s ease; }
.fill.none { background: var(--muted-fill); }
.you { display: inline-block; margin-left: 6px; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: var(--ink); color: var(--surface); vertical-align: 2px; }
@media (prefers-reduced-motion: reduce) { .fill { transition: none; } }

/* ---------- results page ---------- */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.tile b { display: block; font-size: clamp(20px, 6vw, 28px); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.tile span { font-size: 12px; color: var(--ink2); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips button { flex: none; min-height: 40px; padding: 0 14px; border-radius: 99px; border: 1.5px solid var(--line); background: var(--surface); font-weight: 600; font-size: 14px; cursor: pointer; }
.chips button[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.controls { display: grid; gap: 10px; margin-bottom: 14px; }

.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--ink3); font-size: 11px; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .end { stroke: var(--surface); stroke-width: 2; }
.chart .cross { stroke: var(--ink3); stroke-width: 1; }
.c1 { stroke: var(--s1); } .c2 { stroke: var(--s2); } .c3 { stroke: var(--s3); } .c4 { stroke: var(--s4); }
.f1 { fill: var(--s1); background: var(--s1); } .f2 { fill: var(--s2); background: var(--s2); }
.f3 { fill: var(--s3); background: var(--s3); } .f4 { fill: var(--s4); background: var(--s4); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; margin-bottom: 8px; }
.legend span, .tip div { display: flex; align-items: center; gap: 6px; }
.legend b, .tip b { font-variant-numeric: tabular-nums; }
.sw { flex: none; width: 10px; height: 10px; border-radius: 3px; }
.tip {
  position: absolute; top: 0; pointer-events: none; background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-size: 12px; box-shadow: 0 4px 14px rgb(0 0 0 / 0.12); min-width: 150px; z-index: 2;
}
.tip strong { display: block; margin-bottom: 4px; }
.tip div { justify-content: space-between; gap: 12px; }
.tip div span { display: flex; align-items: center; gap: 6px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
th { font-size: 12px; color: var(--ink2); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.scroll { overflow-x: auto; }
details.table { margin-top: 10px; }

/* ---------- prose and footer ---------- */
.prose h1 { font-size: 26px; letter-spacing: -0.02em; margin-bottom: 10px; }
.prose h2 { font-size: 17px; margin: 18px 0 6px; }
.prose p, .prose li { color: var(--ink2); }
.prose ul { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.foot { max-width: 720px; margin: 0 auto; padding: 8px 18px 24px; font-size: 12px; color: var(--ink3); }
.skeleton { height: 120px; border-radius: 12px; background: var(--track); }
td:first-child { white-space: nowrap; }

/* ---------- optional steps: about you, phone confirmation ---------- */
.chips.wrap { flex-wrap: wrap; overflow: visible; margin-top: 6px; }
details.about-you summary { cursor: pointer; font-weight: 650; min-height: 28px; display: flex; align-items: center; justify-content: space-between; list-style: none; }
details.about-you summary::-webkit-details-marker { display: none; }
details.about-you summary::after { content: "+"; font-size: 22px; font-weight: 400; color: var(--ink2); }
details.about-you[open] summary::after { content: "\2212"; }
details.about-you[open] summary { margin-bottom: 8px; }

/* ---------- contact form, footer links, share buttons, consent question ---------- */
textarea { min-height: 130px; padding: 10px 12px; resize: vertical; font: inherit; color: inherit; }
.card-title { font-size: 18px; letter-spacing: -0.01em; }
.foot p + p { margin-top: 6px; }
.foot-links a, button.link { color: var(--ink2); font-weight: 600; }
button.link { background: none; border: 0; padding: 0; font-size: inherit; text-decoration: underline; cursor: pointer; }
.share { margin-top: 10px; }
.btn.wa { background: #128c4b; border-color: #128c4b; color: #fff; }
.btn.fb { background: #1463cc; border-color: #1463cc; color: #fff; }
.btn.solid { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.prose p + p, .prose ul + p { margin-top: 10px; }
.prose a { color: var(--accent); font-weight: 600; }
.prose a.btn { color: inherit; }
.consent {
  position: fixed; left: 8px; right: 8px; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 8px); z-index: 7; max-width: 560px; margin: 0 auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; font-size: 14px;
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.18);
}
.consent .row { margin-top: 10px; justify-content: flex-end; }
@media (min-width: 720px) { .consent { bottom: 16px; } }
.msg { border-top: 1px solid var(--line); padding-top: 10px; }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; margin: 6px 0 8px; }
td.bad { color: var(--warn-ink); background: var(--warn-bg); font-weight: 600; }
.facts td, .facts td:first-child { white-space: normal; overflow-wrap: anywhere; vertical-align: top; }
.facts td:first-child { width: 45%; color: var(--ink2); }
