:root {
  --bg: #f3f5f1;
  --card: #ffffff;
  --ink: #1b2a20;
  --muted: #58675d;
  --line: #d9e0d8;
  --brand: #2c6b45;
  --brand-dark: #1f4f32;
  --brand-ink: #ffffff;
  --brand-soft: #e4f0e8;
  --ok: #1d7a3b;
  --ok-soft: #e1f3e6;
  --warn: #9a5b06;
  --warn-soft: #fdf1d9;
  --bad: #b3261e;
  --bad-soft: #fbe5e3;
  --info: #1a56b0;
  --info-soft: #e3edfb;
  --shadow: 0 1px 2px rgba(20, 40, 25, .08), 0 4px 14px rgba(20, 40, 25, .06);
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121a15;
    --card: #1b261f;
    --ink: #e8f0ea;
    --muted: #a3b3a8;
    --line: #2f4035;
    --brand: #55b27a;
    --brand-dark: #6fc592;
    --brand-ink: #0c1a11;
    --brand-soft: #1e3a2a;
    --ok: #62c283;
    --ok-soft: #173424;
    --warn: #f0b457;
    --warn-soft: #3a2c10;
    --bad: #ff8a80;
    --bad-soft: #3d1b19;
    --info: #8db6f5;
    --info-soft: #172a47;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75em; }
a { color: var(--info); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.prose { white-space: pre-wrap; overflow-wrap: anywhere; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: .75rem; }
.grow { flex: 1 1 auto; }

/* Buttons & forms */
button, .btn {
  font: inherit; font-weight: 600; min-height: 44px; padding: .55rem 1.1rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; text-decoration: none;
}
button:hover:not(:disabled), .btn:hover { border-color: var(--brand); }
button:disabled { opacity: .5; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px;
}
.btn-primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-danger { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn-ghost { background: transparent; }
.btn-sm { min-height: 34px; padding: .25rem .7rem; font-size: .875rem; border-radius: 8px; }
.btn-block { width: 100%; }
input[type=text], input[type=search], input[type=password], input[type=date], input[type=number], select, textarea {
  font: inherit; width: 100%; min-height: 46px; padding: .55rem .8rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
}
textarea { min-height: 110px; resize: vertical; }
label { display: block; font-weight: 600; margin-bottom: .25rem; }
.field { margin-bottom: .9rem; }
.field .hint { font-weight: 400; color: var(--muted); font-size: .875rem; }

/* Cards, chips, banners */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; }
.chip { display: inline-block; padding: .1rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 700; letter-spacing: .02em; background: var(--brand-soft); color: var(--brand-dark); white-space: nowrap; }
.chip.open { background: var(--ok-soft); color: var(--ok); }
.chip.closed { background: var(--line); color: var(--muted); }
.chip.pending { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.info { background: var(--info-soft); color: var(--info); }
.banner { border-radius: 12px; padding: .8rem 1rem; border: 1px solid var(--line); background: var(--card); }
.banner.info { background: var(--info-soft); border-color: transparent; }
.banner.warn { background: var(--warn-soft); border-color: transparent; }
.banner.ok { background: var(--ok-soft); border-color: transparent; }
.banner.bad { background: var(--bad-soft); border-color: transparent; }
.banner .row { margin-top: .5rem; }
.toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); z-index: 100; background: var(--ink); color: var(--bg); padding: .7rem 1.1rem; border-radius: 999px; max-width: 92vw; box-shadow: var(--shadow); font-weight: 600; }
.toast.bad { background: var(--bad); color: #fff; }

/* Modal */
.overlay { position: fixed; inset: 0; background: rgba(8, 20, 12, .62); z-index: 50; display: flex; align-items: flex-end; justify-content: center; padding: 0; overflow-y: auto; }
.modal { background: var(--card); width: 100%; max-width: 520px; border-radius: 18px 18px 0 0; padding: 1.3rem 1.2rem calc(1.2rem + env(safe-area-inset-bottom)); box-shadow: var(--shadow); max-height: 94vh; overflow-y: auto; }
.modal h2 { margin-bottom: .5rem; }
.modal .actions { display: flex; flex-direction: column; gap: .6rem; margin-top: 1rem; }
@media (min-width: 600px) { .overlay { align-items: center; padding: 1rem; } .modal { border-radius: 18px; } }

/* Autocomplete */
.ac { position: relative; }
.ac ul { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); list-style: none; margin: 0; padding: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); max-height: 320px; overflow-y: auto; }
.ac li { padding: .75rem .8rem; border-radius: 8px; cursor: pointer; font-size: 1.05rem; }
.ac li.active, .ac li:hover { background: var(--brand-soft); }

