/* ScanMAP responsive 2026-09-30: isolated itinerary/preferences presentation layer. */
html body[data-page="itinerary"],
html body[data-page="preferences"] {
  --top-h: calc(64px + env(safe-area-inset-top, 0px));
  --bottom-h: calc(72px + env(safe-area-inset-bottom, 0px));
  --it-vh: 100vh;
}
@supports (height:100dvh) {
  html body[data-page="itinerary"], html body[data-page="preferences"] { --it-vh:100dvh; }
}
html body[data-page="itinerary"] #app { height:var(--it-vh); }
html body[data-page="itinerary"] #map {
  top:var(--top-h) !important; bottom:var(--bottom-h) !important;
  height:auto !important; min-height:0 !important;
}
html body[data-page="itinerary"] .scanmap-topbar,
html body[data-page="preferences"] .scanmap-topbar {
  height:var(--top-h) !important; min-height:var(--top-h) !important;
  padding:calc(6px + env(safe-area-inset-top, 0px)) max(8px, env(safe-area-inset-right, 0px)) 6px max(8px, env(safe-area-inset-left, 0px)) !important;
  gap:8px !important;
}
html body[data-page="itinerary"] .scanmap-topbar-left,
html body[data-page="preferences"] .scanmap-topbar-left { min-width:0 !important; flex:1 1 0 !important; }
html body[data-page="itinerary"] .scanmap-topbar-left a,
html body[data-page="preferences"] .scanmap-topbar-left a { max-width:100% !important; gap:6px !important; }
html body[data-page="itinerary"] .scanmap-topbar-right,
html body[data-page="preferences"] .scanmap-topbar-right { gap:6px !important; }
html body[data-page="itinerary"] .scanmap-brand,
html body[data-page="preferences"] .scanmap-brand { min-width:0 !important; }
html body[data-page="itinerary"] .scanmap-brand strong,
html body[data-page="preferences"] .scanmap-brand strong { font-size:17px !important; line-height:1.2 !important; }
html body[data-page="itinerary"] .scanmap-brand span,
html body[data-page="preferences"] .scanmap-brand span { max-width:100% !important; font-size:12px !important; }
html body[data-page="itinerary"] .scanmap-logo,
html body[data-page="preferences"] .scanmap-logo-shell {
  width:40px !important; height:40px !important; min-width:40px !important; max-width:40px !important; flex:0 0 40px !important;
}
html body[data-page="itinerary"] .scanmap-topbar .top-btn#langBtn,
html body[data-page="preferences"] .scanmap-icon-btn {
  min-width:44px !important; min-height:44px !important; height:44px !important; padding:0 8px !important; gap:5px !important;
}
html body[data-page="itinerary"] .scanmap-user-chip {
  width:44px !important; height:44px !important; min-width:44px !important; max-width:44px !important;
}
html body[data-page="itinerary"] .scanmap-user-chip-media { width:36px !important; height:36px !important; min-width:36px !important; }
html body[data-page="itinerary"] #langDropdown,
html body[data-page="preferences"] #langMenu {
  top:calc(var(--top-h) + 4px) !important;
  max-width:calc(100vw - 16px) !important;
  max-height:calc(var(--it-vh) - var(--top-h) - var(--bottom-h) - 16px) !important;
  box-sizing:border-box !important;
}
html body[data-page="itinerary"] #navbar,
html body[data-page="preferences"] #navbar {
  left:0 !important; right:0 !important; bottom:0 !important; transform:none !important;
  width:100% !important; height:var(--bottom-h) !important; min-height:0 !important;
  padding:4px max(4px, env(safe-area-inset-right, 0px)) calc(4px + env(safe-area-inset-bottom, 0px)) max(4px, env(safe-area-inset-left, 0px)) !important;
  border-radius:0 !important; box-sizing:border-box !important;
}
html body[data-page="itinerary"] #navbar .icon-links,
html body[data-page="preferences"] #navbar .icon-links {
  display:flex !important; height:100% !important; padding:0 !important; gap:2px !important;
  overflow-x:auto !important; overflow-y:hidden !important; align-items:stretch !important;
}
html body[data-page="itinerary"] #navbar .icon-links a,
html body[data-page="preferences"] #navbar .icon-links a {
  flex:1 0 44px !important; min-width:44px !important; min-height:44px !important; height:100% !important;
  padding:2px !important; box-sizing:border-box !important;
}
html body[data-page="itinerary"] #navbar .icon-wrapper,
html body[data-page="preferences"] #navbar .icon-wrapper { min-height:0 !important; height:100% !important; gap:3px !important; justify-content:center !important; }
html body[data-page="itinerary"] #navbar img.icon,
html body[data-page="preferences"] #navbar img.icon { width:28px !important; height:28px !important; margin:0 !important; }
html body[data-page="itinerary"] #navbar .icon-label,
html body[data-page="preferences"] #navbar .icon-label { font-size:11px !important; line-height:1.2 !important; max-width:100% !important; white-space:normal !important; overflow-wrap:anywhere !important; }

