/* ============================================================================
   Hunter ChatGPT — full-screen app layout
   ============================================================================ */

body.chat-app-body {
  /* Override library defaults — full-screen app, no scrolling outer page */
  display: block;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}
body.chat-app-body::before { display: none; } /* drop the radial gradient bg */
/* Hide library widgets if they ever leak in (no Base.astro means they shouldn't, but defensive) */
body.chat-app-body #chat-launcher, body.chat-app-body #chat-panel { display: none !important; }

.chat-app {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100dvh;
  background: var(--bg);
}

/* ──── Sidebar ──── */
.chat-sidebar {
  background: rgba(13, 13, 16, 0.9);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.chat-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.chat-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--fg);
  text-decoration: none;
  flex: 1;
  min-width: 0;
}
.chat-sidebar-brand:hover { text-decoration: none; }
.chat-sidebar-brand img {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover;
  border: 1px solid var(--border-strong);
  flex: 0 0 auto;
}
.chat-sidebar-name { font-weight: 600; font-size: 14px; }
.chat-sidebar-tag { font-size: 11px; color: var(--muted-2); margin-top: 1px; }
.chat-sidebar-toggle {
  background: transparent; border: none; color: var(--muted);
  width: 32px; height: 32px; border-radius: 6px; cursor: pointer;
  display: none; align-items: center; justify-content: center;
}
.chat-sidebar-toggle:hover { background: rgba(255,255,255,0.06); color: var(--fg); }

