:root {
  --bg: #f7f2ea;
  --card: #ffffff;
  --ink: #1f2a24;
  --muted: #6b746e;
  --line: #e6dfd3;
  --accent: #c0392b;
  --green: #2f6b4f;
  --yes: #d9efe1;
  --yes-ink: #1d5c3c;
  --maybe: #fbedc4;
  --maybe-ink: #7a5a00;
  --no: #f6d6d2;
  --no-ink: #8c2a1f;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(31,42,36,.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111613;
    --card: #1a211d;
    --ink: #eef0ec;
    --muted: #9aa49e;
    --line: #2b342f;
    --yes: #1f3f2e;
    --yes-ink: #a9e2c1;
    --maybe: #423813;
    --maybe-ink: #f2d77a;
    --no: #45231f;
    --no-ink: #f3aea5;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--green); }
@media (prefers-color-scheme: dark) { a { color: #7cc7a0; } }
h1, h2 { margin: 0 0 12px; line-height: 1.2; }
h2 { font-size: 1.15rem; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.top { border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.top .wrap { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { font-weight: 700; color: var(--ink); text-decoration: none; }
.nav { display: flex; gap: 14px; font-size: .95rem; }
.nav a { color: var(--muted); text-decoration: none; }
.nav a:hover, .nav a[aria-current] { color: var(--ink); }
.nav a[aria-current] { font-weight: 600; }
@media (max-width: 480px) { .brand { font-size: .9rem; } .nav { gap: 10px; font-size: .85rem; } }

/* login + admin */
.login { max-width: 360px; margin: 40px auto; text-align: center; }
.pin {
  font: inherit; font-size: 2rem; letter-spacing: .5em; text-align: center; text-indent: .5em;
  width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink);
}
.pin:focus { outline: 2px solid var(--green); outline-offset: 1px; }
.error { color: var(--no-ink); background: var(--no); border-radius: 8px; padding: 6px 10px; }
.notice { background: var(--yes); color: var(--yes-ink); border-radius: 10px; padding: 10px 14px; }
.pins { max-width: 320px; }
.pins th { text-align: left; }
.pins code { font-size: 1.15rem; letter-spacing: .1em; }
.btn.danger { color: var(--no-ink); border-color: var(--no); }

.grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 820px) { .grid { grid-template-columns: 1fr 1fr; } }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  min-width: 0;
}
.grid .card { margin-bottom: 0; }
.grid { margin-bottom: 16px; }
.hint { color: var(--muted); font-size: .9rem; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 16px 0 8px; }

.btn {
  font: inherit; cursor: pointer; border-radius: 10px; padding: 10px 16px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
}
.btn:disabled { opacity: .5; cursor: default; }
.btn-ghost:hover { border-color: var(--muted); }
.btn-spin {
  display: block; width: 100%; max-width: 320px; margin: 12px auto 0;
  background: var(--accent); border-color: var(--accent); color: #fff;
  font-weight: 700; font-size: 1.05rem; padding: 14px;
}
.btn-spin:not(:disabled):hover { filter: brightness(1.08); }
.btn-spin:not(:disabled):active { transform: translateY(1px); }

/* wheel */
.wheel-card { text-align: center; }
.wheel { max-width: 340px; margin: 0 auto; }
.wheel svg { width: 100%; height: auto; display: block; }
.wheel-rim { fill: var(--ink); }
.wheel-hub { fill: var(--card); stroke: var(--ink); stroke-width: 4; }
.wheel-pointer { fill: var(--ink); stroke: var(--card); stroke-width: 2; }
.wheel-label { fill: #fff; font-weight: 700; letter-spacing: .01em; }
#wheel-rot path { stroke: rgba(255,255,255,.85); stroke-width: 2; }
.wheel-status { min-height: 3.4em; margin-top: 10px; font-size: 1.1rem; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.wheel-status.countdown { color: var(--accent); font-weight: 600; }
.wheel-status.spinning { font-size: 1.4rem; font-weight: 700; }
.wheel-status.done strong { font-size: 1.6rem; }
.wheel-status small { color: var(--muted); font-size: .85rem; }
.history { margin-top: 14px; text-align: left; font-size: .9rem; color: var(--muted); }
.history ol { margin: 6px 0 0; padding-left: 20px; }

/* tags */
.tag { display: inline-block; padding: 0 8px; border-radius: 999px; background: var(--line); font-size: .85em; white-space: nowrap; }
.tag.yes { background: var(--yes); color: var(--yes-ink); }
.tag.maybe { background: var(--maybe); color: var(--maybe-ink); }
.tag.no { background: var(--no); color: var(--no-ink); }

/* calendar */
.weekdays, .calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.weekdays { margin-bottom: 6px; font-size: .75rem; color: var(--muted); text-align: center; text-transform: uppercase; letter-spacing: .04em; }
.day {
  font: inherit; cursor: pointer; aspect-ratio: 1; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  padding: 0; transition: transform .08s;
}
.day:active { transform: scale(.94); }
.day b { font-size: 1.05rem; }
.day span { font-size: .85rem; line-height: 1; opacity: .8; }
.day.empty span { opacity: .35; }
.day.yes { background: var(--yes); color: var(--yes-ink); border-color: transparent; }
.day.maybe { background: var(--maybe); color: var(--maybe-ink); border-color: transparent; }
.day.no { background: var(--no); color: var(--no-ink); border-color: transparent; }
.save-status { color: var(--muted); font-size: .85rem; margin-left: auto; }

/* best dates */
.best-row { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); margin-bottom: 8px; }
.best-row span { color: var(--muted); }
.best-row.top { background: var(--yes); color: var(--yes-ink); border-color: transparent; }
.best-row.top span { color: inherit; }
.empty-note { color: var(--muted); }

/* table */
.table-wrap { overflow-x: auto; }
.avail { border-collapse: collapse; width: 100%; font-size: .95rem; }
.avail th, .avail td { padding: 6px 10px; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
.avail tr > th:first-child { text-align: left; font-weight: 500; }
.avail tr:first-child th { font-weight: 700; }
.avail tr.weekend > th:first-child { font-weight: 700; }
.avail tr.blocked > th:first-child { color: var(--muted); }
.avail tr.best > th:first-child::after { content: " ★"; color: #d4a017; }
.avail tr.best { outline: 2px solid var(--green); outline-offset: -2px; }
.avail td.yes { background: var(--yes); color: var(--yes-ink); }
.avail td.maybe { background: var(--maybe); color: var(--maybe-ink); }
.avail td.no { background: var(--no); color: var(--no-ink); }
.avail td.empty { color: var(--muted); }
.legend .tag { margin-right: 6px; }

/* confetti */
#confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 10; }
#confetti i {
  position: absolute; top: -12px; width: 8px; height: 14px; border-radius: 2px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translate(var(--drift), 105vh) rotate(720deg); opacity: .7; }
}
@media (prefers-reduced-motion: reduce) { #confetti { display: none; } }
@media (max-width: 480px) {
  .card { padding: 16px; }
  .avail { font-size: .85rem; }
  .avail th, .avail td { padding: 6px 4px; }
}

/* ---------- v2: events, slots, calendar editor ---------- */
.page-title { font-size: 1.5rem; margin: 0 0 4px; }
.page-sub { margin: 0 0 16px; }
.grid.single { grid-template-columns: 1fr; }

.cta {
  display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--yes-ink);
  background: var(--yes); border-color: transparent;
}
.cta span { font-size: .9rem; opacity: .85; }
.events { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); margin-bottom: 16px; }
.event-card { display: flex; flex-direction: column; margin: 0; color: var(--ink); text-decoration: none; transition: border-color .15s; }
.event-card:hover { border-color: var(--muted); }
.event-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.event-head h2 { margin: 0; }
.event-loc { margin: 0 0 10px; font-weight: 600; }
.event-card .hint { margin: 8px 0 0; }
.event-open { margin-top: auto; padding-top: 8px; color: var(--green); font-weight: 600; font-size: .9rem; }
@media (prefers-color-scheme: dark) { .event-open { color: #7cc7a0; } }

.month + .month { margin-top: 24px; }
.month h2 { margin-bottom: 2px; }
.month .hint { margin: 0 0 10px; }
.day { gap: 4px; }
.day.off { opacity: .55; }
.day .bars { display: flex; gap: 2px; width: 70%; }
.day .bars i { flex: 1; height: 5px; border-radius: 2px; background: var(--line); }
.day .bars i.yes { background: #3f9b6d; }
.day .bars i.maybe { background: #d4a017; }
.day .bars i.no { background: #c0392b; }
.day.filled { border-color: var(--muted); }

.slots-cell { white-space: nowrap; }
.chip {
  display: inline-block; width: 1.5em; line-height: 1.5em; margin: 0 1px; border-radius: 4px;
  font-size: .75rem; font-weight: 700; background: var(--line); color: var(--muted);
}
.chip.yes { background: var(--yes); color: var(--yes-ink); }
.chip.maybe { background: var(--maybe); color: var(--maybe-ink); }
.chip.no { background: var(--no); color: var(--no-ink); text-decoration: line-through; }
.legend-slots { margin-left: 6px; }

.day-dialog {
  border: 1px solid var(--line); border-radius: 16px; padding: 20px; width: min(420px, calc(100vw - 32px));
  background: var(--card); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.day-dialog::backdrop { background: rgba(0,0,0,.45); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dlg-head h2 { margin: 0; text-align: center; font-size: 1.05rem; }
.dlg-head .btn { padding: 6px 12px; }
#dlg-events { text-align: center; margin: 6px 0 14px; }
.dlg-slots { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.slot-row { display: grid; grid-template-columns: 1fr repeat(3, 48px); gap: 6px; align-items: center; }
.slot-row.all { padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.slot-name { display: flex; flex-direction: column; line-height: 1.2; }
.slot-name small { color: var(--muted); }
.pick {
  font: inherit; font-weight: 700; height: 44px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
}
.pick.yes.on { background: var(--yes); color: var(--yes-ink); border-color: var(--yes-ink); }
.pick.maybe.on { background: var(--maybe); color: var(--maybe-ink); border-color: var(--maybe-ink); }
.pick.no.on { background: var(--no); color: var(--no-ink); border-color: var(--no-ink); }
.day-dialog .btn-spin { margin: 0 auto; }
#calendar { max-width: 560px; }
.page-participant .card { max-width: 600px; margin-left: auto; margin-right: auto; }
