/* Booking form, desktop overlay and mobile bottom sheet. */
html.sheetPageLocked {overflow: hidden; overscroll-behavior: none;}
html.sheetPageLocked body {overscroll-behavior: none;}

#editor {
  --color-control-border: var(--color-editor-divider);
  --color-text: var(--color-editor-text);
  --color-heading: var(--color-editor-text);
  --color-secondary: var(--color-editor-secondary);
  --line: var(--color-editor-divider);
  position: relative;
  background: var(--color-editor-bg);
  color: var(--color-editor-text);
  padding: 0 16px 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#booking {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 0 1 auto;
}

#controls {display: contents;}

.editorScroll {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  padding-bottom: 4px;
  scroll-padding-block: 8px;
}

.editorTop {
  flex-shrink: 0;
  z-index: 4;
  margin: 0 -16px 2px;
  padding: 2px 12px 2px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-editor-bg);
  font-weight: 700;
  color: var(--color-secondary);
}

#editorContext {
  color: var(--color-editor-heading);
}

#editor header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

#title {
  color: var(--color-secondary);
  font-size: var(--font-table);
  font-variant-numeric: tabular-nums;
}

#editor label {
  display: block;
  margin: 0 0 6px;
  font-size: var(--font-label);
  font-weight: var(--weight-bold);
  color: var(--color-editor-text);
}

#editor #work {
  min-height: 40px;
  line-height: 1.3;
  resize: none;
  overflow-y: hidden;
}

#editor .fieldControl {
  min-height: 34px;
  margin-top: 3px;
  padding: 5px 8px;
  font-size: var(--font-control);
}

#editor .fieldControl:hover:not(:disabled):not([aria-invalid=true]) {
  border-color: var(--color-editor-border);
}

#editor .pair {gap: 8px;}
#editor .button {min-height: 40px; padding: 8px 12px;}
#editor #back {width: 40px; min-width: 40px; padding: 8px;}

#editor label.switch, .phone {
  display: flex;
  gap: 7px;
  align-items: center;
}

#editor label.switch {
  position: relative;
  margin: 0;
  font-size: var(--font-label);
  font-weight: var(--weight-normal);
  color: var(--color-secondary);
  min-height: 32px;
  cursor: pointer;
}

#editor .switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.switchTrack {
  width: 28px;
  height: 17px;
  background: var(--color-border);
  border: 1px solid var(--color-control-border);
  border-radius: 20px;
}

.switchTrack::after {
  content: '';
  display: block;
  width: 11px;
  height: 11px;
  margin: 2px;
  background: var(--color-muted);
  border-radius: 50%;
}

.switch input:checked + .switchTrack {
  background: var(--color-action);
  border-color: var(--color-action);
}

.switch input:checked + .switchTrack::after {
  background: var(--color-surface);
  transform: translateX(11px);
}

.switch input:focus-visible + .switchTrack {
  outline: 2px solid var(--color-action);
  outline-offset: 2px;
}

.phone {
  gap: 0;
  margin-top: 3px;
  border: 1px solid var(--color-control-border);
  background: var(--color-surface);
  border-radius: var(--radius-control);
  padding-left: 10px;
}

.phone b {
  font-size: var(--font-control);
  font-weight: var(--weight-normal);
  color: var(--color-heading);
}

#editor .phone input {
  margin: 0;
  border: 0;
  min-height: 32px;
  padding-left: 0;
}

.phone:has(input:focus-visible) {
  outline: 2px solid var(--color-action);
  outline-offset: 2px;
}

#editor .phone input:focus-visible {
  outline: 0;
}

.formActions {
  flex-shrink: 0;
  z-index: 3;
  padding: 8px 0 0;
  background: var(--color-editor-bg);
  border-top: 1px solid var(--line);
}

#editState {
  display: block;
  font-size: var(--font-xs);
  text-align: center;
  color: var(--color-muted);
  margin-bottom: 4px;
}

#editState:empty {
  display: none;
}

@media(min-width:761px) {
  .editing #calendar {
    /* Keep the calendar's white surface out of the overlay's rounded corners. */
    clip-path: inset(0 var(--editor-width) 0 0 round var(--radius-panel) 0 0 var(--radius-panel));
  }
  #editor {
    position: absolute;
    inset: 0 0 0 auto;
    z-index: 6;
    width: var(--editor-width);
    border-radius: 0 var(--radius-panel) var(--radius-panel) 0;
    box-shadow: var(--shadow-editor);
  }
  .editing .navigation, .editing #viewport {
    width: calc(100% - var(--editor-width));
  }
  .editing .navigation {
    padding-right: calc(12px + var(--editor-fade));
  }
  .editing #viewport {
    padding-right: var(--editor-fade);
  }
  .editing .workspace::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    right: var(--editor-width);
    width: var(--editor-fade);
    z-index: 5;
    background: var(--editor-edge);
    pointer-events: none;
  }
  .editing #viewport table {
    width: calc(100% + var(--editor-width) + var(--editor-fade));
  }
}

