/* Hild Bede SRC voting.
   Palette from the college arms and colours: purpure chevron, azure chief, gold lions,
   gules cross; Bede light/dark blue; Hild green and lilac. Sandstone paper for the cathedral city. */
:root {
  --purple: #5b1f66;
  --purple-deep: #3a1243;
  --azure: #1f3a70;
  --sky: #8fb8de;
  --gold: #c9a23f;
  --gold-soft: #ead9a6;
  --gules: #b3261e;
  --green: #2f6b4f;
  --lilac: #c8b6e2;

  --bg: #f5f0e6;
  --paper: #fffdf8;
  --ink: #1d1622;
  --ink-soft: #5d5466;
  --line: #e4dccd;
  --shadow: 0 1px 2px rgba(42, 20, 48, .06), 0 12px 32px -12px rgba(42, 20, 48, .22);

  --for: var(--green);
  --against: var(--gules);
  --abstain: #6b6378;

  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r: 18px;
  --ease: cubic-bezier(.16, 1, .3, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #160f1a; --paper: #211828; --ink: #f3ecf6; --ink-soft: #b3a8bd; --line: #3a2d43;
    --purple: #b48bd0; --azure: #9db8e6; --gold: #ddb95a; --for: #4fae80; --against: #e5675d;
    --abstain: #a59cb2; --shadow: 0 12px 32px -12px rgba(0, 0, 0, .6); color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink); font: 17px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased; min-height: 100dvh;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

/* ---------- crest band + header ---------- */
.band {
  height: 14px; background:
    linear-gradient(135deg, transparent 49%, var(--gold) 49% 51%, transparent 51%) 0 0 / 28px 14px,
    linear-gradient(90deg, var(--azure), var(--purple-deep) 50%, var(--purple));
}
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; max-width: 1100px; margin: 0 auto;
}
.mark { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.mark svg { width: 34px; height: 38px; flex: none; }
.mark b { font: 600 19px/1 var(--serif); letter-spacing: -.01em; display: block; }
.mark small { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft); }
.motto { font: italic 13px var(--serif); color: var(--ink-soft); }

/* ---------- voter ---------- */
.wrap { max-width: 560px; margin: 0 auto; padding: 4px 16px 48px; }
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); padding: 22px 20px; position: relative; overflow: hidden;
}
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase; color: var(--purple);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--for); box-shadow: 0 0 0 0 var(--for); animation: pulse 1.8s infinite; }
.dot.off { background: var(--abstain); animation: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
h1.title { font: 600 clamp(28px, 7vw, 38px)/1.08 var(--serif); letter-spacing: -.02em; margin: 10px 0 8px; text-wrap: balance; }
.question { font-size: 18px; color: var(--ink-soft); margin: 0 0 16px; text-wrap: pretty; }
.people { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; color: var(--ink-soft); margin-bottom: 16px; }
.people b { color: var(--ink); font-weight: 600; }

details.policy { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 -20px; }
details.policy summary {
  list-style: none; padding: 14px 20px; display: flex; justify-content: space-between; align-items: center;
  font-weight: 600; cursor: pointer; color: var(--purple);
}
details.policy summary::-webkit-details-marker { display: none; }
details.policy summary::after { content: "+"; font: 400 24px/1 var(--serif); transition: transform .3s var(--ease); }
details.policy[open] summary::after { transform: rotate(45deg); }
.policy-text { padding: 0 20px 18px; font: 16px/1.65 var(--serif); max-height: 55vh; overflow: auto; }
.policy-text p { margin: 0 0 .8em; }
.policy-text .head { font-family: var(--sans); font-weight: 700; font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--purple); margin-top: 1.2em; }