.chat-new-thread {
  margin: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(34, 211, 238, 0.08);
  border: 1px solid rgba(34, 211, 238, 0.25);
  color: var(--cyan);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.chat-new-thread:hover {
  background: rgba(34, 211, 238, 0.15);
  border-color: var(--cyan);
  color: var(--fg);
}

.chat-threads {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 8px;
}
.chat-threads-empty {
  color: var(--muted-2);
  font-size: 12px;
  text-align: center;
  padding: 24px 12px;
}
.chat-thread-item {
  width: 100%;
  position: relative;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 10px 32px 10px 12px;
  border-radius: var(--radius);
  margin-bottom: 2px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s;
}
.chat-thread-item:hover { background: rgba(255, 255, 255, 0.04); color: var(--fg-soft); }
.chat-thread-item.active {
  background: rgba(34, 211, 238, 0.08);
  color: var(--fg);
}
.chat-thread-title {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}
.chat-thread-meta {
  font-size: 11px;
  color: var(--muted-2);
}
.chat-thread-delete {
  position: absolute;
  top: 50%; right: 8px;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--muted-2);
  width: 22px; height: 22px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s, background 0.12s, color 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-thread-item:hover .chat-thread-delete { opacity: 1; }
.chat-thread-delete:hover { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

.chat-sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-account-slot { margin-bottom: 4px; }
.chat-signin-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.12), rgba(139, 92, 246, 0.1));
  border: 1px solid rgba(34, 211, 238, 0.3);
  color: var(--cyan);
  padding: 9px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.15s;
}
.chat-signin-btn:hover {
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.2), rgba(139, 92, 246, 0.15));
  border-color: var(--cyan);
  color: var(--fg);
}
.chat-account {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(34, 211, 238, 0.05);
  border: 1px solid rgba(34, 211, 238, 0.15);
  padding: 8px 10px 8px 12px;
  border-radius: var(--radius);
}
.chat-account-email {
  font-size: 12px;
  color: var(--fg-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.chat-account-signout {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-family: inherit;
}
.chat-account-signout:hover { color: var(--cyan); background: rgba(34,211,238,0.08); }
.chat-sidebar-link {
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
}
.chat-sidebar-link:hover { color: var(--cyan); }
.chat-sidebar-link-cta { color: var(--cyan); font-weight: 500; }

/* ──── Main ──── */
.chat-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--bg);
}
.chat-main-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 10, 11, 0.7);
  backdrop-filter: blur(10px);
}
.chat-mobile-toggle {
  background: transparent;
  border: none;
  color: var(--muted);
  width: 36px; height: 36px;
  border-radius: 6px;
  display: none;
  cursor: pointer;
}
.chat-mobile-toggle:hover { background: rgba(255,255,255,0.06); color: var(--fg); }
.chat-main-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-soft);
  letter-spacing: -0.005em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-disclaimer-banner {
  padding: 12px 28px;
  background: rgba(251, 191, 36, 0.06);
  border-bottom: 1px solid rgba(251, 191, 36, 0.15);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.chat-disclaimer-banner strong { color: var(--amber); }

.chat-migration-banner {
  padding: 12px 28px;
  background: rgba(34, 211, 238, 0.06);
  border-bottom: 1px solid rgba(34, 211, 238, 0.18);
  color: var(--fg-soft);
  font-size: 13px;
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.chat-migration-banner strong { color: var(--cyan); }
.chat-migration-banner .migration-actions { display: flex; gap: 8px; }
.chat-migration-banner button {
  background: var(--cyan);
  color: #000;
  border: none;
  padding: 6px 14px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.chat-migration-banner button + button {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--muted);
}

/* Sign-in modal */
.chat-signin-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(6px);
}
.chat-signin-card {
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 36px 32px 28px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  position: relative;
  box-shadow: 0 32px 80px -16px rgba(0,0,0,0.6);
}
.chat-signin-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 6px;
}
.chat-signin-close:hover { background: rgba(255,255,255,0.05); color: var(--fg); }
.chat-signin-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 14px;
  border: 1px solid var(--border-strong);
}
.chat-signin-card h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 10px;
  color: var(--fg);
  letter-spacing: -0.01em;
}
.chat-signin-card p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  margin: 0 0 24px;
}
.chat-signin-card form {
  display: flex;
  gap: 8px;
}
.chat-signin-card input {
  flex: 1;
  background: rgba(24,24,27,0.7);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-family: inherit;
  font-size: 14px;
  color: var(--fg);
}
.chat-signin-card input:focus { outline: none; border-color: var(--cyan-strong); }
.chat-signin-card button[type="submit"] {
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  color: #000;
  border: none;
  padding: 0 18px;
  border-radius: var(--radius);
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.chat-signin-card button[type="submit"]:hover { opacity: 0.95; }
.chat-signin-card button[type="submit"]:disabled { opacity: 0.5; cursor: not-allowed; }
.chat-signin-status {
  margin-top: 16px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}
.chat-signin-status--ok { color: var(--cyan); }
.chat-signin-status--ok strong { color: var(--fg); }
.chat-signin-status--ok em { color: var(--cyan); font-style: normal; font-weight: 600; }
.chat-signin-status--err { color: #ef4444; }

@media (max-width: 600px) {
  .chat-migration-banner { padding: 10px 16px; font-size: 12px; }
}

.chat-conversation {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0 24px;
  scroll-behavior: smooth;
}

/* ──── Empty state ──── */
.chat-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
  text-align: center;
  max-width: 760px;
  margin: 0 auto;
}
.chat-empty-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 18px;
  border: 2px solid var(--border-strong);
}
.chat-empty-state h1 {
  font-size: 28px;
  font-weight: 600;
  margin: 0 0 12px;
  letter-spacing: -0.02em;
  color: var(--fg);
}
.chat-empty-state p {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
  max-width: 540px;
  margin: 0 0 32px;
}
.chat-suggestion-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  width: 100%;
}
.chat-suggestion-card {
  text-align: left;
  background: var(--card-soft);
  border: 1px solid var(--border);
  color: var(--fg-soft);
  padding: 14px 16px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
  transition: all 0.15s;
  backdrop-filter: blur(8px);
}
.chat-suggestion-card:hover {
  background: rgba(34, 211, 238, 0.06);
  border-color: rgba(34, 211, 238, 0.4);
  color: var(--fg);
  transform: translateY(-1px);
}
.chat-suggestion-eyebrow {
  font-size: 10px;
  color: var(--cyan);
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: 6px;
}

