.confirmation-first-compact { display: none; }
.booking-mobile-back { display: none; }
.booking-details-actions { display: contents; }
/* Booking shares the index's capped outer frame and menu sizing.
   Later booking steps retain their established calendar and checkout sizing. */
html body.booking-page main#main-content.responsive-booking {
  --booking-frame: min(1600px, calc(100% - clamp(48px, 12vw, 320px)));
  --booking-gap: clamp(28px, 3.3vw, 64px);
  --booking-title: clamp(40px, 4.34vw, 84px);
  width: var(--booking-frame); max-width: none;
  height: auto; min-height: calc(100svh - var(--header-height));
  display: grid; grid-template-rows: max-content minmax(min-content, 1fr);
  /* Keep the divider at the same heading offset throughout every booking step. */
  row-gap: 40px; margin-inline: auto;
  padding: calc(var(--header-height) + 32px) 0 32px;
  overflow: visible;

  & .workspace-heading { margin: 0; }
  & .workspace-heading h1 {
    font-size: var(--booking-title); line-height: 1.02;
    font-weight: 400; letter-spacing: -.045em; text-wrap: balance;
  }
  & .workspace-heading p { font: 300 16px/1.55 var(--sans); margin-top: 18px; }
  & .booking-workspace { min-width: 0; min-height: 0; }
  & .booking-view--format { padding-block: 12px; }
  & .booking-menu { column-gap: var(--booking-gap); }
  & .details-layout .slot-summary { margin-top: 56px; }
  & .details-layout .details-slot-line { display: block; }
  & .details-layout .booking-slot-meta { font: inherit; color: inherit; opacity: .45; }
  & .details-layout .details-slot > .first-lesson { display: block; }
  & .checkout-review-content .checkout-inline-meta { display: inline; font: inherit; color: inherit; opacity: .45; }
}

/* The calendar keeps its flexible 22px minimum rows and independently reserved
   summary from workspace.css. Short windows can scroll at the natural minimum;
   larger windows give the rows the remaining room. Checkout retains its fitter. */
@media (min-width: 768px) and (min-height: 601px), (min-width: 1001px), (min-width: 768px) and (pointer: fine) {
  html:not(.tablet-portrait) body.booking-page main#main-content.responsive-booking:has(.checkout-pair, .booking-view--confirming, .booking-view--success) {
    height: calc(100svh - var(--header-height)); min-height: 0;
    grid-template-rows: max-content minmax(0, 1fr);
    padding-bottom: 0;
  }
}

/* Only the calendar workspace compacts; the page heading retains its initial
   size and position. Calendar rows and summary keep independent space. */
@media (min-width: 768px) and (pointer: fine) {
  html:not(.tablet-portrait):not(.phone-layout) body.booking-page main#main-content.responsive-booking:has(.booking-view--calendar) {
    height: auto; min-height: calc(100svh - var(--header-height));
    grid-template-rows: max-content minmax(min-content, 1fr);
    padding-bottom: 0;
    & .booking-toolbar { min-height: 50px; flex-shrink: 0; }
    & .booking-view--calendar { gap: 8px; }
    & .booking-status { flex-shrink: 0; }
  }
}

@media (max-width: 1000px) {
  html body.booking-page main#main-content.responsive-booking {
    --booking-frame: calc(100% - 64px);
    --booking-title: clamp(40px, 5.5vw, 55px);
    --booking-gap: 32px;
  }
}

@media (max-width: 767px), (max-width: 1000px) and (max-height: 600px) and (pointer: coarse) {
  html body.booking-page main#main-content.responsive-booking {
    --booking-frame: calc(100% - 2 * var(--phone-gutter, 24px));
    --booking-title: clamp(32px, 9vw, 38px);
    --booking-gap: 24px;
    height: auto; min-height: calc(100svh - 90px); row-gap: 28px;
    padding-top: calc(var(--header-height) + 28px); padding-bottom: 12px;
    & .details-layout .slot-summary { margin-top: 40px; }
  }
}

/* A readable confirmation card follows normal flow if a short screen needs more
   room. The page heading and divider keep the same position as earlier steps. */
