:root {
  --amber-900: #5d4037;
  --amber-700: #795548;
  --amber-500: #8d6e63;
  --amber-100: #efebe9;
  --cream: #faf8f3;
  --cream-strong: #fff3e0;
  --ink: #2d2d2d;
  --muted: #6b625e;
  --card: #ffffff;
  --border: #e7ddd7;
  --shadow: 0 10px 30px rgba(93, 64, 55, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  font-size: 18px;
  background: var(--cream);
}

body {
  margin: 0;
  font-family: "Nunito", "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #f6f1ea 0%, var(--cream) 220px);
}

a {
  color: inherit;
}

button,
input,
select,
textarea {
  font: inherit;
}

.page {
  max-width: 480px;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--cream);
}

.shell {
  padding-bottom: 2rem;
}

.header {
  padding: 1.1rem 1.1rem 1rem;
  color: white;
  background: linear-gradient(135deg, var(--amber-900) 0%, var(--amber-700) 55%, var(--amber-500) 100%);
  border-radius: 0 0 1.35rem 1.35rem;
  box-shadow: 0 8px 24px rgba(93, 64, 55, 0.28);
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  text-align: left;
}

.logo-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.2rem;
  height: 3.2rem;
  color: #3e2723;
  flex-shrink: 0;
}

.brand-text {
  min-width: 0;
  text-align: left;
}

.brand-name {
  margin: 0;
  font-family: "Dancing Script", cursive;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}

.brand-subtitle {
  margin-top: 0.15rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.88;
}

.content {
  padding: 1rem 0.9rem 0;
}

.section-card,
.booking-card,
.empty-bookings,
.resident-bar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 1.15rem;
  box-shadow: var(--shadow);
}

.section-card,
.empty-bookings,
.resident-bar {
  padding: 1rem;
}

.section-title {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  font-weight: 800;
}

.section-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.name-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
  margin-top: 1rem;
}

.name-form,
.switch-form,
.inline-switch-form {
  margin: 0;
}

.name-button,
.switch-button,
.facility-tab,
.day-button,
.week-nav-button {
  min-height: 48px;
}

.name-button,
.switch-button {
  width: 100%;
  border: 2px solid var(--border);
  border-radius: 1rem;
  background: #fff;
  color: var(--ink);
  padding: 0.9rem 0.8rem;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
}

.name-button {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.switch-button {
  background: var(--amber-100);
  color: var(--amber-900);
  border-color: #d9c2b9;
}

.compact-switch-button {
  width: auto;
  min-width: 0;
  flex-shrink: 0;
  padding: 0.7rem 0.85rem;
  font-size: 0.95rem;
  white-space: nowrap;
}

#schedule-panel {
  margin-top: 0.2rem;
  padding: 0.7rem 0.55rem 0.2rem;
  border-radius: 1.2rem;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--facility-colour, var(--amber-700)) 18%, white) 0%, rgba(250, 248, 243, 0) 180px),
    transparent;
}

.resident-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
  padding: 0.8rem 0.9rem;
}

.resident-label {
  min-width: 0;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.facility-tabs-header {
  display: flex;
  justify-content: center;
  margin-top: 0.2rem;
}

.tabs-hint {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--amber-700);
  text-align: center;
}

.facility-tabs-wrap {
  position: relative;
  margin-top: 0.25rem;
}

.facility-tabs-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--amber-900);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
  z-index: 1;
}

.facility-tabs-arrow-left {
  left: 0.15rem;
}

.facility-tabs-arrow-right {
  right: 0.15rem;
}

.facility-tabs-wrap[data-show-left="true"] .facility-tabs-arrow-left {
  display: inline-flex;
}

.facility-tabs-wrap[data-show-right="true"] .facility-tabs-arrow-right {
  display: inline-flex;
}

.facility-tabs {
  display: flex;
  gap: 0.55rem;
  overflow-x: auto;
  padding: 0.15rem 2.4rem 0.5rem;
  margin-top: 0;
  scrollbar-width: auto;
  scrollbar-color: color-mix(in srgb, var(--facility-colour, var(--amber-700)) 55%, white) rgba(255, 255, 255, 0.72);
}

.facility-tabs::-webkit-scrollbar {
  height: 10px;
}

.facility-tabs::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.72);
  border-radius: 999px;
}

.facility-tabs::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--facility-colour, var(--amber-700)) 55%, white);
  border-radius: 999px;
}

.facility-tab {
  border: 2px solid var(--border);
  border-radius: 1rem;
  background: #fff;
  color: var(--ink);
  padding: 0.8rem 1rem;
  font-weight: 800;
  white-space: nowrap;
  flex-shrink: 0;
}

.facility-tab.active {
  background: var(--facility-colour, var(--amber-700));
  border-color: var(--facility-colour, var(--amber-700));
  color: white;
  box-shadow: 0 8px 18px color-mix(in srgb, var(--facility-colour, var(--amber-700)) 28%, transparent);
}

.week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.8rem;
}

.week-nav-button {
  width: 52px;
  border: 2px solid color-mix(in srgb, var(--facility-colour, var(--amber-700)) 25%, var(--border));
  border-radius: 1rem;
  background: #fff;
  color: var(--facility-colour, var(--amber-900));
  font-size: 1.4rem;
  font-weight: 800;
}

.week-label {
  flex: 1;
  text-align: center;
  font-weight: 800;
  color: color-mix(in srgb, var(--facility-colour, var(--amber-900)) 75%, var(--ink));
}

.day-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.35rem;
  margin-top: 0.8rem;
}

