/* help-chat 2026-11-12: the signing page's "Ask for help" window (templates/_help_widget.html, static/help.js).
   Look and flow of mock B: a floating button, a chat window (phone: full screen). Colours only from the signing
   page's --pt-* tokens (shadows: the site's --sh-lg); font sizes only var(--fs-*); spacing --sp-*. No zoom / scale /
   3D transforms, no colour-scheme queries (the site is fixed dark). Everything is scoped under .hw: rules are
   (0,2,0) or more, so the flow shell's field rules (portal.css, (0,2,1)) are beaten only where they are named. */
.hw, .hw * { box-sizing: border-box; }
/* help-chat 2026-11-12 round 7 (owner 11-13: the button on every page): the marketing pages (data-shell="site") do not
   load portal.css, so the window's --pt-* tokens are mapped there to the site's own tokens (app.css, fixed dark); the
   signing page and the other flow / portal pages keep portal.css's values. */
body[data-shell="site"] .hw {
  --pt-canvas: var(--bg); --pt-surface: var(--bg-2); --pt-inset: var(--bg-3); --pt-line: var(--line);
  --pt-field: var(--ink-3); --pt-ink: var(--ink); --pt-ink-2: var(--ink-2); --pt-ink-3: var(--ink-3);
  --pt-link: var(--brand-ink); --pt-act: var(--brand); --pt-act-hover: var(--brand-ink); --pt-act-fg: var(--on-brand);
  --pt-done: var(--money); --pt-err: var(--danger); --pt-err-soft: var(--danger-soft);
  --pt-radius-card: 12px; --pt-radius: 10px;
}
/* help-chat 2026-11-12 round 7 (owner 11-13): the button never hides content for good.
   --hw-lift = the height of a bar fixed at the bottom of the page: the button (and the open window on a computer) sits
   above it - the homepage's "Finish signing up" bar (#hc-resume, its height in --resume-h from ac.js), the self-filing
   guide's phone bar (.diy-hire-bar) and the homeowners' exemption guide's phone bar (.hox-bar), both 64px + the safe
   area below 700px. The .hw element itself is an empty block at the end of <body> as tall as the button and its
   margins, so the footer and the legal disclosures can always be scrolled clear of the button. */
