/* Phone interaction layer. Desktop geometry and map pan/pinch gestures stay local. */
dialog:is(.dt-vessel-dialog,.dt-saved-voyages) { margin: 0; padding: 0; inset: auto; }

/* Phone legends show their categories directly. */
html body.dt-mobile-shell #app .dt-legend-header input[type=search] { display: none !important; }

body.dt-mobile-shell :is(button,.el-button,summary,.el-checkbox,.el-radio,.el-switch) {
  min-height: 44px;
  touch-action: manipulation;
}
body.dt-mobile-shell :is(button,.el-button) { min-width: 44px; }
body.dt-mobile-shell :is(input:not([type=checkbox]):not([type=radio]),select,textarea) {
  font-size: 16px !important;
}
body.dt-mobile-shell :is(.el-input__wrapper,.el-select__wrapper) { min-height: 44px; }
body.dt-mobile-shell :is(button,a,summary):active { filter: brightness(.94); }
body.dt-mobile-shell :is(.rp-starter,.cpd-wide,.el-button) { white-space: normal; }
body.dt-mobile-shell :is(.rp-operating input,.cpd-route-select select) { min-height: 44px; }
body.dt-mobile-shell .rp .rp-starter { padding: 10px 8px; }
body.dt-mobile-shell :is(.el-pagination button,.el-pager li) { min-width: 44px; min-height: 44px; }
body.dt-mobile-shell :is(.el-checkbox,.el-radio) { align-items: center; margin-right: 12px; }
body.dt-mobile-shell :is(.el-checkbox__label,.el-radio__label) { white-space: normal; line-height: 1.45; }

/* Camera controls remain compact, with a full finger-sized button for each action. */
body.dt-mobile-cockpit .cpd-map-actions { width: 64px !important; gap: 4px; padding: 4px !important; }
body.dt-mobile-cockpit .cpd-map-actions button {
  height: 44px; min-height: 44px; padding: 6px 3px; gap: 3px; font-size: 11px;
}
body.dt-mobile-cockpit .cpd-map-actions button svg { width: 17px; height: 17px; }
body.dt-mobile-cockpit .cpd-map-actions .cpd-north-compass { width: 44px; height: 44px; min-height: 44px; }
body.dt-mobile-cockpit .cpd-map-actions [data-action=forward] { font-size: 10px; }

