/* "Ask Kip" support chat (chat.js). Layout ideas from a Ramp product card (soft grey card,
   two-tone headline, square ↗ buttons, dotted flow lines, numbered boxed fields);
   colours and type are the homepage tokens from styles.css. Sits under the modals (z 100). */

.kip-launcher {
  position: fixed; right: 24px; bottom: 24px; z-index: 90;
  display: inline-flex; align-items: center; gap: 10px; height: 56px; padding: 0 8px 0 8px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--paper); color: var(--ink);
  font: 500 16px/1 var(--font); letter-spacing: -.01em; cursor: pointer;
  box-shadow: 0 10px 28px rgba(0, 18, 36, .14); transition: transform .15s var(--ease), box-shadow .15s;
}
.kip-launcher:hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(0, 18, 36, .18); }
.kip-launcher:focus-visible { outline: 3px solid var(--brand-deep); outline-offset: 3px; }
.kip-launcher-face { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 9px; background: var(--white); border: 1px solid var(--line); }
.kip-launcher-face img { width: 34px; height: 34px; object-fit: contain; }
.kip-launcher-label span { color: var(--muted); }
.kip-launcher-go { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 8px; background: var(--brand-deep); color: var(--white); }
.kip-launcher:hover .kip-launcher-go { background: var(--brand-ink); }
.kip-launcher-close { display: none; align-items: center; gap: 6px; padding: 0 12px 0 6px; font-weight: 600; }
.kip-open .kip-launcher-face, .kip-open .kip-launcher-label, .kip-open .kip-launcher-go { display: none; }
.kip-open .kip-launcher-close { display: inline-flex; }
.kip-open .kip-launcher { padding: 0 6px; }

.kip-panel {
  position: fixed; right: 24px; bottom: 96px; z-index: 90;
  width: 408px; height: min(660px, calc(100vh - 120px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--paper); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 18, 36, .2); font-family: var(--font); color: var(--ink);
  animation: kip-in .22s var(--ease);
}
.kip-panel[hidden] { display: none; }
@keyframes kip-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

.kip-head { position: relative; padding: 22px 20px 14px 22px; display: flex; align-items: flex-start; gap: 16px; overflow: hidden; }
.kip-flow { position: absolute; right: -20px; top: -10px; width: 280px; height: 190px; color: var(--brand); opacity: .55; pointer-events: none; }
.kip-head h2 { position: relative; flex: 1; margin: 0; font-size: 21px; line-height: 1.18; font-weight: 500; letter-spacing: -.02em; color: var(--ink); }
.kip-head h2 span { display: block; color: var(--muted); }
.kip-head-btns { position: relative; display: flex; gap: 6px; }
.kip-sq { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 7px; background: var(--white); color: var(--ink); cursor: pointer; text-decoration: none; box-shadow: 0 1px 2px rgba(0, 18, 36, .06); }
.kip-sq:hover { border-color: var(--line-strong); background: var(--paper-2); }
.kip-sq:focus-visible { outline: 2px solid var(--brand-deep); outline-offset: 2px; }

.kip-log { flex: 1; overflow-y: auto; padding: 6px 16px 16px; display: flex; flex-direction: column; gap: 12px; overscroll-behavior: contain; }
.kip-row { display: flex; align-items: flex-end; gap: 8px; }
.kip-me { justify-content: flex-end; }
.kip-avatar { width: 28px; height: 28px; flex: none; border-radius: 8px; background: var(--white); border: 1px solid var(--line); object-fit: contain; padding: 2px; }
.kip-wide { padding-left: 36px; }
.kip-bubble { max-width: 84%; padding: 11px 14px; border-radius: 14px; font-size: 14.5px; line-height: 1.45; }
.kip-bubble p { margin: 0; }
.kip-bot .kip-bubble { background: var(--white); border-bottom-left-radius: 4px; box-shadow: 0 6px 18px rgba(0, 18, 36, .08); }
.kip-me .kip-bubble { background: var(--ink); color: var(--white); border-bottom-right-radius: 4px; }

/* Ramp-style field: grey label, boxed value with a ↳ marker */
.kip-field { display: grid; gap: 4px; margin-top: 10px; }
.kip-field-label { font-size: 11.5px; color: var(--muted); }
.kip-field-value { display: flex; align-items: center; gap: 6px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--brand-deep); background: var(--white); }
.kip-field-value svg { flex: none; color: var(--muted); }

