:root {
  --yes: #2e9d5b;
  --no: #d0453a;
  --maybe: #e2a22b;
  --unset: repeating-linear-gradient(45deg, #e2a22b 0 4px, #f2cf86 4px 8px);
  --bg: #fafaf8;
  --card: #fff;
  --fg: #1d1d1b;
  --muted: #76766f;
  --line: #e3e3de;
  --accent: #1d1d1b;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { overflow-x: hidden; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--fg); }
main { max-width: 560px; margin: 0 auto; padding: 16px 20px; }
@media (min-width: 720px) { main { max-width: 960px; } }
footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 24px 16px 40px; }
footer a { color: inherit; }

h1 { font-size: 1.5rem; margin: 8px 0 4px; overflow-wrap: anywhere; }
h2 { font-size: 1.1rem; margin: 0; }
h3 { font-size: 1rem; margin: 0 0 6px; }
.desc { color: var(--muted); margin: 0 0 16px; white-space: pre-line; overflow-wrap: anywhere; }
.hint { font-size: .85rem; color: var(--muted); margin: 0; }
.center { text-align: center; margin: 16px 0; }
.error { color: var(--no); margin: 0; }
.warn { background: #fdf3dc; border-radius: 8px; padding: 8px 10px; font-size: .85rem; margin: 0; }
[hidden] { display: none !important; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 16px 0; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 0; }

label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .9rem; }
input, textarea { font: inherit; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; width: 100%; min-width: 0; }
textarea { resize: vertical; }

button, .button {
  font: inherit; font-size: .95rem; padding: 10px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--fg); cursor: pointer; text-decoration: none; text-align: center; display: inline-block;
}
button:disabled { opacity: .5; cursor: default; }
.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.small, .button.small { padding: 6px 10px; font-size: .85rem; flex: 0 0 auto; }
button.danger { color: var(--no); border-color: currentColor; }
button[aria-pressed=true] { background: var(--accent); color: #fff; border-color: var(--accent); }

/* weekday toggles */
fieldset.weekdays { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
fieldset.weekdays legend { font-weight: 600; font-size: .9rem; margin-bottom: 4px; padding: 0; }
fieldset.weekdays label { font-weight: 500; }
fieldset.weekdays input { position: absolute; opacity: 0; width: 1px; height: 1px; }
fieldset.weekdays span { display: block; text-align: center; padding: 8px 0; border: 1px solid var(--line); border-radius: 8px; font-size: .8rem; cursor: pointer; }
fieldset.weekdays input:checked + span { background: var(--accent); color: #fff; border-color: var(--accent); }
fieldset.weekdays input:focus-visible + span { outline: 2px solid var(--maybe); }

/* calendar */
.calendar { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px 24px; }
@media (min-width: 720px) { .calendar { grid-template-columns: repeat(auto-fill, minmax(260px, 340px)); } }
.month h3 { margin-bottom: 6px; }
.grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.dow { font-size: .7rem; text-align: center; color: var(--muted); }
.day {
  aspect-ratio: 1; min-width: 0; border-radius: 8px; font-size: .95rem; font-weight: 600;
  display: flex; align-items: center; justify-content: center; color: #fff;
  user-select: none; -webkit-tap-highlight-color: transparent;
}
.day.empty { visibility: hidden; }
.day.off { color: #d5d5d0; font-weight: 400; }
.day.out { color: #b9b9b3; font-weight: 400; background: #f1f1ed; }
.day.on { background: var(--accent); }
.day.yes { background: var(--yes); }
.day.no { background: var(--no); }
.day.maybe { background: var(--maybe); }
.day.unset { background: var(--unset); color: #6b4a06; }
.day.stale { opacity: .3; }
.day.active { cursor: pointer; }
.day.active:active { transform: scale(.94); }
.day.active:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .8rem; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.legend i.yes { background: var(--yes); }
.legend i.no { background: var(--no); }
.legend i.maybe { background: var(--maybe); }
.legend i.unset { background: var(--unset); }

/* results */
.results-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.sort { margin-bottom: 10px; }
.sort button { flex: 0 0 auto; padding: 6px 12px; font-size: .85rem; }
.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { border-collapse: separate; border-spacing: 3px; font-size: .85rem; }
th { font-weight: 600; text-align: left; vertical-align: middle; background: var(--card); }
th.date small, th.person small { display: block; font-weight: 400; color: var(--muted); font-size: .72rem; white-space: nowrap; }
th.date .d { white-space: nowrap; }
tbody th, thead th:first-child { position: sticky; left: 0; z-index: 1; padding-right: 8px; }
th.person span { white-space: nowrap; }
tbody th.person span { display: inline-block; max-width: 10em; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
thead th.person { text-align: center; vertical-align: bottom; padding: 0 2px; }
thead th.person span { display: block; max-width: 6em; overflow: hidden; text-overflow: ellipsis; margin: 0 auto; }
th.best .d::after { content: " ★"; color: var(--maybe); }
th.chosen { box-shadow: inset 3px 0 0 var(--yes); padding-left: 6px; }
button.pick { margin-top: 4px; padding: 2px 8px; font-size: .75rem; }
button.remove { border: 0; background: none; color: var(--no); padding: 0 4px; font-size: 1rem; line-height: 1; }
td.cell { width: 2.4em; min-width: 2.4em; height: 2.4em; text-align: center; color: #fff; border-radius: 6px; font-weight: 700; }
td.yes { background: var(--yes); }
td.no { background: var(--no); }
td.maybe { background: var(--maybe); }
td.unset { background: var(--unset); }
td.mine { box-shadow: inset 0 0 0 2px var(--fg); }
tr.mine th { text-decoration: underline; }

/* links */
.link-row { display: flex; gap: 8px; margin-top: 4px; }
.link-row input { flex: 1; font-size: .85rem; padding: 6px 8px; color: var(--muted); }

.banner { border-color: var(--yes); background: #f1faf4; display: flex; flex-direction: column; gap: 8px; }
.banner p { margin: 0; }
.banner > button { align-self: flex-start; }

.final { text-align: center; border-color: var(--yes); }
.final p { margin: 0 0 4px; }
.final-date { font-size: 1.4rem; font-weight: 700; margin-bottom: 12px !important; }
.final .hint { margin-top: 10px; }

details > summary { cursor: pointer; font-weight: 600; }
details[open] > summary { margin-bottom: 12px; }
.tools-actions { margin-top: 16px; }
tbody th.person small { display: inline; }
