:root {
  color-scheme: dark;
  --ink: #f8efd9;
  --muted: #a89c7d;
  --night: #080b15;
  --panel: rgba(13, 18, 32, 0.78);
  --line: rgba(248, 239, 217, 0.14);
  --gold: #f8c772;
  --avail: #6ee7a2;
  --tent: #f5d067;
  --unavail: #f87171;
  --gray: #4b5266;
  --radius: 18px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--night);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100svh;
}

body {
  background:
    radial-gradient(circle at 22% 14%, rgba(248, 199, 114, 0.12), transparent 26rem),
    radial-gradient(circle at 78% 86%, rgba(96, 165, 250, 0.10), transparent 28rem),
    linear-gradient(150deg, #050711 0%, #0b1020 50%, #110d1a 100%);
}

.page {
  width: min(100%, 76rem);
  margin: 0 auto;
  padding: clamp(1rem, 4vw, 3rem);
}

.hero { padding: 2rem 0 1.5rem; }

.kicker {
  margin: 0 0 0.5rem;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}

.title {
  margin: 0 0 0.6rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.4rem, 6vw, 4.4rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}

.lede {
  margin: 0 0 1.4rem;
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 38rem;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 0 0 1.2rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.legend-item { display: inline-flex; align-items: center; gap: 0.45rem; }

.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-avail { background: var(--avail); }
.dot-tent { background: var(--tent); }
.dot-unavail { background: var(--unavail); }

.toolbar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 0.55rem 1rem;
  border-radius: 12px;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 160ms, background 160ms, transform 160ms;
}

.btn:hover { border-color: var(--gold); background: rgba(248, 199, 114, 0.06); }
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--gold);
  color: #18120a;
  border-color: var(--gold);
  font-weight: 700;
}

.btn-primary:hover { background: #ffd991; border-color: #ffd991; }
.btn-ghost { color: var(--muted); }
.btn-danger { color: var(--unavail); border-color: rgba(248, 113, 113, 0.4); }

.status {
  font-size: 0.8rem;
  color: var(--muted);
  margin-left: auto;
}

.status.error { color: var(--unavail); }
.status.ok { color: var(--avail); }

.board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.9rem;
  margin: 1.5rem 0;
}

.weekend {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: border-color 160ms, transform 160ms;
  min-height: 220px;
}

.weekend:hover { border-color: var(--gold); transform: translateY(-2px); }

.weekend.best {
  border-color: rgba(110, 231, 162, 0.55);
  box-shadow: 0 0 0 1px rgba(110, 231, 162, 0.2), 0 12px 32px rgba(110, 231, 162, 0.1);
}

.weekend-date {
  font-family: Georgia, serif;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}

.weekend-month {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  margin-bottom: 0.4rem;
}

.weekend-summary {
  display: flex;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0.4rem 0 0.7rem;
  flex-wrap: wrap;
}

.weekend-summary b { color: var(--ink); font-weight: 600; }

.bar {
  margin-top: auto;
  display: flex;
  flex-direction: column-reverse;
  height: 100px;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.03);
}

.bar-seg { width: 100%; transition: height 240ms ease; }
.bar-seg-avail { background: var(--avail); }
.bar-seg-tent { background: var(--tent); }
.bar-seg-unavail { background: var(--unavail); }
.bar-seg-empty { background: var(--gray); opacity: 0.5; }

.weekend-best-tag {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: #08120c;
  background: var(--avail);
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  text-transform: uppercase;
}

.foot {
  margin: 3rem 0 1rem;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

.foot code {
  background: rgba(248, 199, 114, 0.1);
  color: var(--gold);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

.gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(8, 11, 21, 0.92);
  backdrop-filter: blur(8px);
  z-index: 50;
  padding: 1rem;
}

.gate-card {
  width: min(28rem, 100%);
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.gate-card h2 { margin: 0; font-family: Georgia, serif; font-size: 1.6rem; }
.muted { color: var(--muted); margin: 0; font-size: 0.9rem; }

.field { display: flex; flex-direction: column; gap: 0.4rem; }
.field-label { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.16em; }

input[type="text"], input[type="password"], textarea {
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.3);
  color: var(--ink);
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color 160ms;
}

input:focus, textarea:focus { border-color: var(--gold); }
textarea { min-height: 4.5rem; resize: vertical; }

.gate-error { color: var(--unavail); margin: 0; font-size: 0.85rem; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 11, 21, 0.85);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  z-index: 40;
  padding: 1rem;
  overflow-y: auto;
}

.modal-card {
  position: relative;
  width: min(36rem, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.6rem;
  max-height: 90svh;
  overflow-y: auto;
}

.modal-card h2 { margin: 0 0 1rem; font-family: Georgia, serif; font-size: 1.7rem; }

.modal-close {
  position: absolute;
  top: 0.6rem;
  right: 0.8rem;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover { color: var(--ink); }

.people {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.person {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.18);
}

.person-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.person-name-input {
  font-weight: 600;
  flex: 1 1 auto;
  min-width: 7rem;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  padding: 0.4rem 0.55rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color 140ms, background 140ms;
}

.person-name-input:hover { border-color: var(--line); }
.person-name-input:focus { border-color: var(--gold); background: rgba(0, 0, 0, 0.3); }

.status-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.status-toggle button {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: inherit;
  transition: background 140ms, color 140ms;
}

.status-toggle button[data-active="true"][data-status="available"] { background: var(--avail); color: #08120c; }
.status-toggle button[data-active="true"][data-status="tentative"] { background: var(--tent); color: #1c1408; }
.status-toggle button[data-active="true"][data-status="unavailable"] { background: var(--unavail); color: #210808; }

.status-toggle button:hover:not([data-active="true"]) { color: var(--ink); }

.note-input {
  width: 100%;
  font-size: 0.88rem;
}

.loading {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--night);
  z-index: 100;
  color: var(--muted);
  font-size: 0.9rem;
  flex-direction: column;
}

.loading p { margin-top: 1rem; }

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(248, 199, 114, 0.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

.update-banner {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 80;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.6rem 1rem;
  background: var(--panel);
  border: 1px solid rgba(248, 199, 114, 0.55);
  border-radius: 14px;
  color: var(--ink);
  font: inherit;
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
  animation: fadeIn 200ms ease-out;
  max-width: min(28rem, calc(100vw - 2rem));
}

.update-banner .update-text {
  white-space: normal;
  line-height: 1.35;
}

.update-banner:hover { border-color: var(--gold); }

.update-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 0 rgba(248, 199, 114, 0.6);
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(248, 199, 114, 0.55); }
  70%  { box-shadow: 0 0 0 10px rgba(248, 199, 114, 0); }
  100% { box-shadow: 0 0 0 0 rgba(248, 199, 114, 0); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.picker-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.picker-list button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  font: inherit;
  cursor: pointer;
  transition: border-color 140ms, background 140ms;
}

.picker-list button:hover { border-color: var(--gold); background: rgba(248, 199, 114, 0.06); }

.weekend-row {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.18);
}

.weekend-row .weekend-row-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.weekend-row .weekend-row-label {
  font-weight: 600;
  flex: 1 1 auto;
  min-width: 8rem;
}

.weekend-row .weekend-row-month {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  margin-right: 0.4rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 600px) {
  .board { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .weekend { min-height: 180px; }
  .bar { height: 70px; }
}
