/* poll.json.systems - one stylesheet, no framework, no build step.
   Mobile first; a 390px phone is the primary target. */

:root {
  --bg:        #f4f6f5;
  --surface:   #ffffff;
  --surface-2: #eef2f1;
  --text:      #15201e;
  --text-2:    #3b4745;
  --muted:     #5f6b69;
  --line:      #d9e0de;
  --accent:    #0f766e;
  --accent-2:  #14b8a6;
  --accent-ink:#ffffff;
  --accent-sub:#e0f2ef;
  --bar:       #99d5cd;
  --good:      #1d7a45;
  --good-bg:   #e5f4ea;
  --warn:      #8a5a00;
  --warn-bg:   #fdf3e0;
  --bad:       #a33232;
  --bad-bg:    #fbecec;
  --radius:    12px;
  --shadow:    0 1px 2px rgba(0,0,0,.05), 0 1px 8px rgba(0,0,0,.04);
  --mono:      ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #101615;
    --surface:   #18201f;
    --surface-2: #212b29;
    --text:      #e6eeec;
    --text-2:    #c2cecb;
    --muted:     #93a3a0;
    --line:      #2d3a38;
    --accent:    #2dd4bf;
    --accent-2:  #5eead4;
    --accent-ink:#0c1413;
    --accent-sub:#173532;
    --bar:       #1f6f66;
    --good:      #6ddc9f;
    --good-bg:   #14312a;
    --warn:      #f0c073;
    --warn-bg:   #33290f;
    --bad:       #f08b8b;
    --bad-bg:    #34191b;
    --shadow:    0 1px 2px rgba(0,0,0,.3);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .4em; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; overflow-wrap: anywhere; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75em; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
[hidden] { display: none !important; }

.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px 48px; }

/* ------------------------------------------------------------------ topbar */

.topbar {
  display: flex; align-items: center; gap: 10px;
  max-width: 640px; margin: 0 auto; padding: 18px 16px 12px;
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 1.05rem; letter-spacing: -.02em;
  color: var(--text); text-decoration: none;
}
.brand-mark {
  font-family: var(--mono); font-size: .8rem; font-weight: 700;
  color: var(--accent-ink); background: var(--accent);
  border-radius: 7px; padding: 2px 6px; letter-spacing: 0;
}
.brand-dim { color: var(--muted); font-weight: 500; margin-left: -8px; }
.topbar-link {
  margin-left: auto; font-size: .85rem; font-weight: 600;
  color: var(--muted); text-decoration: none;
}
.topbar-link:hover { color: var(--accent); }

.foot {
  max-width: 640px; margin: 0 auto; padding: 8px 16px 32px;
  color: var(--muted); font-size: .78rem; text-align: center;
}
.foot a { color: inherit; }

/* ------------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin: 0 0 16px;
  min-width: 0;
}
.card.center, .center { text-align: center; }
.hero { padding: 8px 2px 16px; }
.lede { color: var(--muted); }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .84rem; margin: .35em 0 0; }
.mini { font-size: .95rem; margin-top: 1.1em; }
.eyebrow { color: var(--muted); font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; margin: 0 0 .2em; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.muted-card p { margin: 0; color: var(--muted); }

/* ------------------------------------------------------------------- forms */

.field { margin: 0 0 14px; }
label { display: block; font-weight: 600; font-size: .9rem; margin: 0 0 6px; }
.req { float: right; font-weight: 400; color: var(--muted); font-size: .78rem; }

