:root {
  color-scheme: light dark;
  --bg: #f6f6f3;
  --surface: #ffffff;
  --text: #1c1c1e;
  --muted: #6c6c70;
  --border: #e2e2dc;
  --hover: #efefeb;
  --accent: #1f7a4a;
  --accent-text: #ffffff;
  --focus: #2f6fed;
  --yes: #1a7f45;
  --yes-bg: #e2f3e8;
  --maybe: #8a5d00;
  --maybe-bg: #fbf0d3;
  --no: #7c7c82;
  --no-bg: #f0f0ed;
  --best-bg: #f1f8f3;
  --error: #b42318;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141416;
    --surface: #1e1e21;
    --text: #ececee;
    --muted: #9b9ba1;
    --border: #323238;
    --hover: #2a2a2f;
    --accent: #3fb872;
    --accent-text: #0a1a10;
    --focus: #7aa7ff;
    --yes: #5ccb8a;
    --yes-bg: #173522;
    --maybe: #e6b845;
    --maybe-bg: #392e12;
    --no: #8e8e95;
    --no-bg: #28282c;
    --best-bg: #192a1f;
    --error: #ff8f85;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.top {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 8px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.brand {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}

.brand::before {
  content: "";
  display: inline-block;
  width: 0.7em;
  height: 0.7em;
  margin-right: 0.4em;
  border-radius: 3px;
  background: var(--accent);
}

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

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px 64px;
}

h1 {
  font-size: 1.75rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 16px 0 20px;
  overflow-wrap: anywhere;
}

h2 {
  font-size: 1rem;
  margin: 32px 0 10px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.stack > * + * {
  margin-top: 18px;
}

.field {
  display: grid;
  gap: 6px;
}

.label {
  font-weight: 600;
  font-size: 0.9rem;
}

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

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

button:hover:not(:disabled) {
  background: var(--hover);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

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

.primary:hover:not(:disabled) {
  background: var(--accent);
  filter: brightness(1.08);
}

.link {
  border: none;
  background: none;
  padding: 0;
  color: var(--accent);
  text-decoration: underline;
}

.link:hover:not(:disabled) {
  background: none;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

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

.fine {
  font-size: 0.85rem;
  color: var(--muted);
}

.error {
  color: var(--error);
  margin: 0;
}

.notice {
  background: var(--yes-bg);
  border-radius: 8px;
  padding: 10px 14px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

/* Calendar */

.calendar {
  max-width: 360px;
}

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.cal-head strong {
  text-transform: capitalize;
}

.cal-head button {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 1.2rem;
  line-height: 1;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-wd {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  padding-bottom: 4px;
}

.cal-day {
  aspect-ratio: 1;
  min-height: 40px;
  padding: 0;
  border: none;
  background: none;
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
}

.cal-day.today {
  font-weight: 700;
  box-shadow: inset 0 0 0 1px var(--border);
}

.cal-day[aria-pressed="true"],
.cal-day[aria-pressed="true"]:hover:not(:disabled) {
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

.cal-day:disabled {
  opacity: 0.3;
}

.chips {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  border: none;
  background: var(--yes-bg);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.9rem;
}

.chip:hover:not(:disabled) {
  background: var(--yes-bg);
  filter: brightness(0.96);
}

/* Share */

.share {
  display: flex;
  gap: 8px;
}

.share input {
  min-width: 0;
  flex: 1;
  color: var(--muted);
}

/* Results */

.table-wrap {
  overflow-x: auto;
  margin: -20px;
  padding: 20px;
}

table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 100%;
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: 8px 10px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr:last-child > * {
  border-bottom: none;
}

thead th {
  font-size: 0.85rem;
  font-weight: 600;
  max-width: 8em;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

thead th.mine {
  color: var(--accent);
}

th:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  text-align: left;
}

tbody th {
  font-weight: 500;
}

tr.best > * {
  background: var(--best-bg);
}

.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.7rem;
  font-weight: 700;
  vertical-align: 2px;
}

.tally {
  display: inline-flex;
  gap: 10px;
  font-size: 0.9rem;
}

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

.t-maybe {
  color: var(--maybe);
}

td.a-yes,
td.a-maybe,
td.a-no {
  font-weight: 700;
  border-bottom-color: var(--surface);
}

td.a-yes {
  background: var(--yes-bg);
  color: var(--yes);
}

td.a-maybe {
  background: var(--maybe-bg);
  color: var(--maybe);
}

td.a-no {
  background: var(--no-bg);
  color: var(--no);
}

tr.best td.a-yes {
  background: var(--yes-bg);
}

tr.best td.a-maybe {
  background: var(--maybe-bg);
}

tr.best td.a-no {
  background: var(--no-bg);
}

/* Vote form */

.vote-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  flex-wrap: wrap;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

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

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

.seg label {
  position: relative;
}

.seg label + label {
  border-left: 1px solid var(--border);
}

.seg input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.seg span {
  display: block;
  padding: 7px 14px;
  font-size: 0.9rem;
  min-width: 4.2em;
  text-align: center;
}

.seg label:hover span {
  background: var(--hover);
}

.seg input:focus-visible + span {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.seg .yes input:checked + span {
  background: var(--yes-bg);
  color: var(--yes);
  font-weight: 700;
}

.seg .maybe input:checked + span {
  background: var(--maybe-bg);
  color: var(--maybe);
  font-weight: 700;
}

.seg .no input:checked + span {
  background: var(--no-bg);
  color: var(--text);
  font-weight: 700;
}

.voted {
  margin: 0 0 8px;
}

@media (max-width: 480px) {
  .card {
    padding: 16px;
  }

  .table-wrap {
    margin: -16px;
    padding: 16px;
  }

  th,
  td {
    padding: 8px 6px;
  }

  .tally {
    gap: 6px;
  }
}
