/* Chip — floating button + slide-over panel. Works on the app and the marketing site, so
 * every token has a fallback and every selector is .chip-* scoped. (Chip agent.) */
.chip-root {
  --chip-ink: #1D2826; --chip-bg: #FFFFFF; --chip-soft: #F7F2E9; --chip-line: #E8DFCF;
  --chip-accent: #BF4519; --chip-accent-soft: #FBE3D7; --chip-butter: #F4C95D;
  --chip-muted: #66716D; --chip-sage: #2F6B52; --chip-sage-soft: #DDEBDF;
  --chip-warn: #8A5A00; --chip-warn-soft: #FDF1CF;
  --chip-ink-hi: #2A3634; --chip-accent-hover: #A23A13; --chip-soft-2: #FCFAF6;
  --chip-warn-edge: #F0DC9A; --chip-sage-edge: #BFD8C5;
  --chip-ink-rgb: 29, 40, 38; --chip-accent-rgb: 191, 69, 25; --chip-butter-rgb: 244, 201, 93;
  --chip-font: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font: 14px/1.5 var(--chip-font); color: var(--chip-ink);
}
.chip-root *, .chip-root *::before, .chip-root *::after { box-sizing: border-box; }
.chip-root .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* the face (same look as the builder's robot) */
.chip-face { position: relative; display: inline-grid; grid-auto-flow: column; gap: 22%; place-content: center; flex: none;
  width: 34px; height: 29px; border-radius: 10px; background: linear-gradient(160deg, var(--chip-ink-hi, var(--ink-hi)), var(--chip-ink, var(--text)));
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.25); margin-top: 6px; }
.chip-face::before { content: ""; position: absolute; top: -6px; left: 50%; width: 2px; height: 6px; background: var(--chip-ink, var(--text)); transform: translateX(-50%); border-radius: 2px; }
.chip-face::after { content: ""; position: absolute; top: -10px; left: 50%; width: 7px; height: 7px; border-radius: 50%; background: var(--chip-accent); transform: translateX(-50%); box-shadow: 0 0 8px rgba(var(--chip-accent-rgb, var(--accent-rgb)), .55); }
.chip-face i { width: 6px; height: 6px; border-radius: 50%; background: var(--chip-butter); box-shadow: 0 0 6px rgba(var(--chip-butter-rgb, var(--butter-rgb)), .7); animation: chip-blink 5s infinite; }
.chip-face-md { width: 38px; height: 32px; border-radius: 11px; }
.chip-face-md i { width: 7px; height: 7px; }
.chip-face-sm { width: 36px; height: 30px; }
.chip-face-xs { width: 28px; height: 24px; border-radius: 8px; }
.chip-face-xs i { width: 5px; height: 5px; }
.chip-face-xs::before { top: -5px; height: 5px; } .chip-face-xs::after { top: -9px; width: 6px; height: 6px; }
.chip-face.working i { animation: chip-think 1.1s ease-in-out infinite alternate; }
@keyframes chip-blink { 0%, 46%, 50%, 100% { transform: scaleY(1); } 48% { transform: scaleY(.1); } }
@keyframes chip-think { from { transform: translateX(-2px); } to { transform: translateX(2px); } }

/* launcher */
.chip-launcher { position: fixed; right: 20px; bottom: 20px; z-index: 900; display: inline-flex; align-items: center; gap: 9px;
  padding: 8px 16px 8px 10px; border: 0; border-radius: 999px; background: var(--chip-bg); color: var(--chip-ink);
  font: 600 14px/1.2 var(--chip-font, var(--font, system-ui, sans-serif)); cursor: pointer; box-shadow: 0 2px 6px rgba(var(--chip-ink-rgb), .08), 0 12px 32px rgba(var(--chip-ink-rgb), .18);
  transition: transform .15s, box-shadow .15s; }