.choices { display: grid; gap: 12px; margin-top: 20px; }
.choice {
  display: flex; align-items: center; gap: 16px; width: 100%; min-height: 72px; padding: 14px 18px;
  border-radius: 16px; border: 2px solid var(--line); background: var(--paper); text-align: left;
  transition: transform .2s var(--ease), border-color .2s, background .2s, box-shadow .2s;
}
.choice .ico {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none;
  color: #fff; font-size: 22px; font-weight: 700;
}
.choice b { display: block; font: 600 21px/1.1 var(--serif); }
.choice small { color: var(--ink-soft); font-size: 14px; }
.choice[data-c="for"] .ico { background: var(--for); }
.choice[data-c="against"] .ico { background: var(--against); }
.choice[data-c="abstain"] .ico { background: var(--abstain); }
.choice:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.choice:active { transform: scale(.98); }
.choice[data-c="for"]:hover, .choice[data-c="for"].sel { border-color: var(--for); }
.choice[data-c="against"]:hover, .choice[data-c="against"].sel { border-color: var(--against); }
.choice[data-c="abstain"]:hover, .choice[data-c="abstain"].sel { border-color: var(--abstain); }

.code-field { margin-top: 18px; }
.code-field label { font-weight: 600; font-size: 14px; display: block; margin-bottom: 6px; }
.code-field input {
  width: 100%; font: 600 28px/1 var(--serif); letter-spacing: .4em; text-align: center; padding: 14px;
  border-radius: 14px; border: 2px solid var(--line); background: var(--bg);
}

/* confirm sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(20, 10, 24, .45); backdrop-filter: blur(4px); z-index: 10; animation: fade .2s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 11; background: var(--paper);
  border-radius: 24px 24px 0 0; padding: 26px 20px calc(22px + env(safe-area-inset-bottom));
  max-width: 560px; margin: 0 auto; animation: up .35s var(--ease); box-shadow: 0 -10px 40px rgba(0,0,0,.25);
}
.sheet h2 { font: 600 26px/1.15 var(--serif); margin: 0 0 6px; }
.sheet p { color: var(--ink-soft); margin: 0 0 18px; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px;
  padding: 0 22px; border-radius: 14px; border: 0; font-weight: 600; font-size: 17px;
  background: var(--purple); color: #fff; transition: transform .15s var(--ease), filter .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.97); }
.btn.ghost { background: transparent; color: var(--ink); border: 2px solid var(--line); }
.btn.gold { background: var(--gold); color: #2a1a00; }
.btn.danger { background: transparent; color: var(--against); border: 2px solid currentColor; }
.btn.sm { min-height: 38px; padding: 0 14px; font-size: 14px; border-radius: 10px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row.full > .btn { flex: 1; }

/* voted state */
.done { text-align: center; padding: 10px 0 4px; }
.seal {
  width: 96px; height: 96px; margin: 8px auto 14px; border-radius: 50%; display: grid; place-items: center;
  color: #fff; font-size: 44px; animation: pop .6s var(--ease);
  box-shadow: 0 0 0 6px var(--paper), 0 0 0 8px var(--gold);
}
@keyframes pop { from { transform: scale(.4) rotate(-20deg); opacity: 0; } }
.done h2 { font: 600 28px/1.1 var(--serif); margin: 0 0 6px; }
.done p { color: var(--ink-soft); margin: 0; }

/* results */
.results { margin-top: 18px; display: grid; gap: 12px; }
.bar { display: grid; grid-template-columns: 84px 1fr 44px; align-items: center; gap: 10px; font-weight: 600; }
.bar .track { height: 14px; border-radius: 7px; background: var(--line); overflow: hidden; }
.bar .fill { height: 100%; border-radius: 7px; transform-origin: left; transition: width .8s var(--ease); }
.bar .n { text-align: right; font-variant-numeric: tabular-nums; }
.verdict {
  display: inline-block; margin-top: 6px; padding: 6px 14px; border-radius: 999px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; font-size: 13px; color: #fff;
}
.verdict.carried { background: var(--for); } .verdict.falls { background: var(--against); }
.verdict.tied, .verdict.none, .verdict.abstained { background: var(--abstain); }

