:root {
  --bg: #fbf8f3;
  --surface: #ffffff;
  --text: #22201c;
  --muted: #6b665d;
  --border: #e6e0d6;
  --accent: #b3261e;
  --accent-text: #ffffff;
  --yes: #1f7a4d;
  --yes-soft: #dff1e7;
  --maybe: #a86b00;
  --maybe-soft: #fbeccc;
  --no-soft: #f1eee9;
  --no: #b3261e;
  --no-tint: #fbe3e1;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171513;
    --surface: #221f1c;
    --text: #f1ede6;
    --muted: #a59e93;
    --border: #3a3530;
    --accent: #e0574d;
    --yes: #5cc28d;
    --yes-soft: #1d3a2b;
    --maybe: #e8b04a;
    --maybe-soft: #3d3020;
    --no-soft: #2b2724;
    --no: #ff8a80;
    --no-tint: #45211e;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.45;
}

a {
  color: var(--accent);
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px 120px;
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 720px;
  margin: 0 auto;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
}

.brand a {
  color: inherit;
  text-decoration: none;
}

.brand img {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

h1 {
  font-size: 1.6rem;
  margin: 8px 0 4px;
}

h2 {
  font-size: 1.15rem;
  margin: 24px 0 8px;
}

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

.small {
  font-size: 0.875rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 12px 0;
}

.events {
  margin: 8px 0 0;
  padding-left: 20px;
}

/* ---------- form controls ---------- */

label {
  display: block;
  font-weight: 600;
  margin: 12px 0 4px;
}

input[type="text"],
input[type="password"],
input[type="date"],
textarea {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

textarea {
  min-height: 70px;
  resize: vertical;
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 8px 14px;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

button.danger {
  color: var(--accent);
}

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

.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.error {
  color: var(--accent);
  font-weight: 600;
}

/* ---------- tabs ---------- */

.tabs {
  display: flex;
  gap: 4px;
  margin: 16px 0;
  border-bottom: 1px solid var(--border);
}

.tabs button {
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: none;
  padding: 10px 14px;
  font-weight: 600;
  color: var(--muted);
}

.tabs button.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* ---------- voting ---------- */

.legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.875rem;
  color: var(--muted);
}

.week-heading {
  margin: 20px 0 4px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.day {
  padding: 10px 14px;
  margin: 8px 0;
}

.day-title {
  font-weight: 700;
  margin-bottom: 6px;
}

.day.weekend .day-title::after {
  content: "Weekend";
  margin-left: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

.slot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid var(--border);
}

.day-title + .slot {
  border-top: none;
}

.slot-time {
  min-width: 110px;
  font-size: 0.95rem;
}

.choices {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.choices button {
  border: none;
  border-radius: 0;
  border-left: 1px solid var(--border);
  padding: 8px 10px;
  font-size: 0.85rem;
  background: var(--surface);
  white-space: nowrap;
}

.choices button:first-child {
  border-left: none;
}

.choices button[data-answer="yes"].selected {
  background: var(--yes);
  color: #fff;
}

.choices button[data-answer="maybe"].selected {
  background: var(--maybe);
  color: #fff;
}

.choices button[data-answer="no"].selected {
  background: var(--no-tint);
  color: var(--no);
  font-weight: 600;
}

.quick-fill {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.quick-fill button {
  font-size: 0.85rem;
  padding: 6px 10px;
}

.save-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
}

.save-bar-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ---------- results ---------- */

.result {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
}

.result-when {
  font-weight: 700;
}

.counts {
  display: flex;
  gap: 6px;
  align-items: start;
}

.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

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

.pill.no {
  background: var(--no-tint);
  color: var(--no);
}

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

.names {
  grid-column: 1 / -1;
  font-size: 0.875rem;
  color: var(--muted);
}

.names .yes-name {
  color: var(--yes);
  font-weight: 600;
}

.names .maybe-name {
  color: var(--maybe);
}

.bar {
  grid-column: 1 / -1;
  display: flex;
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--no-soft);
}

.bar .yes {
  background: var(--yes);
}

.bar .maybe {
  background: var(--maybe);
}

/* ---------- organizer ---------- */

.skip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 4px 12px;
  margin-top: 6px;
}

.skip-grid label {
  font-weight: 400;
  margin: 0;
  display: flex;
  gap: 6px;
  align-items: center;
}

.poll-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

@media (max-width: 480px) {
  .slot {
    flex-direction: column;
    align-items: stretch;
  }

  .choices {
    display: flex;
  }

  .choices button {
    flex: 1;
  }
}

/* ---------- results order picker ---------- */

.select-wrap {
  position: relative;
}

.select-wrap::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.select-wrap select {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 40px 8px 16px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.06);
}

.select-wrap select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- holiday touches ---------- */

.everyone-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  background: #f6c343;
  color: #3b2a00;
  font-size: 0.75rem;
  font-weight: 700;
  vertical-align: 2px;
}

/* A string of lights under the header that slowly chases. */
.lights {
  height: 10px;
  background-image: radial-gradient(circle, #e0574d 3px, transparent 3.5px), radial-gradient(circle, #5cc28d 3px, transparent 3.5px),
    radial-gradient(circle, #f6c343 3px, transparent 3.5px), radial-gradient(circle, #6aa8ff 3px, transparent 3.5px);
  background-size: 96px 10px;
  background-position: 0 0, 24px 0, 48px 0, 72px 0;
  background-repeat: repeat-x;
  animation: chase 6s linear infinite;
}

@keyframes chase {
  to {
    background-position: 96px 0, 120px 0, 144px 0, 168px 0;
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%);
  z-index: 20;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 999px;
  background: #1f7a4d;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.25);
  text-align: center;
  animation: toast-in 0.3s ease-out;
  transition: opacity 0.4s, transform 0.4s;
}

.toast.leaving {
  opacity: 0;
  transform: translate(-50%, 12px);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 12px);
  }
}

.snow-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 30;
}

.flake {
  position: absolute;
  top: -40px;
  animation-name: fall;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

@keyframes fall {
  to {
    transform: translate(var(--drift), 110vh) rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .lights {
    animation: none;
  }
}

.organizer-box {
  margin-bottom: 8px;
  padding: 10px 12px;
  border: 1px dashed var(--accent);
  border-radius: 8px;
}

.names .no-name {
  color: var(--no);
}

.template-box {
  margin: 8px 0;
}

.time-row {
  margin: 6px 0;
}

.time-row input[type="time"] {
  width: auto;
  flex: 1;
  min-width: 110px;
}