/* ──── Conversation messages ──── */
.chat-msg-row {
  max-width: 780px;
  margin: 0 auto 28px;
  padding: 0 32px;
}
.chat-msg-row--user {
  display: flex;
  justify-content: flex-end;
}
.chat-msg-row--assistant {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.chat-msg-avatar {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  margin-top: 2px;
  border: 1px solid var(--border-strong);
}
.chat-msg-content {
  flex: 1;
  min-width: 0;
}
.chat-msg-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--cyan);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}
.chat-msg-bubble {
  font-size: 15px;
  line-height: 1.65;
}
.chat-msg-bubble--user {
  background: rgba(34, 211, 238, 0.1);
  border: 1px solid rgba(34, 211, 238, 0.22);
  color: var(--fg);
  padding: 12px 18px;
  border-radius: 18px 18px 4px 18px;
  max-width: 75%;
  white-space: pre-wrap;
}
.chat-msg-bubble--assistant {
  color: var(--fg-soft);
}
.chat-msg-bubble--assistant p { margin: 0 0 12px; }
.chat-msg-bubble--assistant p:last-child { margin-bottom: 0; }
.chat-msg-bubble--assistant strong { color: var(--fg); font-weight: 600; }
.chat-msg-bubble--assistant em { color: inherit; }
.chat-msg-bubble--assistant a {
  color: var(--cyan);
  text-decoration: underline;
  text-decoration-color: rgba(34, 211, 238, 0.4);
}
.chat-msg-bubble--assistant a:hover { text-decoration-color: var(--cyan); }
.chat-msg-bubble--assistant sup.chat-cite-ref {
  display: inline-block;
  background: rgba(34, 211, 238, 0.15);
  color: var(--cyan);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  margin: 0 1px;
  vertical-align: super;
  line-height: 1;
}
.chat-msg-bubble--assistant .chat-msg-disclaimer,
.chat-msg-bubble--assistant blockquote.chat-msg-disclaimer {
  font-size: 12px;
  color: var(--muted-2);
  line-height: 1.5;
  padding: 10px 14px;
  background: rgba(251, 191, 36, 0.06);
  border-left: 2px solid rgba(251, 191, 36, 0.4);
  border-radius: 4px;
  margin: 16px 0 0;
}
.chat-typing {
  display: inline-block;
  color: var(--muted-2);
  letter-spacing: 4px;
  animation: chat-typing-pulse 1.4s ease-in-out infinite;
}
@keyframes chat-typing-pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* Citations under assistant message */
.chat-msg-content .chat-cites {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chat-msg-content .chat-cite {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  transition: all 0.12s;
}
.chat-msg-content .chat-cite:hover {
  background: rgba(34, 211, 238, 0.06);
  border-color: rgba(34, 211, 238, 0.4);
  color: var(--fg);
  text-decoration: none;
}
.chat-msg-content .chat-cite-num {
  flex: 0 0 auto;
  background: rgba(34, 211, 238, 0.15);
  color: var(--cyan);
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; font-weight: 600; font-size: 11px;
}
.chat-msg-content .chat-cite-title {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-msg-content .chat-cite-time {
  flex: 0 0 auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
}

/* ──── Composer ──── */
.chat-composer {
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 32px 8px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.chat-composer textarea {
  flex: 1;
  resize: none;
  background: rgba(24, 24, 27, 0.7);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 14px 16px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.45;
  max-height: 220px;
  min-height: 48px;
}
.chat-composer textarea::placeholder { color: var(--muted-2); }
.chat-composer textarea:focus {
  outline: none;
  border-color: var(--cyan-strong);
  background: rgba(24, 24, 27, 0.95);
}
.chat-composer button {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  color: #000;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.12s, opacity 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-composer button:hover:not(:disabled) { transform: scale(1.05); }
.chat-composer button:disabled { opacity: 0.35; cursor: not-allowed; }

.chat-foot-disclaimer {
  text-align: center;
  font-size: 11px;
  color: var(--muted-2);
  padding: 4px 32px 14px;
  max-width: 780px;
  margin: 0 auto;
}

/* ──── Mobile ──── */
@media (max-width: 800px) {
  .chat-app { grid-template-columns: 1fr; }
  .chat-sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 280px;
    height: 100dvh;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s;
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
  }
  .chat-sidebar--open { transform: translateX(0); }
  .chat-sidebar-toggle { display: flex; }
  .chat-mobile-toggle { display: flex; }
  body.chat-sidebar-overlay::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 49;
    pointer-events: none;
  }
  .chat-msg-row { padding: 0 16px; }
  .chat-composer { padding: 12px 16px 4px; }
  .chat-foot-disclaimer { padding: 4px 16px 10px; }
  .chat-disclaimer-banner { padding: 10px 16px; }
  .chat-main-head { padding: 12px 16px; }
}
