:root {
  color-scheme: light dark;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #5d6470;
  --border: #e1e4e9;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --accent-soft: #e8efff;
  --free: #15803d;
  --free-soft: #e7f6ec;
  --busy: #b45309;
  --busy-soft: #fdf1e3;
  --danger: #c62828;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(16 24 40 / 0.06), 0 1px 3px rgb(16 24 40 / 0.08);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.45;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #181b21;
    --text: #e8eaee;
    --muted: #9aa1ad;
    --border: #2a2f38;
    --accent: #5b8cff;
    --accent-text: #0b1020;
    --accent-soft: #1d2740;
    --free: #4ade80;
    --free-soft: #14261b;
    --busy: #fbbf24;
    --busy-soft: #2a2114;
    --danger: #f87171;
    --shadow: none;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

[hidden] {
  display: none !important;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 650;
  font-size: 1.1rem;
}

.logo {
  display: grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 7px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 800;
}

.who {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
}

main {
  max-width: 44rem;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

.stack {
  display: grid;
  gap: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.narrow {
  max-width: 24rem;
  margin: 2rem auto 0;
}

h1,
h2 {
  margin: 0 0 1rem;
  line-height: 1.2;
}

h1 {
  font-size: 1.4rem;
}

h2 {
  font-size: 1.1rem;
}

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

.center {
  text-align: center;
}

label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.9rem;
  font-weight: 550;
  margin-bottom: 0.9rem;
}

input {
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  min-height: 2.6rem;
  width: 100%;
}

input:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button {
  font: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: progress;
  opacity: 0.6;
}

.primary {
  background: var(--accent);
  color: var(--accent-text);
  border: 0;
  border-radius: 8px;
  padding: 0.6rem 1.2rem;
  min-height: 2.6rem;
  font-weight: 600;
}

form .primary {
  width: 100%;
}

.link {
  background: none;
  border: 0;
  padding: 0.25rem;
  color: var(--accent);
  font-weight: 550;
}

.error {
  color: var(--danger);
  margin: 0 0 0.75rem;
}

.success {
  color: var(--free);
  margin: 0;
}

.error:empty,
.success:empty {
  display: none;
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: -0.4rem 0 0.9rem;
}

.notice {
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  margin: 0 0 1rem;
}

/* Status */

.status {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.status .dot {
  flex: none;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  background: var(--free);
  box-shadow: 0 0 0 5px var(--free-soft);
}

.status.busy .dot {
  background: var(--busy);
  box-shadow: 0 0 0 5px var(--busy-soft);
}

.status strong {
  display: block;
  font-size: 1.05rem;
}

/* Booking form */

.book-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0 0.75rem;
  align-items: end;
}

.book-form .primary {
  margin-bottom: 0.9rem;
  width: auto;
}

.presets {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin: -0.2rem 0 0.75rem;
  font-size: 0.9rem;
}

.chip {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.75rem;
}

.chip:hover {
  border-color: var(--accent);
}

@media (max-width: 34rem) {
  .book-form {
    grid-template-columns: 1fr;
  }

  .book-form .primary {
    width: 100%;
  }
}

/* Booking list */

.list-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 450;
  color: var(--muted);
  margin: 0;
}

.toggle input {
  width: auto;
  min-height: 0;
}

.day {
  margin: 1rem 0 0.4rem;
  font-size: 0.8rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.day:first-child {
  margin-top: 0;
}

.bookings {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}

.booking {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 9px;
}

.booking.mine {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: var(--accent-soft);
}

.booking.past {
  opacity: 0.6;
}

.booking .time {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  min-width: 8.5rem;
}

.booking .owner {
  flex: 1;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.booking.mine .owner {
  color: var(--text);
  font-weight: 550;
}

.badge {
  font-size: 0.75rem;
  font-weight: 650;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--busy-soft);
  color: var(--busy);
}

.booking .delete {
  background: none;
  border: 1px solid transparent;
  color: var(--danger);
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
}

.booking .delete:hover {
  border-color: var(--danger);
}

.empty {
  color: var(--muted);
  margin: 0;
}

/* Toby's reg and Saab popups. */
.modal {
  width: min(22rem, calc(100vw - 2rem));
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 12px 32px rgb(16 24 40 / 0.25);
}

.modal::backdrop {
  background: rgb(0 0 0 / 0.45);
}

.modal-actions {
  display: flex;
  flex-direction: row-reverse;
  gap: 0.5rem;
  margin-top: 1rem;
}

.modal form .primary {
  width: auto;
}

.secondary {
  background: none;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 1.2rem;
  min-height: 2.6rem;
  font-weight: 550;
}

.modal-error {
  color: var(--danger);
  font-weight: 600;
  margin: 0;
}