@media(max-width:760px) {
  .editorTop {
    margin-inline: -16px;
  }
  .formActions {
    padding-bottom: 0;
  }
}

#back {
  flex: 0 0 auto;
}

#save {
  width: 100%;
}

#remove {
  display: flex;
  margin: 2px auto 0;
  font-size: var(--font-label);
}

#editorMessage {
  margin-bottom: 12px;
}

#editor .notice {padding: 10px;}
#editor .editorNotices {
  max-height: min(25dvh,140px,calc(var(--sheet-max-height,96dvh) / 4));
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0;
}
#editor .editorNotices > :is(#editorMessage,#remoteConflict) {margin:0 0 8px;}

#bookingHelp {
  font-size: var(--font-label);
  color: var(--color-secondary);
  margin-bottom: var(--space-4);
}

.bookingIdentity {
  margin-bottom: 2px !important;
}

.masterPicker {
  display: flex;
  align-items: center;
  gap: 5px;
  position: relative;
  min-width: 0;
}

#editorContext {
  font-size: 18px;
  margin: 0;
  line-height: 1.2;
}

.inlinePicker {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  font-size: 16px;
}

.inlinePicker:disabled {
  pointer-events: none;
}

.masterPicker:has(:focus-visible), .datePicker:has(:focus-visible) {
  outline: 2px solid var(--color-action);
  outline-offset: 2px;
  border-radius: 4px;
}

.editChevron {
  width: 16px;
  height: 16px;
  color: var(--color-editor-secondary);
}

.editChevron, .datePicker .icon {
  display: none;
}

.canMove .editChevron, .canMove .datePicker .icon {
  display: block;
}

.bookingDate {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--color-secondary);
}

#editorMode {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-editor-heading);
}

.datePicker {
  position: relative;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.datePicker .icon {
  width: 16px;
  height: 16px;
}

.inlineDate {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  margin: -3px -5px;
  padding: 3px 5px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  white-space: nowrap;
}

.inlineDate:not(:disabled) #dateText {
  text-decoration: underline dotted var(--neutral-400);
  text-underline-offset: 4px;
}

.inlineDate:hover:not(:disabled) {background: var(--color-hover);}
.inlineDate:focus-visible {outline: none;}
.inlineDate:disabled {cursor: default;}
.inlineDate:disabled .icon {display: none;}

/* Text controls may match :focus-visible after a pointer click; preserve the ring for keyboard use. */
html[data-input-modality=pointer] #editor :is(.fieldControl,.inlinePicker,.inlineDate):focus,
html[data-input-modality=pointer] #editor :is(.phone,.masterPicker,.datePicker) {
  outline: none;
}

#selectionSummary {
  margin-bottom: 18px;
}

.selectedRange {
  padding: 10px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.rangeTime {
  display: block;
  color: var(--color-secondary);
  margin-top: 3px;
}
.rangeDetail { display: block; }
.selectedRangeChoice {
  display: block;
  width: 100%;
  margin: 0 0 8px;
  padding: 12px;
  color: inherit;
  font: inherit;
  font-size: 13px;
  text-align: left;
  background: rgb(255 255 255 / 70%);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.selectedRangeChoice:hover { background: white; border-color: var(--color-action); }
.rangeAction { display: block; margin-top: 8px; color: var(--color-action); font-weight: 600; }

#entryFields > .pair {
  margin-top: 0;
}

@media(min-width:761px) {
  .editing .workspace::after {
    mask-image: linear-gradient(to bottom,transparent,#000 14px,#000 calc(100% - 14px),transparent);
  }
  #editor {
    box-shadow: -6px 0 14px rgb(32 33 36 / 5%);
  }
}

@media(max-width:760px) {
  .bookingDate {
    margin-bottom: 4px;
  }
  #editor label {
    font-size: 12px;
    margin-bottom: 5px;
  }
  #editor label.switch {margin: 0; min-height: 36px;}
  #editor .masterPicker {min-height: 36px;}
  #editor .inlineDate {min-height: 32px;}
  #editor {--font-control: 14px; -webkit-text-size-adjust: 100%; text-size-adjust: 100%;}
  #editor .fieldControl {min-height: 36px; padding-block: 5px;}
  /* The focused control stays at 16px to avoid iPhone focus magnification.
     Never disable pinch zoom in the viewport meta tag. */
  #editor .fieldControl:focus {font-size: 16px;}
  #editor .phone:focus-within b {font-size: 16px;}
  #editor .phone input {min-height: 34px;}
}