/* Native phone sheets keep focus inside; header and primary actions do not scroll. */
html body.dt-mobile-shell :is(.dt-vessel-dialog,.dt-saved-voyages,.cpd-detail-dialog) {
  inset: auto 0 var(--ma-viewport-bottom,0px) !important;
  width: min(100%,560px) !important; max-width: 100% !important;
  height: auto !important; min-height: 0 !important;
  max-height: calc(var(--ma-viewport-height,100dvh) - max(12px,env(safe-area-inset-top,0px))) !important;
  margin: 0 auto !important; padding: 0 !important; transform: none !important;
  border: 1px solid var(--ma-line); border-radius: 22px 22px 0 0 !important;
  background: var(--ma-bg) !important; color: var(--ma-ink) !important;
  overflow: hidden !important; resize: none; box-shadow: 0 -8px 40px #102d4330;
}
html body.dt-mobile-shell :is(.dt-vessel-dialog,.dt-saved-voyages,.cpd-detail-dialog)[open] {
  display: flex; flex-direction: column;
}
body.dt-mobile-shell :is(.dt-vessel-dialog,.dt-saved-voyages,.cpd-detail-dialog)::backdrop { background: #102d4370; }
body.dt-mobile-shell .dt-vessel-dialog form {
  display: flex; flex-direction: column; min-height: 0;
  max-height: calc(var(--ma-viewport-height,100dvh) - max(12px,env(safe-area-inset-top,0px)));
}
body.dt-mobile-shell :is(.dt-vessel-dialog-header,.dt-saved-voyages-header,.cpd-dialog-head) {
  position: relative; flex: 0 0 auto; align-items: center;
  gap: 12px; padding: 12px 16px !important;
  background: var(--ma-bg) !important; color: var(--ma-ink) !important;
  border-color: var(--ma-line) !important;
}
body.dt-mobile-shell :is(.dt-vessel-dialog-header,.dt-saved-voyages-header,.cpd-dialog-head) h2 {
  font-size: 17px !important; line-height: 1.4;
}
body.dt-mobile-shell .dt-vessel-dialog-header p { font-size: 12px; line-height: 1.5; }
body.dt-mobile-shell :is(.dt-vessel-dialog-close,.dt-saved-voyages-close) {
  display: grid; place-items: center; flex: 0 0 44px; width: 44px; height: 44px;
  padding: 0; border-radius: 50%; background: #2388f810;
}
html body.dt-mobile-shell :is(.dt-vessel-dialog-body,.dt-saved-voyages-body,.cpd-detail-body) {
  flex: 1 1 auto; min-height: 0; max-height: none !important;
  overflow: auto !important; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch; padding: 16px !important;
  scroll-padding: 16px; overflow-wrap: anywhere;
}
body.dt-mobile-shell :is(.dt-saved-voyages-body,.cpd-detail-body) { padding-bottom: calc(16px + env(safe-area-inset-bottom,0px)) !important; }
body.dt-mobile-shell .dt-vessel-dialog-body { gap: 14px 12px; }
body.dt-mobile-shell .dt-vessel-dialog label { font-size: 13px; line-height: 1.45; }
body.dt-mobile-shell .dt-vessel-dialog :is(input,select) { height: 48px; padding: 0 10px; border-radius: 10px; }
body.dt-mobile-shell .dt-vessel-dialog :is(.dt-vessel-dialog-note,.dt-vessel-dialog-error) { font-size: 12px; line-height: 1.55; }
body.dt-mobile-shell .dt-vessel-dialog-actions {
  position: relative; flex: 0 0 auto; gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom,0px));
  border-color: var(--ma-line) !important; background: var(--ma-bg) !important;
}
body.dt-mobile-shell .dt-vessel-dialog-actions button { flex: 1; height: 48px; font-size: 14px; border-radius: 12px; }
body.dt-mobile-shell .dt-saved-voyages .rp :is(input:not([type=checkbox]),select) { min-height: 48px; }
body.dt-mobile-shell .dt-saved-voyages .rp-actions { gap: 8px; }
body.dt-mobile-shell .dt-saved-voyages .rp-actions button { margin: 0; flex: 1 1 120px; }
body.dt-mobile-shell .dt-saved-voyages :is(.rp-note,.rp-field>label) { font-size: 13px; line-height: 1.5; }
body.dt-mobile-shell .dt-saved-voyages-body details>summary { padding: 10px 0; margin: 0; }
html body.dt-mobile-shell .cpd-detail-dialog { height: min(720px,calc(var(--ma-viewport-height,100dvh) - 12px)) !important; }
body.dt-mobile-shell .cpd-detail-dialog .cpd-grid2 { grid-template-columns: repeat(2,minmax(0,1fr)); }

/* Element dialogs use the same sheet geometry and separate header/body/footer. */
body.dt-mobile-shell .el-overlay-dialog {
  display: flex; align-items: flex-end; justify-content: center;
  padding-top: max(12px,env(safe-area-inset-top,0px));
  bottom: var(--ma-viewport-bottom,0px); top: var(--ma-viewport-top,0px);
}
html body.dt-mobile-shell .el-dialog {
  display: flex; flex-direction: column; width: min(100%,560px) !important;
  max-width: 100% !important; min-height: 0;
  max-height: calc(var(--ma-viewport-height,100dvh) - 12px) !important;
  margin: 0 !important; padding: 0 !important; border-radius: 22px 22px 0 0;
  overflow: hidden; background: var(--ma-bg); color: var(--ma-ink);
}
body.dt-mobile-shell .el-dialog__header { flex: none; margin: 0; padding: 20px 64px 16px 16px; border-bottom: 1px solid var(--ma-line); }
body.dt-mobile-shell .el-dialog__title { font-size: 17px; line-height: 1.45; }
body.dt-mobile-shell :is(.el-dialog__headerbtn,.el-message-box__headerbtn) { width: 44px; height: 44px; top: 8px; right: 8px; }
body.dt-mobile-shell .el-dialog__body { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 16px; scroll-padding: 16px; }
body.dt-mobile-shell .el-dialog__footer { flex: none; padding: 12px 16px calc(12px + env(safe-area-inset-bottom,0px)); border-top: 1px solid var(--ma-line); }
body.dt-mobile-shell .el-dialog__footer .dialog-footer { display: flex; flex-wrap: wrap; gap: 8px; }
body.dt-mobile-shell .el-dialog__footer button { flex: 1; margin: 0; }
body.dt-mobile-shell .el-overlay-message-box { top: var(--ma-viewport-top,0px); bottom: var(--ma-viewport-bottom,0px); }
body.dt-mobile-shell .el-message-box { padding: 16px; max-height: calc(var(--ma-viewport-height,100dvh) - 24px); }
body.dt-mobile-shell .el-message-box__header { padding-right: 44px; }
body.dt-mobile-shell .el-message-box__btns { flex-wrap: wrap; gap: 8px; }
body.dt-mobile-shell .el-message-box__btns button { flex: 1; margin: 0; }

