/* Medical & Health CDS — voting system
   White paper, teal ink. Serif for voice, sans for work. */

:root {
  color-scheme: light;

  --white: #ffffff;
  --paper: #fbfdfd;
  --wash: #eff7f6;
  --wash-2: #e1f0ee;
  --line: #d9e9e7;
  --line-strong: #b6d6d3;

  --teal: #45aea9;       /* logo teal: fills, marks, bars */
  --teal-600: #2d938e;
  --teal-700: #1b7c77;   /* teal that is readable as text on white */
  --ink: #0e3b39;        /* deep teal: primary text and buttons */
  --ink-2: #355e5b;
  --muted: #5a7b79;

  --danger: #b93a27;
  --danger-wash: #fbeeeb;

  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --sans: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgb(14 59 57 / 0.05), 0 12px 32px -16px rgb(14 59 57 / 0.22);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-bottom: 120px;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--white);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img,
svg {
  display: block;
}

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

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--teal-700);
  outline-offset: 3px;
  border-radius: 6px;
}

[hidden] {
  display: none !important;
}

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

/* ─── Frame ───────────────────────────────────────────── */

.topline {
  height: 4px;
  background: linear-gradient(90deg, var(--ink) 0 18%, var(--teal) 18% 100%);
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: var(--page, 640px);
  margin: 0 auto;
  padding: 18px 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand img {
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 1px var(--line);
}

.brand-text {
  display: grid;
  line-height: 1.15;
  min-width: 0;
}

.brand-text strong {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 400;
  letter-spacing: -0.005em;
}

.brand-text small {
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shell {
  max-width: var(--page, 640px);
  margin: 0 auto;
  padding: 8px 20px 48px;
}

.colophon {
  max-width: var(--page, 640px);
  margin: 0 auto;
  padding: 28px 20px 40px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* ─── Type ────────────────────────────────────────────── */

.eyebrow {
  margin: 0 0 14px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--teal-700);
  display: flex;
  align-items: center;
  gap: 10px;
}

.eyebrow::before {
  content: "";
  width: 22px;
  height: 1px;
  background: currentColor;
}

.display {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.6rem, 9vw, 3.6rem);
  line-height: 1;
  letter-spacing: -0.02em;
}

.display em {
  color: var(--teal-700);
}

.lede {
  margin: 16px 0 0;
  max-width: 34em;
  color: var(--ink-2);
  font-size: 1.02rem;
}

/* ─── Poll status & buttons ───────────────────────────── */

/* A dateline, not a badge: small caps label over a serif word. */
.poll-status {
  display: grid;
  justify-items: end;
  margin: 0;
  padding-left: 16px;
  border-left: 1px solid var(--line);
  line-height: 1.1;
  flex: none;
}

.ps-label {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.ps-value {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.35rem;
  color: var(--muted);
}

.poll-status.is-open .ps-value {
  color: var(--teal-700);
}

@media (max-width: 400px) {
  .masthead {
    padding: 16px;
    gap: 12px;
  }

  .brand img {
    width: 40px;
    height: 40px;
  }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 22px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.005em;
  text-decoration: none;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.15s var(--ease), opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn svg {
  width: 18px;
  height: 18px;
  flex: none;
}

.btn-primary {
  background: var(--ink);
  color: var(--white);
}

.btn-primary:hover:not(:disabled) {
  background: #155250;
}

.btn-teal {
  background: var(--teal-700);
  color: var(--white);
}

.btn-teal:hover:not(:disabled) {
  background: var(--teal-600);
}

.btn-ghost {
  background: var(--white);
  border-color: var(--line-strong);
  color: var(--ink);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--wash);
}

.btn-quiet {
  background: transparent;
  color: var(--ink-2);
  padding: 0 14px;
}

.btn-quiet:hover:not(:disabled) {
  background: var(--wash);
}

.btn-danger {
  background: var(--danger);
  color: var(--white);
}

.btn-danger-ghost {
  background: var(--white);
  border-color: color-mix(in srgb, var(--danger) 40%, white);
  color: var(--danger);
}

.btn-danger-ghost:hover:not(:disabled) {
  background: var(--danger-wash);
}

.btn-block {
  width: 100%;
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── Voter: intro ────────────────────────────────────── */

.intro {
  padding: 28px 0 8px;
}

.fine-print {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.82rem;
  color: var(--muted);
}

.fine-print li {
  display: flex;
  align-items: center;
  gap: 7px;
}

.fine-print svg {
  width: 15px;
  height: 15px;
  color: var(--teal-700);
}

/* ─── Voter: offices ──────────────────────────────────── */

.offices {
  margin: 36px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: office;
}

.office {
  padding: 30px 0 34px;
  border-top: 1px solid var(--line);
  animation: rise 0.6s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 70ms);
}

/* Starts partly visible so content never stays hidden if animations stall
   (battery saver, slow phones). */
@keyframes rise {
  from { opacity: 0.35; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.office-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: 4px 16px;
  margin-bottom: 18px;
}

.office-num {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--teal-700);
  min-width: 1.8em;
}

.office-title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.7rem, 6vw, 2.1rem);
  line-height: 1.05;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.office-state {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.office-state.is-done {
  color: var(--teal-700);
}

.office-state svg {
  width: 14px;
  height: 14px;
}

.choices {
  display: grid;
  gap: 10px;
}

.choice {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  padding: 10px 16px 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), box-shadow 0.2s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.choice:hover {
  border-color: var(--line-strong);
}

.choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice:has(input:focus-visible) {
  outline: 2px solid var(--teal-700);
  outline-offset: 2px;
}

.monogram {
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--wash);
  color: var(--teal-700);
  font-family: var(--serif);
  font-size: 1.1rem;
  letter-spacing: 0.02em;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.choice-name {
  flex: 1;
  min-width: 0;
  font-weight: 500;
  font-size: 1.02rem;
  overflow-wrap: anywhere;
}

.mark {
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  display: grid;
  place-items: center;
  color: var(--white);
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}

.mark svg {
  width: 14px;
  height: 14px;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.2s var(--ease), transform 0.25s var(--ease);
}

.choice:has(input:checked) {
  border-color: var(--teal);
  background: var(--wash);
  box-shadow: inset 0 0 0 1px var(--teal);
}

.choice:has(input:checked) .monogram {
  background: var(--teal);
  color: var(--white);
}

.choice:has(input:checked) .mark {
  background: var(--teal-700);
  border-color: var(--teal-700);
}

.choice:has(input:checked) .mark svg {
  opacity: 1;
  transform: none;
}

/* An office the voter tried to skip */
.office.is-missing .office-state {
  visibility: hidden;
}

.office.is-missing .choice {
  border-color: color-mix(in srgb, var(--danger) 35%, white);
}

.office.is-missing .office-title::after {
  content: "Choose a candidate to continue.";
  display: block;
  margin-top: 6px;
  font-family: var(--sans);
  font-size: 0.85rem;
  letter-spacing: 0;
  color: var(--danger);
}

#review-btn.is-waiting {
  background: var(--ink-2);
}

/* ─── Voter: dock ─────────────────────────────────────── */

.dock {
  position: sticky;
  bottom: 0;
  z-index: 5;
  padding: 12px 0 max(12px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--white) 70%, rgb(255 255 255 / 0));
}

