/* Calculator controls only. The page background and primary red actions retain
   their existing styles. Context selectors also override the later menu styles. */
.shell .flow .service,
.shell .flow .service-adjustment,
.shell .flow .date-mode-button,
.shell .flow .people,
.shell .flow .people button,
.shell .flow .people input,
.shell .flow :is(input, select, textarea).field,
.shell .flow .picker-trigger,
#menu-selection :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea),
#date-picker .day,
#time-picker .hour-button {
  color-scheme: light;
  background: #fff;
  color: #142028;
  border-color: #9ba6ae;
  opacity: 1;
}

.shell .flow :is(input, select, textarea).field,
.shell .flow .picker-trigger,
#menu-selection :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
  min-height: 44px;
  font-size: 16px;
}

.shell .flow .people button {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid #9ba6ae;
}

.shell .flow .people input {
  min-height: 44px;
}

.shell .flow .service-adjustment,
.shell .flow .date-mode-button,
#date-picker .day,
#time-picker .hour-button {
  min-height: 44px;
}

.shell .flow :is(input, textarea).field::placeholder,
#menu-selection :is(input, textarea)::placeholder,
.shell .flow .picker-trigger .empty {
  color: #586670;
  opacity: 1;
}

.shell .flow select.field option,
#menu-selection select option {
  background: #fff;
  color: #142028;
}

.shell .flow select.field option:disabled,
#menu-selection select option:disabled {
  color: #626d75;
}

.shell .flow .service svg,
.shell .flow .picker-trigger svg {
  stroke: #32434f;
}

.shell .flow .service .base {
  color: #52616c;
}

.shell .flow .service .tick {
  background: #fff;
  border-color: #65747f;
  color: #243640;
}

@media (hover: hover) {
  .shell .flow .service:where(:not(:disabled)):hover,
  .shell .flow .service-adjustment:where(:not(:disabled)):hover,
  .shell .flow .date-mode-button:where(:not(:disabled)):hover,
  .shell .flow .people button:where(:not(:disabled)):hover,
  .shell .flow .picker-trigger:where(:not(:disabled)):hover,
  #date-picker .day:where(:not(:disabled)):hover,
  #time-picker .hour-button:where(:not(:disabled)):hover {
    background: #fff;
    border-color: #304551;
    box-shadow: inset 0 0 0 1px #304551;
  }
}

.shell .flow .service[aria-pressed="true"],
.shell .flow .service-adjustment[aria-pressed="true"],
#time-picker .hour-button[aria-pressed="true"] {
  background: #fff;
  color: #142028;
  border-color: #087443;
  box-shadow: inset 0 0 0 1px #087443;
  font-weight: 700;
}

.shell .flow .service[aria-pressed="true"] svg {
  stroke: #087443;
}

.shell .flow .service[aria-pressed="true"] .tick {
  background: #087443;
  border-color: #087443;
  color: #fff;
}

.shell .flow .service-adjustment[aria-pressed="true"] .service-sign {
  color: #087443;
  font-weight: 700;
}

.shell .flow .date-mode-button[aria-pressed="true"]::after {
  content: " ✓";
  color: #142028;
}

#date-picker .day[aria-pressed="true"]::after {
  background: #142028;
}

/* A selected date is not an availability observation. */
.shell .flow .date-mode-button[aria-pressed="true"],
#date-picker .day[aria-pressed="true"] {
  background: #fff;
  color: #142028;
  border-color: #142028;
  box-shadow: inset 0 0 0 2px #142028;
  font-weight: 700;
}

#date-picker .day {
  min-width: 44px;
}

.shell .flow .service:not([aria-pressed="true"]):disabled,
.shell .flow .service-adjustment:disabled,
.shell .flow .date-mode-button:disabled,
.shell .flow .people button:disabled,
.shell .flow :is(input, select, textarea).field:disabled,
.shell .flow .picker-trigger:disabled,
#menu-selection :is(input, select, textarea):disabled,
#date-picker .day:disabled,
#time-picker .hour-button:disabled {
  background: #e8ecee;
  color: #59656e;
  border-color: #a3adb4;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 1;
}

#date-picker .day:disabled {
  background: #343e46;
  color: #adb5bc;
  border-color: #58656f;
  text-decoration: line-through;
}

#date-picker .day[aria-pressed="true"]:disabled::after {
  display: none;
}

.shell .flow .service:focus-visible,
.shell .flow .service-adjustment:focus-visible,
.shell .flow .date-mode-button:focus-visible,
.shell .flow .people :is(button, input):focus-visible,
.shell .flow .field:focus-visible,
.shell .flow .picker-trigger:focus-visible,
#menu-selection :is(input, select, textarea):focus-visible,
#date-picker .day:focus-visible,
#time-picker .hour-button:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 4px;
}

.shell .flow .people:focus-within {
  outline: 3px solid #fff;
  outline-offset: 4px;
}

.shell .flow .people input:focus-visible {
  outline: 2px solid #087443;
  outline-offset: -2px;
}

/* Size the dialog against the viewport rather than an ancestor's percentage.
   Native modal focus and all calendar/date logic remain unchanged. */
#date-picker,
#time-picker {
  position: fixed;
  inset: 0;
  margin: auto;
  box-sizing: border-box;
  width: min(420px, calc(100vw - 24px));
  min-width: 0;
  max-width: calc(100vw - 24px);
  height: fit-content;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

@supports (height: 100dvh) {
  #date-picker,
  #time-picker {
    max-height: calc(100dvh - 24px);
  }
}

#date-picker .picker-head,
#time-picker .picker-head {
  position: sticky;
  top: 0;
  z-index: 2;
  min-width: 0;
  background: var(--bg, #0e1317);
}

#date-picker .picker-head h2,
#time-picker .picker-head h2,
#date-picker .calendar-nav h3 {
  min-width: 0;
  overflow-wrap: anywhere;
}

#date-picker .picker-close,
#time-picker .picker-close,
#date-picker .calendar-nav button {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
}

#date-picker .calendar-nav {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  gap: 8px;
  align-items: center;
}

#date-picker .calendar-nav h3 {
  text-align: center;
}

#date-picker [role="grid"],
#date-picker #calendar-days,
#date-picker .calendar-week,
#date-picker [role="gridcell"] {
  min-width: 0;
  max-width: 100%;
}

#date-picker .calendar-week {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

#date-picker .day {
  box-sizing: border-box;
  display: grid;
  place-items: center;
  padding: 0;
  max-width: 100%;
}

/* Seven 44px day targets still fit a 320px mobile viewport. Keeping this
   padding small avoids pushing the first/last column outside the dialog. */
@media (max-width: 400px) {
  #date-picker {
    width: calc(100vw - 4px);
    max-width: calc(100vw - 4px);
    padding: clamp(3px, calc(50vw - 157px), 12px);
  }

  #date-picker .calendar-week {
    gap: 0;
  }
}

/* Very narrow effective viewports may shrink columns, while keeping their
   vertical target and the seven-day structure. Never force horizontal scroll. */
@media (max-width: 319px) {
  #date-picker .day {
    min-width: 0;
    aspect-ratio: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .shell .flow .service,
  .shell .flow .service-adjustment,
  .shell .flow .date-mode-button {
    transition: none;
  }
}
