/* Chat on the island map: launcher, dock placement, bot panel stacking. */
.chat-launcher {
  position: fixed; right: 16px; bottom: 16px; z-index: 45;
  display: flex; align-items: center; gap: 8px; padding: 12px 18px; border: 0; border-radius: 999px; cursor: pointer;
  background: #1d2b64; color: #fff; font: 800 14px/1 var(--font, system-ui), sans-serif;   /* navy with a sparkle = the assistant */
  box-shadow: 0 10px 28px rgba(29, 43, 100, .35);
}
.chat-launcher svg { width: 20px; height: 20px; }
.chat-launcher:hover { background: #2c3f8a; }
.chat-launcher:focus-visible { outline: 3px solid #1d2b64; outline-offset: 2px; }
.embed-dock { position: fixed; right: 16px; bottom: 76px; z-index: 46; }
.embed-dock.chat-dock { max-height: calc(100vh - 206px); }   /* stay below the header and toolbar */
.embed-dock[hidden] { display: none !important; }
.embed-dock .cd-head { display: flex; align-items: center; }
.embed-dock .cd-active { flex: 1; }
.embed-close { display: grid; place-items: center; border: 0; background: none; color: #fff; cursor: pointer; padding: 2px; }
.embed-close:focus-visible { outline: 2px solid #fff; }
#botpanel { z-index: 21; }
#panel.under-page { visibility: hidden; }
body.chat-pages a[data-page-link] > span[aria-hidden] { display: none; }   /* stays on this site, so no "opens elsewhere" arrow */
#botpanel .bp-title, .bp-copilot { font-family: inherit; }
.bp-copilot { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; margin-right: 8px; padding: 7px 10px; border: 0; border-radius: 9px; background: #1d2b64; color: #fff; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }   /* navy with a sparkle = the assistant */
.bp-foot { flex: none; padding: 10px 18px; border-top: 1px solid #e3e8f2; font-size: 13px; }
.bp-foot a { color: inherit; font-weight: 700; }
.bp-foot a:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.bp-copilot svg { flex: none; width: 15px; height: 15px; }
.bp-copilot:hover { background: #2c3f8a; }
.bp-copilot:focus-visible { outline: 2px solid #1d2b64; outline-offset: 2px; }
.btn.ghost.chat-cta { cursor: pointer; background: #1d2b64; border-color: #1d2b64; color: #fff; }
.btn.ghost.chat-cta:hover { background: #2c3f8a; border-color: #2c3f8a; }
/* Layout: the chat stays on the right, so panels (the map's and the bots') open on the left.
   Phones keep the map's bottom sheets. The map on its own, without the chat, is unchanged. */
@media (min-width: 761px) {
  #panel, #botpanel { left: 16px; right: auto; transform: translateX(calc(-100% - 32px)); }
  #panel.open, #botpanel.open { transform: none; }
  .stage.panel-open .toolbar { right: 16px; }
  .stage.panel-open .mapctl { left: 436px; }      /* 404px panel + margins */
  body.map-panel-open .embed-dock.chat-dock { width: min(380px, calc(100vw - 452px)); }
  /* Two panes: 404px + 404px. Where the chat doesn't fit beside them, it covers the end of the second. */
  #botpanel.expanded { width: min(808px, calc(100vw - 32px)); }
  body.bot-panel-expanded .mapctl { left: 840px; }
  body.bot-panel-expanded .embed-dock.chat-dock { width: max(320px, min(380px, calc(100vw - 856px))); }
  /* use the height between the map's toolbar and the launcher, instead of a fixed 560px */
  .embed-dock.chat-dock { height: min(760px, calc(100vh - 216px)); }
}
/* Below this the launcher's label would overlap the persona bar: show just the icon. */
@media (min-width: 761px) and (max-width: 1400px) {
  .chat-launcher { padding: 14px; }
  .chat-launcher span { display: none; }
}
@media (max-width: 760px) {
  /* Phones: "Ask us" sits on the top-right corner of the persona bar, following its height
     (main.js sets --persona-top and html.persona-shown). When the bar is hidden (an island
     panel or the list view), it becomes an icon above the map's compass instead. */
  .chat-launcher { top: 120px; bottom: auto; right: 12px; width: 44px; height: 44px; padding: 0; justify-content: center; }
  .chat-launcher span { display: none; }
  html:not(.persona-shown) .mapctl { top: 120px; }
  html.persona-shown .chat-launcher { top: calc(var(--persona-top) - 44px);   /* just above the bar, not on it */ right: 12px; width: auto; height: 36px; padding: 0 14px; }
  html.persona-shown .chat-launcher span { display: inline; }
  body.map-panel-open .chat-launcher { right: 12px; }
  .embed-dock, body.map-panel-open .embed-dock { inset: 64px 8px 8px 8px; }
  .embed-dock.chat-dock { width: auto; height: auto; max-width: none; max-height: none; }
  /* A bot panel (e.g. the calendar) fills the screen like the chat. While it's shown, embed.js
     shrinks the chat to its header: a bar at the bottom that opens the chat again. */
  body.bot-panel-open .chat-launcher { display: none; }
  #botpanel { top: 8px; left: 8px; right: 8px; bottom: 8px; height: auto; border-radius: 22px; }
  body.chat-minimised #botpanel, body.chat-over-panel #botpanel { bottom: 64px; }
  body.bot-panel-open .embed-dock.minimised { inset: auto 8px 8px 8px; }   /* beats the map-panel-open inset above */
  .embed-dock.minimised > :not(.cd-head) { display: none !important; }
  .embed-dock.minimised .cd-head { cursor: pointer; }
  .embed-dock.minimised .cd-account { display: none; }
  .embed-dock.minimised .cd-head::before {
    content: ''; flex: none; width: 16px; height: 16px; margin-right: 8px; background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2l2.2 6.8L21 11l-6.8 2.2L12 20l-2.2-6.8L3 11l6.8-2.2zM19 16l.9 2.6 2.6.9-2.6.9L19 23l-.9-2.6-2.6-.9 2.6-.9zM5 1l.7 2 2 .7-2 .7L5 6.5l-.7-2.1-2-.7 2-.7z'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2l2.2 6.8L21 11l-6.8 2.2L12 20l-2.2-6.8L3 11l6.8-2.2zM19 16l.9 2.6 2.6.9-2.6.9L19 23l-.9-2.6-2.6-.9 2.6-.9zM5 1l.7 2 2 .7-2 .7L5 6.5l-.7-2.1-2-.7 2-.7z'/%3E%3C/svg%3E") center / contain no-repeat;
  }
  .embed-dock.minimised .cd-head::after { content: '⌃'; margin-left: auto; font-size: 18px; line-height: 1; }
  .embed-dock.minimised .embed-close { display: none; }
  /* With the chat open over a bot panel, a matching bar at the bottom goes back to the panel */
  body.chat-over-panel .embed-dock { bottom: 64px; }
  .embed-topanel {
    position: fixed; left: 8px; right: 8px; bottom: 8px; z-index: 46;
    display: flex; align-items: center; gap: 8px; padding: 12px 16px; border: 0; border-radius: 18px;
    background: #1d2b64; color: #fff; font: 800 14px/1.45 var(--font, system-ui), sans-serif; text-align: left; cursor: pointer;
    box-shadow: 0 10px 28px rgba(20, 40, 90, .3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .embed-topanel::after { content: '⌃'; margin-left: auto; font-size: 18px; line-height: 1; }
  .embed-topanel[hidden] { display: none; }
  .embed-topanel:focus-visible { outline: 3px solid #e0283c; outline-offset: 2px; }
  /* iPhones zoom the page when an input under 16px gets focus. */
  .cd-input { font-size: 16px; }
  .cd-log, .bp-body { overscroll-behavior: contain; }
  /* On-screen keyboard: embed.js sets html.keyboard, --vv-height (what's left of the screen) and --vv-top (how far the browser moved the view). */
  html.keyboard, html.keyboard body { overscroll-behavior: none; }
  html.keyboard body .embed-dock.chat-dock { inset: calc(var(--vv-top) + 8px) 8px auto 8px; height: calc(var(--vv-height) - 16px); }
  html.keyboard body #botpanel { bottom: auto; height: calc(var(--vv-top) + var(--vv-height) - var(--header) - 16px); }   /* 8px from the stage's top, 8px above the keyboard */
  html.keyboard body .embed-dock.minimised, html.keyboard .embed-topanel { display: none !important; }   /* no room, and the keyboard is in the way anyway */
}