.dock-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 12px 12px 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgb(255 255 255 / 0.92);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.progress {
  flex: 1;
  min-width: 0;
}

.progress-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
}

.progress-label b {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 400;
  color: var(--ink);
}

.ticks {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}

.ticks span {
  height: 3px;
  flex: 1;
  max-width: 36px;
  border-radius: 3px;
  background: var(--line);
  transition: background 0.3s var(--ease);
}

.ticks span.on {
  background: var(--teal);
}

/* ─── Sheets (dialogs) ────────────────────────────────── */

dialog.sheet {
  position: fixed;
  inset: auto 0 0;
  width: min(560px, 100%);
  max-width: 100%;
  max-height: min(88dvh, 760px);
  margin: 0 auto;
  padding: 0;
  border: 0;
  border-radius: 24px 24px 0 0;
  background: var(--white);
  color: var(--ink);
  box-shadow: 0 -20px 60px -20px rgb(14 59 57 / 0.35);
  overflow: hidden;
}

dialog.sheet[open] {
  display: flex;
  flex-direction: column;
  animation: sheet-up 0.35s var(--ease);
}

dialog.sheet::backdrop {
  background: rgb(14 59 57 / 0.38);
  backdrop-filter: blur(3px);
  animation: fade 0.3s var(--ease);
}