html body.booking-page main#main-content.responsive-booking:has(.booking-view--success > .booking-confirmation) {
  height: auto; min-height: calc(100svh - var(--header-height));
  grid-template-rows: max-content minmax(min-content, 1fr);
  padding-bottom: 24px;

  & .booking-view--success { min-height: 0; padding-top: 28px; }
  & .booking-confirmation {
    position: static; width: 100%; max-width: none;
    margin: auto; transform: none;
    font: 300 14px/1.55 var(--sans); color: var(--ink);
  }
  & .booking-confirmation .success-symbol {
    width: 56px; height: 56px; margin-bottom: 20px;
    background: rgba(255,255,255,.20); border-color: rgba(255,255,255,.8);
  }
  & .booking-confirmation .success-symbol svg { width: 26px; height: 26px; }
  & .booking-confirmation h2 { font-size: clamp(32px,3.1vw,46px); }
  & .booking-confirmation p { margin: 0; font: inherit; }
  & .booking-confirmation #success-message { margin-top: 12px; font-size: 16px; }
  & .confirmation-card {
    max-width: 620px; margin-inline: auto; margin-top: 28px; padding: 28px 32px 24px;
    background: rgba(255,255,255,.20); border: 1px solid rgba(255,255,255,.8);
    border-radius: 22px; text-align: left;
  }
  & .confirmation-facts { display: grid; gap: 12px; margin: 0; }
  & .confirmation-row {
    display: grid; grid-template-columns: max-content minmax(0,1fr);
    align-items: baseline; gap: 24px;
  }
  & .confirmation-row dt { color: var(--muted); }
  & .confirmation-row dd { margin: 0; font-weight: 500; text-align: right; }
  & .confirmation-time { display: block; }
  & .confirmation-time + .confirmation-time { margin-top: 12px; }
  & .confirmation-first-lesson { display: block; font-weight: 300; color: var(--muted); }
  & .confirmation-notes {
    display: grid; gap: 16px; margin-top: 24px; padding-block: 22px;
    border-block: 1px solid var(--line);
  }
  & .confirmation-notes p { display: flex; align-items: flex-start; gap: 12px; }
  & .confirmation-notes svg { flex: 0 0 18px; width: 18px; height: 18px; margin-top: 2px; }
  & .booking-confirmation strong { font-weight: 500; }
  & .confirmation-email { overflow-wrap: anywhere; }
  & .confirmation-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; padding-top: 22px; }
  & .confirmation-button {
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    min-height: 44px; padding: 10px 22px; border: 1px solid var(--ink); border-radius: 999px;
    font: 500 14px/1.4 var(--sans); text-decoration: none; cursor: pointer;
    transition: background-color .2s ease;
  }
  & .confirmation-button--secondary { background: transparent; color: var(--ink); }
  & .confirmation-button--secondary:hover { background: rgba(255,255,255,.4); }
  & .confirmation-button--primary { background: #292929; color: #fff; }
  & .confirmation-button--primary:hover { background: #3a3a3a; }
  & .confirmation-button:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
  & .confirmation-help { max-width: none; margin: 16px auto 0; color: var(--muted); }
  & .confirmation-help p + p { margin-top: 16px; }
  & :is(.confirmation-help,.confirmation-notes,.confirmation-facts) a {
    font-weight: 500; color: var(--ink); text-decoration: underline; text-underline-offset: .16em;
  }
}

@media (max-width: 600px) {
  html body.booking-page main#main-content.responsive-booking:has(.booking-view--success > .booking-confirmation) {
    & .booking-view--success { padding-top: 12px; }
    & .confirmation-card { padding: 22px 20px; }
    & .confirmation-row { gap: 12px; }
    & .confirmation-actions { gap: 10px; }
    & .confirmation-button { padding-inline: 16px; }
  }
}

/* Phones keep the introduction only while choosing a lesson path. Removing
   its grid row also returns that space to every subsequent booking screen. */
