/* Design83: launchers stay available, while page controls take priority. */
#fab:focus-visible, #mwCharacter:focus-visible, #watchRestore:focus-visible,
#watchPanel button:focus-visible {
  outline: 3px solid #963b2c;
  outline-offset: 3px;
}
#watchPanel button { min-height: 44px; }
#watchPanel .mw-close { width: 44px; height: 44px; }
#watchPanel input, #watchPanel textarea { scroll-margin-block: 90px; }

@media (max-width: 759px) {
  html { scroll-padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px)); }
  /* Five intent tabs keep at least 44px; the companion gets its own sixth slot. */
  body.mx:has(#watchMascot:not([hidden]), #watchRestore:not([hidden])) #links {
    width: calc(100% - 60px);
    right: 60px;
    padding-left: 8px;
    padding-right: 8px;
    gap: 2px;
    bottom: var(--nc-ui-viewport-gap, 0px);
  }
  body.mx #links a { min-width: 44px; }
  body.mx .mw-companion.nav-docked { width: 46px; height: 46px; }
  body.mx .mw-companion.nav-docked::before {
    content: "";
    position: absolute;
    top: -10px;
    left: -14px;
    width: 60px;
    height: calc(70px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #d9cbb5;
    background: #faf6ee;
    z-index: -1;
  }
  body.mx .mw-companion.nav-docked #mwCharacter {
    width: 46px;
    height: 46px;
    border: 1px solid #b99c7d;
    background: #fff8eb;
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
    touch-action: manipulation;
  }
  body.mx .mw-companion.nav-docked .mw-svg {
    width: 44px;
    height: 46px;
    overflow: hidden;
    filter: none;
    animation: none;
  }
  body.mx .mw-companion.nav-docked .mw-thinking {
    left: 6px;
    bottom: 1px;
    padding: 3px 4px;
    gap: 3px;
  }
  body.mx .mw-companion.nav-docked.minimised .mw-mini-label {
    font-size: .58rem;
  }
  body.mx .mw-companion.nav-docked .mw-tip {
    bottom: 62px;
    top: auto;
  }
  body.mx #watchRestore {
    right: 8px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px) + var(--nc-ui-viewport-gap, 0px));
    width: 46px;
    min-height: 46px;
    padding: 4px;
    font-size: .6rem;
  }
  body.mx #gatebtn { min-height: 44px; }
  body.mx #app :is(button, input, textarea, select, summary) {
    scroll-margin-bottom: calc(90px + env(safe-area-inset-bottom, 0px));
  }

  /* Public visitors keep the existing chat launcher, now a compact touch control. */
  body:not(.mx) #fab {
    width: 48px;
    height: 48px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    transform: none;
    transition: background-color .2s;
    border: 1px solid #b99c7d;
    box-shadow: 0 4px 16px #1c1f3026;
  }
  /* The narrow-screen Gate action must not sit underneath the chat launcher. */
  body:not(.mx) .lx:not(.ms) .lx-open .lx-cta { padding-right: 64px; }
  body:not(.mx) .mk-bubble { right: 72px; bottom: 20px; }
  /* On public form routes, use an opaque assistant rail rather than artwork over fields. */
  body:not(.mx):has(#app form) { padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
  body:not(.mx):has(#app form) #fab {
    width: calc(100% - 32px);
    right: 16px;
    border-radius: 14px;
    background: #fff8eb;
  }
  body:not(.mx):has(#app form) #fab::before {
    content: "";
    position: fixed;
    inset: auto 0 0;
    height: calc(72px + env(safe-area-inset-bottom, 0px));
    background: #faf6ee;
    border-top: 1px solid #d9cbb5;
    pointer-events: none;
    z-index: -1;
  }
  body:not(.mx):has(#app form) #fab::after {
    content: "Ask Markus";
    color: #292b38;
    font: 700 .85rem var(--sans);
  }
  body:not(.mx):has(#app form) #fab .mk-mini {
    width: 42px;
    left: 7px;
    right: auto;
  }
  body:not(.mx):has(#app form) #fab .fs,
  body:not(.mx):has(#app form) .mk-bubble { display: none; }
  body:not(.mx) #app :is(button, input, textarea, select, summary) { scroll-margin-bottom: 90px; }
}

@media (prefers-reduced-motion: reduce) {
  body:not(.mx) #fab { transition: none; }
}