/* One scrollable reading panel, clear of the fixed map controls. */
html body[data-page="itinerary"] #chat-box,
html body[data-page="itinerary"] #floatingPopup {
  left:8px !important; right:auto !important; transform:none !important;
  top:calc(var(--top-h) + 8px) !important; bottom:calc(var(--bottom-h) + 8px) !important;
  width:min(480px, calc(100vw - 176px)) !important; max-width:calc(100vw - 16px) !important;
  height:calc(var(--it-vh) - var(--top-h) - var(--bottom-h) - 16px) !important;
  max-height:calc(var(--it-vh) - var(--top-h) - var(--bottom-h) - 16px) !important;
  min-height:0 !important; box-sizing:border-box !important; border-radius:18px !important;
}
html body[data-page="itinerary"] #floatingPopup[hidden],
html body[data-page="itinerary"] #floatingPopup:empty { display:none !important; }
html body[data-page="itinerary"]:has(#chat-box.is-open) #floatingPopup { display:none !important; }
html body[data-page="itinerary"] #chat-box .chatbox-head { padding:8px 10px !important; flex:0 0 auto !important; }
html body[data-page="itinerary"] #chat-box .chatbox-head-main { align-items:center !important; gap:6px !important; }
html body[data-page="itinerary"] #chat-box .chatbox-head-title { font-size:15px !important; }
html body[data-page="itinerary"] #chat-box .chatbox-head-subtitle { font-size:11px !important; }
html body[data-page="itinerary"] #chat-box .chatbox-head-tool { min-width:44px !important; min-height:44px !important; padding:0 7px !important; }
html body[data-page="itinerary"] #chat-box #chat-scroll {
  position:relative !important;
  flex:1 1 0 !important; min-height:0 !important; max-height:none !important;
  overflow:auto !important; overscroll-behavior:contain; padding:0 !important;
}
html body[data-page="itinerary"] #chat-box #chat-messages { padding:8px !important; min-width:0 !important; }
html body[data-page="itinerary"] #chat-box #chat-messages:empty { padding:0 !important; }
html body[data-page="itinerary"] #chat-box #scanmap-ai-response {
  /* The full answer stays in normal flow; #chat-scroll owns scrolling. */
  height:auto !important; min-height:0 !important; max-height:none !important;
  padding:6px !important; margin:0 !important; border:0 !important; background:transparent !important; box-shadow:none !important; overflow:visible !important;
}
html body[data-page="itinerary"] #chat-box #chat-quick-questions {
  display:flex !important; flex-wrap:wrap !important; flex-direction:row !important;
  align-content:flex-start !important; max-height:none !important; padding:6px !important; gap:6px !important;
}
html body[data-page="itinerary"] #chat-box #chat-quick-questions button { max-width:100% !important; min-height:40px !important; white-space:normal !important; }
html body[data-page="itinerary"] #chat-box .chatbox-input-row { margin:6px 8px !important; padding:6px !important; }
html body[data-page="itinerary"] #chat-box #chat-input { font-size:16px !important; }
html body[data-page="itinerary"] #chat-box .scanmap-ai-response { padding:10px !important; border-radius:14px !important; }
html body[data-page="itinerary"] #chat-box .scanmap-ai-response-itinerary-compact { gap:8px !important; }
html body[data-page="itinerary"] #chat-box .scanmap-ai-title { font-size:18px !important; margin:4px 0 !important; }
html body[data-page="itinerary"] #chat-box .scanmap-ai-subtitle,
html body[data-page="itinerary"] #chat-box .scanmap-ai-intro-copy p { margin:4px 0 !important; font-size:13px !important; line-height:1.4 !important; }
html body[data-page="itinerary"] #chat-box .scanmap-ai-itinerary-activities { margin:0 !important; padding-top:8px !important; }
html body[data-page="itinerary"] #chat-box .scanmap-ai-summary { padding:8px !important; margin:0 !important; border-radius:12px !important; }
html body[data-page="itinerary"] #chat-box .scanmap-ai-route-metrics { padding:8px !important; border-radius:12px !important; }
html body[data-page="itinerary"] #chat-box .scanmap-ai-route-metrics-head { margin-bottom:6px !important; gap:4px !important; }
html body[data-page="itinerary"] #chat-box .scanmap-ai-route-metrics-grid { display:grid !important; grid-template-columns:repeat(3,minmax(0,1fr)) !important; gap:4px !important; }
html body[data-page="itinerary"] #chat-box .scanmap-ai-route-metric-card { min-width:0 !important; padding:7px !important; border-radius:9px !important; }
html body[data-page="itinerary"] #chat-box .scanmap-ai-route-metric-card strong { font-size:15px !important; line-height:1.25 !important; }
html body[data-page="itinerary"] #chat-box .scanmap-ai-route-metric-card small,
html body[data-page="itinerary"] #chat-box .scanmap-ai-route-metric-card span { font-size:11px !important; }
html body[data-page="itinerary"] #chat-box .scanmap-ai-activity-list,
html body[data-page="itinerary"] #chat-box .scanmap-itinerary-primary-list { gap:6px !important; }
html body[data-page="itinerary"] #chat-box .scanmap-ai-activity-row,
html body[data-page="itinerary"] #chat-box .scanmap-ai-inline-stop-row,
html body[data-page="itinerary"] #chat-box .scanmap-itinerary-primary-row {
  display:grid !important; grid-template-columns:minmax(0, 1fr) auto !important; gap:4px !important; align-items:center !important;
}
html body[data-page="itinerary"] #chat-box .scanmap-ai-activity-card,
html body[data-page="itinerary"] #chat-box .scanmap-itinerary-primary-card {
  grid-template-columns:24px 48px minmax(0, 1fr) !important; gap:6px !important;
  min-width:0 !important; padding:8px !important; border-radius:12px !important; align-items:center !important;
}
html body[data-page="itinerary"] #chat-box .scanmap-ai-activity-index,
html body[data-page="itinerary"] #chat-box .scanmap-itinerary-card-index {
  width:24px !important; height:24px !important; min-width:24px !important; min-height:24px !important; font-size:12px !important;
}
html body[data-page="itinerary"] #chat-box .scanmap-ai-activity-media,
html body[data-page="itinerary"] #chat-box .scanmap-itinerary-card-media {
  width:48px !important; height:48px !important; min-width:48px !important; min-height:48px !important; border-radius:9px !important;
}
html body[data-page="itinerary"] #chat-box .scanmap-ai-activity-copy,
html body[data-page="itinerary"] #chat-box .scanmap-itinerary-card-copy { min-width:0 !important; gap:3px !important; }
html body[data-page="itinerary"] #chat-box .scanmap-ai-activity-copy strong,
html body[data-page="itinerary"] #chat-box .scanmap-itinerary-card-copy strong { font-size:14px !important; line-height:1.25 !important; overflow-wrap:anywhere !important; }
html body[data-page="itinerary"] #chat-box .scanmap-ai-activity-copy span,
html body[data-page="itinerary"] #chat-box .scanmap-itinerary-card-copy span { font-size:12px !important; line-height:1.3 !important; -webkit-line-clamp:2 !important; }
html body[data-page="itinerary"] #chat-box .scanmap-itinerary-card-more { grid-column:3 !important; justify-self:start !important; }
html body[data-page="itinerary"] #chat-box .scanmap-ai-remove-stop,
html body[data-page="itinerary"] #chat-box .scanmap-ai-remove-stop-inline { min-width:44px !important; min-height:44px !important; padding:6px !important; font-size:12px !important; }
html body[data-page="itinerary"] #chat-box .scanmap-ai-route-actions { margin-top:8px !important; grid-template-columns:1fr !important; }
html body[data-page="itinerary"] #chat-box .scanmap-ai-route-btn { min-height:44px !important; padding:8px !important; }
html body[data-page="itinerary"] .scanmap-itinerary-extended-panel {
  max-width:calc(100vw - 16px) !important; max-height:calc(var(--it-vh) - 24px) !important;
  overflow:auto !important; overscroll-behavior:contain;
}
html body[data-page="itinerary"] .scanmap-itinerary-extended-close { width:44px !important; height:44px !important; }
html body[data-page="itinerary"] { --it-side-tabs-top:calc(var(--top-h) + 64px); --it-side-tab-h:60px; --it-side-tab-w:58px; }
html body[data-page="itinerary"] #floatingMarker { transform:none !important; writing-mode:horizontal-tb !important; letter-spacing:0 !important; }
html body[data-page="itinerary"] .sm-area-open { top:calc(var(--top-h) + 8px) !important; right:8px !important; max-width:148px !important; }
html body[data-page="itinerary"] #scanmapRightControls {
  position:fixed !important; top:calc(var(--top-h) + 64px) !important; right:70px !important;
  display:flex !important; flex-direction:column !important; gap:6px !important; z-index:2300 !important;
}
html body[data-page="itinerary"] #scanmapRightControls button {
  min-width:44px !important; min-height:44px !important; border-radius:12px !important; border:1px solid #b7c5d2 !important;
  color:#17324d !important; background:#fff !important; font-size:20px !important; cursor:pointer;
}
html body[data-page="itinerary"] #scanmapNavigatorPanel.scanmap-navv2-host,
html body[data-page="itinerary"] #route-info.scanmap-navv2-host {
  top:calc(var(--top-h) + 8px) !important; max-height:calc(var(--it-vh) - var(--top-h) - var(--bottom-h) - 16px) !important;
  overflow:auto !important; overscroll-behavior:contain;
}