.hw { --hw-lift: 0px; display: block; height: calc(56px + 2 * var(--sp-3)); }
html:has(#hc-resume:not([hidden])) .hw { --hw-lift: var(--resume-h, 0px); }
@media (max-width: 699px) {
  html:has(.diy-hire-bar:not([hidden])) .hw, html:has(.hox-bar:not([hidden])) .hw {
    --hw-lift: calc(64px + env(safe-area-inset-bottom, 0px)); }
}
.hw { color: var(--pt-ink); font-size: var(--fs-body); line-height: 1.55; }
:where(.hw) button { padding: 0; font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.hw :focus-visible { outline: 2px solid var(--pt-link); outline-offset: 2px; }
.hw svg { flex: none; }
.hw [hidden] { display: none !important; }
html.hw-lock, html.hw-lock body { overflow: hidden; }

/* ── the floating button (the only thing on the closed page) ──
   help-chat 2026-11-12 round 5 (owner 11-13, "ask for help太不明显了"): the owner's otter (static/brand/otter-look.webp,
   help.js) in place of the speech bubble, at the homepage bar's size (64x44); the pill grows to fit (56px, phone 50px). */
.hw .hw-fab { position: fixed; z-index: 40; right: var(--sp-3); /* help-chat 2026-11-12 round 7 (owner 11-13): + --hw-lift */
              bottom: calc(var(--sp-3) + max(var(--hw-lift, 0px), env(safe-area-inset-bottom, 0px)));
              display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 5px 20px 5px 12px;
              font-weight: 700; color: var(--pt-ink); background: var(--pt-surface); border: 1px solid var(--pt-field);
              border-radius: 999px; box-shadow: var(--sh-lg); transition: opacity .15s; }
.hw .hw-fab:hover { background: var(--pt-inset); }
.hw .hw-otter { flex: none; display: block; width: 64px; height: 44px; object-fit: contain; pointer-events: none;
                user-select: none; }   /* help-chat 2026-11-12 round 5 (owner 11-13) */
.hw .hw-fab > span { white-space: nowrap; }   /* help-chat 2026-11-12 round 5 (owner 11-13): one line beside the otter */
@media (max-width: 640px) {   /* help-chat 2026-11-12 round 5 (owner 11-13): phone - otter 53x36, pill 50px */
  .hw .hw-fab { min-height: 50px; padding: 6px 18px 6px 10px; gap: 8px; }
  .hw .hw-otter { width: 53px; height: 36px; }
}
.hw .hw-fab.hw-new::after { content: ""; position: absolute; top: 6px; right: 8px; width: 10px; height: 10px;
                            background: var(--pt-done); border: 2px solid var(--pt-surface); border-radius: 50%; }
.hw.hw-open .hw-fab, .hw.hw-signing .hw-fab { opacity: 0; pointer-events: none; }
/* help-chat 2026-11-12 round 7 (owner 11-13): an address search's suggestion list (static/ac.js, .ac) is never under
   the button - the button steps aside while the list is open */
html:has(.ac:not([hidden])) .hw:not(.hw-open) .hw-fab { opacity: 0; pointer-events: none; }
@media (max-width: 640px) {   /* help-chat 2026-11-12 round 7 (owner 11-13): the reserved room = the phone pill */
  .hw { height: calc(50px + 2 * var(--sp-3)); }
}

/* ── the window ──
   help-chat 2026-11-12 round 7 (owner 11-13): above a bottom bar (--hw-lift) and over it (z-index 85 > the homepage
   bar's 80), so the composer is never behind it; a phone's full-screen window covers the bar */
.hw .hw-win { position: fixed; z-index: 85; right: var(--sp-3); bottom: calc(var(--sp-3) + var(--hw-lift, 0px)); width: 360px;
              height: min(640px, calc(100dvh - 32px - var(--hw-lift, 0px))); display: flex; flex-direction: column; visibility: hidden;
              opacity: 0; overflow: hidden; color: var(--pt-ink); background: var(--pt-surface);
              border: 1px solid var(--pt-line); border-radius: var(--pt-radius-card); box-shadow: var(--sh-lg);
              transform: translateY(12px); transition: transform .18s ease, opacity .18s ease, visibility .18s; }
.hw.hw-open .hw-win { visibility: visible; opacity: 1; transform: none; }
.hw .hw-head { flex: none; display: flex; align-items: center; justify-content: space-between; min-height: 56px;
               padding: 0 6px 0 var(--sp-3); border-bottom: 1px solid var(--pt-line); }
.hw .hw-title { margin: 0; font-size: var(--fs-body); font-weight: 700; line-height: 1.4; }
.hw .hw-x { display: grid; width: 44px; height: 44px; place-items: center; color: var(--pt-ink-2); }
.hw .hw-x svg { width: 14px; height: 14px; }
.hw .hw-log { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: var(--sp-3); }

/* bubbles */
.hw .hw-m { max-width: 86%; margin: 0; padding: 10px 12px; border-radius: 14px; overflow-wrap: anywhere; white-space: pre-line; }
.hw .hw-m.bot { align-self: flex-start; background: var(--pt-inset); border-bottom-left-radius: 4px; }
.hw .hw-m.me { align-self: flex-end; color: var(--pt-canvas); background: var(--pt-link); border-bottom-right-radius: 4px; }
.hw .hw-who { display: block; margin: 0 0 2px; font-size: var(--fs-small); font-weight: 700; color: var(--pt-ink-2); }
.hw .hw-sys { align-self: center; max-width: 92%; margin: 0; font-size: var(--fs-small); color: var(--pt-ink-2); text-align: center; }
.hw .hw-m.bot .hw-ans { white-space: normal; }

/* answers: the FAQ's own words */
.hw .hw-ans, .hw .hw-ans p, .hw .hw-ans li { font-size: var(--fs-body); }
.hw .hw-ans p { margin: 0 0 12px; }
.hw .hw-ans p:last-child { margin-bottom: 0; }
.hw .hw-ans ul { margin: 0 0 12px; padding-left: 1.2em; }
.hw .hw-ans li { margin: 0 0 4px; }
.hw .hw-ans a, .hw .hw-note a { color: var(--pt-link); text-decoration: underline; text-underline-offset: 2px; }

/* question list and the ghost buttons under it */
.hw .hw-opts { align-self: stretch; }
.hw .hw-list { list-style: none; margin: 0; padding: 0; overflow: hidden; background: var(--pt-surface);
               border: 1px solid var(--pt-line); border-radius: var(--pt-radius); }
.hw .hw-list li { margin: 0; }
.hw .hw-list li + li { border-top: 1px solid var(--pt-line); }
.hw .hw-q { display: flex; width: 100%; min-height: 52px; align-items: center; gap: 12px; padding: 12px; line-height: 1.4; text-align: left; }
.hw .hw-q:hover { background: var(--pt-inset); }
.hw .hw-chev { width: 8px; height: 12px; margin-left: auto; color: var(--pt-ink-3); }
.hw .hw-ghost { display: flex; width: 100%; min-height: 44px; margin-top: 8px; align-items: center; justify-content: center;
                padding: 8px 12px; font-weight: 600; text-align: center; border: 1px solid var(--pt-field); border-radius: var(--pt-radius); }
.hw .hw-ghost:hover { background: var(--pt-inset); }
.hw .hw-ghost[disabled], .hw .hw-go[disabled] { opacity: .45; cursor: default; }
.hw .hw-go { display: flex; width: 100%; min-height: 48px; margin-top: 12px; align-items: center; justify-content: center;
             padding: 8px 12px; font-weight: 700; text-align: center; color: var(--pt-act-fg); background: var(--pt-act);
             border-radius: var(--pt-radius); }
.hw .hw-go:hover { background: var(--pt-act-hover); }
.hw .hw-link { display: inline; margin: 6px 0 0; padding: 0; font-weight: 600; color: var(--pt-link);
               text-decoration: underline; text-underline-offset: 2px; text-align: left; }

/* help-chat 2026-11-12 (round 3): "Did this answer your question?", the typing line, the choice card's footer notice
   (once, under both options). help-chat 2026-11-12 round 6 (owner 11-13): the suggestion chips are gone */
/* help-chat 2026-11-12 round 6 (owner 11-13): the three chips became the "Common questions" heading + the same
   full-width list as the search results (.hw-list / .hw-q); .hw-chip stays for the Yes / No buttons */
.hw .hw-common { align-self: stretch; }
.hw .hw-common-h { margin: 0 0 6px; font-size: var(--fs-small); font-weight: 700; color: var(--pt-ink-2); }
.hw .hw-chip { min-height: 40px; padding: 6px 14px; font-weight: 600; line-height: 1.35; color: var(--pt-link);
               text-align: left; border: 1px solid var(--pt-field); border-radius: 999px; }
.hw .hw-chip:hover { background: var(--pt-inset); }
.hw .hw-fb { align-self: stretch; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.hw .hw-fb-q { flex-basis: 100%; margin: 0; font-size: var(--fs-small); color: var(--pt-ink-2); }
.hw .hw-fb .hw-chip { min-width: 72px; text-align: center; }
.hw .hw-choice > .hw-note { margin-top: 10px; }
.hw .hw-m.hw-typing { position: relative; display: flex; align-items: center; gap: 5px; min-height: 40px; }
.hw .hw-dot { width: 7px; height: 7px; background: var(--pt-ink-3); border-radius: 50%; animation: hw-blink 1.1s infinite ease-in-out; }
.hw .hw-dot:nth-of-type(3) { animation-delay: .18s; }
.hw .hw-dot:nth-of-type(4) { animation-delay: .36s; }
@keyframes hw-blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }
.hw .hw-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0);
             clip-path: inset(50%); white-space: nowrap; border: 0; }
