:root {
  --bg: #fbf6ee;
  --surface: #ffffff;
  --surface-2: #f4ece0;
  --text: #2b1d0e;
  --muted: #7a6a58;
  --line: #eadfcc;
  --accent: #f2a900;
  --accent-ink: #2b1d0e;
  --accent-strong: #b97800;
  --accent-soft: #fff3d1;
  --weekend: #f8efe1;
  --danger: #b3261e;
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15100a;
    --surface: #211910;
    --surface-2: #2c2216;
    --text: #f5ebdd;
    --muted: #b3a38f;
    --line: #3a2e20;
    --accent: #f2b233;
    --accent-ink: #1b1309;
    --accent-strong: #f6c25a;
    --accent-soft: #3a2a10;
    --weekend: #1c150d;
    --danger: #ff8a80;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

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

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

.wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px 16px 96px;
}

/* ---------------------------------------------------------------- header */

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 0 12px;
}
h1 { font-size: 26px; line-height: 1.15; margin: 0 0 4px; letter-spacing: -0.01em; }
.sub { margin: 0; color: var(--muted); font-size: 14px; max-width: 46ch; }
.whoami { font-size: 14px; white-space: nowrap; padding-top: 6px; text-align: right; }
.me-label { color: var(--muted); }

/* ---------------------------------------------------------------- forms & buttons */

.btn {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  min-height: 36px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn.primary, .btn.joined { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.join { border-color: var(--accent); color: var(--text); }
.btn.join:hover { background: var(--accent-soft); }
.btn.joined:hover { filter: brightness(0.95); }
.btn.ghost:hover { background: var(--surface-2); }

.link {
  font: inherit;
  font-size: 14px;
  background: none;
  border: 0;
  padding: 2px 0;
  color: var(--accent-strong);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

input {
  font: inherit;
  font-size: 16px; /* no zoom-on-focus on iOS */
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 7px 10px;
  min-height: 36px;
  min-width: 0;
}
input:focus-visible, .btn:focus-visible, .link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.name-form {
  background: var(--accent-soft);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px;
  margin: 0 0 16px;
}
.name-form label { display: block; font-weight: 700; margin-bottom: 8px; }
.name-form .row { display: flex; gap: 8px; }
.name-form input { flex: 1; }
.hint { margin: 8px 0 0; font-size: 13px; color: var(--muted); }

.error {
  background: var(--surface);
  border: 1.5px solid var(--danger);
  color: var(--danger);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 16px;
}

/* ---------------------------------------------------------------- it's on */

.on { margin: 4px 0 20px; }
.on h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-strong);
  margin: 0 0 8px;
}
.on-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 12px;
  background: var(--accent-soft);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
}
.on-main { min-width: 0; flex: 1 1 260px; }
.on-when { margin-bottom: 6px; }
.on-when a { color: inherit; font-weight: 700; text-decoration: none; }
.on-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- calendar */

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

.week {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0;
  padding: 14px 0 6px;
  background: var(--bg);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.day {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 12px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 48px;
}
.day.weekend, .day.friday { background: var(--weekend); }
.day.flash { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: var(--accent-soft); } }

.date {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
  padding-top: 2px;
}
.dow { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.dnum { font-size: 22px; font-weight: 800; }
.mon { font-size: 12px; color: var(--muted); }
.day.today .dow { color: var(--accent-strong); }

.spots { min-width: 0; display: flex; flex-direction: column; gap: 6px; }

.spot {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  border-radius: 10px;
  padding: 4px 0;
}
.spot.is-on {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
  padding: 8px 8px 8px 12px;
}
.spot-main { min-width: 0; flex: 1; }
.spot-title { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; font-weight: 700; }
.place { overflow-wrap: anywhere; }
.need { font-size: 12px; font-weight: 500; color: var(--muted); }

.meter { display: inline-flex; gap: 3px; }
.meter i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
}
.meter i.full { background: var(--accent); }

.badge { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.on-badge { background: var(--accent); color: var(--accent-ink); }

.names { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chip {
  font-size: 13px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.chip.me { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.nobody { font-size: 13px; color: var(--muted); }
.spot.is-empty .names { margin-top: 0; }

.add-other { align-self: flex-start; font-size: 13px; color: var(--muted); }
.other-form { display: flex; gap: 6px; flex-wrap: wrap; }
.other-form input { flex: 1 1 140px; }

/* ---------------------------------------------------------------- footer & toast */

.more {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  padding: 20px 0 8px;
}
.jump { font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 8px; }

.foot { font-size: 13px; color: var(--muted); padding-top: 12px; }
.foot code { font-size: 12px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translate(-50%, 20px);
  max-width: calc(100% - 32px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 16px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 420px) {
  h1 { font-size: 22px; }
  .top { flex-direction: column; gap: 6px; }
  .whoami { text-align: left; padding-top: 0; }
  .day { grid-template-columns: 44px 1fr; gap: 10px; padding: 10px 4px; }
  .btn { padding: 6px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
