:root {
  --paper: #f5efdf;
  --paper-deep: #e9dfc7;
  --ink: #172c45;
  --muted: #65717a;
  --red: #e33b2f;
  --green: #218561;
  --line: #c9c2af;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 10%, rgba(255, 255, 255, .72), transparent 27%),
    repeating-linear-gradient(90deg, rgba(23, 44, 69, .018) 0 1px, transparent 1px 5px),
    var(--paper);
  font-family: "DM Sans", sans-serif;
}

button,
select,
input {
  font: inherit;
}

.page-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding-bottom: 64px;
}

.masthead {
  min-height: 112px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  font: 17px/15px "Archivo Black", sans-serif;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: var(--paper);
  background: var(--red);
  border-radius: 50%;
  transform: rotate(-8deg);
  font-size: 23px;
}

.eyebrow,
.step-label,
.preview-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .18em;
}

.eyebrow {
  color: var(--muted);
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 590px) 1fr;
  padding: clamp(48px, 7vw, 88px) 0 52px;
  align-items: start;
}

.step-label {
  margin: 13px 0 0;
  color: var(--red);
}

h1 {
  margin: 0;
  font: clamp(48px, 7vw, 88px)/.92 "Archivo Black", sans-serif;
  letter-spacing: -.055em;
  text-transform: uppercase;
}

h1 em {
  color: var(--red);
  font-style: normal;
}

.intro-copy {
  max-width: 290px;
  margin: 12px 0 0 auto;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.55;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 680px) minmax(290px, 360px);
  gap: clamp(56px, 8vw, 110px);
  align-items: start;
}

.candidate-form {
  border-top: 3px solid var(--ink);
  padding-top: 29px;
}

.state-field label {
  display: block;
  margin-bottom: 11px;
  font-size: 14px;
  font-weight: 700;
}

.select-wrap {
  position: relative;
}

.select-wrap select {
  width: 100%;
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 17px 48px 17px 17px;
  color: var(--ink);
  background: rgba(255, 255, 255, .25);
  outline: none;
  cursor: pointer;
}

.select-wrap span {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

.select-wrap select:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink);
}

.divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 38px 0 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .16em;
}

.divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--line);
}

