* { box-sizing: border-box; }
:root {
  color-scheme: dark;
  --bg: #171614;
  --surface: #201f1d;
  --surface-hover: #292825;
  --border: #393836;
  --text: #e3e0d9;
  --muted: #a29d93;
  --primary: #4f98a3;
  --danger: #b85c6a;
  --free-bg: #30442f;
  --free-text: #cbe2be;
  --maybe-bg: #514624;
  --maybe-text: #f0d981;
  --busy-bg: #4b2e39;
  --busy-text: #f1bcc8;
}
html, body { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  color: var(--text);
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
  font-size: clamp(15px, 1.3vw, 18px);
}
header, main { width: min(calc(100% - 2rem), 1600px); margin: 0 auto; }
header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  align-items: end;
  padding: 1rem 0 2rem;
}
.brand a { color: inherit; text-decoration: none; }
header b { display: block; font-size: 1.5rem; }
header small, .muted, .daynames { color: var(--muted); }
.top-nav {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: center;
}
.top-nav a { color: var(--primary); text-decoration: none; }
.top-nav a:hover { text-decoration: underline; }
.top-nav form { margin: 0; }
.who { color: var(--muted); margin-right: .25rem; }
main { padding-bottom: 2rem; }
h1 { margin: .5rem 0 1rem; font-size: clamp(2rem, 4vw, 3rem); line-height: 1.1; }
h2 { margin: 0 0 1rem; font-size: 1.25rem; }
p { line-height: 1.5; }
.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  color: var(--muted);
}
.legend b {
  padding: .25rem .75rem;
  border-radius: 999px;
  background: var(--free-bg);
  color: var(--free-text);
  font-weight: 600;
}
.error, .notice {
  margin: 1rem 0;
  padding: .85rem 1rem;
  border-radius: .75rem;
  border: 1px solid var(--border);
}
.error { background: var(--busy-bg); color: var(--busy-text); }
.notice { background: #243338; color: #b7d5db; }
.login, .admin-panel {
  max-width: 28rem;
  margin: 1rem 0 2rem;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--surface);
}
.admin-panel-wide { max-width: 42rem; }
.small { font-size: .85rem; margin: .35rem 0 0; }
.member-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
  padding: .75rem 0;
  border-top: 1px solid var(--border);
}
.member-main { flex: 1; min-width: 0; }
.member-actions {
  display: flex;
  flex-direction: column;
  gap: .45rem;
  flex-shrink: 0;
}
.member-actions form { margin: 0; }
.sign-in-link {
  display: flex;
  gap: .45rem;
  margin-top: .65rem;
}
.sign-in-link input {
  flex: 1;
  min-width: 0;
  font-size: .78rem;
}
.sign-in-link button { white-space: nowrap; }
.stack-form, .login form { display: grid; gap: .85rem; }
label { display: grid; gap: .35rem; color: var(--muted); font-size: .9rem; }
input {
  width: 100%;
  min-height: 2.4rem;
  padding: .45rem .65rem;
  border: 1px solid var(--border);
  border-radius: .45rem;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.member-list { list-style: none; margin: 0; padding: 0; }
.member-list li:first-child { border-top: 0; padding-top: 0; }
.calendar-shell {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 1rem;
}
.calendar-grid { width: 100%; min-width: 900px; padding: .75rem; }
.daynames, .week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: .45rem;
}
.daynames { padding: 0 .25rem .35rem; font-size: .85rem; font-weight: 600; }
.week { margin-bottom: .45rem; }
.empty { min-width: 0; }
.day-card {
  min-width: 0;
  min-height: 190px;
  padding: .55rem;
  border: 1px solid var(--border);
  border-radius: .65rem;
  background: var(--surface);
}
.day-card.today { outline: 2px solid var(--primary); outline-offset: -2px; }
.day-card.all-free { background: #263a29; }
.day-top {
  display: flex;
  align-items: center;
  min-height: 1.3rem;
  white-space: nowrap;
  font-size: .9rem;
}
.day-top strong { font-weight: 700; }
.participants { margin-top: .65rem; }
.participant {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .35rem;
  margin: .25rem 0;
  font-size: .82rem;
  line-height: 1.25;
}
.state {
  flex-shrink: 0;
  padding: .1rem .35rem;
  border-radius: 999px;
  font-size: .68rem;
  line-height: 1.2;
  text-transform: lowercase;
}
.state.free { background: var(--free-bg); color: var(--free-text); }
.state.maybe { background: var(--maybe-bg); color: var(--maybe-text); }
.state.busy { background: var(--busy-bg); color: var(--busy-text); }
.state.unset { background: #393836; color: var(--muted); }
.choices { display: grid; gap: .35rem; margin-top: .85rem; }
.choices button, button {
  min-height: 1.9rem;
  padding: .25rem .7rem;
  border: 1px solid var(--border);
  border-radius: .4rem;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .8rem;
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s, opacity .15s;
}
.choices button:hover, button:hover {
  background: var(--surface-hover);
  border-color: #66635d;
}
button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
button.danger { border-color: var(--danger); color: #f1bcc8; }
.status-button.free.selected,
.status-button.maybe.selected,
.status-button.busy.selected {
  border-color: #8fc5cc;
  box-shadow: 0 0 0 2px rgba(79, 152, 163, .35);
  font-weight: 700;
}
.status-button.free.selected { background: var(--free-bg); color: var(--free-text); }
.status-button.maybe.selected { background: var(--maybe-bg); color: var(--maybe-text); }
.status-button.busy.selected { background: var(--busy-bg); color: var(--busy-text); }
.status-button.unset.selected {
  border-color: #66635d;
  background: #393836;
  color: var(--text);
  box-shadow: 0 0 0 2px rgba(102, 99, 93, .3);
  font-weight: 700;
}
.status-button:disabled { opacity: .6; cursor: wait; }
@media (max-width: 800px) {
  header, main { width: calc(100% - 1rem); }
  .calendar-shell { overflow: visible; border: 0; border-radius: 0; }
  .calendar-grid { min-width: 0; padding: 0; }
  .daynames { display: none; }
  .week { display: block; margin: 0; }
  .week .empty { display: none; }
  .week .day-card { min-height: 0; margin-bottom: .55rem; padding: .65rem; }
  .day-top { font-size: 1rem; }
  .participant { font-size: .9rem; }
  .choices {
    grid-template-columns: repeat(4, 1fr);
    gap: .35rem;
    margin-top: .75rem;
  }
  .choices button { min-height: 2rem; font-size: .75rem; }
}