/* Transient choices remain beside their field with wrapping, scrollable rows. */
body.dt-mobile-shell :is(.el-select-dropdown__item,.el-dropdown-menu__item,.el-autocomplete-suggestion li) {
  min-height: 44px; height: auto; line-height: 1.5; display: flex; align-items: center;
  padding-top: 10px; padding-bottom: 10px; white-space: normal; overflow-wrap: anywhere;
}
body.dt-mobile-shell :is(.el-select-dropdown__wrap,.el-autocomplete-suggestion__wrap) {
  max-height: min(280px,calc(var(--ma-viewport-height,100dvh) - 120px));
  overscroll-behavior: contain;
}
body.dt-mobile-shell .rp-sug { max-height: var(--ma-suggestion-height,270px); overscroll-behavior: contain; }
body.dt-mobile-shell .rp-sug li[data-pick] { min-height: 48px; padding: 10px; }
body.dt-mobile-shell .el-date-table td { height: 44px; }
body.dt-mobile-shell .el-date-table-cell { height: 44px; padding: 6px 0; }
body.dt-mobile-shell .el-picker-panel { max-width: calc(100vw - 24px); }
body.dt-mobile-shell .el-picker-panel__body-wrapper { overflow: auto; max-height: calc(var(--ma-viewport-height,100dvh) - 90px); overscroll-behavior: contain; }
body.dt-mobile-shell .el-picker-panel__body { min-width: 0 !important; }
body.dt-mobile-shell .el-date-range-picker { width: min(560px,calc(100vw - 24px)) !important; }
body.dt-mobile-shell .el-date-range-picker__content { width: 100%; float: none; border: 0; padding: 12px; }
body.dt-mobile-shell .el-date-range-picker__content.is-left { border-bottom: 1px solid var(--ma-line); }
body.dt-mobile-shell .el-date-picker { width: min(322px,calc(100vw - 24px)); }
body.dt-mobile-shell .el-date-picker .el-picker-panel__content { width: auto; margin: 10px; }

/* Map details have an easy grab area; their content keeps its own vertical scroll. */
html body[class].dt-mobile-shell .el-card.info-panel[data-v-53e610ab][role=region] {
  bottom: calc(var(--ma-viewport-bottom,0px) + var(--ma-nav-height) + 12px) !important;
  max-height: calc(var(--ma-viewport-height,100dvh) - var(--ma-top) - var(--ma-nav-height) - 24px) !important;
  padding-top: 32px; border-radius: 20px !important;
}
html body[class].dt-mobile-shell .el-card.info-panel[data-v-53e610ab] .resize-handle { height: 44px !important; }
html body[class].dt-mobile-shell .el-card.info-panel[data-v-53e610ab] .resize-handle::after { top: 14px; }
html body[class].dt-mobile-shell .el-card.info-panel[data-v-53e610ab] .map-info-header { gap: 8px !important; }
html body[class].dt-mobile-shell .el-card.info-panel[data-v-53e610ab] .map-info-heading strong { white-space: normal; overflow-wrap: anywhere; }
body.dt-mobile-shell :is(.map-info-detail,.record-list,.rp,.ma-menu-content) { scroll-padding: 16px; }
body.dt-mobile-shell .ma-menu[open] { bottom: var(--ma-viewport-bottom,0px); max-height: calc(var(--ma-viewport-height,100dvh) - 12px); }
body.dt-mobile-shell .ma-menu-content { max-height: calc(var(--ma-viewport-height,100dvh) - 84px); }
body.dt-mobile-shell[data-ma-keyboard=true] .ma-header { display: none; }
body.dt-mobile-shell[data-ma-keyboard=true]:not(.dt-mobile-app) #app .app-main { height: var(--ma-viewport-height,100dvh) !important; padding-top: 12px !important; }
body.dt-mobile-auth[data-ma-keyboard=true] #app { height: var(--ma-viewport-height,100dvh); }
body.dt-mobile-auth[data-ma-keyboard=true] :is(.login,.register) { padding-top: 16px; min-height: var(--ma-viewport-height,100dvh); }
body.dt-mobile-publish[data-ma-keyboard=true] .publish-company-container :is(.form-float-panel,.info-panel) { bottom: var(--ma-viewport-bottom,0px) !important; }