input[type=text], input[type=number], input[type=datetime-local], select, textarea {
  width: 100%; padding: 10px 12px;
  font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 9px;
  min-width: 0;
}
textarea { resize: vertical; line-height: 1.4; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.card { border: 1px solid var(--line); padding: 18px; margin: 0 0 16px; }

.check {
  display: flex; align-items: flex-start; gap: 10px;
  font-weight: 500; margin: 0 0 10px; cursor: pointer;
}
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: .95rem;
  padding: 10px 16px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-lg { padding: 13px 22px; font-size: 1.05rem; width: 100%; }
.btn-sm { padding: 7px 12px; font-size: .85rem; }
.btn-danger { color: var(--bad); }
.btn-danger:hover { border-color: var(--bad); }
.btn-link {
  background: none; border: 0; padding: 4px 0; font: inherit; font-size: .85rem;
  color: var(--muted); cursor: pointer; text-decoration: underline;
}
.btn-link.danger:hover { color: var(--bad); }
.submitrow { margin: 20px 0 8px; }
.addrow { margin: 0 0 16px; }
.addrow .btn { width: 100%; border-style: dashed; color: var(--accent); }

.alert { border-radius: var(--radius); padding: 12px 16px; margin: 0 0 16px; }
.alert ul { margin: 0; padding-left: 1.1em; }
.alert-bad  { background: var(--bad-bg);  color: var(--bad); }
.alert-warn { background: var(--warn-bg); color: var(--warn); }
.alert-good { background: var(--good-bg); color: var(--good); }
.alert p:last-child { margin-bottom: 0; }
.fielderr { color: var(--bad); font-weight: 600; font-size: .88rem; margin: .4em 0 .6em; }
.has-error { border-color: var(--bad) !important; }

/* ----------------------------------------------------------------- builder */

.qlist { counter-reset: q; }
.qblock { counter-increment: q; }
.qhead { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.qnum { font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); padding: 0; float: left; }
.qnum::after { content: " " counter(q); }
.qhead + .field { clear: both; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.kindpart { margin-top: 4px; }
/* Without JS every kind's fields show, each marked with the kind it is for;
   with JS (html.js) only the relevant ones are shown and the notes go. */
.js .nojs-note { display: none; }
.js .qblock .kindpart { display: none; }
.js .qblock[data-kind=single] .kindpart[data-for~=single],
.js .qblock[data-kind=multi]  .kindpart[data-for~=multi],
.js .qblock[data-kind=ranked] .kindpart[data-for~=ranked],
.js .qblock[data-kind=scale]  .kindpart[data-for~=scale] { display: block; }
.js .qblock[data-kind=multi]  .kindpart.row2[data-for~=multi] { display: grid; }
.js [data-for-preset=custom] { display: none; }
.js [data-for-preset=custom].on { display: block; }
.nojs-note { font-weight: 400; color: var(--muted); }

.settings summary { cursor: pointer; font-weight: 650; }
.settings[open] summary { margin-bottom: 14px; }

/* ------------------------------------------------------------------ status */

.pollhead { padding: 4px 2px 10px; }
.desc { color: var(--muted); overflow-wrap: anywhere; }
.status { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; color: var(--muted); font-size: .88rem; margin: 0; }
.pill { font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: 2px 8px; border-radius: 99px; }
.pill-open   { background: var(--good-bg); color: var(--good); }
.pill-closed { background: var(--surface-2); color: var(--muted); }
.count { font-weight: 600; color: var(--text); }

/* ------------------------------------------------------------------ ballot */

.question legend { font-weight: 650; font-size: 1.05rem; padding: 0; margin-bottom: 2px; overflow-wrap: anywhere; }
/* A floated legend sits inside the card instead of on its top border. */
.question legend { float: left; width: 100%; }
.question legend + * { clear: both; }
.qn {
  display: inline-grid; place-items: center; min-width: 1.5em; height: 1.5em;
  margin-right: 8px; border-radius: 6px; font-size: .78em; font-weight: 700;
  background: var(--accent-sub); color: var(--accent); vertical-align: 2px;
}
.question .hint { margin-bottom: 12px; }
/* The creator's guidance: one step below the question - regular weight, a
   little smaller, softer ink - and one step above the "Pick one." hint. It sits
   in the reading line of the prompt, not indented under the number badge. */
.qdesc { font-size: .95rem; color: var(--text-2); margin: 4px 0 0; overflow-wrap: anywhere; }
.question .qdesc + .hint { margin-top: 8px; }
.result .qdesc { font-size: .88rem; margin: 0 0 6px; }
label.sub { font-weight: 500; color: var(--muted); font-size: .82rem; }
textarea.qdesc-input { min-height: 0; }
.choices { display: grid; gap: 8px; }
.choice {
  display: flex; align-items: center; gap: 12px; margin: 0;
  padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px;
  font-weight: 500; cursor: pointer; background: var(--surface);
  overflow-wrap: anywhere;
}
.choice:hover { border-color: var(--accent); }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-sub); }
.choice input[type=radio], .choice input[type=checkbox] { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); flex: none; }
.choice-other input[type=text] { padding: 6px 10px; }
/* A numeric scale reads as one row of numbers, lowest to highest. */
/* One row however many points: the number is the target, the radio is hidden
   but still focusable and still the form control. */
