/* Trevor chat widget styles. Scoped under .trevor-* to avoid clashing with Starlight. */
.trevor-root {
  --trevor-accent: #c0392b; /* TVR-ish red */
  --trevor-bg: #ffffff;
  --trevor-fg: #1c1c1e;
  --trevor-muted: #6b7280;
  --trevor-user: #c0392b;
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 9999;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  .trevor-root { --trevor-bg: #1f2023; --trevor-fg: #f3f4f6; --trevor-muted: #9ca3af; }
}
/* Keep borders/padding inside declared widths so nothing spills past the panel. */
.trevor-root, .trevor-root *, .trevor-root *::before, .trevor-root *::after { box-sizing: border-box; }
.trevor-root { max-width: 100vw; }

.trevor-launcher {
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--trevor-accent); color: #fff;
  border: none; border-radius: 999px;
  padding: 0.7rem 1.1rem; font-size: 0.95rem; font-weight: 600;
  cursor: pointer; box-shadow: 0 6px 20px rgba(0,0,0,0.25);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.trevor-launcher:hover { transform: translateY(-1px); box-shadow: 0 8px 26px rgba(0,0,0,0.3); }
.trevor-spanner { font-size: 1.1rem; }

.trevor-panel {
  position: absolute; right: 0; bottom: 3.6rem;
  width: min(380px, calc(100vw - 2.5rem));
  height: min(560px, calc(100vh - 6rem));
  display: flex; flex-direction: column;
  background: var(--trevor-bg); color: var(--trevor-fg);
  border-radius: 16px; overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,0.35);
  border: 1px solid rgba(0,0,0,0.08);
}
.trevor-panel[hidden] { display: none; }

.trevor-header {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--trevor-accent); color: #fff;
  padding: 0.7rem 1rem;
}
.trevor-title { font-weight: 700; font-size: 1.05rem; }
.trevor-close {
  background: transparent; border: none; color: #fff;
  font-size: 1.5rem; line-height: 1; cursor: pointer; padding: 0 0.25rem;
}

.trevor-messages {
  flex: 1; overflow-y: auto; padding: 1rem;
  display: flex; flex-direction: column; gap: 0.75rem;
}
.trevor-msg { display: flex; }
.trevor-user { justify-content: flex-end; }
.trevor-bubble {
  max-width: 85%; padding: 0.6rem 0.85rem; border-radius: 14px;
  font-size: 0.92rem; line-height: 1.45; word-wrap: break-word;
}
.trevor-assistant .trevor-bubble {
  background: rgba(127,127,127,0.12); border-bottom-left-radius: 4px;
}
.trevor-user .trevor-bubble {
  background: var(--trevor-user); color: #fff; border-bottom-right-radius: 4px;
}
.trevor-bubble p { margin: 0 0 0.5rem; }
.trevor-bubble p:last-child { margin-bottom: 0; }
.trevor-bubble a { color: inherit; text-decoration: underline; }
.trevor-bubble ul { margin: 0.25rem 0; padding-left: 1.1rem; }
.trevor-bubble code {
  background: rgba(127,127,127,0.2); padding: 0.05rem 0.3rem;
  border-radius: 4px; font-size: 0.85em;
}

.trevor-input-row {
  display: flex; gap: 0.5rem; padding: 0.75rem;
  border-top: 1px solid rgba(127,127,127,0.2);
}
.trevor-input {
  flex: 1; resize: none; max-height: 120px;
  border: 1px solid rgba(127,127,127,0.35); border-radius: 10px;
  padding: 0.55rem 0.7rem; font: inherit; font-size: 0.92rem;
  background: var(--trevor-bg); color: var(--trevor-fg);
}
.trevor-input:focus { outline: 2px solid var(--trevor-accent); outline-offset: -1px; }
.trevor-send {
  background: var(--trevor-accent); color: #fff; border: none;
  border-radius: 10px; padding: 0 1rem; font-weight: 600; cursor: pointer;
}
.trevor-send:disabled { opacity: 0.5; cursor: default; }

.trevor-disclaimer {
  padding: 0.4rem 0.75rem 0.55rem; font-size: 0.68rem; line-height: 1.35;
  color: var(--trevor-muted); text-align: center; border-top: 1px solid rgba(127,127,127,0.15);
}

