/* UI v2 message dock (dock.js). Bottom-right chat window + parked conversation tabs on
   desktop; an 85% bottom sheet with a grab handle on phone. Sits left of the Ask
   FleetCollect orb (brain/static, right:28px, 60px). Dialogs (V2.confirm, panel.js) open
   with showModal() in the top layer, so they always stack above the dock. */
.v2dock{position:fixed;right:24px;bottom:16px;z-index:9990;display:flex;align-items:flex-end;gap:12px;
  font-size:14px;line-height:1.45;color:var(--ink);pointer-events:none}
body:has(.brain-launch) .v2dock{right:104px}
.v2dock > *{pointer-events:auto}
.v2dock [hidden]{display:none !important}
.v2dock button{font:inherit}
.v2dock-ico{width:40px;height:40px;border-radius:10px;border:0;background:transparent;color:var(--ink);cursor:pointer;
  display:inline-flex;align-items:center;justify-content:center;flex:none;text-decoration:none}
.v2dock-ico:hover{background:var(--chip);color:var(--ink)}
.v2dock-ico svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}
.v2dock-av{position:relative;flex:none;width:36px;height:36px;border-radius:999px;background:var(--brand-50);color:var(--brand-deep);
  display:flex;align-items:center;justify-content:center;font-weight:600;font-size:13px}