@media (max-width: 767px), (max-width: 1000px) and (max-height: 600px) and (pointer: coarse) {
  /* The initial phone menu is one screen, like the index lesson panel. */
  html:not(.tablet-portrait) body.booking-page main#main-content.responsive-booking:has(.booking-view--format) {
    height: 100svh; min-height: 0;
    grid-template-rows: max-content minmax(0, 1fr); row-gap: 12px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    & .workspace-heading p { font-size: 12.5px; }
    & .booking-workspace { min-height: 0; }
    & .booking-view--format { position: relative; display: block; flex: 1; padding: 0; overflow: clip; }
    & .booking-menu {
      position: absolute; top: 0; left: 50%;
      width: var(--booking-menu-width, 100%); gap: 8px 0;
      transform: translateX(-50%) scale(var(--booking-menu-scale, 1)); transform-origin: 50% 0;
    }
    & .booking-good-to-know, & .booking-status:empty { display: none; }
  }
  html:not(.tablet-portrait) body.booking-page:has(.booking-view--format) > .contact-footer { display: none; }
  html:not(.tablet-portrait) body.booking-page main#main-content.responsive-booking:has(.booking-view:not(.booking-view--format)) {
    grid-template-rows: minmax(min-content, 1fr);
    row-gap: 0;
    & > .workspace-heading { display: none; }
  }

  /* Selection steps share the opening heading position. Back sits beside the
     bottom action, so it no longer inserts a separate row above the title. */
  html:not(.tablet-portrait) body.booking-page main#main-content.responsive-booking:has(.booking-view:is(.booking-view--calendar, .booking-view--style)) {
    height: 100svh; min-height: 0;
    grid-template-rows: minmax(0, 1fr);
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    & .booking-workspace { min-height: 0; }
    & .booking-toolbar { display: none; }
    & .booking-mobile-back {
      display: inline-flex; align-items: center; justify-self: start;
      height: 44px; min-height: 44px; padding-inline: 0 16px;
      font: 300 12.5px/1.55 var(--sans);
    }
    & .booking-status { order: 2; height: auto; min-height: 0; flex: 0 0 auto; margin-top: 8px; }
    & .booking-status:empty { display: none; }
    & :is(.calendar-heading, .step-heading) h2 {
      font-size: 28px; font-weight: 400; line-height: 1.08;
      letter-spacing: -.035em; text-wrap: balance;
    }
    & :is(.calendar-heading, .step-heading) p {
      margin-top: 18px; font: 300 12.5px/1.55 var(--sans);
    }
    & .booking-view--calendar {
      flex: 1; display: grid;
      grid-template-rows: max-content minmax(254px, 1fr) max-content;
      gap: 10px; justify-content: stretch;
    }
    & .calendar-heading { gap: 12px; }
    & .week-navigation { height: 36px; gap: 8px; }
    & .week-navigation button { width: 36px; height: 36px; flex-shrink: 0; }
    & .week-navigation > span { font-size: 12.5px; }
    & .week-navigation small { display: inline; margin: 0 0 0 8px; font-size: 11px; }
    & .calendar-grid {
      grid-template-columns: 30px repeat(7, minmax(0, 1fr));
      grid-template-rows: 30px repeat(14, minmax(14px, 1fr));
      gap: 2px 3px; min-height: 254px; padding: 0;
    }
    & .calendar-date { padding-bottom: 4px; gap: 1px; }
    & .calendar-date span { font-size: 10px; }
    & .calendar-date strong { font-size: 14px; }
    & .calendar-hour { font-size: 10px; }
    & .calendar-slot { min-height: 0; }
    & .slot-mark { font-size: 10px; }
    & .booking-view--calendar > .calendar-actions {
      height: auto; min-height: 0; flex: none;
      display: grid; grid-template-columns: minmax(0, 1fr) 128px;
      grid-template-rows: auto 44px; gap: 8px 12px; padding-top: 8px;
    }
    & .calendar-selection {
      grid-column: 1 / -1; height: auto; min-height: 36px; overflow: visible;
      font: 300 12px/1.4 var(--sans); gap: 4px; justify-content: center;
    }
    & .recurring-slot-summary { display: flex; flex-wrap: wrap; gap: 0 6px; }
    & .first-lesson { font-size: 11px; }
    & .calendar-actions > .booking-mobile-back { grid-column: 1; grid-row: 2; }
    & .calendar-actions > .booking-primary {
      grid-column: 2; grid-row: 2; min-height: 44px; height: 44px;
      padding: 10px 16px; font-size: 12.5px; border-radius: 999px;
    }
    & .booking-view--style { flex: 1; gap: 24px; }
    & .booking-view--style > .booking-mobile-back { margin-top: auto; align-self: flex-start; flex-shrink: 0; }
    & .schedule-options { margin: 0; gap: 12px; }
    & .schedule-option { padding: 16px; }
    & .schedule-option h3 { margin: 8px 0; font-size: 22px; }
    & .schedule-option p { font-size: 12.5px; line-height: 1.5; }
    & .schedule-option .format-kicker { font-size: 11px; }
  }
  html:not(.tablet-portrait) body.booking-page:has(.booking-view--calendar, .booking-view--style) > .contact-footer { display: none; }

  html:not(.tablet-portrait) body.booking-page main#main-content.responsive-booking:has(.booking-view--details) {
    & .booking-toolbar { display: none; }
    & .details-layout { align-items: start; row-gap: 40px; }
    & .step-heading h2 { font-size: 28px; font-weight: 400; line-height: 1.08; letter-spacing: -.035em; text-wrap: balance; }
    & .step-heading > p { margin-top: 18px; font: 300 12.5px/1.55 var(--sans); }
    & .booking-details-actions { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
    & .booking-details-actions > .booking-mobile-back {
      display: inline-flex; align-items: center; justify-content: center;
      width: 100%; height: 48px; min-height: 44px; padding: 10px 16px;
      background: rgba(255,255,255,.20); border: 1px solid rgba(255,255,255,.5);
      border-radius: 999px; color: var(--ink); font: 300 12.5px/1.55 var(--sans);
    }
    & .booking-details-actions > .booking-mobile-back:hover { background: rgba(255,255,255,.3); opacity: 1; }
    & .booking-details-actions > .booking-primary { font-size: 12.5px; gap: 12px; }
  }
}