.choices-numeric { grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 4px; }
.choices-numeric .choice { position: relative; justify-content: center; padding: 12px 0; font-weight: 650; font-variant-numeric: tabular-nums; }
.choices-numeric .choice input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.choices-numeric .choice:has(input:checked) { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.choices-numeric .choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.scale-ends { display: flex; justify-content: space-between; color: var(--muted); font-size: .78rem; margin: 6px 2px 0; }

/* Ranked. Without JS: a rank select per choice. With JS the selects hide and
   the rows become tap targets; the select stays the source of truth. */
.ranklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rankrow {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px;
}
.rankrow select { width: auto; padding: 6px 8px; }
.ranklabel { font-weight: 500; flex: 1; overflow-wrap: anywhere; }
.ranklabel-other input { padding: 6px 10px; }
.js .ranklist .rankrow select { display: none; }
.js .rankrow { cursor: pointer; user-select: none; -webkit-user-select: none; padding: 11px 14px; }
.js .rankrow:hover { border-color: var(--accent); }
.rankbadge {
  display: inline-grid; place-items: center; width: 28px; height: 28px; flex: none;
  border-radius: 50%; border: 1.5px dashed var(--line); color: var(--muted);
  font-weight: 700; font-size: .85rem;
}
.rankrow.ranked { border-color: var(--accent); background: var(--accent-sub); }
.rankrow.ranked .rankbadge { border: 0; background: var(--accent); color: var(--accent-ink); }
.rank-tools { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; min-height: 24px; }

/* ----------------------------------------------------------------- results */

.results { margin-top: 28px; }
.results-head { display: flex; align-items: baseline; gap: 10px; margin: 0 2px 10px; }
.results-head h2 { margin: 0; font-size: 1.25rem; }
.live { color: var(--muted); font-size: .8rem; margin-left: auto; font-variant-numeric: tabular-nums; }
.live.is-news { color: var(--accent); font-weight: 600; }
.refresh { margin-left: auto; font-size: .85rem; }
.js .refresh { display: none; }
.result h3 { overflow-wrap: anywhere; }
.result > .hint:first-of-type { margin: -2px 0 14px; }

.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.bar { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: baseline; }
.blabel { font-weight: 500; overflow-wrap: anywhere; min-width: 0; }
.bnum { font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; }
.pct { color: var(--muted); font-weight: 500; font-size: .85rem; margin-left: 4px; }
.btrack { grid-column: 1 / -1; height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bfill { display: block; height: 100%; border-radius: 99px; background: var(--bar); min-width: 2px; transition: width .4s ease; }
.bar.leader .bfill { background: var(--accent); }
.bar.leader .blabel { font-weight: 650; }

/* Scale histogram: one column per point, in scale order, so a split shows. */
.histo {
  display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  grid-template-rows: 150px auto; column-gap: 6px; row-gap: 6px; align-items: end;
}
.hcol { display: flex; flex-direction: column; align-items: stretch; justify-content: flex-end; height: 100%; }
.hcount { text-align: center; font-size: .8rem; font-weight: 650; font-variant-numeric: tabular-nums; margin-bottom: 3px; }
.hbar { display: block; background: var(--bar); border-radius: 6px 6px 2px 2px; min-height: 2px; transition: height .4s ease; }
.hcol.peak .hbar { background: var(--accent); }
.hlabel {
  align-self: start; text-align: center; font-size: .72rem; line-height: 1.2;
  color: var(--muted); overflow-wrap: anywhere; hyphens: auto;
}
.stats { display: flex; gap: 18px; margin: 14px 0 0; font-size: .9rem; color: var(--muted); }
.stats strong { color: var(--text); }

.verdict { font-size: 1.02rem; margin: 0 0 10px; }
.trophy { color: var(--accent); margin-right: 4px; }
.rounds { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 8px; font-size: .88rem; }
.rounds li { padding: 8px 12px; border-radius: 9px; background: var(--surface-2); }
.rn { display: block; font-weight: 700; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.rc { font-variant-numeric: tabular-nums; }
.rc .out { color: var(--bad); text-decoration: line-through; }
.rc .win { color: var(--accent); font-weight: 700; }
.rx { display: block; color: var(--muted); font-size: .8rem; }
.subhead { font-size: .85rem; color: var(--muted); margin: 18px 0 10px; }

.writeins { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.writeins summary { cursor: pointer; font-size: .88rem; font-weight: 600; color: var(--muted); }
.writeins ul { margin: 8px 0 0; padding-left: 1.2em; font-size: .92rem; }
.writeins li { overflow-wrap: anywhere; }

.mine dl { margin: 0; }
.mine dt { color: var(--muted); font-size: .85rem; margin-top: 10px; overflow-wrap: anywhere; }
.mine dt:first-child { margin-top: 0; }
.mine dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }

/* ------------------------------------------------------------------- share */

.sharerow { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.urlbox { font-family: var(--mono); font-size: .85rem !important; flex: 1; }
.share.compact { margin-top: 24px; }
.share.compact h2 { margin-top: 0; }
.qr summary { cursor: pointer; font-size: .88rem; color: var(--muted); margin: 6px 0; }
.qrimg { display: block; margin: 8px auto; background: #fff; padding: 10px; border-radius: 10px; width: 220px; height: auto; max-width: 100%; }
.keepit { margin-top: 18px; text-align: left; }
.keepit .mini { margin-top: 0; }
.created { text-align: center; }
.created .sharerow { text-align: left; }

/* ------------------------------------------------------------------ manage */

.toolbar .status { margin-bottom: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.inline { display: inline; margin: 0; }
.edit { margin-top: 28px; }
.edit > h2 { font-size: 1.25rem; margin: 0 2px 4px; }
.edit > .hint { margin: 0 2px 12px; }
.more h2 { margin-bottom: 8px; }
.action-row {
  display: flex; gap: 12px; justify-content: space-between; align-items: flex-start;
  padding: 14px 0; border-top: 1px solid var(--line); margin: 0;
}
.action-row .hint { margin-bottom: 8px; }
.action-row .check { margin: 0; font-size: .88rem; }

/* ------------------------------------------------------------------ recent */

.recent { margin-top: 32px; }
.recent h2 { margin: 0 2px 10px; }
.recent-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.recent-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px;
}
.recent-list a { font-weight: 600; text-decoration: none; overflow-wrap: anywhere; min-width: 0; }
.recent-list .tag { font-size: .75rem; color: var(--muted); white-space: nowrap; }
.recent-list .forget { font-size: .75rem; }

/* --------------------------------------------------------------------- api */

.doc {
  font-family: var(--mono); font-size: .78rem; line-height: 1.5;
  white-space: pre-wrap; overflow-wrap: anywhere;
  background: var(--surface-2); padding: 14px; border-radius: 9px; margin: 0;
}

@media (min-width: 640px) {
  h1 { font-size: 1.9rem; }
  .btn-lg { width: auto; min-width: 220px; }
  .submitrow { text-align: center; }
}

/* -------------------------------------------------------------- compare by */

.compare { padding: 14px 16px; }
.compare-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-bottom: 8px; }
.compare-row > label[for] { margin: 0; }
.compare-row select { width: auto; flex: 1 1 200px; }
.seg-toggle { font-size: .88rem; }
.seg-toggle label { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; margin: 0; cursor: pointer; }
.seg-toggle input { accent-color: var(--accent); margin: 0; }
.compare .hint { margin: 4px 0 0; }
.js [data-compare-submit] { display: none; }
.bytag { font-size: .78rem; font-weight: 600; color: var(--accent); margin: -2px 0 8px; }
.smalltag { font-size: .7rem; font-weight: 600; color: var(--warn); background: var(--warn-bg); border-radius: 99px; padding: 1px 7px; margin-left: 4px; white-space: nowrap; }

/* The ordinal ramp for scale points, --t from 0 (first point) to 1 (last).
   One hue, light to dark; validated with the dataviz validator (--ordinal) at
   2-7 points in both modes, which is why STACK_MAX_POINTS is 7. Dark mode flips
   the anchor so the step nearest the surface still clears 2:1. */
.seg, .sw { background: oklch(calc(0.74 - 0.44 * var(--t)) 0.1 185); }
@media (prefers-color-scheme: dark) {
  .seg, .sw { background: oklch(calc(0.46 + 0.45 * var(--t)) 0.1 185); }
}

.legend { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .78rem; color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 12px; height: 12px; border-radius: 3px; flex: none; }

.stackrows, .multiples { display: grid; gap: 14px; }
/* Wraps rather than squeezing: a long median ("Strongly disagree / Disagree")
   must push itself onto its own line, never crush the group name. */
.srhead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 10px; margin-bottom: 5px; font-size: .9rem; }
.srlabel { font-weight: 600; overflow-wrap: anywhere; flex: 1 1 auto; }
.srmeta { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; margin-left: auto; text-align: right; }
.srmeta strong { color: var(--text); }
/* 2px surface gap between segments; rounded data ends only. */
.stack { display: flex; gap: 2px; height: 20px; }
.seg { display: block; flex-grow: 0; flex-shrink: 1; min-width: 3px; }
.seg:first-child { border-radius: 4px 0 0 4px; }
.seg:last-child { border-radius: 0 4px 4px 0; }
.seg:only-child { border-radius: 4px; }

.histo-sm { grid-template-rows: 64px auto; }
.histo-sm .hcount { font-size: .7rem; }
.histo-sm .hlabel { font-size: .66rem; }
.multiple + .multiple { border-top: 1px solid var(--line); padding-top: 12px; }

.cmp { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.cmplabel { display: block; font-weight: 650; margin-bottom: 6px; overflow-wrap: anywhere; }
.bars-sm { gap: 7px; padding-left: 10px; border-left: 2px solid var(--line); }
.bars-sm .blabel { font-size: .85rem; font-weight: 500; }
.bars-sm .bnum { font-size: .85rem; }
.bars-sm .btrack { height: 7px; }

.grouplines { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.grouplines .gl { display: block; font-size: .88rem; color: var(--muted); overflow-wrap: anywhere; }
.grouplines .gl strong { color: var(--text); }