#editor:focus {
  outline: none;
}

#sheetHandle, #sheetBackdrop, #sheetContext {
  display: none;
}

@media(max-width:760px) {
  .editing .workspace {
    display: grid;
  }
  .editing #calendar {
    display: flex;
  }
  .editing .topbar {
    display: flex;
  }
  #editor {
    position: fixed;
    z-index: 12;
    inset: auto 0 var(--keyboard-inset,0px);
    width: 100%;
    max-height: var(--sheet-max-height,96dvh);
    overscroll-behavior: none;
    border: 1px solid var(--color-editor-divider);
    border-bottom: 0;
    border-radius: 18px 18px 0 0;
    padding: 0 16px max(12px,env(safe-area-inset-bottom));
    box-shadow: 0 -6px 24px rgb(32 33 36 / 12%);
  }
  #booking {overflow: hidden;}
  #editor .editorTop {touch-action: none;}
  #sheetHandle {
    flex-shrink: 0;
    z-index: 6;
    display: grid;
    place-items: center;
    width: calc(100% + 32px);
    height: 16px;
    margin: 0 -16px;
    padding: 0;
    border: 0;
    background: var(--color-editor-bg);
    touch-action: none;
    cursor: grab;
  }
  #sheetHandle span {
    width: 36px;
    height: 4px;
    border-radius: 4px;
    background: var(--neutral-400);
  }
  #sheetHandle:focus-visible {
    outline-offset: -4px;
  }
  #editor .editorTop {
    margin-top: -1px;
    margin-bottom: 2px;
    padding: 0 8px 0 16px;
    min-height: 40px;
  }
  #editorContext {
    font-size: 17px;
  }
  .editing #sheetBackdrop {
    display: block;
    position: fixed;
    z-index: 11;
    inset: 0;
    border: 0;
    background: rgb(32 33 36 / 18%);
    cursor: default;
  }
  .sheetCollapsed #sheetBackdrop {
    display: none;
  }
  .sheetCollapsed #editor {
    max-height: 120px;
    overflow: hidden;
  }
  .sheetCollapsed #booking {
    display: none;
  }
  .sheetCollapsed #editor .editorTop {
    margin-bottom: 0;
    padding-bottom: 0;
  }
  .sheetCollapsed #sheetContext {
    display: block;
    margin-top: 3px;
    font-size: 12px;
    font-weight: 400;
    color: var(--color-secondary);
  }
  .sheetCollapsed #editorMode {
    font-size: 14px;
  }
  #editor .formActions {
    padding: 6px 0 0;
  }
  #editor textarea {
    min-height: 60px;
  }
  #editor #remove {
    min-height: 40px;
    margin-top: 2px;
    padding-block: 8px;
  }
  /* Keyboard mode follows the visible viewport, not Safari's layout viewport.
     Actions return when the keyboard closes; they must not cover the input. */
  .sheetKeyboard #editor {
    top: var(--sheet-top,8px);
    bottom: auto;
    height: var(--sheet-max-height);
    padding-bottom: 8px;
    animation: none !important;
  }
  .sheetKeyboard #booking {flex: 1 1 auto;}
  .sheetKeyboard .editorScroll {flex: 1 1 auto; padding-bottom: 20px;}
  .sheetKeyboard #editor .formActions {display: none;}
  @media(prefers-reduced-motion:no-preference) {
    .editing #editor {
      animation: sheet-enter 180ms ease-out;
    }
    .sheetCollapsed #editor {
      animation: none;
    }
    #editor {
      transition: transform 160ms ease-out;
    }
    .sheetDragging #editor {
      transition: none;
    }
  }
}

@keyframes sheet-enter {
from {transform: translateY(60px);opacity: .5} to {transform: translateY(0);opacity: 1}
}
@media(min-width:761px) and (prefers-reduced-motion:no-preference) {
  .editing #editor {animation: editor-enter 150ms ease-out;}
}
@keyframes editor-enter {from {opacity:.3;transform:translateX(12px)} to {opacity:1;transform:translateX(0)}}

