/* Escape Velocity — Ask, the chat helper (ask.js): the round button in the bottom right corner and its panel.
 * The button sits above the tab bar on a phone, above the Wall Street ticker, and above the Save bar on Update values
 * (--ask-lift, measured by ask.js). Under the investment panel (#drawer, 50), the More sheet, the search and the toasts. */
:root { --ask-lift: 0px; --ask-bottom: calc(1.25rem + var(--ticker-space, 0px) + var(--ask-lift)); }

.ask-fab { position: fixed; right: 1.25rem; bottom: var(--ask-bottom); z-index: 47; display: inline-flex; align-items: center; gap: .45rem;
  min-height: 3.1rem; padding: 0 1.15rem 0 .95rem; border-radius: 999px; border: 0; cursor: pointer; font: inherit; font-weight: 800; font-size: 1rem;
  background: linear-gradient(90deg, var(--btn-g1, var(--g1)), var(--btn-g2, var(--g2))); color: var(--on-primary, #fff);
  box-shadow: 0 3px 10px -3px rgba(0, 0, 0, .45), 0 0 0 1px rgba(255, 255, 255, .08) inset; transition: transform .15s, box-shadow .15s; }   /* a tight shadow: text beside the button stays as it was */
.ask-fab[hidden] { display: none; }
body.ask-fab-on main { padding-bottom: calc(5.25rem + var(--ticker-space, 0px)); }   /* the end of every page can be scrolled clear of the button */
.ask-fab svg { width: 1.35rem; height: 1.35rem; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.ask-fab:hover { transform: translateY(-1px); box-shadow: 0 5px 14px -4px rgba(0, 0, 0, .5), 0 0 0 1px rgba(255, 255, 255, .12) inset; }
.ask-fab:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.ask-fab[aria-expanded="true"] { box-shadow: 0 0 0 3px color-mix(in srgb, var(--g1) 45%, transparent), 0 3px 10px -3px rgba(0, 0, 0, .45); }
body.no-anim .ask-fab { transition: none; }

.ask-panel { position: fixed; right: 1.25rem; bottom: calc(var(--ask-bottom) + 3.8rem); z-index: 48; width: min(25rem, calc(100vw - 2.5rem));
  height: min(38rem, calc(100vh - var(--ask-bottom) - 5.5rem)); height: min(38rem, calc(100dvh - var(--ask-bottom) - 5.5rem)); display: flex; flex-direction: column;
  background: var(--card-solid); color: var(--ink); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 24px 70px rgba(0, 0, 0, .5); overflow: hidden; }
.ask-panel[hidden] { display: none; }
.ask-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .85rem .9rem .75rem 1.1rem; border-bottom: 1px solid var(--line); }
.ask-head h2 { margin: 0; font-size: 1.15rem; line-height: 1.2; }
.ask-head p { margin: .1rem 0 0; color: var(--muted); font-size: .9rem; }
.ask-head-btns { display: inline-flex; gap: .35rem; flex: none; }

.ask-log { position: relative; flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: .9rem 1rem .4rem; display: flex; flex-direction: column; gap: .7rem; }
.ask-hello p { margin: 0 0 .6rem; }
.ask-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.ask-chip { min-height: 2rem; }
.ask-msg { max-width: 92%; padding: .65rem .85rem; border-radius: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.ask-msg p { margin: 0; }
.ask-msg p + p, .ask-msg p + .ask-hit, .ask-msg .ask-hit + .ask-hit { margin-top: .5rem; }
.ask-msg.me { align-self: flex-end; background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 35%, transparent); border-bottom-right-radius: 5px; }
.ask-msg.bot { align-self: flex-start; background: color-mix(in srgb, var(--ink) 5%, var(--card-solid)); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.ask-steps { margin: .45rem 0 0; padding-left: 1.3rem; display: grid; gap: .3rem; }
.ask-more, .ask-from, .ask-note { color: var(--muted); font-size: .92rem; }
.ask-from { margin-top: 0; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; font-size: .78rem; }
.ask-hit p { margin-top: .15rem; color: var(--ink); }
.ask-advice { margin-top: .55rem !important; padding: .5rem .65rem; border-radius: 10px; border-left: 4px solid var(--warn-ink, #b45309); background: color-mix(in srgb, var(--warn-ink, #b45309) 9%, transparent); font-size: .92rem; }
.ask-btns { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .65rem; }
.ask-dots { display: inline-flex; gap: .3rem; padding: .2rem 0; }
.ask-dots i { width: .5rem; height: .5rem; border-radius: 50%; background: var(--muted); opacity: .4; animation: askDot 1.1s infinite ease-in-out; }
.ask-dots i:nth-child(2) { animation-delay: .15s; } .ask-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes askDot { 0%, 80%, 100% { opacity: .3; transform: none; } 40% { opacity: 1; transform: translateY(-3px); } }
body.no-anim .ask-dots i { animation: none; opacity: .7; }
@media (prefers-reduced-motion: reduce) { .ask-dots i { animation: none; opacity: .7; } .ask-fab { transition: none; } }

.ask-form { display: flex; gap: .5rem; align-items: flex-end; padding: .7rem .9rem .35rem; border-top: 1px solid var(--line); }
.ask-form textarea { flex: 1; min-height: var(--ctl-h, 2.75rem); max-height: 8.25rem; resize: none; padding: .6rem .75rem; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--card-solid); color: var(--ink); font: inherit; line-height: 1.4; width: auto; }
.ask-form textarea:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.ask-form .btn { flex: none; }
.ask-foot { margin: 0; padding: 0 1rem .75rem; color: var(--muted); font-size: .82rem; line-height: 1.35; }

/* phones and tablets: above the tab bar */
@media (max-width: 860px) {
  :root { --ask-bottom: calc(var(--tabbar-space) + .75rem + var(--ticker-space, 0px) + var(--ask-lift)); }
  .ask-fab { right: .9rem; }
}
/* a phone: the panel is a sheet over the page, above the tab bar, and the button steps aside while it is open */
@media (max-width: 600px) {
  .ask-fab { min-height: 3rem; padding: 0 1rem 0 .85rem; }
  body.ask-on .ask-fab { display: none; }
  .ask-panel { left: 0; right: 0; width: auto; bottom: calc(var(--tabbar-space) + var(--ticker-space, 0px)); height: auto; max-height: calc(100vh - var(--tabbar-space) - var(--desk-hint-h, 0px) - 2.5rem);
    max-height: calc(100dvh - var(--tabbar-space) - var(--desk-hint-h, 0px) - 2.5rem); min-height: 55vh; border-radius: 20px 20px 0 0; border-bottom: 0; box-shadow: 0 -16px 50px rgba(0, 0, 0, .5); }
  .ask-msg { max-width: 96%; }
}
@media print { .ask-fab, .ask-panel { display: none !important; } }