/* ===== Member page ===== */
.app { max-width: 720px; margin: 0 auto; padding: 0 1rem 4rem; }
.topbar { background: var(--brand); color: var(--brand-ink); padding: .8rem 1rem; position: sticky; top: 0; z-index: 10; }
.topbar .inner { max-width: 720px; margin: 0 auto; display: flex; align-items: center; gap: .75rem; justify-content: space-between; }
.topbar .title { font-weight: 800; letter-spacing: .01em; line-height: 1.2; }
.topbar .sub { font-size: .8rem; opacity: .9; }
.conn { font-size: .75rem; font-weight: 700; display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; }
.conn::before { content: ""; width: .6rem; height: .6rem; border-radius: 50%; background: #7ee2a0; display: inline-block; }
.conn.off::before { background: #ffb4a8; }
.whoami { margin: 1rem 0; display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.whoami .addr { font-weight: 800; font-size: 1.1rem; }
.login { margin-top: 1.5rem; }
.login .big { font-size: 1.15rem; min-height: 54px; }
.item { margin-top: 1rem; }
.item header { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; margin-bottom: .5rem; }
.item header h2 { margin: 0; }
.desc-more { margin-top: .25rem; }
details.desc summary { cursor: pointer; font-weight: 600; color: var(--info); }
.files { list-style: none; margin: .5rem 0 0; padding: 0; }
.files li { margin: .25rem 0; }
.choices { display: grid; gap: .6rem; margin: .75rem 0; }
.choices.two { grid-template-columns: 1fr 1fr; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.choice .face { display: flex; align-items: center; gap: .75rem; min-height: 56px; padding: .6rem .9rem; border: 2px solid var(--line); border-radius: 12px; background: var(--card); font-weight: 700; font-size: 1.1rem; }
.choices.two .face { justify-content: center; font-size: 1.25rem; }
.choice input:checked + .face { border-color: var(--brand); background: var(--brand-soft); }
.choice input:focus-visible + .face { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }
.choice input:disabled + .face { opacity: .55; }
.choice .box { width: 1.4rem; height: 1.4rem; border: 2px solid var(--muted); border-radius: 6px; flex: none; display: inline-flex; align-items: center; justify-content: center; }
.choice input:checked + .face .box { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.choice input:checked + .face .box::after { content: "\2713"; font-size: .95rem; }
.cand-bio { font-weight: 400; font-size: .875rem; color: var(--muted); display: block; }
.voted { display: flex; gap: .5rem; align-items: flex-start; background: var(--ok-soft); color: var(--ok); border-radius: 12px; padding: .7rem .9rem; font-weight: 700; margin: .5rem 0; }
.voted .what { color: var(--ink); font-weight: 600; }
.ballot-for { border-top: 1px dashed var(--line); padding-top: .75rem; margin-top: .75rem; }
.ballot-for .who { font-weight: 700; margin-bottom: .25rem; }
.counter { font-size: .9rem; color: var(--muted); font-weight: 600; }
.countdown { font-variant-numeric: tabular-nums; font-weight: 800; }
.page-overlay { position: fixed; inset: 0; z-index: 40; background: var(--bg); overflow-y: auto; }
.page-overlay .app { padding-top: 1rem; }
.steps { counter-reset: step; }
.steps > section { margin-top: 1rem; }
.steps h2::before { counter-increment: step; content: counter(step) ". "; color: var(--brand); }
.thumb { max-width: 100%; max-height: 220px; border-radius: 10px; border: 1px solid var(--line); margin-top: .5rem; display: block; }
.footer-note { margin-top: 2rem; text-align: center; font-size: .8rem; color: var(--muted); }
@media (max-width: 420px) { .choices.two .face { font-size: 1.1rem; } }
