@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,600&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@500&display=swap');

:root {
  --paper: #efe8d6;
  --paper-card: #fbf8ef;
  --line: #d9ceb0;
  --ink: #1c2541;
  --ink-soft: #4a5169;
  --stamp: #2f5233;
  --stamp-dark: #1f3a24;
  --error: #a13d2c;
  --radius: 3px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  background-image:
    radial-gradient(circle, rgba(28,37,65,0.06) 1px, transparent 1px);
  background-size: 14px 14px;
  color: var(--ink);
  font-family: 'IBM Plex Sans', sans-serif;
  display: flex;
  justify-content: center;
  padding: 48px 20px 80px;
}

.ballot {
  width: 100%;
  max-width: 560px;
}

.ballot-header {
  text-align: left;
  margin-bottom: 28px;
}

.ballot-eyebrow {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  margin: 0 0 6px;
}

.ballot-question {
  font-family: 'Fraunces', serif;
  font-size: 32px;
  font-weight: 600;
  line-height: 1.2;
  margin: 0;
  color: var(--ink);
}

.card {
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  position: relative;
}

.card::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 24px;
  right: 24px;
  height: 6px;
  background-image: radial-gradient(circle, var(--paper) 2.5px, transparent 2.5px);
  background-size: 14px 6px;
  background-repeat: repeat-x;
}

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

.option-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.option-row:last-child { border-bottom: none; }

.bubble {
  width: 22px;
  height: 22px;
  min-width: 22px;
  border-radius: 50%;
  border: 2px solid var(--ink-soft);
  position: relative;
  transition: border-color 0.15s ease;
}

.bubble::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--stamp);
  transform: scale(0);
  transition: transform 0.15s ease;
}

.option-row.selected .bubble {
  border-color: var(--stamp);
}

.option-row.selected .bubble::after {
  transform: scale(1);
}

.option-label {
  font-size: 16px;
  color: var(--ink);
}

.category-block {
  padding: 8px 4px 4px;
}

.category-label {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 16px;
  line-height: 1.3;
}

.progress-text {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--ink-soft);
  margin: 0 0 8px;
}

.progress-track {
  height: 6px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 24px;
}

.progress-fill {
  height: 100%;
  background: var(--stamp);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.nav-row {
  display: flex;
  gap: 10px;
  margin-top: 26px;
}

.nav-row .stamp-button {
  margin-top: 0;
  flex: 1;
}

.nav-row .secondary-button {
  flex: 0 0 auto;
}

.category-select {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 15px;
  background: #fff;
  color: var(--ink);
  margin-bottom: 22px;
}

.writein-block {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px dashed var(--line);
}

.writein-label {
  font-size: 13px;
  color: var(--ink-soft);
  display: block;
  margin-bottom: 8px;
}

.writein-input {
  width: 100%;
  border: none;
  border-bottom: 2px solid var(--ink-soft);
  background: transparent;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 16px;
  padding: 6px 2px;
  color: var(--ink);
}

.writein-input:focus {
  outline: none;
  border-bottom-color: var(--stamp);
}

.stamp-button {
  margin-top: 26px;
  width: 100%;
  background: var(--ink);
  color: var(--paper-card);
  border: none;
  border-radius: var(--radius);
  padding: 14px 18px;
  font-family: 'IBM Plex Sans', sans-serif;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
}

.stamp-button:hover { background: var(--stamp-dark); }
.stamp-button:active { transform: scale(0.98); }
.stamp-button:disabled { opacity: 0.5; cursor: not-allowed; }

.status-msg {
  margin-top: 14px;
  font-size: 14px;
  min-height: 18px;
}

.status-msg.error { color: var(--error); }
.status-msg.ok { color: var(--stamp); }

.result-row {
  margin-bottom: 16px;
}

.result-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
  font-size: 15px;
}

.result-count {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  color: var(--ink-soft);
  white-space: nowrap;
  margin-left: 12px;
}

.result-track {
  height: 10px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}

.result-fill {
  height: 100%;
  background: var(--stamp);
  border-radius: 2px;
  transition: width 0.5s ease;
}

.footer-link {
  display: block;
  text-align: center;
  margin-top: 24px;
  font-size: 13px;
  color: var(--ink-soft);
  text-decoration: none;
}

.footer-link:hover { color: var(--ink); }

.results-section {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px dashed var(--line);
}

.results-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.results-section-title {
  font-family: 'Fraunces', serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 14px;
}

.total-votes {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 24px;
  text-align: right;
}

.admin-field {
  margin-bottom: 18px;
}

.admin-field label {
  display: block;
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.admin-field input[type="text"],
.admin-field input[type="password"] {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 15px;
  background: #fff;
}

.admin-list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}

.admin-list-row button {
  background: none;
  border: none;
  color: var(--error);
  cursor: pointer;
  font-size: 13px;
  font-family: 'IBM Plex Sans', sans-serif;
}

.inline-row {
  display: flex;
  gap: 10px;
}

.inline-row input { flex: 1; }

.secondary-button {
  background: var(--paper-card);
  border: 1px solid var(--ink);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-family: 'IBM Plex Sans', sans-serif;
  font-weight: 500;
  cursor: pointer;
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
}