.chip-launcher .chip-face { margin-top: 7px; }
.chip-launcher-label { font: inherit; color: inherit; line-height: 1.2; white-space: nowrap; }
.chip-launcher:hover { transform: translateY(-2px); }
.chip-launcher { transition: transform .15s, box-shadow .15s, opacity .2s, visibility .2s; }
.chip-launcher:focus-visible { outline: 3px solid rgba(var(--chip-accent-rgb), .45); outline-offset: 2px; }
.chip-badge { position: absolute; top: -4px; right: -2px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--chip-accent); color: #fff; font-size: 12px; line-height: 20px; text-align: center; }
html.chip-open .chip-launcher { opacity: 0; pointer-events: none; }
/* the app's off-canvas nav drawer (app.js) is modal: keep the button out of it */
html.drawer-open .chip-launcher { display: none; }
/* Don't collide with the visitor-facing apps' own floating buttons in previews, or the builder composer. */
/* In the builder the chat on the left *is* Chip, so the global button stays out of the way
   (it covered the preview toolbar and the site's own chat bubble on small screens). */
body.builder-page .chip-launcher { display: none; }

/* panel */
.chip-panel { position: fixed; right: 20px; bottom: 20px; z-index: 901; width: min(410px, calc(100vw - 32px));
  height: min(640px, calc(100vh - 40px)); display: flex; flex-direction: column; background: var(--chip-bg);
  border: 1px solid var(--chip-line); border-radius: 20px; overflow: hidden;
  box-shadow: 0 2px 6px rgba(var(--chip-ink-rgb), .06), 0 24px 64px rgba(var(--chip-ink-rgb), .22); animation: chip-in .18s ease-out; }
.chip-panel[hidden] { display: none; }
@keyframes chip-in { from { opacity: 0; transform: translateY(12px); } }
.chip-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 16px; border-bottom: 1px solid var(--chip-line);
  background: linear-gradient(180deg, var(--chip-accent-soft), var(--chip-bg)); }
.chip-who { display: flex; flex-direction: column; line-height: 1.2; flex: 1; min-width: 0; }
.chip-who strong { font-size: 16px; }
.chip-who span { font-size: 12px; color: var(--chip-muted); }
.chip-icon-btn { border: 0; background: transparent; width: 34px; height: 34px; border-radius: 10px; cursor: pointer; font-size: 16px; color: var(--chip-ink); }
.chip-icon-btn:hover, .chip-icon-btn:focus-visible { background: rgba(var(--chip-ink-rgb), .07); outline: none; }

