:root {
  --deep: #0b2a3d;
  --sea: #13496b;
  --wave: #1d6fa5;
  --foam: #e8f4fb;
  --sky: #f4fafd;
  --sand: #f6efe3;
  --ink: #0d2230;
  --muted: #5c7689;
  --line: #d6e6f0;
  --coral: #e8745a;
  --coral-dark: #cf5a40;
  --good: #1f9d6b;
  --card: #ffffff;
  --shadow: 0 10px 40px rgba(11, 42, 61, 0.10);
  --radius: 16px;
}

* { box-sizing: border-box; }

html {
  /* solid fallback so the viewport is never transparent/black */
  background-color: var(--sky);
  color-scheme: light dark;   /* native date/time pickers, scrollbars follow the OS theme */
}

body {
  margin: 0;
  font-family: "Inter", system-ui, sans-serif;
  color: var(--ink);
  background-color: var(--sky);
  background-image:
    radial-gradient(1200px 500px at 50% -200px, #cde8f6 0%, transparent 70%),
    linear-gradient(180deg, var(--sky) 0%, #eaf4fb 100%);
  min-height: 100vh;
  min-height: 100dvh;            /* avoids mobile URL-bar resize jumps */
  -webkit-text-size-adjust: 100%; /* stop iOS auto-inflating text */
  overflow-x: hidden;             /* never allow sideways scroll */
  accent-color: var(--wave);      /* themes native date/time pickers */
}

button, .mode-btn { touch-action: manipulation; }  /* kill 300ms tap delay */

.wave-top {
  height: 6px;
  background: linear-gradient(90deg, var(--wave), var(--coral), var(--wave));
  background-size: 200% 100%;
  animation: drift 12s linear infinite;
}
@keyframes drift { to { background-position: 200% 0; } }

/* ---------- Hero ---------- */
.hero {
  text-align: center;
  padding: 48px 20px 36px;
  color: var(--deep);
}
.anchor { font-size: 40px; opacity: 0.85; }
.hero h1 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  font-size: clamp(2rem, 5vw, 3.1rem);
  margin: 8px 0 6px;
  letter-spacing: -0.5px;
}
.tagline { color: var(--muted); font-size: 1.05rem; margin: 0; }

/* ---------- Layout ---------- */
.layout {
  max-width: 1040px;
  margin: 0 auto;
  padding: 8px 20px 60px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 24px;
  align-items: start;
}
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 24px;
}
.card h2 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  margin: 0 0 18px;
  font-size: 1.4rem;
  color: var(--deep);
}