/* Mobile review keeps the same introduction as Details without the old fixed
   checkout height. Secure payment fields retain their natural scrolling flow. */
@media (max-width: 767px), (max-width: 1000px) and (max-height: 600px) and (pointer: coarse) {
  html:not(.tablet-portrait) body.booking-page main#main-content.responsive-booking:has(.booking-view:is(.booking-view--checkout, .booking-view--payment)) {
    height: auto; min-height: 100svh;
    grid-template-rows: minmax(0, 1fr);
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    & .booking-toolbar { display: none; }
    & .booking-view { flex: 1; margin: 0; }
    & .checkout-pair { position: static; width: 100%; gap: 20px; transform: none; align-items: start; }
    & .step-heading h2 { font-size: 28px; font-weight: 400; line-height: 1.08; letter-spacing: -.035em; text-wrap: balance; }
    & .step-heading > p { margin-top: 18px; font: 300 12.5px/1.55 var(--sans); }
    & .checkout-card-frame { height: auto !important; min-height: 0; }
    & .checkout-card-inner { position: static; width: 100%; transform: none; }
    & .booking-status { height: auto; min-height: 0; flex: 0 0 auto; margin-top: 8px; }
    & .booking-status:empty { display: none; }
    & .booking-mobile-back {
      display: inline-flex; align-items: center; justify-content: center;
      width: 100%; height: 48px; min-height: 48px; padding: 10px 16px;
      background: rgba(255,255,255,.20); border: 1px solid rgba(255,255,255,.5);
      border-radius: 999px; color: var(--ink); font: 300 12.5px/1.55 var(--sans);
      margin-top: 10px;
    }
    & .booking-mobile-back:hover { background: rgba(255,255,255,.3); opacity: 1; }
    & .booking-primary { width: 100%; min-height: 48px; height: 48px; font-size: 12.5px; gap: 12px; }
  }
  html:not(.tablet-portrait) body.booking-page main#main-content.responsive-booking:has(.booking-view.booking-view--checkout) {
    height: 100svh; min-height: 0;
    & .checkout-review-content { min-height: 0; padding: 16px; }
    & .order-line { gap: 10px; font: 300 12.5px/1.5 var(--sans); }
    & .order-line strong { font-size: 12.5px; }
    & .order-line small { margin-top: 3px; font-size: 11px; line-height: 1.4; }
    & .slot-summary { gap: 6px; margin-block: 12px; font: 300 12.5px/1.4 var(--sans); }
    & .recurring-slot-summary { display: flex; flex-direction: column; gap: 2px; }
    & .first-lesson, & .slot-summary > small { font-size: 11px; line-height: 1.4; }
    & .order-total { margin-top: 0; padding: 12px 0; font-size: 12.5px; }
    & .order-total strong { font-size: 22px; }
    & .policy-check { margin: 4px 0 10px; font-size: 12.5px; line-height: 1.4; }
    & .policy-check input { width: 18px; height: 18px; margin-top: 0; }
    & .checkout-note { order: 1; margin: 0 0 12px; font: 300 11px/1.4 var(--sans); }
    & .booking-primary { order: 2; }
    & .booking-mobile-back { order: 3; }
    @media (max-height: 600px) {
      & .checkout-pair { gap: 8px; }
      & .checkout-review-content { padding: 10px; }
      & .slot-summary { margin-block: 4px; gap: 2px; line-height: 1.3; }
      & .order-total { padding: 4px 0; }
      & .order-total strong { font-size: 20px; }
      & .policy-check { margin-block: 2px 4px; }
      & .checkout-note { margin-bottom: 4px; }
      & .booking-primary, & .booking-mobile-back { height: 44px; min-height: 44px; padding-block: 8px; }
      & .booking-mobile-back { margin-top: 6px; }
    }
  }
  html:not(.tablet-portrait) body.booking-page:has(.booking-view--checkout, .booking-view--payment) > .contact-footer { display: none; }
}