/* Ramp-style app "sheet": window bar + numbered boxed lines */
.kip-sheet { width: 100%; background: var(--white); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; box-shadow: 0 6px 18px rgba(0, 18, 36, .06); }
.kip-sheet-bar { display: flex; align-items: center; gap: 5px; padding: 8px 12px; background: var(--paper-2); border-bottom: 1px solid var(--line); }
.kip-sheet-bar i { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.kip-sheet-bar span { margin-left: auto; font-size: 11.5px; color: var(--muted); }
.kip-sheet-body { padding: 12px 14px 14px; display: grid; gap: 8px; }
.kip-sheet-title { margin: 0 0 2px; display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 500; letter-spacing: -.01em; }
.kip-line, .kip-q { display: grid; grid-template-columns: 22px 1fr; align-items: center; gap: 6px; }
.kip-line-n { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.kip-line-box { padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; font-size: 13.5px; line-height: 1.35; text-align: left; }
.kip-q { grid-template-columns: 22px 1fr 32px; width: 100%; padding: 0; border: 0; background: none; font: inherit; color: var(--ink); cursor: pointer; }
.kip-q-go { width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); }
.kip-q:hover .kip-line-box, .kip-q:hover .kip-q-go { border-color: var(--brand); background: var(--brand-soft); }
.kip-q:hover .kip-q-go { color: var(--brand-deep); }
.kip-q:focus-visible { outline: 2px solid var(--brand-deep); outline-offset: 2px; border-radius: 7px; }
.kip-q-urgent .kip-line-box { color: var(--red-ink); }
.kip-q-urgent:hover .kip-line-box, .kip-q-urgent:hover .kip-q-go { border-color: #F5C2C2; background: #FFF5F5; color: var(--red-ink); }
.kip-q:disabled { opacity: .5; cursor: default; }

.kip-sheet-warn { border-color: #F5C2C2; }
.kip-sheet-warn .kip-sheet-bar { background: #FFF5F5; border-color: #F5C2C2; }
.kip-sheet-warn .kip-sheet-title { color: var(--red-ink); font-weight: 600; }
.kip-card-actions { display: flex; gap: 8px; margin-top: 4px; }
.kip-btn { flex: 1; text-align: center; padding: 10px 12px; border-radius: 7px; border: 1px solid var(--line-strong); background: var(--white); color: var(--ink); font: 600 13px/1.2 var(--font); text-decoration: none; }
.kip-btn-primary { background: var(--brand-deep); border-color: var(--brand-deep); color: var(--white); }
.kip-btn:hover { filter: brightness(.95); }
.kip-card-note { margin: 0; font-size: 12px; color: var(--muted); }

.kip-dots { display: flex; gap: 4px; padding: 14px; }
.kip-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--brand-deep); animation: kip-dot 1s infinite ease-in-out; }
.kip-dots i:nth-child(2) { animation-delay: .15s; }
.kip-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes kip-dot { 0%, 80%, 100% { opacity: .3; transform: none; } 40% { opacity: 1; transform: translateY(-3px); } }

.kip-composer { padding: 12px 16px 12px; border-top: 1px solid var(--line); background: var(--white); display: grid; gap: 5px; }
.kip-label { font-size: 11.5px; color: var(--muted); }
.kip-input { display: flex; align-items: center; gap: 8px; }
.kip-input input { flex: 1; min-width: 0; height: 42px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--white); font: 400 15px/1.3 var(--font); color: var(--ink); outline: none; box-shadow: none; }
.kip-input input:focus, .kip-input input:focus-visible { border-color: var(--brand-deep); box-shadow: 0 0 0 3px var(--brand-soft); outline: none; }
.kip-input input::placeholder { color: var(--faint); }
.kip-input button { width: 42px; height: 42px; flex: none; display: grid; place-items: center; border: 0; border-radius: 8px; background: var(--brand-deep); color: var(--white); cursor: pointer; }
.kip-input button:hover { background: var(--brand-ink); }
.kip-input button:disabled { opacity: .5; cursor: default; }
.kip-foot { margin: 2px 0 0; font-size: 11px; line-height: 1.4; color: var(--muted); }

@media (max-width: 600px) {
  .kip-launcher { right: 16px; bottom: 16px; height: 52px; font-size: 15px; }
  .kip-panel { inset: 0; width: auto; height: auto; border: 0; border-radius: 0; }
  .kip-head { padding-top: max(18px, env(safe-area-inset-top)); }
  .kip-composer { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .kip-input input { font-size: 16px; } /* stops iOS zoom-on-focus */
  .kip-open .kip-launcher { display: none; } /* the header close button takes over */
  .kip-open body { overflow: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  .kip-panel, .kip-dots i { animation: none; }
  .kip-launcher { transition: none; }
}
