:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f5f5f5;
  --ink: #141414;
  --muted: #757575;
  --line: #e1e1e1;
  --accent: #171717;
  --accent-ink: #ffffff;
  --gold: #555555;
  --danger: #b42318;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04);
  --radius: 6px;
  --serif: "EB Garamond", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-padding-top: 16px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1024px; margin: 0 auto; padding: 0 24px; }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; margin: 0; }
h1, h2, h3, .stat-value, .pack-credits, .seat-name, .member-name { font-variant-numeric: lining-nums; }

button, input, select, textarea { font: inherit; color: inherit; }

.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13.5px; margin: 8px 0 0; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.18em; font-size: 11px; color: var(--muted); margin: 0 0 12px; font-weight: 500; }

/* ---------- header ---------- */

.masthead { padding: 72px 0 48px; text-align: left; border-bottom: 1px solid var(--line); }
.masthead h1 { font-size: clamp(48px, 7vw, 76px); letter-spacing: -0.02em; font-weight: 500; }
.masthead .lede { max-width: 640px; margin: 16px auto 0; color: var(--muted); font-size: 16px; }
.masthead .lede { margin-left: 0; }

/* ---------- steps ---------- */

.step {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  margin: 24px 0;
}
.step h2 { font-size: 26px; display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.num {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 0;
  border: 1px solid var(--line); color: var(--muted);
  font: 600 15px var(--sans);
}

.btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius);
  padding: 9px 18px; cursor: pointer; font-weight: 500; font-size: 14px;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn.ghost { background: transparent; padding: 7px 14px; font-size: 13px; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* modes */
.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.mode {
  display: flex; gap: 12px; align-items: flex-start;
  border: 1.5px solid var(--line); border-radius: var(--radius); padding: 14px 16px; cursor: pointer;
}
.mode.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); }
.mode.locked { cursor: not-allowed; opacity: 0.6; border-style: dashed; }
.mode input { margin-top: 4px; accent-color: var(--accent); }
.mode-text { display: grid; gap: 2px; }
.mode-text strong { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mode-desc { color: var(--muted); font-size: 13.5px; }
.badge {
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted);
}

/* seats */
.seats { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
.seat {
  position: relative; min-height: 104px; border-radius: var(--radius);
  display: grid; place-items: center; align-content: center; gap: 8px; padding: 10px 6px; text-align: center;
}
.seat.empty { border: 1.5px dashed var(--line); color: var(--muted); font-size: 12px; }
.seat.empty.required { border-color: color-mix(in srgb, var(--gold) 55%, var(--line)); }
.seat.filled { background: var(--surface-2); border: 1px solid var(--line); }
.seat-name { font-family: var(--serif); font-weight: 600; font-size: 16px; line-height: 1.1; }
.seat-remove {
  position: absolute; top: 4px; right: 6px; border: 0; background: none; cursor: pointer;
  color: var(--muted); font-size: 18px; line-height: 1; padding: 2px 4px;
}
.seat-remove:hover:not(:disabled) { color: var(--danger); }
.seat-remove:disabled { visibility: hidden; }

/* avatar */
.avatar {
  --hue: 30;
  flex: none; display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%;
  background: hsl(var(--hue) 45% 88%); color: hsl(var(--hue) 45% 26%);
  font: 600 14px var(--sans); letter-spacing: 0.02em;
  border: 1px solid hsl(var(--hue) 35% 76%);
}
.avatar.small { width: 26px; height: 26px; font-size: 10.5px; }
/* roster */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 20px 0 14px; }
.toolbar input, .toolbar select {
  border: 1px solid var(--line); background: var(--bg); border-radius: var(--radius); padding: 8px 14px; font-size: 14px;
}
.toolbar input { flex: 1 1 220px; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; }

.roster {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px;
  max-height: 440px; overflow-y: auto; padding: 2px; margin: 0 -2px;
}
.card {
  display: flex; align-items: center; gap: 10px; text-align: left;
  border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 8px 10px; cursor: pointer;
}
.card:hover:not(:disabled) { border-color: var(--accent); }
.card:disabled { opacity: 0.4; cursor: not-allowed; }
.card.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--surface)); }
.card .avatar { width: 34px; height: 34px; font-size: 12px; }
.card-text { display: grid; min-width: 0; flex: 1; }
.card-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.check { color: var(--muted); font-weight: 600; width: 16px; text-align: center; }
.card.selected .check { color: var(--accent); }

/* question */
#question {
  width: 100%; resize: vertical; min-height: 84px;
  border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 12px 14px;
  font-family: var(--serif); font-size: 21px; line-height: 1.35;
}
.form-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 12px; flex-wrap: wrap; }
.form-row .hint { margin: 0; }