/* Preferences remain a normal scrolling form; every option stays present. */
html body[data-page="preferences"] { padding-top:var(--top-h); padding-bottom:0 !important; }
html body[data-page="preferences"] .container.preferences-shell { padding:16px 0 calc(var(--bottom-h) + 24px) !important; }
html body[data-page="preferences"] .preferences-header { padding:18px !important; margin-bottom:14px !important; border-radius:20px !important; }
html body[data-page="preferences"] .preferences-header h1 { font-size:clamp(1.5rem, 4vw, 2.5rem) !important; line-height:1.12 !important; }
html body[data-page="preferences"] .preferences-header p { font-size:14px !important; line-height:1.45 !important; }
html body[data-page="preferences"] .preferences-header .eyebrow { margin-bottom:8px !important; }
html body[data-page="preferences"] .preferences-form-card { padding:14px !important; border-radius:20px !important; }
html body[data-page="preferences"] .field-card { min-width:0 !important; padding:12px !important; border-radius:16px !important; }
html body[data-page="preferences"] .choice-grid { grid-template-columns:repeat(2, minmax(0,1fr)) !important; gap:8px !important; }
html body[data-page="preferences"] .choice-card,
html body[data-page="preferences"] .chip { position:relative; min-width:0; }
html body[data-page="preferences"] .choice-card span,
html body[data-page="preferences"] .chip span { min-height:44px !important; height:auto !important; padding:8px !important; font-size:14px !important; line-height:1.3 !important; overflow-wrap:anywhere; }
html body[data-page="preferences"] .choice-card input,
html body[data-page="preferences"] .chip input {
  display:block !important; position:absolute !important; width:1px !important; height:1px !important;
  padding:0 !important; margin:-1px !important; overflow:hidden !important; clip:rect(0,0,0,0); clip-path:inset(50%); white-space:nowrap;
}
html body[data-page="preferences"] .choice-card input:focus-visible + span,
html body[data-page="preferences"] .chip input:focus-visible + span { outline:3px solid #ff6b2c; outline-offset:2px; }
html body[data-page="preferences"] #zoneInput,
html body[data-page="preferences"] #extraInput { min-width:0; max-width:100%; font-size:16px !important; padding:12px !important; }
html body[data-page="preferences"] #extraInput { resize:vertical; }
html body[data-page="preferences"] .preferences-summary { grid-template-columns:repeat(2,minmax(0,1fr)) !important; gap:8px !important; }
html body[data-page="preferences"] .summary-pill { padding:10px !important; overflow-wrap:anywhere; }
html body[data-page="preferences"] #detectLocationButton { max-width:100%; white-space:normal; }
html body[data-page="preferences"] #mapsLink { display:inline-flex !important; }
html body[data-page="preferences"] .idim-loading-card { max-height:calc(var(--it-vh) - 32px); overflow:auto; }
html body[data-page="preferences"] .idim-loading-visual { height:clamp(100px,30vh,280px); }

@media (max-width:700px) and (min-height:501px) {
  html body[data-page="itinerary"] #chat-box,
  html body[data-page="itinerary"] #floatingPopup {
    top:auto !important; left:8px !important; right:8px !important; width:auto !important;
    height:clamp(280px, 58dvh, 520px) !important;
    max-height:calc(var(--it-vh) - var(--top-h) - var(--bottom-h) - 112px) !important;
  }
  html body[data-page="itinerary"] #floatingMarker,
  html body[data-page="itinerary"] #scanmapItineraryRoutesBtn,
  html body[data-page="itinerary"] #scanmapItineraryAiBtn,
  html body[data-page="itinerary"] .sm-area-open {
    top:calc(var(--top-h) + 6px) !important; bottom:auto !important; right:auto !important;
    width:calc(25vw - 10px) !important; min-width:0 !important; max-width:none !important;
    height:44px !important; min-height:44px !important; max-height:44px !important;
    padding:4px !important; margin:0 !important; border-radius:12px !important; box-sizing:border-box !important;
    font-size:11px !important; line-height:1.2 !important; letter-spacing:0 !important;
    flex-direction:row !important; gap:3px !important; white-space:normal !important; text-align:center !important;
  }
  html body[data-page="itinerary"] #floatingMarker { left:8px !important; display:flex !important; align-items:center !important; justify-content:center !important; }
  html body[data-page="itinerary"] #scanmapItineraryRoutesBtn { left:calc(25vw + 4px) !important; }
  html body[data-page="itinerary"] #scanmapItineraryAiBtn { left:50vw !important; }
  html body[data-page="itinerary"] .sm-area-open { left:calc(75vw - 4px) !important; }
  html body[data-page="itinerary"] #scanmapItineraryRoutesBtn .scanmap-it-routes-icon,
  html body[data-page="itinerary"] #scanmapItineraryAiBtn .scanmap-it-ai-icon { width:18px !important; height:18px !important; flex:0 0 18px; }
  html body[data-page="itinerary"] #scanmapItineraryRoutesBtn .scanmap-it-routes-text,
  html body[data-page="itinerary"] #scanmapItineraryAiBtn .scanmap-it-ai-text { font-size:11px !important; line-height:1.2 !important; }
  html body[data-page="itinerary"] #scanmapRightControls { top:calc(var(--top-h) + 56px) !important; right:8px !important; flex-direction:row !important; gap:4px !important; }
  html body[data-page="itinerary"] #scanmapNavigatorPanel.scanmap-navv2-host,
  html body[data-page="itinerary"] #route-info.scanmap-navv2-host { top:calc(var(--top-h) + 56px) !important; max-height:calc(var(--it-vh) - var(--top-h) - var(--bottom-h) - 64px) !important; }
}
@media (max-width:380px) {
  html body[data-page="itinerary"] #scanmapItineraryRoutesBtn .scanmap-it-routes-icon { display:none !important; }
  html body[data-page="itinerary"] .scanmap-brand strong,
  html body[data-page="preferences"] .scanmap-brand strong { font-size:14px !important; }
  html body[data-page="itinerary"] .scanmap-it-lang-img,
  html body[data-page="preferences"] #currentFlag { width:22px !important; height:16px !important; min-width:22px !important; flex-basis:22px !important; }
  html body[data-page="itinerary"] #chat-box .scanmap-ai-activity-card,
  html body[data-page="itinerary"] #chat-box .scanmap-itinerary-primary-card { grid-template-columns:22px 40px minmax(0,1fr) !important; gap:4px !important; padding:6px !important; }
  html body[data-page="itinerary"] #chat-box .scanmap-ai-activity-media,
  html body[data-page="itinerary"] #chat-box .scanmap-itinerary-card-media { width:40px !important; height:40px !important; min-width:40px !important; min-height:40px !important; }
  html body[data-page="preferences"] .preferences-form-card { padding:8px !important; }
  html body[data-page="preferences"] .field-card { padding:9px !important; }
  html body[data-page="preferences"] .scanmap-topbar .scanmap-icon-btn { font-size:12px !important; padding:0 6px !important; }
}
@media (max-height:500px) {
  html body[data-page="itinerary"], html body[data-page="preferences"] {
    --top-h:calc(56px + env(safe-area-inset-top, 0px)); --bottom-h:calc(60px + env(safe-area-inset-bottom, 0px));
  }
  html body[data-page="itinerary"] { --it-side-tabs-top:calc(var(--top-h) + 6px); --it-side-tab-h:48px; }
  html body[data-page="itinerary"] #chat-box,
  html body[data-page="itinerary"] #floatingPopup { width:min(440px, calc(100vw - 240px)) !important; min-width:min(280px, calc(100vw - 84px)) !important; }
  html body[data-page="itinerary"] .sm-area-open { right:70px !important; }
  html body[data-page="itinerary"] #scanmapRightControls { top:calc(var(--top-h) + 58px) !important; flex-direction:row !important; gap:4px !important; }
  html body[data-page="itinerary"] #chat-box .chatbox-head-subtitle { font-size:10px !important; }
  html body[data-page="itinerary"] #navbar img.icon,
  html body[data-page="preferences"] #navbar img.icon { width:22px !important; height:22px !important; }
}