@keyframes sheet-up {
  from { transform: translateY(40px); opacity: 0; }
}

@keyframes fade {
  from { opacity: 0; }
}

@media (min-width: 640px) {
  dialog.sheet {
    inset: 0;
    margin: auto;
    border-radius: 24px;
  }
}

.sheet-head {
  padding: 26px 26px 10px;
}

.sheet-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 2rem;
  line-height: 1.05;
}

.sheet-head p {
  margin: 8px 0 0;
  color: var(--ink-2);
  font-size: 0.92rem;
}

.sheet-body {
  padding: 8px 26px;
  overflow-y: auto;
}

.sheet-foot {
  display: flex;
  gap: 10px;
  padding: 16px 26px max(22px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--paper);
}

.sheet-foot .btn {
  flex: 1;
  padding: 0 16px;
  white-space: nowrap;
}

.sheet-foot .btn-ghost {
  flex: 0 0 auto;
}

.receipt {
  margin: 0;
  padding: 0;
  list-style: none;
}

.receipt li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 16px;
  padding: 14px 0;
  border-bottom: 1px dashed var(--line-strong);
}

.receipt li:last-child {
  border-bottom: 0;
}

.receipt .r-office {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.receipt .r-choice {
  grid-column: 1;
  font-family: var(--serif);
  font-size: 1.35rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.receipt .r-edit {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--teal-700);
  font-size: 0.82rem;
  font-weight: 600;
}

.receipt .r-edit:hover {
  background: var(--wash);
}

.form-error {
  margin: 12px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--danger-wash);
  color: var(--danger);
  font-size: 0.88rem;
  font-weight: 500;
}

/* ─── Voter: states (closed / thanks / loading) ───────── */

.state {
  display: grid;
  justify-items: center;
  text-align: center;
  padding: 48px 0 24px;
  animation: rise 0.6s var(--ease) both;
}

.state .display {
  font-size: clamp(2.4rem, 9vw, 3.2rem);
}

.state .lede {
  margin-left: auto;
  margin-right: auto;
}

.state-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 28px;
}

.seal {
  position: relative;
  width: 168px;
  height: 168px;
  margin-bottom: 30px;
}

.seal img {
  position: absolute;
  inset: 18px;
  width: calc(100% - 36px);
  height: calc(100% - 36px);
  border-radius: 50%;
  object-fit: cover;
}

.seal svg.ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.seal .ring circle {
  fill: none;
  stroke-width: 3;
}

.seal .ring .track {
  stroke: var(--line);
}

.seal .ring .draw {
  stroke: var(--teal);
  stroke-linecap: round;
  stroke-dasharray: 490;
  stroke-dashoffset: 490;
  animation: draw 1.2s 0.15s var(--ease) forwards;
}

@keyframes draw {
  to { stroke-dashoffset: 0; }
}

.seal .badge {
  position: absolute;
  right: 4px;
  bottom: 10px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--teal-700);
  color: var(--white);
  box-shadow: 0 0 0 5px var(--white);
  animation: pop 0.5s 1.1s var(--ease) both;
}

.seal .badge svg {
  width: 22px;
  height: 22px;
}

@keyframes pop {
  from { transform: scale(0); }
  60% { transform: scale(1.12); }
}

