/* Kelly's panel (kelly-panel.js): her look from the Finance and Health dashboards' widget (Kelly-Cloud
   public/widget/v1/kelly-widget.js), in her own magenta. Nothing here uses Hollow's amber. */
.kp {
  --kp-bg: #06111c; --kp-surface: #0d1b29; --kp-border: #16283a; --kp-text: #fff; --kp-muted: #7ea3bc; --kp-accent: var(--kelly, #D6336F);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.kp *, .kp *::before, .kp *::after { box-sizing: border-box; font-family: inherit; }

/* The launcher: her headshot, top right of every page. Her logo (logo-kelly.png, untouched) zoomed past its
   lettering to her face and pink hair. */
.kelly-btn { position: relative; width: 44px; height: 44px; padding: 0; border-radius: 50%; border: none; background: none; flex: none; cursor: pointer; }
.kelly-face { position: relative; display: block; width: 44px; height: 44px; border-radius: 50%; overflow: hidden; border: 2px solid color-mix(in srgb, var(--kelly) 55%, transparent); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45); background: #1a1016; }
.kelly-face img { width: 100%; height: 100%; object-fit: cover; display: block; transform: scale(1.45); }
.kelly-btn::before { content: ''; position: absolute; inset: -5px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--kelly) 55%, transparent) 0%, transparent 70%); animation: kp-breathe 2.8s ease-in-out infinite; }
.kelly-btn:focus-visible { outline: 2px solid var(--kelly); outline-offset: 3px; }
.kelly-btn.unavailable::before { display: none; }
.kelly-btn.unavailable .kelly-face { filter: grayscale(1); opacity: 0.45; border-color: var(--field-border); box-shadow: none; }

/* Her avatar, bottom right, as on Finance and Health (kelly-avatar.js, a verbatim copy in /vendor/kelly). Gone while
   she's unavailable or hidden: the greyed headshot says so. */
.kelly-off [data-kelly-avatar], .kelly-hidden [data-kelly-avatar] { display: none; }
.kelly-btn[hidden] { display: none; }
@keyframes kp-breathe { 0%, 100% { transform: scale(0.92); opacity: 0.55; } 50% { transform: scale(1.18); opacity: 0.95; } }

/* The panel: a modal dialog, so it opens over the file viewer too */
dialog.kp-modal {
  width: min(820px, calc(100vw - 32px)); height: min(600px, calc(100vh - 32px)); max-width: none; max-height: none;
  padding: 0; border: 1px solid var(--kp-border); border-radius: 20px; overflow: hidden; color: var(--kp-text);
  background: var(--kp-surface); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}
dialog.kp-modal[open] { display: flex; }
dialog.kp-modal::backdrop { background: rgba(6, 17, 28, 0.6); backdrop-filter: blur(3px); }
dialog.kp-modal.kp-ack { box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), 0 0 0 2px var(--kp-accent); }

.kp-stage { position: relative; width: 340px; flex: none; overflow: hidden; background: var(--kp-bg); }
.kp-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.kp-gradient { position: absolute; left: 0; right: 0; bottom: 0; height: 56%; background: linear-gradient(180deg, transparent 0%, rgba(6, 17, 28, 0.9) 100%); pointer-events: none; }
.kp-name { position: absolute; left: 14px; bottom: 12px; font-size: 0.9375rem; font-weight: 700; letter-spacing: 0.02em; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6); }
.kp-round { position: absolute; top: 10px; width: 32px; height: 32px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.25); background: rgba(6, 17, 28, 0.5); color: var(--kp-text); cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; z-index: 1; }
.kp-round svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.kp-close { right: 10px; }
.kp-voice { right: 48px; }
.kp-round:focus-visible, .kp-send:focus-visible, .kp-btn:focus-visible, .kp-choice:focus-visible, .kp-chip button:focus-visible { outline: 2px solid var(--kp-accent); outline-offset: 2px; }

