@import url("/vendor/inter/inter.css");
@import url("/vendor/ibm-plex-mono/ibm-plex-mono.css");

:root {
  --white: #ffffff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --blue-200: #bfdbfe;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --green-50: #f0fdf4;
  --green-200: #bbf7d0;
  --green-600: #16a34a;
  --red-50: #fef2f2;
  --red-200: #fecaca;
  --red-500: #ef4444;
  --amber-50: #fffbeb;
  --amber-200: #fde68a;
  --amber-600: #d97706;

  --bg: var(--gray-50);
  --surface: var(--white);
  --border: var(--gray-200);
  --border-strong: var(--gray-300);
  --text: var(--gray-900);
  --text-secondary: var(--gray-600);
  --text-muted: var(--gray-400);
  --accent: var(--brand-accent, var(--blue-600));
  --accent-bg: var(--blue-50);
  --accent-border: var(--blue-100);

  --sidebar-bg: #111827;
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --sidebar-text: #f9fafb;
  --sidebar-muted: #6b7280;
  --sidebar-hover: rgba(255, 255, 255, 0.06);
  --sidebar-active: rgba(255, 255, 255, 0.1);

  --sidebar-width: 260px;
  --chat-max-width: 780px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html, body { height: 100%; }
html { background: var(--bg); }

body {
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { border: none; cursor: pointer; background: none; }
a { color: inherit; text-decoration: none; }
svg { display: block; flex-shrink: 0; }

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 999px; }
::-webkit-scrollbar-track { background: transparent; }

/* ── App shell ───────────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 8px 12px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 4px 4px 6px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  min-width: 0;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a5f, #2d5fa6);
  color: #fff;
  flex-shrink: 0;
}

.brand-mark svg { width: 15px; height: 15px; }
.brand-copy { min-width: 0; }

.brand-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--sidebar-text);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-subtitle { font-size: 11px; color: var(--sidebar-muted); margin-top: 1px; }

.sidebar-toggle {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--sidebar-muted);
  flex-shrink: 0;
  transition: background 100ms, color 100ms;
}

.sidebar-toggle svg { width: 16px; height: 16px; }
.sidebar-toggle:hover { background: var(--sidebar-hover); color: var(--sidebar-text); }

.sidebar-button {
  width: 100%;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  transition: background 100ms ease;
}

.sidebar-button:hover { background: var(--sidebar-hover); }

.sidebar-button-primary {
  background: rgba(255, 255, 255, 0.09);
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-button-primary:hover { background: rgba(255, 255, 255, 0.13); }

.button-icon {
  width: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  color: var(--sidebar-muted);
}

.sidebar-button-primary .button-icon { color: rgba(255,255,255,0.6); }

.search-field { position: relative; }

.search-field input {
  width: 100%;
  height: 36px;
  border-radius: var(--radius-sm);
  padding: 0 10px 0 34px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--sidebar-border);
  color: var(--sidebar-text);
  font-size: 13px;
  outline: none;
  transition: border-color 120ms, background 120ms;
}

.search-field input::placeholder { color: var(--sidebar-muted); }

.search-field input:focus {
  border-color: rgba(96, 165, 250, 0.5);
  background: rgba(255, 255, 255, 0.1);
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--sidebar-muted);
  width: 14px;
  height: 14px;
  pointer-events: none;
}

.sidebar-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-section-title {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
  padding: 8px 8px 4px;
}

.conversation-list { display: flex; flex-direction: column; gap: 1px; }

.conversation-item {
  width: 100%;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  text-align: left;
  color: rgba(249, 250, 251, 0.65);
  border: 1px solid transparent;
  transition: background 100ms, color 100ms;
}

.conversation-item:hover { background: var(--sidebar-hover); color: rgba(249,250,251,0.9); }

.conversation-item.active {
  background: var(--sidebar-active);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--sidebar-text);
}

.conversation-item-title {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-item-meta {
  margin-top: 2px;
  display: flex;
  gap: 6px;
  font-size: 11px;
  color: var(--sidebar-muted);
  align-items: center;
}

.conversation-item-mode { color: #60a5fa; font-weight: 600; font-size: 10.5px; }

.empty-state {
  padding: 14px 8px;
  font-size: 12.5px;
  color: var(--sidebar-muted);
  text-align: center;
}

.sidebar-footer {
  border-top: 1px solid var(--sidebar-border);
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.user-card { padding: 4px 8px 4px; }

.user-name { font-size: 13px; font-weight: 600; color: var(--sidebar-text); }

.user-email {
  font-size: 11px;
  color: var(--sidebar-muted);
  overflow-wrap: anywhere;
  margin-top: 1px;
}

.sidebar-actions { display: flex; flex-direction: column; }

.sidebar-link {
  display: flex;
  align-items: center;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--sidebar-muted);
  transition: background 100ms, color 100ms;
}

.sidebar-link:hover { background: var(--sidebar-hover); color: var(--sidebar-text); }

.sidebar-backdrop { display: none; }

/* ── Workspace ───────────────────────────────────────────── */
.workspace {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  overflow: hidden;
}

/* ── Drag & Drop ─────────────────────────────────────────── */
.workspace.drag-active {
  position: relative;
}
.workspace.drag-active::after {
  content: "Solte os arquivos para anexar";
  position: absolute;
  inset: 0;
  background: rgba(37, 99, 235, 0.06);
  border: 2px dashed var(--blue-500);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--blue-600);
}