.seal.is-waiting .ring .draw {
  stroke-dasharray: 60 430;
  stroke-dashoffset: 0;
  animation: spin-ring 2.6s linear infinite;
  transform-origin: 50% 50%;
}

@keyframes spin-ring {
  to { stroke-dashoffset: -490; }
}

.stamp {
  margin-top: 26px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.stamp svg {
  width: 15px;
  height: 15px;
  flex: none;
}

.skeleton {
  display: grid;
  gap: 12px;
  padding-top: 40px;
}

.skeleton span {
  height: 64px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--wash) 0%, var(--paper) 50%, var(--wash) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

.skeleton span:first-child {
  height: 110px;
  width: 70%;
}

@keyframes shimmer {
  to { background-position: -200% 0; }
}

/* ─── Toast ───────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  top: max(20px, env(safe-area-inset-top));
  z-index: 50;
  transform: translate(-50%, -20px);
  opacity: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--white);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast svg {
  width: 18px;
  height: 18px;
  color: var(--teal);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── Admin ───────────────────────────────────────────── */

body.admin {
  --page: 880px;
}

.masthead-end {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--muted);
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.icon-btn:hover:not(:disabled) {
  background: var(--wash);
  color: var(--ink);
}

.icon-btn.is-danger:hover:not(:disabled) {
  background: var(--danger-wash);
  color: var(--danger);
}

.icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.text-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  margin: -6px -8px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--teal-700);
  font-size: 0.86rem;
  font-weight: 600;
}

.text-btn svg {
  width: 16px;
  height: 16px;
}

.text-btn:hover:not(:disabled) {
  background: var(--wash);
}

.text-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.colophon-link {
  color: var(--teal-700);
  text-decoration: none;
  font-weight: 600;
}

.colophon-link:hover {
  text-decoration: underline;
}

/* Login */

.login {
  max-width: 420px;
  margin: 0 auto;
  padding: 40px 0 24px;
  animation: rise 0.6s var(--ease) both;
}

.login-logo {
  width: 88px;
  height: 88px;
  margin-bottom: 30px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 1px var(--line), 0 0 0 8px var(--wash);
}

.login-form {
  display: grid;
  gap: 12px;
  margin-top: 32px;
}

.field-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.login-form input,
.confirm-input {
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--white);
  font-size: 1rem;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.login-form input:focus,
.confirm-input:focus {
  outline: none;
  border-color: var(--teal-700);
  box-shadow: 0 0 0 4px var(--wash-2);
}

.login-form .btn {
  margin-top: 6px;
}

.confirm-input {
  margin: 8px 0 12px;
  font-weight: 600;
  letter-spacing: 0.2em;
}

/* Console hero */

.hero {
  padding: 28px 0 8px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px 28px;
  margin-top: 28px;
}

.share {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
  min-width: 0;
  padding-left: 20px;
  border-left: 1px solid var(--line);
}

.share-label {
  width: 100%;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.share-url {
  font-family: var(--serif);
  font-size: 1.2rem;
  color: var(--ink);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.share-url:hover {
  text-decoration: underline;
  text-decoration-color: var(--teal);
  text-underline-offset: 4px;
}

/* Tabs: plain words with a rule, not a segmented control */

.tabs {
  display: flex;
  gap: 28px;
  margin-top: 40px;
  border-bottom: 1px solid var(--line);
}

.tab {
  position: relative;
  padding: 12px 0 14px;
  border: 0;
  background: none;
  font-family: var(--serif);
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted);
  transition: color 0.2s var(--ease);
}

.tab:hover,
.tab[aria-current="page"] {
  color: var(--ink);
}

.tab[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--teal);
}

.panel {
  padding-bottom: 24px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 18px 0 4px;
}

.meta {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.empty {
  margin: 28px 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.35rem;
  color: var(--muted);
}

.notice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin: 18px 0 0;
  padding: 4px 0 4px 16px;
  border-left: 2px solid var(--teal);
  color: var(--ink-2);
  font-size: 0.9rem;
}