/* ---------- deliberation ---------- */

.deliberation { margin: 40px 0 20px; }
.delib-title { font-size: 34px; text-align: center; }
.asked {
  margin: 12px auto 28px; max-width: 760px; text-align: center;
  font-family: var(--serif); font-size: 24px; font-style: italic; line-height: 1.35;
}
.asked::before { content: "“"; color: var(--gold); }
.asked::after { content: "”"; color: var(--gold); }

.round {
  border-top: 1px solid var(--line); padding: 24px 0 8px;
}
.round h3 { font-size: 24px; display: flex; align-items: baseline; gap: 12px; }
.roman { color: var(--gold); font-size: 20px; min-width: 24px; }
.round-note { color: var(--muted); font-size: 13.5px; margin: 4px 0 16px; }
.round-note.center { text-align: center; margin-top: 12px; }
.round-body { display: grid; gap: 10px; }
.round-actions { display: flex; justify-content: flex-end; margin-top: 4px; }

.member {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
}
.member.quiet { background: transparent; }
.member.has-question { border-color: color-mix(in srgb, var(--gold) 60%, var(--line)); }
.member-body { flex: 1; min-width: 0; display: grid; gap: 4px; }
.member-name { font-family: var(--serif); font-weight: 600; font-size: 18px; line-height: 1.2; }
.member p { margin: 0; }
.clar-q { font-family: var(--serif); font-size: 18px; font-style: italic; }
.clar-a {
  width: 100%; margin-top: 6px; resize: vertical;
  border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 8px 10px;
}
.clar-given { font-size: 14px; }
.ballot strong { font-family: var(--serif); font-size: 17px; }
.justification { color: var(--muted); font-style: italic; }
.error-text { color: var(--danger); font-size: 14px; }