@media (orientation:landscape) and (max-height:500px) {
  body.dt-mobile-cockpit .cpd-map-actions { width: auto !important; }
  body.dt-mobile-shell .ma-nav a { min-height: 44px; }
  body.dt-mobile-shell .cpd-detail-dialog { height: calc(var(--ma-viewport-height,100dvh) - 12px) !important; }
}
@media (prefers-reduced-motion:reduce) {
  body.dt-mobile-shell :is(.dt-vessel-dialog,.dt-saved-voyages,.cpd-detail-dialog,.el-dialog) { animation: none; transition: none; }
}

/* Location sheets keep the map visible, including after a manual resize. */
body.dt-mobile-shell {
  --ma-place-limit: min(calc(var(--ma-viewport-height,100dvh) * .60),calc(var(--ma-viewport-height,100dvh) - var(--ma-top) - var(--ma-nav-height) - 24px));
}
html body[class].dt-mobile-shell .el-card.info-panel[data-v-53e610ab][role=region].map-info-expanded {
  inset: auto 10px calc(var(--ma-viewport-bottom,0px) + var(--ma-nav-height) + 10px) !important;
  width: auto !important; max-width: none !important; min-height: 0 !important;
  height: min(var(--map-info-height,52dvh),var(--ma-place-limit)) !important;
  max-height: var(--ma-place-limit) !important;
  transform: none !important; padding-top: 22px !important; border-radius: 18px !important;
  overflow: hidden !important;
}
html body[class].dt-mobile-shell .el-card.info-panel[data-v-53e610ab][role=region] .resize-handle { height: 24px !important; }
html body[class].dt-mobile-shell .el-card.info-panel[data-v-53e610ab][role=region] .resize-handle::after { top: 9px; width: 36px; left: calc(50% - 18px); }
html body[class].dt-mobile-shell .el-card.info-panel[data-v-53e610ab][role=region] .map-info-header {
  min-height: 62px; padding: 6px 12px 10px !important; gap: 8px !important;
}
html body[class].dt-mobile-shell .el-card.info-panel[data-v-53e610ab][role=region] .map-info-heading strong {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden; white-space: normal; overflow-wrap: anywhere; font-size: 14px !important; line-height: 1.35;
}
html body[class].dt-mobile-shell .el-card.info-panel[data-v-53e610ab][role=region] .map-info-actions button {
  min-width: 44px; min-height: 44px; padding: 8px 10px !important;
}
html body[class].dt-mobile-plan .el-card.info-panel[data-v-53e610ab][role=region] .map-info-actions .map-info-go-here {
  min-width: 82px; background: #1579ea !important; color: #fff !important;
  border-color: #1579ea !important; font-weight: 600; white-space: nowrap;
}
html body[class].dt-mobile-shell .el-card.info-panel[data-v-53e610ab][role=region] .map-info-detail {
  padding: 10px 12px 14px !important; overflow-x: hidden !important; overflow-y: auto !important;
  scroll-padding: 12px; overflow-wrap: anywhere; -webkit-overflow-scrolling: touch;
}

/* The fixed shell already identifies the berth. Retain category, position and freshness. */
html body[class].dt-mobile-shell .info-panel[role=region] .berth-panel .bp-header {
  display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: start; gap: 8px; margin-bottom: 12px;
}
body.dt-mobile-shell .info-panel[role=region] .berth-panel .bp-header h2 { display: none; }
body.dt-mobile-shell .info-panel[role=region] .berth-panel .bp-header p { margin-top: 4px; }
body.dt-mobile-shell .info-panel[role=region] .berth-panel .bp-eyebrow { letter-spacing: .5px; font-size: 10px; }
body.dt-mobile-shell .info-panel[role=region] .berth-panel .bp-refresh-group { max-width: 116px; margin: 0; gap: 4px; }
body.dt-mobile-shell .info-panel[role=region] .berth-panel .bp-updated { font-size: 10px; overflow-wrap: anywhere; }
body.dt-mobile-shell .info-panel[role=region] .berth-panel .bp-location-pills { margin-top: 6px; gap: 4px; }
body.dt-mobile-shell .info-panel[role=region] .berth-panel :is(.bp-conditions,.bp-decision,.bp-primary>section,.bp-euris,.bp-confidence,.bp-notices) { padding: 10px; margin-bottom: 10px; }
html body[class].dt-mobile-shell .info-panel[role=region] .berth-panel .bp-fit-grid { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; margin: 10px 0; }
body.dt-mobile-shell .info-panel[role=region] .berth-panel .bp-fit-grid>div { min-width: 0; border-bottom: 0; padding-bottom: 0; }
body.dt-mobile-shell .info-panel[role=region] .berth-panel .bp-fit-grid strong { font-size: 15px; }
body.dt-mobile-shell .info-panel[role=region] .berth-panel .bp-decision h3 { gap: 4px; }

