.booking-dialog {
  width: min(680px, calc(100% - 40px));
  max-width: 100%;
  max-height: calc(100dvh - 40px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--on-surface);
  box-shadow: 0 24px 90px var(--dialog-shadow);
  overflow: hidden;
  overscroll-behavior: contain;
}

.booking-dialog[open] {
  display: flex;
  flex-direction: column;
}

.booking-dialog[data-booking-stage="preview"] {
  width: min(940px, calc(100% - 40px));
}

.booking-dialog::backdrop {
  background: var(--backdrop);
  backdrop-filter: blur(5px);
}

.dialog-inner {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  max-height: inherit;
}

.dialog-top {
  display: flex;
  align-items: flex-start;
  flex: none;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--primary);
  color: var(--on-primary);
}

.dialog-heading {
  min-width: 0;
}

.booking-dialog h2 {
  margin: 0 0 10px;
  color: var(--on-primary);
  font-size: clamp(22px, 2.2vw, 27px);
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: -0.025em;
  hyphens: manual;
  text-wrap: pretty;
}

.booking-dialog[data-booking-stage="preview"] h2,
.booking-dialog[data-booking-stage="done"] h2 {
  margin-bottom: 0;
}

.dialog-heading > p:last-child {
  margin: 0;
  font-size: 16px;
  line-height: 1.6;
}

.dialog-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--secondary);
  color: var(--on-surface);
}

.dialog-close:hover {
  background: var(--surface);
}

.dialog-top :focus-visible {
  outline-color: var(--secondary);
}

.dialog-content {
  min-height: 0;
  padding: 20px 28px 28px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.booking-panel,
.booking-form {
  min-width: 0;
  margin: 0;
}

.booking-progress-text {
  margin: 0 0 8px;
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
}

.booking-form .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.booking-progress {
  height: 6px;
  margin: 0 0 26px;
  border-radius: 4px;
  background: var(--line);
  overflow: hidden;
}

.booking-progress-fill {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transform: scaleX(.2);
  transform-origin: left;
  transition: transform 420ms cubic-bezier(.22, 1, .36, 1);
}

.booking-progress[data-progress-step="2"] .booking-progress-fill { transform: scaleX(.4); }
.booking-progress[data-progress-step="3"] .booking-progress-fill { transform: scaleX(.6); }
.booking-progress[data-progress-step="4"] .booking-progress-fill { transform: scaleX(.8); }
.booking-progress[data-progress-step="5"] .booking-progress-fill { transform: scaleX(1); }

@media (prefers-reduced-motion: reduce) {
  .booking-progress-fill { transition: none; }
}

.booking-form fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.booking-form legend {
  width: 100%;
  margin: 0 0 20px;
  padding: 0;
  font-family: var(--font-heading);
  font-size: clamp(21px, 2.2vw, 25px);
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.name-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.form-field {
  min-width: 0;
}

.form-field label {
  display: block;
  margin-bottom: 8px;
  color: var(--on-surface);
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 600;
}

.form-field input,
.booking-form textarea {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 50px;
  padding: 12px 14px;
  border: 1px solid var(--input-line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--on-surface);
  font-family: var(--font-heading);
  font-size: 16px;
  line-height: 1.5;
}

.booking-form textarea {
  min-height: 130px;
  max-height: 40dvh;
  resize: vertical;
}

.form-field input:focus,
.booking-form textarea:focus {
  background-color: var(--input-surface-active);
  border-color: var(--primary);
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Inset paint covers the browser's protected autofill background. */
.form-field input:is(:autofill, :-webkit-autofill) {
  box-shadow: 0 0 0 1000px var(--input-surface-active) inset;
  -webkit-text-fill-color: var(--on-surface);
  caret-color: var(--on-surface);
}

.form-field input::selection,
.booking-form textarea::selection {
  background: var(--secondary);
  color: var(--on-surface);
}

.form-field:focus-within label {
  color: var(--primary);
}

.booking-form [aria-invalid="true"] {
  border-color: var(--error-line);
}

.field-hint,
.form-error {
  margin: 12px 0 0;
  font-size: 16px;
  line-height: 1.6;
}

.field-hint {
  color: var(--on-surface);
}

.form-error {
  color: var(--error-text);
}

.readiness-rating {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 8px;
  margin-top: 20px;
}

.readiness-choice {
  position: relative;
  cursor: pointer;
}

.readiness-choice input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.readiness-choice span {
  display: grid;
  place-items: center;
  min-height: 46px;
  border: 1px solid var(--input-line);
  border-radius: 6px;
  background: var(--surface);
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
}

.readiness-choice input:checked + span {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

.readiness-choice input:focus-visible + span {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

.readiness-choice input[aria-invalid="true"] + span {
  border-color: var(--error-line);
}

.intake-actions,
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 26px;
}

.booking-dialog .button-secondary {
  background: var(--surface);
  color: var(--primary);
  border-color: var(--input-line);
}

.intake-next {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-left: auto;
}

.intake-next svg {
  flex: none;
}

.intake-actions .button,
.dialog-actions .button {
  min-height: 48px;
}

.booking-panel h3 {
  font-size: clamp(21px, 2.2vw, 26px);
  line-height: 1.4;
}

.booking-panel h3 + p {
  margin-top: 16px;
  font-size: 16px;
}

.calendar-feedback {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 0 0 16px;
}

.calendar-status {
  flex: 1 1 260px;
  margin: 0;
  font-size: 16px;
  line-height: 1.6;
}

.calendar-status[data-state="error"] {
  color: var(--error-text);
}

.booking-calendar {
  min-width: 0;
  border-radius: 8px;
  overflow: hidden;
}

.booking-calendar-frame {
  display: block;
  width: 100%;
  min-width: 0;
  height: 780px;
  border: 0;
  background: var(--surface);
  color-scheme: light;
}

@media (max-width: 600px) {
  .booking-dialog,
  .booking-dialog[data-booking-stage="preview"] {
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .dialog-top {
    gap: 14px;
    padding: 18px 18px 16px;
  }

  .dialog-content {
    padding: 20px 20px 24px;
  }

  .name-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .readiness-rating {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
  }

  .booking-form textarea {
    min-height: 110px;
    height: 110px;
  }

  .booking-calendar {
    width: calc(100% + 40px);
    margin-inline: -20px;
    border-radius: 0;
  }

  .booking-calendar-frame {
    height: 960px;
  }
}