/* ── Topbar ──────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 57px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--surface);
}

.topbar-left, .topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-copy { display: flex; align-items: center; min-width: 0; }

.mobile-menu-btn {
  display: none;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background 100ms;
}

.mobile-menu-btn:hover { background: var(--gray-100); }
.mobile-menu-btn svg { width: 18px; height: 18px; }

.topbar-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 320px;
}

.control-strip { display: flex; align-items: center; gap: 8px; }

.mode-select-wrap select {
  height: 34px;
  border-radius: var(--radius-md);
  padding: 0 32px 0 11px;
  background: var(--gray-100);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: calc(100% - 9px) center;
  cursor: pointer;
  transition: border-color 120ms;
}

.mode-select-wrap select:focus { border-color: var(--blue-500); outline: none; }
.mode-select-wrap select:hover { background: var(--gray-200); }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 11px;
  border-radius: var(--radius-md);
  background: var(--gray-100);
  border: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.status-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green-600);
  flex-shrink: 0;
}

.status-pill[data-tone="warn"] { color: #92400e; background: var(--amber-50); border-color: var(--amber-200); }
.status-pill[data-tone="warn"]::before { background: var(--amber-600); }
.status-pill[data-tone="error"] { color: #991b1b; background: var(--red-50); border-color: var(--red-200); }
.status-pill[data-tone="error"]::before { background: var(--red-500); }

/* ── Welcome panel ───────────────────────────────────────── */
.welcome-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  overflow-y: auto;
}

.welcome-panel-inner {
  width: min(660px, 100%);
  text-align: center;
}

.welcome-eyebrow {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--gray-100);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
}

.welcome-panel h1 {
  margin: 18px 0 10px;
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.05;
}

.welcome-copy {
  color: var(--text-muted);
  font-size: 14.5px;
  line-height: 1.7;
  max-width: 460px;
  margin: 0 auto;
}


/* ── Message list ────────────────────────────────────────── */
.message-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 16px;
}

.message-row { width: 100%; }

.message {
  width: min(var(--chat-max-width), 100%);
  margin: 0 auto;
  padding: 12px 24px;
}

.message.assistant {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

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

.message-avatar {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  font-weight: 700;
  background: linear-gradient(135deg, #1e3a5f, #2d5fa6);
  color: #fff;
  flex-shrink: 0;
  margin-top: 2px;
}

.message.user .message-avatar { display: none; }

.message-body { min-width: 0; }

.message.user .message-body {
  max-width: min(72%, 600px);
  padding: 11px 15px;
  border-radius: 16px;
  background: var(--gray-100);
  border: 1px solid var(--border);
}

.message-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.message.user .message-head { margin-bottom: 3px; }

.message-role { font-size: 13px; font-weight: 600; }
.message-meta { font-size: 11px; color: var(--text-muted); }

.message-content { font-size: 15px; line-height: 1.75; }
.user-text-segment { white-space: pre-wrap; }

.message-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 8px;
}

.message-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 8px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 100ms, border-color 100ms, color 100ms;
}

