:root {
  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --text: #111827;
  --text-2: #4b5563;
  --muted: #9ca3af;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --accent: #3554d1;
  --accent-hover: #2a45b4;
  --accent-text: #ffffff;
  --accent-soft: #edf1ff;
  --accent-soft-hover: #dfe6ff;
  --success: #12805c;
  --success-soft: #e6f6ef;
  --error: #c4321c;
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.04), 0 12px 40px rgba(17, 24, 39, 0.08);
  --radius: 16px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d12;
    --surface: #14171e;
    --surface-2: #1a1e27;
    --text: #e8eaf0;
    --text-2: #a4acbb;
    --muted: #6b7384;
    --border: #262b36;
    --border-strong: #353b48;
    --accent: #7091ff;
    --accent-hover: #8ba5ff;
    --accent-text: #0b0d12;
    --accent-soft: rgba(112, 145, 255, 0.14);
    --accent-soft-hover: rgba(112, 145, 255, 0.24);
    --success: #4cc79a;
    --success-soft: rgba(76, 199, 154, 0.14);
    --error: #ff8a75;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 40px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
a { color: var(--accent); }

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Layout ---------- */
.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 16px 24px;
}
.booking {
  width: 100%;
  max-width: 1060px;
  display: grid;
  grid-template-columns: 300px 1fr;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.booking.is-done { max-width: 560px; grid-template-columns: 1fr; }
.booking.is-done .summary { display: none; }
.footer { margin-top: 20px; font-size: 13px; }
.footer a { color: var(--muted); text-decoration: none; }
.footer a:hover { color: var(--text-2); }

/* ---------- Summary ---------- */
.summary {
  padding: 32px 28px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.host { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), #7c5cff);
  color: #fff;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.02em;
  background-size: cover;
  background-position: center;
  box-shadow: 0 0 0 1px var(--border), 0 0 0 4px var(--surface-2);
}
.host-name { margin: 0; font-weight: 600; }
.host-title { margin: 0; color: var(--text-2); font-size: 13px; }
.event-title { margin: 0; font-size: 24px; line-height: 1.25; font-weight: 700; letter-spacing: -0.01em; }
.meta { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; color: var(--text-2); font-weight: 500; }
.meta li { display: flex; gap: 10px; align-items: flex-start; }
.meta .icon { margin-top: 2px; color: var(--muted); }
#meta-when { color: var(--success); }
#meta-when .icon { color: var(--success); }
.duration-field { display: grid; gap: 8px; margin-top: auto; padding-top: 8px; }

.field-label { font-size: 13px; font-weight: 600; color: var(--text); }
.optional { font-weight: 400; color: var(--muted); margin-left: 4px; }

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.segmented button {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 7px 14px;
  border-radius: 7px;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-checked="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.08), 0 0 0 1px var(--border);
}
.segmented.small button { padding: 4px 10px; font-size: 13px; }

/* ---------- Panels ---------- */
.panel { padding: 32px 32px 28px; min-width: 0; }
.panel-title { margin: 0 0 24px; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }

.picker { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; }
.picker.has-day { grid-template-columns: minmax(0, 1fr) 220px; }

/* ---------- Calendar ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.cal-month { font-weight: 600; font-size: 16px; }
.cal-nav { display: flex; gap: 4px; }
.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  transition: background 0.15s;
}
.icon-btn:hover:not(:disabled) { background: var(--accent-soft-hover); }
.icon-btn:disabled { background: transparent; color: var(--muted); cursor: default; opacity: 0.5; }

.cal-weekdays, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; }
.cal-weekdays span { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; padding-bottom: 8px; }
.cal-grid { row-gap: 6px; }
.day {
  position: relative;
  justify-self: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  cursor: default;
}
.day.available {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.day.available:hover { background: var(--accent-soft-hover); }
.day[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.day.today::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 6px;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: currentColor;
}
.cal-grid.loading .day { color: transparent; }
.skeleton {
  justify-self: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2));
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.prefs {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.tz-field { display: grid; gap: 6px; flex: 1; min-width: 200px; }
.select-wrap { position: relative; }
.select-wrap::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: -5px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  pointer-events: none;
}
select {
  width: 100%;
  appearance: none;
  padding: 9px 36px 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  font-weight: 500;
}

/* ---------- Times ---------- */
.times { display: none; min-width: 0; }
.picker.has-day .times { display: flex; flex-direction: column; animation: slide-in 0.2s ease-out; }
@keyframes slide-in { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: none; } }
.times-day { margin: 6px 0 18px; font-weight: 600; }
.times-list {
  display: grid;
  gap: 8px;
  align-content: start;
  max-height: 440px;
  overflow-y: auto;
  padding: 2px 4px 2px 2px;
  scrollbar-width: thin;
}
.times-list.more-below {
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 48px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 48px), transparent);
}
.slot {
  height: 48px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 10px;
  background: var(--surface);
  color: var(--accent);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.slot:hover { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.slot-split { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; animation: fade 0.15s ease-out; }
.slot-split .chosen {
  display: grid;
  place-items: center;
  height: 48px;
  border-radius: 10px;
  background: var(--text-2);
  color: var(--surface);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.slot-split .btn { height: 48px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.state-msg { text-align: center; padding: 48px 16px; color: var(--text-2); }
.state-msg p { margin: 0 0 16px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 18px;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
}
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.secondary { background: var(--surface); border-color: var(--border-strong); }
.btn.secondary:hover { border-color: var(--text-2); }
.btn.link { background: none; color: var(--accent); padding: 8px 0; }
.btn.large { height: 50px; font-size: 16px; }
.btn:disabled { opacity: 0.7; cursor: wait; }
.spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.btn.busy .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: -6px 0 16px -8px;
  padding: 6px 10px 6px 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--accent);
  font-weight: 600;
}
.back-btn:hover { background: var(--accent-soft); }

/* ---------- Form ---------- */
.form { display: grid; gap: 18px; max-width: 460px; }
.field { display: grid; gap: 6px; }
input, textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft-hover);
}
input[aria-invalid="true"] { border-color: var(--error); }
textarea { resize: vertical; min-height: 96px; }
.form-error { margin: -6px 0 0; min-height: 0; color: var(--error); font-weight: 500; }
.form-error:empty { display: none; }