.v2dock-badge{position:absolute;top:-5px;right:-7px;min-width:20px;height:20px;padding:0 5px;box-sizing:border-box;border-radius:999px;
  background:var(--brand-strong);color:#fff;font-size:11px;font-weight:600;font-family:var(--mono);display:flex;align-items:center;
  justify-content:center;border:2px solid #fff}

/* parked tabs */
.v2dock-heads{display:flex;align-items:flex-end;gap:12px}
.v2dock-head{display:flex;align-items:center;height:56px;box-sizing:border-box;background:var(--surface);border:1px solid var(--line);
  border-radius:14px;box-shadow:0 12px 32px rgba(15,23,42,.16),0 2px 6px rgba(15,23,42,.08);padding-right:4px}
.v2dock-head > .v2dock-open{display:flex;align-items:center;gap:10px;min-height:54px;padding:0 8px 0 10px;border:0;background:transparent;
  color:inherit;cursor:pointer;text-align:left;border-radius:14px}
.v2dock-head .who{display:block;min-width:0;width:156px;text-align:left;overflow:hidden}
.v2dock-head .nm{display:block;font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.v2dock-head .pv{display:block;font-size:12px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.v2dock-head .v2dock-ico{color:var(--muted)}
.v2dock-head .v2dock-ico svg{width:14px;height:14px}

/* open window */
.v2dock-win{width:384px;height:560px;max-height:calc(100vh - 32px);max-height:calc(100dvh - 32px);box-sizing:border-box;background:var(--surface);
  border:1px solid var(--line);border-radius:14px;box-shadow:0 24px 56px rgba(15,23,42,.22),0 4px 12px rgba(15,23,42,.10);
  display:flex;flex-direction:column;overflow:hidden}
.v2dock-grab,.v2dock-also,.v2dock-scrim{display:none}
.v2dock-top{display:flex;align-items:center;gap:10px;padding:10px 6px 10px 14px;flex:none}
.v2dock-who{flex:1;min-width:0}
.v2dock-who h2{margin:0;font-size:15px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.v2dock-who .sub{font-size:12px;min-height:18px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.v2dock-who .sub .v2st{font-size:12px}
.v2dock-chan{display:flex;align-items:center;gap:10px;padding:0 14px 10px;border-bottom:1px solid var(--line-soft);flex:none}
.v2dock-seg{display:flex;gap:2px;background:#EEF0F4;padding:3px;border-radius:10px;flex:none}
.v2dock-seg button{min-height:34px;min-width:64px;padding:0 12px;border:0;border-radius:8px;background:transparent;font-size:13px;font-weight:500;color:var(--muted);cursor:pointer}
.v2dock-seg button[aria-pressed="true"]{background:#fff;box-shadow:0 1px 2px rgba(15,23,42,.10);font-weight:600;color:var(--ink)}
.v2dock-to{flex:1;min-width:0;text-align:right;font-size:12px;color:var(--muted);font-family:var(--mono);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

.v2dock-log{flex:1 1 auto;min-height:0;overflow-y:auto;display:flex;flex-direction:column-reverse;background:#F7F8FA;overscroll-behavior:contain}
.v2dock-msgs{display:flex;flex-direction:column;gap:6px;padding:12px 14px 14px}
.v2dock-day{display:flex;align-items:center;gap:10px;margin:8px 0 4px;font-size:12px;font-weight:600;color:var(--muted)}
.v2dock-day::before,.v2dock-day::after{content:"";flex:1;height:1px;background:var(--line)}
.v2dock-m{display:flex;flex-direction:column;gap:3px}
.v2dock-m.out{align-items:flex-end}
.v2dock-m.in{align-items:flex-start}
.v2dock-bub{max-width:80%;padding:9px 12px;font-size:14px;line-height:1.4;white-space:pre-wrap;overflow-wrap:anywhere;color:var(--ink)}
.v2dock-m.out .v2dock-bub{background:#FCE3F2;border-radius:16px 16px 4px 16px}
.v2dock-m.in .v2dock-bub{background:#fff;border:1px solid var(--line);border-radius:16px 16px 16px 4px}
.v2dock-m.failed .v2dock-bub{background:var(--crit-bg);border:1px solid var(--crit-line);color:#7A1A12}
.v2dock-bub .subj{display:block;font-weight:600;margin-bottom:2px}
.v2dock-mm{font-size:11px;color:var(--muted);padding:0 4px}
.v2dock-mm .bad{color:var(--crit-fg);font-weight:600}
.v2dock-ev{display:flex;flex-direction:column;align-items:center;gap:3px;margin:4px 0}
.v2dock-ev .chip{display:inline-flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:6px;max-width:92%;padding:5px 11px;border-radius:999px;
  background:#EEF1F5;color:var(--text);font-size:12px;font-weight:600;text-align:center}
.v2dock-ev.review .chip{background:#EAF2FF;color:#1D4ED8}
.v2dock-ev.filed .chip{background:var(--ok-bg);color:var(--ok-fg)}
.v2dock-ev .chip svg{width:13px;height:13px;fill:none;stroke:currentColor;stroke-width:2;flex:none}
.v2dock-ev .chip a{color:inherit;text-decoration:underline}
.v2dock-ev .meta{font-size:11px;color:var(--muted)}
.v2dock-note{align-self:center;font-size:12px;color:var(--muted);text-align:center;padding:6px 0}

.v2dock-comp{flex:none;border-top:1px solid var(--line-soft);background:#fff}
.v2dock-quick{display:flex;gap:8px;padding:10px 14px 0;overflow-x:auto;scrollbar-width:none}
.v2dock-quick button{flex:none;min-height:40px;padding:0 14px;border-radius:999px;border:1px solid var(--field);background:#fff;font-size:13px;
  font-weight:600;color:var(--ink);cursor:pointer;white-space:nowrap}
.v2dock-quick button:hover{background:var(--brand-50);border-color:var(--brand-200)}
.v2dock-form{padding:10px 14px 12px;display:flex;flex-direction:column;gap:8px}
.v2dock-subj{display:flex;align-items:center;gap:8px;font-size:13px;color:var(--muted)}
.v2dock-subj input{flex:1;min-width:0;min-height:40px;padding:0 10px;border:1px solid var(--field);border-radius:10px;font:inherit;font-size:14px;color:var(--ink)}
.v2dock-form textarea{width:100%;box-sizing:border-box;min-height:64px;max-height:160px;padding:10px 12px;border:1px solid var(--field);border-radius:12px;
  font:inherit;font-size:14px;line-height:1.4;color:var(--ink);resize:none;background:#fff}
.v2dock-row{display:flex;align-items:center;gap:8px}
.v2dock-count{flex:1;min-width:0;font-size:12px;color:var(--muted);font-family:var(--mono);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.v2dock-send{min-height:40px;padding:0 16px;border-radius:10px;border:0;background:#EEF0F4;font-weight:600;color:var(--muted);cursor:pointer;
  display:inline-flex;align-items:center;gap:8px;flex:none}
.v2dock-send.ready{background:var(--brand);color:#fff}
.v2dock-send.ready:hover{background:var(--brand-strong)}
.v2dock-send[disabled]{opacity:.7;cursor:progress}
.v2dock-send svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.v2dock-ro{padding:12px 14px;font-size:13px;color:var(--muted);margin:0}
.v2dock-addph{display:flex;flex-direction:column;gap:8px;padding:10px 14px 12px}
.v2dock-addph-l{display:flex;flex-direction:column;gap:4px;font-size:13px;font-weight:600}
.v2dock-addph input[type=tel]{min-height:38px;border:1px solid var(--field);border-radius:8px;padding:0 10px;font:inherit;font-size:14px;font-weight:400}
.v2dock-addph input[type=tel]:focus{outline:2px solid var(--brand);outline-offset:0;border-color:var(--brand)}
.v2dock-cons{display:flex;align-items:center;gap:8px;font-size:13px}
.v2dock-cons input{width:16px;height:16px;accent-color:var(--brand)}
.v2dock-err{margin:0;font-size:12.5px;color:var(--crit-fg)}
.v2dock-addph .v2dock-row{justify-content:flex-end}
.v2dock-load{flex:1;display:flex;align-items:center;justify-content:center;color:var(--muted);font-size:13px;background:#F7F8FA}

/* the button that opened the open conversation */
.is-docked{background:var(--brand-50) !important;border-color:var(--brand) !important;color:var(--brand-deep) !important;box-shadow:0 0 0 3px var(--brand-50)}

/* toasts stay visible above the dock */
body.v2dock-on .v2-toast{z-index:9995}
body.v2dock-on:has(.brain-launch) .v2-toast{right:104px}

@media (min-width:701px) and (max-width:1100px){.v2dock-heads .v2dock-head:nth-child(n+3){display:none}}

/* phone: 85% bottom sheet */
@media (max-width:700px){
  .v2dock{left:0;right:0;bottom:0;display:block}
  body:has(.brain-launch) .v2dock{right:0}
  .v2dock-heads{position:fixed;left:16px;bottom:calc(84px + env(safe-area-inset-bottom));flex-direction:column-reverse;align-items:flex-start;gap:10px}
  .v2dock.sheet .v2dock-heads{display:none}
  .v2dock-head{height:52px;width:52px;border-radius:999px;padding:0;justify-content:center}
  .v2dock-head > .v2dock-open{min-height:50px;width:50px;padding:0;border-radius:999px;justify-content:center}
  .v2dock-head .v2dock-av{width:40px;height:40px}
  .v2dock-head .who,.v2dock-head .v2dock-ico{display:none}
  .v2dock-scrim{display:block;position:fixed;inset:0;background:rgba(15,23,42,.45)}
  .v2dock-win{position:fixed;left:0;right:0;bottom:var(--v2dock-kb,0px);width:auto;max-height:none;
    height:min(85vh, calc(var(--v2dock-vh,100vh) - 12px));height:min(85dvh, calc(var(--v2dock-vh,100dvh) - 12px));
    border:0;border-radius:20px 20px 0 0;box-shadow:0 -12px 40px rgba(15,23,42,.25);transition:transform .18s ease}
  .v2dock-grab{display:flex;justify-content:center;padding-top:4px;flex:none;touch-action:none}
  .v2dock-grab button{width:64px;height:24px;border:0;background:transparent;cursor:grab;display:flex;align-items:center;justify-content:center}
  .v2dock-grab span{width:40px;height:5px;border-radius:999px;background:#C9CFD8}
  .v2dock-also{display:flex;align-items:center;gap:8px;padding:0 16px 8px;overflow-x:auto;flex:none;scrollbar-width:none}
  .v2dock-also > span{font-size:12px;color:var(--muted);flex:none}
  .v2dock-also button{flex:none;display:inline-flex;align-items:center;gap:8px;min-height:40px;padding:0 12px 0 4px;border-radius:999px;
    border:1px solid var(--line);background:#fff;font-size:13px;font-weight:600;color:var(--ink);cursor:pointer}
  .v2dock-also .v2dock-av{width:32px;height:32px;font-size:12px}
  .v2dock-also .n{min-width:20px;height:20px;padding:0 6px;box-sizing:border-box;border-radius:999px;background:var(--brand-strong);color:#fff;
    font-size:11px;font-family:var(--mono);display:inline-flex;align-items:center;justify-content:center}
  .v2dock-top{padding:4px 8px 10px 16px}
  .v2dock-who h2{font-size:16px}
  .v2dock-chan{padding:0 16px 10px}
  .v2dock-top .v2dock-ico{width:44px;height:44px}
  .v2dock-bub{font-size:15px}
  .v2dock-quick{padding:10px 16px 0}
  .v2dock-form{padding:10px 16px calc(12px + env(safe-area-inset-bottom))}
  .v2dock.kb .v2dock-form{padding-bottom:10px}
  .v2dock-form textarea,.v2dock-subj input{font-size:16px}
  .v2dock-send{min-height:44px}
  .v2dock-quick button{min-height:44px}
  body.v2dock-sheet{overflow:hidden}
  body.v2dock-sheet .brain-launch{display:none}
  body.v2dock-sheet .v2-toast{bottom:auto;top:16px}
}
@media (prefers-reduced-motion:reduce){.v2dock-win{transition:none}}