.chip-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: var(--chip-soft); }
.chip-msg { display: flex; gap: 8px; align-items: flex-start; max-width: 100%; }
.chip-msg-body { background: var(--chip-bg); border: 1px solid var(--chip-line); border-radius: 4px 14px 14px 14px; padding: 9px 12px; min-width: 0; overflow-wrap: anywhere; }
.chip-me { justify-content: flex-end; }
.chip-me .chip-msg-body { background: var(--chip-ink); color: #fff; border-color: var(--chip-ink); border-radius: 14px 4px 14px 14px; max-width: 85%; }
.chip-text p { margin: 0 0 6px; } .chip-text p:last-child { margin-bottom: 0; }
.chip-text ul { margin: 4px 0; padding-left: 18px; }
.chip-note { font-size: 12px; color: var(--chip-muted); margin: 6px 0 0; }
.chip-sources { margin-top: 8px; font-size: 12px; color: var(--chip-muted); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.chip-sources a { color: var(--chip-accent); text-decoration: underline; text-underline-offset: 2px; }
.chip-actions, .chip-nudge-row, .chip-confirm-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.chip-btn { display: inline-flex; align-items: center; min-height: 32px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--chip-line);
  background: var(--chip-bg); color: var(--chip-ink); font: 600 13px var(--chip-font); text-decoration: none; cursor: pointer; }
.chip-btn:hover { border-color: var(--chip-ink); }
.chip-btn:focus-visible, .chip-suggest button:focus-visible, .chip-link:focus-visible { outline: 3px solid rgba(var(--chip-accent-rgb), .35); outline-offset: 1px; }
.chip-btn-primary { background: var(--chip-accent); border-color: var(--chip-accent); color: #fff; }
.chip-btn-primary:hover { background: var(--chip-accent-hover); border-color: var(--chip-accent-hover); }
.chip-btn.disabled { opacity: .55; cursor: not-allowed; }
.chip-btn[disabled] { opacity: .6; cursor: wait; }
.chip-confirm { margin-top: 8px; padding: 10px; border-radius: 12px; background: var(--chip-warn-soft); border: 1px solid var(--chip-warn-edge); }
.chip-confirm p { margin: 0; font-size: 13px; }
.chip-status { display: block; font-size: 12px; margin-top: 6px; color: var(--chip-ink); }
.chip-link { border: 0; background: none; padding: 4px; color: var(--chip-muted); font: 500 12px var(--chip-font); cursor: pointer; text-decoration: underline; }

.chip-suggest { display: flex; flex-wrap: wrap; gap: 6px; padding-left: 36px; }
.chip-suggest button { border: 1px solid var(--chip-line); background: var(--chip-bg); color: var(--chip-ink); border-radius: 999px;
  padding: 6px 12px; font: 500 13px var(--chip-font); cursor: pointer; text-align: left; }
.chip-suggest button:hover { border-color: var(--chip-accent); color: var(--chip-accent); }

.chip-nudge { border-radius: 12px; padding: 10px 12px; border: 1px solid var(--chip-line); background: var(--chip-bg); }
.chip-nudge p { margin: 0; }
.chip-nudge-warn { background: var(--chip-warn-soft); border-color: var(--chip-warn-edge); }
.chip-nudge-success { background: var(--chip-sage-soft); border-color: var(--chip-sage-edge); }

.chip-journey { background: var(--chip-bg); border: 1px solid var(--chip-line); border-radius: 14px; padding: 10px 12px; }
.chip-journey summary { display: flex; justify-content: space-between; gap: 8px; cursor: pointer; list-style: none; }
.chip-journey summary::-webkit-details-marker { display: none; }
.chip-journey summary span { color: var(--chip-muted); font-size: 12px; white-space: nowrap; }
.chip-progress { height: 6px; border-radius: 99px; background: var(--chip-soft); margin: 8px 0 6px; overflow: hidden; }
.chip-progress span { display: block; height: 100%; background: var(--chip-sage); border-radius: 99px; }
.chip-steps { list-style: none; margin: 0; padding: 0; }
.chip-step { display: grid; grid-template-columns: 20px 1fr; gap: 0 8px; align-items: center; padding: 4px 0; font-size: 13px; }
.chip-step a { color: var(--chip-ink); text-decoration: none; }
.chip-step a:hover { color: var(--chip-accent); text-decoration: underline; }
.chip-tick { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--chip-line); display: grid; place-items: center; font-size: 11px; color: #fff; }
.chip-step.done .chip-tick { background: var(--chip-sage); border-color: var(--chip-sage); }
.chip-step.done > span:nth-child(2) { color: var(--chip-muted); text-decoration: line-through; text-decoration-color: rgba(0,0,0,.25); }
.chip-step.current .chip-tick { border-color: var(--chip-accent); box-shadow: 0 0 0 3px var(--chip-accent-soft); }
.chip-step.current a { font-weight: 700; }
.chip-step.skipped { opacity: .55; }
.chip-step-hint { grid-column: 2; font-size: 12px; color: var(--chip-muted); }
.chip-next { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--chip-line); }
.chip-next p { margin: 0 0 4px; font-size: 13px; }

.chip-dots { display: inline-flex; gap: 4px; padding: 4px 0; }
.chip-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--chip-muted); animation: chip-dot 1s infinite ease-in-out; }
.chip-dots i:nth-child(2) { animation-delay: .15s; } .chip-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes chip-dot { 50% { transform: translateY(-4px); opacity: .5; } }

.chip-composer { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px; border-top: 1px solid var(--chip-line); background: var(--chip-bg); }
.chip-composer textarea { flex: 1; resize: none; min-height: 42px; height: 42px; margin: 0; border: 1.5px solid var(--chip-line); border-radius: 14px; padding: 9px 12px;
  font: 15px/1.4 var(--chip-font); color: var(--chip-ink); background: var(--chip-soft-2); max-height: 120px; }