/* ---------- Calendar ---------- */
.calendar-card { grid-column: 1 / -1; }
.cal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.cal-head h2 { margin: 0; font-size: 1.25rem; }
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 6px;
}
.cal-weekdays span {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--muted);
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.cal-cell {
  position: relative;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 7px;
  background: #fcfdfe;
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s, background 0.12s;
  overflow: hidden;
}
.cal-cell:hover { border-color: var(--wave); box-shadow: 0 2px 8px rgba(11,42,61,0.08); }
.cal-cell.blank { border: none; background: transparent; cursor: default; box-shadow: none; }
.cal-cell.past { opacity: 0.5; }
.cal-cell .cal-num { font-size: 0.85rem; font-weight: 600; color: var(--ink); }
.cal-cell.today { border-color: var(--wave); }
.cal-cell.today .cal-num {
  background: var(--wave); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
}
.cal-cell.booked { background: #fdeee9; border-color: #f3c9bd; }
.cal-cell .cal-tags { margin-top: 4px; display: flex; flex-direction: column; gap: 2px; }
.cal-cell .cal-tag {
  font-size: 0.68rem; line-height: 1.25;
  color: var(--coral-dark); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-cell .cal-more { font-size: 0.66rem; color: var(--muted); font-weight: 600; }
.cal-legend {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-top: 14px; font-size: 0.8rem; color: var(--muted);
}
.cal-legend .dot { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.cal-legend .dot.booked { background: #f3c9bd; }
.cal-legend .dot.today { background: var(--wave); border-radius: 50%; }
.cal-legend .cal-hint { margin-left: auto; font-style: italic; }

@media (max-width: 600px) {
  .cal-head h2 { font-size: 1.1rem; }
  .cal-grid, .cal-weekdays { gap: 4px; }
  .cal-weekdays span { font-size: 0.6rem; letter-spacing: 0; }
  .cal-cell { min-height: 44px; padding: 4px; border-radius: 8px; }
  .cal-cell .cal-num { font-size: 0.8rem; }
  .cal-cell .cal-tags { display: none; }            /* dot-only on small screens */
  .cal-cell.booked::after {
    content: ""; position: absolute; bottom: 5px; left: 50%; transform: translateX(-50%);
    width: 6px; height: 6px; border-radius: 50%; background: var(--coral);
  }
  .cal-cell.today .cal-num { width: 20px; height: 20px; }
  .cal-legend { gap: 12px; margin-top: 12px; }
  .cal-legend .cal-hint { margin-left: 0; width: 100%; }
}

/* ---------- Mode toggle ---------- */
.mode-toggle {
  display: flex;
  gap: 4px;
  background: var(--foam);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 20px;
}
.mode-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px;
  border-radius: 9px;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
}
.mode-btn.active {
  background: var(--card);
  color: var(--sea);
  box-shadow: 0 2px 8px rgba(11, 42, 61, 0.08);
}

/* ---------- Fields ---------- */
.field { display: block; margin-bottom: 16px; }
.field > span {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--sea);
}
.field em { color: var(--muted); font-weight: 400; font-style: normal; font-size: 0.8rem; }
.field input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  color: var(--ink);
  background: #fcfdfe;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus {
  outline: none;
  border-color: var(--wave);
  box-shadow: 0 0 0 3px rgba(29, 111, 165, 0.15);
}
.row { display: flex; gap: 12px; }
.row .field { flex: 1; }
.hint { font-size: 0.82rem; color: var(--muted); margin: -6px 0 14px; }
.field-group.hidden, .hidden { display: none; }

button.primary {
  width: 100%;
  border: none;
  background: var(--coral);
  color: #fff;
  padding: 13px;
  font: inherit;
  font-weight: 600;
  font-size: 1rem;
  border-radius: 11px;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
  margin-top: 4px;
}
button.primary:hover { background: var(--coral-dark); }
button.primary:active { transform: translateY(1px); }
button.primary:disabled { opacity: 0.6; cursor: progress; }

/* ---------- Cancel link receipt + cancel-by-code ---------- */
.receipt {
  margin-top: 12px; padding: 12px 14px;
  background: var(--sand); border: 1px solid #e7dcc6; border-radius: 10px;
}
.receipt-title { font-weight: 600; color: var(--deep); margin: 0 0 2px; font-size: 0.9rem; }
.receipt-sub { margin: 0 0 8px; font-size: 0.8rem; color: var(--muted); }
.receipt-row { display: flex; gap: 8px; }
.receipt-row input {
  flex: 1; min-width: 0;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px;
  font: inherit; font-size: 0.82rem; color: var(--ink); background: #fff;
}
.receipt-row input:focus { outline: none; border-color: var(--wave); box-shadow: 0 0 0 3px rgba(29,111,165,0.15); }
.ghost-btn {
  border: 1px solid var(--wave); background: #fff; color: var(--sea);
  font: inherit; font-weight: 600; font-size: 0.85rem; padding: 9px 14px;
  border-radius: 9px; cursor: pointer; white-space: nowrap; flex-shrink: 0;
}
.ghost-btn:hover { background: var(--foam); }
.ghost-btn:disabled { opacity: 0.6; cursor: progress; }

.cancel-box { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.cancel-box summary {
  cursor: pointer; font-weight: 600; font-size: 0.9rem; color: var(--sea); list-style: none;
}
.cancel-box summary::-webkit-details-marker { display: none; }
.cancel-box summary::before { content: "\25B8\00a0"; }
.cancel-box[open] summary::before { content: "\25BE\00a0"; }
.cancel-body { padding-top: 10px; }
.cancel-body .hint { margin: 0 0 8px; }
#cancel-target { margin-top: 8px; color: var(--sea); font-weight: 500; }

.form-msg { margin: 12px 0 0; font-size: 0.9rem; min-height: 1.2em; }
.form-msg.error { color: var(--coral-dark); font-weight: 500; }
.form-msg.success { color: var(--good); font-weight: 500; }

/* ---------- List ---------- */
.list-head { display: flex; align-items: center; justify-content: space-between; }
.ghost {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--sea);
  width: 36px; height: 36px;
  border-radius: 9px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: background 0.15s;
}
.ghost:hover { background: var(--foam); }

.booking-list, #my-list { list-style: none; margin: 0; padding: 0; }

.booking-item {
  display: flex;
  gap: 14px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.booking-item:first-child { border-top: none; }
.date-chip {
  flex-shrink: 0;
  width: 56px;
  text-align: center;
  background: var(--foam);
  border-radius: 10px;
  padding: 8px 4px;
  align-self: flex-start;
}
.date-chip .mon { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--wave); font-weight: 600; }
.date-chip .day { font-size: 1.3rem; font-weight: 600; color: var(--deep); line-height: 1.1; }
.booking-body { min-width: 0; flex: 1; }
.booking-when { font-weight: 600; color: var(--ink); }
.booking-who { color: var(--sea); font-size: 0.92rem; margin-top: 2px; }
.booking-note { color: var(--muted); font-size: 0.86rem; margin-top: 3px; word-break: break-word; }
.badge-days {
  display: inline-block;
  font-size: 0.7rem;
  background: var(--sea);
  color: #fff;
  padding: 2px 7px;
  border-radius: 20px;
  margin-left: 6px;
  vertical-align: middle;
  font-weight: 600;
}

/* My bookings */
.my-bookings {
  background: var(--sand);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 18px;
}
.my-bookings h3 { margin: 0 0 8px; font-size: 0.95rem; color: var(--deep); }
#my-list li {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 7px 0; font-size: 0.9rem;
  border-top: 1px solid rgba(0,0,0,0.06);
}
#my-list li:first-child { border-top: none; }
.cancel-btn {
  border: 1px solid var(--coral);
  background: transparent;
  color: var(--coral-dark);
  font: inherit; font-size: 0.8rem; font-weight: 600;
  padding: 4px 10px; border-radius: 8px; cursor: pointer;
  flex-shrink: 0;
}
.cancel-btn:hover { background: var(--coral); color: #fff; }

.empty { color: var(--muted); text-align: center; padding: 24px 0; }

.footer { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 0 20px 40px; }

/* ============ Phone optimisation ============ */
@media (max-width: 600px) {
  .hero { padding: 30px 18px 22px; }
  .anchor { font-size: 34px; }
  .tagline { font-size: 0.98rem; }

  .layout { padding: 6px 12px 36px; gap: 14px; }
  .card { padding: 18px 15px; border-radius: 14px; }
  .card h2 { font-size: 1.25rem; margin-bottom: 14px; }

  /* roomier tap targets (Apple/Material ~44px min) */
  .mode-btn { padding: 13px 8px; }
  .ghost { width: 42px; height: 42px; font-size: 1.2rem; }
  .ghost-btn { padding: 13px 16px; }
  .cancel-btn { padding: 9px 14px; font-size: 0.85rem; }
  button.primary { padding: 15px; }
  .cancel-box summary { padding: 4px 0; }

  /* time inputs keep side-by-side but breathe a little */
  .row { gap: 10px; }

  /* iOS zooms when a focused input is < 16px — force 16px on typed fields */
  .receipt-row input, #cancel-code, .field input { font-size: 16px; }

  .footer { padding: 0 16px calc(28px + env(safe-area-inset-bottom)); }
}

@media (max-width: 400px) {
  /* stack link/code + button so the button is a full-width thumb target */
  .receipt-row { flex-direction: column; }
  .receipt-row .ghost-btn { width: 100%; }
  .date-chip { width: 48px; }
}

/* ============ Enhancements: depth, motion, micro-interactions ============ */

/* Brand badge */
.hero-inner { display: flex; flex-direction: column; align-items: center; }
.brand-badge {
  width: 62px; height: 62px; border-radius: 20px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--wave), var(--deep));
  box-shadow: 0 12px 26px rgba(29, 111, 165, 0.38);
  animation: badge-float 5s ease-in-out infinite;
}
.brand-badge svg { width: 32px; height: 32px; fill: #fff; }
@keyframes badge-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

.month-summary { margin: 10px 0 0; font-size: 0.86rem; color: var(--sea); font-weight: 600; min-height: 1.1em; }

/* Card entrance, staggered */
.card { animation: rise 0.55s cubic-bezier(0.2, 0.7, 0.3, 1) backwards; }
.calendar-card { animation-delay: 0.02s; }
.form-card { animation-delay: 0.10s; }
.list-card { animation-delay: 0.18s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* Inputs: hover affordance */
.field input:hover:not(:focus), .receipt-row input:hover:not(:focus) { border-color: #b9d5e6; }

/* Primary button: gradient, sheen, spinner */
button.primary {
  position: relative; overflow: hidden;
  background-image: linear-gradient(135deg, #ef8166, var(--coral) 55%, var(--coral-dark));
  box-shadow: 0 8px 20px rgba(232, 116, 90, 0.35);
  transition: transform 0.08s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
button.primary::after {
  content: ""; position: absolute; top: 0; left: -120%; width: 60%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,0.35), transparent);
  transform: skewX(-18deg); transition: left 0.6s ease;
}
button.primary:hover { box-shadow: 0 10px 26px rgba(232, 116, 90, 0.45); filter: brightness(1.03); }
button.primary:hover::after { left: 130%; }
button.primary:active { transform: translateY(1px) scale(0.995); }
.btn-spinner { display: none; }
button.primary.loading { color: transparent; pointer-events: none; }
button.primary.loading .btn-spinner {
  display: block; position: absolute; inset: 0; margin: auto;
  width: 20px; height: 20px; border: 2.5px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Trip-summary chip */
.trip-summary {
  margin: 2px 0 14px; padding: 11px 14px;
  background: var(--foam); border-radius: 12px;
  font-size: 0.9rem; color: var(--sea); font-weight: 600;
  display: flex; align-items: center; gap: 8px;
  animation: rise 0.3s ease backwards;
}
.trip-summary::before { content: "🛥️"; font-size: 1.05rem; }
.trip-summary.hidden { display: none; }

/* Calendar interactions */
.cal-cell { transition: transform 0.12s ease, border-color 0.12s, box-shadow 0.12s, background 0.12s; }
.cal-cell:not(.blank):hover { transform: translateY(-2px); }
.cal-cell:not(.blank):active { transform: translateY(0); }
.cal-cell.selected { border-color: var(--coral); box-shadow: 0 0 0 2px var(--coral) inset; }

/* Booking list entrance */
.booking-item { animation: rise 0.4s ease backwards; }

/* Refresh icon spins while loading */
.ghost.spinning { animation: spin 0.8s linear infinite; }

/* Cancel two-tap confirm state */
.cancel-btn.confirming { background: var(--coral); color: #fff; }

/* Toasts */
.toast-wrap {
  position: fixed; top: calc(14px + env(safe-area-inset-top)); left: 50%;
  transform: translateX(-50%); z-index: 60;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  width: max-content; max-width: 92vw; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-left: 4px solid var(--good);
  border-radius: 12px; padding: 12px 16px;
  box-shadow: 0 12px 32px rgba(11, 42, 61, 0.20);
  font-size: 0.9rem; font-weight: 500;
  animation: toast-in 0.35s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.toast.leaving { animation: toast-out 0.3s ease forwards; }
.toast.error { border-left-color: var(--coral); }
.toast.info { border-left-color: var(--wave); }
.toast-ico { font-size: 1.05rem; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-14px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px); } }

/* Skeleton loaders */
.skeleton-item { display: flex; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); }
.skeleton-item:first-child { border-top: none; }
.sk {
  background: linear-gradient(90deg, var(--line) 25%, var(--foam) 37%, var(--line) 63%);
  background-size: 300% 100%; border-radius: 8px; animation: shimmer 1.4s ease infinite;
}
.sk-chip { width: 56px; height: 56px; flex-shrink: 0; border-radius: 10px; }
.sk-lines { flex: 1; display: flex; flex-direction: column; gap: 9px; padding-top: 5px; }
.sk-line { height: 12px; }
.sk-line.w70 { width: 70%; } .sk-line.w45 { width: 45%; } .sk-line.w55 { width: 55%; }
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -150% 0; } }

/* Empty state */
.empty .empty-emoji { font-size: 2rem; line-height: 1; margin-bottom: 8px; }

/* Success message gets a little pop */
.form-msg.success { animation: pop 0.4s ease; }
@keyframes pop { 0% { transform: scale(0.96); opacity: 0.4; } 100% { transform: scale(1); opacity: 1; } }

/* Respect reduced-motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============ Automatic dark mode (follows the device / browser theme) ============ */
@media (prefers-color-scheme: dark) {
  :root {
    --deep: #eaf2f9;
    --sea:  #9cc2de;
    --wave: #4a9fd4;
    --foam: #18313f;
    --sky:  #0b1822;
    --sand: #1d2730;
    --ink:  #e7eef5;
    --muted:#93aabc;
    --line: #2a3c4b;
    --good: #38cf90;
    --card: #14222d;
    --shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  }

  /* page background gradient uses literal colours — restate for dark */
  body {
    background-color: var(--sky);
    background-image:
      radial-gradient(1200px 500px at 50% -220px, #123247 0%, transparent 70%),
      linear-gradient(180deg, #0b1822 0%, #0a131c 100%);
  }

  /* inputs + placeholders */
  .field input,
  .receipt-row input { background: #0f1c25; }
  .field input::placeholder,
  .receipt-row input::placeholder { color: var(--muted); opacity: 1; }

  /* calendar surfaces */
  .cal-cell { background: #11202a; }
  .cal-cell.booked { background: #3a2620; border-color: #5e3a2e; }
  .cal-cell .cal-tag { color: #f0a48f; }
  .cal-cell.today .cal-num { color: #06121a; }   /* dark text on the bright "today" dot */

  /* mode toggle */
  .mode-toggle { background: #0e1a23; }
  .mode-btn.active { background: #1f3340; color: #d3e8f6; }

  /* ghost buttons + receipt border (used literal light colours) */
  .ghost, .ghost-btn { background: var(--card); }
  .receipt { border-color: var(--line); }

  /* badge + divider that assumed a light background */
  .badge-days { background: var(--wave); color: #06121a; }
  #my-list li { border-top-color: rgba(255, 255, 255, 0.08); }

  /* enhancement components in dark */
  .brand-badge { background: linear-gradient(145deg, var(--wave), #07171f); box-shadow: 0 12px 26px rgba(0, 0, 0, 0.55); }
  .toast { box-shadow: 0 12px 34px rgba(0, 0, 0, 0.55); }
}