.notice svg {
  width: 17px;
  height: 17px;
  flex: none;
  margin-top: 2px;
  color: var(--teal-700);
}

.notice strong {
  color: var(--ink);
  font-weight: 600;
}

/* Tally */

.tally {
  margin-top: 12px;
}

.tally-rows {
  display: grid;
  gap: 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tally-line {
  display: grid;
  grid-template-columns: 1fr auto 4.2em;
  align-items: baseline;
  gap: 16px;
}

.tally-name {
  min-width: 0;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.tally-flag {
  margin-left: 10px;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--teal-700);
  white-space: nowrap;
}

.tally-votes {
  font-family: var(--serif);
  font-size: 1.6rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.tally-pct {
  text-align: right;
  font-size: 0.85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.tally-bar {
  display: block;
  height: 3px;
  margin-top: 8px;
  background: var(--wash-2);
  border-radius: 3px;
  overflow: hidden;
}

.tally-bar span {
  display: block;
  height: 100%;
  background: var(--teal);
  border-radius: 3px;
  transition: width 0.8s var(--ease);
}

.tally-row.is-leader .tally-bar span {
  background: var(--ink);
}

.tally-row.is-leader .tally-name {
  font-weight: 600;
}

/* Ballot editor */

.editor {
  margin-top: 8px;
}

.edit-office {
  padding: 26px 0 28px;
}

.edit-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
}

.office-input {
  width: 100%;
  min-width: 0;
  padding: 4px 0 6px;
  border: 0;
  border-bottom: 1px solid transparent;
  background: none;
  font-family: var(--serif);
  font-size: clamp(1.6rem, 5vw, 2rem);
  line-height: 1.1;
  color: var(--ink);
  transition: border-color 0.2s var(--ease);
}

.office-input::placeholder,
.candidate-input::placeholder {
  color: var(--line-strong);
}

.office-input:hover:not(:disabled),
.office-input:focus {
  outline: none;
  border-bottom-color: var(--teal);
}

.edit-tools {
  display: flex;
  gap: 2px;
}

.edit-candidates {
  display: grid;
  gap: 8px;
  margin: 16px 0 14px;
  padding: 0;
  list-style: none;
}

.edit-candidate {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
}

.edit-bullet {
  width: 1.8em;
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  color: var(--muted);
}

.candidate-input {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--white);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.candidate-input:hover:not(:disabled) {
  border-color: var(--line-strong);
}

.candidate-input:focus {
  outline: none;
  border-color: var(--teal-700);
  box-shadow: 0 0 0 4px var(--wash-2);
}

.candidate-input:disabled {
  color: var(--ink-2);
  background: var(--paper);
  cursor: not-allowed;
}

.office-input:disabled {
  cursor: not-allowed;
}

.add-candidate {
  margin-left: calc(1.8em + 2px);
}

.add-office {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 64px;
  margin-top: 8px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: none;
  font-family: var(--serif);
  font-size: 1.3rem;
  color: var(--teal-700);
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}

.add-office svg {
  width: 20px;
  height: 20px;
}

.add-office:hover:not(:disabled) {
  background: var(--wash);
  border-color: var(--teal);
}

.add-office:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.save-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  padding: 14px 0 max(14px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--white) 70%, rgb(255 255 255 / 0));
}

.save-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  padding: 10px 10px 10px 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.save-note {
  flex: 1;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--ink-2);
}

.save-inner .form-error {
  order: 5;
  width: 100%;
  margin: 0;
}

.danger-zone {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 24px;
  margin-top: 56px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}

.danger-zone > div {
  flex: 1 1 320px;
}

.danger-zone h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.5rem;
}

.danger-zone p {
  margin: 6px 0 0;
  max-width: 36em;
  color: var(--ink-2);
  font-size: 0.9rem;
}