.thinking { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.dots { width: 26px; height: 6px; background:
  radial-gradient(circle, var(--gold) 2.5px, transparent 3px) 0 50% / 9px 6px repeat-x;
  animation: dots 1.1s infinite linear; opacity: 0.8; }
@keyframes dots { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@media (prefers-reduced-motion: reduce) { .dots { animation: none; } }

.cards { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.proposal-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; display: grid; gap: 10px; align-content: start;
}
.proposal-card header { display: flex; align-items: center; gap: 10px; }
.proposal-card header .member-name { flex: 1; }
.proposal-card.winner { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), var(--shadow); }
.proposal { margin: 0; font-family: var(--serif); font-size: 18px; line-height: 1.45; }
.votes-badge {
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.winner .votes-badge { background: var(--gold); color: var(--accent-ink); }

.verdict {
  margin-top: 28px; background: var(--surface); border: 1px solid var(--gold);
  border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); text-align: center;
}
.verdict h3 { font-size: 30px; }
.winning { margin: 20px auto 0; max-width: 720px; }
.winning blockquote { margin: 0; font-family: var(--serif); font-size: 22px; line-height: 1.45; }
.winning figcaption { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 10px; color: var(--muted); }

.bars { list-style: none; margin: 28px auto 0; padding: 0; max-width: 680px; display: grid; gap: 8px; text-align: left; }
.bars li {
  display: grid; grid-template-columns: 130px 1fr 24px; grid-template-areas: "label track count" ". voters voters";
  align-items: center; gap: 2px 10px; font-size: 14px;
}
.bar-label { grid-area: label; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { grid-area: track; height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: color-mix(in srgb, var(--gold) 55%, var(--surface-2)); border-radius: 999px; }
.lead .bar-fill { background: var(--gold); }
.bar-count { grid-area: count; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.bar-voters { grid-area: voters; font-size: 12px; color: var(--muted); }

.alert {
  margin: 20px 0; padding: 12px 16px; border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--danger) 50%, transparent);
  background: color-mix(in srgb, var(--danger) 9%, transparent); color: var(--danger);
}
.end-actions { display: flex; justify-content: center; margin: 28px 0; }

.footer { color: var(--muted); font-size: 12.5px; text-align: center; padding-bottom: 40px; }
.project-credit { margin-top: 8px; color: color-mix(in srgb, var(--muted) 78%, transparent); }


/* ---------- top bar, account, toast ---------- */

.topbar { border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 94%, transparent); position: sticky; top: 0; z-index: 10; backdrop-filter: blur(10px); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 66px; flex-wrap: wrap; padding-top: 9px; padding-bottom: 9px; }
.brand-block { display: grid; color: var(--ink); text-decoration: none; line-height: 1.1; }
.brand { font-family: var(--serif); font-weight: 500; font-size: 20px; }
.brand-subtitle { margin-top: 4px; color: var(--muted); font-size: 10px; font-weight: 300; letter-spacing: 0.08em; text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.back-to-site { color: var(--muted); font-size: 12px; text-decoration: none; transition: color 0.15s; }
.back-to-site:hover { color: var(--ink); }
.account { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.account a.btn { text-decoration: none; display: inline-block; }
.who { color: var(--muted); font-size: 13px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill {
  border: 1px solid var(--gold); color: var(--accent); background: color-mix(in srgb, var(--gold) 10%, transparent);
  border-radius: var(--radius); padding: 5px 12px; font-size: 13px; font-weight: 600; white-space: nowrap;
}
button.pill { cursor: pointer; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: var(--radius); box-shadow: var(--shadow); font-size: 14px;
  max-width: calc(100% - 32px);
}

/* ---------- dialogs ---------- */

.dialog {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 0; width: min(420px, calc(100% - 32px));
  background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgb(0 0 0 / 0.25);
}
.dialog.wide-dialog { width: min(760px, calc(100% - 32px)); }
.dialog::backdrop { background: rgb(20 15 8 / 0.45); }
.dialog-body { position: relative; padding: 28px; display: grid; gap: 14px; }
.dialog-body h2 { font-size: 28px; }
.dialog-body .hint { margin: 0; }
.dialog-close { position: absolute; top: 10px; right: 14px; border: 0; background: none; font-size: 24px; color: var(--muted); cursor: pointer; }
.field { display: grid; gap: 6px; font-size: 13.5px; font-weight: 500; }
.field input, .field select {
  border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 10px 12px; font-size: 15px; font-weight: 400;
}
.btn.wide { width: 100%; padding: 11px; }
.center { text-align: center; }
.linklike { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; font-weight: 600; text-decoration: underline; }

.packs { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.pack {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: grid; gap: 6px; justify-items: center; text-align: center;
  background: var(--bg);
}
.pack-name { text-transform: uppercase; letter-spacing: 0.12em; font-size: 11.5px; color: var(--gold); font-weight: 600; }
.pack-credits { font-family: var(--serif); font-size: 26px; font-weight: 600; }
.pack-price { font-size: 18px; font-weight: 600; }
.pack .btn { margin-top: 6px; width: 100%; }


/* ---------- admin ---------- */

.admin { padding-bottom: 40px; }
.admin-title { font-size: 40px; margin: 32px 0 8px; }
.admin .step h2 { font-size: 24px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 20px 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 2px; }
.stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.stat-value { font-family: var(--serif); font-size: 28px; font-weight: 600; }
.key-row { border-top: 1px solid var(--line); padding: 16px 0; display: grid; gap: 10px; }
.key-row:first-of-type { border-top: 0; }
.key-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.key-status { font-size: 12.5px; font-weight: 600; padding: 2px 10px; border-radius: 999px; }
.key-status.ok { background: color-mix(in srgb, #2e7d4f 15%, transparent); color: #2e7d4f; }
.key-status.missing { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.key-input { display: flex; gap: 8px; flex-wrap: wrap; }
.key-input input, .grid-fields input, .grid-fields select, .field.inline select, .table input, .small-input {
  border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 8px 10px; font-size: 14px;
}
.key-input input { flex: 1 1 260px; }
.field.inline { display: flex; align-items: center; gap: 10px; }
.grid-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.sub { font-size: 20px; margin: 24px 0 10px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.table input { width: 100%; min-width: 80px; }
.small-input { width: 90px; }
.adjust { display: flex; gap: 6px; align-items: center; }
.row-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.alert.subtle { color: var(--muted); border-color: var(--line); background: var(--surface-2); }
code { font-size: 12.5px; background: var(--surface-2); padding: 1px 6px; border-radius: 5px; overflow-wrap: anywhere; }

/* ---------- small screens ---------- */

@media (max-width: 760px) {
  .wrap { padding: 0 16px; }
  .step { padding: 18px 16px; }
  .seats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .seat { min-height: 88px; }
  .seat-name { font-size: 14px; overflow-wrap: anywhere; }
  .cards { grid-template-columns: 1fr; }
  .bars li { grid-template-columns: 96px 1fr 24px; }
  .verdict { padding: 20px 16px; }
  .who { display: none; }
  .topbar-actions { gap: 10px; }
  .back-to-site { width: 100%; text-align: right; order: 2; }
  .dialog-body { padding: 22px 18px; }
}