/* Phone confirmation uses the available space, with centered readable content.
   Keep natural overflow for larger text or unusually short screens. */
@media (max-width: 767px), (max-width: 1000px) and (max-height: 600px) and (pointer: coarse) {
  html:not(.tablet-portrait) body.booking-page main#main-content.responsive-booking:has(.booking-view--success > .booking-confirmation) {
    height: auto; min-height: 100svh;
    grid-template-rows: minmax(min-content, 1fr); row-gap: 0;
    padding-top: calc(var(--header-height) + 28px);
    padding-bottom: max(28px, env(safe-area-inset-bottom));
    & > .workspace-heading, & .booking-toolbar, & .booking-status:empty { display: none; }
    & .booking-workspace { min-height: 0; justify-content: center; }
    & .booking-view--success { flex: 0 0 auto; min-height: 0; padding-top: 0; justify-content: center; }
    & .booking-confirmation {
      position: static; width: 100%; max-width: none; margin: 0;
      transform: none; text-align: center; font: 300 14px/1.45 var(--sans);
    }
    & .booking-confirmation .success-symbol,
    & .confirmation-button--secondary { display: none; }
    & .booking-confirmation h2 {
      font-size: 28px; font-weight: 400; line-height: 1.08;
      letter-spacing: -.035em; text-wrap: balance;
    }
    & .booking-confirmation #success-message { margin-top: 14px; font: 300 14px/1.5 var(--sans); }
    & .confirmation-card { margin-top: 24px; padding: 22px 20px; border-radius: 20px; text-align: left; }
    & .confirmation-facts { gap: 12px; }
    & .confirmation-row { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 16px; }
    & .confirmation-row dt { text-align: left; }
    & .confirmation-row dd { font-weight: 500; text-align: right; }
    & .confirmation-time + .confirmation-time { margin-top: 12px; }
    & .confirmation-first-lesson { margin-top: 4px; font-size: 12.5px; line-height: 1.45; }
    & .confirmation-notes { gap: 14px; margin-top: 20px; padding-block: 18px; }
    & .confirmation-notes p { display: flex; align-items: flex-start; gap: 10px; text-align: left; }
    & .confirmation-notes svg { flex: 0 0 16px; width: 16px; height: 16px; margin-top: 2px; }
    & .confirmation-actions { gap: 0; padding-top: 20px; justify-content: center; }
    & .confirmation-button--primary { width: 100%; min-height: 48px; padding: 12px 16px; border-radius: 999px; font: 300 14px/1.5 var(--sans); }
    & .confirmation-help { max-width: none; margin-top: 20px; font-size: 12.5px; line-height: 1.5; text-align: center; text-wrap: pretty; }
    & .confirmation-help p + p { margin-top: 12px; }
    & .booking-status { height: auto; min-height: 0; flex: 0 0 auto; margin-top: 12px; text-align: center; }
  }
  html:not(.tablet-portrait) body.booking-page:has(.booking-view--success > .booking-confirmation) > .contact-footer { display: none; }
}
