/* In-app helper (js/assistant): a round chat button in the bottom-left corner and the panel that opens upward from it.
   Grey like the rest of the UI, except the button's soft glow, which marks it as the place to ask. */
body { --as-fab-bottom: calc(env(safe-area-inset-bottom, 0px) + 16px + var(--bottom-h) + 12px); } /* over the sky's bottom bar */
body:not([data-view="sky"]) { --as-fab-bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); } /* Compare and Field cover that bar */

.as-fab {
  position: fixed; z-index: 6; left: calc(env(safe-area-inset-left, 0px) + 16px); bottom: var(--as-fab-bottom);
  width: 52px; height: 52px; padding: 0; border-radius: 50%; display: grid; place-items: center;
  background: var(--panel-solid); color: var(--ink); border: 1px solid var(--edge); cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .25), 0 0 20px 4px rgba(120, 180, 255, .5);
  animation: as-glow 2.8s ease-in-out infinite; transition: transform .15s ease;
}
.as-fab:hover { transform: translateY(-1px) scale(1.05); }
.as-fab:active { transform: scale(.97); }
.as-fab:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.as-fab[aria-expanded="true"] { background: var(--fill); color: var(--fill-ink); }
@keyframes as-glow {
  0%, 100% { box-shadow: 0 6px 18px rgba(0, 0, 0, .25), 0 0 16px 3px rgba(120, 180, 255, .45); }
  50% { box-shadow: 0 6px 18px rgba(0, 0, 0, .25), 0 0 30px 9px rgba(120, 180, 255, .7); }
}

#assistant {
  position: fixed; z-index: 5; left: calc(env(safe-area-inset-left, 0px) + 16px); bottom: calc(var(--as-fab-bottom) + 64px); width: 360px;
  max-height: calc(100dvh - var(--as-top, calc(var(--top-h) + 8px)) - var(--as-fab-bottom) - 72px);
  border-radius: 10px; display: flex; flex-direction: column; overflow: hidden;
  background: var(--panel-solid); /* solid: long text over the moving sky stays readable */
}
#assistant[hidden] { display: none; }
#assistant:not([hidden]) > * { animation: as-in .2s cubic-bezier(.2, .7, .2, 1); }
@keyframes as-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.as-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--edge); }
.as-head h2 { margin: 0; font-size: 13px; font-weight: 500; }

.as-log { flex: 1 1 auto; min-height: 80px; overflow: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; outline: none; }
.as-log:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.as-msg { margin: 0; line-height: 1.5; max-width: 100%; overflow-wrap: anywhere; }
.as-msg p { margin: 0; }
.as-a { color: var(--ink-2); }
.as-a p:first-child { color: var(--ink); }
.as-intro { color: var(--ink-2); }
.as-q { align-self: flex-end; max-width: 85%; padding: 6px 10px; border-radius: 8px; background: var(--fill); color: var(--fill-ink); }
.as-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.as-acts button { text-align: left; line-height: 1.3; }
.as-src { margin-top: 6px !important; font-size: 11px; color: var(--ink-3); }
.as-wait { color: var(--ink-3); font-style: italic; }
.as-tag { display: inline-block; margin-bottom: 4px; padding: 0 5px; border: 1px solid var(--edge); border-radius: 4px; font-size: 10.5px; letter-spacing: .02em; color: var(--ink-2); }
.as-a .as-tag + p { color: var(--ink); }

.as-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 14px; border-top: 1px solid var(--edge); }
.as-chip { border-radius: 999px; padding: 6px 10px; color: var(--ink-2); line-height: 1.3; text-align: left; }
.as-chip:hover { color: var(--ink); }

.as-form { display: flex; gap: 6px; padding: 8px 14px 12px; }
.as-form input { flex: 1; min-width: 0; }

body[data-mode="simple"] .as-msg { font-size: 14px; }

@media (max-width: 860px) and (pointer: coarse), (max-width: 560px) {
  .as-fab { width: 56px; height: 56px; }
  .as-chip, .as-acts button, .as-form button, .as-form input { min-height: 40px; }
  .as-head .icon { width: 40px; height: 40px; }
}
@media (max-width: 560px) {
  /* a sheet across the screen, from just above the button up to the wrapped top bar (--as-top, set by index.js) */
  #assistant { left: 12px; right: 12px; width: auto; bottom: calc(var(--as-fab-bottom) + 66px); max-height: calc(100dvh - var(--as-top, 160px) - var(--as-fab-bottom) - 74px); }
  .as-msg { font-size: 14px; }
  .as-form input { font-size: 16px; } /* no zoom on focus in iOS Safari */
}
/* Below 860 px the Field view scrolls as one page and the bubble sits over its end: room after the last control
   (bubble 56 px + 16 px from the edge + a gap) so it scrolls clear instead of staying under the bubble. */
@media (max-width: 860px) { .fv .fv-side { padding-bottom: 88px; } }
/* In portrait below 860 px the movers list opens as a sheet over the bottom of the sky, where the bubble sits: the
   bubble steps aside until the sheet closes (unless the helper itself is open). In landscape the list docks right. */
@media (max-width: 860px) and (orientation: portrait) { body.panel-open[data-view="sky"] .as-fab:not([aria-expanded="true"]) { display: none; } }
@media (prefers-reduced-motion: reduce) { .as-fab { animation: none; transition: none; } #assistant > * { animation: none !important; } .as-log { scroll-behavior: auto; } }