@media (prefers-reduced-motion: reduce) {
  .hw .hw-dot { animation: none; opacity: .6; }
  .hw .hw-win { transition: none; }
}

/* the message form (a card in the log; no form element - see help.js) */
.hw .hw-card { align-self: stretch; margin: 0; padding: var(--sp-3); background: var(--pt-inset); border-radius: var(--pt-radius); }
.hw .hw-card-h { margin: 0 0 var(--sp-2); font-weight: 700; }
.hw .hw-fld { margin: 0 0 12px; }
.hw .hw-card label { display: block; margin: 0 0 4px; font-size: var(--fs-small); font-weight: 600; color: var(--pt-ink); }
.hw .hw-card .hw-in { display: block; width: 100%; min-height: 44px; padding: 0 12px; font-family: inherit;
                       font-size: var(--fs-body); line-height: 1.4; color: var(--pt-ink); background: var(--pt-surface);
                       border: 1px solid var(--pt-field); border-radius: var(--pt-radius); }
.hw .hw-card textarea.hw-in { min-height: 104px; padding: 10px 12px; resize: vertical; }
.hw .hw-card .hw-in[aria-invalid="true"] { border-color: var(--pt-err); }
.hw .hw-err { margin: 4px 0 0; font-size: var(--fs-small); font-weight: 600; color: var(--pt-err); }
.hw .hw-hint { margin: 4px 0 0; font-size: var(--fs-small); color: var(--pt-ink-2); }
.hw .hw-hint .hw-link { margin: 0; }
/* help-chat 2026-11-12 (round 2, A4): the honeypot field - off screen, never seen or reached by people */
.hw .hw-card .hw-hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
/* help-chat 2026-11-12 round 7 (owner 11-13): the address step before Talk to an agent (off the signing page) */
.hw .hw-card label.hw-card-h { margin: 0 0 4px; font-size: var(--fs-body); font-weight: 700; }
.hw .hw-card .hw-addr-why { margin: 0 0 var(--sp-2); }
.hw .hw-card .hw-in:disabled { opacity: .7; }
.hw .hw-alert { margin: 8px 0 0; padding: 8px 10px; font-size: var(--fs-small); color: var(--pt-err);
                background: var(--pt-err-soft); border-radius: var(--pt-radius); }

