@font-face {
  font-family: 'Bricolage';
  src: url('/static/fonts/bricolage-latin.woff2') format('woff2');
  font-weight: 200 800;
  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: 'Bricolage';
  src: url('/static/fonts/bricolage-latin-ext.woff2') format('woff2');
  font-weight: 200 800;
  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;
}

:root {
  --bg: #ecebf4;
  --surface: #ffffff;
  --ink: #1a1c2e;
  --muted: #5f6280;
  --line: #d6d4e4;
  --a: #2d5bff;
  --a-ink: #ffffff;
  --b: #ffb400;
  --b-ink: #1a1c2e;
  --danger: #c8322f;
  --focus: #2d5bff;
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --font: 'Bricolage', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14151f;
    --surface: #1e2030;
    --ink: #f1f0f8;
    --muted: #a3a5bf;
    --line: #34374d;
    --a: #5b7dff;
    --b: #ffc233;
    --danger: #ff6b66;
    --focus: #8ea4ff;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.5;
  font-variation-settings: 'opsz' 14;
  -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---- Frame --------------------------------------------------------------- */

.masthead {
  max-width: 34rem;
  margin: 0 auto;
  padding: max(1rem, env(safe-area-inset-top)) 1rem 0.25rem;
}

.wordmark {
  display: inline-flex;
  font-weight: 800;
  font-size: 1.375rem;
  letter-spacing: -0.03em;
  text-decoration: none;
  color: var(--ink);
  font-variation-settings: 'opsz' 96;
}
.wordmark .wm-a { color: var(--a); }
.wordmark .wm-b {
  background: var(--b);
  color: var(--b-ink);
  border-radius: 6px;
  padding: 0 0.22em;
  margin-left: 0.08em;
}

main {
  max-width: 34rem;
  margin: 0 auto;
  padding: 0.75rem 1rem calc(2.5rem + env(safe-area-inset-bottom));
}

h1, h2 { margin: 0; font-variation-settings: 'opsz' 96; letter-spacing: -0.025em; }

/* ---- The pair: the heart of the product --------------------------------- */

.pair {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.or {
  position: absolute;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  box-shadow: 0 0 0 5px var(--bg);
  pointer-events: none;
}

/* ---- Create -------------------------------------------------------------- */

.create { display: grid; gap: 1.25rem; }

.lede {
  font-size: clamp(2rem, 9vw, 2.75rem);
  line-height: 1.02;
  font-weight: 800;
  letter-spacing: -0.04em;
  max-width: 13ch;
  margin-top: 0.5rem;
}

.field { position: relative; display: grid; gap: 0.375rem; }

.field-label { font-weight: 600; font-size: 0.95rem; color: var(--muted); }

textarea {
  width: 100%;
  resize: none;
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 0.85rem 1rem 1.6rem;
  font-size: 1.25rem;
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: -0.01em;
}
textarea::placeholder { color: var(--muted); opacity: 0.6; }
textarea:focus { border-color: var(--a); outline: none; }
textarea:focus-visible { outline: none; }

.counter {
  position: absolute;
  right: 0.85rem;
  bottom: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.counter.near { color: var(--danger); }

.slot {
  position: relative;
  display: block;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 2px dashed var(--line);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s;
}
.slot[data-slot='0'] { color: var(--a); }
.slot[data-slot='1'] { color: #b37e00; }
@media (prefers-color-scheme: dark) { .slot[data-slot='1'] { color: var(--b); } }
.slot:hover { border-color: currentColor; }
.slot:focus-within { outline: 3px solid var(--focus); outline-offset: 3px; }
.slot.filled { border-style: solid; border-color: transparent; }
.slot.invalid { border-color: var(--danger); }

.slot-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.35rem;
  font-weight: 700;
  font-size: 0.95rem;
}
.slot.filled .slot-empty { display: none; }

.slot-preview { width: 100%; height: 100%; object-fit: cover; }

.form-error {
  margin: 0;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
  font-weight: 600;
  font-size: 0.95rem;
}
.form-error[hidden] { display: none; }

.fineprint { margin: 0; font-size: 0.85rem; color: var(--muted); max-width: 40ch; }

.recent { margin-top: 2.5rem; }
.recent h2 { font-size: 1.05rem; margin-bottom: 0.5rem; }
.recent ul { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.recent li { border-bottom: 1px solid var(--line); }
.recent a {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}
.recent a span:last-child { color: var(--muted); font-weight: 400; font-size: 0.9rem; white-space: nowrap; }

/* ---- Buttons ------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3.25rem;
  padding: 0 1.4rem;
  border-radius: 999px;
  border: 2px solid transparent;
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.1s, background-color 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.55; cursor: progress; }
.btn-primary { background: var(--ink); color: var(--bg); }
.btn-secondary { background: transparent; border-color: var(--ink); color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-outline { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-small { min-height: 2.5rem; font-size: 0.95rem; padding: 0 1rem; }

.link {
  background: none;
  border: 0;
  padding: 0.25rem 0;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  font-size: 0.9rem;
}

/* ---- Vote ---------------------------------------------------------------- */

.question {
  font-size: clamp(1.75rem, 7.5vw, 2.4rem);
  line-height: 1.08;
  font-weight: 800;
  letter-spacing: -0.035em;
  overflow-wrap: anywhere;
  margin: 0.5rem 0 0.4rem;
}

.hint { margin: 0 0 1rem; color: var(--muted); font-weight: 500; }
.hint.is-hidden { visibility: hidden; }

.choice {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  cursor: pointer;
  aspect-ratio: 3 / 4;
  transition: transform 0.15s ease, filter 0.4s ease;
  -webkit-tap-highlight-color: transparent;
}
.choice:not([disabled]):hover { transform: translateY(-2px); }
.choice:not([disabled]):active { transform: scale(0.97); }
.choice[disabled] { cursor: default; }
.choice img { width: 100%; height: 100%; object-fit: cover; }

/* Results: a colour fill rises from the bottom of each photo. */
.result {
  position: absolute;
  inset: 0;
  display: none;
  pointer-events: none;
}
.voted .result, .closed .result { display: block; }

.fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0;
  opacity: 0.75;
  transition: height 0.9s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.choice[data-choice='0'] .fill { background: var(--a); }
.choice[data-choice='1'] .fill { background: var(--b); }

.pct {
  position: absolute;
  left: 0.75rem;
  bottom: 0.6rem;
  font-weight: 800;
  font-size: clamp(1.75rem, 8.5vw, 2.5rem);
  line-height: 1;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
  font-variation-settings: 'opsz' 96;
  color: #fff;
  text-shadow: 0 1px 12px rgb(0 0 0 / 0.35);
}
.choice[data-choice='1'] .pct { color: var(--b-ink); text-shadow: 0 1px 12px rgb(255 255 255 / 0.35); }

.voted .choice.lost img, .closed .choice.lost img { filter: saturate(0.7); }

.mine {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  display: none;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.8rem;
}
.choice.picked .mine { display: block; }

.meta { margin: 0.9rem 0 0; color: var(--muted); font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.page-vote .meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 0.75rem;
  margin-top: 1rem;
}
.page-vote .meta .total {
  color: var(--ink);
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.after { margin-top: 2rem; display: grid; gap: 1.5rem; justify-items: start; }

.report p { margin: 0.25rem 0 0.6rem; font-size: 0.9rem; color: var(--muted); max-width: 40ch; }
.report [hidden] { display: none; }

/* Larger screens: centre the voting page and give the photos more room. */
@media (min-width: 48rem) {
  .page-vote .masthead,
  .page-vote main { max-width: 44rem; }
  .page-vote .masthead { text-align: center; }
  .page-vote .poll,
  .page-vote .after { text-align: center; }
  .page-vote .question { max-width: 22ch; margin-inline: auto; }
  .page-vote .meta { justify-content: center; }
  .page-vote .after { justify-items: center; }
  .page-vote .report p { margin-inline: auto; }
  .page-vote .or { width: 3.25rem; height: 3.25rem; font-size: 1.05rem; }
}

@media (prefers-reduced-motion: reduce) {
  .fill, .choice, .btn { transition: none; }
}

/* ---- Manage -------------------------------------------------------------- */

.manage { display: grid; gap: 1.5rem; }
.manage .question { margin: 0; font-size: clamp(1.5rem, 6.5vw, 2.1rem); }

.status {
  margin: 0;
  justify-self: start;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: var(--surface);
  font-weight: 700;
  font-size: 0.9rem;
}
.status::before {
  content: '';
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  margin-right: 0.45rem;
  border-radius: 50%;
  background: #1fa863;
  vertical-align: 0.05em;
}
.status.ended::before { background: var(--muted); }
.status.removed::before { background: var(--danger); }

.share {
  display: grid;
  gap: 0.75rem;
  padding: 1.25rem 1rem 1rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 2px solid var(--a);
}
.share-url {
  width: 100%;
  min-height: 3rem;
  padding: 0 0.9rem;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-weight: 600;
  font-size: 1rem;
  text-overflow: ellipsis;
}
.share-title {
  font-size: 1.3rem;
  line-height: 1.2;
  font-weight: 800;
}
.share-actions { display: grid; gap: 0.5rem; }
.share-actions .btn { width: 100%; }
.share-actions .btn-primary { min-height: 3.5rem; font-size: 1.1rem; }
@media (min-width: 30rem) {
  .share-actions { grid-template-columns: 3fr 2fr; }
}
.share-feedback { margin: 0; min-height: 1.4em; font-size: 0.9rem; color: var(--muted); }
.share-feedback:empty { min-height: 0; }

.manage-total { margin: 0 0 -0.75rem; color: var(--muted); font-weight: 600; }
.manage-total b {
  color: var(--ink);
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  margin-right: 0.15rem;
}

.tally { display: grid; gap: 0.75rem; }
.tally-row {
  display: grid;
  grid-template-columns: 4rem 1fr auto;
  align-items: center;
  gap: 0.85rem;
}
.tally-img {
  width: 4rem;
  height: 4rem;
  object-fit: cover;
  border-radius: var(--radius-md);
  background: var(--surface);
}
.tally-bar { height: 0.85rem; border-radius: 999px; background: var(--surface); overflow: hidden; }
.tally-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.tally-row[data-slot='0'] .tally-fill { background: var(--a); }
.tally-row[data-slot='1'] .tally-fill { background: var(--b); }
.tally-num { display: grid; justify-items: end; min-width: 4.5rem; line-height: 1.15; }
.tally-pct { font-size: 1.4rem; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.tally-count { font-size: 0.8rem; color: var(--muted); }
.removed-poll .tally-img { visibility: hidden; }

.keep {
  padding: 1rem;
  border-radius: var(--radius-lg);
  border: 2px solid var(--line);
}
.keep h2 { font-size: 1.05rem; margin-bottom: 0.25rem; }
.keep p { margin: 0 0 0.5rem; color: var(--muted); font-size: 0.95rem; }

.danger-zone { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.danger-zone .btn { flex: 1 1 9rem; }
.danger-zone [hidden] { display: none; }

/* ---- Message pages ------------------------------------------------------- */

.message { display: grid; gap: 0.75rem; justify-items: start; padding-top: 2rem; }
.message h1 { font-size: 2rem; font-weight: 800; }
.message p { margin: 0 0 0.75rem; color: var(--muted); max-width: 40ch; }

/* ---- Footer and policy pages --------------------------------------------- */

.site-footer {
  max-width: 34rem;
  margin: 0 auto;
  padding: 0 1rem calc(1.5rem + env(safe-area-inset-bottom));
  display: flex;
  gap: 1.25rem;
  font-size: 0.85rem;
}
.site-footer a { color: var(--muted); text-underline-offset: 3px; }
.fineprint a { color: inherit; text-underline-offset: 3px; }
@media (min-width: 48rem) {
  .page-vote .site-footer { max-width: 44rem; justify-content: center; }
}
.page-admin .site-footer { max-width: 60rem; }

.policy { max-width: 38rem; }
.policy h1 { font-size: clamp(1.9rem, 8vw, 2.4rem); font-weight: 800; letter-spacing: -0.035em; margin: 0.5rem 0 1rem; }
.policy h2 { font-size: 1.15rem; font-weight: 800; margin: 1.6rem 0 0.4rem; }
.policy p, .policy li { color: var(--ink); line-height: 1.55; }
.policy p { margin: 0 0 0.75rem; }
.policy ul { margin: 0 0 0.75rem; padding-left: 1.2rem; }
.policy li { margin-bottom: 0.35rem; }
.policy a { color: var(--a); text-underline-offset: 3px; overflow-wrap: anywhere; }
.policy code { font-size: 0.9em; }
.policy-updated { margin-top: 2rem !important; color: var(--muted) !important; font-size: 0.85rem; }

/* ---- Admin (operator-only page) ------------------------------------------ */

.page-admin main, .page-admin .masthead { max-width: 60rem; }
.admin { display: grid; gap: 1.25rem; }
.admin h1 { font-size: 1.75rem; font-weight: 800; }
.admin h2 { font-size: 1.3rem; font-weight: 800; margin-top: 1rem; }
.admin-notice { margin: 0; padding: 0.6rem 0.9rem; border-radius: var(--radius-sm); background: var(--surface); font-weight: 600; }
.admin-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.admin-poll {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem;
  padding: 0.85rem;
  border-radius: var(--radius-md);
  background: var(--surface);
}
.admin-thumbs { display: flex; gap: 0.35rem; }
.admin-thumbs img { width: 4.5rem; height: 6rem; object-fit: cover; border-radius: var(--radius-sm); background: var(--bg); }
.admin-q { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.admin-meta { margin: 0.2rem 0 0.6rem; color: var(--muted); font-size: 0.9rem; }
.admin-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.admin-actions form { margin: 0; }
.admin-empty, .admin-note { margin: 0; color: var(--muted); }
.admin-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 0.5rem; margin: 0; }
.admin-kpis div { padding: 0.75rem; border-radius: var(--radius-md); background: var(--surface); }
.admin-kpis dt { color: var(--muted); font-size: 0.85rem; }
.admin-kpis dd { margin: 0.15rem 0 0; font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.admin-table-wrap { overflow-x: auto; }
.admin-table { border-collapse: collapse; width: 100%; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.admin-table th, .admin-table td { padding: 0.4rem 0.6rem; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.admin-table th:first-child { text-align: left; }
.admin-table thead th { color: var(--muted); font-weight: 600; }
@media (max-width: 30rem) { .admin-poll { grid-template-columns: 1fr; } }