.message-action-btn svg { width: 12px; height: 12px; }

.message-action-btn:hover {
  background: var(--gray-100);
  border-color: var(--border);
  color: var(--text-secondary);
}

.message-action-btn.active {
  color: var(--blue-600);
  background: var(--blue-50);
  border-color: var(--blue-200);
}

.message-action-btn.copied {
  color: var(--green-600);
  background: var(--green-50);
  border-color: var(--green-200);
}

/* ── Attachment list ─────────────────────────────────────── */
.attachment-list { display: flex; flex-wrap: wrap; gap: 6px; }

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--gray-100);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.attachment-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.attachment-size { font-size: 10px; color: var(--text-muted); font-weight: 400; flex-shrink: 0; max-width: none; }
.attachment-chip button { color: var(--text-muted); font-size: 14px; line-height: 1; transition: color 100ms; }
.attachment-chip button:hover { color: var(--red-500); }

/* chip com preview de imagem no composer */
.attachment-chip.has-image-preview { height: auto; border-radius: 10px; padding: 6px 10px; flex-direction: column; align-items: flex-start; }
.attach-preview-img { max-width: 180px; max-height: 120px; border-radius: 6px; object-fit: cover; display: block; }
.attach-preview-audio { max-width: 240px; height: 32px; display: block; }

/* previews de anexo no histórico de mensagens */
.msg-attach-preview { margin-bottom: 6px; }
.msg-preview-img { max-width: 320px; max-height: 240px; border-radius: 8px; object-fit: contain; display: block; border: 1px solid var(--border); }
.msg-preview-audio { max-width: 320px; height: 36px; display: block; }
.msg-preview-label { display: block; font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.msg-attach-file { font-size: 13px; color: var(--text-secondary); padding: 4px 0; }

/* ── Composer dock ───────────────────────────────────────── */
.composer-dock {
  padding: 8px 20px 18px;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
}

.composer-dock-inner {
  width: min(var(--chat-max-width), 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.composer-shell {
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-strong);
  background: var(--white);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: border-color 150ms, box-shadow 150ms;
  overflow: hidden;
}

.composer-shell:focus-within {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1), 0 2px 8px rgba(0, 0, 0, 0.06);
}

.composer-shell textarea {
  width: 100%;
  min-height: 50px;
  max-height: 220px;
  resize: none;
  border: none;
  padding: 13px 18px;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  outline: none;
}

.composer-shell textarea::placeholder { color: var(--text-muted); }

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px 8px;
  border-top: 1px solid var(--gray-100);
}

.composer-tools { display: flex; align-items: center; gap: 2px; }

.tool-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 100ms, border-color 100ms, color 100ms;
}

.tool-button svg { width: 14px; height: 14px; }
.tool-button:hover { background: var(--gray-100); border-color: var(--border); }

.tool-button.active {
  color: var(--blue-600);
  background: var(--blue-50);
  border-color: var(--blue-200);
}

#mic-btn.is-recording { color: var(--red-500); background: var(--red-50); border-color: var(--red-200); }

.composer-submit { display: flex; align-items: center; gap: 10px; }

.composer-hint { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; }

.send-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  background: var(--gray-900);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms, transform 120ms;
}

.send-button svg { width: 14px; height: 14px; }
.send-button:hover { background: var(--gray-700); transform: translateY(-1px); }
.send-button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── Markdown content ────────────────────────────────────── */
.message-content h1, .message-content h2,
.message-content h3, .message-content h4 {
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 1.1em 0 0.4em;
  line-height: 1.3;
}

.message-content h1 { font-size: 1.45em; }
.message-content h2 { font-size: 1.25em; }
.message-content h3 { font-size: 1.1em; }
.message-content h4 { font-size: 1em; font-weight: 600; }

.message-content p { margin: 0.5em 0; }
.message-content p:first-child { margin-top: 0; }
.message-content p:last-child { margin-bottom: 0; }