.chip-composer textarea:focus { outline: none; border-color: var(--chip-accent); box-shadow: 0 0 0 3px rgba(var(--chip-accent-rgb), .18); background: #fff; }
.chip-send { width: 40px; height: 40px; flex: none; border: 0; border-radius: 12px; background: var(--chip-accent); color: #fff; cursor: pointer; display: grid; place-items: center; }
.chip-send svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.chip-send:disabled, .chip-composer textarea:disabled { opacity: .5; cursor: not-allowed; }
.chip-foot { display: flex; flex-direction: column; gap: 2px; padding: 8px 14px 10px; font-size: 12px; border-top: 1px solid var(--chip-line); background: var(--chip-bg); }
.chip-foot a { color: var(--chip-accent); font-weight: 600; text-decoration: none; }
.chip-foot a:hover { text-decoration: underline; }
.chip-cta { font-size: 14px; }
.chip-fine { color: var(--chip-muted); font-size: 11px; }

@media (max-width: 600px) {
  .chip-launcher { right: 12px; bottom: 12px; padding: 7px 14px 7px 9px; }
  .chip-panel { right: 0; bottom: 0; width: 100vw; height: 100dvh; max-height: none; border-radius: 0; border: 0; }
  .chip-composer textarea { font-size: 16px; } /* no iOS zoom */
  .chip-launcher { bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  /* [fix-1106 M2] marketing "Ask Chip" on phones: the face only (the label stays for screen readers), and out of
     the way (chip.js adds .chip-away) while it would cover the hero, a form field or a button */
  .chip-launcher-public { padding: 7px; gap: 0; }
  .chip-launcher-public .chip-launcher-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .chip-launcher.chip-away { opacity: 0; visibility: hidden; transform: translateY(12px); pointer-events: none; }
  .chip-foot { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
}
/* touch screens: 16px composer (no iOS zoom), 44px tap targets */
@media (pointer: coarse) {
  .chip-composer textarea { font-size: 16px; min-height: 44px; }
  .chip-send { width: 44px; height: 44px; }
  .chip-icon-btn { width: 44px; height: 44px; }
  .chip-btn, .chip-suggest button { min-height: 44px; }
  .chip-link { min-height: 44px; padding: 4px 8px; }
  .chip-launcher { min-height: 48px; }
  .chip-journey summary { min-height: 44px; align-items: center; }
  .chip-foot a, .chip-sources a, .chip-step a { display: inline-flex; align-items: center; min-height: 44px; }
}
/* tablets: a taller panel that still leaves the page's top bar visible */
@media (min-width: 601px) and (max-width: 1024px) {
  .chip-panel { height: min(720px, calc(100dvh - 96px)); }
}
@media (prefers-reduced-motion: reduce) {
  .chip-face i, .chip-dots i, .chip-panel { animation: none; }
}

/* The journey card on the site Overview (app/chip_journey_card.html). */
.chip-journey-card .chip-steps-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.chip-journey-card .chip-step-row { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--border, #E8DFCF); }
.chip-journey-card .chip-step-row:last-child { border-bottom: 0; }
.chip-journey-card .chip-tick { width: 20px; height: 20px; }
.chip-journey-card .done .chip-tick { background: var(--sage, #2F6B52); border-color: var(--sage, #2F6B52); color: #fff; }
.chip-journey-card .done .chip-step-label { color: var(--muted, #66716D); }
.chip-journey-card .current .chip-tick { border-color: var(--accent, #BF4519); box-shadow: 0 0 0 3px var(--accent-soft, #FBE3D7); }
.chip-journey-card .current .chip-step-label { font-weight: 700; }
.chip-journey-card .skipped { opacity: .55; }
.chip-journey-card .chip-step-label small { display: block; font-weight: 400; color: var(--muted, #66716D); }
.chip-journey-card .chip-next-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.chip-journey-card .chip-next-row .chip-face { margin-top: 8px; }

/* [consent] above the marketing site's cookie banner while it is open (site.js sets --consent-h; 0 elsewhere) */
.chip-launcher { margin-bottom: var(--consent-h, 0px); }