.waiting { text-align: center; padding: 40px 10px; }
.waiting h1 { font: 600 30px/1.1 var(--serif); margin: 18px 0 8px; }
.waiting p { color: var(--ink-soft); margin: 0; }
.chev-anim { width: 90px; margin: 0 auto; animation: float 3s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-6px); } }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20; background: var(--ink);
  color: var(--paper); padding: 12px 18px; border-radius: 12px; font-weight: 600; max-width: calc(100% - 32px);
  animation: up .3s var(--ease);
}
.foot { text-align: center; font-size: 12px; color: var(--ink-soft); margin-top: 22px; }
/* Deliberately quiet: there for the chair who knows to look, not an invitation to voters. */
.chair-link { margin: 10px 0 28px; }
.chair-link a { color: var(--ink-soft); opacity: .55; text-decoration: none; padding: 10px 14px; }
.chair-link a:hover, .chair-link a:focus-visible { opacity: 1; text-decoration: underline; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- chair console ---------- */
.tools { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.tools .btn { text-decoration: none; }
.console {
  max-width: 1100px; margin: 0 auto; padding: 4px 16px 60px; display: grid; gap: 20px;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start;
}
.console > .card:only-child { grid-column: 1 / -1; }
.col { display: grid; gap: 20px; }
.list { display: grid; gap: 14px; }
.login { max-width: 440px; margin: 40px auto; grid-column: 1 / -1; display: grid; gap: 10px; }
/* ---------- chair login ---------- */
/* The logo sits centred at the top, out of the flow, so the card is centred in the whole window. */
/* Same gap between the top bar and the logo whether logged in or not. */
body.chair .top { padding-top: 34px; padding-bottom: 34px; }
body.chair .console { padding-top: 0; }
body.gate .top { position: absolute; left: 0; right: 0; top: 14px; justify-content: center; padding-top: 34px; }
body.gate .console { display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; min-height: calc(100dvh - 14px); padding: 110px 16px; }
body.gate .login { margin: 0; width: 100%; }
.pin-field { position: relative; display: grid; }
.pin-field input {
  width: 100%; font-size: 24px; letter-spacing: .3em; padding: 12px 56px 12px 14px; border-radius: 12px;
  border: 2px solid var(--line); background: var(--bg);
}
/* Hidden characters are drawn in a face whose bullet is a round dot (the page font's is a square). */
.pin-field input[type="password"] { font-family: Verdana, "Segoe UI", system-ui, sans-serif; }
.pin-field input[type="text"] { letter-spacing: .04em; font-size: 20px; padding-top: 14px; padding-bottom: 14px; }
.eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; display: grid;
  place-items: center; border: 0; border-radius: 10px; background: none; color: var(--ink-soft);
}
.eye:hover, .eye[aria-pressed="true"] { color: var(--purple); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.card h2 { font: 600 22px/1.2 var(--serif); margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 14px 0 16px; }
.fld { display: grid; gap: 4px; }
.fld.wide { grid-column: 1 / -1; }
.lbl { font-weight: 600; font-size: 14px; }
.hint { color: var(--ink-soft); font-size: 13px; margin: 0; }
.fld input, .fld textarea {
  width: 100%; padding: 11px 13px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--bg);
  transition: border-color .15s, background .15s;
}
.fld textarea { font: 15px/1.6 var(--serif); resize: vertical; }
.fld input:focus, .fld textarea:focus { border-color: var(--purple); background: var(--paper); outline: none; }
.grow { flex: 1; }
.row { align-items: center; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink-soft); }
.chk input { width: 18px; height: 18px; accent-color: var(--purple); }