.kp-chat { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.kp-context { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px 0; min-height: 0; }
.kp-context:empty { display: none; }
.kp-chip { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 3px 9px; border-radius: 999px; background: var(--kp-bg); border: 1px solid var(--kp-border); color: var(--kp-muted); font-size: 0.75rem; }
.kp-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kp-chip b { color: var(--kp-text); font-weight: 600; }
.kp-chip button { border: none; background: none; color: var(--kp-muted); cursor: pointer; padding: 0 0 0 2px; font-size: 0.8125rem; line-height: 1; }

.kp-transcript { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.kp-msg { max-width: 85%; padding: 0.5rem 0.7rem; border-radius: 12px; font-size: 0.8125rem; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.kp-msg-user { align-self: flex-end; background: color-mix(in srgb, var(--kp-accent) 30%, var(--kp-surface)); }
.kp-msg-kelly { align-self: flex-start; background: var(--kp-bg); border: 1px solid var(--kp-border); }
.kp-msg-error { align-self: flex-start; background: transparent; border: 1px solid #6b2138; color: #ff9db3; }
.kp-hint { align-self: center; color: var(--kp-muted); font-size: 0.75rem; text-align: center; padding: 18px 12px; }

/* A change waiting for the OK, then its one-line result with Undo */
.kp-card { align-self: stretch; padding: 0.7rem 0.8rem; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--kp-accent) 45%, var(--kp-border)); background: var(--kp-bg); font-size: 0.8125rem; line-height: 1.45; display: grid; gap: 8px; }
.kp-card p { margin: 0; overflow-wrap: anywhere; }
.kp-card .kp-done { color: var(--kp-text); }
.kp-card .kp-quiet { color: var(--kp-muted); }
.kp-card .kp-one { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kp-row { display: flex; gap: 8px; flex-wrap: wrap; }
.kp-btn { border-radius: 999px; padding: 0.4rem 0.9rem; font-size: 0.8125rem; font-weight: 600; cursor: pointer; border: 1px solid var(--kp-border); background: var(--kp-surface); color: var(--kp-text); }
.kp-btn.kp-primary { background: var(--kp-accent); border-color: var(--kp-accent); color: #fff; }
.kp-btn:disabled { opacity: 0.5; cursor: default; }

.kp-choices { align-self: stretch; display: grid; gap: 6px; }
.kp-choice { text-align: left; padding: 0.5rem 0.7rem; border-radius: 12px; border: 1px solid var(--kp-border); background: var(--kp-bg); color: var(--kp-text); cursor: pointer; font-size: 0.8125rem; display: grid; gap: 2px; }
.kp-choice:hover { border-color: var(--kp-accent); }
.kp-ask { margin: 0; color: var(--kp-muted); font-size: 0.8125rem; }
.kp-choice small { color: var(--kp-muted); font-size: 0.6875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.kp-composer { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--kp-border); flex: none; margin: 0; }
.kp .kp-input { flex: 1; width: auto; min-width: 0; background: var(--kp-bg); border: 1px solid var(--kp-border); color: var(--kp-text); border-radius: 999px; padding: 0.55rem 0.9rem; font-size: 0.8125rem; outline: none; }
.kp .kp-input:focus, .kp .kp-input:focus-visible { border-color: var(--kp-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--kp-accent) 25%, transparent); }
.kp-send { flex: none; width: 34px; height: 34px; border-radius: 50%; border: none; background: var(--kp-accent); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.kp-send svg { width: 15px; height: 15px; fill: currentColor; }
.kp-send:disabled { opacity: 0.5; cursor: default; }
.kp-typing { align-self: flex-start; display: flex; gap: 4px; padding: 0.5rem 0.7rem; }
.kp-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--kp-muted); animation: kp-typing 1.1s ease-in-out infinite; }
.kp-typing span:nth-child(2) { animation-delay: 0.15s; }
.kp-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes kp-typing { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

@media (max-width: 640px) {
  dialog.kp-modal { width: 100vw; height: 100dvh; border-radius: 0; border: none; }
  dialog.kp-modal[open] { flex-direction: column; }
  .kp-stage { width: 100%; height: 280px; }
  .kp-chat { flex: 1; min-height: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .kelly-btn::before, .kp-typing span { animation: none; }
}