.message-content ul, .message-content ol {
  padding-left: 1.4em;
  margin: 0.4em 0;
  display: grid;
  gap: 2px;
}

.message-content li { line-height: 1.7; }

.message-content code {
  font-family: "IBM Plex Mono", "Menlo", "Consolas", monospace;
  font-size: 0.845em;
  padding: 2px 5px;
  border-radius: 5px;
  background: var(--gray-100);
  border: 1px solid var(--border);
  color: #1d4ed8;
}

.code-block-wrapper {
  margin: 0.75em 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #1e1e2e;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.code-lang {
  font-size: 11px;
  color: var(--gray-400);
  font-family: "IBM Plex Mono", monospace;
  text-transform: uppercase;
}

.code-copy-btn {
  font-size: 11px;
  color: var(--gray-400);
  background: transparent;
  transition: color 150ms;
}

.code-copy-btn:hover {
  color: var(--white);
}

/* ── Tabelas no Markdown ─────────────────────────────────── */
.message-content .table-wrap {
  overflow-x: auto;
  margin: 1em 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
}
.message-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  text-align: left;
}
.message-content th, .message-content td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.message-content th {
  background: var(--gray-50);
  font-weight: 600;
  color: var(--text-secondary);
}
.message-content tr:last-child td { border-bottom: none; }
.message-content tr:hover td { background: var(--gray-50); }

.message-content pre {
  margin: 0;
  border-radius: 0;
  border: none;
  background: transparent;
}

.message-content pre code {
  display: block;
  padding: 15px 18px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.65;
  color: #cdd6f4;
  background: none;
  border: none;
}

.message-content blockquote {
  margin: 0.6em 0;
  padding: 10px 14px;
  border-left: 3px solid var(--blue-500);
  background: var(--blue-50);
  border-radius: 0 8px 8px 0;
  color: var(--text-secondary);
}

.message-content hr { border: none; border-top: 1px solid var(--border); margin: 0.9em 0; }
.message-content strong { font-weight: 700; }
.message-content em { font-style: italic; }
.message-content a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

/* ── Streaming cursor ────────────────────────────────────── */
@keyframes cursor-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.message-content.is-streaming::after {
  content: "▋";
  display: inline-block;
  animation: cursor-blink 0.8s ease infinite;
  color: var(--blue-500);
  font-size: 0.82em;
  margin-left: 1px;
  vertical-align: text-bottom;
}

/* ── Attachment source details ───────────────────────────── */
.source-details {
  margin-top: 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

.source-details summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--gray-100);
  user-select: none;
  transition: background 100ms, color 100ms;
}

.source-details summary::-webkit-details-marker { display: none; }

.source-details summary::before {
  content: "▶";
  font-size: 9px;
  transition: transform 150ms;
}

.source-details[open] summary::before { transform: rotate(90deg); }

.source-details summary:hover { background: var(--gray-200); color: var(--text-secondary); }

.source-details pre {
  margin: 0;
  padding: 10px 12px;
  font-size: 11.5px;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--gray-50);
  color: var(--text-muted);
  font-family: "IBM Plex Mono", monospace;
  border-top: 1px solid var(--border);
}

/* ── Message Sources & Queries ───────────────────────────── */
.message-sources-details {
  margin-top: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

.message-sources-details summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--gray-100);
  user-select: none;
  transition: background 100ms, color 100ms;
}

.message-sources-details summary::-webkit-details-marker { display: none; }

.message-sources-details summary::before {
  content: "▶";
  font-size: 9px;
  transition: transform 150ms;
}

.message-sources-details[open] summary::before { transform: rotate(90deg); }

.message-sources-details summary:hover { background: var(--gray-200); color: var(--text); }

.message-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px;
}
.source-search-query {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--gray-100);
  border-radius: 999px;
  border: 1px solid var(--border);
}
.source-link {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--blue-600);
  background: var(--blue-50);
  border-radius: 999px;
  border: 1px solid var(--blue-200);
  text-decoration: none !important;
  transition: background 150ms;
}
.source-link:hover {
  background: var(--blue-100);
}

