:root {
  color-scheme: light dark;
  --bg: #f5f6fb;
  --bg-tint: #e9ecff;
  --surface: #ffffff;
  --surface-soft: #f7f8fd;
  --text: #13172a;
  --muted: #5b6279;
  --faint: #8990a5;
  --line: #e0e4ef;
  --line-strong: #cbd1e2;
  --brand: #4f46e5;
  --brand-strong: #4338ca;
  --brand-soft: #eef0ff;
  --brand-ink: #3730a3;
  --success: #0b7a5c;
  --success-soft: #e5f7f0;
  --danger: #b42318;
  --danger-soft: #fef1f0;
  --track: #e8eaf2;
  --shadow: 0 1px 2px rgb(16 24 40 / 4%), 0 18px 44px -24px rgb(30 41 89 / 28%);
  --radius: 20px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #090d1a;
    --bg-tint: #121a35;
    --surface: #111629;
    --surface-soft: #161c32;
    --text: #eef1fb;
    --muted: #a5adc4;
    --faint: #7d86a1;
    --line: #252d47;
    --line-strong: #38415f;
    --brand: #8b8cf7;
    --brand-strong: #a5a6ff;
    --brand-soft: #1b2145;
    --brand-ink: #c7c8ff;
    --success: #5ce0b5;
    --success-soft: #102c26;
    --danger: #ff8f86;
    --danger-soft: #321a1c;
    --track: #232a43;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 22px 50px -24px rgb(0 0 0 / 65%);
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(56rem 32rem at 12% -12%, var(--bg-tint) 0%, transparent 60%),
    radial-gradient(44rem 30rem at 105% 6%, rgb(129 140 248 / 12%) 0%, transparent 55%),
    var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--brand-ink);
  text-underline-offset: 3px;
}

.site-header,
.site-footer {
  width: 100%;
  max-width: 44rem;
  margin: 0 auto;
  padding: 1.35rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.site-header {
  justify-content: space-between;
}

.site-footer {
  margin-top: auto;
  color: var(--faint);
  font-size: 0.8rem;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
}

.footer-note {
  opacity: 0.85;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand-mark {
  width: 2rem;
  height: 2rem;
  border-radius: 9px;
  box-shadow: 0 6px 16px -8px rgb(79 70 229 / 75%);
}

.tagline {
  color: var(--faint);
  font-size: 0.82rem;
}

.app {
  width: 100%;
  max-width: 44rem;
  margin: 0 auto;
  padding: 0.5rem 1.25rem 2.5rem;
  outline: none;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem;
  margin-bottom: 1rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--brand-ink);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 0.6rem;
  font-size: clamp(1.55rem, 4.5vw, 2.1rem);
  line-height: 1.16;
  letter-spacing: -0.03em;
}

h2 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
  letter-spacing: -0.015em;
}

p {
  margin: 0 0 0.85rem;
}

.lede {
  color: var(--muted);
  font-size: 1rem;
  max-width: 36rem;
}

.hint {
  color: var(--faint);
  font-size: 0.82rem;
  margin: 0.9rem 0 0;
}

.form {
  margin-top: 0.5rem;
}

.field {
  margin-bottom: 1.15rem;
  min-width: 0;
  border: 0;
  padding: 0;
}

.field > label,
.field > legend,
.field-label {
  display: block;
  margin-bottom: 0.42rem;
  font-size: 0.83rem;
  font-weight: 650;
  color: var(--muted);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  min-height: 2.9rem;
  padding: 0.62rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}

select {
  cursor: pointer;
}

input::placeholder {
  color: var(--faint);
}

input[type="text"]:focus-visible,
input[type="number"]:focus-visible,
select:focus-visible,
button:focus-visible,
a:focus-visible,
.option:has(input:focus-visible) {
  outline: 3px solid color-mix(in srgb, var(--brand) 40%, transparent);
  outline-offset: 2px;
}

.option-fields {
  display: grid;
  gap: 0.55rem;
  margin-bottom: 0.65rem;
}

.option-field {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.option-field input {
  flex: 1;
}

.icon-button {
  flex: none;
  width: 2.55rem;
  height: 2.55rem;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
}

.icon-button:hover:not(:disabled) {
  background: var(--surface-soft);
  color: var(--text);
}

.icon-button:disabled {
  opacity: 0.35;
  cursor: default;
}

.button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.9rem;
  padding: 0.65rem 1.15rem;
  border: 1px solid transparent;
  border-radius: 12px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.button:active:not(:disabled) {
  transform: translateY(1px);
}

.button:disabled {
  opacity: 0.6;
  cursor: default;
}

.primary {
  background: var(--brand);
  color: #ffffff;
  box-shadow: 0 10px 22px -12px color-mix(in srgb, var(--brand) 80%, transparent);
}

.primary:hover:not(:disabled) {
  background: var(--brand-strong);
}

@media (prefers-color-scheme: dark) {
  .primary {
    color: #0b1020;
  }
}

.ghost {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--text);
}

