:root {
  --bg: #f6efe4;
  --card: #fffdf9;
  --ink: #2b2118;
  --muted: #7a6a5a;
  --line: #e7dccb;
  --brand: #b5652b;       /* sparrow chestnut */
  --brand-ink: #fff;
  --brand-soft: #f6e2cf;
  --ok: #3f7d4e;
  --ok-soft: #e1f0e3;
  --err: #b23a3a;
  --err-soft: #f8e1df;
  --warn-soft: #fbefc8;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(60 40 20 / 6%), 0 2px 8px rgb(60 40 20 / 5%);
  color-scheme: light;
}

* { 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, sans-serif;
}
main { max-width: 640px; margin: 0 auto; padding: 8px 16px 64px; }
a { color: var(--brand); }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0.2em 0 0.4em; text-wrap: balance; }
h2 { font-size: 1.05rem; margin: 0 0 0.6em; }
small, .small { font-size: 0.85rem; }
.muted { color: var(--muted); }

.top {
  display: flex; justify-content: space-between; align-items: center;
  max-width: 640px; margin: 0 auto; padding: 14px 16px 6px;
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--ink); text-decoration: none; }
.me {
  color: var(--muted); text-decoration: none; font-size: 0.9rem;
  max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.card {
  display: block; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin: 12px 0; box-shadow: var(--shadow);
  color: inherit; text-decoration: none;
}
.card.narrow { max-width: 440px; margin-inline: auto; }
.card.empty { text-align: center; }
details.card > summary { cursor: pointer; font-weight: 600; }

.row { display: flex; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack.tight { gap: 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.small { min-height: 38px; padding: 0 12px; font-size: 0.9rem; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); cursor: pointer; text-decoration: underline; }
.link.danger { color: var(--err); }

label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
label small, legend small { font-weight: 400; }
.timeline-fields:not(:has([name=results_mode][value=scheduled]:checked)) .results-at { display: none; }
label.inline { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px 14px; margin: 0; display: flex; flex-direction: column; gap: 8px; }
legend { font-weight: 600; padding: 0 4px; }
input:not([type=checkbox]):not([type=radio]), textarea {
  font: inherit; font-weight: 400; color: inherit; width: 100%;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; accent-color: var(--brand); }
input:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 1px;
}

.flash { padding: 10px 14px; border-radius: 10px; margin: 8px 0; }
.flash.err { background: var(--err-soft); color: var(--err); }
.flash.ok { background: var(--ok-soft); color: var(--ok); }

.eyebrow { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0; }
.eyebrow a { color: inherit; }
.pill {
  display: inline-block; font-size: 0.8rem; font-weight: 600; padding: 2px 10px; border-radius: 99px;
  background: var(--brand-soft); color: var(--brand);
}
.pill.status-closed { background: #ece6dd; color: var(--muted); }
.pill.status-assigning { background: var(--ok-soft); color: var(--ok); }
.pill.status-paused, .pill.status-scheduled { background: var(--warn-soft); color: #7a5a00; }

/* home */
.list { list-style: none; padding: 0; margin: 0; }
.poll-card { display: flex; flex-direction: column; gap: 4px; }
.poll-card strong { font-size: 1.1rem; }
.poll-card .meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: 0.9rem; }
.poll-card.status-closed { opacity: 0.75; box-shadow: none; }
.closed-list > summary { cursor: pointer; color: var(--muted); margin-top: 20px; }
.type-card { display: grid; grid-template-columns: 44px 1fr; gap: 2px 12px; }
.type-card .type-ico { grid-row: span 2; font-size: 1.8rem; line-height: 1; }

/* poll */
.poll-head { padding: 8px 0 4px; }
.desc { white-space: pre-wrap; margin: 0 0 8px; }
.stepper { display: flex; list-style: none; padding: 0; margin: 12px 0 0; gap: 4px; font-size: 0.78rem; }
.stepper li { flex: 1; text-align: center; padding: 6px 2px; border-radius: 8px; background: #ece6dd; color: var(--muted); }
.stepper li.done { background: var(--brand-soft); color: var(--brand); }
.stepper li.current { background: var(--brand); color: var(--brand-ink); font-weight: 700; }
.timeline {
  list-style: none; padding: 10px 12px; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 4px 16px;
  background: var(--card); border: 1px dashed var(--line); border-radius: 10px; font-size: 0.9rem;
}
.timeline li.done { text-decoration: line-through; color: var(--muted); }
.status-line { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; margin: 12px 0 4px; font-size: 0.92rem; }
.hint { flex-basis: 100%; margin: 2px 0 0; font-weight: 600; }
.results-note { background: var(--warn-soft); border-radius: 10px; padding: 10px 14px; margin: 8px 0; font-size: 0.92rem; }

.options, .claims { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 10px; }
.option-btn {
  position: relative; display: flex; align-items: center; gap: 10px; width: 100%; min-height: 54px;
  padding: 10px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--card);
  font: inherit; color: inherit; text-align: left; cursor: pointer; overflow: hidden;
}
.option-btn:disabled { cursor: default; }
.option-btn:not(:disabled):hover { border-color: var(--brand); }
.option-btn .bar {
  position: absolute; inset: 0 auto 0 0; background: var(--brand-soft); z-index: 0;
  transition: width 0.4s ease;
}
.option-btn > :not(.bar) { position: relative; z-index: 1; }
.option-btn .check {
  flex: none; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line);
  display: grid; place-items: center; font-size: 0.85rem; font-weight: 700; background: #fff;
}
.option-btn .label { flex: 1; font-weight: 600; overflow-wrap: anywhere; }
.option-btn .count { font-weight: 700; font-variant-numeric: tabular-nums; }
.option.mine .option-btn { border-color: var(--brand); }
.option.mine .check { background: var(--brand); border-color: var(--brand); color: #fff; }
.option.winner .option-btn { border-color: var(--ok); }
.option-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 0.82rem; padding: 4px 6px 0; }
.voters { min-width: 0; }
.voters > summary { cursor: pointer; list-style: none; }
.voters > summary::-webkit-details-marker { display: none; }
.voters .more { color: var(--brand); font-weight: 600; text-decoration: underline; }
.voters[open] > summary { display: none; }

.claim {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--card); border: 2px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
.claim.mine { border-color: var(--ok); background: var(--ok-soft); }
.claim.full:not(.mine) { opacity: 0.7; }
.claim-main { min-width: 0; overflow-wrap: anywhere; }
.claim .who { font-size: 0.88rem; color: var(--muted); }
.claim .free { color: var(--brand); font-weight: 600; }

.add-option input { flex: 1; }
.share h2, .manage h2 { margin-bottom: 10px; }
.manage { border-style: dashed; box-shadow: none; }
.manage .btn { width: 100%; }

.final-table { width: 100%; border-collapse: collapse; }
.final-table th { text-align: left; font-size: 0.8rem; color: var(--muted); font-weight: 600; padding: 4px; }
.final-table td { padding: 8px 4px; border-top: 1px solid var(--line); }
.final-table label { font-weight: 600; }
.final-table .qty { width: 64px !important; }

@media (min-width: 560px) {
  h1 { font-size: 1.9rem; }
  .manage .btn { width: auto; }
}