/* ── Workspace states ────────────────────────────────────── */
.workspace.has-messages .welcome-panel { display: none; }
.workspace.is-empty .message-list { display: none; }

/* ── Auth gate ───────────────────────────────────────────── */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-50);
}

.auth-gate-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding: 44px 40px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  text-align: center;
  min-width: 320px;
}

.auth-gate-brand { display: flex; align-items: center; gap: 12px; }

.auth-gate-brand .brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 9px;
}

.auth-gate-brand .brand-mark svg { width: 18px; height: 18px; }

.auth-gate-brand .brand-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.auth-gate-brand .brand-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

.auth-gate-message { font-size: 14px; color: var(--text-secondary); font-weight: 500; }

.auth-gate-login-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 11px 22px;
  background: var(--gray-900);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
  transition: background 150ms;
}

.auth-gate-login-btn:hover { background: var(--gray-700); }

/* ── Artifact blocks ─────────────────────────────────────── */
.artifact-block {
  margin: 12px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.artifact-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--gray-100);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.artifact-frame {
  display: block;
  width: 100%;
  height: 320px;
  border: none;
  background: var(--white);
}

/* ── Edit inline ─────────────────────────────────────────── */
.edit-textarea {
  width: 100%;
  min-height: 80px;
  padding: 8px 10px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  box-sizing: border-box;
}

.edit-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.edit-confirm-btn {
  padding: 5px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
}

.edit-confirm-btn:hover { background: var(--blue-500); }

.edit-cancel-btn {
  padding: 5px 14px;
  border-radius: var(--radius-sm);
  background: var(--gray-200);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  border: none;
}

.edit-cancel-btn:hover { background: var(--gray-300); }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 980px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    transform: translateX(-108%);
    transition: transform 180ms ease;
    box-shadow: 4px 0 28px rgba(0, 0, 0, 0.4);
    z-index: 10;
  }

  .sidebar.is-open { transform: translateX(0); }
  .sidebar-toggle { display: flex; }
  .mobile-menu-btn { display: inline-flex; }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 9;
    border: none;
    cursor: pointer;
  }

  .sidebar.is-open + .sidebar-backdrop { display: block; }

  .topbar { padding: 0 14px; }
  .message { padding: 10px 16px; }
  .composer-dock { padding: 8px 12px 16px; }
}

@media (max-width: 640px) {
  .topbar-title { max-width: 180px; }
  .composer-hint { display: none; }
  .message.user .message-body { max-width: 90%; }
  .status-pill { font-size: 11.5px; padding: 0 8px; }
  .mode-select-wrap select { max-width: 140px; font-size: 13px; }
  .welcome-panel { padding: 20px 16px; }
  .welcome-eyebrow { font-size: 11px; }
}

@media (max-width: 480px) {
  .topbar { padding: 0 10px; gap: 6px; }
  .topbar-title { max-width: 120px; font-size: 13px; }
  .composer-dock { padding: 6px 8px 12px; }
  .composer-dock-inner { gap: 6px; }
  .send-button { padding: 0 14px; font-size: 13px; }
  .message { padding: 8px 12px; }
  .message-avatar { width: 28px; height: 28px; font-size: 10px; }
  .artifact-frame { height: 240px; }
  .welcome-panel { padding: 16px 12px; }
  h1 { font-size: 1.3em; }
  h2 { font-size: 1.15em; }
}

.conversation-item-wrap {
  position: relative;
  display: flex;
  align-items: stretch;
}
.conversation-item-wrap .conversation-item {
  flex: 1;
  padding-right: 32px;
}
.conversation-delete-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--sidebar-muted, #888);
  padding: 4px;
  border-radius: 4px;
  line-height: 0;
}
.conversation-item-wrap:hover .conversation-delete-btn,
.conversation-item.active ~ .conversation-delete-btn,
.conversation-item-wrap:has(.conversation-item.active) .conversation-delete-btn {
  display: flex;
  align-items: center;
  justify-content: center;
}
.conversation-delete-btn:hover {
  color: #e53e3e;
  background: rgba(229, 62, 62, 0.1);
}