/* typing dots */
.trevor-dots { display: inline-flex; gap: 4px; }
.trevor-dots i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--trevor-muted); display: inline-block;
  animation: trevor-blink 1.2s infinite both;
}
.trevor-dots i:nth-child(2) { animation-delay: 0.2s; }
.trevor-dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes trevor-blink { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }

/* Mobile: pin the panel to the viewport with explicit left+right so it locks to
   the screen width and can never overflow (which let the page scroll sideways).
   Uses fixed positioning + dvh so it behaves with the mobile browser chrome. */
@media (max-width: 480px) {
  .trevor-root { right: 0.6rem; bottom: 0.6rem; left: auto; }
  .trevor-panel {
    position: fixed;
    left: 0.5rem;
    right: 0.5rem;
    bottom: 0.5rem;
    width: auto;
    height: 80vh;
    height: 80dvh;
    max-height: 600px;
  }
  /* Hide the launcher while the panel is open so it doesn't peek out behind it. */
  .trevor-panel:not([hidden]) + .trevor-launcher { display: none; }
}

/* Auth box (sign-in / register) shown when not logged in */
.trevor-auth {
  display: flex; flex-direction: column; gap: 0.5rem;
  padding: 0.85rem; border-top: 1px solid rgba(127,127,127,0.2);
}
.trevor-auth-intro { margin: 0 0 0.1rem; font-size: 0.88rem; color: var(--trevor-muted); }
.trevor-input {
  padding: 0.5rem 0.7rem;
  border: 1px solid rgba(127,127,127,0.35); border-radius: 8px;
  background: var(--trevor-bg); color: var(--trevor-fg); font: inherit; font-size: 0.92rem;
}
.trevor-auth-submit { align-self: flex-start; padding: 0.45rem 1rem; }
.trevor-auth-link {
  color: var(--trevor-accent); font-size: 0.82rem; text-decoration: none;
}
.trevor-auth-link:hover { text-decoration: underline; }
.trevor-auth-err { color: var(--trevor-accent); font-size: 0.82rem; min-height: 1em; }
.trevor-header-status {
  margin-left: auto; font-size: 0.78rem; opacity: 0.85; padding-right: 0.5rem;
}
.trevor-signout {
  color: var(--trevor-accent); text-decoration: underline; cursor: pointer;
  font-size: 0.78rem; margin-left: 0.25rem;
}
.trevor-img { max-width: 100%; height: auto; border-radius: 8px; margin-top: 0.5rem; display: block; }

/* Citations panel — small "📎 Sources" footer under Trevor's answer. */
.trevor-cites {
  margin-top: 0.55rem; padding: 0.45rem 0.6rem;
  background: rgba(127,127,127,0.10); border-radius: 8px;
  font-size: 0.78rem; line-height: 1.45;
}
.trevor-cites-head {
  font-weight: 600; color: var(--trevor-muted); margin-bottom: 0.2rem;
  font-size: 0.74rem; letter-spacing: 0.02em;
}
.trevor-cites-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.trevor-cites-list a { color: inherit; text-decoration: underline; word-break: break-word; }
.trevor-cite-tag {
  display: inline-block; font-size: 0.62rem; font-weight: 700;
  background: var(--trevor-accent); color: #fff;
  padding: 0.05rem 0.35rem; border-radius: 99px;
  margin-right: 0.35rem; vertical-align: 0.08em; letter-spacing: 0.03em;
}

/* Feedback (thumbs) under each Trevor answer */
.trevor-fb {
  margin-top: 0.55rem; display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.76rem; color: var(--trevor-muted);
}
.trevor-fb-label { margin-right: 0.2rem; }
.trevor-fb-btn {
  background: transparent; border: 1px solid rgba(127,127,127,0.35);
  border-radius: 999px; padding: 0.1rem 0.5rem; cursor: pointer;
  font-size: 0.95rem; line-height: 1;
  transition: background 0.12s, border-color 0.12s;
}
.trevor-fb-btn:hover { background: rgba(127,127,127,0.15); border-color: var(--trevor-accent); }
.trevor-fb-thanks { font-style: italic; color: var(--trevor-muted); }