/* Voyage/location details stay over the map; forms have room without filling the viewport. */
html body.dt-mobile-shell .cpd-detail-dialog {
  inset: auto 10px calc(var(--ma-viewport-bottom,0px) + var(--ma-nav-height) + 10px) !important;
  width: calc(100% - 20px) !important; max-width: 560px !important;
  height: min(56dvh,var(--ma-place-limit)) !important; max-height: var(--ma-place-limit) !important;
  border-radius: 18px !important;
}
body.dt-mobile-shell .cpd-detail-dialog::backdrop { background: #102d4326; }
html body.dt-mobile-shell :is(.dt-vessel-dialog,.dt-saved-voyages,.el-dialog) {
  max-height: min(calc(var(--ma-viewport-height,100dvh) * .88),calc(var(--ma-viewport-height,100dvh) - max(12px,env(safe-area-inset-top,0px)))) !important;
}
body.dt-mobile-shell .dt-vessel-dialog form { max-height: inherit; }

/* Optional map inspectors use the same compact bounds and a reachable close action. */
html body[class].dt-mobile-shell.dt-mobile-cockpit .map.cpd-environment-open>.overlay.right.dt-environment-drawer,
html body[class].dt-mobile-shell.dt-mobile-cockpit .map.cpd-details-open>.overlay.left {
  display: block !important; position: fixed !important;
  inset: auto 10px calc(var(--ma-viewport-bottom,0px) + var(--ma-nav-height) + 10px) !important;
  width: auto !important; height: var(--ma-place-limit) !important; max-height: var(--ma-place-limit) !important;
  min-height: 0 !important; margin: 0 !important; transform: none !important;
  box-sizing: border-box; overflow: auto !important; overscroll-behavior: contain;
  visibility: visible !important; opacity: 1 !important; pointer-events: auto !important;
  border-radius: 18px !important; padding: 12px !important; z-index: 3400 !important;
  background: var(--ma-bg) !important; color: var(--ma-ink) !important;
}
html body.dt-mobile-cockpit .map:is(.cpd-environment-open,.cpd-details-open) .cpd-close-panel {
  top: auto !important; right: 14px !important;
  bottom: calc(var(--ma-viewport-bottom,0px) + var(--ma-nav-height) + var(--ma-place-limit) + 18px) !important;
  min-height: 44px; z-index: 3500;
}

@media (orientation:landscape) and (max-height:500px) {
  body.dt-mobile-shell { --ma-place-limit: calc(var(--ma-viewport-height,100dvh) - var(--ma-nav-height) - max(8px,env(safe-area-inset-top,0px)) - 20px); }
  html body[class].dt-mobile-shell .el-card.info-panel[data-v-53e610ab][role=region].map-info-expanded,
  html body.dt-mobile-shell .cpd-detail-dialog {
    left: auto !important; right: calc(10px + env(safe-area-inset-right,0px)) !important;
    width: min(400px,52vw) !important; max-width: calc(100vw - 20px) !important;
    height: var(--ma-place-limit) !important; max-height: var(--ma-place-limit) !important; margin: 0 !important;
  }
  html body[class].dt-mobile-shell .el-card.info-panel[data-v-53e610ab][role=region].map-info-expanded { padding-top: 0 !important; }
  html body[class].dt-mobile-shell .el-card.info-panel[data-v-53e610ab][role=region] .resize-handle { display: none !important; }
  html body.dt-mobile-shell:has(.info-panel[role=region],.cpd-detail-dialog[open]) .dt-map-search {
    left: calc(10px + env(safe-area-inset-left,0px)) !important; right: auto !important;
    width: calc(100vw - min(400px,52vw) - 30px - env(safe-area-inset-left,0px) - env(safe-area-inset-right,0px)) !important;
    max-width: none !important;
  }
  html body[class].dt-mobile-shell.dt-mobile-cockpit .map.cpd-environment-open>.overlay.right.dt-environment-drawer,
  html body[class].dt-mobile-shell.dt-mobile-cockpit .map.cpd-details-open>.overlay.left {
    left: auto !important; width: min(400px,52vw) !important; padding-top: 56px !important;
  }
  html body.dt-mobile-cockpit .map:is(.cpd-environment-open,.cpd-details-open) .cpd-close-panel {
    top: calc(max(8px,env(safe-area-inset-top,0px)) + 18px) !important; bottom: auto !important; right: 22px !important;
  }
}