/* ── Archive & Archived Section ───────────────────────────── */
.conversation-archive-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--sidebar-muted, #888);
  padding: 4px;
  border-radius: 4px;
  line-height: 0;
}
.conversation-item-wrap:hover .conversation-archive-btn,
.conversation-item.active ~ .conversation-archive-btn,
.conversation-item-wrap:has(.conversation-item.active) .conversation-archive-btn {
  display: flex;
  align-items: center;
  justify-content: center;
}
.conversation-archive-btn:hover {
  color: var(--yellow-500, #d97706);
  background: rgba(217, 119, 6, 0.1);
}

.conversation-unarchive-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--sidebar-muted, #888);
  padding: 4px;
  border-radius: 4px;
  line-height: 0;
}
.conversation-unarchive-btn:hover {
  color: var(--green-500, #16a34a);
  background: rgba(22, 163, 74, 0.1);
}

.conversation-item-wrap.is-archived .conversation-item {
  opacity: 0.65;
}

.toggle-archived-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  font-size: 0.8em;
  padding: 0 4px;
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.15s;
}
.toggle-archived-btn:hover {
  opacity: 1;
}

#archived-section .sidebar-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#archived-section {
  flex: 0 0 auto;
}

#archived-conversation-list {
  max-height: 220px;
  overflow-y: auto;
}


/* ═══════════════════════════════════════════════════════════════════════════
   Fact-Check Audit Result (V8.2)
   ═══════════════════════════════════════════════════════════════════════════ */

.audit-result {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  font-size: 13px;
}

.audit-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--border);
}

.audit-result-verdict {
  font-weight: 600;
  font-size: 13px;
}

.audit-result-meta {
  font-size: 11px;
  color: var(--text-muted);
  font-family: "IBM Plex Mono", monospace;
}

.audit-result-justification {
  padding: 8px 12px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
  border-bottom: 1px solid var(--border);
  background: var(--gray-50);
}

.audit-claims {
  padding: 0;
}

.audit-claim {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.audit-claim:last-child {
  border-bottom: none;
}

.audit-claim-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.audit-claim-verdict {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.audit-claim-text {
  color: var(--text);
  line-height: 1.4;
}

.audit-claim-justification {
  margin-top: 4px;
  padding-left: 0;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
}

.audit-claim-sources {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.audit-source-link {
  font-size: 11px;
  color: var(--accent);
  text-decoration: none;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--accent-bg);
}

.audit-source-link:hover {
  text-decoration: underline;
}

.audit-corrected {
  border-top: 2px solid var(--green-200);
  background: var(--green-50);
  padding: 10px 12px;
}

.audit-corrected-label {
  font-weight: 600;
  font-size: 12px;
  color: var(--green-600);
  margin-bottom: 4px;
}

.audit-corrected-text {
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}

.audit-error {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--red-50);
  border: 1px solid var(--red-200);
  border-radius: var(--radius-sm);
  color: var(--red-500);
  font-size: 12px;
}

/* Verdict colors */
.verdict-accurate {
  border-left: 3px solid var(--green-600);
}
.verdict-accurate .audit-claim-verdict {
  background: var(--green-50);
  color: var(--green-600);
}

.verdict-inaccurate {
  border-left: 3px solid var(--red-500);
}
.verdict-inaccurate .audit-claim-verdict {
  background: var(--red-50);
  color: var(--red-500);
}

.verdict-disputed {
  border-left: 3px solid var(--amber-600);
}
.verdict-disputed .audit-claim-verdict {
  background: var(--amber-50);
  color: var(--amber-600);
}

.verdict-unsupported {
  border-left: 3px solid var(--gray-400);
}
.verdict-unsupported .audit-claim-verdict {
  background: var(--gray-100);
  color: var(--gray-600);
}

.verdict-na {
  border-left: 3px solid var(--border-strong);
}

.verdict-mixed {
  border-left: 3px solid var(--blue-500);
}
.verdict-mixed .audit-claim-verdict {
  background: var(--blue-50);
  color: var(--blue-600);
}

/* Verify button state */
.message-action-btn.verifying {
  opacity: 0.65;
  cursor: wait;
}

.message-action-btn[disabled] {
  opacity: 0.5;
  pointer-events: none;
}