.day-button {
  border: 0;
  border-radius: 0.95rem;
  background: transparent;
  color: var(--ink);
  padding: 0.55rem 0.2rem 0.6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
}

.day-button.active {
  background: var(--facility-colour, var(--amber-900));
  color: white;
}

.day-name {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  opacity: 0.85;
}

.day-number {
  font-size: 1.15rem;
  font-weight: 800;
}

.day-dot {
  width: 0.38rem;
  height: 0.38rem;
  border-radius: 999px;
  background: currentColor;
  margin-top: 0.15rem;
}

.primary-action,
.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border-radius: 1rem;
  font-weight: 800;
  text-decoration: none;
}

.primary-action {
  width: 100%;
  margin-top: 0.8rem;
  background: var(--facility-colour, var(--amber-700));
  color: white;
  padding: 0.85rem 1rem;
  box-shadow: 0 8px 18px color-mix(in srgb, var(--facility-colour, var(--amber-700)) 28%, transparent);
}

.back-link {
  margin-top: 0.75rem;
  color: var(--amber-900);
  justify-content: flex-start;
}

.bookings-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.9rem;
}

.booking-card {
  padding: 1rem;
  border-left: 6px solid var(--facility-colour, var(--amber-700));
}

.booking-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.booking-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
}

.capacity-badge {
  flex-shrink: 0;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--facility-colour, var(--amber-700)) 14%, white);
  color: color-mix(in srgb, var(--facility-colour, var(--amber-700)) 78%, var(--ink));
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.capacity-badge.full {
  background: #fce8e6;
  color: #a63d2f;
}

.booking-meta {
  margin: 0.35rem 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.attendee-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.7rem;
}

.attendee-chip {
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
}

.attendee-chip.yes {
  background: #e2f3e5;
  color: #25643a;
}

.attendee-chip.maybe {
  background: #fff4d9;
  color: #8a5b00;
}

.rsvp-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
  margin-top: 0.85rem;
}

.rsvp-button {
  width: 100%;
  min-height: 48px;
  border: 2px solid var(--border);
  border-radius: 1rem;
  background: #fff;
  color: var(--ink);
  padding: 0.7rem 0.55rem;
  font-size: 0.95rem;
  font-weight: 800;
}

.rsvp-button.yes.active {
  background: #2e7d32;
  border-color: #2e7d32;
  color: white;
}

.rsvp-button.maybe.active {
  background: #f0b429;
  border-color: #f0b429;
  color: #3d2a00;
}

.rsvp-button.cancel {
  background: var(--amber-100);
  color: var(--amber-900);
}

.rsvp-button.full,
.rsvp-button.disabled,
.rsvp-button:disabled {
  background: #ece7e4;
  color: #8c817b;
  border-color: #ddd3ce;
}

.delete-booking-button {
  width: 100%;
  min-height: 48px;
  margin-top: 0.7rem;
  border: 2px solid #e5b8b0;
  border-radius: 1rem;
  background: #fff5f3;
  color: #a63d2f;
  padding: 0.75rem 0.8rem;
  font-size: 0.95rem;
  font-weight: 800;
}

.booking-form-card {
  padding: 1.1rem;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--facility-colour, var(--amber-700)) 14%, white) 0%, white 220px),
    white;
  border-color: color-mix(in srgb, var(--facility-colour, var(--amber-700)) 24%, var(--border));
}

.form-error {
  margin-top: 0.85rem;
  padding: 0.85rem 0.95rem;
  border-radius: 1rem;
  background: #fce8e6;
  color: #a63d2f;
  font-weight: 800;
}

.booking-form {
  margin-top: 1rem;
}

.form-section + .form-section {
  margin-top: 1rem;
}

.form-label {
  display: block;
  margin-bottom: 0.55rem;
  font-weight: 800;
}

.text-input {
  width: 100%;
  min-height: 52px;
  padding: 0.85rem 0.95rem;
  border: 2px solid var(--border);
  border-radius: 1rem;
  background: #fff;
}

.duration-grid,
.time-slot-grid {
  display: grid;
  gap: 0.6rem;
}

.duration-grid,
.time-slot-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.selected-facility-chip,
.option-pill,
.time-slot {
  min-height: 52px;
  border: 2px solid var(--border);
  border-radius: 1rem;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.85rem 0.7rem;
  font-weight: 800;
  text-align: center;
  cursor: pointer;
}

.selected-facility-chip {
  color: color-mix(in srgb, var(--facility-colour, var(--amber-700)) 80%, var(--ink));
  background: color-mix(in srgb, var(--facility-colour, var(--amber-700)) 12%, white);
  border-color: color-mix(in srgb, var(--facility-colour, var(--amber-700)) 35%, var(--border));
}

.option-pill.active,
.time-slot.active,
.option-pill:has(input:checked),
.time-slot:has(input:checked) {
  border-color: var(--facility-colour, var(--amber-700));
  background: color-mix(in srgb, var(--facility-colour, var(--amber-700)) 12%, white);
  color: color-mix(in srgb, var(--facility-colour, var(--amber-700)) 80%, var(--ink));
}

.option-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.time-slot.taken {
  color: #8c817b;
  background: #f1ece8;
  border-color: #ddd3ce;
  text-decoration: line-through;
}

.submit-booking-button {
  margin-top: 1.2rem;
}

.empty-bookings {
  text-align: center;
}

@media (max-width: 360px) {
  .name-grid {
    grid-template-columns: 1fr;
  }

  .brand-name {
    font-size: 1.7rem;
  }
}
