:root {
  color-scheme: light dark;
  --page: light-dark(#f3f3f0, #121212);
  --surface: light-dark(#ffffff, #202020);
  --surface-raised: light-dark(#ffffff, #292929);
  --text: light-dark(#151515, #f5f5f5);
  --muted: light-dark(#737373, #a6a6a6);
  --line: light-dark(#dfdfda, #393939);
  --accent: #e83a35;
  --accent-dark: #bd2925;
  --good: light-dark(#12623b, #7dd5a5);
  --good-bg: light-dark(#edf8f1, #183327);
  --busy: light-dark(#9a9a96, #777777);
  --busy-bg: light-dark(#e8e8e4, #2a2a2a);
  --danger: light-dark(#b22520, #ff7772);
  --shadow: light-dark(rgba(0, 0, 0, .10), rgba(0, 0, 0, .35));
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--page); }

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  min-width: 320px;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--page);
  padding-bottom: 118px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: calc(18px + env(safe-area-inset-top)) 18px 17px;
  background: #151515;
  color: #f8f8f8;
}

.brand {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .11em;
}

.brand span { color: var(--accent); }
.app-header h1 { margin: 5px 0 0; font-size: 20px; line-height: 1.2; }

.user-avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #2d2d2d;
  color: #fff;
  font-weight: 800;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 10px 18px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.tab {
  min-height: 44px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.tab.is-active { color: var(--text); border-bottom-color: var(--accent); }

main { padding: 18px; }
.step + .step { margin-top: 24px; }
h2 { margin: 0 0 11px; font-size: 16px; line-height: 1.3; }

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-heading h2 { margin-bottom: 11px; }
.section-note, .field-hint, .loading-line { color: var(--muted); font-size: 12px; }

.date-navigation { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; }
.date-navigation span { min-width: 96px; text-align: center; color: var(--muted); font-size: 12px; }

.icon-button, .text-button {
  min-width: 36px;
  min-height: 36px;
  border: 0;
  background: transparent;
  color: var(--text);
}

.icon-button { border-radius: 50%; background: var(--surface); font-size: 22px; }
.text-button { color: var(--accent); font-size: 13px; font-weight: 700; }

.date-list { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.date-button {
  min-height: 60px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
}
.date-button span { color: var(--muted); font-size: 11px; }
.date-button strong { font-size: 18px; }
.date-button.is-selected { border-color: var(--accent); background: var(--accent); color: #fff; }
.date-button.is-selected span { color: #fff; }

.legend { display: flex; gap: 10px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.legend-dot.free { background: #29955f; }
.legend-dot.busy { background: var(--busy); }

.time-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.time-button, .duration-button {
  min-height: 46px;
  border: 1px solid light-dark(#cbded3, #315b46);
  border-radius: 11px;
  background: var(--good-bg);
  color: var(--good);
  font-weight: 750;
}
.time-button.is-selected, .duration-button.is-selected {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
.time-button:disabled, .duration-button:disabled {
  border-color: var(--line);
  background: var(--busy-bg);
  color: var(--busy);
  text-decoration: line-through;
}

.loading-line { margin-top: 8px; }
.duration-list { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.field-hint { margin: 8px 0 0; }

.service-list { display: grid; gap: 9px; }
.service-button {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
}
.service-button.is-selected { border: 2px solid var(--accent); padding: 11px 12px; }
.service-button:disabled { opacity: .48; }
.service-copy { display: flex; flex-direction: column; gap: 3px; }
.service-copy strong, .service-price { font-size: 14px; }
.service-copy small { color: var(--muted); font-size: 11px; }
.service-price { color: var(--accent); font-weight: 800; white-space: nowrap; }

.booking-footer {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: 0;
  width: min(100%, 520px);
  transform: translateX(-50%);
  padding: 13px 18px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: 0 -10px 30px var(--shadow);
}

.booking-summary { display: flex; justify-content: space-between; gap: 14px; margin-bottom: 9px; }
.booking-summary span { color: var(--muted); font-size: 12px; }
.booking-summary strong { font-size: 16px; }

.primary-button, .secondary-button {
  min-height: 48px;
  border-radius: 13px;
  padding: 0 18px;
  font-weight: 750;
}
.primary-button { border: 0; background: #171717; color: #fff; }
@media (prefers-color-scheme: dark) { .primary-button { background: #f1f1f1; color: #151515; } }
.primary-button:disabled { opacity: .45; }
.secondary-button { border: 1px solid var(--line); background: var(--surface); color: var(--text); }
#book-button { width: 100%; }

.app-message { min-height: 0; margin: 7px 0 0; text-align: center; color: var(--danger); font-size: 12px; }
.app-message.success { color: var(--good); }

.bookings-heading { margin-bottom: 10px; }
.bookings-list { display: grid; gap: 10px; }
.empty-state { padding: 44px 20px; text-align: center; color: var(--muted); }
.booking-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}
.booking-card.cancelled { opacity: .58; }
.booking-card-head { display: flex; justify-content: space-between; gap: 12px; }
.booking-card h3 { margin: 0; font-size: 15px; }
.booking-card p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.status-label { color: var(--good); font-size: 12px; font-weight: 700; }
.status-label.cancelled { color: var(--muted); }
.cancel-button { margin-top: 12px; border: 0; background: transparent; color: var(--danger); font-weight: 700; padding: 7px 0; }

.dialog-backdrop {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  align-items: end;
  background: rgba(0, 0, 0, .48);
}
.dialog-backdrop[hidden] { display: none; }
.dialog {
  width: min(100%, 520px);
  margin: 0 auto;
  padding: 22px 18px calc(18px + env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0;
  background: var(--surface-raised);
  box-shadow: 0 -12px 50px var(--shadow);
}
.dialog h2 { font-size: 20px; }
.confirm-details { margin: 14px 0 20px; color: var(--muted); line-height: 1.55; }
.confirm-details strong { color: var(--text); }
.dialog-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 9px; }

@media (max-width: 370px) {
  .time-list { grid-template-columns: repeat(3, 1fr); }
  .duration-list { grid-template-columns: repeat(3, 1fr); }
  .date-list { grid-template-columns: repeat(5, minmax(48px, 1fr)); gap: 5px; }
  .legend { gap: 6px; }
}
