/* The panel's own stylesheet.
 *
 * It lives inside an iframe, so none of this can leak into the host page and none
 * of their CSS can reach in. That isolation is the main reason the panel is a
 * separate document rather than a div — a widget that inherits a host page's
 * `* { box-sizing }`, line-height, or `!important` button styles looks broken on
 * roughly every third site it is installed on.
 *
 * Deliberately no dark-mode block. The launcher and panel are the *brand's*
 * furniture on the brand's site, and a support bubble that flips to dark while the
 * page around it stays light looks like a bug rather than a preference.
 */

:root {
  --paper: #ffffff;
  --ink: #23201b;
  --muted: #6d675e;
  --faint: #a09a90;
  --line: #e6dfd2;
  --accent: #b4512a;
  --bot: #f4efe6;
  --radius: 12px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
  overflow: hidden;
}

/* -------------------------------------------------- head */

.head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--line);
  background: #26332f;
  color: #f4f1ea;
}

.who {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
}

.who strong { display: block; font-size: 13.5px; }

.sub {
  display: block;
  color: #a9b3ae;
  font-size: 11px;
}

.close {
  flex: none;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #c9d1cd;
  font-size: 13px;
  cursor: pointer;
}

.close:hover { background: rgb(255 255 255 / 0.12); color: #fff; }

/* -------------------------------------------------- log */

.log {
  flex: 1;
  overflow-y: auto;
  padding: 0.9rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  /* The transcript grows from the bottom; scroll anchoring would fight the
   * scrollTop assignment in panel.js. */
  overflow-anchor: none;
}

.msg { display: flex; }
.msg.user { justify-content: flex-end; }

.bubble {
  max-width: 85%;
  padding: 0.5rem 0.7rem;
  border-radius: 14px;
  background: var(--bot);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-wrap: anywhere;
}

.msg.user .bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg.bot .bubble { border-bottom-left-radius: 4px; }

/* -------------------------------------------------- cards & links */

.card {
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.card-title {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 12.5px;
}

.card-rows {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.15rem 0.7rem;
  margin: 0;
  font-size: 12.5px;
}

.card-rows dt { color: var(--faint); }
.card-rows dd { margin: 0; }

.article {
  display: inline-block;
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-size: 12px;
  text-decoration: none;
  align-self: flex-start;
}

.article:hover { background: var(--accent); color: #fff; }

.article-plain { font-size: 12px; color: var(--muted); }

/* -------------------------------------------------- typing */

.dots {
  flex-direction: row;
  gap: 4px;
  padding: 0.6rem 0.75rem;
}

.dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--faint);
  animation: blink 1.3s infinite ease-in-out both;
}

.dots span:nth-child(2) { animation-delay: 0.18s; }
.dots span:nth-child(3) { animation-delay: 0.36s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.25; }
  40% { opacity: 1; }
}

/* -------------------------------------------------- chips */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0 0.85rem;
}

.chips:empty { display: none; }

.chip {
  padding: 0.32rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}

.chip:hover { border-color: var(--accent); color: var(--accent); }

/* -------------------------------------------------- composer */

.composer {
  display: flex;
  gap: 0.4rem;
  padding: 0.7rem 0.85rem 0.85rem;
}

.composer input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
}

.composer input:focus {
  outline: 2px solid color-mix(in oklab, var(--accent) 40%, transparent);
  border-color: var(--accent);
}

.composer button {
  flex: none;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}

.composer button:disabled { opacity: 0.45; cursor: default; }

.notice {
  margin: 0;
  padding: 0.9rem;
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
}

/* On a phone the panel is the whole screen. A 380px floating card on a 360px
 * viewport is a worse experience than no widget at all. */
@media (max-width: 420px) {
  .panel { border: 0; border-radius: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .dots span { animation: none; opacity: 0.6; }
}