.data-status {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.data-status.ready {
  color: var(--green);
}

.data-status.error {
  color: var(--red);
}

.candidate-row {
  display: grid;
  grid-template-columns: 190px 1fr;
  align-items: center;
  min-height: 112px;
  border-bottom: 1px solid var(--line);
}

.candidate-meta strong {
  display: block;
  font-family: "Archivo Black", sans-serif;
  font-size: 17px;
  text-transform: uppercase;
}

.candidate-meta span {
  color: var(--muted);
  font-size: 12px;
}

.vote-options {
  display: grid;
  gap: 5px;
  margin-top: 12px;
}

.vote-options button {
  width: max-content;
  border: 0;
  padding: 3px 0;
  color: var(--muted);
  background: transparent;
  font-size: 10px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.vote-options button::before {
  content: "○";
  display: inline-block;
  width: 16px;
  color: var(--line);
}

.vote-options button:hover {
  color: var(--ink);
}

.vote-options button.selected {
  color: var(--red);
}

.vote-options button.selected::before {
  content: "●";
  color: var(--red);
}

.candidate-entry {
  padding: 18px 0;
}

.candidate-search-wrap {
  position: relative;
  margin-bottom: 12px;
}

.candidate-search {
  width: 100%;
  height: 39px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 8px 32px 8px 3px;
  color: var(--ink);
  background: transparent;
  outline: none;
  font-size: 12px;
}

.candidate-search:focus {
  border-color: var(--ink);
}

.candidate-search:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.candidate-search-wrap>span {
  position: absolute;
  top: 7px;
  right: 6px;
  color: var(--muted);
  font-size: 20px;
  pointer-events: none;
}

.search-results {
  display: none;
  position: absolute;
  z-index: 10;
  top: 42px;
  right: 0;
  width: 100%;
  max-height: 245px;
  overflow-y: auto;
  border: 1px solid var(--ink);
  background: #fffaf0;
  box-shadow: 7px 7px 0 rgba(23, 44, 69, .14);
}

.search-results.open {
  display: block;
}

.search-results button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.search-results button:hover,
.search-results button:focus {
  background: var(--paper-deep);
  outline: none;
}

.search-results button span {
  display: grid;
  gap: 2px;
}

.search-results button strong {
  font-size: 11px;
  text-transform: uppercase;
}

.search-results button small {
  color: var(--muted);
  font-size: 10px;
}

.search-results button b {
  font-family: "Archivo Black", sans-serif;
  font-size: 16px;
}

.search-results p {
  margin: 0;
  padding: 14px 12px;
  color: var(--red);
  font-size: 11px;
}

.digit-group {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.digit {
  width: clamp(42px, 5vw, 56px);
  height: 62px;
  border: 1px solid #aaa691;
  border-radius: 3px;
  color: var(--ink);
  background: rgba(255, 255, 255, .32);
  text-align: center;
  font: 28px/1 "Archivo Black", sans-serif;
  caret-color: transparent;
  outline: none;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}

.digit:focus {
  border: 2px solid var(--red);
  background: #fffaf0;
  transform: translateY(-2px);
}

.digit.filled {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.digit:disabled {
  opacity: .3;
  cursor: not-allowed;
}

.candidate-match {
  min-height: 18px;
  margin: 9px 0 0;
  text-align: right;
  font-size: 12px;
}

.candidate-match strong {
  font-weight: 700;
  text-transform: uppercase;
}

.candidate-match span {
  color: var(--muted);
}

.candidate-match.not-found {
  color: var(--red);
}

.candidate-row.invalid .digit {
  border-color: var(--red);
}

.form-message {
  min-height: 20px;
  margin: 18px 0 6px;
  color: var(--red);
  font-size: 13px;
  font-weight: 600;
}

.action-buttons {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 10px;
}

.print-button,
.save-button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  border: 0;
  padding: 20px 22px;
  font-family: "Archivo Black", sans-serif;
  cursor: pointer;
  transition: background .2s ease, transform .2s ease;
}

.print-button {
  color: var(--paper);
  background: var(--red);
}

.save-button {
  border: 1px solid var(--ink);
  color: var(--ink);
  background: transparent;
}

.print-button:hover:not(:disabled) {
  background: #c92c23;
  transform: translateY(-2px);
}

.save-button:hover:not(:disabled) {
  color: var(--paper);
  background: var(--ink);
  transform: translateY(-2px);
}

.print-button:disabled,
.save-button:disabled {
  border-color: transparent;
  color: #8c918e;
  background: #d9d3c2;
  cursor: not-allowed;
}

.preview-column {
  position: sticky;
  top: 30px;
}

.preview-label {
  margin: 0 0 13px;
  color: var(--muted);
}

.ballot-card {
  position: relative;
  overflow: hidden;
  min-height: 550px;
  padding: 25px;
  color: #fff9e9;
  background: var(--ink);
  box-shadow: 14px 14px 0 var(--red);
  transform: rotate(1deg);
}

.ballot-card::before {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  right: -85px;
  top: 70px;
  border: 24px solid rgba(245, 239, 223, .08);
  border-radius: 50%;
}

.ballot-topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(245, 239, 223, .28);
  font-size: 10px;
  letter-spacing: .15em;
}

.ballot-topline strong {
  display: grid;
  place-items: center;
  min-width: 36px;
  min-height: 36px;
  padding: 5px;
  border-radius: 50%;
  color: var(--ink);
  background: var(--paper);
  font-family: "Archivo Black", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

.ballot-card h2 {
  margin: 27px 0 24px;
  font: 33px/.95 "Archivo Black", sans-serif;
  letter-spacing: -.035em;
}

.preview-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  align-items: baseline;
  padding: 9px 0;
  border-bottom: 1px dashed rgba(245, 239, 223, .25);
}

.preview-item span {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .1em;
}

.preview-item strong {
  font: 21px/1 "Archivo Black", sans-serif;
  letter-spacing: .12em;
}

.preview-item strong.empty {
  opacity: .25;
}

.preview-item small {
  grid-column: 1 / -1;
  min-height: 13px;
  color: var(--paper-deep);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.ballot-card footer {
  position: absolute;
  left: 25px;
  right: 25px;
  bottom: 23px;
  display: flex;
  justify-content: space-between;
  align-items: end;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .1em;
}

.ballot-card footer b {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: var(--ink);
  background: #f2c84b;
  font-size: 24px;
}

.privacy-note {
  margin-top: 26px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.privacy-note span {
  color: var(--green);
  font-size: 8px;
}

@media (max-width: 820px) {
  .page-shell {
    width: min(100% - 28px, 680px);
  }

  .masthead {
    min-height: 90px;
  }

  .eyebrow {
    display: none;
  }

  .intro {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 46px 0 38px;
  }

  .step-label {
    margin: 0;
  }

  .intro-copy {
    margin: 0;
  }

  .workspace {
    grid-template-columns: 1fr;
    gap: 62px;
  }

  .preview-column {
    position: static;
    width: min(100%, 360px);
    margin: 0 auto;
  }
}

@media (max-width: 520px) {
  .action-buttons {
    grid-template-columns: 1fr;
  }

  .candidate-row {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 21px 0;
  }

  .candidate-entry {
    padding: 0;
  }

  .digit-group {
    justify-content: flex-start;
    gap: 6px;
  }

  .candidate-match {
    text-align: left;
  }

  .digit {
    width: min(52px, calc((100vw - 64px) / 5));
    height: 58px;
  }
}

@media print {
  body {
    background: white;
  }

  .masthead,
  .intro,
  .candidate-form,
  .preview-label,
  .privacy-note {
    display: none;
  }

  .page-shell,
  .workspace,
  .preview-column {
    width: auto;
    margin: 0;
    display: block;
  }

  .ballot-card {
    width: 90mm;
    min-height: 130mm;
    margin: 10mm auto;
    box-shadow: none;
    transform: none;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    transition: none !important;
  }
}