@media (max-width: 560px) {
  .share {
    padding-left: 0;
    border-left: 0;
  }

  .hero-actions .btn {
    width: 100%;
  }

  .tally-line {
    grid-template-columns: 1fr auto 3.6em;
    gap: 12px;
  }

  .edit-tools .icon-btn {
    width: 34px;
  }
}

/* ═══ Batch C EXCO awards ═══════════════════════════════ */

/* ─── Voter: welcome ──────────────────────────────────── */

.welcome {
  padding: 28px 0 8px;
}

.award-index {
  margin: 30px 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.award-index li {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 2px;
  border-bottom: 1px solid var(--line);
  font-family: var(--serif);
  font-size: 1.22rem;
  line-height: 1.2;
  animation: rise 0.6s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 60ms);
}

.ai-emoji {
  width: 1.7em;
  flex: none;
  text-align: center;
  font-size: 1.15rem;
}

.ai-title {
  flex: 1;
  min-width: 0;
}

.ai-done {
  width: 22px;
  height: 22px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--teal-700);
  color: var(--white);
}

.ai-done svg {
  width: 13px;
  height: 13px;
}

.step-dock {
  padding: 10px;
}

.step-dock .btn-primary,
.step-dock .btn-teal {
  flex: 1;
}

.step-dock .btn-ghost {
  width: 52px;
  padding: 0;
  flex: none;
}

/* ─── Voter: one award per screen ─────────────────────── */

.award {
  padding: 22px 0 8px;
  animation: step-in 0.45s var(--ease) both;
}

@keyframes step-in {
  from { opacity: 0.4; transform: translateX(12px); }
  to { opacity: 1; transform: none; }
}

.step {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 26px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--teal-700);
}

.step .ticks {
  flex: 0 1 168px;
  margin: 0;
}

.ticks span.now {
  background: var(--ink);
}

.award-emoji {
  display: block;
  margin-bottom: 12px;
  font-size: 2.5rem;
  line-height: 1;
}

.award-title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.15rem, 8.5vw, 3rem);
  line-height: 1.02;
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
}

.award-title:focus {
  outline: none;
}

.award-desc {
  margin-top: 12px;
}

.nominees {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 28px 0 0;
}

@media (min-width: 600px) {
  .nominees {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
  }
}

.nominee {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 7px 7px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), box-shadow 0.25s var(--ease), transform 0.15s var(--ease);
  -webkit-tap-highlight-color: transparent;
  animation: rise 0.5s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 35ms);
}

.nominee:hover {
  border-color: var(--line-strong);
}

.nominee:active {
  transform: scale(0.985);
}

.nominee input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.nominee:has(input:focus-visible) {
  outline: 2px solid var(--teal-700);
  outline-offset: 2px;
}

.portrait {
  position: relative;
  display: block;
  aspect-ratio: 1;
  margin-bottom: 10px;
  border-radius: 9px;
  overflow: hidden;
  background: var(--wash);
}

.portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s var(--ease);
}

.initials {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  font-family: var(--serif);
  font-size: clamp(2rem, 10vw, 3rem);
  letter-spacing: 0.02em;
  color: var(--teal-700);
  background: var(--wash);
}

.tick {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  background: rgb(255 255 255 / 0.92);
  color: var(--white);
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}

.tick svg {
  width: 16px;
  height: 16px;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.2s var(--ease), transform 0.25s var(--ease);
}