.motion h3 { font: 600 21px/1.2 var(--serif); margin: 8px 0 4px; }
.motion .q { color: var(--ink-soft); margin: 0 0 12px; }
.motion.open { border-color: var(--for); box-shadow: 0 0 0 3px color-mix(in srgb, var(--for) 18%, transparent), var(--shadow); }
.motion.draft { background: transparent; box-shadow: none; border-style: dashed; }
.motion .row { margin-top: 12px; }
.roomcode { font-size: 14px; color: var(--ink-soft); margin: 0 0 10px; }
.roomcode b { font: 600 22px var(--serif); letter-spacing: .2em; color: var(--ink); margin-left: 6px; }
.counts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.cnt { border-radius: 12px; padding: 10px 12px; background: var(--bg); border-top: 4px solid var(--line); }
.cnt b { display: block; font: 600 26px/1 var(--serif); font-variant-numeric: tabular-nums; }
.cnt span { font-size: 12px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .08em; }
.cnt.for { border-color: var(--for); } .cnt.against { border-color: var(--against); }
.cnt.abstain { border-color: var(--abstain); } .cnt.total { border-color: var(--gold); }
.counts.big b { font-size: 40px; }
.qr { text-align: center; }
.qr img { width: 200px; height: 200px; background: #fff; padding: 8px; border-radius: 12px; margin: 12px auto 6px; display: block; }
.qr .url { font: 600 18px var(--serif); margin: 0 0 6px; }
.empty { text-align: center; color: var(--ink-soft); }

@media (max-width: 820px) {
  .console { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .counts { grid-template-columns: repeat(2, 1fr); }
  .motto { display: none; }
}

/* ---------- projector screen ---------- */
body.screen { background: radial-gradient(120% 90% at 0% 0%, #4a1a56 0%, var(--purple-deep) 45%, #170a1c 100%); color: #fff; overflow: hidden; }
.stage { height: calc(100dvh - 14px); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 5vw; align-items: center; padding: 4vh 5vw; }
.stage .qrbox { background: #fff; border-radius: 28px; padding: 2.4vw; box-shadow: 0 30px 80px rgba(0,0,0,.45), 0 0 0 6px var(--gold); text-align: center; color: var(--purple-deep); }
.stage .qrbox img { width: 100%; max-height: 60vh; aspect-ratio: 1; display: block; }
.stage .qrbox p { font: 600 clamp(18px, 2vw, 32px)/1.1 var(--serif); margin: 1vh 0 0; }
.stage .eyebrow { color: var(--gold-soft); font-size: clamp(14px, 1.2vw, 20px); }
.stage h1 { font: 600 clamp(36px, 4.6vw, 88px)/1.04 var(--serif); letter-spacing: -.02em; margin: 2vh 0 1.5vh; text-wrap: balance; }
.stage .q { font-size: clamp(18px, 1.8vw, 32px); opacity: .8; margin: 0 0 4vh; }
.stage .tally { display: flex; align-items: baseline; gap: 16px; }
.stage .tally b { font: 600 clamp(64px, 9vw, 170px)/1 var(--serif); font-variant-numeric: tabular-nums; color: var(--gold); }
.stage .tally span { font-size: clamp(18px, 1.6vw, 28px); opacity: .8; }
.stage .code { margin-top: 3vh; font-size: clamp(18px, 1.6vw, 28px); }
.stage .code b { font: 600 1.8em var(--serif); letter-spacing: .25em; color: var(--gold); margin-left: 12px; }
.stage .code small { display: block; font-size: .6em; opacity: .65; margin-top: .4em; }
.stage .results { max-width: 900px; }
.stage .bar { grid-template-columns: 7em 1fr 3em; font-size: clamp(18px, 1.8vw, 32px); }
.stage .bar .track { height: clamp(16px, 2vh, 28px); border-radius: 99px; background: rgba(255,255,255,.12); }
.stage .verdict { font-size: clamp(16px, 1.4vw, 24px); padding: 10px 22px; margin-top: 2vh; }
body.screen { --for: #4fae80; --against: #e5675d; --abstain: #a59cb2; }
.composer .tmpl { margin: -6px 0 16px; }
.composer .actions { justify-content: flex-end; }
.closed-note { margin-top: 18px; }

/* ---------- voter stepper (several motions open) ---------- */
.stepper {
  display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; gap: 8px; margin-bottom: 14px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 8px;
}
.step-btn {
  width: 48px; height: 48px; border-radius: 12px; border: 0; background: var(--bg); font: 600 26px/1 var(--serif);
  color: var(--purple);
}
.step-btn:disabled { opacity: .3; }
.step-mid { text-align: center; display: grid; gap: 4px; justify-items: center; }
.step-mid b { font: 600 16px var(--serif); }
.step-mid small { font-size: 12px; color: var(--ink-soft); }
.pips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.pip { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line); background: transparent; padding: 0; }
.pip.voted { background: var(--for); border-color: var(--for); }
.pip.on { outline: 2px solid var(--gold); outline-offset: 2px; }
.next-btn { margin-top: 16px; }

/* ---------- chair: meeting + agenda + history ---------- */
.meeting-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.meeting-bar h2 { font: 600 22px/1.2 var(--serif); margin: 2px 0 0; }
.meeting-bar .when { color: var(--ink-soft); font-size: 14px; }
.agenda { display: grid; gap: 10px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.agenda .row { gap: 8px; }
.num { font: 600 13px var(--sans); color: var(--ink-soft); letter-spacing: .08em; text-transform: uppercase; }
.mover { display: inline-flex; gap: 4px; margin-left: auto; }
.mover button { width: 32px; height: 32px; border-radius: 8px; border: 1.5px solid var(--line); background: transparent; }
.mover button:disabled { opacity: .3; }
.meeting-form { display: grid; gap: 10px; margin-top: 12px; grid-template-columns: 1fr auto; align-items: end; }
.meeting-form .row { grid-column: 1 / -1; }
.history h2 { margin-bottom: 4px; }
.past { border-top: 1px solid var(--line); padding: 14px 0 4px; }
.past:first-of-type { border-top: 0; }
.past summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.past summary::-webkit-details-marker { display: none; }
.past summary b { font: 600 18px/1.2 var(--serif); flex: 1; }
.bin { flex: none; width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 8px; background: none; color: var(--ink-soft); align-self: center; }
.bin:hover { color: var(--against); background: color-mix(in srgb, var(--against) 10%, transparent); }
/* a plain text link that happens to be a button */
.textbtn { border: 0; background: none; padding: 4px 0; font-size: 13px; color: var(--ink-soft); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.textbtn:hover { color: var(--purple); }
.deleted { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 10px; display: grid; gap: 8px; }
.deleted .textbtn { justify-self: start; }
.deleted-row { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; font-size: 14px; color: var(--ink-soft); flex-wrap: wrap; }
.deleted-row .row { gap: 14px; }
.qr .btn { text-decoration: none; margin-top: 12px; }
.history .card-head .btn { text-decoration: none; }
body.chair #foot-tools { margin: 0 0 40px; }
.past summary span { color: var(--ink-soft); font-size: 13px; white-space: nowrap; }
.past-motion { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.past-motion:last-child { border-bottom: 0; }
.past-motion h4 { margin: 0; font: 600 16px/1.3 var(--serif); }
.past-motion .meta { grid-column: 1 / -1; font-size: 13px; color: var(--ink-soft); }
.past-motion .nums { grid-column: 1 / -1; display: flex; gap: 14px; font-size: 14px; font-variant-numeric: tabular-nums; }
.past-motion .nums b { font-weight: 700; }
.past-motion .nums .f { color: var(--for); } .past-motion .nums .a { color: var(--against); } .past-motion .nums .x { color: var(--abstain); }
.past-motion .verdict { margin: 0; align-self: start; font-size: 11px; padding: 4px 10px; }
.past .row { margin: 10px 0 6px; }
.right { display: grid; gap: 14px; align-content: start; }
.screen-list { display: grid; gap: 2vh; margin-top: 2vh; }
.screen-item { display: flex; justify-content: space-between; align-items: baseline; gap: 2vw; border-bottom: 1px solid rgba(255,255,255,.15); padding-bottom: 1.4vh; }
.screen-item span { font: 600 clamp(20px, 2.2vw, 40px)/1.15 var(--serif); }
.screen-item b { font: 600 clamp(28px, 3vw, 56px)/1 var(--serif); color: var(--gold); font-variant-numeric: tabular-nums; white-space: nowrap; }
.screen-item small { font-size: .45em; opacity: .7; margin-left: 6px; font-family: var(--sans); color: #fff; }
.past-text summary { cursor: pointer; color: var(--purple); font-weight: 600; }
.past-text .policy-text { padding: 8px 0 0; max-height: none; font-size: 14px; color: var(--ink); }
