/* Ask: the floating button, the assistant panel (side panel on desktop, bottom sheet on phones) and the multi
   optimiser cards (in the chat and in the bet slip). Tokens from app.css + predictor.css only, both themes; no inline
   styles (CSP). Stacking: tab bar 45 < Ask 49 < slip bar 50 < slip sheet 55/60 < assistant 64/65 < age gate 100. */

/* ---------------------------------------------------------------- the floating "Ask" button */
/* desktop: over the main column's bottom-right corner, never over the slip column (320px + 20px gap + 16px padding) */
.ask-fab { position: fixed; z-index: 49; bottom: 20px; right: calc(max(0px, (100vw - 1640px) / 2) + 372px);
  width: 60px; height: 60px; border-radius: 50%; border: 0; padding: 0; display: grid; place-items: center; align-content: center; gap: 1px;
  background: var(--nav); color: var(--nav-ink); font: 800 .68rem/1 var(--sans); letter-spacing: .02em; cursor: pointer;
  box-shadow: 0 0 0 1px var(--nav-line), 0 12px 28px -10px rgba(0, 0, 0, .55); transition: transform .15s ease, box-shadow .15s ease; }
.ask-fab svg { width: 24px; height: 24px; fill: none; stroke: var(--brand); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ask-fab:hover { transform: translateY(-2px); box-shadow: 0 0 0 1px var(--brand), 0 16px 30px -10px rgba(0, 0, 0, .6); }
.ask-fab:active { transform: translateY(0) scale(.96); }
.ask-fab:focus-visible { outline: 3px solid var(--brand); outline-offset: 3px; border-radius: 50%; }
body[data-route="slip"] .ask-fab { right: calc(max(0px, (100vw - 1640px) / 2) + 24px); }
body.chat-open .ask-fab, body.sheet-open .ask-fab { display: none; }

/* ---------------------------------------------------------------- the panel */
.chat-bd { position: fixed; inset: 0; z-index: 64; background: rgba(4, 8, 18, .5); }
.chat { position: fixed; z-index: 65; top: 0; right: 0; bottom: 0; width: min(460px, 100vw); display: flex; flex-direction: column;
  background: var(--bg); border-left: 1px solid var(--line); box-shadow: -14px 0 40px rgba(0, 0, 0, .35); }
.chat-h { display: flex; align-items: center; gap: 8px; padding: 12px 12px 12px 16px; background: var(--nav); color: var(--nav-ink); flex: none; }
.chat-ht { flex: 1; min-width: 0; }
.chat-h h2 { font-size: 1.02rem; font-weight: 850; }
.chat-ctx { margin: 2px 0 0; font-size: .74rem; color: var(--nav-muted); }
.chat-x { width: 36px; height: 36px; flex: none; border-radius: 8px; border: 1px solid var(--nav-line); background: none; color: var(--nav-ink); font-size: 1.3rem; line-height: 1; cursor: pointer; }
.chat-x:hover { border-color: var(--brand); }
.chat-log { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; list-style: none; margin: 0; padding: 14px 12px; display: grid; align-content: start; gap: 12px; outline: none; }
.cm { min-width: 0; font-size: .9rem; line-height: 1.5; }
.cm p { margin: 0; } .cm-text p + p, .cm-text p + ul, .cm-text p + ol, .cm-text ul + p, .cm-text ol + p { margin-top: 8px; }
.cm-text ul, .cm-text ol { margin: 0; padding-left: 20px; display: grid; gap: 3px; }
.cm-user { justify-self: end; max-width: 86%; padding: 9px 13px; border-radius: 16px 16px 4px 16px; background: var(--sel-bg); color: var(--sel-ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.cm-bot { justify-self: stretch; padding: 11px 13px; border-radius: 16px 16px 16px 4px; background: var(--surface); border: 1px solid var(--line); overflow-wrap: anywhere; display: grid; gap: 10px; }
.cm-bot > * { min-width: 0; }
.cm-intro { background: var(--ref-bg); border-color: transparent; color: var(--ref-ink); }
.cm-sugg { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-q { text-align: left; padding: 7px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: 650 .82rem/1.35 var(--sans); cursor: pointer; }
.chip-q:hover { border-color: var(--accent); background: var(--odds-hover); }
.cm-used { margin: 0; font-size: .72rem; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 6px; }
.cm-err { background: var(--bad-bg); border-color: transparent; }
.cm-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.cm-thinking { background: var(--surface-2); color: var(--muted); }
.cm-wait { display: flex; align-items: flex-start; gap: 10px; font-size: .84rem; }
.cm-stop { color: var(--accent); justify-self: start; } .cm-stop:hover { color: var(--text); }
.opt-acts [aria-disabled="true"] { opacity: .6; cursor: progress; }
.dots { display: inline-flex; gap: 4px; padding-top: 7px; flex: none; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: chat-dot 1.1s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes chat-dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.chat-f { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px; border-top: 1px solid var(--line); background: var(--surface); flex: none; }
.chat-f textarea { flex: 1; min-width: 0; resize: none; max-height: 140px; min-height: 44px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: 400 16px/1.4 var(--sans); }
.chat-f textarea:focus-visible { outline: 3px solid var(--accent); outline-offset: 0; }
.chat-send { min-height: 44px; flex: none; }
.chat-foot { margin: 0; padding: 0 12px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); font-size: .68rem; color: var(--muted); flex: none; }

/* ---------------------------------------------------------------- optimiser (slip zone and chat cards) */
.opt-zone { display: grid; gap: 8px; padding: 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.opt-zone > *, .optr > *, .opt-body > *, .oc > * { min-width: 0; }
.opt-intro { margin: 0; font-size: .78rem; color: var(--muted); }
.opt-acts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.opt-target { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--muted); }
.opt-target input { width: 84px; min-height: 36px; padding: 5px 8px; font-size: 16px; }
.opt-out:empty { display: none; }
.optr { display: grid; gap: 10px; }
.opt-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; }
.opt-sum { margin: 0; font-size: .8rem; color: var(--muted); } .opt-sum b { color: var(--text); }
.opt-book { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--muted); }
.opt-book select { min-height: 34px; padding: 4px 8px; font-size: .84rem; max-width: 150px; }
.opt-body { display: grid; gap: 10px; }
.opt-now { margin: 0; padding: 7px 10px; border-radius: 9px; background: var(--ref-bg); color: var(--ref-ink); font-size: .8rem; } .opt-now b { color: var(--text); }
.opt-cards { display: grid; gap: 10px; }
.oc { display: grid; gap: 8px; padding: 10px 12px 12px; border-radius: 12px; border: 1px solid var(--line); border-top: 3px solid var(--best); background: var(--surface-2); }
.oc-value { border-top-color: var(--accent); } .oc-target { border-top-color: var(--pc); }
.oc-h { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.oc-h h4 { margin: 0; font-size: .92rem; font-weight: 850; }
.oc-book { font-size: .72rem; font-weight: 750; color: var(--muted); }
.oc-sub { margin: 0; font-size: .76rem; color: var(--muted); }
.oc-legs { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.oc-legs li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 8px; background: var(--surface); }
.oc-sel { display: grid; min-width: 0; } .oc-sel b { font-size: .84rem; overflow-wrap: anywhere; }
.oc-ev { font-size: .72rem; color: var(--muted); overflow-wrap: anywhere; }
.oc-new { justify-self: start; margin-top: 2px; padding: 0 6px; border-radius: 4px; background: var(--accent-soft); color: var(--text); font-size: .62rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.oc-px { display: grid; text-align: right; } .oc-px b { font-size: .9rem; font-weight: 850; } .oc-px span { font-size: .68rem; color: var(--muted); white-space: nowrap; }
.oc-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 0; }
.oc-stats div { display: grid; gap: 1px; padding: 6px 8px; border-radius: 8px; background: var(--surface); }
.oc-stats dt { font-size: .66rem; color: var(--muted); font-weight: 700; }
.oc-stats dd { margin: 0; font-size: 1rem; font-weight: 850; }
.oc-delta, .oc-model { margin: 0; font-size: .76rem; color: var(--muted); }
.oc .mc-open ol { margin: 6px 0 0; padding-left: 20px; font-size: .8rem; } .oc .mc-open summary { font-size: .8rem; }
.oc-late { margin: 0; padding: 6px 8px; border-radius: 8px; background: var(--bad-bg); font-size: .78rem; }
.oc-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.oc-acts .btn { flex: 1 1 140px; }
.opt-miss { margin: 0; }
.opt-swaps h4 { margin: 0 0 6px; font-size: .84rem; }
.opt-swaps ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.opt-swaps li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 7px 9px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); font-size: .8rem; }
.sw-what { display: grid; gap: 1px; min-width: 0; } .sw-what s { color: var(--muted); } .sw-eff, .sw-after { font-size: .74rem; } .sw-after { color: var(--muted); }
.opt-adv summary { cursor: pointer; font-size: .8rem; font-weight: 750; color: var(--muted); }
.opt-adv[open] summary { margin-bottom: 6px; }
.opt-fr { width: 100%; border-collapse: collapse; font-size: .8rem; }
.opt-fr th, .opt-fr td { padding: 5px 6px; border: 0; font-family: var(--sans); text-align: left; }
.opt-fr .r { text-align: right; }
.opt-fr thead th { font-size: .66rem; color: var(--muted); }
.opt-fr .btn.sm { min-height: 30px; padding: 3px 10px; }
.opt-fr tbody tr:not(.fr-legs) td { border-top: 1px solid var(--line); }
.fr-legs td { padding-top: 0; font-size: .7rem; color: var(--muted); overflow-wrap: anywhere; }
.opt-notes { margin: 0; padding-left: 18px; font-size: .78rem; color: var(--muted); }
.optr .note { margin: 0; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1199px) {
  /* drawer layout: the slip bar (right 16px, bottom 16px) sits below the button. On the full-width slip page the
     button would sit over the multi's prices, so it steps aside there: the page's own "Improve this multi" opens the chat */
  .ask-fab { right: 16px; bottom: 76px; }
  body:has(#slipbar[hidden]) .ask-fab { bottom: 16px; }
  body[data-route="slip"] .ask-fab { display: none; }
}
@media (max-width: 899px) {
  /* phone: above the full-width slip bar, which sits above the tab bar */
  .ask-fab { right: 12px; bottom: calc(122px + env(safe-area-inset-bottom)); width: 54px; height: 54px; }
  body:has(#slipbar[hidden]) .ask-fab { bottom: calc(70px + env(safe-area-inset-bottom)); }
  footer.rg-footer { padding-bottom: calc(190px + env(safe-area-inset-bottom)); }
  .chat { top: auto; left: 0; width: 100%; height: 88vh; height: 88dvh; border-left: 0; border-radius: 16px 16px 0 0; box-shadow: 0 -14px 40px rgba(0, 0, 0, .35); overflow: hidden; overflow: clip; }
  .chat-h { border-radius: 16px 16px 0 0; }
  body.chat-open { overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) { .ask-fab { transition: none; } .dots i { animation: none; opacity: .7; } }
@media print { .ask-fab, .chat, .chat-bd, .opt-zone { display: none !important; } }