/* ---------- Done ---------- */
.done { text-align: center; padding: 48px 40px 36px; }
.done-badge {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--success-soft);
  color: var(--success);
  animation: pop 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
.done-badge .icon { width: 30px; height: 30px; stroke-width: 2.5; }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } to { transform: none; opacity: 1; } }
.done .panel-title { margin-bottom: 8px; }
.done-sub { margin: 0 0 28px; color: var(--text-2); }
.done-card {
  text-align: left;
  padding: 20px 22px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  margin-bottom: 20px;
}
.done-title { margin: 0 0 14px; font-weight: 700; font-size: 17px; }

/* ---------- Server-rendered pages (cancel, privacy) ---------- */
.card.narrow {
  max-width: 560px;
  margin: 48px auto;
  padding: 36px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card.narrow h1 { margin: 0 0 16px; font-size: 24px; letter-spacing: -0.01em; }
.card.narrow h2 { margin: 24px 0 6px; font-size: 16px; }
.card.narrow p { color: var(--text-2); }
.card.narrow button.primary {
  border: 0;
  border-radius: 10px;
  padding: 11px 20px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

/* ---------- Mobile ---------- */
@media (max-width: 820px) {
  .shell { padding: 0; justify-content: flex-start; }
  .booking { grid-template-columns: 1fr; border-radius: 0; border-width: 0 0 1px; box-shadow: none; }
  .summary { border-right: 0; border-bottom: 1px solid var(--border); padding: 24px 16px; gap: 16px; }
  .duration-field { margin-top: 0; padding-top: 0; }
  .panel { padding: 24px 16px; }
  .picker.has-day { grid-template-columns: 1fr; }
  .times-list { grid-template-columns: repeat(2, 1fr); max-height: none; overflow: visible; }
  .times-list.more-below { -webkit-mask-image: none; mask-image: none; }
  .slot-split { grid-column: 1 / -1; }
  .day { width: 40px; height: 40px; }
  .skeleton { width: 40px; height: 40px; }
  .done { padding: 40px 16px; }
  .card.narrow { margin: 0; border-radius: 0; border-width: 0 0 1px; box-shadow: none; padding: 28px 16px; }
  .footer { margin: 20px 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