.ghost:hover:not(:disabled) {
  background: var(--surface-soft);
}

.danger {
  background: transparent;
  border-color: color-mix(in srgb, var(--danger) 45%, var(--line));
  color: var(--danger);
}

.danger:hover:not(:disabled) {
  background: var(--danger-soft);
}

.text-button {
  appearance: none;
  border: 0;
  background: none;
  padding: 0.3rem 0;
  color: var(--brand-ink);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.text-button:hover:not(:disabled) {
  text-decoration: underline;
}

.text-button:disabled {
  color: var(--faint);
  cursor: default;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.stack-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.1rem;
}

.form-error,
.form-message {
  border-radius: 12px;
  padding: 0.7rem 0.9rem;
  font-size: 0.87rem;
  margin: 0 0 0.9rem;
}

.form-error {
  background: var(--danger-soft);
  color: var(--danger);
}

.form-message {
  background: var(--success-soft);
  color: var(--success);
}

.form-error[hidden] {
  display: none;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
  padding: 0.28rem 0.62rem;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pill::before {
  content: "";
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  background: currentColor;
}

.pill-success {
  background: var(--success-soft);
  color: var(--success);
}

.pill-muted {
  background: var(--surface-soft);
  color: var(--muted);
}

.poll-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.1rem;
  margin-bottom: 0.85rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.poll-meta strong {
  color: var(--text);
  font-weight: 650;
}

.meter {
  margin-bottom: 1.3rem;
}

.meter progress,
.result-row progress {
  display: block;
  width: 100%;
  height: 0.55rem;
  appearance: none;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  background: var(--track);
}

.meter progress::-webkit-progress-bar,
.result-row progress::-webkit-progress-bar {
  background: var(--track);
  border-radius: 999px;
}

.meter progress::-webkit-progress-value,
.result-row progress::-webkit-progress-value {
  background: linear-gradient(90deg, var(--brand), color-mix(in srgb, var(--brand) 60%, #a5b4fc));
  border-radius: 999px;
}

.meter progress::-moz-progress-bar,
.result-row progress::-moz-progress-bar {
  background: linear-gradient(90deg, var(--brand), color-mix(in srgb, var(--brand) 60%, #a5b4fc));
  border-radius: 999px;
}

.vote-options {
  display: grid;
  gap: 0.6rem;
  margin: 0.3rem 0 1.25rem;
}

.option {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface-soft);
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.option:hover {
  border-color: var(--brand);
}

.option input {
  flex: none;
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--brand);
}

.option:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: inset 0 0 0 1px var(--brand);
}

.option-text {
  overflow-wrap: anywhere;
}

.voted-choice {
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
}

.voted-choice strong {
  font-weight: 700;
}

.waiting {
  color: var(--muted);
  margin-bottom: 1.15rem;
}

.results {
  display: grid;
  gap: 0.85rem;
  margin: 1.15rem 0 1.35rem;
}

.result-row {
  display: grid;
  gap: 0.35rem;
  padding: 0.5rem 0.65rem;
  border-radius: 12px;
}

.result-row.is-mine {
  background: var(--brand-soft);
}

.result-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.92rem;
}

.result-label {
  overflow-wrap: anywhere;
}

.result-count {
  flex: none;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.84rem;
}

.result-count strong {
  color: var(--text);
  font-size: 1rem;
}

.you-tag {
  display: inline-block;
  margin-left: 0.45rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--brand);
  color: #ffffff;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: 0.1em;
}

@media (prefers-color-scheme: dark) {
  .you-tag {
    color: #0b1020;
  }
}

.summary {
  color: var(--muted);
  font-size: 0.9rem;
}

.share-link {
  margin: 1rem 0 1.1rem;
  padding: 0.85rem 0.95rem;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: var(--surface-soft);
  overflow-wrap: anywhere;
  font-size: 0.92rem;
}

.share-url {
  font-weight: 600;
}

.admin-card {
  background: var(--surface-soft);
  box-shadow: none;
  padding: 1.25rem 1.4rem;
}

.admin-card h2 {
  font-size: 0.95rem;
  margin-bottom: 0.15rem;
}

.admin-card p {
  color: var(--faint);
  font-size: 0.82rem;
  margin-bottom: 0.9rem;
}

.empty-card .button {
  margin-top: 0.4rem;
}

.loading {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  color: var(--muted);
  padding: 2.4rem 1.75rem;
}

.spinner {
  width: 1.2rem;
  height: 1.2rem;
  border: 2px solid var(--line-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.noscript {
  max-width: 44rem;
  margin: 0 auto 2rem;
  padding: 0 1.25rem;
  color: var(--danger);
}

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

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

@media (max-width: 34rem) {
  .tagline {
    display: none;
  }

  .card {
    padding: 1.35rem;
    border-radius: 17px;
  }

  .field-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .button {
    width: 100%;
  }

  .button-row .button,
  .stack-actions .button {
    flex: 1 1 auto;
  }

  .icon-button {
    width: 2.75rem;
    height: 2.75rem;
  }
}

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