.nominee-name {
  padding: 0 5px;
  font-weight: 600;
  font-size: 0.98rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.nominee-role {
  padding: 0 5px;
  font-size: 0.8rem;
  line-height: 1.3;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.nominee:has(input:checked) {
  border-color: var(--teal);
  background: var(--wash);
  box-shadow: inset 0 0 0 1px var(--teal), var(--shadow);
}

.nominee:has(input:checked) .tick {
  background: var(--teal-700);
  border-color: var(--teal-700);
}

.nominee:has(input:checked) .tick svg {
  opacity: 1;
  transform: none;
}

.nominee:has(input:checked) .portrait img {
  transform: scale(1.04);
}

/* ─── Voter: review ───────────────────────────────────── */

.review {
  padding: 28px 0 8px;
}

.review .display:focus {
  outline: none;
}

.picks {
  margin: 28px 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.pick {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  animation: rise 0.5s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 50ms);
}

.pick-portrait {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--wash);
}

.pick-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pick-portrait .initials,
.avatar .initials {
  font-size: 1.15rem;
}

.pick-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.pick-award {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.pick-name {
  font-family: var(--serif);
  font-size: 1.4rem;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.review .form-error {
  margin-top: 18px;
}

/* ─── Admin: avatars & tally ──────────────────────────── */

.avatar {
  display: block;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 50%;
  overflow: hidden;
  background: var(--wash);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar.lg {
  width: 64px;
  height: 64px;
}

.avatar.lg .initials {
  font-size: 1.45rem;
}

.avatar.is-empty {
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.award-num {
  font-style: normal;
  font-size: 1.4rem;
}

.tally-line.has-avatar {
  grid-template-columns: 40px minmax(0, 1fr) auto 4.2em;
  align-items: center;
  gap: 14px;
}

.tally-line.has-avatar + .tally-bar {
  margin-left: 54px;
}

.tally-role {
  display: block;
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--muted);
}

/* ─── Admin: setup ────────────────────────────────────── */

.setup-section + .setup-section {
  margin-top: 48px;
}

.section-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 2rem;
  line-height: 1.1;
}

.section-head p {
  margin: 6px 0 0;
  max-width: 36em;
  color: var(--ink-2);
  font-size: 0.9rem;
}

.exco-list {
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.exco-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.avatar-btn {
  position: relative;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
}

.avatar-btn .avatar {
  transition: box-shadow 0.2s var(--ease);
}

.avatar-btn:hover .avatar {
  box-shadow: 0 0 0 4px var(--wash-2);
}

.avatar-badge {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: var(--white);
  box-shadow: 0 0 0 2px var(--white);
}

.avatar-badge svg {
  width: 14px;
  height: 14px;
}

.exco-fields {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.exco-fields .candidate-input {
  min-height: 40px;
}

.name-input {
  font-weight: 600;
}

.add-exco {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}

.add-exco .field-label {
  margin: 0;
}

.add-exco-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.add-exco .btn {
  justify-self: start;
}

.add-exco .form-error {
  margin: 0;
}

.edit-award .edit-head {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.emoji-input {
  width: 2.3em;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--white);
  text-align: center;
  font-size: 1.5rem;
}

.emoji-input:focus {
  outline: none;
  border-color: var(--teal-700);
  box-shadow: 0 0 0 4px var(--wash-2);
}

.desc-input {
  display: block;
  margin-top: 12px;
  padding: 10px 14px;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.45;
  resize: vertical;
}

/* ─── Admin: photo sheet ──────────────────────────────── */

.photo-preview {
  display: grid;
  justify-items: center;
  gap: 12px;
  margin: 4px 0 0;
}

.photo-preview img {
  width: min(280px, 100%);
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.photo-preview figcaption {
  font-size: 0.85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.sheet-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 28px 0;
  color: var(--ink-2);
}

@media (max-width: 560px) {
  .exco-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .exco-row .edit-tools {
    grid-column: 2;
    justify-content: flex-end;
    margin-top: -4px;
  }

  .add-exco-fields {
    grid-template-columns: 1fr;
  }

  .add-exco .btn {
    justify-self: stretch;
  }

  .tally-line.has-avatar {
    grid-template-columns: 36px minmax(0, 1fr) auto 3.4em;
    gap: 10px;
  }

  .tally-line.has-avatar .avatar {
    width: 36px;
    height: 36px;
  }

  .tally-line.has-avatar + .tally-bar {
    margin-left: 46px;
  }
}

/* Long award titles must stay readable on a phone. */
@media (max-width: 560px) {
  .edit-award .office-input {
    font-size: 1.3rem;
  }
}