/* the composer */
.hw .hw-foot { flex: none; border-top: 1px solid var(--pt-line); }
.hw .hw-comp { display: flex; gap: 8px; padding: 10px 12px 0; }
.hw .hw-foot > .hw-err, .hw .hw-foot > .hw-note { padding: 0 12px; }
.hw .hw-foot > :last-child { padding-bottom: 10px; }
.hw .hw-win input.hw-inp { flex: 1; width: auto; min-width: 0; min-height: 44px; padding: 0 12px; font-family: inherit;
             font-size: var(--fs-body); line-height: 1.4; color: var(--pt-ink); background: var(--pt-inset);
             border: 1px solid var(--pt-field); border-radius: var(--pt-radius); }
.hw .hw-win input.hw-inp::placeholder, .hw .hw-card .hw-in::placeholder { color: var(--pt-ink-3); }
.hw .hw-send { display: grid; flex: none; width: 44px; height: 44px; place-items: center; color: var(--pt-act-fg);
               background: var(--pt-act); border-radius: var(--pt-radius); }
.hw .hw-send[disabled] { opacity: .4; cursor: default; }
.hw .hw-send svg { width: 18px; height: 18px; }
.hw .hw-note { margin: 6px 0 0; font-size: var(--fs-small); line-height: 1.5; color: var(--pt-ink-2); }

@media (max-width: 640px) {
  .hw .hw-win { top: 0; right: 0; bottom: 0; left: 0; width: auto; height: auto; border: 0; border-radius: 0; }
  .hw .hw-head { padding-top: env(safe-area-inset-top, 0px); }
  .hw .hw-foot > :last-child { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
}
