@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,600;0,8..60,700;1,8..60,400&family=EB+Garamond:ital,wght@0,400;0,500;0,600;1,400;1,500&family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,500;0,9..144,600;0,9..144,700;0,9..144,800;1,9..144,400;1,9..144,500&family=JetBrains+Mono:wght@400;500;600&family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,500;0,6..72,600;1,6..72,400&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg-cream: #f4f5f7;
  --bg-white: #ffffff;
  --text-primary: #111318;
  --text-secondary: #5c5f66;
  --text-tertiary: #8b8e96;
  --border-light: #e2e4e9;
  --accent-coral: #c08b5c;
  --accent-coral-dark: #a87644;
  --user-bubble: #111318;
  --shadow-soft: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-input: 0 4px 16px rgba(0, 0, 0, 0.08);
  /* Dark sidebar tokens */
  --sidebar-bg: #16181f;
  --sidebar-surface: #1e2028;
  --sidebar-border: rgba(255, 255, 255, 0.07);
  --sidebar-text: #c8cad0;
  --sidebar-text-muted: #6b6e78;
  --sidebar-hover: rgba(255, 255, 255, 0.05);
  --sidebar-active: rgba(192, 139, 92, 0.15);

  /* DeepInsights brand gradient — indigo → periwinkle → teal.
   * Lifted from the logo lockup (mark + wordmark colours). Used on
   * page-title text and the accent rule under the page header so every
   * top-level surface (Artifacts / Settings / Dashboard / Inbox) shares
   * the same brand pulse. */
  --brand-indigo: #2A3899;
  --brand-periwinkle: #7DB0E0;
  --brand-teal: #1D9A94;
  --brand-gradient: linear-gradient(110deg, var(--brand-indigo) 0%, #5E8FCC 32%, var(--brand-periwinkle) 58%, #4FB6B0 80%, var(--brand-teal) 100%);
  --brand-gradient-rule: linear-gradient(90deg, var(--brand-indigo) 0%, var(--brand-periwinkle) 55%, var(--brand-teal) 100%);
}

/* ══════════════════════════════════════════════════════════════════════
 * UNIFIED PAGE HEADER  (Artifacts / Settings / Dashboard / Inbox)
 *
 * Same typographic treatment, same vertical rhythm, same brand-gradient
 * pulse on every top-level page. Done as a shared selector list against
 * the existing per-page classes so no markup change is needed.
 * ════════════════════════════════════════════════════════════════════ */
.artifacts-page-header,
.settings-header,
.dash-header,
.inbox-header,
.telemetry-header,
.dh-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 4px 0 28px;
  padding: 0 0 20px;
  border-bottom: 1px solid var(--border-light);
  position: relative;
  flex-wrap: wrap;
}
.artifacts-page-header::after,
.settings-header::after,
.dash-header::after,
.inbox-header::after,
.telemetry-header::after,
.dh-header::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -1.5px;
  width: 110px;
  height: 3px;
  background: var(--brand-gradient-rule);
  border-radius: 2px;
}

.artifacts-page-title,
.settings-title,
.dash-title,
.inbox-title,
.telemetry-title,
.dh-header > h1 {
  font-family: 'Fraunces', 'EB Garamond', Georgia, serif;
  font-size: 40px;
  font-weight: 500;
  line-height: 1.04;
  letter-spacing: -0.022em;
  margin: 0;
  /* Gradient text — webkit fallback for Safari, modern for the rest */
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  font-variation-settings: 'opsz' 144, 'SOFT' 50;
  width: fit-content;
}
@media (max-width: 700px) {
  .artifacts-page-title,
  .settings-title,
  .dash-title,
  .inbox-title,
  .telemetry-title,
  .dh-header > h1 { font-size: 32px; }
}

/* Right-aligned header chrome (counts, refresh button, etc.) gets its
 * own consistent treatment — mono small caps, never gradient. */
.dash-header-actions,
.inbox-header-count {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.inbox-header-count { font-weight: 500; }

/* Amber selection */
::selection { background: rgba(192, 139, 92, 0.25); color: inherit; }

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

html {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-cream);
  color: var(--text-primary);
  height: 100vh;
  line-height: 1.55;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1;
  font-optical-sizing: auto;
}

.hidden {
  display: none !important;
}

/* App Container */
.app-container {
  position: relative;
  height: 100vh;
  display: flex;
  flex-direction: row;
  overflow: hidden;
}

/* ==================== LEFT SIDEBAR ==================== */
.left-sidebar {
  width: 260px;
  min-width: 260px;
  height: 100vh;
  background: var(--bg-white);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Sidebar brand header (DeepInsights logo) ── */
.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 10px;
  min-height: 52px;
}

.sidebar-brand-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  flex: 1;
  min-width: 0;
  transition: opacity 0.15s ease;
}

.sidebar-brand-link:hover {
  opacity: 0.85;
}

.sidebar-brand-logo {
  /* DeepInsights lockup at its native ~4:1 aspect. Height fixed, width
   * auto so the image never distorts. object-fit: contain is a belt-and-
   * braces guard if the max-width clips. */
  height: 34px;
  width: auto;
  max-width: 100%;
  display: block;
  object-fit: contain;
}

/* Legacy selectors kept for compatibility (hidden if still present) */
.sidebar-brand-name,
.sidebar-brand-mark {
  display: none;
}

.sidebar-toggle-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.15s;
}

.sidebar-toggle-btn:hover {
  background: var(--bg-cream);
  color: var(--text-primary);
}

/* ── Top action items (New chat, Search) ── */
.sidebar-actions {
  padding: 8px 12px 4px;
}

.sidebar-action-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.12s;
}

.sidebar-action-item:hover {
  background: var(--bg-cream);
  color: var(--text-primary);
}

.sidebar-action-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ── Navigation group (Chats, Artifacts, etc.) ── */
.sidebar-nav-group {
  padding: 10px 12px 4px;
  border-top: 1px solid var(--border-light);
  margin-top: 4px;
}

.sidebar-nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.sidebar-nav-link:hover {
  background: var(--bg-cream);
  color: var(--text-primary);
}

.sidebar-nav-link.active {
  background: rgba(192, 139, 92, 0.1);
  color: var(--accent-coral);
  font-weight: 500;
}

.sidebar-nav-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ── Section label ── */
.sidebar-section-label {
  padding: 14px 16px 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* ── Chat history list ── */
.chat-history-list {
  flex: 1;
  overflow-y: auto;
  padding: 2px 8px;
}

/* ── Sidebar profile footer ─────────────────────────────────────────────
 * Sits at the bottom of the left sidebar. Click → /profile page. Avatar
 * shows the first letter of the email (or "?" signed-out). Meta block
 * disappears when sidebar is collapsed — just the avatar remains.
 * ──────────────────────────────────────────────────────────────────── */
.sidebar-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  width: calc(100% - 16px);
  /* margin-top: auto pins the button to the very bottom of the sidebar
   * regardless of how tall the chat history list ends up. */
  margin: auto 8px 8px;
  padding: 8px 10px;
  background: none;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
  flex-shrink: 0;
}
.sidebar-profile:hover {
  background: var(--bg-cream);
  border-color: var(--border-medium, var(--border-light));
}

.sidebar-profile-avatar {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand-gradient);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  letter-spacing: 0;
  user-select: none;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25),
              0 1px 3px rgba(42, 56, 153, 0.18);
}
.sidebar-profile-avatar img,
.profile-avatar-lg img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
.profile-avatar-lg {
  overflow: hidden;
}

.sidebar-profile-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-profile-name {
  font-weight: 500;
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-profile-email {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-profile-chevron {
  flex: 0 0 14px;
  width: 14px;
  height: 14px;
  color: var(--text-tertiary);
}

/* Collapsed sidebar: keep avatar visible, hide the rest. margin-top:auto
 * still needed because the chat-history-list is display:none in this
 * state (removes its flex:1 fill), so without explicit bottom-push the
 * button would float to the middle. */
.left-sidebar.collapsed .sidebar-profile {
  justify-content: center;
  padding: 4px;
  width: 40px;
  margin: auto auto 10px;
  border: 0;
  background: transparent;
}
.left-sidebar.collapsed .sidebar-profile:hover {
  background: transparent;
  border-color: transparent;
}
.left-sidebar.collapsed .sidebar-profile-meta,
.left-sidebar.collapsed .sidebar-profile-chevron {
  display: none;
}

/* Admin status no longer marked on the avatar — kept clean to match the
   brand-gradient circle. */
.sidebar-profile-avatar.is-admin {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25),
              0 1px 3px rgba(42, 56, 153, 0.18);
}

/* ── Profile page ──────────────────────────────────────────────────── */
.profile-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 40px 48px 60px;
  background: var(--bg-cream);
  width: 100%;
  box-sizing: border-box;
}
.profile-header {
  margin-bottom: 28px;
}
.profile-title {
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 6px;
}
.profile-dek {
  font-size: 14px;
  color: var(--text-tertiary);
  margin: 0;
}
.profile-card {
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 24px;
  max-width: 720px;
  margin-bottom: 24px;
}
.profile-avatar-lg {
  flex: 0 0 72px;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, #c08b5c, #8c6846);
  color: #fff;
  font-weight: 600;
  font-size: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  user-select: none;
}
.profile-identity {
  flex: 1;
  min-width: 0;
}
.profile-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.profile-email {
  font-size: 14px;
  color: var(--text-secondary);
  word-break: break-all;
  margin-bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.profile-email-verified {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
}
.profile-email-verified.is-verified {
  background: rgba(46, 160, 67, 0.12);
  color: #2ea043;
}
.profile-email-verified.not-verified {
  background: rgba(217, 119, 87, 0.12);
  color: #d97757;
}
.profile-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.profile-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  border-radius: 999px;
  text-transform: uppercase;
}
.profile-badge.admin {
  background: rgba(192, 139, 92, 0.12);
  color: var(--accent-coral);
  border: 1px solid rgba(192, 139, 92, 0.32);
}
.profile-badge.user {
  background: var(--bg-cream);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}
.profile-section {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 8px 4px;
  max-width: 720px;
  margin-bottom: 24px;
}
.profile-field {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
}
.profile-field:last-child {
  border-bottom: none;
}
.profile-field label {
  flex: 0 0 160px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.profile-field code,
.profile-field span {
  flex: 1;
  font-size: 13px;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-all;
}
.profile-field span {
  font-family: inherit;
}
.profile-actions {
  max-width: 720px;
  display: flex;
  gap: 12px;
}
.profile-signout-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--bg-white);
  border: 1px solid #d97757;
  color: #d97757;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.profile-signout-btn:hover {
  background: #d97757;
  color: #fff;
}

/* ── Admins tab ─────────────────────────────────────────────────────── */
.admins-page {
  padding: 24px 28px;
  max-width: 820px;
}
.admins-header {
  margin-bottom: 20px;
}
.admins-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 4px;
}
.admins-dek {
  font-size: 13px;
  color: var(--text-tertiary);
  margin: 0;
  line-height: 1.5;
}
.admins-add-form {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  padding: 16px;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: 12px;
}
.admins-add-form input {
  flex: 1;
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: var(--bg-white);
  color: var(--text-primary);
}
.admins-add-form input[type="email"] { flex: 2; }
.admins-add-form input:focus {
  outline: none;
  border-color: var(--accent-coral);
}
.admins-add-form button {
  padding: 9px 18px;
  background: var(--accent-coral);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.12s ease;
}
.admins-add-form button:hover { opacity: 0.9; }
.admins-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.admins-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: 10px;
}
.admins-row-main { flex: 1; min-width: 0; }
.admins-email {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  word-break: break-all;
}
.admins-self-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 1px 6px;
  margin-left: 6px;
  background: rgba(192, 139, 92, 0.15);
  color: var(--accent-coral);
  border-radius: 4px;
  vertical-align: middle;
}
.admins-meta {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}
.admins-remove-btn {
  padding: 6px 12px;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.12s ease, color 0.12s ease;
}
.admins-remove-btn:hover:not(:disabled) {
  border-color: #d97757;
  color: #d97757;
}
.admins-remove-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.admins-loading, .admins-empty, .admins-error {
  padding: 32px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
}
.admins-error { color: #d97757; }

/* ── Signed-out overlay ────────────────────────────────────────────────
 * Shown after the user signs out of Swarm (sessionStorage guard set).
 * Sits above everything so the empty app shell underneath doesn't leak.
 * ─────────────────────────────────────────────────────────────────── */
.swarm-signed-out-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: linear-gradient(180deg, rgba(250, 247, 242, 0.97), rgba(250, 247, 242, 0.99));
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: swarmSignedOutFadeIn 0.28s ease-out;
}
@keyframes swarmSignedOutFadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}
.swarm-signed-out-card {
  max-width: 440px;
  width: 100%;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 40px 36px;
  text-align: center;
  box-shadow: 0 18px 48px rgba(60, 40, 20, 0.08);
}
.swarm-signed-out-check {
  width: 56px;
  height: 56px;
  margin: 0 auto 20px;
  color: var(--accent-coral);
}
.swarm-signed-out-check svg {
  width: 100%;
  height: 100%;
}
.swarm-signed-out-card h1 {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 10px;
}
.swarm-signed-out-card p {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-tertiary);
  margin: 0 0 28px;
}
.swarm-signed-out-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.swarm-signed-out-primary {
  padding: 11px 18px;
  background: var(--accent-coral);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.12s ease;
}
.swarm-signed-out-primary:hover { opacity: 0.9; }
.swarm-signed-out-secondary {
  padding: 10px 18px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.12s ease, color 0.12s ease;
}
.swarm-signed-out-secondary:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

/* ── Artifacts full-page view ── */
/* ══════════════════════════════════════════════════════════════════════
 * ARTIFACTS — Editorial Catalogue
 *
 * Refined archival catalogue aesthetic. Each artifact is a numbered
 * specimen, not a card. Filters read like a catalogue index. Brand
 * gradient is a quiet thumbnail accent, not a coral leader. Hairline
 * rules, generous space, mono numerals, italic serif titles.
 * ════════════════════════════════════════════════════════════════════ */

.artifacts-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 32px 40px 60px;
  width: 100%;
  box-sizing: border-box;
  height: 100%;
  background: var(--bg-cream);
}
.artifacts-page.hidden { display: none; }

/* Optional dek under the gradient title — sets context for the catalogue */
.artifacts-page-header-dek {
  font-family: 'EB Garamond', Georgia, serif;
  font-style: italic;
  font-size: 15px;
  color: var(--text-secondary);
  margin: 8px 0 0;
  max-width: 540px;
}

/* ── Catalogue index (filter strip) ─────────────────────────────────── */
.artifacts-page-tabs {
  display: flex;
  gap: 0;
  padding: 0 0 22px;
  margin: 0 0 32px;
  flex-wrap: wrap;
  align-items: baseline;
  border-bottom: 1px solid var(--border-light);
  position: relative;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}

.artifacts-tab {
  padding: 0;
  margin: 0;
  background: transparent;
  border: 0;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: color 0.15s ease;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  position: relative;
}
.artifacts-tab + .artifacts-tab {
  margin-left: 22px;
  padding-left: 22px;
}
.artifacts-tab + .artifacts-tab::before {
  content: '/';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-55%);
  color: rgba(26, 15, 5, 0.18);
  font-weight: 400;
}
.artifacts-tab:hover { color: var(--text-primary); }
.artifacts-tab.active { color: var(--text-primary); }
.artifacts-tab.active::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  bottom: -23px;
  height: 2px;
  background: var(--brand-gradient-rule);
  border-radius: 2px;
}
.artifacts-tab + .artifacts-tab.active::after { left: 22px; }

/* ── Page pill tabs (Telemetry, Validation, etc.) ─────────────────── */
/* A softer, segmented-control style for sub-tabs that aren't filter
 * strips. Used by Telemetry's Chats/Validations switch and any other
 * page-level binary/N-way mode toggle. Reads as one cohesive pill
 * rather than a typographic catalogue strip. */
.page-pill-tabs {
  display: inline-flex;
  gap: 0;
  padding: 4px;
  margin: 4px 0 18px;
  background: rgba(26, 15, 5, 0.04);
  border: 1px solid var(--border-light);
  border-radius: 999px;
}

.page-pill-tab {
  padding: 7px 18px;
  border: none;
  background: transparent;
  border-radius: 999px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.page-pill-tab:hover {
  color: var(--text-primary);
}

.page-pill-tab.active {
  color: var(--text-primary);
  background: #fff;
  box-shadow:
    0 1px 2px rgba(26, 15, 5, 0.06),
    0 0 0 1px rgba(26, 15, 5, 0.04);
}

.page-pill-tab + .page-pill-tab {
  margin-left: 2px;
}

/* The little count beside each filter, e.g. "HTML  ·  12" */
.artifacts-tab-count {
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
  font-weight: 400;
  font-style: italic;
}
.artifacts-tab.active .artifacts-tab-count { color: var(--text-secondary); }

/* ── The catalogue grid ─────────────────────────────────────────────── */
.artifacts-page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 44px 32px;
  padding: 0;
}
@media (max-width: 700px) {
  .artifacts-page-grid { gap: 36px 22px; }
  .artifacts-page { padding: 28px 22px 50px; }
}

.artifacts-page-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 90px 24px;
  color: var(--text-tertiary);
  font-family: 'EB Garamond', Georgia, serif;
  font-style: italic;
  font-size: 18px;
}

/* ── Specimen entry — borderless catalogue entry ──────────────────────
 * Layout (no card border, no rounded corners — pure typographic):
 *
 *   № 087                                       [ MARKDOWN ]
 *   ┌────────────────────────────────────────┐
 *   │  preview plate (paper texture, ruled)  │
 *   └────────────────────────────────────────┘
 *   Italic serif title — Fraunces / Garamond
 *   FROM PARLIAMENT & POLICY DIGEST  ·  2026.04.18
 *
 * Brand gradient is a 1px top accent on the plate; reveals to 3px on
 * hover. Title gets an underline. Whole entry rises 2px.            */
.artifact-card {
  position: relative;
  border: 0;
  border-radius: 0;
  overflow: visible;
  cursor: pointer;
  background: transparent;
  display: flex;
  flex-direction: column;
  gap: 0;
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.artifact-card::before { content: none; }
.artifact-card:hover { transform: translateY(-2px); }
.artifact-card:hover .artifact-card-title {
  text-decoration: underline;
  text-decoration-color: var(--text-primary);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}
.artifact-card:hover .artifact-card-thumb::before {
  height: 3px;
  background: var(--brand-gradient-rule);
}
.artifact-card:hover .artifact-card-catalog-num { color: var(--text-primary); }

/* Catalogue header line above the plate — № on the left, type on the right */
.artifact-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0 0 10px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.artifact-card-catalog-num {
  color: var(--text-tertiary);
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0.06em;
  transition: color 0.15s ease;
}
.artifact-card-type-code {
  color: var(--text-secondary);
  font-weight: 500;
}
.artifact-card-type-code::before { content: '['; opacity: 0.45; margin-right: 2px; }
.artifact-card-type-code::after  { content: ']'; opacity: 0.45; margin-left: 2px; }

/* Plate — reads as a tiny printed page. White paper, hairline border,
 * soft layered shadow. The content scales inside via .artifact-plate-
 * scale-inner; this container is just the page frame. Hover lifts the
 * shadow and reveals a brand-gradient top accent. */
.artifact-card-thumb {
  height: 200px;
  background: #ffffff;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(26, 15, 5, 0.1);
  padding: 0;            /* inner content provides its own margins */
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,    /* paper highlight */
    0 1px 0 rgba(26, 15, 5, 0.04),
    0 2px 4px rgba(26, 15, 5, 0.04),
    0 8px 18px -8px rgba(26, 15, 5, 0.08);
  transition: box-shadow 0.28s ease, transform 0.28s ease;
  border-radius: 1px;
}
.artifact-card:hover .artifact-card-thumb {
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 1px 0 rgba(26, 15, 5, 0.06),
    0 4px 10px rgba(26, 15, 5, 0.06),
    0 14px 28px -10px rgba(26, 15, 5, 0.14);
}

/* Faint paper fade at the bottom of the page — implies "more page
 * below" and prevents abrupt text cut-off mid-glyph. */
.artifact-plate-fade {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 48px;
  background: linear-gradient(180deg, rgba(255,255,255,0) 0%, #ffffff 80%);
  pointer-events: none;
  z-index: 3;
}

/* Top accent — invisible at rest, becomes a brand-gradient rule on hover */
.artifact-card-thumb::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 0;
  background: transparent;
  transition: height 0.22s ease, background 0.22s ease;
  z-index: 2;
  pointer-events: none;
}

/* Subtle paper grain on the plate */
.artifact-card-thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 18% 28%, rgba(168, 118, 68, 0.05) 0, transparent 42%),
    radial-gradient(circle at 82% 72%, rgba(42, 56, 153, 0.03) 0, transparent 48%);
  pointer-events: none;
  z-index: 1;
}

/* The legacy type chip is hidden — replaced by the header type code. */
.artifact-card-type-chip { display: none; }

/* ── Type-specific plate previews (pure CSS — no images needed) ─────────── */

/* Shared scaffolding for preview lines */
.artifact-plate {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  position: relative;
  z-index: 1;
}

/* ── Real-content thumbnail container ────────────────────────────────────
 * Each plate can render the ACTUAL artifact content scaled down. The
 * `-scale` wrapper is clipped to plate size; the inner renders at natural
 * size and is CSS-transformed to fit. Renders markdown, code, csv, json,
 * svg, html at their real fidelity but miniature.
 */
/* The scaled "page". Outer is the page frame, inner is the content
 * column. Centered horizontally with proper margins so the document
 * reads as a portrait page, not a left-aligned crop. */
.artifact-plate-scale {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 1;
  padding: 22px 30px 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  pointer-events: none;
}

/* Use `zoom` instead of `transform: scale()` so the browser reflows
 * type at the target size rather than rasterising-then-resampling.
 * Result: crisp anti-aliased text instead of blurred glyphs. Falls
 * back to scale on engines without zoom (none we ship to). */
.artifact-plate-scale-inner {
  zoom: 0.7;
  -moz-transform: scale(0.7);     /* Firefox doesn't support zoom */
  -moz-transform-origin: top left;
  width: 100%;
  max-height: 100%;
  overflow: hidden;
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 15px;
  color: rgba(26, 15, 5, 0.92);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: geometricPrecision;
}

.artifact-plate-scale-inner.mono {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  line-height: 1.55;
  color: rgba(26, 15, 5, 0.78);
  white-space: pre;
}

/* H1 — looks like the printed title of the page. Display serif, a touch
 * bigger, with a hairline rule beneath like a real document title. */
.artifact-plate-scale-inner h1 {
  font-family: 'Fraunces', 'EB Garamond', Georgia, serif;
  font-weight: 500;
  font-size: 22px;
  letter-spacing: -0.012em;
  line-height: 1.1;
  margin: 0 0 8px;
  padding: 0 0 6px;
  border-bottom: 1px solid rgba(26, 15, 5, 0.18);
  color: rgba(26, 15, 5, 0.92);
  font-variation-settings: 'opsz' 144;
}

.artifact-plate-scale-inner h2 {
  font-family: 'Fraunces', 'EB Garamond', Georgia, serif;
  font-weight: 500;
  font-size: 16px;
  font-style: italic;
  margin: 8px 0 4px;
  color: rgba(26, 15, 5, 0.86);
  font-variation-settings: 'opsz' 60;
}

.artifact-plate-scale-inner h3 {
  font-family: 'Fraunces', 'EB Garamond', Georgia, serif;
  font-weight: 500;
  font-size: 13.5px;
  margin: 6px 0 2px;
  color: rgba(26, 15, 5, 0.86);
}

.artifact-plate-scale-inner p,
.artifact-plate-scale-inner ul,
.artifact-plate-scale-inner ol {
  margin: 0 0 5px 0;
}
.artifact-plate-scale-inner ul,
.artifact-plate-scale-inner ol { padding-left: 14px; }
.artifact-plate-scale-inner li { margin-bottom: 2px; }
.artifact-plate-scale-inner li::marker { color: rgba(168, 118, 68, 0.85); }

.artifact-plate-scale-inner strong { font-weight: 600; color: rgba(26, 15, 5, 0.95); }
.artifact-plate-scale-inner em { font-style: italic; }

.artifact-plate-scale-inner a {
  color: rgba(42, 56, 153, 0.85);
  text-decoration: underline;
  text-decoration-thickness: 0.5px;
  text-underline-offset: 2px;
}

/* Wrapper added by markdown renderer to allow horizontal scroll on
   wide tables without overflowing the artifact panel. */
.artifact-plate-scale-inner .table-scroll-wrap {
  overflow-x: auto;
  margin: 4px 0 6px;
  -webkit-overflow-scrolling: touch;
}

.artifact-plate-scale-inner table {
  border-collapse: collapse;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  width: 100%;
  margin: 0;
  border-top: 1.5px solid rgba(26, 15, 5, 0.55);
  border-bottom: 1.5px solid rgba(26, 15, 5, 0.55);
}

.artifact-plate-scale-inner th,
.artifact-plate-scale-inner td {
  border: 0;
  border-bottom: 1px solid rgba(26, 15, 5, 0.1);
  padding: 3px 8px 3px 0;
  text-align: left;
  vertical-align: top;
}

.artifact-plate-scale-inner th {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 500;
  color: rgba(26, 15, 5, 0.6);
  border-bottom-color: rgba(26, 15, 5, 0.55);
}

.artifact-plate-scale-inner blockquote {
  border-left: 2px solid rgba(168, 118, 68, 0.7);
  margin: 4px 0;
  padding: 0 0 0 8px;
  font-style: italic;
  color: rgba(26, 15, 5, 0.7);
}

.artifact-plate-scale-inner code {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.88em;
  background: rgba(168, 118, 68, 0.1);
  padding: 0 3px;
  border-radius: 2px;
  color: rgba(168, 118, 68, 0.95);
}

.artifact-plate-scale-inner pre {
  background: rgba(26, 15, 5, 0.04);
  padding: 6px 8px;
  border-radius: 2px;
  margin: 4px 0;
  overflow: hidden;
}
.artifact-plate-scale-inner pre code { background: transparent; padding: 0; color: inherit; }

/* Artifact-preview image guard: prevent wide images (infographics
 * embedded by the L6 consolidator, oversized chart screenshots) from
 * overflowing the preview pane horizontally. Markdown ![]() images
 * inside .artifact-markdown get max-width:100% with proportional
 * height; the parent container clips correctly. */
.artifact-markdown img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 12px auto;
}

/* ─── Inline rich blocks (scorecard, chart, metric) ───────────────── */
/* Rendered from ```scorecard / ```chart / ```metric fenced blocks.
 * Works in both chat bubbles (.markdown-content) and artifact preview
 * (.artifact-markdown, .artifact-plate-scale-inner).                  */

/* Scorecard — Anthropic-style KPI tile grid.
 * Warm cream cards, centered text, generous spacing.
 * Mirrors the Claude.ai inline-metric aesthetic:
 *   • sentence-case labels (not UPPERCASE)
 *   • large bold value as the visual anchor
 *   • muted detail line below
 *   • warm neutral palette, no cold blue-grays                          */
.inline-scorecard {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin: 18px 0;
  padding: 0;
  max-width: 100%;
}
@media (min-width: 700px) {
  .inline-scorecard {
    grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  }
}
.inline-scorecard .sc-card {
  padding: 16px 13px;
  border-radius: 12px;
  background: #f3eeea;
  border: 1px solid rgba(0, 0, 0, 0.04);
  text-align: center;
  min-width: 0;
  overflow: hidden;
}
.sc-card .sc-label {
  font-size: 13.5px;
  font-weight: 400;
  color: #6b6560;
  letter-spacing: 0;
  margin-bottom: 6px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sc-card .sc-value {
  /* Smaller + viewport-responsive (was a fixed 28px that overflowed cards for
     long values like "₹1,57,000/10g"). overflow-wrap lets a long value wrap to
     a second line instead of being clipped by the card's overflow:hidden. */
  font-size: clamp(17px, 2.1vw, 23px);
  font-weight: 700;
  color: #1a1a1a;
  line-height: 1.18;
  font-family: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}
.sc-card .sc-unit {
  font-size: 13px;
  font-weight: 400;
  color: #8a8480;
  margin-top: 4px;
  line-height: 1.3;
}
.sc-card .sc-detail {
  font-size: 13px;
  font-weight: 400;
  color: #8a8480;
  margin-top: 5px;
  line-height: 1.3;
}
.sc-card .sc-trend {
  font-size: 12px;
  font-weight: 600;
  margin-top: 6px;
  line-height: 1;
}
.sc-card .sc-trend-up   { color: #c53030; }
.sc-card .sc-trend-down { color: #276749; }

/* 5-6 cards: slightly smaller values so rows stay balanced */
.inline-scorecard[data-count="5"] .sc-value,
.inline-scorecard[data-count="6"] .sc-value {
  font-size: clamp(15px, 1.7vw, 20px);
}
.inline-scorecard[data-count="5"] .sc-card,
.inline-scorecard[data-count="6"] .sc-card {
  padding: 16px 12px;
}

/* Inline chart — Chart.js canvas in a styled container */
.inline-chart {
  margin: 18px 0;
  padding: 18px 18px 14px;
  background: #f3eeea;
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 12px;
  position: relative;
}
.inline-chart .chart-title {
  font-size: 13px;
  font-weight: 600;
  color: #2d3748;
  margin-bottom: 10px;
  font-family: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
}
.inline-chart canvas {
  width: 100% !important;
  max-height: 320px;
}

/* Small multiples — one chart per unit family for mixed-scale tables.
   Auto-fit 2-up on wide panes, single column when narrow. */
.inline-chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin: 18px 0;
}
.inline-chart-grid .inline-chart {
  margin: 0;
}
.inline-chart-grid .inline-chart canvas {
  max-height: 240px;
}

/* Metric callout — single highlighted number, warm Anthropic style */
.inline-metric {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 18px 22px;
  margin: 14px 0;
  background: #f3eeea;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.04);
  max-width: 100%;
}
.inline-metric .metric-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.inline-metric .metric-label {
  font-size: 13.5px;
  font-weight: 400;
  color: #6b6560;
}
.inline-metric .metric-value {
  font-size: 28px;
  font-weight: 700;
  color: #1a1a1a;
  line-height: 1.15;
  font-family: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.inline-metric .metric-detail {
  font-size: 13px;
  color: #8a8480;
  margin-top: 2px;
}

/* Rich blocks inside the preview pane — slightly tighter spacing */
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown .inline-scorecard {
  margin: 14px 0;
  gap: 10px;
}
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown .sc-card .sc-value {
  font-size: 24px;
}
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown .sc-card {
  padding: 16px 14px;
}
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown .inline-chart {
  margin: 14px 0;
}
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown .inline-metric .metric-value {
  font-size: 24px;
}

/* ─── / Inline rich blocks ──────────────────────────────────────────── */

.artifact-plate-scale-inner hr {
  border: 0;
  border-top: 1px solid rgba(26, 15, 5, 0.12);
  margin: 8px 0;
}

/* HTML / DOC iframe thumbnail — fully rendered, scaled. Iframes can't
 * use `zoom` (they're isolated documents), so we scale via transform.
 * The iframe stretches to 200% of the plate then scales 0.5 — net
 * result: same size as the plate, but the iframe's internal viewport
 * is large enough to render a real layout instead of a mobile-narrow
 * fallback. z-index 1 puts it above the plate grain but below the
 * bottom fade. */
.artifact-plate-iframe {
  position: absolute;
  inset: 0;
  border: 0;
  width: 200%;
  height: 200%;
  transform: scale(0.5);
  transform-origin: top left;
  pointer-events: none;
  background: #ffffff;
  z-index: 1;
}

/* SVG inline thumbnail */
.artifact-plate-svg {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}
.artifact-plate-svg svg {
  max-width: 100%;
  max-height: 100%;
}

.artifact-plate-line {
  height: 6px;
  background: linear-gradient(90deg, rgba(26, 15, 5, 0.18), rgba(26, 15, 5, 0.08));
  border-radius: 2px;
}

.artifact-plate-line.h1 {
  height: 10px;
  width: 62%;
  background: linear-gradient(90deg, rgba(26, 15, 5, 0.36), rgba(26, 15, 5, 0.18));
  margin-bottom: 6px;
}

.artifact-plate-line.short { width: 45%; }
.artifact-plate-line.med { width: 70%; }
.artifact-plate-line.long { width: 92%; }

/* CSV-style mini grid */
.artifact-plate-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  width: 100%;
  height: 70%;
}
.artifact-plate-cell {
  background: rgba(26, 15, 5, 0.06);
  border-radius: 1px;
}
.artifact-plate-cell.header {
  background: rgba(192, 139, 92, 0.25);
}
.artifact-plate-cell.accent {
  background: rgba(192, 139, 92, 0.14);
}

/* JSON-style — indented monospace lines with braces */
.artifact-plate-json {
  font-family: 'Monaco', 'Menlo', ui-monospace, monospace;
  font-size: 11px;
  color: rgba(26, 15, 5, 0.55);
  line-height: 1.55;
  letter-spacing: -0.3px;
}

/* Code-style — dots representing syntax colors */
.artifact-plate-code-line {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 8px;
}
.artifact-plate-code-line > span {
  height: 6px;
  border-radius: 1px;
}
.artifact-plate-code-kw { background: rgba(192, 139, 92, 0.6); width: 12%; }
.artifact-plate-code-fn { background: rgba(26, 15, 5, 0.35); width: 18%; }
.artifact-plate-code-arg { background: rgba(26, 15, 5, 0.18); width: 32%; }
.artifact-plate-code-str { background: rgba(120, 140, 90, 0.55); width: 20%; }

/* HTML-style — mock browser chrome */
.artifact-plate-browser {
  width: 100%;
  height: 100%;
  border-radius: 4px;
  background: var(--bg-white);
  border: 1px solid rgba(26, 15, 5, 0.1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.artifact-plate-browser-bar {
  height: 12px;
  background: #f0edec;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0 6px;
  border-bottom: 1px solid rgba(26, 15, 5, 0.05);
}
.artifact-plate-browser-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(26, 15, 5, 0.18);
}
.artifact-plate-browser-body {
  flex: 1;
  padding: 5px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.artifact-plate-browser-body .artifact-plate-line { height: 4px; }

/* SVG / Mermaid — abstract diagram */
.artifact-plate-diagram {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.artifact-plate-diagram svg {
  width: 100%;
  height: 100%;
  max-width: 160px;
}

/* Markdown / document / docx — editorial layout */
.artifact-plate-doc {
  width: 100%;
  padding: 0 6px;
}
.artifact-plate-doc-pullquote {
  font-family: 'EB Garamond', Georgia, serif;
  font-style: italic;
  font-size: 13px;
  color: rgba(26, 15, 5, 0.32);
  line-height: 1.3;
  border-left: 2px solid rgba(192, 139, 92, 0.4);
  padding-left: 8px;
  margin: 4px 0;
}

/* ── Card body — title + metadata ────────────────────────────────────────── */

/* Body sits BELOW the plate — no background, just type. */
.artifact-card-body {
  padding: 14px 0 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.artifact-card-title {
  font-family: 'Fraunces', 'EB Garamond', Georgia, serif;
  font-style: italic;
  font-size: 19px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--text-primary);
  letter-spacing: -0.012em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variation-settings: 'opsz' 60, 'SOFT' 50;
}

.artifact-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.artifact-card-badge { display: none; }

.artifact-card-chat {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-secondary);
  font-weight: 500;
}
.artifact-card-chat::before { content: 'FROM '; opacity: 0.45; margin-right: 2px; }

.artifact-card-date {
  white-space: nowrap;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
}

.artifact-card-meta-sep {
  color: rgba(26, 15, 5, 0.18);
  user-select: none;
  font-weight: 400;
}

/* ==================== PLUGINS PAGE ==================== */

.plugins-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 0;
}
.plugins-page.hidden { display: none; }

/* Section header inside the Plugins tab — italic Fraunces matching
 * dashboard category labels. The page-level "Settings" gradient
 * header sits above the tab bar; this is the second-tier header. */
.plugins-page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0 0;
  gap: 16px;
  flex-wrap: wrap;
}
.plugins-header-left {
  display: flex;
  align-items: baseline;
  gap: 14px;
}
.plugins-page-title {
  font-family: 'Fraunces', 'EB Garamond', Georgia, serif;
  font-style: italic;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.012em;
  color: var(--text-primary);
  margin: 0;
  font-variation-settings: 'opsz' 60;
}
.plugins-count {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  font-weight: 500;
}
.plugins-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.plugins-search-wrap {
  position: relative;
}
.plugins-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  pointer-events: none;
}
.plugins-search {
  width: 240px;
  padding: 8px 14px 8px 36px;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  font-family: 'EB Garamond', Georgia, serif;
  font-style: italic;
  font-size: 14px;
  background: var(--bg-white);
  color: var(--text-primary);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.plugins-search::placeholder {
  color: var(--text-tertiary);
  font-style: italic;
}
.plugins-search:focus {
  outline: none;
  border-color: var(--brand-teal, #1d9a94);
  box-shadow: 0 0 0 3px rgba(29, 154, 148, 0.1);
}
.plugins-activate-all-btn,
.plugins-create-btn {
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid var(--border-light);
  background: transparent;
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.plugins-activate-all-btn:hover,
.plugins-create-btn:hover {
  color: var(--text-primary);
  background: var(--bg-white);
  border-color: var(--text-tertiary);
}
.plugins-activate-all-btn.all-active {
  color: var(--text-tertiary);
}
.plugins-activate-all-btn.all-active:hover {
  background: var(--bg-cream);
  color: var(--text-primary);
}
.plugins-create-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 8px;
  background: var(--accent-coral);
  color: white;
  border: none;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.plugins-create-btn:hover {
  background: var(--accent-coral-dark);
}

/* Filters */
.plugins-filters {
  padding: 16px 48px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
/* Category filter strip — same editorial language as artifacts. */
.plugins-page-tabs {
  display: flex;
  gap: 0;
  flex-wrap: wrap;
  align-items: baseline;
  padding: 0 0 18px;
  border-bottom: 1px solid var(--border-light);
  position: relative;
  margin-bottom: 8px;
}
.plugins-tab {
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: color 0.15s ease;
  position: relative;
  white-space: nowrap;
  border-radius: 0;
}
.plugins-tab + .plugins-tab { margin-left: 22px; padding-left: 22px; }
.plugins-tab + .plugins-tab::before {
  content: '/';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-55%);
  color: rgba(26, 15, 5, 0.18);
  font-weight: 400;
}
.plugins-tab:hover { color: var(--text-primary); background: transparent; }
.plugins-tab.active { color: var(--text-primary); background: transparent; border: 0; }
.plugins-tab.active::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  bottom: -19px;
  height: 2px;
  background: var(--brand-gradient-rule);
  border-radius: 2px;
}
.plugins-tab + .plugins-tab.active::after { left: 22px; }

/* Priority pills → quiet mono small-caps, single ink colour for active.
 * The previous rainbow (coral/amber/blue/grey per priority) was loud
 * and competed with the cards. */
.plugins-priority-pills {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: baseline;
}
.plugins-priority-pill {
  padding: 4px 0;
  border: 0;
  background: transparent;
  border-radius: 0;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
  border-bottom: 1.5px solid transparent;
}
.plugins-priority-pill:hover { color: var(--text-primary); border-color: rgba(26, 15, 5, 0.18); }
.plugins-priority-pill.active {
  background: transparent;
  color: var(--text-primary);
  border-bottom-color: var(--brand-teal, #1d9a94);
}
/* Drop the per-priority colour overrides — single ink language */
.plugins-priority-pill.p1,
.plugins-priority-pill.p2,
.plugins-priority-pill.p3,
.plugins-priority-pill.p4 { color: var(--text-tertiary); border-color: transparent; }
.plugins-priority-pill.p1.active,
.plugins-priority-pill.p2.active,
.plugins-priority-pill.p3.active,
.plugins-priority-pill.p4.active {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--brand-teal, #1d9a94);
}

/* Stats bar */
.plugins-stats-bar {
  padding: 8px 48px;
  font-size: 12px;
  color: var(--text-tertiary);
  border-bottom: 1px solid var(--border-light);
}

/* Plugin grid — wider min so cards have room for editorial typography. */
.plugins-page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 22px;
  padding: 24px 0 48px;
}
.plugins-page-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 24px;
  color: var(--text-tertiary);
  font-family: 'EB Garamond', Georgia, serif;
  font-style: italic;
  font-size: 17px;
}

/* Plugin card — paper sheet on cream page (matches artifacts plate
 * + dashboard chart card language). Hairline border, layered shadow,
 * brand-gradient top accent appears on hover. The "enabled" state is
 * marked by a permanent thin gradient rule + warmer paper, not a
 * glaring coral box-shadow. */
.plugin-card {
  border: 1px solid rgba(26, 15, 5, 0.08);
  border-radius: 4px;
  background: #ffffff;
  overflow: hidden;
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1),
              box-shadow 0.22s ease;
  cursor: pointer;
  position: relative;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 1px 0 rgba(26, 15, 5, 0.04),
    0 2px 4px rgba(26, 15, 5, 0.04),
    0 8px 18px -8px rgba(26, 15, 5, 0.08);
}
.plugin-card:hover {
  transform: translateY(-2px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 1px 0 rgba(26, 15, 5, 0.06),
    0 4px 10px rgba(26, 15, 5, 0.06),
    0 14px 28px -10px rgba(26, 15, 5, 0.14);
}
.plugin-card:hover .plugin-card-accent {
  height: 3px;
  background: var(--brand-gradient-rule);
  opacity: 1;
}
.plugin-card.enabled {
  border-color: rgba(26, 15, 5, 0.12);
  background: #fdfaf2;
}
.plugin-card.enabled .plugin-card-accent {
  height: 2px;
  background: var(--brand-gradient-rule);
  opacity: 1;
}

/* Top accent rule — invisible at rest, brand-gradient on hover or
 * when enabled. Replaces the rainbow per-category bars. */
.plugin-card-accent {
  height: 0;
  width: 100%;
  background: transparent;
  opacity: 0;
  transition: height 0.22s ease, background 0.22s ease, opacity 0.22s ease;
}
/* Drop all per-category colour overrides */
.plugin-card-accent[data-cat] { background: transparent; }

.plugin-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px 4px;
}
.plugin-card-icon {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
  opacity: 0.9;
}
.plugin-card-name {
  flex: 1;
  font-family: 'Fraunces', 'EB Garamond', serif;
  font-style: italic;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.012em;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variation-settings: 'opsz' 60;
  line-height: 1.2;
}

/* Toggle switch */
.plugin-toggle {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.plugin-toggle input { display: none; }
.plugin-toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border-light);
  border-radius: 11px;
  cursor: pointer;
  transition: background 0.2s;
}
.plugin-toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.plugin-toggle input:checked + .plugin-toggle-slider {
  background: var(--brand-teal, #1d9a94);
}
.plugin-toggle input:checked + .plugin-toggle-slider::before {
  transform: translateX(18px);
}

.plugin-card-body {
  padding: 6px 18px 4px;
}
.plugin-card-desc {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 14px;
  font-style: italic;
  color: var(--text-secondary);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0;
}

.plugin-card-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px 14px;
  flex-wrap: wrap;
  border-top: 1px dotted rgba(26, 15, 5, 0.1);
  margin-top: 12px;
}
/* All badges share one mono small-caps register; category is hinted
 * with a tiny coloured dot rather than a coloured pill background. */
.plugin-card-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  background: transparent;
  border-radius: 0;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.plugin-card-badge::before {
  content: '';
  width: 5px; height: 5px; border-radius: 50%;
  background: currentColor;
  opacity: 0.55;
  flex-shrink: 0;
}
/* Category dot colours — quiet, semantic; no background pill. */
.plugin-card-badge.cat-data       { color: #2f5fa6; }
.plugin-card-badge.cat-macro      { color: #2f8d4f; }
.plugin-card-badge.cat-doc        { color: #6f4baf; }
.plugin-card-badge.cat-research   { color: #b35a2a; }
.plugin-card-badge.cat-compliance { color: #b3502a; }
.plugin-card-badge.cat-custom     { color: var(--accent-coral-dark, #a87644); }

/* Priority — quiet text only, no dot, no background. */
.plugin-card-badge.priority-p1,
.plugin-card-badge.priority-p2,
.plugin-card-badge.priority-p3,
.plugin-card-badge.priority-p4 {
  color: var(--text-tertiary);
}
.plugin-card-badge.priority-p1::before,
.plugin-card-badge.priority-p2::before,
.plugin-card-badge.priority-p3::before,
.plugin-card-badge.priority-p4::before { content: none; }

.plugin-card-version {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 9.5px;
  letter-spacing: 0.12em;
  color: var(--text-tertiary);
  font-weight: 400;
  margin-left: auto;
}

/* Plugin capabilities — these are full sentences, not labels.
 * Render as a quiet bullet list in italic Garamond so they read as
 * editorial captions, not mono-caps tags. Wraps cleanly inside the
 * card width; no horizontal overflow. */
.plugin-card-caps {
  padding: 4px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.plugin-cap-tag {
  display: block;
  font-family: 'EB Garamond', Georgia, serif;
  font-style: italic;
  font-size: 13px;
  line-height: 1.4;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-secondary);
  background: transparent;
  border-radius: 0;
  padding: 0 0 0 14px;
  white-space: normal;
  position: relative;
  overflow-wrap: anywhere;
}
.plugin-cap-tag::before {
  content: '·';
  position: absolute;
  left: 4px;
  top: 0;
  color: var(--accent-coral-dark, #a87644);
  font-weight: 700;
}
.plugin-cap-more {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  color: var(--text-tertiary);
  padding: 4px 0 0 14px;
  letter-spacing: 0.12em;
  font-style: italic;
  text-transform: uppercase;
}

/* ── Plugin Create Form ── */
.plugin-create-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease-out;
}
.plugin-create-overlay.hidden { display: none; }

.plugin-create-form {
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--bg-white);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.15);
  animation: fadeIn 0.2s ease-out;
}

.plugin-form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 28px 0;
}
.plugin-form-header h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}
.plugin-form-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  transition: background 0.15s;
}
.plugin-form-close:hover {
  background: var(--bg-cream);
  color: var(--text-primary);
}

.plugin-form-grid {
  padding: 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.plugin-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.plugin-form-group label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.plugin-form-group input,
.plugin-form-group textarea,
.plugin-form-group select {
  padding: 10px 14px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-white);
  transition: border-color 0.15s;
}
.plugin-form-group input:focus,
.plugin-form-group textarea:focus,
.plugin-form-group select:focus {
  outline: none;
  border-color: var(--accent-coral);
}
.plugin-form-group textarea {
  resize: vertical;
}
.plugin-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.plugin-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 28px 24px;
}
.plugin-form-cancel {
  padding: 10px 20px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: var(--bg-white);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.plugin-form-cancel:hover {
  background: var(--bg-cream);
}
.plugin-form-submit {
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  background: var(--accent-coral);
  color: white;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.plugin-form-submit:hover {
  background: var(--accent-coral-dark);
}

/* Icon selector */
.plugin-icon-selector {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.plugin-icon-option {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: var(--bg-white);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.plugin-icon-option:hover {
  border-color: var(--accent-coral);
  background: var(--bg-cream);
}
.plugin-icon-option.selected {
  background: var(--accent-coral);
  border-color: var(--accent-coral);
  box-shadow: 0 0 0 2px rgba(196,145,123,0.25);
}

/* ── Plugin Detail Overlay ── */
.plugin-detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease-out;
}
.plugin-detail-overlay.hidden { display: none; }

.plugin-detail-panel {
  width: 90%;
  max-width: 640px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--bg-white);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.15);
}
.plugin-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 28px 0;
}
.plugin-detail-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.plugin-detail-icon {
  font-size: 28px;
}
.plugin-detail-header h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}
.plugin-detail-body {
  padding: 20px 28px 28px;
}
.plugin-detail-body p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0 0 16px;
}
.plugin-detail-section {
  margin-bottom: 20px;
}
.plugin-detail-section h4 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
  margin: 0 0 10px;
}
.plugin-detail-section ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.plugin-detail-section li {
  font-size: 13px;
  color: var(--text-primary);
  padding: 6px 10px;
  background: var(--bg-cream);
  border-radius: 6px;
}
.plugin-detail-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.plugin-detail-tag {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--bg-cream);
  color: var(--text-secondary);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==================== END PLUGINS ==================== */

/* ==================== SEARCH SCOPE MANAGEMENT ==================== */

.search-scope-page { flex: 1; display: flex; flex-direction: column; overflow-y: auto; padding: 40px 48px; max-width: 960px; }
.search-scope-page.hidden { display: none; }
/* Search Scope page — editorial language matches plugins. */
.scope-header { display: flex; align-items: baseline; gap: 14px; margin-bottom: 24px; }
.scope-title {
  font-family: 'Fraunces', 'EB Garamond', Georgia, serif;
  font-style: italic;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.012em;
  color: var(--text-primary);
  font-variation-settings: 'opsz' 60;
}
.scope-count {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  font-weight: 500;
}

/* Tier filter strip — same pattern as plugins/artifacts. */
.scope-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 22px;
  padding: 0 0 18px;
  border-bottom: 1px solid var(--border-light);
  align-items: baseline;
  position: relative;
}
.scope-tab {
  padding: 0;
  background: transparent;
  border: 0;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: color 0.15s ease;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  border-radius: 0;
}
.scope-tab + .scope-tab { margin-left: 22px; padding-left: 22px; }
.scope-tab + .scope-tab::before {
  content: '/';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-55%);
  color: rgba(26, 15, 5, 0.18);
  font-weight: 400;
}
.scope-tab:hover { color: var(--text-primary); }
.scope-tab.active { color: var(--text-primary); border: 0; font-weight: 500; }
.scope-tab.active::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  bottom: -19px;
  height: 2px;
  background: var(--brand-gradient-rule);
  border-radius: 2px;
}
.scope-tab + .scope-tab.active::after { left: 22px; }
.scope-tab-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.scope-tab-dot.gold { background: #D4AF37; }
.scope-tab-dot.silver { background: #A8A8A8; }
.scope-tab-dot.gov { background: #2f8d4f; }

.scope-tier-desc {
  font-family: 'EB Garamond', Georgia, serif;
  font-style: italic;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.45;
}

/* Add-domain row */
.scope-add-row { display: flex; gap: 8px; margin-bottom: 22px; align-items: center; }
.scope-add-input {
  flex: 1;
  padding: 8px 14px;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  background: var(--bg-white);
  font-family: 'EB Garamond', Georgia, serif;
  font-style: italic;
  font-size: 14px;
  color: var(--text-primary);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.scope-add-input::placeholder { color: var(--text-tertiary); font-style: italic; }
.scope-add-input:focus {
  outline: none;
  border-color: var(--brand-teal, #1d9a94);
  box-shadow: 0 0 0 3px rgba(29, 154, 148, 0.1);
}
.scope-add-score {
  width: 64px;
  padding: 8px 10px;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  text-align: center;
  background: var(--bg-white);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.scope-add-btn {
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid var(--text-primary);
  background: var(--text-primary);
  color: var(--bg-white);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
}
.scope-add-btn:hover { background: rgba(26, 15, 5, 0.78); }

/* Domain list — paper rows with hairline divider, no per-row card */
.scope-domain-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-top: 1px solid var(--border-light);
}
.scope-domain-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  background: transparent;
  border: 0;
  border-bottom: 1px dotted rgba(26, 15, 5, 0.12);
  border-radius: 0;
  margin-bottom: 0;
  box-shadow: none;
}
.scope-domain-name {
  width: 240px;
  min-width: 160px;
  font-family: 'Fraunces', 'EB Garamond', serif;
  font-style: italic;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.012em;
  font-variation-settings: 'opsz' 60;
}
.scope-domain-desc {
  flex: 1;
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 13.5px;
  font-style: italic;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.scope-domain-score {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border-light);
  padding: 3px 10px;
  border-radius: 999px;
  min-width: 32px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.scope-domain-del {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-tertiary);
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: color 0.15s ease;
}
.scope-domain-del:hover { color: #b3502a; background: transparent; }
.scope-empty {
  padding: 40px 24px;
  text-align: center;
  color: var(--text-tertiary);
  font-family: 'EB Garamond', Georgia, serif;
  font-style: italic;
  font-size: 15px;
}

/* ── Scope Selector (chat form) ── */

.scope-selector { position: relative; }
.scope-selector-btn { display: flex; align-items: center; gap: 5px; padding: 4px 10px; font-size: 12px;
  font-family: 'Plus Jakarta Sans', sans-serif; color: var(--text-secondary); background: none; border: 1px solid var(--border-light);
  border-radius: 16px; cursor: pointer; white-space: nowrap; transition: all .15s; }
.scope-selector-btn:hover { border-color: var(--accent-coral); color: var(--text-primary); }
.scope-selector-label { max-width: 100px; overflow: hidden; text-overflow: ellipsis; }

.scope-dropdown { position: absolute; bottom: calc(100% + 6px); left: 0; background: var(--bg-white);
  border: 1px solid var(--border-light); border-radius: 10px; padding: 6px 4px; min-width: 160px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1); z-index: 100; }
.scope-dropdown.hidden { display: none; }
.scope-option { display: flex; align-items: center; gap: 8px; padding: 6px 10px; font-size: 12px;
  font-family: 'Plus Jakarta Sans', sans-serif; color: var(--text-primary); cursor: pointer; border-radius: 6px; }
.scope-option:hover { background: var(--bg-cream); }
.scope-option input[type=checkbox] { width: 14px; height: 14px; accent-color: var(--accent-coral); }
.scope-opt-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.scope-opt-dot.gold { background: #D4AF37; }
.scope-opt-dot.silver { background: #A8A8A8; }
.scope-opt-dot.gov { background: #2E7D32; }
.scope-option-full { border-top: 1px solid var(--border-light); margin-top: 2px; padding-top: 8px; }

/* ==================== END SEARCH SCOPE ==================== */

/* ==================== CONNECTORS PAGE ==================== */

.connectors-page { padding: 32px 40px; max-width: 900px; margin: 0 auto; }
.connectors-page.hidden { display: none; }
/* Connectors page — same editorial language as plugins. */
.conn-header { display: flex; align-items: baseline; gap: 14px; margin-bottom: 24px; }
.conn-title {
  font-family: 'Fraunces', 'EB Garamond', Georgia, serif;
  font-style: italic;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.012em;
  color: var(--text-primary);
  font-variation-settings: 'opsz' 60;
}
.conn-count {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  font-weight: 500;
}

/* Filter strip — editorial mono caps with brand-gradient underline. */
.conn-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 22px;
  padding: 0 0 18px;
  border-bottom: 1px solid var(--border-light);
  align-items: baseline;
  position: relative;
}
.conn-tab {
  padding: 0;
  background: transparent;
  border: 0;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: color 0.15s ease;
  position: relative;
  white-space: nowrap;
  border-radius: 0;
}
.conn-tab + .conn-tab { margin-left: 22px; padding-left: 22px; }
.conn-tab + .conn-tab::before {
  content: '/';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-55%);
  color: rgba(26, 15, 5, 0.18);
  font-weight: 400;
}
.conn-tab:hover { color: var(--text-primary); }
.conn-tab.active { color: var(--text-primary); border: 0; font-weight: 500; }
.conn-tab.active::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  bottom: -19px;
  height: 2px;
  background: var(--brand-gradient-rule);
  border-radius: 2px;
}
.conn-tab + .conn-tab.active::after { left: 22px; }

.conn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 22px;
}
.conn-empty {
  padding: 80px 24px;
  text-align: center;
  color: var(--text-tertiary);
  font-family: 'EB Garamond', Georgia, serif;
  font-style: italic;
  font-size: 17px;
  grid-column: 1 / -1;
}

/* Connector card — paper sheet (matches plugin / artifacts plate). */
.connector-card {
  background: #ffffff;
  border: 1px solid rgba(26, 15, 5, 0.08);
  border-radius: 4px;
  overflow: hidden;
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1),
              box-shadow 0.22s ease;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 1px 0 rgba(26, 15, 5, 0.04),
    0 2px 4px rgba(26, 15, 5, 0.04),
    0 8px 18px -8px rgba(26, 15, 5, 0.08);
  position: relative;
}
.connector-card:hover {
  transform: translateY(-2px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 1px 0 rgba(26, 15, 5, 0.06),
    0 4px 10px rgba(26, 15, 5, 0.06),
    0 14px 28px -10px rgba(26, 15, 5, 0.14);
}
/* Drop the heavy coloured top accent — neutralise per-type colours.
 * Brand gradient appears on hover (parallel to plugin treatment). */
.conn-card-accent {
  height: 0;
  background: transparent;
  transition: height 0.22s ease, background 0.22s ease;
}
.connector-card:hover .conn-card-accent {
  height: 3px;
  background: var(--brand-gradient-rule);
}
.accent-mcp,
.accent-composio { background: transparent; }

.conn-card-header { display: flex; align-items: center; gap: 12px; padding: 18px 18px 8px; }
.conn-card-icon { font-size: 22px; line-height: 1; opacity: 0.9; }
.conn-card-info { flex: 1; min-width: 0; }
.conn-card-name {
  font-family: 'Fraunces', 'EB Garamond', serif;
  font-style: italic;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.012em;
  color: var(--text-primary);
  font-variation-settings: 'opsz' 60;
  line-height: 1.2;
}
/* Type badge — single mono-caps register, no per-type colour pills. */
.conn-card-badge {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 0;
  border-radius: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  color: var(--text-tertiary);
}
.conn-card-badge::before {
  content: '';
  width: 5px; height: 5px; border-radius: 50%;
  background: currentColor;
  opacity: 0.55;
}
.conn-badge-mcp { color: #2f5fa6; }
.conn-badge-composio { color: var(--accent-coral-dark, #a87644); }

.conn-card-desc {
  font-family: 'EB Garamond', Georgia, serif;
  font-style: italic;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.45;
  padding: 0 18px 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.conn-card-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px 14px;
  border-top: 1px dotted rgba(26, 15, 5, 0.1);
}
.conn-status-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.conn-status-on   { background: #2f8d4f; }
.conn-status-off  { background: rgba(26, 15, 5, 0.18); }
.conn-status-warn { background: #c4904a; }
.conn-status-text {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  flex: 1;
  font-weight: 500;
}
.conn-config-btn {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: none;
  border: 0;
  cursor: pointer;
  font-weight: 500;
  padding: 0;
  transition: color 0.15s ease;
}
.conn-config-btn:hover { text-decoration: none; color: var(--text-primary); }

/* Toggle switch — brand-teal active state to match plugin toggles. */
.conn-toggle { position: relative; display: inline-block; width: 36px; height: 20px; cursor: pointer; flex-shrink: 0; }
.conn-toggle input { opacity: 0; width: 0; height: 0; }
.conn-toggle-slider { position: absolute; inset: 0; background: rgba(26, 15, 5, 0.18); border-radius: 20px; transition: background 0.2s; }
.conn-toggle-slider::before {
  content: ''; position: absolute; width: 16px; height: 16px;
  left: 2px; top: 2px; background: #fff; border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 2px rgba(26, 15, 5, 0.18);
}
.conn-toggle input:checked + .conn-toggle-slider { background: var(--brand-teal, #1d9a94); }
.conn-toggle input:checked + .conn-toggle-slider::before { transform: translateX(16px); }

/* Detail overlay */
.conn-detail-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 200;
  display: flex; align-items: center; justify-content: center; }
.conn-detail-overlay.hidden { display: none; }
.conn-detail-panel { background: var(--bg-white); border-radius: 16px; width: 480px; max-width: 90vw;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15); overflow: hidden; }
.conn-detail-header { display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 12px; border-bottom: 1px solid var(--border-light); }
.conn-detail-title-row { display: flex; align-items: center; gap: 10px; }
.conn-detail-icon { font-size: 24px; }
.conn-detail-header h2 { font-size: 18px; font-weight: 600; color: var(--text-primary); margin: 0; }
.conn-detail-badge { font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 8px; }
.conn-detail-close { border: none; background: none; cursor: pointer; color: var(--text-tertiary); padding: 4px; }
.conn-detail-close:hover { color: var(--text-primary); }
.conn-detail-body { padding: 20px 24px; }
.conn-form-group { margin-bottom: 14px; }
.conn-form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary);
  margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.5px; }
.conn-form-input { width: 100%; padding: 8px 12px; font-size: 13px; border: 1px solid var(--border-light);
  border-radius: 8px; background: var(--bg-white); font-family: 'Inter', monospace; }
.conn-form-input:focus { outline: none; border-color: var(--accent-coral); }
textarea.conn-form-input { resize: vertical; font-family: 'Monaco', 'Menlo', monospace; font-size: 12px; }
.conn-form-hint { font-size: 12px; color: var(--text-tertiary); line-height: 1.5; margin-top: 8px; }
.conn-form-hint code { background: var(--bg-cream); padding: 1px 5px; border-radius: 4px; font-size: 11px; }
.conn-detail-actions { padding: 12px 24px 20px; display: flex; justify-content: flex-end; }
.conn-save-btn { padding: 8px 20px; font-size: 13px; font-weight: 500; background: var(--accent-coral);
  color: #fff; border: none; border-radius: 8px; cursor: pointer; font-family: 'Plus Jakarta Sans', sans-serif; }
.conn-save-btn:hover { background: var(--accent-coral-dark); }

/* ==================== END CONNECTORS ==================== */

/* ==================== DASHBOARD ==================== */
/* The dashboard is a server-composed "edition": a self-contained, multi-tab
 * full-pager (its own styles + tab script) rendered inside a sandboxed iframe.
 * The app supplies only a slim toolbar and the loading / empty / error states;
 * the rich design lives inside the edition itself. */

.dash-page { padding: 0; width: 100%; box-sizing: border-box; height: 100%;
  display: flex; flex-direction: column; overflow: hidden; background: var(--bg-cream); }
.dash-page.hidden { display: none; }

.dash-header { display: flex; align-items: flex-end; justify-content: space-between;
  gap: 18px; padding: 16px 28px 13px; border-bottom: 1px solid var(--border-light);
  background: var(--bg-white); flex: 0 0 auto; }
.dash-header-label { display: flex; flex-direction: column; gap: 3px; }
.dash-kicker { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 10px;
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent-coral); font-weight: 600; }
.dash-title { font-size: 19px; font-weight: 700; color: var(--text-primary); margin: 0; letter-spacing: -0.01em; }

.dash-header-actions { display: flex; align-items: center; gap: 18px; }
.dash-refresh-hint { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 10.5px;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-tertiary); font-weight: 500; }
.dash-refresh-btn { display: inline-flex; align-items: center; gap: 7px; padding: 6px 14px;
  border: 1px solid var(--border-light); border-radius: 999px; background: transparent;
  color: var(--text-secondary); font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; font-weight: 500;
  cursor: pointer; transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease; }
.dash-refresh-btn:hover { color: var(--text-primary); background: var(--bg-white); border-color: var(--text-tertiary); }
.dash-refresh-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.dash-refresh-btn svg { flex-shrink: 0; opacity: 0.7; }
.dash-refresh-btn:hover svg { opacity: 1; }
.dash-refresh-spinning svg { animation: dashSpin 0.8s linear infinite; }
@keyframes dashSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* Edition mount — owns the single scrollbar; the iframe is autosized to fit. */
.dash-edition { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden;
  background: var(--bg-cream); -webkit-overflow-scrolling: touch; }
.dash-edition-frame { display: block; width: 100%; min-height: 100%; border: 0; background: var(--bg-cream); }

/* States: loading / generating / empty / error. */
.dash-state { max-width: 460px; margin: 13vh auto 0; text-align: center; color: var(--text-secondary); padding: 0 24px; }
.dash-state h2 { font-size: 18px; color: var(--text-primary); margin: 0 0 8px; font-weight: 700; }
.dash-state p { font-size: 13.5px; line-height: 1.62; margin: 0; }
.dash-state-icon { width: 42px; height: 42px; margin: 0 auto 16px; color: var(--accent-coral); opacity: 0.85; display: block; }
.dash-state-spinner { width: 26px; height: 26px; border-radius: 50%; border: 2.5px solid var(--border-light);
  border-top-color: var(--accent-coral); animation: dashSpin 0.8s linear infinite; margin: 0 auto 18px; }
/* ==================== END DASHBOARD ==================== */

/* ==================== BUDGET PROGRESS ==================== */
.budget-progress-page {
  width: 100%;
  height: 100%;
  padding: 0;
  overflow: hidden;
  background: var(--bg-cream);
}
.budget-progress-page.hidden { display: none; }
.budget-progress-iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}
/* ==================== END BUDGET PROGRESS ==================== */



/* ==================== MESSAGE ACTIONS ==================== */

.message-actions { display: flex; gap: 2px; opacity: 0; transition: opacity 0.15s;
  padding: 2px 0; margin-top: 4px; }
.message:hover .message-actions { opacity: 1; }
.action-btn { background: none; border: 1px solid var(--border-light); border-radius: 6px; padding: 4px 6px;
  cursor: pointer; color: var(--text-tertiary); display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; }
.action-btn:hover { color: var(--text-primary); background: var(--bg-cream); border-color: var(--text-tertiary); }
.action-btn-success { color: #22C55E !important; border-color: #22C55E !important; }
.feedback-active-up { color: #22C55E !important; border-color: #22C55E !important; background: rgba(34,197,94,0.08) !important; }
.feedback-active-down { color: #EF4444 !important; border-color: #EF4444 !important; background: rgba(239,68,68,0.08) !important; }

/* ==================== CHAT SIDEBAR ENHANCEMENTS ==================== */

.chat-history-item { position: relative; }
.chat-item-actions { display: flex; gap: 2px; opacity: 0; transition: opacity 0.15s; margin-left: auto; flex-shrink: 0; }
.chat-history-item:hover .chat-item-actions { opacity: 1; }
.chat-action-btn { background: none; border: none; cursor: pointer; color: var(--text-tertiary);
  padding: 2px; border-radius: 4px; display: flex; align-items: center; }
.chat-action-btn:hover { color: var(--text-primary); background: rgba(0,0,0,0.06); }

.pin-indicator { font-size: 10px; flex-shrink: 0; margin-right: 2px; }
.chat-history-item.pinned { background: rgba(184,128,90,0.04); }

.chat-rename-input { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 13px; border: 1px solid var(--accent-coral);
  border-radius: 4px; padding: 2px 6px; width: 100%; background: var(--bg-white); outline: none;
  color: var(--text-primary); }

/* ==================== SEARCH MODAL ==================== */

/* ── Share-via-email modal ──────────────────────────────────────────── */
.share-email-overlay {
  position: fixed; inset: 0;
  background: rgba(26, 15, 5, 0.45);
  backdrop-filter: blur(2px);
  z-index: 500;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 18vh;
  animation: articleFadeIn 0.18s ease;
}
.share-email-overlay.hidden { display: none; }
.share-email-modal {
  background: #fbf7ee;
  border-radius: 14px;
  width: 440px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  font-family: 'Plus Jakarta Sans', sans-serif;
}
.share-email-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #eee9e4;
}
.share-email-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}
.share-email-close {
  background: none; border: none;
  font-size: 20px; color: var(--text-tertiary);
  cursor: pointer; padding: 2px 6px;
  line-height: 1; border-radius: 6px;
}
.share-email-close:hover { background: rgba(0,0,0,0.06); color: var(--text-primary); }
.share-email-body { padding: 16px 20px; }
.share-email-label {
  font-size: 12px;
  font-weight: 600;
  color: #847A70;
  margin-bottom: 8px;
  display: block;
}
.share-email-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
  min-height: 8px;
}
.share-email-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f3eeea;
  border: 1px solid #e8e2db;
  border-radius: 20px;
  padding: 4px 8px 4px 12px;
  font-size: 13px;
  color: var(--text-primary);
}
.share-email-chip-text { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-email-chip-x {
  background: none; border: none;
  font-size: 15px; color: var(--text-tertiary);
  cursor: pointer; padding: 0 2px;
  line-height: 1; border-radius: 50%;
}
.share-email-chip-x:hover { color: var(--text-primary); background: rgba(0,0,0,0.08); }
.share-email-input-row {
  display: flex;
  gap: 8px;
}
.share-email-input {
  flex: 1;
  border: 1px solid #e8e2db;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-primary);
  background: #fff;
  outline: none;
}
.share-email-input:focus { border-color: var(--accent-coral); box-shadow: 0 0 0 2px rgba(192, 139, 92, 0.15); }
.share-email-input::placeholder { color: var(--text-tertiary); }
.share-email-add-btn {
  padding: 8px 14px;
  border: 1px solid #e8e2db;
  border-radius: 8px;
  background: #f3eeea;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
}
.share-email-add-btn:hover { background: #ebe5de; }
.share-email-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid #eee9e4;
}
.share-email-status {
  font-size: 12px;
  color: var(--text-tertiary);
}
.share-email-status--ok { color: #2E6B66; font-weight: 500; }
.share-email-status--err { color: #8C3A30; font-weight: 500; }
.share-email-send-btn {
  padding: 8px 22px;
  border: none;
  border-radius: 8px;
  background: var(--accent-coral);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.share-email-send-btn:hover { background: var(--accent-coral-dark); }
.share-email-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.search-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 400;
  display: flex; align-items: flex-start; justify-content: center; padding-top: 15vh; }
.search-modal { background: var(--bg-white); border-radius: 16px; width: 560px; max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2); overflow: hidden; }
.search-modal-input { width: 100%; border: none; padding: 18px 22px; font-size: 16px;
  font-family: 'Plus Jakarta Sans', sans-serif; outline: none; color: var(--text-primary);
  border-bottom: 1px solid var(--border-light); box-sizing: border-box; }
.search-modal-input::placeholder { color: var(--text-tertiary); }
.search-modal-results { max-height: 50vh; overflow-y: auto; }
.search-result { padding: 12px 22px; cursor: pointer; transition: background 0.1s;
  border-bottom: 1px solid rgba(0,0,0,0.04); }
.search-result:hover { background: var(--bg-cream); }
.search-result-title { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }
.search-result-snippet { font-size: 12px; color: var(--text-secondary); line-height: 1.4;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-hint { padding: 16px 22px; font-size: 13px; color: var(--text-tertiary); text-align: center; }

/* ==================== SETTINGS PAGE ==================== */

.settings-page { padding: 32px 32px 40px; width: 100%; box-sizing: border-box; height: 100%; overflow-y: auto; overflow-x: hidden; }
.settings-page.hidden { display: none; }
/* .settings-header / .settings-title — unified in brand-gradient header block at top */

/* Settings top tabs — editorial filter strip matching artifacts /
 * dashboard / inbox. Mono small-caps with slash separators and a
 * brand-gradient underline on the active tab. */
.settings-tab-bar {
  display: flex;
  gap: 0;
  margin: 0 0 32px;
  padding: 0 0 22px;
  border-bottom: 1px solid var(--border-light);
  align-items: baseline;
  flex-wrap: wrap;
  position: relative;
}
.settings-tab {
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: color 0.15s ease;
  position: relative;
  white-space: nowrap;
  border-radius: 0;
}
.settings-tab + .settings-tab { margin-left: 22px; padding-left: 22px; }
.settings-tab + .settings-tab::before {
  content: '/';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-55%);
  color: rgba(26, 15, 5, 0.18);
  font-weight: 400;
}
.settings-tab:hover { color: var(--text-primary); }
.settings-tab.active { color: var(--text-primary); border: 0; }
.settings-tab.active::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  bottom: -23px;
  height: 2px;
  background: var(--brand-gradient-rule);
  border-radius: 2px;
}
.settings-tab + .settings-tab.active::after { left: 22px; }
.settings-tab-content.hidden { display: none; }

/* Settings tab contents: unified alignment so switching tabs doesn't
 * shift content left/right or change container width. Outer
 * .settings-page (padding: 32px 32px 40px) provides the only horizontal
 * inset; nested pages drop their own padding, max-width, and auto
 * margins so every tab lays out on the same left edge with the same
 * full-width canvas. The .hidden override is critical — these pages
 * carry .hidden from their standalone (non-tab) lifecycle, but inside
 * a settings tab they should always render. */
.settings-tab-content { width: 100%; }
.settings-tab-content .plugins-page,
.settings-tab-content .search-scope-page,
.settings-tab-content .connectors-page,
.settings-tab-content .mcp-page,
.settings-tab-content .credits-page,
.settings-tab-content #settingsMcpTab > * {
  padding: 0 !important;
  margin: 0 !important;
  max-width: none !important;
  height: auto;
  overflow: visible;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}
.settings-tab-content .plugins-page.hidden,
.settings-tab-content .search-scope-page.hidden,
.settings-tab-content .connectors-page.hidden { display: flex !important; }

/* Consistent top spacing on every tab content so the first row of
 * content sits at the same vertical position as the others. */
.settings-tab-content > * { margin-top: 0; }
.settings-tab-content .plugins-page-header,
.settings-tab-content .scope-header,
.settings-tab-content .conn-header,
.settings-tab-content .mcp-status-header { margin-top: 0; padding-top: 0; }

/* MCP status */
.mcp-status-header { margin-bottom: 16px; }
.mcp-status-hint { font-size: 11px; color: var(--text-tertiary); }
.mcp-section-title { font-size: 14px; font-weight: 600; color: var(--text-primary); margin: 20px 0 8px; }

/* MCP server cards */
.mcp-server-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.mcp-server-card { background: var(--bg-white); border: 1px solid var(--border-light); border-radius: 12px;
  padding: 16px 18px; cursor: pointer; transition: all 0.15s; }
.mcp-server-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.07); transform: translateY(-1px); }
.mcp-server-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.mcp-server-name { font-size: 13px; font-weight: 600; color: var(--text-primary); flex: 1; }
.mcp-server-type { font-size: 10px; color: var(--text-tertiary); background: var(--bg-cream);
  padding: 2px 8px; border-radius: 6px; font-family: 'Monaco','Menlo', monospace; }
.mcp-server-status { font-size: 11px; color: var(--text-secondary); margin-bottom: 4px; text-transform: capitalize; }
.mcp-server-config { font-size: 10px; color: var(--text-tertiary); font-family: 'Monaco','Menlo', monospace;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* MCP card enhancements */
.mcp-server-meta { display: flex; gap: 10px; align-items: center; margin-bottom: 4px; }
.mcp-server-port { font-size: 11px; color: var(--text-tertiary); font-family: 'Monaco','Menlo', monospace;
  background: var(--bg-cream); padding: 1px 6px; border-radius: 4px; }
.mcp-server-tool-count { font-size: 11px; color: var(--accent-coral); font-weight: 600; }
.mcp-server-plugin-count { font-size: 10px; color: var(--text-tertiary); }
.mcp-server-plugins { font-size: 10px; color: var(--text-tertiary); margin-top: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* MCP detail overlay tabs */
.mcp-detail-tabs { display: flex; gap: 0; padding: 0 24px; border-bottom: 1px solid var(--border-light); }
.mcp-detail-tab { padding: 10px 18px; font-size: 13px; border: none; background: none;
  cursor: pointer; color: var(--text-tertiary); border-bottom: 2px solid transparent;
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif; transition: all 0.15s; }
.mcp-detail-tab:hover { color: var(--text-primary); }
.mcp-detail-tab.active { color: var(--text-primary); border-bottom-color: var(--accent-coral); font-weight: 600; }

/* MCP detail info grid */
.mcp-detail-info-grid { display: grid; grid-template-columns: 100px 1fr; gap: 6px 16px; margin-bottom: 16px; }
.mcp-detail-label { font-size: 11px; font-weight: 600; color: var(--text-tertiary); text-transform: uppercase;
  letter-spacing: 0.5px; padding-top: 2px; }
.mcp-detail-value { font-size: 13px; color: var(--text-primary); word-break: break-all; }

/* Tools list */
.mcp-tools-list { display: flex; flex-direction: column; }
.mcp-tool-item { padding: 12px 0; border-bottom: 1px solid var(--border-light); }
.mcp-tool-item:last-child { border-bottom: none; }
.mcp-tool-name { font-size: 13px; font-weight: 600; color: var(--text-primary);
  font-family: 'Monaco','Menlo', monospace; }
.mcp-tool-desc { font-size: 12px; color: var(--text-secondary); margin-top: 4px; line-height: 1.5; }
.mcp-tool-params { font-size: 11px; color: var(--text-tertiary); margin-top: 6px;
  font-family: 'Monaco','Menlo', monospace; }
.mcp-tool-try-btn { font-size: 11px; color: var(--accent-coral); border: 1px solid var(--accent-coral);
  background: none; border-radius: 6px; padding: 3px 12px; cursor: pointer; white-space: nowrap; }
.mcp-tool-try-btn:hover { background: var(--accent-coral); color: #fff; }

/* Playground */
.mcp-playground-select { width: 100%; padding: 8px 12px; font-size: 13px;
  border: 1px solid var(--border-light); border-radius: 8px; margin-bottom: 8px;
  background: var(--bg-white); color: var(--text-primary); }
.mcp-playground-editor { width: 100%; min-height: 100px; padding: 10px 12px; font-size: 12px;
  font-family: 'Monaco','Menlo', monospace; border: 1px solid var(--border-light);
  border-radius: 8px; resize: vertical; margin-bottom: 12px; background: var(--bg-cream);
  color: var(--text-primary); line-height: 1.5; box-sizing: border-box; }
.mcp-playground-run { padding: 8px 24px; font-size: 13px; font-weight: 600;
  background: var(--accent-coral); color: #fff; border: none; border-radius: 8px; cursor: pointer;
  transition: all 0.15s; }
.mcp-playground-run:hover { background: var(--accent-coral-dark, #d94f3a); }
.mcp-playground-run:disabled { opacity: 0.5; cursor: not-allowed; }
.mcp-playground-result { margin-top: 16px; padding: 14px; background: var(--bg-cream);
  border-radius: 8px; font-family: 'Monaco','Menlo', monospace; font-size: 12px;
  white-space: pre-wrap; max-height: 350px; overflow-y: auto; line-height: 1.5;
  border: 1px solid var(--border-light); }
.mcp-playground-error { color: #c0392b; }

/* ==================== PROJECTS & MEMORY ==================== */

.projects-page { padding: 40px 32px; width: 100%; box-sizing: border-box; height: 100%; overflow-y: auto; }
.projects-page.hidden { display: none; }
.projects-header { margin-bottom: 32px; }
.projects-title { font-family: 'EB Garamond', Georgia, serif; font-size: 28px; font-weight: 500; margin: 0; }

.projects-section { margin-bottom: 36px; }
.projects-section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px;
  border-bottom: 1px solid var(--border-light); padding-bottom: 8px; }
.projects-section-header h2 { font-family: 'EB Garamond', Georgia, serif; font-size: 20px; font-weight: 500; margin: 0; }
.projects-add-btn { font-size: 12px; font-weight: 600; color: var(--accent-coral); background: none; border: 1px solid var(--accent-coral);
  border-radius: 8px; padding: 5px 14px; cursor: pointer; font-family: 'Plus Jakarta Sans', sans-serif; transition: all 0.15s; }
.projects-add-btn:hover { background: var(--accent-coral); color: #fff; }

.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.project-card { background: var(--bg-white); border: 1px solid var(--border-light); border-radius: 14px;
  padding: 18px 20px; transition: all 0.15s; }
.project-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.06); }
.project-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.project-card-name { font-size: 14px; font-weight: 600; color: var(--text-primary); margin: 0; }
.project-card-instructions { font-size: 12px; color: var(--text-secondary); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.memory-list { display: flex; flex-direction: column; gap: 6px; }
.memory-item { display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: var(--bg-white); border: 1px solid var(--border-light); border-radius: 10px; }
.memory-content { flex: 1; font-size: 13px; color: var(--text-primary); }

/* ==================== RESPONSE STYLE DROPDOWN ==================== */

.style-selector { display: flex; align-items: center; gap: 4px; background: none; border: none;
  cursor: pointer; font-family: 'Plus Jakarta Sans', sans-serif; font-size: 13px; font-weight: 500;
  color: var(--text-secondary); padding: 4px 2px; transition: color 0.15s; }
.style-selector:hover { color: var(--text-primary); }
.style-selector svg { width: 14px; height: 14px; }
.style-label { white-space: nowrap; }
.style-menu { min-width: 200px; }

/* ==================== EXPORT BUTTON ==================== */

.export-btn { background: none; border: none; cursor: pointer; color: var(--text-tertiary);
  padding: 4px; border-radius: 6px; display: flex; align-items: center; transition: all 0.15s; }
.export-btn:hover { color: var(--text-primary); background: var(--bg-cream); }

/* ==================== LOADING SKELETONS ==================== */

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton { background: linear-gradient(90deg, var(--bg-cream) 25%, #e8e6e0 50%, var(--bg-cream) 75%);
  background-size: 200% 100%; animation: shimmer 1.5s ease-in-out infinite; border-radius: 8px; }
.skeleton-line { height: 14px; margin-bottom: 10px; border-radius: 6px; }
.skeleton-line:nth-child(1) { width: 90%; }
.skeleton-line:nth-child(2) { width: 70%; }
.skeleton-line:nth-child(3) { width: 50%; }
.skeleton-block { height: 80px; border-radius: 12px; margin-bottom: 14px; }
.skeleton-card { height: 120px; border-radius: 14px; }

/* ==================== INBOX & SCHEDULED TASKS ==================== */

.inbox-page { padding: 32px 32px 40px; width: 100%; box-sizing: border-box; height: 100%; overflow-y: auto; overflow-x: hidden; }
.inbox-page.hidden { display: none; }
/* .inbox-header / .inbox-title / .inbox-header-count — unified in brand-gradient header block at top */

.inbox-tab-bar { display: flex; gap: 0; margin-bottom: 20px; border-bottom: 1px solid var(--border-light); }
.inbox-tab { padding: 8px 20px; font-size: 13px; font-family: 'Plus Jakarta Sans', sans-serif; border: none; background: none;
  cursor: pointer; color: var(--text-secondary); border-bottom: 2px solid transparent; font-weight: 500; }
.inbox-tab:hover { color: var(--text-primary); }
.inbox-tab.active { color: var(--text-primary); border-bottom-color: var(--accent-coral); }
.inbox-tab-content.hidden { display: none; }

/* Pulse unread badge on the sidebar (expanded state) — numeric coral pill.
   When the sidebar is collapsed the rule below shrinks it to a pulsating
   teal dot. Same treatment is applied to the Automations badge so both
   notifications read identically. */
.inbox-badge {
  background: var(--accent-coral);
  color: #fff;
  border-radius: 10px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  margin-left: auto;
  min-width: 18px;
  text-align: center;
  line-height: 16px;
  box-shadow: 0 0 0 2px rgba(184, 128, 90, 0.18);
  font-variant-numeric: tabular-nums;
  font-family: 'Plus Jakarta Sans', sans-serif;
}
.inbox-badge.hidden { display: none; }

/* Feed */
.inbox-feed { display: flex; flex-direction: column; gap: 6px; }
.inbox-empty { padding: 60px 20px; text-align: center; color: var(--text-tertiary); }
.inbox-empty-hint { font-size: 13px; margin-top: 6px; }

/* Feed — responsive card grid (3 cols on wide, 2 on medium, 1 on narrow) */
.inbox-feed { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 900px) { .inbox-feed { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .inbox-feed { grid-template-columns: 1fr; } }

/* ══════════════════════════════════════════════════════════════════════
 * MAGAZINE INBOX — editorial layout
 *
 * Aesthetic direction: refined editorial — Atlantic / Foreign Affairs.
 * Serif display headlines (Fraunces), mono eyebrows + bylines (JetBrains
 * Mono), Garamond body. Hairline rules over heavy borders. One bold
 * hero piece + a quiet grid of standard cards below — the canonical
 * weekend-edition layout.
 *
 * Scoped under .inbox-magazine so the rest of the app stays on Plus
 * Jakarta Sans.
 * ════════════════════════════════════════════════════════════════════ */

/* Editorial section header sitting above the grid. Sets tone. */
.inbox-magazine-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  padding: 0 0 18px;
  margin: 6px 0 28px;
  border-bottom: 1px solid var(--text-primary);
}
.inbox-magazine-masthead {
  font-family: 'Fraunces', 'EB Garamond', serif;
  font-style: italic;
  font-weight: 500;
  font-size: 30px;
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}
.inbox-magazine-issue {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

/* Grid: 6 columns underneath, hero spans all 6, standard cards span 2.
 * On medium widths, hero spans 2 and standards span 1 (2-up). On narrow,
 * everything stacks. CSS Grid keeps row alignment crisp — masonry
 * looks ragged for editorial. */
.inbox-magazine {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 38px 28px;
  padding: 4px 0 60px;
  background: transparent;
}
@media (max-width: 1100px) {
  .inbox-magazine { grid-template-columns: repeat(2, 1fr); gap: 32px 22px; }
}
@media (max-width: 640px) {
  .inbox-magazine { grid-template-columns: 1fr; gap: 26px; }
}

.magazine-card {
  grid-column: span 2;
  display: flex;
  flex-direction: column;
  background: transparent;
  border: 0;
  border-radius: 0;
  overflow: visible;
  cursor: pointer;
  position: relative;
  transition: transform 0.25s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.magazine-card:hover { transform: translateY(-2px); }
.magazine-card:hover .magazine-card-cover {
  filter: contrast(1.04) saturate(1.05);
}
.magazine-card:hover .magazine-card-title {
  text-decoration: underline;
  text-decoration-color: var(--text-primary);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
}
.magazine-card.unread::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 0;
  width: 2px;
  height: 100%;
  background: var(--accent-coral);
}
@media (max-width: 1100px) {
  .magazine-card { grid-column: span 1; }
  .magazine-card.unread::before { left: -6px; }
}

/* HERO card: spans the full row, lays out as image + text side-by-side
 * with a much larger title. Only the first card gets this treatment. */
.magazine-card.hero {
  grid-column: span 6;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 44px;
  align-items: center;
  padding-bottom: 38px;
  border-bottom: 1px solid var(--border-light);
}
@media (max-width: 1100px) {
  .magazine-card.hero {
    grid-column: span 2;
    grid-template-columns: 1fr;
    gap: 22px;
  }
}
@media (max-width: 640px) {
  .magazine-card.hero { grid-column: span 1; }
}

/* Cover image — clean, square-ish, NO border so the image carries.
 * Background matches the inbox page bg so the image blends fluidly. */
.magazine-card-cover {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  display: block;
  background: var(--bg-cream);
  transition: filter 0.25s ease;
}
.magazine-card.hero .magazine-card-cover {
  aspect-ratio: 5 / 4;
}
.magazine-card-cover-skeleton {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: linear-gradient(110deg, var(--bg-cream) 8%, #f0f1f4 18%, var(--bg-cream) 33%);
  background-size: 200% 100%;
  animation: magazineShimmer 1.8s ease-in-out infinite;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(26, 15, 5, 0.45);
}
.magazine-card.hero .magazine-card-cover-skeleton {
  aspect-ratio: 5 / 4;
}
@keyframes magazineShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.magazine-card-body {
  padding: 18px 0 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.magazine-card.hero .magazine-card-body {
  padding: 0;
  gap: 0;
}

/* Eyebrow — section/category label, tracked-out mono caps. */
.magazine-card-eyebrow {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent-coral-dark, #a87644);
  font-weight: 500;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.magazine-card-eyebrow::after {
  content: '';
  flex: 1;
  max-width: 40px;
  height: 1px;
  background: var(--accent-coral-dark, #a87644);
  opacity: 0.35;
}

/* Title — Fraunces display serif, generous weight, tight leading. */
.magazine-card-title {
  font-family: 'Fraunces', 'EB Garamond', Georgia, serif;
  font-size: 22px;
  font-weight: 500;
  line-height: 1.18;
  letter-spacing: -0.012em;
  margin: 0 0 12px;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  /* Use Fraunces opsz axis for proper display sizing */
  font-variation-settings: 'opsz' 60, 'SOFT' 30;
}
.magazine-card.hero .magazine-card-title {
  font-size: 44px;
  line-height: 1.04;
  letter-spacing: -0.018em;
  font-weight: 500;
  margin-bottom: 18px;
  -webkit-line-clamp: 5;
  font-variation-settings: 'opsz' 144, 'SOFT' 50;
}
@media (max-width: 700px) {
  .magazine-card.hero .magazine-card-title { font-size: 32px; }
}

/* Dek — italic Garamond, the standfirst. */
.magazine-card-dek {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 15.5px;
  line-height: 1.42;
  font-style: italic;
  color: var(--text-secondary);
  margin: 0 0 16px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.magazine-card.hero .magazine-card-dek {
  font-size: 19px;
  line-height: 1.45;
  -webkit-line-clamp: 4;
  margin-bottom: 22px;
  color: var(--text-primary);
  opacity: 0.78;
}

/* Meta line — mono, datestamp + duration. */
.magazine-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  text-transform: uppercase;
  margin-top: 4px;
}
.magazine-card-meta .dot {
  width: 3px; height: 3px; border-radius: 50%;
  background: var(--text-tertiary);
  display: inline-block;
}

/* Action row — Chat / Download. Lighter, mono. */
.magazine-card-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dotted var(--border-light);
}
.magazine-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 0;
  border: 0;
  background: transparent;
  color: var(--text-tertiary);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s ease;
}
.magazine-action-btn + .magazine-action-btn {
  margin-left: 14px;
  padding-left: 14px;
  border-left: 1px solid var(--border-light);
}
.magazine-action-btn:hover { color: var(--text-primary); }
.magazine-action-btn svg { display: block; opacity: 0.7; }
.magazine-action-btn:hover svg { opacity: 1; }

.magazine-card-status-error {
  color: var(--accent-coral-dark, #a87644);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 14px 0 0;
  border-top: 1px dotted var(--border-light);
  margin-top: 14px;
}

/* Magazine card action buttons (Chat / Download) */
.magazine-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
}
.magazine-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-family: inherit;
}
.magazine-action-btn:hover {
  background: var(--bg-cream);
  color: var(--text-primary);
  border-color: var(--text-tertiary);
}
.magazine-action-btn svg { display: block; }

/* ══════════════════════════════════════════════════════════════════════
 * ARTICLE OVERLAY — editorial reader
 *
 * Big-format magazine reader. Backdrop is warm ink (not black) so the
 * cream paper of the panel reads as paper. Hero image bleeds full
 * width. Reading column is narrow on purpose — 640–680px is the
 * established editorial sweet spot. Drop cap, italic dek, mono byline,
 * blockquote pull-quotes — every detail says "considered prose".
 * ════════════════════════════════════════════════════════════════════ */

.article-overlay {
  position: fixed; inset: 0;
  background: rgba(26, 15, 5, 0.62);
  backdrop-filter: blur(2px);
  z-index: 9000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 5vh 24px 4vh;
  animation: articleFadeIn 0.22s ease;
}
.article-overlay.hidden { display: none; }
@keyframes articleFadeIn { from { opacity: 0; } to { opacity: 1; } }

.article-panel {
  background: #fbf7ee;          /* warm cream — feels like paper */
  width: min(1040px, 100%);
  max-height: 90vh;
  border-radius: 4px;            /* magazines aren't rounded */
  overflow: hidden;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.08) inset,
    0 30px 90px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  position: relative;
  animation: articleSlideUp 0.32s cubic-bezier(0.2, 0.7, 0.2, 1);
}
@keyframes articleSlideUp { from { transform: translateY(14px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Sticky top bar with masthead, actions, close. */
.article-panel-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 14px 22px;
  background: rgba(251, 247, 238, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(26, 15, 5, 0.08);
  position: sticky;
  top: 0;
  z-index: 2;
}
.article-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border: 0;
  background: transparent;
  color: var(--text-tertiary);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s ease;
  border-radius: 0;
}
.article-action-btn + .article-action-btn { border-left: 1px solid rgba(26, 15, 5, 0.12); }
.article-action-btn:hover { color: var(--text-primary); }
.article-action-btn svg { display: block; opacity: 0.65; }
.article-action-btn:hover svg { opacity: 1; }
.article-close-btn {
  background: transparent;
  border: 0;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 6px;
  margin-left: 8px;
  border-radius: 0;
  border-left: 1px solid rgba(26, 15, 5, 0.12);
  padding-left: 14px;
}
.article-close-btn:hover { color: var(--text-primary); }

.article-scroll {
  overflow-y: auto;
  flex: 1;
  scroll-behavior: smooth;
}
/* Subtle scrollbar styling so it doesn't break the editorial mood. */
.article-scroll::-webkit-scrollbar { width: 8px; }
.article-scroll::-webkit-scrollbar-thumb { background: rgba(26, 15, 5, 0.18); border-radius: 4px; }
.article-scroll::-webkit-scrollbar-thumb:hover { background: rgba(26, 15, 5, 0.32); }

/* Hero image bleeds full width. Tall-ish for impact.
 * Background matches the overlay panel bg so the image blends fluidly. */
.article-hero {
  width: 100%;
  max-height: 420px;
  aspect-ratio: 21 / 9;
  object-fit: contain;
  display: block;
  background: #fbf7ee;
}

/* Shown when the cover image fails to load — replaces the broken <img>
   with a quiet labelled tile so the panel never silently looks empty. */
.article-hero-skeleton {
  width: 100%;
  aspect-ratio: 21 / 9;
  max-height: 420px;
  background: linear-gradient(135deg, #fbf7ee 0%, #f5efe5 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(20, 30, 80, 0.45);
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.article-content {
  padding: 56px 72px 72px;
  max-width: 820px;
  margin: 0 auto;
  font-family: 'EB Garamond', Georgia, serif;
  color: var(--text-primary);
}
@media (max-width: 700px) {
  .article-content { padding: 38px 26px 50px; }
}

/* EYEBROW — section/category, mono caps with rule on the right */
.article-eyebrow {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--accent-coral-dark, #a87644);
  font-weight: 500;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.article-eyebrow::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--accent-coral-dark, #a87644);
  opacity: 0.3;
}

/* TITLE — display Fraunces, big and confident. */
.article-title {
  font-family: 'Fraunces', 'EB Garamond', Georgia, serif;
  font-size: 46px;
  line-height: 1.05;
  margin: 0 0 22px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  font-variation-settings: 'opsz' 144, 'SOFT' 50;
}
@media (max-width: 700px) { .article-title { font-size: 34px; } }

/* DEK — italic Garamond, the standfirst */
.article-dek {
  font-family: 'EB Garamond', Georgia, serif;
  font-style: italic;
  font-size: 21px;
  line-height: 1.42;
  color: var(--text-secondary);
  margin: 0 0 28px;
  font-weight: 400;
}

/* BYLINE — mono, slightly tracked. Editorial bottom rule. */
.article-byline {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin: 0 0 38px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--text-primary);
  font-weight: 500;
}

/* LEDE — first paragraph after byline, drop cap. */
.article-lede {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 19px;
  line-height: 1.55;
  color: var(--text-primary);
  margin: 0 0 28px;
}
/* Lede drop-cap removed per user feedback ("doesn't look good") — the lede's
   first letter now renders inline like the rest of the paragraph. */

/* BODY — Garamond, generous leading, classic editorial measure */
.article-body {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 18px;
  line-height: 1.62;
  color: var(--text-primary);
}
.article-body p { margin: 0 0 18px; }
.article-body p + p { text-indent: 1.4em; margin-top: -10px; }  /* classic indent on continuing paras */

.article-body h1, .article-body h2, .article-body h3 {
  font-family: 'Fraunces', 'EB Garamond', serif;
  font-weight: 500;
  margin: 38px 0 14px;
  line-height: 1.18;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  font-variation-settings: 'opsz' 60;
}
.article-body h2 { font-size: 26px; padding-top: 14px; border-top: 1px solid rgba(26, 15, 5, 0.12); }
.article-body h3 { font-size: 21px; }

.article-body ul, .article-body ol { padding-left: 22px; margin: 0 0 18px; }
.article-body li { margin-bottom: 8px; }
.article-body li::marker { color: var(--accent-coral-dark, #a87644); }

.article-body a {
  color: var(--text-primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: var(--accent-coral-dark, #a87644);
}
.article-body a:hover { color: var(--accent-coral-dark, #a87644); }

.article-body strong { font-weight: 600; }
.article-body em { font-style: italic; }

/* Tables — bordered, magazine-style with rules not cells */
.article-body table {
  border-collapse: collapse;
  margin: 22px 0;
  width: 100%;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 14px;
  border-top: 2px solid var(--text-primary);
  border-bottom: 2px solid var(--text-primary);
}
.article-body table th, .article-body table td {
  padding: 10px 14px 10px 0;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid rgba(26, 15, 5, 0.12);
}
.article-body table th {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--text-tertiary);
  border-bottom-color: var(--text-primary);
}
.article-body table tr:last-child td { border-bottom: 0; }

/* Blockquote → editorial pull-quote */
.article-body blockquote {
  font-family: 'Fraunces', 'EB Garamond', serif;
  font-style: italic;
  font-weight: 400;
  font-size: 22px;
  line-height: 1.4;
  color: var(--text-primary);
  margin: 28px -10px;
  padding: 22px 28px 22px 32px;
  border-left: 3px solid var(--accent-coral-dark, #a87644);
  position: relative;
}
.article-body blockquote::before {
  content: '\201C';
  position: absolute;
  left: -2px;
  top: -10px;
  font-family: 'Fraunces', serif;
  font-size: 80px;
  line-height: 1;
  color: var(--accent-coral-dark, #a87644);
  opacity: 0.25;
}
.article-body blockquote p { margin: 0; text-indent: 0; }
.article-body blockquote p + p { margin-top: 10px; }

/* Code — quiet monospace inline. Block code uses warm dark. */
.article-body code {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  background: rgba(168, 118, 68, 0.1);
  padding: 1px 6px;
  border-radius: 2px;
  font-size: 0.86em;
  color: var(--accent-coral-dark, #a87644);
}
.article-body pre {
  background: #2a1a0d;
  color: #f5ede0;
  padding: 18px 20px;
  border-radius: 4px;
  overflow-x: auto;
  margin: 22px 0;
  font-size: 13.5px;
  line-height: 1.5;
}
.article-body pre code { background: transparent; color: inherit; padding: 0; }

/* HR → ornamental rule */
.article-body hr {
  border: 0;
  text-align: center;
  margin: 36px 0;
  height: 12px;
}
.article-body hr::before {
  content: '\00a7';   /* section sign — editorial "asterism" alt */
  font-family: 'Fraunces', serif;
  font-size: 18px;
  color: var(--accent-coral-dark, #a87644);
  letter-spacing: 0.5em;
}

/* Run card — vertical card layout */
.inbox-run-card { background: var(--bg-white); border: 1px solid var(--border-light); border-radius: 12px;
  display: flex; flex-direction: column; padding: 0; transition: all 0.15s;
  position: relative; overflow: hidden; }
.inbox-run-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: transparent; transition: background 0.15s; }
.inbox-run-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.07); transform: translateY(-2px); }
.inbox-run-card.unread::before { background: var(--accent-coral); }
.inbox-run-card.unread { background: #fdfcfa; }

/* Card header row */
.inbox-run-card .run-card-top { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; }

/* Status dot */
.run-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.run-dot-ok { background: #22C55E; box-shadow: 0 0 0 3px rgba(34,197,94,0.12); }
.run-dot-fail { background: #EF4444; box-shadow: 0 0 0 3px rgba(239,68,68,0.12); }
.run-dot-running { background: #F59E0B; box-shadow: 0 0 0 3px rgba(245,158,11,0.12); animation: pulse 1.5s infinite; }
.run-dot-off { background: #D1D5DB; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }

/* Card content */
.run-task-name { font-size: 14px; font-weight: 600; color: var(--text-primary); flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-meta { display: flex; align-items: center; gap: 8px; padding: 0 16px 12px; }
.run-duration { font-size: 10px; color: var(--text-tertiary); background: var(--bg-cream);
  padding: 2px 8px; border-radius: 10px; font-weight: 500; font-variant-numeric: tabular-nums; }
.run-time { font-size: 11px; color: var(--text-tertiary); white-space: nowrap; }

/* Actions — bottom bar */
.inbox-run-actions { display: flex; align-items: center; gap: 6px; padding: 10px 16px;
  border-top: 1px solid var(--border-light); margin-top: auto; }
.run-action-btn { font-size: 11px; font-weight: 500; padding: 5px 14px; border-radius: 6px;
  cursor: pointer; font-family: 'Plus Jakarta Sans', sans-serif; transition: all 0.15s; flex: 1; text-align: center; }
.run-view-btn { color: var(--text-primary); background: var(--bg-cream); border: 1px solid var(--border-light); }
.run-view-btn:hover { background: #eae8e3; }
.run-chat-btn { color: #fff; background: var(--accent-coral); border: 1px solid var(--accent-coral); }
.run-chat-btn:hover { background: var(--accent-coral-dark); }
.run-error-hint { font-size: 11px; color: #EF4444; cursor: help; font-weight: 500; padding: 5px 0; }
.run-running-hint { font-size: 11px; color: #F59E0B; font-weight: 500; padding: 5px 0; }

/* Tasks tab */
.tasks-filter-bar { display: flex; gap: 8px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }
.tasks-filter-bar select { padding: 6px 12px; font-size: 12px; border: 1px solid var(--border-light);
  border-radius: 8px; background: var(--bg-white); font-family: 'Plus Jakarta Sans', sans-serif; color: var(--text-primary);
  cursor: pointer; transition: border-color 0.15s; }
.tasks-filter-bar select:hover { border-color: var(--text-tertiary); }
.tasks-filter-bar select:focus { outline: none; border-color: var(--accent-coral); }

.tasks-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 900px) { .tasks-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .tasks-grid { grid-template-columns: 1fr; } }

.task-card { background: var(--bg-white); border: 1px solid var(--border-light); border-radius: 12px;
  display: flex; flex-direction: column; overflow: hidden; position: relative;
  transition: all 0.15s; }
.task-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: transparent; transition: background 0.15s; }
.task-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.07); transform: translateY(-2px); }
.task-card.task-enabled::before { background: #22C55E; }
.task-card.task-disabled { opacity: 0.6; }

.task-card-header { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; }
.task-freq-badge { width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0; }
.freq-daily { background: #3B82F6; }
.freq-weekly { background: #8B5CF6; }
.freq-monthly { background: #F59E0B; }
.freq-quarterly { background: #10B981; }
.freq-annual { background: #EF4444; }
.freq-other { background: #6B7280; }

.task-card-info { flex: 1; min-width: 0; }
.task-card-name { font-size: 13px; font-weight: 600; color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-card-schedule { font-size: 11px; color: var(--text-tertiary); font-family: 'Monaco','Menlo', monospace;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.task-card-prompt { font-size: 11px; color: var(--text-secondary); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  cursor: pointer; border-radius: 6px; padding: 6px 16px; flex: 1; }
.task-card-prompt:hover { background: var(--bg-cream); color: var(--text-primary); }

.task-card-footer { display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-top: 1px solid var(--border-light); margin-top: auto; }
.task-skill-badge { font-size: 10px; background: var(--bg-cream); color: var(--text-secondary); padding: 2px 8px;
  border-radius: 8px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-run-btn { font-size: 11px; color: var(--accent-coral); background: none; border: none; cursor: pointer;
  font-weight: 500; font-family: 'Plus Jakarta Sans', sans-serif; padding: 4px 10px; border-radius: 6px; transition: all 0.15s; }
.task-run-btn:hover { background: rgba(233,119,89,0.08); }

/* Status tab */
.status-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.status-table th { background: var(--bg-cream); font-weight: 600; text-align: left; padding: 8px 12px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary);
  border-bottom: 2px solid var(--border-light); position: sticky; top: 0; }
.status-table td { padding: 8px 12px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
.status-table tbody tr:hover td { background: var(--bg-cream); }
.status-table .run-dot { display: inline-block; vertical-align: middle; margin-right: 6px; }
.status-source-badge { display: inline-block; font-size: 10px; font-weight: 600; letter-spacing: 0.3px;
  padding: 2px 7px; border-radius: 8px; vertical-align: middle; }
.status-source-org  { background: rgba(42,56,153,0.10); color: #2a3899; }
.status-source-mine { background: rgba(233,119,89,0.12); color: var(--accent-coral-dark, #a87644); }

/* Report overlay */
.report-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 300;
  display: flex; align-items: center; justify-content: center; }
.report-overlay.hidden { display: none; }
.report-panel { background: var(--bg-white); border-radius: 16px; width: 800px; max-width: 92vw;
  max-height: 88vh; display: flex; flex-direction: column; box-shadow: 0 12px 48px rgba(0,0,0,0.2); }
.report-panel-header { display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid var(--border-light); flex-shrink: 0; }
.report-panel-title { font-family: 'EB Garamond', Georgia, serif; font-size: 20px; font-weight: 500; margin: 0; }
.report-panel-actions { display: flex; gap: 8px; align-items: center; }
.report-download-btn,.report-close-btn { border: none; background: none; cursor: pointer;
  color: var(--text-tertiary); padding: 4px; border-radius: 6px; display: flex; align-items: center; }
.report-download-btn:hover,.report-close-btn:hover { color: var(--text-primary); background: var(--bg-cream); }
.report-panel-body { flex: 1; overflow-y: auto; padding: 24px 32px 40px;
  font-family: 'Plus Jakarta Sans', sans-serif; font-size: 14px; line-height: 1.7; color: var(--text-primary); }
.report-panel-body h1,.report-panel-body h2,.report-panel-body h3 {
  font-family: 'EB Garamond', Georgia, serif; margin-top: 1.2em; margin-bottom: 0.4em; }
.report-panel-body h1 { font-size: 1.6em; }
.report-panel-body h2 { font-size: 1.3em; }
.report-panel-body table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 13px; }
.report-panel-body th,.report-panel-body td { border: 1px solid var(--border-light); padding: 6px 10px; text-align: left; }
.report-panel-body th { background: var(--bg-cream); font-weight: 600; }
.report-panel-body ul,.report-panel-body ol { padding-left: 1.4em; }
.report-panel-body code { background: var(--bg-cream); padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }
.report-panel-body blockquote { border-left: 3px solid var(--accent-coral); padding-left: 14px;
  color: var(--text-secondary); margin: 1em 0; }

.run-duration { font-size: 10px; color: var(--text-tertiary); background: var(--bg-cream);
  padding: 1px 6px; border-radius: 8px; }

/* ==================== END INBOX ==================== */

/* ==================== SLASH COMMAND AUTOCOMPLETE ==================== */

.slash-autocomplete {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 320px;
  overflow-y: auto;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  z-index: 50;
  display: none;
  padding: 6px;
}
.slash-autocomplete.visible {
  display: block;
  animation: fadeIn 0.12s ease-out;
}
.slash-autocomplete-header {
  padding: 8px 12px 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
}
.slash-autocomplete-item {
  display: flex;
  flex-direction: column;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.1s;
}
.slash-autocomplete-item:hover,
.slash-autocomplete-item.selected {
  background: var(--bg-cream);
}
.slash-autocomplete-item-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.slash-autocomplete-cmd {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-coral);
  font-family: 'Monaco', 'Menlo', monospace;
}
.slash-autocomplete-plugin {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--bg-cream);
  color: var(--text-tertiary);
  font-weight: 500;
}
.slash-autocomplete-desc {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.slash-autocomplete-empty {
  padding: 16px 12px;
  text-align: center;
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ==================== END SLASH COMMAND ==================== */

/* ── Subtle button tooltips ── */

.control-btn.has-tooltip {
  position: relative;
}
.btn-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  white-space: nowrap;
  padding: 5px 10px;
  border-radius: 6px;
  background: var(--text-primary);
  color: var(--bg-white);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 20;
}
.btn-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--text-primary);
}
.control-btn.has-tooltip:hover .btn-tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==================== END AUTO-ROUTE ==================== */

.chat-history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: background 0.12s, color 0.12s;
  margin-bottom: 1px;
}

.chat-history-item:hover {
  background: var(--bg-cream);
  color: var(--text-primary);
}

.chat-history-item.active {
  background: rgba(192, 139, 92, 0.1);
  color: var(--text-primary);
}

.chat-history-item.streaming .chat-title {
  color: var(--accent, #c96442);
}

.streaming-dot {
  width: 6px;
  height: 6px;
  min-width: 6px;
  border-radius: 50%;
  background: var(--accent, #c96442);
  animation: pulse-dot 1.4s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(0.7); }
}

.chat-history-item .chat-title-row {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-history-item .chat-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Live status badges */
.chat-status-badge {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  padding: 1px 6px;
  border-radius: 8px;
  display: inline-block;
  width: fit-content;
}

.chat-status-badge.running {
  background: rgba(192, 139, 92, 0.15);
  color: var(--accent-coral);
  animation: pulse-dot 1.4s ease-in-out infinite;
}

.chat-status-badge.needs-input {
  background: rgba(37, 99, 235, 0.1);
  color: #2563eb;
}

.chat-history-item .delete-chat-btn {
  opacity: 0;
  padding: 4px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s, background 0.15s;
}

.chat-history-item:hover .delete-chat-btn {
  opacity: 1;
}

.chat-history-item .delete-chat-btn:hover {
  background: rgba(0, 0, 0, 0.08);
}

.chat-history-item .delete-chat-btn svg {
  width: 14px;
  height: 14px;
  color: var(--text-tertiary);
}

.chat-history-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
}

.chat-history-item.loading {
  background: rgba(196, 145, 123, 0.08);
}

.chat-loading-icon {
  animation: spin 1.5s linear infinite;
  color: var(--accent-coral);
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ==================== HOME VIEW ==================== */
.home-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px 48px;
  overflow-y: auto;
}

/* Plan Badge */
.plan-badge {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  font-size: 14px;
  box-shadow: var(--shadow-soft);
}

.plan-text {
  color: var(--text-secondary);
}

.separator {
  color: var(--text-tertiary);
}

.upgrade-link {
  color: var(--text-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.upgrade-link:hover {
  color: var(--text-secondary);
}

/* Greeting Section */
.greeting-section {
  margin-bottom: 32px;
}

.greeting {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.asterisk-icon {
  width: 32px;
  height: 32px;
  color: var(--accent-coral);
}

.greeting-text {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 36px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.6px;
  /* Sharper rendering: crisp antialiasing + ligature-aware legibility. */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ==================== INPUT STYLES ==================== */
.input-container {
  width: 100%;
  max-width: 820px;
}

.home-input {
  margin-top: 8px;
}

.input-form {
  width: 100%;
}

.input-wrapper {
  background:
    linear-gradient(135deg, rgba(42, 56, 153, 0.025) 0%, rgba(255, 255, 255, 0) 45%, rgba(29, 154, 148, 0.030) 100%),
    rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  border: 1.5px solid rgba(42, 56, 153, 0.10);
  border-radius: 24px;
  box-shadow:
    0 4px 20px rgba(20, 30, 80, 0.05),
    0 1px 4px rgba(20, 30, 80, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.65);
  overflow: visible;
  position: relative;
  transition: border-color 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
}

.input-wrapper:focus-within {
  border-color: rgba(42, 56, 153, 0.32);
  box-shadow:
    0 6px 26px rgba(42, 56, 153, 0.10),
    0 0 0 4px rgba(42, 56, 153, 0.06),
    0 1px 4px rgba(20, 30, 80, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.message-input {
  width: 100%;
  padding: 20px 24px 12px;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 16px;
  background: transparent;
  color: var(--text-primary);
  resize: none;
  min-height: 24px;
  max-height: 200px;
  overflow-y: auto;
  line-height: 1.5;
}

.message-input::placeholder {
  color: var(--text-tertiary);
}

.input-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px 12px;
  min-width: 0;
}

.left-controls,
.right-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.input-controls .right-controls {
  gap: 30px;
  margin-left: auto;
}

.control-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background 0.18s ease, color 0.18s ease;
}

.control-btn:hover {
  background: rgba(42, 56, 153, 0.06);
  color: var(--brand-indigo);
}

.control-btn svg {
  width: 16px;
  height: 16px;
}

.model-selector {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-secondary);
  transition: background 0.15s;
}

.model-selector:hover {
  background: var(--bg-cream);
}

.model-selector svg {
  width: 16px;
  height: 16px;
}

.provider-selector {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-secondary);
  transition: background 0.15s;
}

.provider-selector:hover {
  background: var(--bg-cream);
}

.provider-selector svg {
  width: 16px;
  height: 16px;
}

.provider-menu {
  min-width: 180px;
}

.send-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--brand-gradient);
  border-radius: 10px;
  cursor: pointer;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(42, 56, 153, 0.28),
              inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.send-btn svg {
  width: 16px;
  height: 16px;
}

.send-btn:hover:not(:disabled) {
  filter: brightness(1.08) saturate(1.05);
  box-shadow: 0 6px 18px rgba(42, 56, 153, 0.35),
              inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.send-btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(42, 56, 153, 0.30);
}

.send-btn:disabled {
  background: var(--border-light);
  color: var(--text-tertiary);
  cursor: not-allowed;
}

.send-btn svg {
  width: 18px;
  height: 18px;
}

.send-btn svg.hidden {
  display: none;
}

.send-btn.streaming {
  background: var(--accent-coral-dark);
}

.send-btn.streaming:hover:not(:disabled) {
  background: var(--accent-coral);
}

/* Hidden file input */
.file-input-hidden {
  display: none;
}

/* Attached files preview */
.attached-files {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 16px 0;
}

.attached-file {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-cream);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.attached-file svg {
  width: 14px;
  height: 14px;
}

.attached-file .remove-file {
  cursor: pointer;
  color: var(--text-tertiary);
  transition: color 0.15s;
}

.attached-file .remove-file:hover {
  color: #c0392b;
}

/* Large-file chips show upload + ingest progress */
.attached-file-large {
  position: relative;
  padding-right: 12px;
  background: linear-gradient(to right, rgba(20, 110, 110, 0.06), var(--bg-cream));
  border: 1px solid rgba(20, 110, 110, 0.18);
}

.attached-file .file-name {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attached-file .file-state {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.attached-file .file-state-uploading {
  background: rgba(20, 110, 110, 0.12);
  color: #146e6e;
}

.attached-file .file-state-processing {
  background: rgba(196, 145, 123, 0.18);
  color: #8a4f30;
}

.attached-file .file-state-ready {
  background: rgba(34, 139, 34, 0.14);
  color: #1f6f1f;
}

.attached-file .file-state-error {
  background: rgba(192, 57, 43, 0.14);
  color: #a23021;
  cursor: help;
}

.attached-file .file-progress {
  width: 100%;
  height: 3px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 2px;
  overflow: hidden;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
}

.attached-file .file-progress-bar {
  height: 100%;
  background: linear-gradient(to right, #146e6e, #1aa0a0);
  transition: width 0.2s ease;
}

.attached-file .file-spinner {
  width: 10px;
  height: 10px;
  border: 1.5px solid rgba(138, 79, 48, 0.3);
  border-top-color: #8a4f30;
  border-radius: 50%;
  animation: file-spin 0.8s linear infinite;
}

@keyframes file-spin {
  to { transform: rotate(360deg); }
}

/* ── Pinned-doc chip strip (above the input) ───────────────────────── */
/* Persists across turns until the user X's a chip off. Source of truth
 * for what the model sees in the [Documents the user has uploaded in
 * this chat] block. Visually distinct from the per-turn .attached-files
 * strip — pinned chips are green-tinged and have a subtle border to
 * signal "this is in your chat scope, not just attached to this send". */
.pinned-docs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 16px 0;
}

.pinned-doc {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 4px 5px 10px;
  background: rgba(34, 139, 34, 0.07);
  border: 1px solid rgba(34, 139, 34, 0.22);
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-secondary);
  max-width: 420px;
  min-width: 0;
}

.pinned-doc svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  color: #1f6f1f;
}

.pinned-doc-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
  flex: 1 1 auto;
  min-width: 80px;
}

.pinned-doc-size {
  font-size: 11px;
  opacity: 0.7;
  flex-shrink: 0;
}

.pinned-doc-x {
  background: transparent;
  border: 0;
  padding: 2px;
  margin-left: 2px;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-tertiary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}

.pinned-doc-x:hover {
  color: #c0392b;
  background: rgba(192, 57, 43, 0.12);
}

.pinned-doc-x svg {
  width: 12px;
  height: 12px;
  color: inherit;
}

/* Status badge inside the pinned-doc chip — surfaces docs-rag ingest
 * state ("Ready · 740p · 917 chunks", "Index failed", "Indexing…", etc.).
 * Mirrors .attached-file .file-state styling but scoped to .pinned-doc
 * so the green-tinged pinned chip background doesn't fight the badge's
 * own state color. The HTML for these spans is emitted by
 * renderPinnedDocs in renderer.js. */
.pinned-doc .pinned-doc-state {
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  letter-spacing: 0.02em;
  flex: 0 1 auto;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pinned-doc .pinned-doc-state-ready {
  background: rgba(34, 139, 34, 0.18);
  color: #1f6f1f;
}

.pinned-doc .pinned-doc-state-processing {
  background: rgba(196, 145, 123, 0.22);
  color: #8a4f30;
}

.pinned-doc .pinned-doc-state-error {
  background: rgba(192, 57, 43, 0.16);
  color: #a23021;
  cursor: help;
}

/* Spinner used inside .pinned-doc-state-processing badges. Mirrors the
 * .attached-file .file-spinner rule so both chip families animate
 * identically while indexing is in flight. */
.pinned-doc .file-spinner {
  width: 9px;
  height: 9px;
  border: 1.5px solid rgba(138, 79, 48, 0.3);
  border-top-color: #8a4f30;
  border-radius: 50%;
  animation: file-spin 0.8s linear infinite;
}

/* Snippet chips — pinned text excerpts created via the precision-edit
 * "Add to chat context" action. Live in the same .pinned-docs strip as
 * doc chips but use an amber tint so users can tell at a glance that
 * a chip is a quoted excerpt (snippet) vs a whole document (doc).
 * Inherits sizing, X button, and hover behavior from .pinned-doc. */
.pinned-doc.pinned-snippet {
  background: rgba(180, 140, 80, 0.10);
  border-color: rgba(180, 140, 80, 0.34);
}

.pinned-doc.pinned-snippet svg {
  color: #8a5a1a;
}

.pinned-doc.pinned-snippet .pinned-doc-name {
  /* Snippet labels can be longer than doc titles since they often
     include a derived preview. Cap the chip width so a single long
     snippet doesn't steal the whole row. */
  max-width: 260px;
}

/* Dropdown Container */
.dropdown-container {
  position: relative;
}

/* Model Selector Button */
.model-selector {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  transition: background 0.15s;
}

.model-selector:hover {
  background: var(--bg-cream);
}

.model-selector svg {
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
}

/* Provider Selector Button */
.provider-selector {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  transition: background 0.15s;
}

.provider-selector:hover {
  background: var(--bg-cream);
}

.provider-selector svg {
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
}

.provider-menu {
  min-width: 180px;
}

/* Dropdown Menu - opens upward since it's at bottom of screen */
.dropdown-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  min-width: 260px;
  max-height: 400px;
  overflow-y: auto;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  padding: 8px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 0.15s, visibility 0.15s, transform 0.15s;
  z-index: 1000;
}

.dropdown-container.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  flex-direction: column;
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.dropdown-item:hover {
  background: var(--bg-cream);
}

.dropdown-item[aria-disabled="true"],
.dropdown-item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.dropdown-item .item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.dropdown-item .item-label {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

.dropdown-item .item-desc {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.dropdown-item .check-icon {
  width: 18px;
  height: 18px;
  color: var(--accent-coral);
  display: none;
}

.dropdown-item.selected .check-icon {
  display: block;
}

.dropdown-item .upgrade-badge {
  font-size: 12px;
  color: var(--accent-coral);
  font-weight: 500;
}

.dropdown-divider {
  height: 1px;
  background: var(--border-light);
  margin: 8px 0;
}

.dropdown-item.more-models {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.dropdown-item.more-models svg {
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
}

/* ==================== CHAT VIEW ==================== */
.chat-view {
  flex: 1;
  display: flex;
  flex-direction: row;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* Chat Header — Glass */
.chat-header {
  padding: 16px 24px;
  border-bottom: 1px solid rgba(216, 216, 208, 0.4);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.chat-title-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  transition: background 0.15s;
}

.chat-title-btn:hover {
  background: rgba(0, 0, 0, 0.04);
}

.chat-title-btn svg {
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
}

/* New Chat Button */
.new-chat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.new-chat-btn:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-primary);
}

.new-chat-btn:active {
  background: rgba(0, 0, 0, 0.08);
}

.new-chat-btn svg {
  width: 18px;
  height: 18px;
}

.chat-view-artifact-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.chat-view-artifact-btn svg {
  width: 18px;
  height: 18px;
}
.chat-view-artifact-btn:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-primary);
}
.chat-view-artifact-btn:active {
  background: rgba(0, 0, 0, 0.08);
}

/* Messages Container */
.messages-container {
  flex: 1 1 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
  padding-bottom: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 24px;
  min-height: 0;
  max-height: 100%;
  background:
    radial-gradient(ellipse at 15% 85%, rgba(184, 128, 90, 0.05) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 15%, rgba(184, 128, 90, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(245, 240, 230, 0.4) 0%, transparent 70%),
    var(--bg-white);
  position: relative;
}

/* Noise grain texture overlay */
.messages-container::before {
  content: '';
  position: fixed;
  inset: 0;
  opacity: 0.025;
  pointer-events: none;
  z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

/* Message Styles — Spring Physics Entry */
@keyframes messageEnter {
  0% { opacity: 0; transform: translateY(16px) scale(0.98); }
  60% { opacity: 1; transform: translateY(-2px) scale(1.001); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.message {
  display: flex;
  animation: messageEnter 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  width: 100%;
  max-width: 820px;
}

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

.message.assistant {
  justify-content: flex-start;
  flex-direction: column;
}

/* User Message — light-coral liquid-glass bubble. Same design language
 * as the validation island: translucent coral primary + 20px backdrop
 * blur with saturation boost, neutral inset highlight + 1px drop
 * shadow for Apple-style depth (no coloured glow). The bubble is
 * inline-block so it shrink-fits short messages, while its parent wrap
 * extends to the message-column edge so the bubble's right edge lands
 * flush with the composer's right edge below. */
.user .message-content {
  background: rgba(251, 234, 219, 0.72);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  padding: 12px 18px;
  border-radius: 20px 20px 6px 20px;
  max-width: 100%;
  display: inline-block;
  align-self: flex-end;
  /* Match god-report artifact body (.artifact-markdown.god-report p) */
  font-family: 'Newsreader', Georgia, serif;
  font-size: 16.5px;
  line-height: 1.7;
  color: #2E281F;
  white-space: pre-wrap;
  word-wrap: break-word;
  border: 1px solid rgba(192, 139, 92, 0.16);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.04),
    0 6px 16px -4px rgba(184, 128, 90, 0.08),
    inset 0 0.5px 0 rgba(255, 255, 255, 0.6);
  transition: box-shadow 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
}

.user .message-content:hover {
  border-color: rgba(192, 139, 92, 0.24);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.05),
    0 8px 20px -4px rgba(184, 128, 90, 0.12),
    inset 0 0.5px 0 rgba(255, 255, 255, 0.7);
  transform: translateY(-1px);
}

/* Assistant Message — match god-report artifact body type */
.assistant .message-content {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 16.5px;
  line-height: 1.7;
  letter-spacing: -0.01em;
  color: #2E281F;
  width: 100%;
  position: relative;
  padding: 4px 0;
  transition: all 0.3s ease;
}

/* Ambient warm glow on hover */
.message.assistant:hover .message-content::before {
  content: '';
  position: absolute;
  inset: -8px -16px;
  background: radial-gradient(ellipse, rgba(184, 128, 90, 0.03) 0%, transparent 70%);
  border-radius: 12px;
  z-index: -1;
  pointer-events: none;
}

.assistant .message-content p {
  margin: 0 0 15px 0;
}

.assistant .message-content p:last-child {
  margin-bottom: 0;
}

/* Thinking Section (Reasoning/Chain of Thought) — Glassmorphism */
.thinking-section {
  background: rgba(245, 242, 237, 0.6);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  border: 1px solid rgba(184, 128, 90, 0.15);
  border-radius: 12px;
  margin-bottom: 16px;
  font-size: 12px;
  color: var(--text-secondary);
  box-shadow:
    0 2px 12px rgba(184, 128, 90, 0.06),
    0 1px 3px rgba(0, 0, 0, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  position: relative;
  overflow: hidden;
}

/* Disable shimmer once streaming is done */
.thinking-section.thinking-complete::after {
  display: none !important;
}

/* Subtle shimmer while collapsed (streaming) */
.thinking-section:not([open])::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: linear-gradient(
    110deg,
    transparent 30%,
    rgba(184, 128, 90, 0.06) 50%,
    transparent 70%);
  animation: thinking-shimmer 2.5s ease-in-out infinite;
  pointer-events: none;
}

@keyframes thinking-shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.thinking-section[open] {
  background: rgba(245, 242, 237, 0.75);
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
}

.thinking-header {
  padding: 10px 16px;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 14.5px;
  font-style: italic;
  font-weight: 400;
  color: #8a6a50;
  letter-spacing: 0.3px;
}

.thinking-header:hover {
  color: var(--accent-coral-dark);
}

.thinking-header::marker {
  color: rgba(184, 128, 90, 0.4);
}

/* Status thinking card — always-visible gold banner during processing */
.status-thinking-card {
  display: flex !important;
  align-items: center;
  padding: 0;
  cursor: default;
}

.status-thinking-card .thinking-header {
  list-style: none;
  cursor: default;
}

/* Hide the native disclosure triangle when there's nothing to expand
   (the pill is a passive status row in that mode). When reasoning
   text lands the renderer drops the data-no-reasoning attr and the
   marker becomes visible — clickable affordance for "expand to read
   the chain-of-thought". */
.status-thinking-card[data-no-reasoning] .thinking-header::marker,
.status-thinking-card[data-no-reasoning] .thinking-header::-webkit-details-marker {
  display: none;
}
.status-thinking-card[data-no-reasoning] .thinking-header {
  cursor: default;
}
.status-thinking-card:not([data-no-reasoning]) .thinking-header {
  cursor: pointer;
}

.thinking-label {
  transition: opacity 0.15s ease;
  /* Single-row label: fill the pill width, ellipsis only when there's
     no more room. Same flex: 1 1 0% + min-width: 0 trick as
     .tool-friendly so the label expands to fill all available space
     and only truncates when the pill actually runs out. */
  flex: 1 1 0%;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thinking-icon {
  font-size: 15px;
  filter: grayscale(0.3);
}

/* Reasoning-trace typography. The model's own thinking is rendered
   in EB Garamond italic — the same serif italic used for in-chat
   prose throughout the app — to read as "thoughtful prose" rather
   than "system text". Font is already loaded by the @import at the
   top of style.css (italic 400+500). 14.5px + 1.75 line-height
   keeps the wall-of-text readable; letter-spacing nudge tightens
   italic strokes that otherwise look loose. */
.thinking-content {
  padding: 14px 20px 18px;
  border-top: 1px solid rgba(184, 128, 90, 0.1);
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 420px;
  overflow-y: auto;
  font-family: 'EB Garamond', 'Iowan Old Style', 'Iowan', 'Palatino Linotype', 'Palatino', Georgia, serif;
  font-style: italic;
  font-size: 14.5px;
  line-height: 1.75;
  letter-spacing: 0.005em;
  color: rgba(15, 23, 42, 0.78);
}

.thinking-content::-webkit-scrollbar { width: 4px; }
.thinking-content::-webkit-scrollbar-track { background: transparent; }
.thinking-content::-webkit-scrollbar-thumb {
  background: rgba(184, 128, 90, 0.2);
  border-radius: 2px;
}
.thinking-content::-webkit-scrollbar-thumb:hover {
  background: rgba(184, 128, 90, 0.35);
}

/* ── Reasoning Trace Card ─────────────────────────────────────────────
 *
 * Post-streaming rich rendering of the model's reasoning + tool calls
 * as a unified timeline card. Per design spec: warm cream/white surface,
 * lavender/teal/terracotta semantic accents, sans for prose, mono for
 * payloads, Tabler-style inline SVGs in tinted circular rails.
 *
 * Replaces the post-streaming .thinking-content block. The streaming
 * "live status" pill (.status-thinking-card) stays unchanged; this
 * card only appears after msg.status === 'complete'.
 */

/* L7 synthesis card — mounted by renderer.js _handleL7SynthesisEvent
   in the assistant message bubble during section + exec-summary writing.
   Visually distinct from the (dark) planner trace card: a lighter, more
   structural panel matching the reasoning-trace-card register, so the
   reader sees "OK, planner is done, now sections are being written". */
.l7-synthesis-card {
  margin: 10px 0 14px;
  border-radius: 12px;
  background: #FFFFFF;
  border: 1px solid #E6E8EE;
  box-shadow: 0 1px 2px rgba(20, 30, 50, 0.04);
  padding: 14px 18px 12px;
  font-variant-numeric: tabular-nums;
}
.l7-synthesis-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}
.l7-synthesis-title {
  font-family: 'Source Serif 4', 'Tiempos Text', 'Georgia', serif;
  font-weight: 700;
  font-size: 15px;
  color: #1E3A5F;
  letter-spacing: -0.005em;
}
.l7-synthesis-sub {
  font-family: 'Inter', 'Plus Jakarta Sans', sans-serif;
  font-weight: 400;
  font-size: 12.5px;
  color: #7C766A;
}
.l7-synthesis-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.l7-synthesis-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: 'Inter', 'Plus Jakarta Sans', sans-serif;
  font-size: 13px;
  line-height: 1.5;
  color: #403B33;
}
.l7-synthesis-icon {
  display: inline-block;
  width: 14px;
  text-align: center;
  font-weight: 700;
  color: #7C766A;
}
.l7-synthesis-row.running .l7-synthesis-icon {
  color: #CE7A3E;
  animation: l7-synth-pulse 1.4s ease-in-out infinite;
}
.l7-synthesis-row.done .l7-synthesis-icon {
  color: #6E9080;
}
.l7-synthesis-row.failed .l7-synthesis-icon {
  color: #B5573B;
}
.l7-synthesis-label {
  flex: 1 1 auto;
  min-width: 0;
}
.l7-synthesis-meta {
  flex: 0 0 auto;
  color: #7C766A;
  font-size: 12px;
  font-weight: 500;
}
.l7-synthesis-row.failed .l7-synthesis-meta {
  color: #B5573B;
}
@keyframes l7-synth-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.reasoning-trace-card {
  /* No outer cream wrapper — sits directly on the chat surface. The
   * inner panel's shadow alone separates it from surrounding prose. */
  margin-top: 14px;
  /* Tabular numerals for all metric displays (latency, token counts) */
  font-variant-numeric: tabular-nums;
}

/* Typography isolation — chat prose uses Newsreader (artifact match);
 * the trace card keeps its original sans/mono register. Without this,
 * header chrome and unscoped descendants inherit editorial serif. */
.assistant .message-content .reasoning-trace-card {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: #5C544D;
  letter-spacing: normal;
}

.reasoning-trace-card[hidden] { display: none; }

.reasoning-trace-card__inner {
  /* The white card itself */
  background: #FFFFFF;
  border-radius: 14px;
  /* Hairline side rules — just enough warm-grey to define the card's
   * left/right edges against the chat surface without re-introducing
   * a full frame. Top/bottom stay clean since the header gradient
   * and footer row already give those edges their own visual weight. */
  border-left: 1px solid rgba(0, 0, 0, 0.06);
  border-right: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  overflow: hidden;
}

/* ── Header chrome ───────────────────────────────────────────────── */

.reasoning-trace-card__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 22px;
  border-bottom: 1px solid rgba(184, 128, 90, 0.15);
  /* Warm gold-cream gradient — carries forward the gold-pill hue from
   * the streaming-status card so the trace card feels like its mature
   * descendant, not a cold replacement. Subtle gold-shimmer overlay
   * matches the legacy `.thinking-section` background tint. */
  background: linear-gradient(
    135deg,
    rgba(245, 232, 210, 0.85) 0%,
    rgba(248, 240, 224, 0.65) 50%,
    rgba(252, 246, 235, 0.55) 100%
  );
  position: relative;
}

.reasoning-trace-card__avatar {
  /* Same DeepInsights logo crop technique as `.tool-icon-disc` and the
   * collapsed left-sidebar toggle: PNG is a lockup (mark + wordmark);
   * scaling auto/100% with left-center anchor crops to just the
   * circular mark on the left. Keeps the chat-wide brand mark
   * consistent across cards. */
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  background-image: url('assets/logo_deepinsights.png');
  background-repeat: no-repeat;
  background-position: left center;
  background-size: auto 100%;
  /* Subtle ring matching the gold hue, reinforces "this is the
   * authoring agent" without competing with the rail icons below */
  box-shadow: 0 0 0 1px rgba(184, 128, 90, 0.18),
              inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

/* Suppress legacy avatar SVG rendering — older code paths injected an
 * inline sparkles glyph; the logo PNG is the new source of truth. */
.reasoning-trace-card__avatar svg { display: none; }

.reasoning-trace-card__identity {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.reasoning-trace-card__title {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  /* Warm dark-taupe — keeps the title readable against the gold tint
   * without going pure-black, matching the chat-wide warm typography. */
  color: #4A3F35;
}

.reasoning-trace-card__subtitle {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.3;
  /* Slightly warmer than the body taupe to harmonise with the gold
   * gradient sitting under it. */
  color: #9C8B7B;
}

/* Chrome items (latency + tokens) inherit the same warm tone so they
 * sit comfortably on the gold tint without looking detached. */
.reasoning-trace-card__chrome-item { color: #9C8B7B; }
.reasoning-trace-card__copy { color: #7A6A58; }
.reasoning-trace-card__copy:hover {
  background: rgba(255, 255, 255, 0.55);
  color: #4A3F35;
}

.reasoning-trace-card__chrome {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.reasoning-trace-card__chrome-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #A89E94;
}

.reasoning-trace-card__chrome-item svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.reasoning-trace-card__copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 0;
  background: transparent;
  color: #847A70;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.reasoning-trace-card__copy:hover {
  background: #FBF6F0;
  color: #3A342E;
}

.reasoning-trace-card__copy svg {
  width: 15px;
  height: 15px;
}

/* Auto-scroll toggle — same chrome footprint as the copy button.
 * data-state="on" (default): cream-tinted background + slight color
 * lift so the user can tell it's the active follow-tail mode.
 * data-state="off": neutral; click to re-enable.
 * The brand cream-orange accent comes through on hover for both. */
.reasoning-trace-card__autoscroll {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 0;
  background: transparent;
  color: #847A70;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.reasoning-trace-card__autoscroll svg {
  width: 15px;
  height: 15px;
}
.reasoning-trace-card__autoscroll:hover {
  background: #FBF6F0;
  color: #3A342E;
}
.reasoning-trace-card__autoscroll[data-state="on"] {
  background: rgba(184, 128, 90, 0.10);
  color: #8B5A3C;
}
.reasoning-trace-card__autoscroll[data-state="on"]:hover {
  background: rgba(184, 128, 90, 0.18);
  color: #6B4530;
}

.reasoning-trace-card__copy.is-copied {
  color: #4A9B92;
}

/* Artifact pill: click-to-open affordance for the turn's primary
 * artifact. Compact rounded pill in the header chrome row, sized to
 * sit alongside the verify badge without crowding the brand block. */
.reasoning-trace-card__artifact-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  border-radius: 14px;
  border: 1px solid rgba(184, 128, 90, 0.25);
  background: rgba(255, 255, 255, 0.6);
  color: #6B5C4D;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  max-width: 360px;
  white-space: nowrap;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.reasoning-trace-card__artifact-pill:hover {
  background: #FFFFFF;
  border-color: rgba(184, 128, 90, 0.45);
  color: #3A342E;
}
.reasoning-trace-card__artifact-pill svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  color: #B8805A;
}
.reasoning-trace-card__artifact-pill-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* Pill strip — dedicated row between the trace card header and body
 * for the turn's status pills (artifact + validation). Decouples pill
 * width from the title row so neither side cramps when labels grow.
 *
 * The strip is its own CSS container (container-type: inline-size +
 * a named container) so the responsive collapse below reacts to the
 * strip's own width, not the viewport's — important because the trace
 * card has its own expand toggle. */
.reasoning-trace-card__pill-strip {
  container-type: inline-size;
  container-name: trace-pills;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 18px 10px;
  border-bottom: 1px solid rgba(184, 128, 90, 0.10);
  background: rgba(255, 250, 244, 0.35);
}

/* Compact — labels truncate harder so two-pill rows still fit cleanly
 * on the standard chat-column width. */
@container trace-pills (max-width: 480px) {
  .reasoning-trace-card__pill-strip .reasoning-trace-card__artifact-pill {
    max-width: 240px;
  }
  .reasoning-trace-card__pill-strip .reasoning-trace-card__verify > span {
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* Icon-only — labels hidden entirely; tooltip on hover (the parent
 * already carries a `title` attribute so this is automatic). Verify
 * badge keeps its coloured background as the state indicator; artifact
 * pill loses the wide max-width since there's no label to bound. */
@container trace-pills (max-width: 240px) {
  .reasoning-trace-card__pill-strip .reasoning-trace-card__artifact-pill-label,
  .reasoning-trace-card__pill-strip .reasoning-trace-card__verify > span {
    display: none;
  }
  .reasoning-trace-card__pill-strip .reasoning-trace-card__artifact-pill {
    max-width: none;
    padding: 4px 6px;
    gap: 0;
  }
  .reasoning-trace-card__pill-strip .reasoning-trace-card__verify {
    padding: 4px 6px;
    gap: 0;
  }
}

/* Fact-verification badge: passive indicator (not a button). Three
 * states — pass (teal), fail/auto-fix (terracotta), unrun (warm grey). */
.reasoning-trace-card__verify {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.reasoning-trace-card__verify svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}
.reasoning-trace-card__verify--pass  { background: #DEF1ED; color: #2E6B66; }
.reasoning-trace-card__verify--fail  { background: #FBE0DC; color: #8C3A30; }
.reasoning-trace-card__verify--unrun { background: #F1ECE4; color: #847A70; }

/* Expand button: now icon-only (replaces the old "Show all N steps"
 * text label). Round pad to match copy button's footprint. */
.reasoning-trace-card__expand--icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 0;
  background: transparent;
  color: #847A70;
  cursor: pointer;
  padding: 0;
  transition: background 120ms ease, color 120ms ease;
}
.reasoning-trace-card__expand--icon:hover {
  background: #FBF6F0;
  color: #3A342E;
}
.reasoning-trace-card__expand--icon svg {
  width: 16px;
  height: 16px;
}

/* ── Body: timeline of steps ─────────────────────────────────────── */

.reasoning-trace-card__body {
  padding: 0 22px;
  /* Bound height with internal scroll on long traces — preserves the
   * card framing instead of stretching the chat. The footer's "Show
   * all" affordance is the explicit expand. */
  max-height: 540px;
  overflow-y: auto;
}

.reasoning-trace-card__body::-webkit-scrollbar { width: 6px; }
.reasoning-trace-card__body::-webkit-scrollbar-track { background: transparent; }
.reasoning-trace-card__body::-webkit-scrollbar-thumb {
  background: #E8DFD3;
  border-radius: 3px;
}

.reasoning-trace-step {
  display: grid;
  grid-template-columns: 40px 1fr;
  padding: 10px 0;
}

.reasoning-trace-step:last-child { padding-bottom: 14px; }

.reasoning-trace-step__rail {
  position: relative;
  display: flex;
  justify-content: center;
}

.reasoning-trace-step__rail-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  flex-shrink: 0;
}

.reasoning-trace-step__rail-icon svg {
  width: 14px;
  height: 14px;
}

.reasoning-trace-step__content {
  padding-left: 16px;
  min-width: 0;        /* allow code-block overflow scroll */
}

.reasoning-trace-step__label-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.reasoning-trace-step__label {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0;
  text-transform: none;
}

.reasoning-trace-step__meta {
  font-size: 11px;
  color: #B8AFA6;
  font-variant-numeric: tabular-nums;
}

.reasoning-trace-step__tool-name {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  color: #847A70;
  font-variant-ligatures: none;
}

/* Thinking step — semantic accent: warm amber */
.reasoning-trace-step--thinking .reasoning-trace-step__rail-icon {
  background: #F5EBE0;
  color: #B8805A;
}
.reasoning-trace-step--thinking .reasoning-trace-step__label { color: #B8805A; }

/* Calling tool step — semantic accent: teal */
.reasoning-trace-step--tool .reasoning-trace-step__rail-icon {
  background: #DEF1ED;
  color: #4A9B92;
}
.reasoning-trace-step--tool .reasoning-trace-step__label { color: #4A9B92; }

/* Result step — semantic accent: terracotta */
.reasoning-trace-step--result .reasoning-trace-step__rail-icon {
  background: #FBE8D6;
  color: #C77A4F;
}
.reasoning-trace-step--result .reasoning-trace-step__label { color: #C77A4F; }

/* Error result — same terracotta family but heavier */
.reasoning-trace-step--result.reasoning-trace-step--error .reasoning-trace-step__rail-icon {
  background: #F7DAC8;
  color: #B0521E;
}
.reasoning-trace-step--result.reasoning-trace-step--error .reasoning-trace-step__label { color: #B0521E; }

/* Body: prose vs code block */

.reasoning-trace-step__prose {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.6;
  color: #5C544D;
  word-wrap: break-word;
  /* Claude-style reasoning prose: warm grays on cream, generous leading,
   * clear vertical rhythm between sections. */
}

/* Beat chat editorial prose inheritance on every markdown descendant. */
.assistant .message-content .reasoning-trace-card .reasoning-trace-step__prose p,
.assistant .message-content .reasoning-trace-card .reasoning-trace-step__prose li,
.assistant .message-content .reasoning-trace-card .reasoning-trace-step__prose strong,
.assistant .message-content .reasoning-trace-card .reasoning-trace-step__prose em,
.assistant .message-content .reasoning-trace-card .reasoning-trace-step__prose span,
.assistant .message-content .reasoning-trace-card .reasoning-trace-step__prose a {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

.reasoning-trace-step__prose p { margin: 0; }
.reasoning-trace-step__prose p + p { margin-top: 8px; }
.reasoning-trace-step__prose ul,
.reasoning-trace-step__prose ol { margin: 4px 0; padding-left: 22px; }
.reasoning-trace-step__prose li { margin: 0; }
/* marked renders "loose" list items as <li><p>...</p></li> when there
 * was a blank line between source items. Without this, the prose's
 * p-margin rule cascades inside list items and every "1. foo / 2. bar"
 * block opens up into a wall of empty space. */
.reasoning-trace-step__prose li > p { margin: 0; }
.reasoning-trace-step__prose li + li { margin-top: 3px; }
.reasoning-trace-step__prose strong { font-weight: 600; color: #3F3934; }
.reasoning-trace-step__prose em { font-style: italic; color: #6F6660; }

/* Headings — Claude-style section markers inside the trace.
 * Smaller-than-default, tighter top margin, warm dark color. */
.reasoning-trace-step__prose h1,
.reasoning-trace-step__prose h2,
.reasoning-trace-step__prose h3,
.reasoning-trace-step__prose h4,
.reasoning-trace-step__prose h5,
.reasoning-trace-step__prose h6 {
  font-family: inherit;
  font-weight: 600;
  color: #3F3934;
  margin: 14px 0 4px;
  line-height: 1.35;
  letter-spacing: -0.005em;
}
.reasoning-trace-step__prose h1 { font-size: 16px; }
.reasoning-trace-step__prose h2 { font-size: 15px; }
.reasoning-trace-step__prose h3 { font-size: 14.5px; }
.reasoning-trace-step__prose h4,
.reasoning-trace-step__prose h5,
.reasoning-trace-step__prose h6 {
  font-size: 13.5px;
  color: #6F6660;
  text-transform: none;
  letter-spacing: 0;
}
/* First heading at the top of the body shouldn't push down. */
.reasoning-trace-step__prose > h1:first-child,
.reasoning-trace-step__prose > h2:first-child,
.reasoning-trace-step__prose > h3:first-child,
.reasoning-trace-step__prose > h4:first-child,
.reasoning-trace-step__prose > h5:first-child,
.reasoning-trace-step__prose > h6:first-child {
  margin-top: 0;
}

/* Blockquotes — used by some thinking models for emphasised passages.
 * Left rail in the brand cream-orange, soft indent. */
.reasoning-trace-step__prose blockquote {
  margin: 8px 0;
  padding: 4px 12px;
  border-left: 2px solid #B8805A;
  background: rgba(184, 128, 90, 0.05);
  border-radius: 4px;
  color: #5C544D;
}
.reasoning-trace-step__prose blockquote p { margin: 0; }

/* Horizontal rule — Claude uses these to separate reasoning sub-sections.
 * Hairline in the same hue as the cream paper border so it reads as a
 * structural divider rather than a visual interrupt. */
.reasoning-trace-step__prose hr {
  border: 0;
  height: 1px;
  background: #EAE2D6;
  margin: 12px 0;
}

/* Links inside the prose (e.g. URLs the planner emits in reasoning) —
 * subdued so they don't compete with bold figures. */
.reasoning-trace-step__prose a {
  color: #8B5A3C;
  text-decoration: underline;
  text-decoration-color: rgba(139, 90, 60, 0.35);
  text-underline-offset: 2px;
}
.reasoning-trace-step__prose a:hover {
  text-decoration-color: rgba(139, 90, 60, 0.7);
}

/* Multi-line code block (from triple-backtick fences in the thinking
 * blob — slot-ledger XML, JSON dumps, etc.). Same cream-inset look as
 * the tool input/output panels so the trace reads as one surface.
 * Doubled-class selector beats the global `.message-content pre` rule
 * (dark slate fill); without it, fences in the trace inherit the
 * chat-prose code style and break the cream-paper aesthetic. */
.reasoning-trace-step__prose.reasoning-trace-step__prose pre {
  background: #FBF6F0;
  border: 1px solid #F1ECE4;
  border-radius: 10px;
  padding: 10px 12px;
  margin: 6px 0;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.5;
  color: #5C544D;
  /* `pre-wrap` keeps newlines + spaces visible (real code structure)
   * while letting long lines wrap inside the trace card width. Paired
   * with `word-break: break-word` so unbroken URLs / identifiers still
   * wrap rather than overflowing. `overflow-wrap: anywhere` is the
   * modern, more aggressive sibling. Previously this used
   * `white-space: pre` + `overflow-x: auto`, which made every code
   * block clip its right edge inside the narrow card column. */
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.reasoning-trace-step__prose.reasoning-trace-step__prose pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: inherit;
  font-family: inherit;
  border-radius: 0;
}

/* Inline code pill (mono identifier inside sans prose) */
.reasoning-trace-step__prose code {
  background: #DEF1ED;
  color: #4A9B92;
  padding: 2px 7px;
  border-radius: 5px;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
  font-variant-ligatures: none;
}

/* Mono code block (tool inputs / outputs / structured content).
 * Doubled-up class selector to outweigh the more general
 * `.message-content pre` rule (which sets a dark slate code-block fill
 * for prose code blocks). The trace card uses a cream inset instead. */
.reasoning-trace-step__code.reasoning-trace-step__code {
  background: #FBF6F0;
  border: 1px solid #F1ECE4;
  border-radius: 10px;
  padding: 12px 14px;
  margin: 0;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
  font-weight: 400;
  line-height: 1.65;
  color: #5C544D;
  font-variant-ligatures: none;
  overflow-x: auto;
  white-space: pre;       /* horizontal scroll instead of wrap */
  box-shadow: none;
}

/* Code-block syntax tinting — applied via spans the JS renderer adds
 * to JSON-shaped payloads. Plain string content stays default colored. */
.reasoning-trace-step__code .tok-punct { color: #A89E94; }
.reasoning-trace-step__code .tok-key   { color: #8B7355; }
.reasoning-trace-step__code .tok-str   { color: #C77A4F; }
.reasoning-trace-step__code .tok-num   { color: #4A9B92; }
.reasoning-trace-step__code .tok-bool  { color: #4A9B92; }
.reasoning-trace-step__code .tok-null  { color: #A89E94; }

/* ── Footer chrome ───────────────────────────────────────────────── */

.reasoning-trace-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 22px;
  border-top: 1px solid #F1ECE4;
  background: #FBF6F0;
  font-size: 12px;
  color: #A89E94;
}

/* ──────────────────────────────────────────────────────────────────────
 * Phase blocks inside the planner reasoning card — design pass.
 *
 * Design principles applied here:
 *   1. Two-tone ink palette: primary #1F1B17 (warm near-black), secondary
 *      #5C5048 (taupe), muted #8C7B6A. No mid-grays.
 *   2. Phase-accent variables drive dot, rail, code chip, bullet, strong.
 *   3. Vertical rhythm on 4px grid; status row 26px tall, body 1.6 lh.
 *   4. Monospace + tabular-nums for every metric / slot_id / count.
 *   5. Subtle elevation: card has hairline border only, no shadow noise.
 *   6. Lists get custom accent-color bullets (no browser default disc).
 *   7. Code chips: phase-tinted background, no border, mono.
 *   8. Soft fade-in on new phase blocks (no flash on streaming append).
 *   9. Pulse is symmetric & gentle: scale 1→1.35, opacity 1→0.55.
 * ────────────────────────────────────────────────────────────────────── */

:root {
  --rt-ink-primary: #1F1B17;
  --rt-ink-secondary: #5C5048;
  --rt-ink-muted: #8C7B6A;
  --rt-divider: #F2ECE3;
  --rt-divider-hairline: #EAE2D6;
}

.rtcard__phase {
  --phase-accent: #8C7B6A;
  --phase-accent-soft: rgba(140, 123, 106, 0.10);
  --phase-accent-tint: rgba(140, 123, 106, 0.05);
  position: relative;
  padding: 16px 24px;
  border-top: 1px solid var(--rt-divider);
  /* Fade-in animation only fires on NEW phase blocks (when JS sets
   * data-fresh="1" via partial-DOM update). Pre-existing blocks that
   * re-render don't re-animate — eliminates the flash/jitter the user
   * was seeing during streaming. */
}
.rtcard__phase[data-fresh="1"] {
  animation: rtcard-phase-fadein 220ms ease-out;
}
.rtcard__phase:first-child { border-top: 0; }

.rtcard__phase[data-phase="planning"] {
  --phase-accent: #B27A3E;
  --phase-accent-soft: rgba(178, 122, 62, 0.11);
  --phase-accent-tint: rgba(178, 122, 62, 0.045);
}
.rtcard__phase[data-phase="retrieval"] {
  --phase-accent: #2E8A82;
  --phase-accent-soft: rgba(46, 138, 130, 0.11);
  --phase-accent-tint: rgba(46, 138, 130, 0.045);
}
.rtcard__phase[data-phase="fact-registry"] {
  --phase-accent: #6F4FAE;
  --phase-accent-soft: rgba(111, 79, 174, 0.11);
  --phase-accent-tint: rgba(111, 79, 174, 0.045);
}

/* ── Status row ────────────────────────────────────────────────────── */
.rtcard__phase-status {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  min-height: 22px;
}
.rtcard__phase-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--phase-accent);
  flex-shrink: 0;
  box-shadow:
    0 0 0 2px #FFFFFF,
    0 0 0 3px var(--phase-accent);
  position: relative;
}
.rtcard__phase-name {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.005em;
  color: var(--rt-ink-primary);
  flex-shrink: 0;
}
.rtcard__phase-summary {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--rt-ink-secondary);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rtcard__phase-time {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--phase-accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.005em;
  flex-shrink: 0;
  padding: 3px 7px;
  background: var(--phase-accent-soft);
  border-radius: 999px;
  line-height: 1;
}

/* ── Body container ────────────────────────────────────────────────── */
.rtcard__phase-body {
  padding: 4px 0 0 17px;
  border-left: 2px solid var(--phase-accent-soft);
  margin-left: 3px;
  position: relative;
}
.rtcard__phase-block + .rtcard__phase-block {
  border-top: 1px solid var(--rt-divider-hairline);
  margin-top: 12px;
  padding-top: 12px;
}
.rtcard__phase-block-label {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--phase-accent);
  margin-bottom: 6px;
  display: inline-block;
  padding: 2px 8px;
  background: var(--phase-accent-soft);
  border-radius: 999px;
}

/* ── Prose body — the core typography ──────────────────────────────── */
/*
 * Specificity bump: `.reasoning-trace-card .rtcard__phase-block-prose`
 * (0,2,0) beats `.assistant .message-content` (0,2,0) via later
 * cascade order, AND we set explicit font-size on every descendant
 * markdown element so inheritance can't be intercepted by an
 * intermediate `.markdown-content p` / `.assistant .message-content p`
 * rule defined elsewhere. Without this, subagent bodies (which marked
 * renders as `<ul><li><p><strong>` chains) inherited 15-22px from
 * upstream chat-bubble rules and read as "headings" — the user
 * reported "subagent reasoning trace not in right format".
 */
.reasoning-trace-card .rtcard__phase-block-prose {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  font-size: 13px;
  line-height: 1.65;
  color: var(--rt-ink-primary);
  letter-spacing: -0.005em;
  font-variant-numeric: tabular-nums;
}
.reasoning-trace-card .rtcard__phase-block-prose p,
.reasoning-trace-card .rtcard__phase-block-prose li,
.reasoning-trace-card .rtcard__phase-block-prose strong,
.reasoning-trace-card .rtcard__phase-block-prose em,
.reasoning-trace-card .rtcard__phase-block-prose span,
.reasoning-trace-card .rtcard__phase-block-prose a {
  font-size: 13px;
  line-height: 1.65;
}
.reasoning-trace-card .rtcard__phase-block-prose p {
  margin: 0 0 8px 0;
}
.reasoning-trace-card .rtcard__phase-block-prose p:last-child { margin-bottom: 0; }
/* Drop any heading sizing inside the phase prose — marked may produce
 * <h*> from `**Bold**` runs on their own line in some configs, and we
 * never want a heading-style size jump inside the reasoning card. */
.reasoning-trace-card .rtcard__phase-block-prose h1,
.reasoning-trace-card .rtcard__phase-block-prose h2,
.reasoning-trace-card .rtcard__phase-block-prose h3,
.reasoning-trace-card .rtcard__phase-block-prose h4,
.reasoning-trace-card .rtcard__phase-block-prose h5,
.reasoning-trace-card .rtcard__phase-block-prose h6 {
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -0.012em;
  line-height: 1.35;
  margin: 12px 0 5px 0;
  padding: 0 0 2px 0;
  color: var(--rt-ink-primary);
  position: relative;
  /* Faint phase-accent hairline under the heading, signals hierarchy
   * without a heavy weight bump. Matches Claude/Anthropic's quiet
   * section-divider style. */
  border-bottom: 1px solid var(--phase-accent-soft);
}
/* h1 is rarely used inside the trace; treat any explicit heading the
 * same way regardless of level — they're all section beats. */
.reasoning-trace-card .rtcard__phase-block-prose h4,
.reasoning-trace-card .rtcard__phase-block-prose h5,
.reasoning-trace-card .rtcard__phase-block-prose h6 {
  font-size: 13px;
}
/* First heading in a phase body sits flush — no top margin doubling
 * with the phase-block padding above it. */
.reasoning-trace-card .rtcard__phase-block-prose > h1:first-child,
.reasoning-trace-card .rtcard__phase-block-prose > h2:first-child,
.reasoning-trace-card .rtcard__phase-block-prose > h3:first-child,
.reasoning-trace-card .rtcard__phase-block-prose > h4:first-child,
.reasoning-trace-card .rtcard__phase-block-prose > h5:first-child,
.reasoning-trace-card .rtcard__phase-block-prose > h6:first-child {
  margin-top: 0;
}
/* Loose-list paragraphs: marked wraps <li> content in <p> when blank
 * lines separate items (which _autoBreakInlineLists triggers for
 * `**Title:**` runs). Without this rule the `p` rule above adds an 8px
 * bottom margin between every list item, blowing up the vertical rhythm. */
.reasoning-trace-card .rtcard__phase-block-prose li > p {
  margin: 0;
}

/* Strong = the reasoning card's primary "this is important" affordance.
 * Anthropic / Claude style: weight + size bump only, no background
 * highlighter. The marker-pen treatment read as a brown shadow band
 * behind every bold run; removed per user feedback. Emphasis now
 * comes from weight 700 + slightly larger size + tabular-nums on
 * numeric content — clean and surgical. */
.reasoning-trace-card .rtcard__phase-block-prose strong {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--rt-ink-primary);
  letter-spacing: -0.008em;
  font-variant-numeric: tabular-nums;
}

.reasoning-trace-card .rtcard__phase-block-prose em {
  font-style: italic;
  color: var(--rt-ink-secondary);
  /* Slightly deeper than primary-italic so qualifying / hedging text
   * recedes — emphasis stays with strong, not em. */
}

/* Inline code chips — phase-tinted, monospace, no border. The slot IDs,
 * source names, and indicator codes that appear all over reasoning text
 * become little glanceable pills. Bumped contrast vs the prior version:
 * border + slightly stronger bg so a `code` chip reads as a distinct
 * affordance, not a tinted run of text. */
.reasoning-trace-card .rtcard__phase-block-prose code {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  font-weight: 500;
  padding: 1.5px 7px;
  background: var(--phase-accent-soft);
  border: 1px solid var(--phase-accent-soft);
  border-radius: 4px;
  color: var(--phase-accent);
  letter-spacing: -0.01em;
  word-break: break-all;
}

/* Callout paragraphs — the writer's conclusion / next-step / warning
 * lines. Detected via `:has()` on a leading marker character (→ ✓ ⚠ ▸
 * 🔑). Left accent bar + tinted bg lifts these out of the flow so the
 * reader's eye lands on the "what does it mean" beats first. */
.reasoning-trace-card .rtcard__phase-block-prose p:has(> strong:first-child),
.reasoning-trace-card .rtcard__phase-block-prose p.rt-callout {
  /* Reset — only the marker-prefixed paragraphs (below) get the bar. */
}
.reasoning-trace-card .rtcard__phase-block-prose p {
  /* Detect leading marker via :has-like trick. CSS can't read text
   * content directly, but we can match leading characters using a
   * sibling combinator with a generated content trick. Simpler: rely
   * on the writer / renderer wrapping callouts in a known class
   * (.rt-callout) when emitting markdown. CSS for that class below. */
}
.reasoning-trace-card .rtcard__phase-block-prose .rt-callout,
.reasoning-trace-card .rtcard__phase-block-prose p:where(
  [data-leading="arrow"], [data-leading="check"], [data-leading="warn"], [data-leading="key"]
) {
  margin: 6px 0;
  padding: 6px 10px 6px 12px;
  border-left: 3px solid var(--phase-accent);
  background: var(--phase-accent-tint);
  border-radius: 0 4px 4px 0;
}

/* Numeric token pill — wraps key numeric values inline when the prose
 * carries them (currency, percentages, indicator levels). The DOM walk
 * in decorateProseHighlights (renderer.js) adds the class to text-node
 * ranges matching the numeric pattern, skipping content already inside
 * <code> / <a> / <strong>. Applies inside BOTH the planner-card phase
 * prose AND the persistent reasoning-trace-step prose. */
.reasoning-trace-card .rtcard__phase-block-prose .rt-num,
.reasoning-trace-card .reasoning-trace-step__prose .rt-num {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--phase-accent, #B27A3E);
  letter-spacing: -0.005em;
}

/* Persistent reasoning-trace step prose — extends the planner-card
 * phase-prose typography rules to the post-streaming reasoning trace
 * card. Same emphasis hierarchy so the user sees consistent treatment
 * for **strong** / `code` / callouts wherever the model's reasoning
 * surfaces. */
.reasoning-trace-card .reasoning-trace-step__prose strong {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--rt-ink-primary);
  letter-spacing: -0.008em;
  font-variant-numeric: tabular-nums;
}
.reasoning-trace-card .reasoning-trace-step__prose code {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  font-weight: 500;
  padding: 1.5px 7px;
  background: rgba(178, 122, 62, 0.11);
  border: 1px solid rgba(178, 122, 62, 0.11);
  border-radius: 4px;
  color: #B27A3E;
  letter-spacing: -0.01em;
  word-break: break-all;
}
.reasoning-trace-card .reasoning-trace-step__prose .rt-callout,
.reasoning-trace-card .reasoning-trace-step__prose p:where(
  [data-leading="arrow"], [data-leading="check"], [data-leading="warn"], [data-leading="key"]
) {
  margin: 6px 0;
  padding: 6px 10px 6px 12px;
  border-left: 3px solid #B27A3E;
  background: rgba(178, 122, 62, 0.045);
  border-radius: 0 4px 4px 0;
}
.reasoning-trace-card .reasoning-trace-step__prose h1,
.reasoning-trace-card .reasoning-trace-step__prose h2,
.reasoning-trace-card .reasoning-trace-step__prose h3,
.reasoning-trace-card .reasoning-trace-step__prose h4,
.reasoning-trace-card .reasoning-trace-step__prose h5,
.reasoning-trace-card .reasoning-trace-step__prose h6 {
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -0.012em;
  line-height: 1.35;
  margin: 12px 0 5px 0;
  padding: 0 0 2px 0;
  color: var(--rt-ink-primary);
  border-bottom: 1px solid rgba(178, 122, 62, 0.11);
}

/* Hyperlinks inside reasoning prose — phase-tinted underline, no
 * default blue. Makes the URL chain stay quiet visually until hover. */
.reasoning-trace-card .rtcard__phase-block-prose a {
  color: var(--phase-accent);
  text-decoration: underline;
  text-decoration-color: var(--phase-accent-soft);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  font-weight: 500;
}
.reasoning-trace-card .rtcard__phase-block-prose a:hover {
  text-decoration-color: var(--phase-accent);
}

/* Lists — custom accent bullets, tight spacing, indented from the rail. */
.reasoning-trace-card .rtcard__phase-block-prose ul,
.reasoning-trace-card .rtcard__phase-block-prose ol {
  margin: 6px 0 8px 0;
  padding: 0;
  list-style: none;
}
.reasoning-trace-card .rtcard__phase-block-prose li {
  position: relative;
  margin: 0;
  padding: 2px 0 2px 16px;
  line-height: 1.55;
  font-size: 13px;
}
.reasoning-trace-card .rtcard__phase-block-prose ul > li::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 11px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--phase-accent);
  opacity: 0.7;
}
.reasoning-trace-card .rtcard__phase-block-prose ol {
  counter-reset: rt-prose-ol;
}
.reasoning-trace-card .rtcard__phase-block-prose ol > li {
  padding-left: 22px;
  counter-increment: rt-prose-ol;
}
.reasoning-trace-card .rtcard__phase-block-prose ol > li::before {
  content: counter(rt-prose-ol) ".";
  position: absolute;
  left: 0;
  top: 2px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--phase-accent);
  font-variant-numeric: tabular-nums;
}
.reasoning-trace-card .rtcard__phase-block-prose li > ul,
.reasoning-trace-card .rtcard__phase-block-prose li > ol {
  margin: 2px 0 2px 0;
}

/* Pre / blockquote (rare but worth styling for excerpts). */
.reasoning-trace-card .rtcard__phase-block-prose pre {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  background: var(--phase-accent-tint);
  border-left: 2px solid var(--phase-accent);
  padding: 8px 12px;
  border-radius: 0 6px 6px 0;
  margin: 6px 0;
  color: var(--rt-ink-primary);
  overflow-x: auto;
}
.reasoning-trace-card .rtcard__phase-block-prose pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}
.reasoning-trace-card .rtcard__phase-block-prose blockquote {
  margin: 8px 0;
  padding: 4px 14px;
  border-left: 3px solid var(--phase-accent);
  color: var(--rt-ink-secondary);
  font-style: italic;
}

/* ── State variants ────────────────────────────────────────────────── */
.rtcard__phase.is-active .rtcard__phase-dot {
  animation: rtcard-phase-pulse 1.8s ease-in-out infinite;
}
.rtcard__phase.is-done .rtcard__phase-name {
  color: var(--rt-ink-primary);
}

@keyframes rtcard-phase-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.35); opacity: 0.55; }
}
@keyframes rtcard-phase-fadein {
  from { opacity: 0; transform: translateY(2px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Semantic merge widget ──────────────────────────────────────────────
 * Replaces the raw `#### Semantic merge / *Clustering N extracted facts
 * by identity.*` marker the server emits during slot induction. The
 * widget shows the merge as small colored pills appearing in 2-3-pill
 * clusters with a staggered fade-in, so the user sees the clustering
 * happen instead of reading a flat line of text.
 *
 * Lives inside .rtcard__phase[data-phase="fact-registry"], so its
 * surroundings are lavender. The pills cycle through the warm palette
 * (gold / teal / lavender / slate) for variety against that backdrop.
 * The widget never carries data on its own — the count at the top is
 * the truth, the pills are decorative texture for the merge moment.
 */
.sem-merge-widget {
  margin: 4px 0 10px 0;
  padding: 10px 12px 11px 12px;
  background: var(--phase-accent-tint);
  border: 1px solid var(--phase-accent-soft);
  border-radius: 8px;
}
.sem-merge-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}
.sem-merge-title {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--phase-accent);
}
.sem-merge-count {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--rt-ink-secondary);
  letter-spacing: -0.005em;
}
.sem-merge-body {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 6px;
  align-items: center;
  margin: 2px 0 8px 0;
}
.sem-merge-pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  /* User spec: "full names pill". Slot IDs can be long
   * (tata_motors_consolidated.fy26q3.consolidated_revenue.yoy_growth)
   * — render verbatim. white-space: normal lets the pill wrap onto
   * a second line on narrow viewports rather than truncate; the
   * widget already wraps to multiple rows so taller pills are fine.
   * max-width caps the pill at the widget width so a single
   * pathologically-long slot_id can't push the layout sideways. */
  white-space: normal;
  word-break: break-all;
  max-width: 100%;
  line-height: 1.3;
  /* Faint tone backdrop + matching deeper-tone text so each pill
   * reads as one of the four warm palette accents without shouting. */
  background: rgba(140, 123, 106, 0.16);
  color: #5C5048;
  border: 1px solid rgba(140, 123, 106, 0.32);
  /* Per-pill stagger fade-in. `backwards` keeps the pill invisible
   * until its delay elapses, so a fresh widget render reads as
   * pills appearing one after another rather than a wall popping in. */
  opacity: 0;
  animation: sem-merge-pill-in 320ms ease-out forwards;
  animation-delay: var(--pill-delay, 0s);
}
.sem-merge-pill[data-tone="gold"] {
  background: rgba(178, 122, 62, 0.14);
  color: #7A4F1F;
  border-color: rgba(178, 122, 62, 0.42);
}
.sem-merge-pill[data-tone="teal"] {
  background: rgba(46, 138, 130, 0.13);
  color: #1F635D;
  border-color: rgba(46, 138, 130, 0.42);
}
.sem-merge-pill[data-tone="lavender"] {
  background: rgba(111, 79, 174, 0.13);
  color: #4F3380;
  border-color: rgba(111, 79, 174, 0.42);
}
.sem-merge-pill[data-tone="slate"] {
  background: rgba(140, 123, 106, 0.14);
  color: #5C5048;
  border-color: rgba(140, 123, 106, 0.42);
}

/* Skeleton state — when no slots have landed yet. Narrower, no text,
 * gentle ping while waiting for the merge LLM to return. */
.sem-merge-pill--skeleton {
  width: 28px;
  height: 10px;
  padding: 0;
  border: none;
  animation:
    sem-merge-pill-in 320ms ease-out forwards,
    sem-merge-pill-pulse 1.6s ease-in-out 0.3s infinite;
}

/* Overflow counter — "+N more" when slot count exceeds the visible
 * cap. Same shape as a pill, neutral palette, no fade animation. */
.sem-merge-more {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  white-space: nowrap;
  color: var(--rt-ink-muted);
  background: transparent;
  border: 1px dashed rgba(140, 123, 106, 0.4);
}

/* While the phase is still running, the LATEST pills breathe gently —
 * picks up after the initial fade-in completes (~5s for 60 pills) so
 * the widget never feels frozen during long merge calls. Once the
 * phase transitions to is-done the pulse stops naturally. */
.rtcard__phase.is-active .sem-merge-pill:not(.sem-merge-pill--skeleton) {
  animation:
    sem-merge-pill-in 320ms ease-out forwards,
    sem-merge-pill-pulse 2.6s ease-in-out 2.4s infinite;
  animation-delay:
    var(--pill-delay, 0s),
    0s;
}
.sem-merge-foot {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  font-size: 11.5px;
  font-style: italic;
  color: var(--rt-ink-muted);
  letter-spacing: -0.005em;
}

@keyframes sem-merge-pill-in {
  from { opacity: 0; transform: translateY(3px) scale(0.92); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes sem-merge-pill-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

/* The card's own body container — remove the legacy step padding now
 * that phases own their own vertical rhythm. */
.reasoning-trace-card--planner .reasoning-trace-card__body {
  padding: 0;
}

/* ── Synthesis branch-out card ─────────────────────────────────────────
 * Sits below the planner strip. Shows the writer's slot-fetch tool calls
 * (fetch_slot, fetch_table, fetch_timeseries, query_ledger) as branches
 * off a central trunk.
 *
 * Uses the existing warm gold accent (#B27A3E — same as the planning
 * phase) so the card sits inside the warm cream family the rest of the
 * chat surface uses. The structurally-distinct card layout (trunk +
 * branches) carries the visual difference; the color stays unified.
 */
.reasoning-trace-card--synthesis {
  --syn-accent: #B27A3E;
  --syn-accent-deep: #8C5E2A;
  --syn-accent-soft: rgba(178, 122, 62, 0.12);
  --syn-accent-tint: rgba(178, 122, 62, 0.05);
  --syn-accent-ring: rgba(178, 122, 62, 0.30);
}
.reasoning-trace-card__header--synthesis {
  /* Same warm gold-cream gradient as the main reasoning-trace-card header
   * — sits as a family member, not a separate species. */
  background: linear-gradient(
    135deg,
    rgba(245, 232, 210, 0.85) 0%,
    rgba(248, 240, 224, 0.65) 50%,
    rgba(252, 246, 235, 0.55) 100%
  ) !important;
  border-bottom-color: rgba(184, 128, 90, 0.15) !important;
}
.reasoning-trace-card__body--synthesis {
  padding: 18px 24px 22px 24px;
}
.synthesis-trunk {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 12px;
}
.synthesis-trunk::before {
  content: '';
  position: absolute;
  left: 16px;
  top: 18px;
  bottom: 18px;
  width: 2px;
  background: linear-gradient(180deg,
    var(--syn-accent-ring) 0%,
    var(--syn-accent-soft) 50%,
    var(--syn-accent-ring) 100%);
  border-radius: 1px;
}
.synthesis-branch {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  font-size: 13px;
  color: var(--rt-ink-primary, #1F1B17);
}
.synthesis-branch__elbow {
  width: 12px;
  text-align: center;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  color: var(--syn-accent);
  font-size: 14px;
  line-height: 1;
  position: relative;
  z-index: 1;
  background: #FFFFFF; /* hide trunk line behind the elbow glyph */
  padding: 0 1px;
}
.synthesis-branch__root-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--syn-accent);
  box-shadow: 0 0 0 2px #FFFFFF, 0 0 0 3px var(--syn-accent-ring);
  margin-left: 1px;
  position: relative;
  z-index: 1;
}
.synthesis-branch__pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--syn-accent-tint);
  border: 1px solid var(--syn-accent-soft);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--rt-ink-primary, #1F1B17);
  transition: background 120ms ease, border-color 120ms ease;
}
.synthesis-branch__pill--root {
  background: var(--syn-accent);
  color: #FFFFFF;
  border-color: var(--syn-accent);
  font-weight: 600;
}
.synthesis-branch__pill--terminal {
  background: #FCF6E8;
  color: var(--syn-accent-deep);
  border-color: var(--syn-accent-soft);
  font-style: italic;
}

/* Inline-read branches — slots the writer cited via [slot:X] in
 * streaming content without calling fetch_slot. Visually distinct
 * from fetched branches (lighter background, dashed left edge)
 * because they represent a different mechanism: reads from inline
 * context vs tool-call round-trips. */
.synthesis-branch--inline-read .synthesis-branch__pill {
  background: rgba(239, 234, 220, 0.4);
  border-style: dashed;
  border-color: rgba(196, 145, 123, 0.35);
}
.synthesis-branch--inline-read .synthesis-branch__tool {
  color: #7a6650;
  font-weight: 500;
}
.synthesis-branch--inline-read .synthesis-branch__arg {
  color: #5a4d3e;
}
.synthesis-branch--inline-read-more .synthesis-branch__pill {
  background: rgba(239, 234, 220, 0.25);
  border-style: dashed;
  font-style: italic;
}

/* Parallel-section branches — emitted by the WRITER_PARALLEL_SECTIONS_
 * orchestrator (one per outline section). Visually distinct from
 * fetch-slot pills because they represent section-level orchestration
 * (top-level work units) rather than per-slot fetches. Slightly
 * stronger ink + teal accent so they read as the dominant activity
 * during the parallel drafting window. */
.synthesis-branch--parallel-section .synthesis-branch__pill {
  background: linear-gradient(180deg,
    rgba(20, 184, 166, 0.10) 0%,
    rgba(20, 184, 166, 0.06) 100%);
  border-color: rgba(20, 184, 166, 0.35);
}
.synthesis-branch--parallel-section .synthesis-branch__tool {
  color: #0d5a55;
  font-weight: 600;
}
.synthesis-branch--parallel-section .synthesis-branch__arg {
  background: rgba(255, 255, 255, 0.85);
  color: #0d5a55;
}

/* Empty-state branch — shown when no fetches OR inline citations
 * have happened yet (drafting just started). Status pill animates
 * subtly to signal liveness. */
.synthesis-branch--empty .synthesis-branch__pill {
  background: rgba(239, 234, 220, 0.6);
  border-color: var(--syn-accent-soft);
  animation: synthesis-empty-pulse 2.4s ease-in-out infinite;
}
@keyframes synthesis-empty-pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}
.synthesis-branch__tool {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--rt-ink-primary, #1F1B17);
}
.synthesis-branch__pill--root .synthesis-branch__tool {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  color: #FFFFFF;
}
.synthesis-branch__pill--terminal .synthesis-branch__tool {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-weight: 500;
  color: var(--syn-accent-deep);
}
.synthesis-branch__arg {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  font-weight: 500;
  color: var(--syn-accent-deep);
  padding: 1.5px 7px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 4px;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.01em;
}
.synthesis-branch__dur {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--rt-ink-muted, #8C7B6A);
  margin-left: 2px;
  font-variant-numeric: tabular-nums;
}
.synthesis-branch.is-running .synthesis-branch__pill {
  background: linear-gradient(90deg,
    var(--syn-accent-tint) 0%,
    var(--syn-accent-soft) 50%,
    var(--syn-accent-tint) 100%);
  background-size: 200% 100%;
  animation: synthesis-pill-shimmer 1.8s ease-in-out infinite;
}
@keyframes synthesis-pill-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.synthesis-branch.is-error .synthesis-branch__pill {
  background: #FCEEEA;
  color: #8C3A30;
  border-color: rgba(140, 58, 48, 0.25);
}
.synthesis-branch--terminal .synthesis-branch__elbow {
  color: var(--syn-accent-deep);
}
.reasoning-trace-card--synthesis.reasoning-trace-card--streaming
  .synthesis-branch__root-dot {
  animation: rtcard-phase-pulse 1.6s ease-in-out infinite;
}

.reasoning-trace-card__footer-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  font-variant-ligatures: none;
}

.reasoning-trace-card__footer-divider {
  color: #D9D0C5;
}

.reasoning-trace-card__expand {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #6F665E;
  background: transparent;
  border: 0;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 120ms ease;
}

.reasoning-trace-card__expand:hover { background: #F4ECDF; }
.reasoning-trace-card__expand svg {
  width: 12px;
  height: 12px;
  transition: transform 150ms ease;
}
.reasoning-trace-card__expand[data-expanded="true"] svg {
  transform: rotate(180deg);
}

/* When body is collapsed below the visible window, fade-out the bottom
 * to hint scrollability. */
/* Fully collapsed: body hidden, click header/expand to reopen.
 * Matches synthesis-card pattern — no partial preview, clean fold. */
.reasoning-trace-card__body--collapsed {
  max-height: 0;
  padding: 0;
  overflow: hidden;
}
.reasoning-trace-card__body--collapsed::after {
  display: none;
}

/* "Show all N steps" — let the card body grow taller than the default
 * 540px cap, but still cap it at viewport height so the card doesn't
 * push the chat into a long outer scroll. The 160px buffer accounts
 * for the chat header (~70px) and the message-input footer (~80px)
 * so the expanded card stays inside the visible chat pane and scrolls
 * internally for very long traces. */
.reasoning-trace-card__body--expanded {
  max-height: calc(100vh - 160px);
  overflow-y: auto;
}

/* Synthesis card collapsed state — when the response has landed and
 * the card auto-collapses, hide the branch-tree body entirely (header
 * stays visible with the slot-count summary). The chevron toggle in
 * the header re-expands on user click. Overrides the generic
 * --collapsed rule above (which only caps height for the long-trace
 * reasoning card) because the synthesis branch-tree needs to disappear
 * fully, not just be height-capped — even 220px would push the
 * response prose down by half a screen on tall fetches. */
.reasoning-trace-card__body--synthesis.reasoning-trace-card__body--collapsed {
  max-height: 0;
  padding: 0;
  margin: 0;
  overflow: hidden;
  border: 0;
  /* Suppress the fade-out gradient the generic collapsed rule paints */
}
.reasoning-trace-card__body--synthesis.reasoning-trace-card__body--collapsed::after {
  display: none;
}

/* Synthesis chevron button — small, subtle, sits at the end of the
 * chrome strip. Rotates 180° in the expanded state (matching the
 * legacy reasoning-card expand button convention). */
.reasoning-trace-card__expand--synthesis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  margin-left: 6px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-tertiary, #9ca3af);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.reasoning-trace-card__expand--synthesis:hover {
  background: var(--bg-cream, rgba(0, 0, 0, 0.04));
  color: var(--text-secondary, #6b7280);
}
.reasoning-trace-card__expand--synthesis svg {
  display: block;
}

/* Pointer cursor + small hover affordance on the synthesis header
 * strip so users discover the click-to-toggle behaviour. */
.reasoning-trace-card__header--synthesis {
  cursor: pointer;
  user-select: none;
}
.reasoning-trace-card__header--synthesis:hover {
  background: var(--bg-cream, rgba(0, 0, 0, 0.02));
}

/* When the trace is in user-expanded state, the assistant message's
 * action strip (copy / thumb up / thumb down / regenerate) sits
 * below the card and pokes into the visible viewport above the chat
 * input. The user reads that as the strip "leaking through" — hide
 * it while expanded; it returns the moment the card collapses. */
.message.assistant:has(.reasoning-trace-card--user-expanded) .message-actions {
  display: none;
}

/* The legacy `.message-actions { opacity: 0 }` rule (line ~4014)
 * made the four feedback icons hover-only — invisible at rest, on
 * by hovering the bubble. With the trace card now anchored at the
 * top of the chat pane on history-load, the user's mouse rarely
 * passes through the bubble first, and the icons never came into
 * view. Surface them at rest in their own quiet baseline; hover
 * still gives them full strength via the legacy rule. */
.message.assistant:not(:has(.reasoning-trace-card--user-expanded)) .message-actions {
  opacity: 1;
}

/* ── Slot-ledger table (rendered from <slot>…</slot> dumps) ───────── */
.reasoning-trace-step__prose .slot-table-wrap {
  overflow-x: auto;
  margin: 8px 0;
  border: 1px solid #e8e2db;
  border-radius: 12px;
}
.reasoning-trace-step__prose .slot-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: #FFFFFF;
}
.reasoning-trace-step__prose .slot-table th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: #847A70;
  padding: 8px 12px;
  border-bottom: 1px solid #e8e2db;
  background: #f3eeea;
  white-space: nowrap;
}
.reasoning-trace-step__prose .slot-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #eee9e4;
  color: #5C544D;
  vertical-align: top;
  line-height: 1.45;
}
.reasoning-trace-step__prose .slot-table tr:last-child td { border-bottom: none; }
.reasoning-trace-step__prose .slot-table.slot-table code {
  background: transparent;
  color: #4A9B92;
  padding: 0;
  font-size: 12px;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  border-radius: 0;
}
.reasoning-trace-step__prose .slot-table strong {
  color: #3F3934;
  font-variant-numeric: tabular-nums;
}

.slot-status {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 10px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.slot-status--filled   { background: #DEF1ED; color: #2E6B66; }
.slot-status--pending  { background: #FBF1E0; color: #8C6F2E; }
.slot-status--disputed { background: #FBE0DC; color: #8C3A30; }
.slot-status--failed   { background: #F0DCDC; color: #8C2E2E; }
.slot-status--partial  { background: #F5EBE0; color: #8B6D3F; }
.slot-status--default  { background: #F1ECE4; color: #847A70; }

/* Reference-line metadata pills — replace dense " · Released … ·
 * Vintage … · Confidence HIGH" trailers in citation lists with
 * scannable, editorial-grade chips. Palette is intentionally muted
 * (5–8% saturation, off-white grounds, slate-grey text) so the pills
 * read as quiet typographic affordances, not dashboard candy. */
.ref-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.015em;
  white-space: nowrap;
  vertical-align: baseline;
  margin: 0 1px;
  border: 1px solid transparent;
}
/* Date released / source date — warm off-white. */
.ref-pill--date    { background: #F4F0EA; color: #7A6F62; border-color: #ECE5DA; }
/* Vintage tag — cool off-white with a slate hint. */
.ref-pill--vintage { background: #EEF1F4; color: #5A6573; border-color: #E2E7ED; }
/* Type tag — warm-neutral. */
.ref-pill--type    { background: #F1EFEC; color: #5F584F; border-color: #E5E1DB; }
/* Confidence — quiet sage / sand / terracotta. Backgrounds sit just
 * a few percent off white so they don't shout, but the borders give
 * the pill a discrete edge so the reader can tell tiers apart. */
.ref-pill--conf-high { background: #ECF0EE; color: #4F6359; border-color: #D9E1DC; }
.ref-pill--conf-med  { background: #F2EEE6; color: #6F6452; border-color: #E5DDC9; }
.ref-pill--conf-low  { background: #F2EAE6; color: #7A5A52; border-color: #E5D4CC; }
/* Source-channel pill — appears once per reference line, right after
 * the hyperlink. Three calm variants so the reader can sweep the
 * reference list and see at a glance which sources are MCP-fronted
 * vs web vs internal. */
.ref-pill--source {
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 10px;
  padding: 1px 7px;
}
.ref-pill--source-web      { background: #EEF1F4; color: #4F5D6B; border-color: #DDE4EB; }
.ref-pill--source-mcp      { background: #ECEFEB; color: #56664E; border-color: #D9E0D2; }
.ref-pill--source-internal { background: #F1EDE6; color: #6E6450; border-color: #E2D9C8; }

/* Auto-generated references block pills — surface slot_id, value,
 * tier, and date as separate chips per reference line. Emitted by
 * buildReferencesBlock() in server/stages/verifier.js. The palette
 * stays in the editorial muted family so a long references list
 * reads as quiet typographic affordances, not dashboard candy. */

/* slot_id — monospaced technical identifier, slate-tinted. */
.ref-pill--slot {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  background: #F3EFE9;
  color: #5C5048;
  border-color: #E5DED2;
}
/* value — warm gold, the data point. Slightly bolder so the eye
 * lands on it when scanning the references list. */
.ref-pill--value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  background: #F7EFE2;
  color: #7A4F1F;
  border-color: #ECDDC2;
}
/* tier — teal, provenance class. */
.ref-pill--tier {
  background: #E6F1EF;
  color: #1F635D;
  border-color: #CFE3DF;
}
/* external-citation domain — quiet lavender. Appears next to
 * [ext:Description|URL] references in the auto-generated block so
 * the reader sees the host at a glance without needing to mouse
 * over the link. */
.ref-pill--ext-domain {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  background: #EDE9F2;
  color: #4F3380;
  border-color: #DDD6E7;
}
/* MCP tool name — muted sage, monospaced. Names the exact MCP that produced
 * the reference (e.g. "pib", "authority_web"). Emitted by buildReferencesBlock
 * for external (god-mode) citations that carry a 4th `mcp` marker segment. */
.ref-pill--mcp {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  background: #ECEFEB;
  color: #56664E;
  border-color: #D9E0D2;
}

/* ── References box — scrollable container in chat panel ──────────── */
/* Wraps the References/Sources heading + all [N] entries. Shows ~5
 * entries at a time with internal scroll; auto-shrinks when fewer.
 * Warm cream treatment matching the Anthropic design language. */
.references-box {
  margin: 20px 0 8px;
  padding: 14px 18px 10px;
  background: #f9f6f2;
  border: 1px solid #e8e2db;
  border-radius: 12px;
  max-height: 340px;      /* ~5 entries visible */
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #d5cec4 transparent;
}
.references-box::-webkit-scrollbar { width: 5px; }
.references-box::-webkit-scrollbar-track { background: transparent; }
.references-box::-webkit-scrollbar-thumb {
  background: #d5cec4;
  border-radius: 3px;
}
/* Tighten the heading inside the box — it's already contextual. */
.references-box h2,
.references-box h3,
.references-box h4,
.references-box h5,
.references-box h6 {
  font-size: 13px;
  font-weight: 600;
  color: #847A70;
  letter-spacing: 0;
  text-transform: none;
  margin: 0 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #eee9e4;
}
/* Each reference entry — compact spacing inside the box. */
.references-box > p {
  margin: 0;
  padding: 6px 0;
  border-bottom: 1px solid rgba(232, 226, 219, 0.5);
  font-size: 13px;
  line-height: 1.5;
}
.references-box > p:last-child { border-bottom: none; }

/* ── Insights enriched references (insights.js _enrichInsightReferences) ──── */
/* One row per source: number chip · agency + Official/Web badge + citation
 * count · dataset/release meta · "Backed" figure chips · clickable domain.
 * Warm-cream family matching .references-box; the insights canvas is light. */
.insights-refs {
  margin: 24px 0 8px;
  border: 1px solid #e8e2db;
  border-radius: 12px;
  background: #fbf9f6;
  overflow: hidden;
}
.insights-refs__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid #eee9e4;
}
.insights-refs__title { font-size: 14px; font-weight: 600; color: #2f2a24; }
.insights-refs__summary { font-size: 12px; color: #9a8f82; white-space: nowrap; }
.insrefs-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(232, 226, 219, 0.6);
}
.insrefs-row:last-child { border-bottom: none; }
.insrefs-num {
  flex: 0 0 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  background: #e7efe9;
  color: #0f6e56;
}
.insrefs-main { flex: 1 1 auto; min-width: 0; }
.insrefs-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  min-width: 0;
  max-width: 100%;
}
.insrefs-agency {
  font-size: 14px;
  font-weight: 600;
  color: #2f2a24;
  min-width: 0;
  flex: 0 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.insrefs-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 20px;
  white-space: nowrap;
  flex: 0 0 auto;
}
.insrefs-badge--official { background: #e1f5ee; color: #0f6e56; }
.insrefs-badge--web { background: #eef1f4; color: #4f5d6b; }
.insrefs-count { font-size: 11px; color: #9a8f82; flex: 0 0 auto; white-space: nowrap; }
.insrefs-meta { font-size: 12px; color: #6f655a; margin-top: 3px; line-height: 1.45; }
.insrefs-backed {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
.insrefs-backed__lbl {
  font-size: 11px;
  color: #9a8f82;
  margin-right: 2px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.insrefs-chip {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  background: #ffffff;
  color: #5f574c;
  border: 1px solid #ece5da;
}
.insrefs-link {
  flex: 0 0 auto;
  align-self: flex-start;
  font-size: 12px;
  color: #7a6f62;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}
.insrefs-link:hover { color: #0f6e56; text-decoration: underline; }
.insrefs-link__arw { font-size: 11px; }

/* Internal-artifact / attachment references — violet family, distinct from the
 * teal/slate external-source treatment. The link cell opens the artifact in the
 * canvas (filename-link) rather than a new browser tab. */
.insrefs-num--ws { background: #eeedfe; color: #3c3489; }
.insrefs-badge--ws { background: #eeedfe; color: #3c3489; }
.insrefs-badge--attach { background: #f1efe8; color: #5f5e5a; }
/* Compound selector so it wins over the app's .filename-link (coral, dotted). */
.insrefs-link--ws,
.insrefs-link--ws.filename-link {
  color: #3c3489;
  cursor: pointer;
  padding: 2px 8px;
  border: 1px solid #cecbf6;
  border-radius: 6px;
  background: #f6f5fe;
  text-decoration: none;
  display: inline-flex;
  flex: 0 0 auto;
  max-width: none;
  overflow: visible;
}
.insrefs-link--ws.filename-link:hover,
.insrefs-link--ws.filename-link:focus {
  background: #eeedfe;
  color: #26215c;
  text-decoration: none;
  outline: none;
}
.insrefs-link__ico { font-size: 10px; margin-right: 2px; }

/* Inline citation marker (rewritten from a raw "[https://…]" body citation).
 * A small superscript pill that scrolls to its reference row on click. */
.ins-cite {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  margin: 0 1px;
  vertical-align: super;
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
  color: #0f6e56;
  background: #e1f5ee;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  user-select: none;
}
.ins-cite:hover { background: #cfeee2; }
.ins-cite:focus-visible { outline: 2px solid #0f6e56; outline-offset: 1px; }
/* Brief highlight when a marker scrolls its reference row into view. */
.insrefs-row--flash { animation: insrefsFlash 1.4s ease-out; }
@keyframes insrefsFlash {
  0%, 30% { background: #fbf6e9; }
  100% { background: transparent; }
}

/* While streaming: pulse the rail icon of the active (last) step so the
 * user sees the trace is alive. The active step is the last one in the
 * card's body — typically a thinking step that's still growing or a
 * tool call awaiting result. */
.reasoning-trace-card--streaming .reasoning-trace-step:last-child .reasoning-trace-step__rail-icon {
  animation: reasoning-trace-pulse 1.6s ease-in-out infinite;
}

@keyframes reasoning-trace-pulse {
  0%, 100% { transform: scale(1);    opacity: 1; }
  50%      { transform: scale(1.08); opacity: 0.78; }
}

/* While the planner card is in its no-thoughts wait state, append
 * three animated dots after the placeholder text so the user sees
 * a visible "still working" pulse — the elapsed-time counter alone
 * looked too static during a 30-40s drafting silence. The dots use
 * a staggered keyframe so each one fades in/out 200ms apart, the
 * standard chat-typing-indicator idiom. */
.reasoning-trace-card--planner.reasoning-trace-card--streaming
.reasoning-trace-step--thinking .reasoning-trace-step__prose::after {
  content: '';
  display: inline-block;
  width: 3px;
  height: 3px;
  margin-left: 4px;
  border-radius: 50%;
  background: #7A6BC9;
  box-shadow:
    8px 0 0 0 #7A6BC9,
    16px 0 0 0 #7A6BC9;
  animation: planner-typing-dots 1.4s ease-in-out infinite;
  vertical-align: 2px;
}

@keyframes planner-typing-dots {
  0%, 100% {
    background: #7A6BC9;
    box-shadow: 8px 0 0 0 #C9C0E8, 16px 0 0 0 #C9C0E8;
  }
  33% {
    background: #C9C0E8;
    box-shadow: 8px 0 0 0 #7A6BC9, 16px 0 0 0 #C9C0E8;
  }
  66% {
    background: #C9C0E8;
    box-shadow: 8px 0 0 0 #C9C0E8, 16px 0 0 0 #7A6BC9;
  }
}

/* While streaming, the subtitle reads "Reasoning live" and gets a
 * subtle pulsing dot prefix so it visually matches the rail pulse. */
.reasoning-trace-card--streaming .reasoning-trace-card__subtitle::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #7A6BC9;
  margin-right: 6px;
  vertical-align: 1px;
  animation: reasoning-trace-pulse 1.6s ease-in-out infinite;
}

/* Message Actions */
.message-actions {
  display: flex;
  gap: 4px;
  margin-top: 12px;
}

/* Response completion time badge */
.response-time-badge {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  margin-top: 6px;
  padding: 2px 8px;
  background: var(--bg-cream);
  border-radius: 10px;
  display: inline-block;
  letter-spacing: 0.3px;
}

.action-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
}

.action-btn:hover {
  background: rgba(184, 128, 90, 0.08);
  color: var(--accent-coral-dark);
}

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

/* Loading Indicator */
.chat-route-loader {
  min-height: 40vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
}

/* Pulse ring around the asterisk */
.loading-pulse-ring {
  position: relative;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.loading-pulse-ring::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(192, 139, 92, 0.15);
  animation: ring-pulse 2s ease-out infinite;
}

.loading-pulse-ring::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(192, 139, 92, 0.1);
  animation: ring-pulse 2s ease-out infinite 0.8s;
}

@keyframes ring-pulse {
  0% { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}

.loading-asterisk {
  width: 20px;
  height: 20px;
  color: var(--accent-coral);
  animation: refined-pulse 2.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

/* Status text cycling */
.loading-status-text {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 15px;
  font-style: italic;
  color: var(--text-tertiary);
  transition: opacity 0.2s ease;
  letter-spacing: 0.2px;
}

@keyframes refined-pulse {
  0%, 100% { opacity: 1; transform: scale(1) rotate(0deg); }
  25% { opacity: 0.6; transform: scale(0.9) rotate(20deg); }
  50% { opacity: 0.35; transform: scale(0.85) rotate(0deg); }
  75% { opacity: 0.6; transform: scale(0.9) rotate(-20deg); }
}

/* Chat Input Wrapper */
.chat-input-wrapper {
  padding: 16px 24px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  flex-grow: 0;
  background: var(--bg-white);
}

.chat-input-wrapper .input-container {
  width: 100%;
  max-width: 820px;
}

/* ── Insight Pin Bar ──────────────────────────────────────────────────────── */
/* Appears above the text input when user has activated /rbi-insight or       */
/* /dea-insights. Plain messages are auto-routed to the pinned connector.      */
.insight-pin-bar {
  width: 100%;
  max-width: 820px;
  margin: 0 auto 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: insight-pin-in 0.18s ease;
}
.insight-pin-bar.hidden { display: none; }

@keyframes insight-pin-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.insight-pin-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.4;
  background: #fff3f0;
  border: 1px solid #f4a58a;
  color: #c9450a;
  user-select: none;
  white-space: nowrap;
}

/* DEA variant — blue */
.insight-pin-bar[data-type="dea"] .insight-pin-chip {
  background: #eef5ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}

/* RSI variant — violet (combined RBI + DEA) */
.insight-pin-bar[data-type="rsi"] .insight-pin-chip {
  background: #f5f0ff;
  border-color: #c4b5fd;
  color: #6d28d9;
}

/* PIB variant — teal (Press Information Bureau) */
.insight-pin-bar[data-type="pib"] .insight-pin-chip {
  background: #ecfdf5;
  border-color: #6ee7b7;
  color: #047857;
}

.insight-pin-icon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  opacity: 0.85;
}

.insight-pin-dismiss {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: transparent;
  border: none;
  cursor: pointer;
  color: inherit;
  opacity: 0.55;
  padding: 0;
  transition: opacity 0.13s, background 0.13s;
  flex-shrink: 0;
}
.insight-pin-dismiss:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.09);
}
.insight-pin-dismiss svg {
  width: 10px;
  height: 10px;
}

.insight-pin-hint {
  font-size: 11.5px;
  color: var(--text-tertiary, #9ca3af);
  white-space: nowrap;
}
/* ── End Insight Pin Bar ─────────────────────────────────────────────────── */

/* ── Marketplace apps ─────────────────────────────────────────────────────
 * Catalogue page (#/apps), the composer drop-up, and the pin bar. Borrows the
 * paper-sheet card from .connector-card and the drop-up geometry from
 * .scope-dropdown, so a pinned app reads as part of the composer rather than
 * as a visitor from another product.
 */

.mp-page-note {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--text-secondary);
  max-width: 620px;
  margin: -8px 0 24px;
}

.mp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

.mp-empty {
  grid-column: 1 / -1;
  padding: 70px 24px;
  text-align: center;
  color: var(--text-tertiary);
  font-family: 'EB Garamond', Georgia, serif;
  font-style: italic;
  font-size: 17px;
  line-height: 1.6;
}
.mp-empty-detail {
  font-style: normal;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  opacity: 0.75;
}

.mp-card {
  display: flex;
  align-items: stretch;
  gap: 0;
  width: 100%;
  padding: 0;
  text-align: left;
  background: #ffffff;
  border: 1px solid rgba(26, 15, 5, 0.08);
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  font: inherit;
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.22s ease;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 1px 0 rgba(26, 15, 5, 0.04),
    0 2px 4px rgba(26, 15, 5, 0.04),
    0 8px 18px -8px rgba(26, 15, 5, 0.08);
}
.mp-card:hover {
  transform: translateY(-2px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 1px 0 rgba(26, 15, 5, 0.06),
    0 4px 10px rgba(26, 15, 5, 0.06),
    0 14px 28px -10px rgba(26, 15, 5, 0.14);
}
.mp-card-accent { width: 4px; flex-shrink: 0; }
.mp-card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 18px;
  min-width: 0;
  flex: 1;
}
.mp-card-head { display: flex; align-items: baseline; gap: 10px; justify-content: space-between; }
.mp-card-name {
  font-family: 'Fraunces', 'EB Garamond', Georgia, serif;
  font-size: 16.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mp-card-badge {
  flex-shrink: 0;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  border: 1px solid var(--border-light);
  border-radius: 3px;
  padding: 2px 6px;
}
.mp-card-badge.is-published { color: #2E7D32; border-color: rgba(46, 125, 50, 0.35); }
.mp-card-desc {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.mp-card-sources { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 2px; }
.mp-chip {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 10.5px;
  color: var(--text-tertiary);
  background: var(--bg-cream);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 2px 8px;
  white-space: nowrap;
}
.mp-chip-more { font-variant-numeric: tabular-nums; }

/* ── Composer picker (drop-up) ── */

.mp-picker { position: relative; }
.mp-picker-btn { gap: 6px; }
.mp-picker.is-pinned .mp-picker-btn {
  border-color: var(--accent-coral);
  color: var(--text-primary);
}
.mp-picker .scope-selector-label { max-width: 130px; }

.mp-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  width: 320px;
  max-height: 380px;
  overflow-y: auto;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 8px 28px rgba(26, 15, 5, 0.14);
  z-index: 200;
}
.mp-menu.hidden { display: none; }

.mp-menu-group + .mp-menu-group { margin-top: 6px; border-top: 1px solid var(--border-light); padding-top: 6px; }
.mp-menu-head {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 6px 8px 4px;
}
.mp-menu-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
}
.mp-menu-item:hover { background: var(--bg-cream); }
.mp-menu-item.is-active { background: var(--bg-cream); box-shadow: inset 2px 0 0 var(--accent-coral); }
.mp-menu-check input[type=checkbox] {
  width: 14px; height: 14px; margin-top: 2px; accent-color: var(--accent-coral); flex-shrink: 0;
}
.mp-menu-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.mp-menu-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.mp-menu-name {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 12.5px;
  color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mp-menu-sub {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 11px;
  color: var(--text-tertiary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mp-menu-empty, .mp-menu-loading {
  padding: 12px 10px;
  font-family: 'EB Garamond', Georgia, serif;
  font-style: italic;
  font-size: 13.5px;
  color: var(--text-tertiary);
}
.mp-menu-foot {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 6px; padding: 8px 8px 4px; border-top: 1px solid var(--border-light);
}
.mp-menu-clear, .mp-menu-link {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 11.5px;
  color: var(--text-secondary);
  background: none; border: 0; padding: 0; cursor: pointer; text-decoration: none;
}
.mp-menu-clear:disabled { opacity: 0.4; cursor: default; }
.mp-menu-clear:not(:disabled):hover, .mp-menu-link:hover { color: var(--accent-coral); }

/* ── Pin bar ── */

.mp-pin-bar {
  width: 100%;
  max-width: 820px;
  margin: 0 auto 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: insight-pin-in 0.18s ease;
}
.mp-pin-bar.hidden { display: none; }
.mp-pin-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  border-radius: 20px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.4;
  background: var(--bg-cream);
  border: 1px solid var(--accent-coral);
  color: var(--accent-coral);
  user-select: none;
  white-space: nowrap;
  max-width: 380px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mp-pin-icon { width: 13px; height: 13px; flex-shrink: 0; opacity: 0.85; }
/* ── End Marketplace apps ────────────────────────────────────────────────── */

.disclaimer {
  display: none;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
  .greeting-text {
    font-size: 32px;
  }

  .input-container {
    max-width: 100%;
  }

  .message-input {
    font-size: 16px;
  }

  .user .message-content {
    max-width: 85%;
  }
}

@media (max-width: 480px) {
  .plan-badge {
    font-size: 13px;
    padding: 6px 12px;
  }

  .greeting-text {
    font-size: 28px;
  }

  .asterisk-icon {
    width: 24px;
    height: 24px;
  }
}

/* ==================== ANIMATIONS ==================== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Markdown Content Styles — match god-report artifact body type */
.markdown-content {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 16.5px;
  line-height: 1.7;
  color: #2E281F;
}

/* KaTeX math rendering. The library ships its own font + sizing rules
   via katex.min.css (loaded in index.html); we only adjust the spacing
   around display-mode equations so they breathe inside chat bubbles. */
.markdown-content .katex-display {
  margin: 14px 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 0;
}
.markdown-content .katex {
  font-size: 1.02em;
}
/* Fallback for invalid LaTeX or pre-KaTeX-loaded paint: surface the
   source equation in a code-block style so the user sees the formula
   rather than a broken placeholder. */
.markdown-content .math-render-failed {
  background: rgba(120, 120, 120, 0.08);
  border: 1px dashed rgba(120, 120, 120, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.92em;
  color: #b45309;
}
.markdown-content .math-render-failed.math-display {
  display: block;
  margin: 12px 0;
  padding: 8px 12px;
  white-space: pre-wrap;
}

.markdown-content p {
  margin: 0 0 15px 0;
}

.markdown-content p:last-child {
  margin-bottom: 0;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
  font-family: 'EB Garamond', Georgia, serif;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.3;
}

.markdown-content h1:first-child,
.markdown-content h2:first-child,
.markdown-content h3:first-child {
  margin-top: 0;
}

.markdown-content h1 { font-size: 1.6em; margin: 28px 0 14px 0; }
.markdown-content h2 { font-size: 1.35em; margin: 24px 0 12px 0; }
.markdown-content h3 { font-size: 1.15em; margin: 20px 0 10px 0; }
.markdown-content h4 { font-size: 1em; margin: 18px 0 8px 0; }

.markdown-content ul,
.markdown-content ol {
  margin: 12px 0;
  padding-left: 24px;
}

.markdown-content li {
  margin: 6px 0;
}

.markdown-content li > ul,
.markdown-content li > ol {
  margin: 4px 0;
}

.markdown-content blockquote {
  margin: 16px 0;
  padding: 14px 18px;
  border-left: 3px solid var(--accent-coral);
  background: linear-gradient(135deg, rgba(184, 128, 90, 0.04), transparent);
  border-radius: 0 10px 10px 0;
  font-style: italic;
  color: var(--text-secondary);
}

.markdown-content blockquote p {
  margin: 0;
}

.markdown-content hr {
  margin: 20px 0;
  border: none;
  border-top: 1px solid var(--border-light);
}

.markdown-content a {
  color: var(--accent-coral-dark);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.markdown-content a:hover {
  color: var(--accent-coral);
}

.markdown-content strong {
  font-weight: 600;
}

.markdown-content table {
  /* Anthropic-style table: warm tones, clean horizontal dividers,
   * full container width, content-driven column sizing. */
  display: table;
  width: 100%;
  table-layout: auto;
  border-collapse: separate;
  border-spacing: 0;
  margin: 16px 0;
  font-size: 14px;
  border: 1px solid #e8e2db;
  border-radius: 12px;
  overflow: hidden;
}

.markdown-content th,
.markdown-content td {
  padding: 11px 16px;
  border-bottom: 1px solid #eee9e4;
  text-align: left;
  vertical-align: top;
  white-space: normal;
  word-break: normal;
  overflow-wrap: anywhere;
}
/* Strip the bottom border on the last row so the outer border isn't doubled. */
.markdown-content tbody tr:last-child > td { border-bottom: none; }

.markdown-content th {
  background: #f3eeea;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
  color: #3d3833;
}
/* First-column label cell — bolder for row scanning */
.markdown-content tbody td:first-child {
  font-weight: 500;
  color: #1a1a1a;
}

/* Code Blocks — Dark Panel */
.markdown-content code {
  background: rgba(184, 128, 90, 0.1);
  color: #8a6a50;
  padding: 2px 7px;
  border-radius: 5px;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
  font-size: 0.88em;
  border: 1px solid rgba(184, 128, 90, 0.08);
}

.markdown-content pre {
  background: #1a1a1e;
  color: #e0ddd6;
  border: none;
  border-radius: 12px;
  padding: 40px 20px 18px;
  overflow-x: auto;
  margin: 16px 0;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
  font-size: 13px;
  line-height: 1.6;
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.15),
    0 1px 4px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  position: relative;
}

.markdown-content pre code {
  background: transparent;
  padding: 0;
  color: #e0ddd6;
  font-size: 13px;
  line-height: 1.6;
  border: none;
}

/* Code block language header */
.code-block-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 32px;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.35);
  border-radius: 12px 12px 0 0;
}

/* Legacy support — match dark panel style */
.message-content code {
  background: rgba(184, 128, 90, 0.1);
  color: #8a6a50;
  padding: 2px 7px;
  border-radius: 5px;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
  font-size: 0.88em;
  border: 1px solid rgba(184, 128, 90, 0.08);
}

.message-content pre {
  background: #1a1a1e;
  color: #e0ddd6;
  border: none;
  padding: 18px 20px;
  border-radius: 12px;
  overflow-x: auto;
  margin: 16px 0;
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.15),
    0 1px 4px rgba(0, 0, 0, 0.1);
}

.message-content pre code {
  background: transparent;
  padding: 0;
  color: #e0ddd6;
  border: none;
}

/* Scrollbar — Minimal Coral */
.messages-container::-webkit-scrollbar {
  width: 5px;
}

.messages-container::-webkit-scrollbar-track {
  background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
  background: rgba(184, 128, 90, 0.18);
  border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
  background: rgba(184, 128, 90, 0.35);
}

/* ==================== SIDEBAR ==================== */
.sidebar {
  width: 320px;
  height: 100vh;
  background: var(--bg-white);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border-light);
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar.collapsed {
  width: 0;
  border-left: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px 8px 8px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
  gap: 6px;
}

/* Sidebar tabs in header */
.sidebar-tabs { display: flex; gap: 2px; background: rgba(0,0,0,0.03); border-radius: 7px; padding: 2px; flex: 1; }
.sidebar-tab { display: inline-flex; align-items: center; gap: 5px; padding: 5px 12px; border: none;
  background: transparent; border-radius: 5px; font-family: inherit; font-size: 11px; font-weight: 600;
  color: var(--text-tertiary); cursor: pointer; transition: all 0.15s; white-space: nowrap; flex: 1;
  justify-content: center; }
.sidebar-tab:hover { color: var(--text-secondary); background: rgba(0,0,0,0.03); }
.sidebar-tab-active { background: var(--bg-white); color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.sidebar-tab svg { flex-shrink: 0; }
.sidebar-tab-badge { font-size: 9px; font-weight: 700; background: var(--accent-coral); color: #fff;
  border-radius: 4px; padding: 1px 5px; min-width: 14px; text-align: center; }
.sidebar-tab-badge:empty { display: none; }

/* Tab panels */
.sidebar-tab-panel { display: none; flex: 1; overflow: hidden; min-height: 0; flex-direction: column; }
.sidebar-tab-panel-active { display: flex; }

.sidebar-toggle {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
}

.sidebar-toggle:hover {
  background: var(--bg-cream);
  color: var(--text-primary);
}

.sidebar-toggle svg {
  width: 16px;
  height: 16px;
}

/* Removed: old stacked sidebar-section styles replaced by tabbed layout */

.steps-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  min-height: 0;
}

.tool-calls-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  min-height: 0;
}

/* Sidebar scrollbar styling */
.steps-list::-webkit-scrollbar,
.tool-calls-list::-webkit-scrollbar {
  width: 6px;
}

.steps-list::-webkit-scrollbar-track,
.tool-calls-list::-webkit-scrollbar-track {
  background: transparent;
}

.steps-list::-webkit-scrollbar-thumb,
.tool-calls-list::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 3px;
}

.steps-list::-webkit-scrollbar-thumb:hover,
.tool-calls-list::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* ── Artifacts sidebar tab ────────────────────────────────────────── */
/* Two vertical sections (Today / Earlier), scrollable, beautiful cards
 * with a colored file-type pill, title, size + relative time, and the
 * source chat as a subtle footer line. */
.artifacts-sidebar-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-light) transparent;
  padding: 4px 6px 24px;
}
.artifacts-sidebar-list::-webkit-scrollbar { width: 6px; }
.artifacts-sidebar-list::-webkit-scrollbar-track { background: transparent; }
.artifacts-sidebar-list::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 3px;
}
.artifacts-sidebar-list::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

.artifact-sidebar-section + .artifact-sidebar-section {
  margin-top: 22px;
}

.artifact-sidebar-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 14px 10px;
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  font-weight: 600;
  position: sticky;
  top: 0;
  background: linear-gradient(to bottom, var(--bg-cream) 78%, rgba(252, 248, 240, 0));
  z-index: 1;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Subtle counter pill that matches the title's mono-style label without
   the italic-serif clash. Aligned tabularly so two-digit counts don't
   wobble the title baseline. */
.artifact-sidebar-section-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  padding: 1px 7px;
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--text-tertiary);
  background: rgba(26, 15, 5, 0.06);
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

.artifact-sidebar-section-cards {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 6px;
}

.chat-artifacts-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 8px 10px 2px;
}

.chat-artifacts-toolbar-btn {
  border: 1px solid rgba(26, 15, 5, 0.12);
  background: rgba(255, 255, 255, 0.6);
  color: var(--text-secondary);
  border-radius: 8px;
  padding: 6px 10px;
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background .14s ease, border-color .14s ease, color .14s ease;
}

.chat-artifacts-toolbar-btn:hover {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(26, 15, 5, 0.2);
}

.chat-artifacts-toolbar-btn.active {
  color: #8a5a1a;
  border-color: rgba(180, 140, 80, 0.36);
  background: rgba(180, 140, 80, 0.14);
}

.chat-artifacts-toolbar-btn.chat-artifacts-toolbar-btn-primary {
  color: #f8f5f0;
  background: linear-gradient(180deg, #986f4b 0%, #7b5839 100%);
  border-color: rgba(123, 88, 57, 0.64);
}

.chat-artifacts-toolbar-btn.chat-artifacts-toolbar-btn-primary:hover {
  background: linear-gradient(180deg, #a37751 0%, #835d3d 100%);
}

.chat-artifacts-toolbar-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.artifact-sidebar-card {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto auto;
  grid-column-gap: 12px;
  grid-row-gap: 3px;
  align-items: start;
  padding: 12px 14px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
  width: 100%;
  outline: none;
}

.artifact-sidebar-card:hover {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(26, 15, 5, 0.10);
  box-shadow: 0 1px 2px rgba(26, 15, 5, 0.04), 0 4px 12px rgba(26, 15, 5, 0.04);
  transform: translateY(-1px);
}

.artifact-sidebar-card:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(26, 15, 5, 0.04);
}

.artifact-sidebar-card:focus-visible {
  border-color: rgba(180, 140, 80, 0.45);
  box-shadow: 0 0 0 2px rgba(180, 140, 80, 0.22);
}

/* Reserve space on the right edge of pin-eligible cards so the button
   doesn't overlap the title/meta on long titles. */
.artifact-sidebar-card.has-pin {
  padding-right: 36px;
}

.artifact-sidebar-card-select {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: 1.5px solid rgba(26, 15, 5, 0.22);
  background: rgba(255, 255, 255, 0.86);
  color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.14s ease, border-color 0.14s ease, background 0.14s ease, color 0.14s ease;
}

.artifacts-sidebar-list.artifact-sidebar-list--select-mode .artifact-sidebar-card-select {
  opacity: 1;
}

.artifact-sidebar-card.artifact-sidebar-card--selected {
  border-color: rgba(180, 140, 80, 0.45);
  background: rgba(180, 140, 80, 0.12);
}

.artifact-sidebar-card.artifact-sidebar-card--selected .artifact-sidebar-card-select {
  border-color: rgba(180, 140, 80, 0.7);
  background: #8a5a1a;
  color: #fff;
}

.artifact-sidebar-card-pin {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-tertiary, #8b8e96);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
  opacity: 0.85;
}

.artifact-sidebar-card-pin svg {
  width: 14px;
  height: 14px;
  pointer-events: none;
}

.artifact-sidebar-card-pin:hover {
  background: rgba(180, 140, 80, 0.14);
  border-color: rgba(180, 140, 80, 0.28);
  color: #8a5a1a;
  opacity: 1;
}

.artifact-sidebar-card-pin:active {
  transform: scale(0.94);
}

.artifact-sidebar-card-pin:disabled {
  opacity: 0.4;
  cursor: default;
}

.artifact-sidebar-card-pin.pinning {
  background: rgba(180, 140, 80, 0.18);
  color: #8a5a1a;
}

.artifact-sidebar-pill {
  grid-row: 1 / 3;
  grid-column: 1;
  align-self: start;
  margin-top: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  padding: 4px 8px;
  border-radius: 6px;
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-secondary);
}
.artifact-sidebar-pill-pdf     { background: rgba(192, 57, 43, 0.12); color: #a23021; }
.artifact-sidebar-pill-docx    { background: rgba(41, 98, 192, 0.12); color: #1f4f9c; }
.artifact-sidebar-pill-xlsx    { background: rgba(34, 139, 34, 0.14); color: #1f6f1f; }
.artifact-sidebar-pill-pptx    { background: rgba(217, 119, 6, 0.14); color: #b45309; }
.artifact-sidebar-pill-image   { background: rgba(147, 51, 234, 0.14); color: #7e22ce; }
.artifact-sidebar-pill-web     { background: rgba(20, 110, 110, 0.14); color: #0f6b6b; }
.artifact-sidebar-pill-text    { background: rgba(75, 85, 99, 0.12); color: #4b5563; }
.artifact-sidebar-pill-code    { background: rgba(101, 70, 214, 0.12); color: #5b3fd6; }
.artifact-sidebar-pill-archive { background: rgba(120, 70, 30, 0.12); color: #8a4f30; }
.artifact-sidebar-pill-default { background: rgba(0, 0, 0, 0.06); color: var(--text-secondary); }

.artifact-sidebar-title {
  grid-row: 1;
  grid-column: 2;
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.005em;
}

.artifact-sidebar-meta {
  grid-row: 2;
  grid-column: 2;
  margin-top: 1px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-tertiary);
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.artifact-sidebar-dot {
  opacity: 0.4;
  font-weight: 400;
}

.artifact-sidebar-chat {
  grid-row: 3;
  grid-column: 2;
  margin-top: 3px;
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.75;
}

/* Subtle leading mark on the chat reference so it reads as a "from"
   pointer rather than a duplicate title. */
.artifact-sidebar-chat::before {
  content: '↳ ';
  margin-right: 2px;
  opacity: 0.55;
}

/* ── Artifacts overlay (slide-in from the right) ───────────────────── */
.artifacts-overlay-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 15, 5, 0.18);
  opacity: 0;
  transition: opacity 0.24s ease;
  z-index: 80;
  pointer-events: auto;
}
.artifacts-overlay-backdrop.open { opacity: 1; }
.artifacts-overlay-backdrop.hidden { display: none; }

.artifacts-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 460px;
  max-width: 92vw;
  background: var(--bg-cream);
  border-left: 1px solid rgba(26, 15, 5, 0.08);
  box-shadow: -20px 0 60px rgba(26, 15, 5, 0.14);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0.18, 1);
  z-index: 90;
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.artifacts-overlay.open { transform: translateX(0); }
.artifacts-overlay.hidden { display: none; }

.artifacts-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(26, 15, 5, 0.06);
  background: rgba(255, 255, 255, 0.62);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
}

.artifacts-overlay-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.artifacts-overlay-title {
  margin: 0;
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.artifacts-overlay-close {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}
.artifacts-overlay-close:hover {
  background: rgba(26, 15, 5, 0.05);
  border-color: rgba(26, 15, 5, 0.08);
  color: var(--text-primary);
}
.artifacts-overlay-close:focus-visible {
  outline: none;
  border-color: rgba(180, 140, 80, 0.4);
  box-shadow: 0 0 0 2px rgba(180, 140, 80, 0.18);
}
.artifacts-overlay-close svg { width: 16px; height: 16px; }

.artifact-transform-help {
  margin: 0 0 10px 0;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.artifacts-overlay #artifactsOverlayList {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px 28px;
}
.artifacts-overlay #artifactsOverlayList::-webkit-scrollbar { width: 8px; }
.artifacts-overlay #artifactsOverlayList::-webkit-scrollbar-track { background: transparent; }
.artifacts-overlay #artifactsOverlayList::-webkit-scrollbar-thumb {
  background: rgba(26, 15, 5, 0.10);
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.artifacts-overlay #artifactsOverlayList::-webkit-scrollbar-thumb:hover {
  background: rgba(26, 15, 5, 0.18);
  background-clip: padding-box;
}

/* Empty state inside the overlay specifically — larger, centered, with
   a quieter tone than the default chip-strip empty state. */
.artifacts-overlay .empty-state {
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-tertiary);
  text-align: center;
  padding: 48px 32px;
  line-height: 1.5;
}

.empty-state {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 8px 0;
}

/* Step Item */
/* Phase headers for long-horizon report progress */
.step-phase-header {
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  padding: 6px 12px 2px;
  margin-top: 4px;
}

.step-phase-header.active {
  color: var(--accent-coral, #c9977a);
}

.step-phase-header.done {
  color: #22c55e;
}

.step-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-cream);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  font-size: 13px;
}

.step-status {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.step-status.pending {
  background: var(--border-light);
  color: var(--text-tertiary);
}

.step-status.in_progress {
  background: var(--accent-coral);
  color: white;
  animation: pulse 1.5s ease-in-out infinite;
}

.step-status.completed {
  background: var(--accent-coral);
  color: white;
}

.step-status svg {
  width: 12px;
  height: 12px;
}

.step-content {
  flex: 1;
  min-width: 0;
}

.step-text {
  color: var(--text-primary);
  line-height: 1.4;
}

.tool-call-item {
  background: var(--bg-cream);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}

.tool-call-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
  transition: background 0.15s;
}

.tool-call-header:hover {
  background: #efefea;
}

.tool-call-icon {
  width: 20px;
  height: 20px;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tool-call-icon svg {
  width: 12px;
  height: 12px;
  color: var(--text-secondary);
}

.tool-call-icon.running {
  background: var(--accent-coral);
  animation: pulse 1.5s ease-in-out infinite;
}

.tool-call-icon.running svg {
  color: white;
}

.tool-call-icon.success {
  background: var(--accent-coral);
  border-color: var(--accent-coral-dark);
}

.tool-call-icon.success svg {
  color: white;
}

.tool-call-icon.error {
  background: #c45a5a;
  border-color: #a84848;
}

.tool-call-icon.error svg {
  color: white;
}

.tool-call-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.tool-call-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tool-call-status {
  font-size: 10px;
  color: var(--text-tertiary);
  margin-top: 1px;
}

.tool-call-expand {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.tool-call-expand svg {
  width: 12px;
  height: 12px;
}

.tool-call-item.expanded .tool-call-expand {
  transform: rotate(180deg);
}

.tool-call-details {
  display: none;
  padding: 8px;
  background: var(--bg-white);
  border-top: 1px solid var(--border-light);
  font-size: 11px;
  max-height: 150px;
  overflow-y: auto;
}

.tool-call-item.expanded .tool-call-details {
  display: block;
}

.tool-detail-section {
  margin-bottom: 6px;
}

.tool-detail-section:last-child {
  margin-bottom: 0;
}

.tool-detail-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 3px;
}

.tool-call-details pre {
  background: rgba(0, 0, 0, 0.04);
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid var(--border-light);
  overflow-x: auto;
  color: var(--text-primary);
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 10px;
  line-height: 1.4;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 80px;
  overflow-y: auto;
}

/* Artifact Item */
.artifact-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-cream);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.artifact-item:hover {
  background: #efefea;
}

.artifact-icon {
  width: 32px;
  height: 32px;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.artifact-icon svg {
  width: 16px;
  height: 16px;
  color: var(--accent-coral);
}

.artifact-info {
  flex: 1;
  min-width: 0;
}

.artifact-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.artifact-type {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* ── Inline Tool Cards — Premium Intelligence Feed ── */
.inline-tool-call {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  margin: 10px 0;
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.inline-tool-call:hover {
  border-color: rgba(192, 139, 92, 0.25);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

.inline-tool-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.15s;
}

.inline-tool-header:hover {
  background: var(--bg-cream);
}

.inline-tool-header svg {
  width: 16px;
  height: 16px;
  color: var(--accent-coral);
  flex-shrink: 0;
}

.inline-tool-header .tool-name {
  font-weight: 600;
  color: var(--text-primary);
}

.inline-tool-header .tool-preview {
  color: var(--text-tertiary);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 350px;
}

.inline-tool-header .expand-icon {
  margin-left: auto;
  color: var(--text-tertiary);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.inline-tool-call.expanded .expand-icon {
  transform: rotate(180deg);
}

/* Tool-friendly label — the main visible text */
.inline-tool-header .tool-friendly {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
  /* Show the FULL query — user explicitly asked for no ellipsis.
   * Long search strings wrap onto multiple lines inside the pill
   * instead of being chopped with a trailing "…". The min-width:0
   * is needed for flex children to wrap correctly under a 1fr-style
   * flex:1 row. */
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  min-width: 0;
  line-height: 1.4;
  transition: color 0.15s;
}

.inline-tool-header:hover .tool-friendly {
  color: var(--accent-coral-dark);
}

/* Collapsed by default — only show details on expand */
.inline-tool-result {
  display: none;
  padding: 0 16px 14px;
  max-height: 220px;
  overflow-y: auto;
}

.inline-tool-call.expanded .inline-tool-result {
  display: block;
}

/* Query/input display — subtle, not screaming */
.inline-tool-result pre {
  background: var(--bg-cream);
  color: var(--text-secondary);
  padding: 10px 14px;
  border-radius: 8px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 12.5px;
  overflow-x: auto;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.55;
  border: none;
}

.tool-section {
  margin-bottom: 8px;
}

.tool-section:last-child {
  margin-bottom: 0;
}

.tool-section-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 5px;
  padding-left: 2px;
}

/* Output section — warm accent border */
.tool-output-section pre {
  background: rgba(192, 139, 92, 0.04);
  color: var(--text-primary);
  border-left: 3px solid var(--accent-coral);
  border-radius: 0 8px 8px 0;
}

/* ── Streaming Activity Zone — fills dead space while model works ── */
.streaming-activity-zone {
  padding: 24px 0 16px;
  animation: fadeIn 0.3s ease-out;
}

.activity-progress {
  height: 3px;
  background: var(--border-light);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 20px;
}

.activity-bar {
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg, var(--accent-coral), rgba(192, 139, 92, 0.3));
  border-radius: 2px;
  animation: activity-slide 2s ease-in-out infinite;
}

@keyframes activity-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(300%); }
}

.activity-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.activity-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13px;
  color: var(--text-tertiary);
  transition: color 0.4s ease, opacity 0.4s ease;
  opacity: 0.4;
}

.activity-step.active {
  color: var(--text-secondary);
  opacity: 1;
}

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-light);
  flex-shrink: 0;
  transition: background 0.4s ease, box-shadow 0.4s ease;
}

.activity-step.active .activity-dot {
  background: var(--accent-coral);
  box-shadow: 0 0 8px rgba(192, 139, 92, 0.3);
}

/* Compact technical tool — single-line, no expand, minimal footprint */
.compact-tool {
  background: transparent !important;
  backdrop-filter: none !important;
  border: none !important;
  box-shadow: none !important;
  margin: 4px 0 !important;
  padding: 0 !important;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.compact-tool:hover {
  opacity: 0.7;
}

.compact-tool .compact-header {
  padding: 4px 0 !important;
  gap: 6px;
  font-size: 12px;
  cursor: default;
}

.compact-tool .compact-header .tool-friendly {
  font-size: 12px !important;
  font-weight: 400 !important;
  color: var(--text-tertiary) !important;
  font-style: italic;
}

.compact-tool .compact-header .tool-spinner,
.compact-tool .compact-header .tool-check {
  width: 14px !important;
  height: 14px !important;
}

.compact-tool .compact-header .tool-spinner svg,
.compact-tool .compact-header .tool-check svg {
  width: 14px !important;
  height: 14px !important;
}

/* Hide timeline dots/rails for compact tools */
.compact-tool::before,
.compact-tool::after {
  display: none !important;
}

/* Consecutive compact tools collapse tighter */
.compact-tool + .compact-tool {
  margin-top: 0 !important;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}


/* Right sidebar expand button (visible when collapsed) */
.right-sidebar-expand-btn {
  display: none;
  position: absolute;
  right: 0;
  top: 16px;
  width: 24px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-light);
  border-right: none;
  background: var(--bg-white);
  border-radius: 6px 0 0 6px;
  cursor: pointer;
  color: var(--text-tertiary);
  transition: background 0.15s, color 0.15s;
  z-index: 10;
}

.right-sidebar-expand-btn:hover {
  background: var(--bg-cream);
  color: var(--text-primary);
}

.right-sidebar-expand-btn svg {
  width: 14px;
  height: 14px;
}

.right-sidebar-expand-btn.visible {
  display: flex;
}

/* Hide the right-sidebar expand affordance whenever the home view is
   showing — the home page has no right panel, so the chevron is dead UI. */
body:has(#homeView:not(.hidden)) .right-sidebar-expand-btn {
  display: none !important;
}

.left-sidebar.collapsed {
  width: 52px;
  min-width: 52px;
}

/* Overlay rail: always out of flow so open/close only animates width/shadow
   (no chat L→R reflow). Collapsed = 52px strip; expanded = 260px panel. */
.left-sidebar {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 80;
  transition:
    width 0.36s cubic-bezier(0.22, 1, 0.36, 1),
    min-width 0.36s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.36s cubic-bezier(0.22, 1, 0.36, 1);
}
.left-sidebar:not(.collapsed) {
  width: 260px;
  min-width: 260px;
  box-shadow:
    0 12px 40px rgba(20, 30, 80, 0.14),
    0 2px 8px rgba(20, 30, 80, 0.06);
}
/* Permanent rail footprint — same whether strip or overlay is showing */
.app-container > .main-content {
  margin-left: 64px; /* 52px rail + 12px gap */
}

/* Label text beside icons fades out smoothly as the sidebar narrows.
 * Inline spans (brand name, action-item text, nav link text, section
 * labels) get opacity+scale transitions; big block elements
 * (chat-history-list, header, brand-link logo) still use display:none
 * since they'd otherwise overflow the 52px collapsed width. */
.sidebar-brand-name,
.sidebar-action-item span,
.sidebar-nav-link span,
.sidebar-section-label {
  transition:
    opacity 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  opacity: 1;
}
.left-sidebar.collapsed .sidebar-brand-name,
.left-sidebar.collapsed .sidebar-action-item span,
.left-sidebar.collapsed .sidebar-nav-link span,
.left-sidebar.collapsed .sidebar-section-label {
  opacity: 0;
  pointer-events: none;
  /* Out of flex flow so they don't hold width open as sidebar shrinks */
  width: 0;
  overflow: hidden;
  white-space: nowrap;
  margin: 0;
  transition:
    opacity 0.18s cubic-bezier(0.32, 0.72, 0.18, 1),
    width 0.36s cubic-bezier(0.32, 0.72, 0.18, 1);
}

/* Big block elements still use display:none so they don't break the
 * narrow collapsed layout, but the sidebar width itself animates
 * fluidly so the transition still reads as smooth. */
.left-sidebar.collapsed .sidebar-brand-link,
.left-sidebar.collapsed .chat-history-list,
.left-sidebar.collapsed .left-sidebar-header {
  display: none;
}

.left-sidebar.collapsed .sidebar-brand {
  justify-content: center;
  padding: 14px 8px 8px;
}

/* Collapsed sidebar: swap the rectangular "expand" icon for the
 * DeepInsights logo circle. The full PNG is a wide lockup (mark + text);
 * background-size: auto 100% + background-position: left center crops to
 * the leftmost portion so only the circular mark is visible inside the
 * round button. On hover, fade in the original SVG icon so the
 * affordance to expand is still discoverable. Click behaviour is
 * unchanged (toggleLeftSidebar). */
.left-sidebar.collapsed .sidebar-toggle-btn {
  position: relative;
  width: 36px;
  height: 36px;
  min-width: 36px;
  flex: 0 0 36px;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  overflow: hidden;
  background: transparent;
  padding: 0;
}

/* The PNG is a 1280×271 lockup; the circular mark occupies roughly the
 * leftmost 271px (i.e. a square at the start). background-size: auto 100%
 * scales the image so its height matches the button, then we anchor it
 * left: at button height = 36px, the image renders ~170px wide and the
 * circle (originally 271/1280 ≈ 21% of width) occupies ~36×36px starting
 * at x=0 — exactly filling the round container with no distortion. */
.left-sidebar.collapsed .sidebar-toggle-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url('assets/logo_deepinsights.png');
  background-repeat: no-repeat;
  background-position: left center;
  background-size: auto 100%;
  transition: opacity 0.18s ease;
  pointer-events: none;
}

.left-sidebar.collapsed .sidebar-toggle-btn svg {
  position: relative;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.left-sidebar.collapsed .sidebar-toggle-btn:hover {
  background: var(--bg-cream);
}

.left-sidebar.collapsed .sidebar-toggle-btn:hover::before {
  opacity: 0;
}

.left-sidebar.collapsed .sidebar-toggle-btn:hover svg {
  opacity: 1;
}

/* Collapsed sidebar: show pulsing dots for live running chats */
.collapsed-live-chats {
  display: none;
}

.left-sidebar.collapsed .collapsed-live-chats {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
}

.collapsed-live-dot {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: rgba(192, 139, 92, 0.1);
  transition: background 0.15s;
}

.collapsed-live-dot:hover {
  background: rgba(192, 139, 92, 0.2);
}

.collapsed-live-dot .streaming-dot {
  width: 8px;
  height: 8px;
}

/* ── Collapsed sidebar: rigorous centring ────────────────────────────
 * The sidebar is 52px wide collapsed. Every row must render as a
 * 52px-wide flex container with its single icon dead-centred. Earlier
 * pass left subtle drift because base-rule padding was asymmetric
 * (8px 12px) and the active nav-link's peach bg was measured from the
 * padding edge, not the full row. This block wins with !important on
 * the alignment-critical properties so future additions don't silently
 * re-break it. */
.left-sidebar.collapsed {
  align-items: center;
}

.left-sidebar.collapsed .sidebar-brand {
  padding: 14px 0 10px !important;
  justify-content: center !important;
  width: 100% !important;
}

.left-sidebar.collapsed .sidebar-actions,
.left-sidebar.collapsed .sidebar-nav-group {
  padding: 8px 0 !important;
  width: 100% !important;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.left-sidebar.collapsed .sidebar-nav-link.hidden,
.left-sidebar.collapsed .sidebar-action-item.hidden {
  display: none !important;
}

.left-sidebar.collapsed .sidebar-action-item,
.left-sidebar.collapsed .sidebar-nav-link {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  width: 36px !important;          /* fixed pill width so the active
                                    * peach background is a tidy 36×36
                                    * square, not a full-width strip */
  height: 36px !important;
  padding: 0 !important;
  gap: 0 !important;
  margin: 2px auto !important;     /* horizontally centred in 52px */
  border-radius: 10px !important;
  box-sizing: border-box;
}

/* Fixed 18px icon — matches the uncollapsed base-rule size so icons
 * don't visually "pop" bigger on collapse. Block + auto margin nails
 * centring even if the SVG viewBox is slightly off-centre. */
.left-sidebar.collapsed .sidebar-action-item svg,
.left-sidebar.collapsed .sidebar-nav-link svg {
  width: 18px !important;
  height: 18px !important;
  flex-shrink: 0;
  display: block;
  margin: 0 auto;
}

/* The ⌘K kbd hint nudges the icon when rendered — hide while
 * collapsed. */
.left-sidebar.collapsed .sidebar-action-kbd { display: none !important; }

/* The inbox unread badge and any similar trailing accessories push
 * the icon off the horizontal centre of the 36×36 collapsed pill.
 * Hide all non-svg children by default — the inbox badge is then
 * hoisted back as a dot overlay (rule below). */
.left-sidebar.collapsed .sidebar-nav-link > *:not(svg):not(.inbox-badge):not(.auto-badge),
.left-sidebar.collapsed .sidebar-action-item > *:not(svg) {
  display: none !important;
}

/* Inbox unread indicator when collapsed: a small coral dot sits at the
 * top-right of the icon pill. The number is kept (for expanded state
 * and accessibility) but visually collapsed into a dot — keeps the
 * tiny pill calm while still signalling unread. */
.left-sidebar.collapsed .sidebar-nav-link {
  position: relative;                  /* anchor for the absolute dot */
}
/* Collapsed: shrink badge to a small, clean teal dot. The number is
   hidden but the element stays in the DOM for accessibility + expanded-
   state use. Soft pulse — no halo, no border, no inner shadow. */
.left-sidebar.collapsed #sidebarInboxBtn .inbox-badge,
.left-sidebar.collapsed #sidebarAutomationsBtn .auto-badge {
  display: block !important;
  position: absolute;
  top: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  min-width: 0;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 50%;
  background: var(--brand-teal);
  box-shadow: none;
  font-size: 0;
  line-height: 0;
  color: transparent;
  animation: sidebarBadgePulse 1.8s ease-in-out infinite;
}
.left-sidebar.collapsed #sidebarInboxBtn .inbox-badge.hidden,
.left-sidebar.collapsed #sidebarAutomationsBtn .auto-badge.hidden {
  display: none !important;
}
/* Hidden state (count = 0) still wins via its .hidden !important */
.left-sidebar.collapsed #sidebarInboxBtn .inbox-badge.hidden {
  display: none !important;
}


/* Header toggle button (inside sidebar) */
.sidebar-collapse-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-tertiary);
  transition: background 0.15s, color 0.15s;
  margin-left: auto;
}

.sidebar-collapse-btn:hover {
  background: var(--bg-cream);
  color: var(--text-primary);
}

.sidebar-collapse-btn svg {
  width: 16px;
  height: 16px;
}

/* Sidebar Responsive */
@media (max-width: 1024px) {
  .sidebar {
    width: 280px;
  }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    transform: translateX(100%);
    transition: transform 0.3s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }
}

/* ==================== ARTIFACT CANVAS (split-screen) ==================== */
.artifact-canvas {
  /* Width driven by --canvas-width CSS var (set inline via JS when user
   * drags the handle). Defaults to 60% on first load; clamped at 380px
   * min and 85vw max so the chat panel never disappears. */
  width: var(--canvas-width, 60%);
  min-width: 380px;
  max-width: 85vw;
  height: 100%;
  min-height: 0;
  background: var(--bg-white);
  border-left: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.08);
}

.artifact-canvas.hidden {
  display: none;
}

/* ── Canvas directory tree (CANVAS_TREE_ENABLED) ───────────────────────
 * Left rail listing Session > Turn-N > [Output, Ancillary] > files.
 * Hidden by default; canvas-tree.js sets body.flag-canvas-tree when the
 * server-side flag is on, switching the canvas to a 2-column grid and
 * showing the rail. .canvas-main wraps everything that used to live
 * directly under .artifact-canvas so the existing flex column behaviour
 * stays untouched in both flag-on and flag-off modes. */
.canvas-tree {
  display: none;
}
.canvas-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  flex: 1;
  min-width: 0;
}
body.flag-canvas-tree .artifact-canvas:not(.hidden) {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
}
body.flag-canvas-tree .artifact-canvas:not(.hidden) > .canvas-tree,
body.flag-canvas-tree .artifact-canvas:not(.hidden) > .canvas-main {
  min-height: 0;
  max-height: 100%;
}
body.flag-canvas-tree .artifact-canvas:not(.hidden) > .canvas-main {
  overflow: hidden;
}

/* ─── Canvas tree — Anthropic-grade restyle ───────────────────────────────
   Palette pulls Anthropic's brand swatches (Orange #d97757, Blue #6a9bcc,
   Green #788c5d, Cream #faf9f5, Dark #141413) and grafts them onto the
   project's existing tokens. Buckets earn distinct accents (output=orange,
   visuals=blue, ancillary=green), turns become hairline-bordered cards,
   leaves render type-tinted chips with monospace glyphs, and the active
   row gets a warm orange wash + caret. Per-bucket vertical guide-rule
   traces the indent so deep nesting stays legible. */
body.flag-canvas-tree .canvas-tree {
  --ct-bg:           #fbfaf6;
  --ct-border:       rgba(20, 20, 19, 0.07);
  --ct-border-soft:  rgba(20, 20, 19, 0.04);
  --ct-text:         #141413;
  --ct-text-soft:    #5c5f66;
  --ct-text-muted:   #8b8e96;
  --ct-hover:        rgba(20, 20, 19, 0.045);
  --ct-card-bg:      #ffffff;
  --ct-accent:       #d97757;                /* Anthropic Orange — active state */
  --ct-accent-soft:  rgba(217, 119, 87, 0.12);
  --ct-bucket-out:   #d97757;                /* Output = Orange */
  --ct-bucket-vis:   #6a9bcc;                /* Visuals = Blue */
  --ct-bucket-anc:   #788c5d;                /* Ancillary = Green */
  --ct-bucket-int:   #b66a9b;                /* Intermediate = Magenta */
  --ct-guide:        rgba(20, 20, 19, 0.07);
  --ct-final:        #9a6bd8;                /* Final synthesised deliverable = Violet */
  --ct-final-soft:   rgba(154, 107, 216, 0.12);

  display: block;
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid var(--ct-border);
  background: var(--ct-bg);
  padding: 0 0 24px;
  font-family: var(--font-sans, 'Plus Jakarta Sans', system-ui, sans-serif);
  font-size: 13px;
  color: var(--ct-text-soft);
  line-height: 1.45;
  scrollbar-width: thin;
  scrollbar-color: rgba(20,20,19,0.18) transparent;
}
body.flag-canvas-tree .canvas-tree[hidden] { display: none; }
.canvas-tree::-webkit-scrollbar { width: 8px; }
.canvas-tree::-webkit-scrollbar-thumb { background: rgba(20,20,19,0.12); border-radius: 8px; border: 2px solid var(--ct-bg); }
.canvas-tree::-webkit-scrollbar-thumb:hover { background: rgba(20,20,19,0.22); }

/* Sticky session header — stays pinned while long turn lists scroll. The
   sub-line carries the rolled-up "N files · M turns" counter from JS. */
.canvas-tree .ct-session { padding: 0; }
.canvas-tree .ct-session-head {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 16px 16px 14px;
  background: linear-gradient(180deg, var(--ct-bg) 75%, rgba(251,250,246,0));
  border-bottom: 1px solid var(--ct-border);
  margin-bottom: 8px;
}
.canvas-tree .ct-session-title {
  font-family: var(--font-display, var(--font-sans, 'Plus Jakarta Sans', system-ui, sans-serif));
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.012em;
  color: var(--ct-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}
.canvas-tree .ct-session-sub {
  font-size: 11px;
  font-weight: 500;
  color: var(--ct-text-muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.005em;
}

.canvas-tree .ct-turns { padding: 0 10px; display: flex; flex-direction: column; gap: 6px; }

/* Turn card — hairline border + soft white fill lifts each turn out of the
   cream background so boundaries are unmistakable. Open state strengthens
   the border + adds a faint shadow. */
.canvas-tree .ct-turn {
  background: var(--ct-card-bg);
  border: 1px solid var(--ct-border-soft);
  border-radius: 10px;
  margin: 0;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.canvas-tree .ct-turn[open] {
  border-color: var(--ct-border);
  box-shadow: 0 1px 2px rgba(20,20,19,0.025), 0 1px 0 rgba(20,20,19,0.015);
}
/* Selected turn — soft white lift + warm shadow. Defaults to the latest
   turn when nothing on the canvas maps to a turn; follows the open file. */
.canvas-tree .ct-turn:not(.ct-turn--selected) {
  background: rgba(255, 255, 255, 0.55);
  border-color: rgba(20, 20, 19, 0.06);
  box-shadow: none;
}
.canvas-tree .ct-turn--selected {
  background: #ffffff;
  border-color: rgba(20, 20, 19, 0.08);
  box-shadow:
    0 4px 14px rgba(20, 20, 19, 0.07),
    0 1px 3px rgba(20, 20, 19, 0.04);
}
.canvas-tree .ct-turn--selected[open] {
  border-color: rgba(217, 119, 87, 0.22);
  box-shadow:
    0 6px 18px rgba(20, 20, 19, 0.08),
    0 1px 3px rgba(217, 119, 87, 0.08);
}
/* Empty turns: same hairline card but desaturated, so the chat's turn
   skeleton is visible without competing for attention with populated
   cards. Hover still wakes up. */
.canvas-tree .ct-turn--empty { background: transparent; border-style: dashed; border-color: rgba(20,20,19,0.05); }
.canvas-tree .ct-turn--empty .ct-turn-label { color: var(--ct-text-soft); font-weight: 500; }
.canvas-tree .ct-turn-meta--empty { color: var(--ct-text-muted); font-style: italic; }
.canvas-tree .ct-turn-body--empty { padding: 0 12px 10px; }
.canvas-tree .ct-empty-inline {
  font-size: 11.5px;
  color: var(--ct-text-muted);
  font-style: italic;
  padding: 4px 8px;
  border-left: 2px solid rgba(20,20,19,0.06);
}
.canvas-tree .ct-turn-summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 12px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  user-select: none;
  border-radius: 10px;
  transition: background-color 140ms ease-out;
}
.canvas-tree .ct-turn-summary:hover { background: var(--ct-hover); }
.canvas-tree .ct-turn-summary::-webkit-details-marker { display: none; }
.canvas-tree .ct-turn-head { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.canvas-tree .ct-turn-label {
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.005em;
  color: var(--ct-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.canvas-tree .ct-turn-meta {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0 5px;
  min-width: 0;
  width: 100%;
  white-space: nowrap;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--ct-text-muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.005em;
}
.canvas-tree .ct-turn-time {
  white-space: nowrap;
  color: #888;
  font-weight: 500;
  flex: 0 0 auto;
}
.canvas-tree .ct-turn-meta-sep {
  display: inline-block;
  width: 1px;
  height: 11px;
  background: #1F1B17;
  flex: 0 0 auto;
  align-self: center;
}
.canvas-tree .ct-turn-pills {
  display: inline-flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 4px;
  flex: 0 0 auto;
}
.canvas-tree .ct-turn-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid #1F1B17;
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  flex: 0 0 auto;
}
.canvas-tree .ct-turn-pill--data {
  background: #f7f1ea;
  border-color: #eadfd4;
  color: #7d6b5d;
}
.canvas-tree .ct-turn-pill--insight {
  background: #eef6f1;
  border-color: #d7e8de;
  color: #5e7d6e;
}
.canvas-tree .ct-turn-pill--visual {
  background: #eef2f7;
  border-color: #d8e0ea;
  color: #5e7085;
}
.canvas-tree .ct-turn-pill-n {
  color: #1a1a1a;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.canvas-tree .ct-turn-pill-label {
  color: inherit;
  font-weight: 500;
  opacity: 0.9;
}

/* Caret — quietly rotates on open. Sized to align with the bucket dot below. */
.canvas-tree .ct-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 18px;
  flex: 0 0 14px;
  font-size: 13px;
  line-height: 1;
  color: var(--ct-text-muted);
  transition: transform 160ms ease-out;
}
.canvas-tree details[open] > summary .ct-caret { transform: rotate(90deg); }

.canvas-tree .ct-turn-body { padding: 0 8px 8px; }

/* Bucket — small caps section header with a color-coded dot. Per-bucket
   accent dot tints from the data-bucket attribute. The body indents with
   a soft vertical guide rule tracing the hierarchy. */
.canvas-tree .ct-bucket { margin: 0; padding: 0; }
.canvas-tree .ct-bucket-summary {
  list-style: none;
  cursor: pointer;
  padding: 6px 8px 6px 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: 6px;
  user-select: none;
  transition: background-color 140ms ease-out;
}
.canvas-tree .ct-bucket-summary::-webkit-details-marker { display: none; }
.canvas-tree .ct-bucket-summary:hover { background: var(--ct-hover); }
.canvas-tree .ct-bucket-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--ct-text-muted);
  flex: 0 0 6px;
}
.canvas-tree .ct-bucket[data-bucket="output"]    .ct-bucket-dot { background: var(--ct-bucket-out); }
.canvas-tree .ct-bucket[data-bucket="visuals"]   .ct-bucket-dot { background: var(--ct-bucket-vis); }
.canvas-tree .ct-bucket[data-bucket="ancillary"] .ct-bucket-dot { background: var(--ct-bucket-anc); }
.canvas-tree .ct-bucket[data-bucket="intermediate"] .ct-bucket-dot { background: var(--ct-bucket-int); }
.canvas-tree .ct-bucket-name {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ct-text-soft);
  flex: 1;
}
.canvas-tree .ct-bucket[data-bucket="ancillary"] .ct-bucket-name { color: var(--ct-text-muted); }
.canvas-tree .ct-bucket-count {
  font-size: 10.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ct-text-muted);
  background: rgba(20,20,19,0.04);
  border-radius: 999px;
  padding: 1px 7px;
  min-width: 18px;
  text-align: center;
}

/* Bucket body — leaves nest under a guide rule so the indent is traceable
   at a glance. The rule itself takes the bucket accent at low opacity. */
.canvas-tree .ct-bucket-body {
  position: relative;
  margin: 2px 0 4px;
  padding-left: 16px;
}
.canvas-tree .ct-bucket-body::before {
  content: '';
  position: absolute;
  left: 9px;
  top: 4px;
  bottom: 4px;
  width: 1px;
  background: var(--ct-guide);
  border-radius: 1px;
}
.canvas-tree .ct-bucket[data-bucket="output"]    .ct-bucket-body::before { background: color-mix(in srgb, var(--ct-bucket-out) 35%, transparent); }
.canvas-tree .ct-bucket[data-bucket="visuals"]   .ct-bucket-body::before { background: color-mix(in srgb, var(--ct-bucket-vis) 35%, transparent); }
.canvas-tree .ct-bucket[data-bucket="ancillary"] .ct-bucket-body::before { background: color-mix(in srgb, var(--ct-bucket-anc) 35%, transparent); }

/* Leaf row — full-width button with a type-tinted chip on the left. The
   chip carries the file glyph (X/W/P/T/{}/etc) and changes background tint
   by data-type. Hover wash is soft; active row gets the Anthropic-orange
   wash + a left rule + bolder weight. */
.canvas-tree .ct-leaf {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 6px 8px 6px 8px;
  background: transparent;
  border: 0;
  font: inherit;
  font-size: 12.5px;
  color: var(--ct-text-soft);
  text-align: left;
  cursor: pointer;
  border-radius: 7px;
  position: relative;
  transition: background-color 140ms ease-out, color 140ms ease-out;
}
.canvas-tree .ct-leaf + .ct-leaf { margin-top: 1px; }
.canvas-tree .ct-leaf:hover {
  background: var(--ct-hover);
  color: var(--ct-text);
}
.canvas-tree .ct-leaf--active {
  background: var(--ct-accent-soft);
  color: var(--ct-text);
  font-weight: 600;
}
.canvas-tree .ct-leaf--active::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  border-radius: 1px;
  background: var(--ct-accent);
}

/* Type chip — small rounded square with the file glyph. Tints per data-type
   for instant visual scanning. Defaults to a neutral wash. */
.canvas-tree .ct-leaf-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border-radius: 5px;
  background: rgba(20,20,19,0.06);
  color: var(--ct-text-soft);
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}
.canvas-tree .ct-leaf[data-type="sheet"] .ct-leaf-chip { background: rgba(120, 140, 93, 0.18);  color: #4f6038; }
.canvas-tree .ct-leaf[data-type="doc"]   .ct-leaf-chip { background: rgba(106, 155, 204, 0.18); color: #2f5b86; }
.canvas-tree .ct-leaf[data-type="pdf"]   .ct-leaf-chip { background: rgba(217, 119, 87, 0.18);  color: #a8542f; }
.canvas-tree .ct-leaf[data-type="text"]  .ct-leaf-chip { background: rgba(20, 20, 19, 0.08);    color: #3c3c3a; }
.canvas-tree .ct-leaf[data-type="web"]   .ct-leaf-chip { background: rgba(106, 155, 204, 0.14); color: #3a6a99; }
.canvas-tree .ct-leaf[data-type="image"] .ct-leaf-chip { background: rgba(176, 174, 165, 0.30); color: #5e5d57; }
.canvas-tree .ct-leaf[data-type="data"]  .ct-leaf-chip { background: rgba(232, 230, 220, 0.85); color: #6a6862; font-size: 9px; }
.canvas-tree .ct-leaf--active .ct-leaf-chip { background: rgba(217, 119, 87, 0.22); color: #a8542f; }

/* Final synthesised deliverable — the DAG's synthesis/report output, coloured
   apart from the per-node "leg" files so the user knows which one is THE final.
   Uses violet (distinct from the orange active accent + orange Output bucket):
   a soft violet chip, a stronger title, and a right-aligned "Final" pill. */
.canvas-tree .ct-leaf--final .ct-leaf-chip {
  background: var(--ct-final-soft);
  color: var(--ct-final);
}
.canvas-tree .ct-leaf--final .ct-leaf-title {
  font-weight: 650;
  color: var(--ct-text);
}
.canvas-tree .ct-leaf-final-badge {
  flex: 0 0 auto;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ct-final);
  background: var(--ct-final-soft);
  border: 1px solid rgba(154, 107, 216, 0.28);
  line-height: 1.4;
}
/* When the final row is also the active one, keep the violet badge legible
   over the orange active wash (the active state owns the left caret + bg). */
.canvas-tree .ct-leaf--final.ct-leaf--active .ct-leaf-final-badge {
  background: #ffffff;
}

/* Intermediate Data — MCP source pill parsed from `…_<slug>.md` filenames.
   Distinct from the Final violet badge (blue) so the two never collide. */
.canvas-tree .ct-leaf-mcp-badge {
  flex: 0 0 auto;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #2f5b86;
  background: rgba(106, 155, 204, 0.18);
  border: 1px solid rgba(106, 155, 204, 0.28);
  line-height: 1.4;
  max-width: 11em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.canvas-tree .ct-leaf--active .ct-leaf-mcp-badge {
  background: #ffffff;
}

.canvas-tree .ct-leaf-label {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  flex: 1;
}
.canvas-tree .ct-leaf-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}
.canvas-tree .ct-leaf-ext {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--ct-text-muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  flex: 0 0 auto;
}

/* Empty state — centred glyph + warm copy, claude.ai-style. */
.canvas-tree .ct-empty {
  padding: 48px 20px;
  color: var(--ct-text-muted);
  text-align: center;
  font-family: var(--font-display, var(--font-sans, 'Plus Jakarta Sans', system-ui, sans-serif));
}
.canvas-tree .ct-empty-glyph {
  font-size: 28px;
  color: var(--ct-bucket-out);
  opacity: 0.5;
  line-height: 1;
  margin-bottom: 12px;
}
.canvas-tree .ct-empty-line {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ct-text);
  letter-spacing: -0.005em;
  margin-bottom: 4px;
}
.canvas-tree .ct-empty-sub {
  font-size: 11.5px;
  font-weight: 400;
  color: var(--ct-text-muted);
  line-height: 1.5;
  max-width: 200px;
  margin: 0 auto;
}

/* Virtual "Progress" leaf — synthesized client-side from msg.interimFindings.
 * Sits above the bucket folders inside each turn. Streaming state pulses the
 * dot in Anthropic orange; settled state dims to the type-chip default. */
.canvas-tree .ct-leaf--progress {
  padding-left: 8px;
  margin-bottom: 4px;
  font-weight: 600;
  color: var(--ct-text);
}
.canvas-tree .ct-leaf--progress .ct-leaf-chip {
  background: var(--ct-accent-soft);
  color: var(--ct-accent);
  font-size: 11px;
}
.canvas-tree .ct-leaf--progress[data-progress-status="streaming"] .ct-leaf-chip {
  animation: ct-progress-pulse 1.6s ease-in-out infinite;
}
.canvas-tree .ct-leaf--progress[data-progress-status="streaming"] .ct-leaf-ext {
  color: var(--ct-accent);
}
@keyframes ct-progress-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217, 119, 87, 0.35); }
  50%      { box-shadow: 0 0 0 5px rgba(217, 119, 87, 0); }
}

/* ── Canvas-tree toolbar ─────────────────────────────────────────────────────
   Sticky bar at the top of the file-manager rail.  Holds collapse toggle +
   Select / Transform action buttons.  Lives above ct-session-head (z-index 3
   vs. session-head's z-index 2). */
.ct-toolbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 8px 10px 7px;
  background: var(--ct-bg, #fbfaf6);
  border-bottom: 1px solid var(--ct-border, rgba(20,20,19,0.07));
}
.ct-toolbar-actions { display: flex; align-items: center; gap: 5px; }

.ct-collapse-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(20,20,19,0.10);
  background: transparent;
  border-radius: 7px;
  color: var(--ct-text-muted, #8b8e96);
  cursor: pointer;
  transition: background .13s, color .13s, border-color .13s;
}
.ct-collapse-btn:hover { background: rgba(20,20,19,0.06); color: var(--ct-text, #141413); }

.ct-toolbar-btn {
  border: 1px solid rgba(20,20,19,0.11);
  background: rgba(255,255,255,0.7);
  color: var(--ct-text-soft, #5c5f66);
  border-radius: 7px;
  padding: 4px 9px;
  font-family: var(--font-sans, 'Plus Jakarta Sans', system-ui, sans-serif);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  white-space: nowrap;
  transition: background .13s, border-color .13s, color .13s;
}
.ct-toolbar-btn:hover { background: #fff; border-color: rgba(20,20,19,0.20); }
.ct-toolbar-btn--active {
  color: #7a4f1c;
  background: rgba(180,140,80,0.14);
  border-color: rgba(180,140,80,0.36);
}
.ct-toolbar-btn.ct-toolbar-btn-primary {
  color: #f8f5f0;
  background: linear-gradient(180deg, #986f4b 0%, #7b5839 100%);
  border-color: rgba(123,88,57,0.55);
}
.ct-toolbar-btn.ct-toolbar-btn-primary:hover {
  background: linear-gradient(180deg, #a37751 0%, #835d3d 100%);
}
.ct-toolbar-btn:disabled { opacity: 0.45; cursor: default; }

/* Select-mode leaf styles */
.canvas-tree .ct-leaf--selectable { cursor: pointer; }
.canvas-tree .ct-leaf-check {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border: 1.5px solid rgba(20,20,19,0.22);
  border-radius: 4px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: transparent;
  margin-right: 2px;
  transition: background .12s, border-color .12s, color .12s;
}
.canvas-tree .ct-leaf--selected .ct-leaf-check {
  background: var(--ct-accent, #d97757);
  border-color: var(--ct-accent, #d97757);
  color: #fff;
}
.canvas-tree .ct-leaf--selected {
  background: rgba(217,119,87,0.08);
  border-radius: 7px;
}

/* ── Horizontal collapse ─────────────────────────────────────────────────────
   Collapsed: no rail strip. Expand button floats at the top-left; tabs
   (and header) pad left so they clear the button without a full-height gutter. */
body.flag-canvas-tree .artifact-canvas:not(.hidden).ct-tree-collapsed {
  grid-template-columns: minmax(0, 1fr);
  position: relative;
}
/* Expanded (fullscreen) must win over collapsed-tree's position:relative —
   otherwise Expand does nothing while the tree rail is collapsed. */
body.flag-canvas-tree .artifact-canvas:not(.hidden).ct-tree-collapsed.expanded {
  position: fixed;
  top: 12px;
  right: 12px;
  bottom: 12px;
  left: 12px;
  width: auto;
  max-width: none;
  z-index: 100;
  grid-template-columns: minmax(0, 1fr);
}
body.flag-canvas-tree .artifact-canvas:not(.hidden).ct-tree-collapsed .artifact-session-tabs,
body.flag-canvas-tree .artifact-canvas:not(.hidden).ct-tree-collapsed .artifact-header {
  padding-left: 44px;
}
body.flag-canvas-tree .artifact-canvas:not(.hidden).ct-tree-collapsed .canvas-tree,
body.flag-canvas-tree .artifact-canvas:not(.hidden).ct-tree-collapsed .canvas-tree.ct-collapsed {
  position: absolute;
  top: 0;
  left: 0;
  width: 40px;
  height: 44px;
  max-width: 40px;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  overflow: visible !important;
  overflow-x: visible !important;
  overflow-y: visible !important;
  z-index: 60;
  pointer-events: none;
  scrollbar-width: none;
}
body.flag-canvas-tree .artifact-canvas:not(.hidden).ct-tree-collapsed .canvas-tree > *:not(.ct-toolbar) {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
  visibility: hidden !important;
}
body.flag-canvas-tree .artifact-canvas:not(.hidden).ct-tree-collapsed .canvas-tree .ct-toolbar-actions {
  display: none !important;
}
body.flag-canvas-tree .artifact-canvas:not(.hidden).ct-tree-collapsed .canvas-tree .ct-toolbar {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 61;
  pointer-events: auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  width: auto;
  height: auto;
  padding: 0;
  gap: 0;
  margin: 0;
  border: none;
  background: transparent;
  visibility: visible;
}
body.flag-canvas-tree .artifact-canvas:not(.hidden).ct-tree-collapsed .canvas-tree .ct-collapse-btn {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: #ffffff;
  border: 1px solid rgba(20, 20, 19, 0.10);
  box-shadow:
    0 2px 8px rgba(20, 20, 19, 0.08),
    0 1px 2px rgba(20, 20, 19, 0.04);
  color: #5c5f66;
  visibility: visible;
  pointer-events: auto;
  position: relative;
  z-index: 62;
  cursor: pointer;
}
body.flag-canvas-tree .artifact-canvas:not(.hidden).ct-tree-collapsed .canvas-tree .ct-collapse-btn:hover {
  background: #ffffff;
  color: #141413;
  border-color: rgba(217, 119, 87, 0.35);
  box-shadow:
    0 4px 12px rgba(20, 20, 19, 0.10),
    0 1px 3px rgba(217, 119, 87, 0.10);
}
body.flag-canvas-tree .artifact-canvas:not(.hidden).ct-tree-collapsed .canvas-tree .ct-collapse-btn svg {
  transform: rotate(180deg);
}

/* ── Canvas-tree Insights bucket accent ──────────────────────────────────── */
.canvas-tree { --ct-bucket-ins: #d97757; }
.canvas-tree .ct-bucket[data-bucket="insights"] .ct-bucket-dot { background: var(--ct-bucket-ins); }
.canvas-tree .ct-bucket[data-bucket="insights"] .ct-bucket-body::before { background: color-mix(in srgb, var(--ct-bucket-ins) 35%, transparent); }



/* ── Transform overlay (.at-overlay) ────────────────────────────────────────
   Purpose-built compact dialog, replacing the generic report-panel.
   Warm cream card, 460px wide, centred.  Keeps the project palette. */
.at-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20,20,19,0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.at-overlay.hidden { display: none; }

.at-modal {
  position: relative;
  background: #faf9f5;
  border-radius: 18px;
  width: 460px;
  max-width: 100%;
  box-shadow: 0 20px 60px rgba(20,20,19,0.22), 0 4px 16px rgba(20,20,19,0.10);
  padding: 36px 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.at-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 28px;
  height: 28px;
  border: none;
  background: rgba(20,20,19,0.06);
  border-radius: 8px;
  color: var(--text-tertiary, #8b8e96);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .13s, color .13s;
}
.at-modal-close:hover { background: rgba(20,20,19,0.12); color: var(--text-primary, #141413); }

.at-modal-icon {
  font-size: 22px;
  color: #d97757;
  margin-bottom: 10px;
  line-height: 1;
}
.at-modal-title {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 22px;
  font-weight: 500;
  color: var(--text-primary, #141413);
  margin: 0 0 6px;
  letter-spacing: -0.015em;
}
.at-modal-desc {
  font-size: 13px;
  color: var(--text-secondary, #5c5f66);
  line-height: 1.55;
  margin: 0 0 14px;
}

/* Selected-file chips strip */
.at-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 14px;
  min-height: 0;
}
.at-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(217,119,87,0.10);
  border: 1px solid rgba(217,119,87,0.28);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: #7a4220;
  max-width: 180px;
}
.at-chip-ext {
  background: rgba(217,119,87,0.18);
  border-radius: 4px;
  padding: 1px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #a8542f;
}
.at-chip-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Textarea */
.at-textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1.5px solid rgba(20,20,19,0.13);
  border-radius: 10px;
  background: #fff;
  padding: 12px 14px;
  font-family: var(--font-sans, 'Plus Jakarta Sans', system-ui, sans-serif);
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-primary, #141413);
  resize: vertical;
  min-height: 110px;
  transition: border-color .14s, box-shadow .14s;
  outline: none;
  margin-bottom: 18px;
}
.at-textarea:focus {
  border-color: #d97757;
  box-shadow: 0 0 0 3px rgba(217,119,87,0.15);
}
.at-textarea::placeholder { color: var(--text-tertiary, #b0ae9c); }

/* Footer actions */
.at-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.at-btn {
  border-radius: 9px;
  padding: 9px 18px;
  font-family: var(--font-sans, 'Plus Jakarta Sans', system-ui, sans-serif);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .13s, box-shadow .13s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.at-btn-cancel {
  border: 1px solid rgba(20,20,19,0.12);
  background: rgba(20,20,19,0.04);
  color: var(--text-secondary, #5c5f66);
}
.at-btn-cancel:hover { background: rgba(20,20,19,0.08); }
.at-btn-submit {
  border: 1px solid rgba(123,88,57,0.50);
  background: linear-gradient(180deg, #a8763a 0%, #7b5839 100%);
  color: #fdf8f2;
  box-shadow: 0 2px 8px rgba(123,88,57,0.28);
}
.at-btn-submit:hover {
  background: linear-gradient(180deg, #b57f3e 0%, #87603e 100%);
  box-shadow: 0 3px 12px rgba(123,88,57,0.36);
}
.at-btn:disabled { opacity: 0.5; cursor: default; box-shadow: none; }

/* Preset picker grid */
.at-presets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}
.at-preset-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 14px 14px 12px;
  background: #fff;
  border: 1.5px solid rgba(20,20,19,0.11);
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  transition: border-color .14s, box-shadow .14s, background .14s;
}
.at-preset-btn:hover {
  border-color: #d97757;
  background: rgba(217,119,87,0.04);
  box-shadow: 0 2px 10px rgba(217,119,87,0.12);
}
.at-preset-btn:active { background: rgba(217,119,87,0.08); }
.at-preset-icon {
  color: #d97757;
  display: flex;
  align-items: center;
  margin-bottom: 2px;
}
.at-preset-label {
  font-family: var(--font-sans, 'Plus Jakarta Sans', system-ui, sans-serif);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary, #141413);
  line-height: 1.2;
}
.at-preset-sub {
  font-size: 11.5px;
  color: var(--text-tertiary, #8b8e96);
  line-height: 1.3;
}
.at-preset-btn--other .at-preset-icon { color: var(--text-tertiary, #8b8e96); }
.at-preset-btn--other .at-preset-label { color: var(--text-secondary, #5c5f66); }

/* Step visibility */
.at-step { display: block; }
.at-step--hidden { display: none; }

/* Loading step */
.at-loading-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 8px 16px;
  gap: 14px;
  text-align: center;
}
.at-spinner svg {
  animation: at-spin 0.9s linear infinite;
  display: block;
}
@keyframes at-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.at-loading-label {
  font-family: var(--font-sans, 'Plus Jakarta Sans', system-ui, sans-serif);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary, #141413);
  margin: 0;
}
.at-loading-sub {
  font-size: 12.5px;
  color: var(--text-tertiary, #8b8e96);
  line-height: 1.5;
  margin: 0;
  max-width: 300px;
}

/* Back button in custom step */
.at-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  color: var(--text-secondary, #5c5f66);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  margin-bottom: 10px;
  transition: color .13s;
}
.at-back-btn:hover { color: var(--text-primary, #141413); }

/* Widen the modal slightly for the 2-col preset grid */
.at-modal { width: 500px; }

/* Canvas progress view — body of the synthetic 'progress' artifact, rendered
 * by renderProgressIntoPane. Same vertical scroll behaviour as the prose
 * preview, sticky header + pulsing dot while live. */
/* When Progress owns the preview pane, scroll lives only inside
 * .canvas-progress__body — never also on .artifact-pane (that double
 * scrollbar happened when a raced document iframe stacked under Progress). */
.artifact-preview-pane:has(> .canvas-progress) {
  overflow: hidden;
}
.canvas-progress {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  position: relative;   /* anchor for the jump-to-latest pill */

  /* ── Force light mode regardless of browser dark mode preference ──
   * Progress tab must look identical in light and dark browser themes.
   * color-scheme: light tells the browser to render scrollbars, form
   * controls, and system UI in light mode inside this subtree.
   * The CSS variable overrides below re-anchor all var(--*) references
   * used by child elements to their light-mode values. */
  color-scheme: light;
  --bg-primary: #ffffff;
  --bg-secondary: #f4f5f7;
  --bg-tertiary: #F4F5F7;
  --text-primary: #111318;
  --text-secondary: #5c5f66;
  --text-tertiary: #8B8E96;
  --border-subtle: #E6E7EB;
  --border-light: #e2e4e9;
  --accent-teal: #0B7A6E;
  --accent-coral: #c08b5c;
  background: #ffffff;
  color: #111318;
}
.canvas-progress__header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: var(--bg-primary, #fff);
  border-bottom: 1px solid var(--border-subtle, #E6E7EB);
}
.canvas-progress__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-teal, #0B7A6E);
  flex-shrink: 0;
}
.canvas-progress--streaming .canvas-progress__dot {
  animation: ct-progress-dot-pulse 1.4s ease-in-out infinite;
}
.canvas-progress--settled .canvas-progress__dot {
  background: var(--text-tertiary, #8B8E96);
}
@keyframes ct-progress-dot-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.78); }
}
.canvas-progress__title {
  flex: 1;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary, #111318);
}
.canvas-progress__count {
  font-size: 11px;
  color: var(--text-tertiary, #8B8E96);
  background: var(--bg-tertiary, #F4F5F7);
  padding: 2px 8px;
  border-radius: 999px;
}
.canvas-progress__artifact-wait {
  margin: 10px 20px 0;
  padding: 11px 12px 10px;
  border: 1px solid rgba(11, 122, 110, 0.18);
  border-radius: 10px;
  background: rgba(11, 122, 110, 0.06);
}
.canvas-progress__artifact-wait-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary, #111318);
}
.canvas-progress__artifact-wait-note {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--text-tertiary, #6f7680);
}
.canvas-progress__artifact-wait-bar {
  margin-top: 8px;
  height: 6px;
  border-radius: 999px;
  background: rgba(11, 122, 110, 0.14);
  overflow: hidden;
  position: relative;
}
.canvas-progress__artifact-wait-bar > span {
  position: absolute;
  top: 0;
  left: -45%;
  height: 100%;
  width: 45%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(11, 122, 110, 0.25) 0%, rgba(11, 122, 110, 0.75) 55%, rgba(11, 122, 110, 0.25) 100%);
  animation: canvas-progress-artifact-bar 1.2s ease-in-out infinite;
}
@keyframes canvas-progress-artifact-bar {
  0% { left: -45%; }
  100% { left: 100%; }
}
.canvas-progress__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 20px 24px;
  /* NO scroll-behavior:smooth — in Chromium it makes every programmatic scrollTop
     assignment animate, which turned the card-list rewrite's position-restore into a
     visible glide (the jump-to-top / scroll-back jitter). The one intentional smooth
     scroll is the "Jump to latest" pill, which passes behavior:'smooth' explicitly. */
}
/* Live heartbeat / terminal badge — sits at the end of the scroll content but updates
   on its own channel so a once-a-second tick never rewrites the card list above it. */
.canvas-progress__body > .ncs-foot { margin: 2px 0 0; }
/* Jump-to-latest pill — shown only when the user has scrolled up off the live tail.
   Auto-follow yields to them until they click it (or scroll back to the bottom). */
.canvas-progress__jump {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: #d97757;
  border: none;
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(217, 119, 87, 0.34);
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.canvas-progress__jump.is-visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.canvas-progress__jump:hover { background: #c2603f; }
.canvas-progress__jump-arrow { font-size: 13px; line-height: 1; }
.canvas-progress__empty {
  color: var(--text-tertiary, #8B8E96);
  font-style: italic;
  font-size: 13px;
  text-align: center;
  padding: 32px 0;
}
.canvas-progress__wave {
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px dashed var(--border-subtle, #E6E7EB);
}
.canvas-progress__wave:last-child { border-bottom: 0; }
.canvas-progress__wave-head {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
}
.canvas-progress__wave-idx {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-teal, #0B7A6E);
  background: rgba(11, 122, 110, 0.08);
  padding: 2px 8px;
  border-radius: 4px;
}
.canvas-progress__wave-md { font-size: 13.5px; line-height: 1.55; }
.canvas-progress__wave-md p { margin: 0 0 8px; }
.canvas-progress__wave-md a { color: var(--accent-teal, #0B7A6E); }

/* ── Canvas resize handle ────────────────────────────────────────────
 * Zero-width flex item sitting between .chat-main and .artifact-canvas
 * — takes no layout space, so the original chat↔canvas gap is
 * restored. The interactive grab zone and the visible grip are both
 * absolutely positioned over the canvas's left border, so the handle
 * looks like it's on the canvas edge instead of a separate divider
 * line in the gap. */
.canvas-resize-handle {
  display: none;
  width: 0;
  flex-shrink: 0;
  position: relative;
  z-index: 5;
  user-select: none;
}

.chat-view.has-artifact .canvas-resize-handle {
  display: block;
}

/* 12px wide invisible grab zone — straddles the canvas border so the
 * cursor change happens whether you're approaching from the chat side
 * or the canvas side. */
.canvas-resize-handle::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: -6px;
  width: 12px;
  cursor: col-resize;
  z-index: 1;
}

/* Visible grip — small vertical bar centred on the canvas border,
 * invisible by default, fades in on hover/drag. */
.canvas-resize-grip {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translate(-50%, -50%);
  width: 3px;
  height: 56px;
  border-radius: 3px;
  background: rgba(168, 118, 68, 0);
  transition: background 0.15s ease, height 0.15s ease, width 0.15s ease;
  pointer-events: none;
  z-index: 2;
}

.canvas-resize-handle:hover .canvas-resize-grip,
.canvas-resize-handle.dragging .canvas-resize-grip {
  background: var(--accent-coral-dark, #a87644);
  height: 72px;
  width: 3px;
}

.canvas-resize-handle:focus-visible::before {
  outline: 2px solid var(--accent-coral, #c08b5c);
  outline-offset: -2px;
}

/* Hide the handle when canvas is expanded (full-screen) — no chat to
 * resize against. */
.chat-view.artifact-expanded .canvas-resize-handle {
  display: none !important;
}

/* While dragging, disable text selection + iframe pointer events across
 * the whole page so the mouse stays with the handle even if it moves
 * outside the strip. JS toggles body.canvas-resizing. */
body.canvas-resizing,
body.canvas-resizing * {
  user-select: none !important;
  cursor: col-resize !important;
}
body.canvas-resizing iframe {
  pointer-events: none !important;
}

/* When the artifact canvas is visible, hide the regular progress sidebar
   so the chat can stay comfortable in the remaining space. */
.chat-view.has-artifact .sidebar {
  display: none;
}

/* Floor for the chat column when canvas is open — width at which the
   Data Explorer / Data & Analysis labels still fit (narrower → icons only). */
.chat-view.has-artifact .chat-main {
  min-width: 450px;
}

/* When chat is at its floor, shrink/cap the canvas instead of pushing it
   off-screen. Leave room for chat min + the chat-view gap. */
.chat-view.has-artifact .artifact-canvas:not(.expanded) {
  max-width: min(85vw, calc(100% - 450px - 12px));
  min-width: min(380px, calc(100% - 450px - 12px));
  flex-shrink: 1;
}

/* Session artifact tabs — glassy strip with a sliding indicator that
 * matches the canvas-tab pattern. Each open artifact in the session
 * is a tab; the active one is highlighted by a single glassy pill
 * that slides between tabs (CSS vars updated by JS in
 * renderArtifactSessionTabs). */
.artifact-session-tabs {
  display: flex;
  gap: 0;
  padding: 5px 8px;
  overflow: hidden;                  /* fit-only; overflow goes into "▼ N" popover */
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border-bottom: 1px solid rgba(26, 15, 5, 0.06);
  flex-shrink: 0;
  scrollbar-width: none;
  position: relative;
  --session-indicator-left: 8px;
  --session-indicator-width: 0px;
}
.artifact-session-tabs::-webkit-scrollbar { display: none; }
.artifact-session-tabs.hidden { display: none; }

.artifact-session-tabs::before {
  content: '';
  position: absolute;
  top: 5px;
  bottom: 5px;
  left: var(--session-indicator-left, 8px);
  width: var(--session-indicator-width, 0);
  background: rgba(255, 255, 255, 0.95);
  border-radius: 999px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 1px 3px rgba(26, 15, 5, 0.1),
    0 2px 6px -1px rgba(26, 15, 5, 0.08);
  transition:
    left 0.42s cubic-bezier(0.32, 0.72, 0.18, 1),
    width 0.42s cubic-bezier(0.32, 0.72, 0.18, 1);
  z-index: 0;
  pointer-events: none;
}

.artifact-session-tab {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border: none;
  background: transparent;
  border-radius: 999px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.28s cubic-bezier(0.32, 0.72, 0.18, 1);
  max-width: 200px;
}
.artifact-session-tab:hover { color: var(--text-primary); background: transparent; }
.artifact-session-tab.active {
  color: var(--text-primary);
  background: transparent;
  font-weight: 500;
  box-shadow: none;
}
.ast-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  opacity: 0.75;
}
.artifact-session-tab.active .ast-dot { opacity: 1; }
.ast-label {
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: none;          /* preserve real artifact title casing */
  letter-spacing: 0;
  font-family: 'EB Garamond', Georgia, serif;
  font-style: italic;
  font-size: 13px;
}

/* ── Per-tab close (X) ────────────────────────────────────────────── */
/* Chrome-style: visible always on active tab, on hover for inactive. */
.artifact-session-tab .ast-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 4px;
  border-radius: 50%;
  color: var(--text-tertiary);
  opacity: 0;
  transition: opacity 0.18s ease, background 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
}
.artifact-session-tab .ast-close svg { width: 10px; height: 10px; }
.artifact-session-tab:hover .ast-close,
.artifact-session-tab.active .ast-close { opacity: 0.7; }
.artifact-session-tab .ast-close:hover {
  opacity: 1;
  background: rgba(192, 57, 43, 0.14);
  color: #c0392b;
}

/* ── Progress tab (system-managed, non-closeable) ──────────────────── */
/* Progress tabs are pinned to the first position and cannot be closed.
   They're streaming system views that should remain visible throughout
   the query lifecycle. */
.artifact-session-tab.progress-tab {
  /* No close button, so adjust padding to match visual weight */
  padding-right: 16px;
}
.artifact-session-tab.progress-tab .ast-label {
  /* Slightly bolder to emphasize it's the active streaming view */
  font-weight: 500;
}

/* ── Overflow chevron "▼ N" ───────────────────────────────────────── */
.ast-more {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  margin-left: 2px;
  border: none;
  background: transparent;
  border-radius: 999px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: color 0.18s ease, background 0.15s ease;
  flex-shrink: 0;
}
.ast-more:hover {
  color: var(--text-primary);
  background: rgba(26, 15, 5, 0.06);
}
.ast-more svg { width: 12px; height: 12px; }
.ast-more-count {
  font-weight: 600;
  letter-spacing: 0.03em;
}

/* ── Hidden-tabs popover ──────────────────────────────────────────── */
.ast-more-popover {
  min-width: 220px;
  max-width: 320px;
  max-height: 60vh;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border: 1px solid rgba(26, 15, 5, 0.08);
  border-radius: 10px;
  box-shadow:
    0 8px 24px rgba(26, 15, 5, 0.12),
    0 2px 6px rgba(26, 15, 5, 0.06);
  padding: 4px;
}

.ast-more-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  transition: background 0.12s ease;
}
.ast-more-item:hover { background: rgba(26, 15, 5, 0.05); }
.ast-more-item .ast-label {
  flex: 1;
  font-style: normal;
  font-family: inherit;
  font-size: 13px;
}
.ast-more-item .ast-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  color: var(--text-tertiary);
  opacity: 0.6;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
}
.ast-more-item .ast-close svg { width: 11px; height: 11px; }
.ast-more-item .ast-close:hover {
  opacity: 1;
  background: rgba(192, 57, 43, 0.14);
  color: #c0392b;
}

/* ── Inline Source Card (cite popover) ─────────────────────────────── */
.cite-card {
  position: fixed;
  z-index: 9999;
  min-width: 360px;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border: 1px solid rgba(26, 15, 5, 0.08);
  border-radius: 12px;
  box-shadow:
    0 12px 32px rgba(26, 15, 5, 0.14),
    0 2px 6px rgba(26, 15, 5, 0.06);
  font-family: 'Plus Jakarta Sans', -apple-system, system-ui, sans-serif;
  font-size: 13px;
  color: var(--text-primary);
  overflow: hidden;
  animation: cite-card-pop-in 0.2s ease-out;
  transition: width 0.28s cubic-bezier(.2, .8, .2, 1), max-width 0.28s cubic-bezier(.2, .8, .2, 1), box-shadow 0.22s ease;
}
@keyframes cite-card-pop-in {
  from { opacity: 0; transform: translateY(6px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* HEAD */
.cite-card-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(26, 15, 5, 0.06);
  flex-wrap: wrap;
}
.cite-card-n {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 30px;
}
.cite-card-tier {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(26, 15, 5, 0.06);
  color: var(--text-secondary);
}
.cite-card-tier.t1 { background: #e0f2fe; color: #075985; }
.cite-card-tier.t2 { background: #ede9fe; color: #5b21b6; }
.cite-card-tier.t3 { background: #f3f4f6; color: #374151; }
.cite-card-fresh {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
}
.cite-card-fresh.fresh { background: #dcfce7; color: #166534; }
.cite-card-fresh.sla   { background: #fef3c7; color: #92400e; }
.cite-card-fresh.stale { background: #fde8e8; color: #991b1b; }
.cite-card-age {
  font-size: 11px;
  color: var(--text-tertiary);
}
.cite-card-close {
  margin-left: auto;
  background: none;
  border: 0;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-tertiary);
  padding: 0 4px;
  transition: color 0.15s ease;
}
.cite-card-close:hover { color: #c0392b; }

/* CITED CLAIM QUOTE */
.cite-card-claim {
  margin: 0;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(26, 15, 5, 0.06);
  font-style: italic;
  font-size: 12.5px;
  color: var(--text-secondary);
  background: rgba(26, 15, 5, 0.02);
  line-height: 1.4;
}

/* BODY (scrollable) */
.cite-card-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding-bottom: 4px;
}
.cite-card-section {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(26, 15, 5, 0.04);
}
.cite-card-section:last-child { border-bottom: 0; }
.cite-card-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  margin-bottom: 4px;
  font-weight: 600;
}
.cite-card-row {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 10px;
  padding: 3px 0;
  align-items: baseline;
}
.cite-card-row > span:first-child {
  color: var(--text-tertiary);
  font-size: 12px;
}
.cite-card-row a {
  word-break: break-all;
  color: #075985;
  text-decoration: underline;
  text-decoration-color: rgba(7, 89, 133, 0.35);
  text-underline-offset: 2px;
}
.cite-card-row a:hover { text-decoration-color: #075985; }

/* CONFIDENCE PILL */
.cite-card-confidence {
  border-radius: 8px;
  padding: 8px 10px;
  margin: 2px 0;
}
.cite-card-conf-high { background: #dcfce7; color: #166534; }
.cite-card-conf-med,
.cite-card-conf-medium { background: #fef3c7; color: #92400e; }
.cite-card-conf-low { background: #fde8e8; color: #991b1b; }
.cite-card-conf-na  { background: rgba(26, 15, 5, 0.04); color: var(--text-tertiary); }
.cite-card-conf-label {
  font-weight: 600;
  font-size: 13px;
}
.cite-card-conf-why {
  font-size: 11.5px;
  opacity: 0.85;
  margin-top: 3px;
  line-height: 1.4;
}

/* References subset list (appended under a parent [N] reference when the
   same source is cited multiple times in the body with different facts).
   Each .cite-subset-item is one row "[N.K] — short label". */
.cite-subset-list {
  margin: 4px 0 8px 18px;
  padding-left: 6px;
  border-left: 1.5px solid rgba(184, 128, 90, 0.35);
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-secondary, #5a4a3a);
}
.cite-subset-item { padding: 1px 0; }
.cite-subset {
  font-feature-settings: "tnum" 1;
  font-weight: 600;
  margin-right: 4px;
}

/* SLOT INTELLIGENCE (Stage-6 citation→slot mapping)
 *
 * Layout (top → bottom):
 *   1. Header  — description + slot_id chip + type chip + status pill
 *   2. Hero    — chosen value (large) + chosen source/tier line
 *   3. Excerpt — chosen source's supporting text snippet (blockquote)
 *   4. Ladder  — every candidate the slot considered, table form,
 *                chosen row marked with a filled bullet
 *   5. Footer  — freshness + gap_disclosure
 *
 * Palette stays in the warm-gold family that the rest of the citation
 * card uses. Pills + table tints reuse the existing ref-pill / status
 * pill colours so the card reads as one consistent surface. */
.cite-card-slot-section {
  background: rgba(184, 128, 90, 0.04);
  border-left: 2px solid #B8805A;
  padding-left: 11px;
  padding-right: 4px;
}
.cite-card-slot-header { margin: 4px 0 8px 0; }
.cite-card-slot-desc {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: #1F1B17;
  line-height: 1.4;
  margin-bottom: 5px;
}
.cite-card-slot-idline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.cite-card-slot-id {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  padding: 2px 7px;
  border-radius: 4px;
  background: #F3EFE9;
  color: #5C5048;
  border: 1px solid #E5DED2;
}
.cite-card-slot-type {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  background: #EEF1F4;
  color: #4F5D6B;
  border: 1px solid #DDE4EB;
}
.cite-card-slot-hero {
  margin: 8px 0;
  padding: 10px 12px;
  background: rgba(178, 122, 62, 0.07);
  border: 1px solid rgba(178, 122, 62, 0.24);
  border-radius: 7px;
}
.cite-card-slot-hero-value {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 19px;
  font-weight: 700;
  color: #7A4F1F;
  letter-spacing: -0.012em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.cite-card-slot-hero-source {
  margin-top: 4px;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 11.5px;
  font-weight: 500;
  color: #6F584A;
  letter-spacing: -0.005em;
}
.cite-card-slot-excerpt {
  margin: 8px 0;
  padding: 6px 11px;
  border-left: 2px solid #D9CDB8;
  background: #FAF7F1;
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 13px;
  line-height: 1.55;
  color: #3F362D;
  font-style: italic;
  border-radius: 0 4px 4px 0;
}
.cite-card-slot-ladder {
  margin: 10px 0 6px 0;
}
.cite-card-section-sublabel {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8C7B6A;
  margin-bottom: 4px;
}
.cite-card-slot-ladder table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
}
.cite-card-slot-ladder thead th {
  text-align: left;
  padding: 4px 6px;
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #8C7B6A;
  border-bottom: 1px solid #E5DED2;
}
.cite-card-slot-ladder tbody td {
  padding: 5px 6px;
  border-bottom: 1px solid rgba(229, 222, 210, 0.55);
  vertical-align: middle;
  color: #3F362D;
}
.cite-card-slot-ladder tbody tr:last-child td { border-bottom: 0; }
.cite-card-slot-ladder tbody tr.is-chosen {
  background: rgba(46, 138, 130, 0.06);
}
.cite-card-slot-ladder tbody tr.is-chosen td {
  font-weight: 600;
  color: #1F635D;
}
.cite-card-ladder-marker {
  width: 14px;
  text-align: center;
  color: #2E8A82;
  font-size: 12px;
  line-height: 1;
}
.cite-card-slot-ladder tbody tr:not(.is-chosen) .cite-card-ladder-marker {
  color: #C5BAA9;
}
.cite-card-ladder-source {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px;
  white-space: nowrap;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cite-card-ladder-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}
.cite-card-ladder-tier { color: #6F584A; white-space: nowrap; }
.slot-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 11.5px;
  line-height: 1.4;
}
.slot-status-filled   { background: #DEF1ED; color: #2E6B66; }
.slot-status-disputed { background: #fee2e2; color: #991b1b; }
/* Part 6 — Unverified: sub-agent-only candidate, no corroborating fetch.
   Amber pill so the user (and the writer reading the slim ledger) can
   spot at a glance that this figure needs human verification or a
   follow-up fetch. Distinguish from Disputed (red) which means
   contradicting sources, vs Unverified which means single-source-only. */
.slot-status-unverified { background: #fef3c7; color: #92400e; }

/* Commit 7 — Citation card structured-slot preview (timeseries + table).
 * Renders inside .cite-card-slot-section when the mapping has cell + cells_preview.
 * The cited cell is highlighted; disputed cells get an amber border. */

.cite-card-row--full { width: 100%; }

.cite-timeseries-preview {
  display: flex; flex-direction: column;
  margin: 6px 0 2px;
  max-height: 240px;
  overflow-y: auto;
  font-size: 11.5px;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
}
.cite-ts-row {
  display: flex; justify-content: space-between;
  padding: 2px 8px;
  border-bottom: 1px solid rgba(120, 120, 120, 0.1);
}
.cite-ts-row:last-child { border-bottom: 0; }
.cite-ts-period { color: #6F6660; font-variant-numeric: tabular-nums; }
.cite-ts-value { color: #3F3934; font-variant-numeric: tabular-nums; font-weight: 500; }
.cite-cell-secondary { color: #8B8278; font-weight: 400; }
.cite-ts-trunc { text-align: center; color: #8B8278; padding: 4px 0; font-style: italic; font-size: 11px; }

.cite-table-preview-wrap {
  margin: 6px 0 2px;
  max-height: 280px;
  overflow: auto;
}
.cite-table-preview {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}
.cite-table-preview th,
.cite-table-preview td {
  padding: 3px 8px;
  text-align: right;
  border: 1px solid rgba(120, 120, 120, 0.15);
  color: #3F3934;
}
.cite-table-preview thead th {
  background: #F7F2EA;
  font-weight: 600;
  color: #6F6660;
  text-align: center;
}
.cite-table-preview .cite-table-rowhead {
  background: #F7F2EA;
  font-weight: 500;
  color: #6F6660;
  text-align: left;
}
.cite-cell--cited {
  background: rgba(184, 128, 90, 0.18) !important;
  font-weight: 700;
  outline: 1.5px solid rgba(184, 128, 90, 0.7);
  outline-offset: -1.5px;
}
.cite-cell--disputed {
  background: rgba(245, 158, 11, 0.18);
}
.cite-cell--cited.cite-cell--disputed {
  outline: 1.5px solid rgba(245, 158, 11, 0.85);
}
/* In-line dispute marker — replaces literal `<DISPUTED: a vs b>` text that
   would otherwise leak through marked.parse into rendered table cells.
   The preprocessor (_disputeMarkerLinkify in renderer.js) rewrites the
   raw token to <span class="dispute-marker" title="…">⚠</span> BEFORE
   markdown rendering, so it survives as a real DOM element. The title
   attr carries the candidate values for hover; the visual is a compact
   warning glyph that fits inside a table cell. */
.dispute-marker {
  display: inline-block;
  font-size: 0.92em;
  line-height: 1;
  vertical-align: baseline;
  color: #C77F2A;                       /* warm amber — matches the soft red palette */
  background: rgba(245, 158, 11, 0.15);
  padding: 1px 6px;
  border-radius: 8px;
  border: 1px solid rgba(245, 158, 11, 0.45);
  cursor: help;
  user-select: none;
  font-weight: 600;
  margin: 0 2px;
  transition: background 0.12s, border-color 0.12s;
}
.dispute-marker:hover {
  background: rgba(245, 158, 11, 0.28);
  border-color: rgba(245, 158, 11, 0.75);
}
/* Inside a table cell — keep tight; no horizontal margin so it lives
   alongside the value cleanly (e.g. "9.2 % ⚠" instead of "9.2 % ⚠ "). */
table .dispute-marker,
.markdown-content table .dispute-marker {
  margin: 0 0 0 4px;
  font-size: 0.85em;
  padding: 0 5px;
}

/* ──────────────────────────────────────────────────────────────────────
   Magazine-article assembly for multi-section markdown responses
   (L4 today, L7 once shipped).

   The post-render pass (_magazineAssembleSections in renderer.js)
   wraps each H2-bounded section in <section class="article-section">,
   marks the first <p> as .lead, and wraps every <img> in
   <figure class="ig ig--right|--left"> — alternating sides — so prose
   flows around the figures instead of stacking below them.

   CRITICAL: no font / color / background / border-color overrides
   below. Every rule inherits silently from the surrounding
   .markdown-content cascade so L4's chat-panel typography stays
   exactly as it is today. We only add LAYOUT (drop-cap geometry,
   float widths, figure box rounding, caption padding).
   ────────────────────────────────────────────────────────────────────── */
.article-section {
  margin: 0 0 28px;
}
.article-section::after {
  content: '';
  display: block;
  clear: both;
}

/* Section-lede drop-cap removed per user feedback ("doesn't look good") — the
   first paragraph's first letter renders inline (no float, no min-height guard). */

/* Figure box — geometry only. Background, border-color, and text
   color inherit from the chat panel's existing surface styling. */
.article-section .ig {
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
  background: var(--surface-secondary, transparent);
  border: 1px solid var(--border-primary, transparent);
}
.article-section .ig img {
  width: 100%;
  height: auto;
  display: block;
  /* Soft height ceiling so a tall/near-square infographic can't tower
     over the prose. `contain` (not cover) bounds the box WITHOUT cropping
     any of the artwork — a tall image letterboxes against the figure's
     surface tint, a wide one fills the width as before. */
  max-height: 440px;
  object-fit: contain;
}
.article-section .ig figcaption {
  padding: 10px 14px;
  font-size: 12px;
  line-height: 1.5;
}
.article-section .ig figcaption b {
  display: block;
  font-size: 13px;
  margin-bottom: 2px;
  font-weight: 700;
}

/* Floated figures — alternating right / left in document order.
   Width strategy: % of container so the figure scales with the pane
   width; px cap ceilings the figure on very wide canvases. ~36% (≈300px
   at the 1000px measure) reads as a magazine spot illustration beside a
   ~2/3 prose column — NOT a half-page image. The old 48%/560px made the
   figure rival the text column and dominate the page. */
.article-section .ig--right {
  float: right;
  clear: right;
  width: min(36%, 360px);
  margin: 0.3em 0 16px 28px;
}
.article-section .ig--left {
  float: left;
  clear: left;
  width: min(36%, 360px);
  margin: 0.3em 28px 16px 0;
}
/* Solo figure (figures-only sections) — centred, comfortably sized but
   not full-bleed. */
.article-section .ig--solo {
  width: min(58%, 460px);
  float: none;
  margin: 4px auto 22px;
}

/* Mobile: floats clear, figures stack full-width — matches the
   compose.js media query at <680px. */
@media (max-width: 680px) {
  .article-section .ig--right,
  .article-section .ig--left,
  .article-section .ig--solo {
    float: none;
    width: 100%;
    margin: 0 0 18px;
  }
}

/* Library hierarchy and file-format language ------------------------- */
#libraryPage .lfm-session-row {
  border-left: 3px solid rgba(47, 111, 205, 0.55);
}

#libraryPage .lfm-turn-row {
  border-left: 3px solid rgba(218, 139, 54, 0.58);
}

#libraryPage .lfm-bucket-row {
  border-left: 3px solid rgba(32, 158, 139, 0.58);
}

#libraryPage .lfm-session-row .lfm-folder-icon-svg,
#libraryPage .lfm-tree-session .lfm-folder-icon-svg {
  color: #2f6fcd;
}

#libraryPage .lfm-turn-row .lfm-folder-icon-svg,
#libraryPage .lfm-tree-turn .lfm-folder-icon-svg {
  color: #dc913e;
}

#libraryPage .lfm-bucket-row .lfm-folder-icon-svg,
#libraryPage .lfm-tree-bucket .lfm-folder-icon-svg {
  color: #22a58d;
}

#libraryPage .lfm-tree-session.active {
  color: #2058aa;
  background: rgba(47, 111, 205, 0.13);
}

#libraryPage .lfm-tree-turn.active {
  color: #a65f16;
  background: rgba(220, 145, 62, 0.14);
}

#libraryPage .lfm-tree-bucket.active {
  color: #117563;
  background: rgba(34, 165, 141, 0.14);
}

#libraryPage .lfm-file-glyph {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 25px;
  height: 29px;
  flex: 0 0 auto;
  color: #69778b;
}

#libraryPage .lfm-file-glyph .lfm-file-icon-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  color: inherit;
}

#libraryPage .lfm-file-sheet {
  fill: currentColor;
  fill-opacity: 0.11;
}

#libraryPage .lfm-file-fold {
  fill: currentColor;
  fill-opacity: 0.22;
}

#libraryPage .lfm-file-ext {
  position: absolute;
  right: -5px;
  bottom: -2px;
  max-width: 31px;
  padding: 1px 3px;
  overflow: hidden;
  border-radius: 3px;
  color: #fff;
  background: currentColor;
  font: 750 6.5px/1.35 'Inter', system-ui, sans-serif;
  letter-spacing: 0;
  text-overflow: clip;
  white-space: nowrap;
}

#libraryPage .lfm-file-ext::first-line {
  color: #fff;
}

#libraryPage .lfm-file-glyph--excel { color: #16845b; }
#libraryPage .lfm-file-glyph--word { color: #3272c8; }
#libraryPage .lfm-file-glyph--pdf { color: #d34b4b; }
#libraryPage .lfm-file-glyph--powerpoint { color: #d36538; }
#libraryPage .lfm-file-glyph--markdown { color: #45627f; }
#libraryPage .lfm-file-glyph--image { color: #c0589d; }
#libraryPage .lfm-file-glyph--html { color: #168aa2; }
#libraryPage .lfm-file-glyph--json { color: #8b7b1d; }
#libraryPage .lfm-file-glyph--code { color: #4f657e; }

#libraryPage .lfm-file-glyph--excel .lfm-file-ext { background: #16845b; }
#libraryPage .lfm-file-glyph--word .lfm-file-ext { background: #3272c8; }
#libraryPage .lfm-file-glyph--pdf .lfm-file-ext { background: #d34b4b; }
#libraryPage .lfm-file-glyph--powerpoint .lfm-file-ext { background: #d36538; }
#libraryPage .lfm-file-glyph--markdown .lfm-file-ext { background: #45627f; }
#libraryPage .lfm-file-glyph--image .lfm-file-ext { background: #c0589d; }
#libraryPage .lfm-file-glyph--html .lfm-file-ext { background: #168aa2; }
#libraryPage .lfm-file-glyph--json .lfm-file-ext { background: #8b7b1d; }
#libraryPage .lfm-file-glyph--code .lfm-file-ext { background: #4f657e; }
#libraryPage .lfm-file-glyph--generic .lfm-file-ext { background: #69778b; }

#libraryPage .lfm-view--small .lfm-file-glyph,
#libraryPage .lfm-view--medium .lfm-file-glyph,
#libraryPage .lfm-view--large .lfm-file-glyph {
  width: 100%;
  height: 100%;
}

#libraryPage .lfm-tree-file .lfm-file-glyph {
  width: 15px;
  height: 18px;
}

#libraryPage .lfm-tree-file .lfm-file-ext {
  display: none;
}

.library-viewer-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 0 0 auto;
}

.library-viewer-chat-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 13px;
  border: 1px solid rgba(55, 105, 212, 0.28);
  border-radius: 7px;
  color: #fff;
  background: #3769d4;
  box-shadow: 0 2px 7px rgba(55, 105, 212, 0.18);
  font: 650 12px/1 'Inter', system-ui, sans-serif;
  cursor: pointer;
}

.library-viewer-chat-btn:hover {
  background: #2f5fc3;
}

.library-viewer-header #libraryViewerTitle {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════════════════
   L7 MAGAZINE V2 — Anthropic editorial. Scoped to .l7-mag-v2, which the
   renderer adds ONLY when the exec-summary masthead block is present
   (l7_magazine_v2 flag). OFF → never applies → V1 float layout untouched.
   APPROVED mockup: _magazine_mockup_full.html. Principle: SYMMETRY.
   ────────────────────────────────────────────────────────────────────── */
.l7-mag-v2 {
  /* Editorial palette — mirrors editorial-layout.html v2 reference. Page
     and illustration share a near-off-white cream so the card top edge
     blends seamlessly into the page; only the caption / chart-foot band
     is a clean #FFFFFF. Operator: "parchment cream has to be toned down
     a bit, towards light-cream moving towards off-white" — bumped from
     #F8F7F1 to #FBFAF5 (5 lightness steps brighter, less yellow). */
  --mag-paper:#FBFAF5;        /* page + illustration background — light cream / near-off-white */
  --mag-card:#FFFFFF;         /* caption band / chart-foot — clean white */
  --mag-ink:#2A2A28;          /* body text */
  --mag-soft:#403B33;         /* deck colour — warm dark, softer than ink */
  --mag-faint:#7C766A;        /* subtitle / labels grey */
  --mag-rule:#EFEDE4;         /* hairline — paired with the lighter paper tone */
  --mag-clay:#CE7A3E;         /* terracotta / burnt orange */
  --mag-clay-deep:#B5573B;
  --mag-slate:#1E3A5F;        /* deep navy ink (headings) */
  --mag-green:#6E9080;        /* sage-teal accent */
  --mag-shadow-bottom:0 10px 20px -14px rgba(30,58,95,.16);
  --mag-shadow-right:8px 6px 15px -18px rgba(30,58,95,.09);
  --mag-shadow-left:-8px 6px 15px -18px rgba(30,58,95,.09);
  background: var(--mag-paper); color: var(--mag-ink);
  font-family:'Source Serif 4','Newsreader','Tiempos',Georgia,serif;
  line-height:1.62;
  -webkit-font-smoothing:antialiased;
}
/* ── Editorial Brief masthead (spec) — classification strip · headline+dek ·
   4-KPI band · sources/doc-id footer. Background stays the page cream
   (--mag-paper #FBFAF5, set on .l7-mag-v2). Type ramp: navy headline, one
   terracotta accent, warm-gray everything else; weights never exceed 600. ── */
.l7-mag-v2 .l7-masthead { padding:0; margin:0 0 26px; border:0; }
/* 1 · classification strip */
.l7-mag-v2 .l7-mast-strip {
  display:flex; align-items:center; justify-content:space-between; gap:16px;
  padding:0 0 14px; border-bottom:1px solid #D6CCB8; margin:0 0 30px;
  font-family:'Inter','Plus Jakarta Sans',sans-serif;
}
.l7-mag-v2 .l7-mast-strip-l { display:flex; align-items:center; gap:14px; min-width:0; }
.l7-mag-v2 .l7-mast-strip-r { display:flex; align-items:center; gap:10px; min-width:0; }
.l7-mag-v2 .l7-mast-tick { flex:none; width:4px; height:14px; background:#C97A4E; }
.l7-mag-v2 .l7-kicker {
  font-family:'Inter','Plus Jakarta Sans',sans-serif;
  font-size:11px; font-weight:600; letter-spacing:.20em; text-transform:uppercase;
  color:#B86A3E; margin:0; white-space:nowrap;
}
.l7-mag-v2 .l7-mast-div { flex:none; width:1px; height:12px; background:#D6CCB8; }
.l7-mag-v2 .l7-mast-vol,
.l7-mag-v2 .l7-mast-date {
  font-size:11px; font-weight:400; letter-spacing:.11em; text-transform:uppercase;
  color:#8A8278; white-space:nowrap;
}
.l7-mag-v2 .l7-mast-class {
  font-size:11px; font-weight:400; letter-spacing:.14em; text-transform:uppercase;
  color:#5F584D; padding:3px 8px; border:1px solid #C9BFA9; border-radius:2px; white-space:nowrap;
}
/* 2 · headline + deck */
.l7-mag-v2 .l7-title {
  font-family:'Source Serif 4','Newsreader','Tiempos',Georgia,serif;
  font-size:clamp(30px,3.4vw,38px);
  font-weight:500; line-height:1.14; letter-spacing:-.012em;
  color:#1A3D5C; margin:0 0 14px;
}
.l7-mag-v2 .l7-deck {
  font-family:'Source Serif 4','Newsreader','Tiempos',Georgia,serif;
  font-size:clamp(16px,1.9vw,18px);
  font-weight:400; line-height:1.55; color:#4A4540;
  max-width:620px; margin:0; text-align:left; hyphens:none;
}
/* 3 · KPI band — hairline top+bottom, label → value+unit → methodology */
.l7-mag-v2 .l7-heroband {
  display:grid; grid-template-columns:repeat(4,1fr);
  border-top:1px solid #D6CCB8; border-bottom:1px solid #D6CCB8;
  padding:20px 0 22px; margin:30px 0 0;
}
.l7-mag-v2 .l7-stat { padding:0 16px; border-left:1px solid #E4DCC4; }
.l7-mag-v2 .l7-stat:first-child { padding-left:0; border-left:0; }
.l7-mag-v2 .l7-stat:last-child { padding-right:0; }
.l7-mag-v2 .l7-l {
  font-family:'Inter','Plus Jakarta Sans',sans-serif;
  font-size:11px; font-weight:500; letter-spacing:.14em; text-transform:uppercase;
  line-height:1.45; color:#8A8278; margin:0 0 14px; min-height:32px;
}
.l7-mag-v2 .l7-n {
  font-family:'Source Serif 4','Newsreader','Tiempos',Georgia,serif;
  font-size:36px; font-weight:500; line-height:1.0; letter-spacing:-.01em;
  color:#C97A4E; margin:0 0 8px; display:flex; align-items:baseline; flex-wrap:wrap;
}
.l7-mag-v2 .l7-n .l7-cur { font-size:.72em; font-weight:500; margin-right:.03em; }
.l7-mag-v2 .l7-n .l7-unit { font-size:.56em; font-weight:500; margin-left:.10em; }
.l7-mag-v2 .l7-n .l7-unit-sm { font-size:.36em; margin-left:.16em; letter-spacing:.02em; }
.l7-mag-v2 .l7-n .yoy { font-size:.5em; font-weight:400; margin-left:.14em; color:#8A8278; }
.l7-mag-v2 .l7-meth {
  font-family:'Inter','Plus Jakarta Sans',sans-serif;
  font-size:11px; font-weight:400; line-height:1.4; color:#7A7268; margin:0;
}
/* 4 · footer */
.l7-mag-v2 .l7-mast-foot {
  display:flex; align-items:center; justify-content:space-between; gap:16px;
  padding:14px 0 0; margin:0 0 40px;
  font-family:'Inter','Plus Jakarta Sans',sans-serif;
  font-size:11px; font-weight:400; letter-spacing:.08em; color:#8A8278;
}
.l7-mag-v2 .l7-foot-lbl { font-weight:600; letter-spacing:.14em; color:#5F584D; }
.l7-mag-v2 .l7-foot-id { letter-spacing:.14em; text-transform:uppercase; white-space:nowrap; }
@media (max-width:640px){
  .l7-mag-v2 .l7-heroband { grid-template-columns:repeat(2,1fr); gap:24px 0; }
  .l7-mag-v2 .l7-stat:nth-child(3) { border-left:0; padding-left:0; }
  .l7-mag-v2 .l7-mast-strip, .l7-mag-v2 .l7-mast-foot { flex-wrap:wrap; }
}
/* Editorial float-and-wrap — figure floats right/left (alternating per
   section), text wraps beside it for the figure's full height, then flows
   full-width below it. No grid, no flexbox side-by-side: just CSS float so
   text genuinely wraps under the image. Mirrors the editorial-layout.html
   reference. `.split` is a thin float container that clears at section end. */
.l7-mag-v2 .split { margin:12px 0 8px; }
.l7-mag-v2 .split::after { content:''; display:table; clear:both; }
.l7-mag-v2 .article-section { clear:both; }
/* .col-text is the WRAPPING text container. Plain block — no display:flex,
   no width, no grid — so float pushes its inline content correctly. */
.l7-mag-v2 .split .col-text > *:last-child { margin-bottom:0; }
/* The illustration card. Default float = right (matches reference's odd
   section); .split.flip flips to left for even sections. Width is FIXED
   (340px) per the reference — no percentage, no stretching. */
.l7-mag-v2 .col-fig {
  float:right; width:340px; margin:6px 0 18px 36px;
  background:var(--mag-paper);          /* illustration bleeds — same as page */
  border:0;                              /* NO border around the illustration */
  border-radius:16px; overflow:hidden;
  /* 3-layer shadow: bottom pool + lower-right + lower-left, NO top shadow,
     so the card top blends into the page seamlessly. */
  box-shadow: var(--mag-shadow-bottom), var(--mag-shadow-right), var(--mag-shadow-left);
  shape-outside:margin-box;
}
/* Body paragraphs — Source Serif 4 18.5px, justified, hyphenated. */
.l7-mag-v2 .article-section p {
  font-size:18.5px; line-height:1.62;
  margin:0 0 22px;
  text-align:justify; hyphens:auto;
}
@media (max-width:640px){
  .l7-mag-v2 .article-section p { text-align:left; }
}
.l7-mag-v2 .split.flip .col-fig { float:left; margin:6px 36px 18px 0; }
/* Illustration art block. NO padding — the SVG/image must bleed to all
   edges. Background is the page cream so any transparent edges blend. */
.l7-mag-v2 .col-fig .art {
  display:block; width:100%; padding:0;
  background:var(--mag-paper);
}
.l7-mag-v2 .col-fig img { display:block; width:100%; height:auto; }
.l7-mag-v2 .col-fig .inline-chart, .l7-mag-v2 .col-fig canvas, .l7-mag-v2 .col-fig svg {
  display:block; width:100%; max-width:100%;
}
/* Caption band — clean WHITE bottom band, subtle text. */
.l7-mag-v2 .col-fig .fig-cap {
  background:#FFFFFF;
  padding:14px 18px 16px;
  border-top:1px solid var(--mag-rule);
  border-bottom-left-radius:16px;
  border-bottom-right-radius:16px;
}
/* Caption TITLE — subtle: medium weight, slate (not navy), small caps tracking.
   Used to be 16px bold navy 'feature'; user wanted it subtler — caption-style
   byline rather than a callout heading. */
.l7-mag-v2 .col-fig .fig-cap b {
  display:block;
  font-family:'Inter','Plus Jakarta Sans',sans-serif;
  font-size:12.5px; font-weight:600;
  letter-spacing:.06em; text-transform:uppercase;
  color:var(--mag-slate);
  margin:0 0 4px;
}
.l7-mag-v2 .col-fig .fig-cap span {
  font-family:'Inter','Plus Jakarta Sans',sans-serif;
  font-size:13px; line-height:1.5; font-weight:400;
  color:var(--mag-faint);
}
/* When the writer emits a single descriptive prose alt (no '—' / '|' / ':'
   editorial split), the renderer wraps the whole thing in <b>. That reads
   loud and prosey — flatten it to the subtle muted style of the subtitle so
   it doesn't dominate the card. */
.l7-mag-v2 .col-fig .fig-cap:not(:has(span)) b {
  font-weight:400; text-transform:none; letter-spacing:0;
  font-size:13px; line-height:1.5; color:var(--mag-faint);
}
/* Section hero illustration — FULL-WIDTH banner. The Gemini data
   infographic (panel triptych etc.) renders as an editorial-magazine
   banner across the full column, with the alt-text caption beneath it
   as a horizontal byline. Reserved for class `l7-section-hero` (set by
   the orchestrator). Float-and-wrap (.col-fig) is reserved for in-text
   vector illustrations the writer emits separately. Operator: "section
   highlight (gemini image) should always be full display, not meant as
   split and float; split-and-float image is supposed to be generated
   as abstract small image as vector." */
.l7-mag-v2 img.l7-section-hero {
  display:block;
  clear:both;
  width:100%;
  height:auto;
  margin:8px 0 14px;
  border-radius:18px;
  background:var(--mag-paper);
  box-shadow: var(--mag-shadow-bottom), var(--mag-shadow-right), var(--mag-shadow-left);
}
/* Caption beneath the banner — derived from img alt-text via JS-free
   approach: the alt itself isn't visible by default, so the renderer
   emits an inline caption span next to the hero (see renderer.js
   _v2RenderHeroCaption). When that hook isn't present the banner just
   shows with no caption; the section's <h2> still tells the story. */
.l7-mag-v2 .l7-section-hero-cap {
  display:block;
  margin:-6px 0 28px;
  padding:0 4px;
  font-family:'Source Serif 4','Tiempos Text','Georgia',serif;
  color:var(--mag-deep-navy, #1E3A5F);
  font-size:18px;
  font-weight:600;
  letter-spacing:-0.005em;
}
.l7-mag-v2 .l7-section-hero-cap > b {
  font-weight:700;
}
.l7-mag-v2 .l7-section-hero-cap > span {
  display:block;
  margin-top:4px;
  font-family:'Inter','Plus Jakarta Sans',sans-serif;
  font-weight:400;
  font-size:14px;
  color:var(--mag-slate, #7C766A);
  letter-spacing:0;
}

/* Magazine-layout (.l7-mag-v2) section-lede drop-cap removed per user feedback
   ("doesn't look good") — the first paragraph's first letter renders inline
   (no float, no min-height guard, no terra colour). */

/* Chart-card shell — inline charts inside .l7-mag-v2 get the same shadow
   family as illustration cards. Full-width by default; the renderer's
   _v2ApplySplit already skips the float split for charts, so this rule
   takes effect for every emit_chart_svg block in an L7 magazine report. */
.l7-mag-v2 .inline-chart {
  clear:both;
  margin:14px 0 34px;
  border-radius:16px;
  overflow:hidden;
  background:var(--mag-paper);
  box-shadow: var(--mag-shadow-bottom), var(--mag-shadow-right), var(--mag-shadow-left);
}
.l7-mag-v2 .inline-chart .chart-title {
  padding:22px 26px 4px;
  font-family:'Inter','Plus Jakarta Sans',sans-serif;
  font-weight:700; font-size:16px; color:var(--mag-slate);
  margin:0 0 2px;
}
.l7-mag-v2 .inline-chart canvas,
.l7-mag-v2 .inline-chart svg { padding:8px 18px 20px; }

/* References section — chat-panel scroll box, twice as tall (680px vs the
   chat panel's 340px). Mirrors .references-box (style.css ~7422) but uses
   the magazine V2 editorial palette. The renderer adds .l7-references via
   _v2TagReferences when the section heading matches /references|sources|
   citations|bibliography/. */
.l7-mag-v2 .article-section.l7-references {
  max-height: 680px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--mag-rule) transparent;
  background: var(--mag-card);
  border: 1px solid var(--mag-rule);
  border-radius: 12px;
  padding: 20px 24px 16px;
  margin: 28px 0 12px;
}
.l7-mag-v2 .article-section.l7-references::-webkit-scrollbar { width: 6px; }
.l7-mag-v2 .article-section.l7-references::-webkit-scrollbar-track { background: transparent; }
.l7-mag-v2 .article-section.l7-references::-webkit-scrollbar-thumb {
  background: var(--mag-rule); border-radius: 3px;
}
.l7-mag-v2 .article-section.l7-references > h2 {
  font-size: 22px; font-weight: 600;
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--mag-rule);
  color: var(--mag-slate);
}
.l7-mag-v2 .article-section.l7-references > p {
  margin: 0;
  padding: 8px 0;
  border-bottom: 1px solid rgba(228, 218, 194, .5);
  font-size: 13.5px; line-height: 1.5;
  text-align: left; hyphens: none;
}
.l7-mag-v2 .article-section.l7-references > p:last-child { border-bottom: 0; }

/* Mobile — cards become full width, text left-aligned. */
@media (max-width:640px){
  .l7-mag-v2 .col-fig, .l7-mag-v2 .split.flip .col-fig {
    float:none; width:100%; margin:8px 0 28px;
  }
  .l7-mag-v2 .article-section.l7-references { max-height: 520px; }
}
/* Editorial data table. Two shapes:
   - default: text-heavy (scenarios, frameworks, narrative cells) — LEFT aligned,
     first column nowrap so labels like "Downside" don't break to "Downsid/e".
   - .dtable-numeric: pure data — RIGHT aligned + tabular-nums (auto-detected
     by _v2TagTables when every non-header data cell parses as a number).
   Both wrap inside .dtable-wrap which adds horizontal scroll for wide tables
   so columns are never compressed below their content width. */
.l7-mag-v2 .dtable-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 14px 0;
  /* Subtle right-edge fade hints scrollability when overflowing. */
  background:
    linear-gradient(to right, var(--mag-paper), var(--mag-paper)),
    linear-gradient(to right, var(--mag-paper), rgba(251,250,245,0)),
    linear-gradient(to left,  var(--mag-paper), rgba(251,250,245,0));
  background-position: left top, left top, right top;
  background-repeat: no-repeat;
  background-size: 20px 100%, 14px 100%, 14px 100%;
  background-attachment: local, scroll, scroll;
}
.l7-mag-v2 table.dtable {
  border-collapse: collapse;
  font-size: 15.5px;
  width: 100%;
  min-width: max-content;
}
.l7-mag-v2 table.dtable thead th {
  font-family: 'Inter','Plus Jakarta Sans',sans-serif;
  font-size: 11.5px; font-weight: 600;
  letter-spacing: .10em; text-transform: uppercase;
  color: var(--mag-faint);
  text-align: left;
  padding: 0 22px 10px 0;
  border-bottom: 2px solid var(--mag-slate);
  background: transparent; white-space: nowrap;
}
.l7-mag-v2 table.dtable thead th:last-child { padding-right: 0; }
.l7-mag-v2 table.dtable tbody td {
  padding: 12px 22px 12px 0;
  border-bottom: 1px solid var(--mag-rule);
  text-align: left;
  vertical-align: top;
  line-height: 1.5;
}
.l7-mag-v2 table.dtable tbody td:last-child { padding-right: 0; }
/* First column = row label. Keep it on one line and visually anchor it as
   the row's name (navy + semibold). Prevents "Downside" wrapping to two
   lines just because the column was sized to the longest cell across rows. */
.l7-mag-v2 table.dtable tbody td:first-child {
  white-space: nowrap;
  font-weight: 600;
  color: var(--mag-slate);
}
.l7-mag-v2 table.dtable tbody tr:last-child td { border-bottom: 0; }
/* Numeric variant — right-align + tabular-nums on every column except the row label. */
.l7-mag-v2 table.dtable.dtable-numeric thead th:not(:first-child),
.l7-mag-v2 table.dtable.dtable-numeric tbody td:not(:first-child) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
/* editorial accents on the shared .article-section bits */
.l7-mag-v2 .article-section h2 {
  font-family:'Newsreader','Tiempos',Georgia,serif; font-weight:500; font-size:38px;
  line-height:1.14; letter-spacing:-.015em; color:var(--mag-ink);
  margin:24px 0 14px;
}
.l7-mag-v2 .article-section h3 {
  font-family:'Newsreader','Tiempos',Georgia,serif; font-weight:600; font-size:24px;
  line-height:1.2; letter-spacing:-.01em; color:var(--mag-ink);
  margin:20px 0 10px;
}
.l7-mag-v2 a { color:var(--mag-clay-deep); }
@media (max-width:680px){
  .l7-mag-v2 .l7-heroband { grid-template-columns:repeat(2,1fr); }
  .l7-mag-v2 .split { grid-template-columns:1fr; gap:22px; }
  .l7-mag-v2 .split.flip .col-fig { order:0; }
}

/* Timeseries cell-cited variant (same styling, but inline-flex row) */
.cite-ts-row.cite-cell--cited {
  background: rgba(184, 128, 90, 0.12);
  border-radius: 4px;
}
.cite-ts-row.cite-cell--cited .cite-ts-value { font-weight: 700; color: #B8805A; }
.slot-status-partial  { background: #fef3c7; color: #92400e; }
.slot-value {
  font-weight: 600;
  font-feature-settings: "tnum" 1;
  color: var(--text-primary, #2a1f12);
}
.slot-conflict {
  color: #991b1b;
  font-weight: 500;
  font-feature-settings: "tnum" 1;
}
.slot-freshness {
  font-weight: 500;
  font-size: 11.5px;
}
.slot-freshness-fresh { color: #166534; }
.slot-freshness-sla   { color: #92400e; }
.slot-freshness-stale { color: #991b1b; }
.slot-gap {
  font-style: italic;
  color: var(--text-secondary, #5a4a3a);
  line-height: 1.4;
}

/* ACTIONS */
.cite-card-actions {
  flex: 0 0 auto;
  padding: 8px 10px;
  border-top: 1px solid rgba(26, 15, 5, 0.06);
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(26, 15, 5, 0.015);
}
.cite-card-actions-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.cite-card-btn {
  flex: 1 1 auto;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid rgba(26, 15, 5, 0.12);
  background: rgba(255, 255, 255, 0.7);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 11.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.cite-card-btn:hover:not([disabled]) {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(26, 15, 5, 0.2);
}
.cite-card-btn[disabled] {
  color: var(--text-tertiary);
  cursor: not-allowed;
  opacity: 0.55;
  background: rgba(26, 15, 5, 0.02);
}

/* References-row flash on "Show in references" click */
@keyframes cite-ref-flash {
  0%   { background-color: rgba(254, 243, 199, 0.95); }
  100% { background-color: transparent; }
}
.cite-ref-flash {
  animation: cite-ref-flash 1.5s ease-out;
}

/* Inline cite anchor — subtle hint that it's clickable for the popover */
a.cite {
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  font-weight: 500;
  border-bottom: 1px dotted currentColor;
  padding: 0 1px;
  border-radius: 2px;
  transition: background 0.12s ease;
}
a.cite:hover {
  background: rgba(7, 89, 133, 0.08);
}
/* Inside tables the values are bold, so a same-coloured [N] competes with the
   numbers. Keep the citation chip (dotted box, size, position) but tint it a
   shade lighter — the box uses currentColor, so a muted colour softens both
   the [N] text and its outline, making it secondary to the value. */
table a.cite {
  color: var(--text-tertiary, #9a948c);
  font-weight: 400;
}

/* ── Slot-aware citation tooltip ───────────────────────────────────────
 * When a [N] citation has been bound to a slot via the Stage-6 map,
 * decorateCitationsWithSlotTooltips() sets data-slot-id + companion
 * attributes and adds the .cite-with-slot class. Hover reveals a
 * floating pill showing slot_id (mono) + value + source + description.
 * Replaces the previous "user has to click the citation to see slot
 * info" path with an at-a-glance hover affordance. */
a.cite-with-slot {
  position: relative;
}
/* Reset the generic hover-bg so it doesn't fight the pill. */
a.cite-with-slot:hover {
  background: rgba(178, 122, 62, 0.10);
}
a.cite-with-slot::after {
  content: attr(data-slot-id);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  /* `--cite-pill-offset-x` is set by `_adjustCitePillPosition` (renderer.js)
   * on mouseenter — shifts the pill horizontally to clamp it inside the
   * viewport when the [N] sits near the left/right edge of the chat
   * pane. Defaults to 0 so unmeasured anchors render exactly as before. */
  transform: translate(calc(-50% + var(--cite-pill-offset-x, 0px)), 4px);
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  line-height: 1.4;
  padding: 6px 11px;
  background: #1F1B17;
  color: #F5EFE6;
  border-radius: 7px;
  white-space: nowrap;
  /* Safety net for slot_ids longer than the JS clamp expects: at most
   * 90vw wide; wrap with break-all if it would still overflow. */
  max-width: min(280px, calc(100vw - 24px));
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 50;
  box-shadow:
    0 6px 18px rgba(26, 15, 5, 0.22),
    0 2px 6px rgba(26, 15, 5, 0.10);
  /* Subtle warm-gold accent stripe so the pill reads as part of the
   * cream/gold reasoning palette, not a generic system tooltip. */
  border: 1px solid rgba(178, 122, 62, 0.55);
}
/* Triangle pointer */
a.cite-with-slot::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #1F1B17;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
  z-index: 51;
}
a.cite-with-slot:hover::after,
a.cite-with-slot:focus::after {
  opacity: 1;
  transform: translate(calc(-50% + var(--cite-pill-offset-x, 0px)), 0);
}
a.cite-with-slot:hover::before,
a.cite-with-slot:focus::before {
  opacity: 1;
}

/* Status-tinted left dot on the pill — green/amber/red micro-signal so
 * the user knows at a glance whether the slot was clean, disputed, or
 * a gap. Uses the same warm palette family as the rest of the card. */
a.cite-with-slot[data-slot-status]::after {
  padding-left: 18px;
}
a.cite-with-slot[data-slot-status="filled"]::after {
  box-shadow:
    inset 5px 0 0 0 #2E8A82,
    0 6px 18px rgba(26, 15, 5, 0.22),
    0 2px 6px rgba(26, 15, 5, 0.10);
}
a.cite-with-slot[data-slot-status="partial"]::after {
  box-shadow:
    inset 5px 0 0 0 #B27A3E,
    0 6px 18px rgba(26, 15, 5, 0.22),
    0 2px 6px rgba(26, 15, 5, 0.10);
}
a.cite-with-slot[data-slot-status="disputed"]::after {
  box-shadow:
    inset 5px 0 0 0 #C75B39,
    0 6px 18px rgba(26, 15, 5, 0.22),
    0 2px 6px rgba(26, 15, 5, 0.10);
}
a.cite-with-slot[data-slot-status="failed"]::after {
  box-shadow:
    inset 5px 0 0 0 #8C7B6A,
    0 6px 18px rgba(26, 15, 5, 0.22),
    0 2px 6px rgba(26, 15, 5, 0.10);
}

/* Citation Excerpt In-Card */
.cite-card-expanded {
  max-width: min(760px, calc(100vw - 24px));
  width: min(760px, calc(100vw - 24px));
  box-shadow:
    0 16px 40px rgba(26, 15, 5, 0.18),
    0 4px 10px rgba(26, 15, 5, 0.08);
}
.cite-card-excerpt-section {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-bottom: 0;
  transform: translateY(-4px);
  overflow: hidden;
  pointer-events: none;
  transition:
    max-height 0.3s cubic-bezier(.2, .8, .2, 1),
    opacity 0.2s ease,
    padding 0.26s ease,
    transform 0.26s ease;
}
.cite-card-excerpt-section.is-open {
  /* Let the card body own scrolling; avoid nested scroll clipping near actions. */
  max-height: 12000px;
  opacity: 1;
  padding-top: 10px;
  padding-bottom: 12px;
  transform: translateY(0);
  pointer-events: auto;
  overflow: visible;
  background: rgba(26, 15, 5, 0.018);
}
.cite-excerpt-loading,
.cite-excerpt-error,
.cite-excerpt-empty {
  padding: 12px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-secondary);
  border: 1px dashed rgba(26, 15, 5, 0.15);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  animation: cite-fade-in 0.2s ease-out;
}
.cite-excerpt-error {
  color: #c0392b;
}
.cite-excerpt-item {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(26, 15, 5, 0.08);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  animation: cite-item-in 0.24s ease-out both;
}
.cite-excerpt-item:last-child {
  margin-bottom: 0;
}
.cite-excerpt-item-header {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  word-break: break-all;
}
.cite-excerpt-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px;
  padding: 4px 0;
  font-size: 12px;
  border-bottom: 1px solid rgba(26, 15, 5, 0.06);
}
.cite-excerpt-row:last-of-type {
  border-bottom: none;
}
.cite-excerpt-row > span:first-child {
  font-weight: 600;
  color: var(--text-secondary);
}
.cite-excerpt-row > span:last-child {
  color: var(--text-primary);
  word-break: break-word;
}
.cite-excerpt-content {
  margin-top: 8px;
  padding: 10px;
  background: white;
  border: 1px solid rgba(26, 15, 5, 0.1);
  border-radius: 6px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  animation: cite-fade-in 0.22s ease-out;
}
@keyframes cite-fade-in {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes cite-item-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.artifact-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Tight top padding so the artifact title + tab strip sit closer to
   * the top of the canvas viewport — eliminates the dead space the user
   * was seeing above the "TCS Quarterly Revenue…" pill. Bottom retains
   * the original 14px so the border-bottom has breathing room. */
  padding: 6px 20px 10px 20px;
  border-bottom: 1px solid var(--border-light);
  gap: 16px;
  flex-shrink: 0;
}

.artifact-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.artifact-type-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--bg-cream);
  border: 1px solid var(--border-light);
  color: var(--accent-coral-dark);
  font-family: 'Monaco', 'Menlo', monospace;
  flex-shrink: 0;
}

/* Artifact-writer phase pill — disabled (Drafting/Polishing kept coming back). */
.artifact-phase-pill {
  display: none !important;
}
.artifact-phase-pill .aph-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
  flex-shrink: 0;
}
.artifact-phase-pill[data-phase="drafting"] {
  color: #6b7d8f;
  background: rgba(107, 125, 143, 0.08);
  border-color: rgba(107, 125, 143, 0.18);
}
.artifact-phase-pill[data-phase="polishing"] {
  color: var(--accent-coral-dark, #b66c4d);
  background: rgba(192, 139, 92, 0.08);
  border-color: rgba(192, 139, 92, 0.22);
}
.artifact-phase-pill[data-phase="drafting"] .aph-dot,
.artifact-phase-pill[data-phase="polishing"] .aph-dot {
  animation: aphPulse 1.4s ease-in-out infinite;
}
/* Post-stream "finalizing" state was moved out of the inline pill
 * and into the #finalizeIsland dynamic-island element — see the
 * .finalize-island rule block below for the liquid-glass treatment.
 * Inline-pill rules for "finalizing" intentionally absent here. */
.artifact-phase-pill[data-phase="final"] {
  color: #2e7d4f;
  background: rgba(46, 125, 79, 0.08);
  border-color: rgba(46, 125, 79, 0.22);
}
.artifact-phase-pill[data-phase="final"] .aph-dot {
  background: #2e7d4f;
}
@keyframes aphPulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}

.artifact-title {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 20px;
  font-weight: 500;
  color: var(--text-primary);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.artifact-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

/* Subtle vertical divider between the tab pill and the action-button row
   so the two groups read as distinct clusters even when compacted. */
.artifact-actions .artifact-tabs { margin-right: 8px; }
.artifact-actions .artifact-tabs + .artifact-action-btn::before,
.artifact-actions .artifact-tabs + .artifact-download-group::before {
  content: ''; position: absolute; left: -5px; top: 6px; bottom: 6px;
  width: 1px; background: rgba(26, 15, 5, 0.08);
}
.artifact-actions .artifact-tabs + .artifact-action-btn,
.artifact-actions .artifact-tabs + .artifact-download-group { position: relative; margin-left: 4px; }

/* Glassy tab strip with a fluid sliding indicator. The active "pill"
 * is a single ::before on the container that slides between tabs via
 * CSS variables (--tab-indicator-left / --tab-indicator-width) updated
 * by switchArtifactTab(). The container itself is a frosted-glass
 * surface — semi-transparent white over the canvas with a backdrop
 * blur and a subtle inner highlight. */
.artifact-tabs {
  position: relative;
  display: flex;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  padding: 3px;
  margin-right: 4px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 1px 2px rgba(26, 15, 5, 0.06),
    0 4px 12px -4px rgba(26, 15, 5, 0.08);
  --tab-indicator-left: 3px;
  --tab-indicator-width: 0px;
}

.artifact-tabs::before {
  content: '';
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: var(--tab-indicator-left, 3px);
  width: var(--tab-indicator-width, 0);
  background: rgba(255, 255, 255, 0.95);
  border-radius: 999px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 1px 3px rgba(26, 15, 5, 0.1),
    0 2px 6px -1px rgba(26, 15, 5, 0.08);
  transition:
    left 0.42s cubic-bezier(0.32, 0.72, 0.18, 1),
    width 0.42s cubic-bezier(0.32, 0.72, 0.18, 1);
  z-index: 0;
  pointer-events: none;
}

.artifact-tab {
  position: relative;
  z-index: 1;
  padding: 5px 14px;
  border: none;
  background: transparent;
  border-radius: 999px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: color 0.28s cubic-bezier(0.32, 0.72, 0.18, 1);
}

.artifact-tab:hover { color: var(--text-primary); }
.artifact-tab.active { color: var(--text-primary); background: transparent; box-shadow: none; }

/* (.artifacts-floating-btn rule removed — the library opener now lives
 * inline as the last .artifact-action-btn in the canvas action row,
 * inheriting the standard action-button styling.) */

/* My Files pagination — sits below the grid in each library pane (uploads
 * + artifacts). Numbered buttons with first/last + current ± 1 windowing,
 * Prev / Next on the ends, and a "X–Y of Z" summary on the right. */
.artifacts-pager {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  padding: 18px 4px 8px;
  margin-top: 6px;
  border-top: 1px solid rgba(26, 15, 5, 0.06);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
}
.artifacts-pager-btn {
  min-width: 30px;
  height: 28px;
  padding: 0 9px;
  border: 1px solid rgba(26, 15, 5, 0.10);
  background: transparent;
  border-radius: 6px;
  color: var(--text-secondary, #4a4d54);
  font: inherit;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.artifacts-pager-btn:hover:not(:disabled) {
  background: rgba(26, 15, 5, 0.05);
  color: var(--text-primary, #111318);
  border-color: rgba(26, 15, 5, 0.18);
}
.artifacts-pager-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.artifacts-pager-btn.active {
  background: var(--text-primary, #111318);
  color: #fff;
  border-color: var(--text-primary, #111318);
}
.artifacts-pager-gap {
  padding: 0 4px;
  color: var(--text-tertiary, #8b8e96);
  user-select: none;
}
.artifacts-pager-summary {
  margin-left: auto;
  color: var(--text-tertiary, #8b8e96);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.artifact-action-btn {
  width: 28px; height: 28px;
  border: none; border-radius: 8px;
  background: transparent;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-tertiary, #8b8e96);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.08s ease;
}
.artifact-action-btn:hover {
  background: rgba(26, 15, 5, 0.06);
  color: var(--text-primary, #111318);
}
.artifact-action-btn:active { transform: scale(0.94); }
.artifact-action-btn svg { width: 14px; height: 14px; }

/* Primary-action tint: Validate, Edit and Re-design get a soft coral
   hover so they stand apart from passive utilities (copy / download /
   expand / close) without being loud. */
.artifact-validate-btn:hover,
.artifact-edit-btn:hover,
.artifact-redesign-btn:hover {
  background: rgba(192, 139, 92, 0.12);
  color: var(--accent-coral-dark, #a87644);
}
.artifact-edit-btn.active,
.artifact-redesign-btn.active {
  background: rgba(192, 139, 92, 0.14);
  color: var(--accent-coral-dark, #a87644);
}
.artifact-validate-btn.validated {
  color: var(--accent-coral, #c08b5c);
}

/* Insights button — wider pill with icon + text label */
.artifact-insights-btn {
  width: auto !important;
  padding: 0 12px;
  gap: 5px;
  font-family: inherit;
  color: var(--text-secondary, #5c5f66);
}
.artifact-insights-btn:hover {
  background: rgba(217, 119, 87, 0.10) !important;
  color: #bf6240 !important;
}
.artifact-insights-btn svg { stroke: currentColor; }

/* ── Insight slash-command assistant bubble status spans ─────────────── */
.insight-bubble-status {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 0.875rem;
  line-height: 1.5;
}
.insight-bubble-status--searching {
  color: var(--text-secondary, #6b7280);
}
.insight-bubble-status--searching::after {
  content: '';
  display: inline-block;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: currentColor;
  margin-left: 4px;
  animation: insight-dot-blink 1.1s ease-in-out infinite;
}
@keyframes insight-dot-blink {
  0%, 100% { opacity: 0.2; transform: scale(0.8); }
  50%       { opacity: 1;   transform: scale(1.2); }
}
.insight-bubble-status--done {
  color: var(--text-primary, #111827);
}
.insight-bubble-status--done strong { color: inherit; }
.insight-bubble-status--error {
  color: #dc2626;
}

/* Close sits at the trailing end; give it a slightly more destructive
   hover cue so the target is obvious without being alarming. */
.artifact-actions > button:last-child:hover {
  background: rgba(192, 57, 43, 0.08);
  color: #c0392b;
}

/* ── Artifact download button + format menu ─────────────────────────────
 * Single Download button (no caret). Click ALWAYS opens the format menu
 * — there is no default extension; the user picks every time. The menu
 * is anchored to the button via .artifact-download-group as the
 * positioning context. */
.artifact-download-group {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.artifact-download-group .artifact-download-primary {
  border-radius: 6px;
}

/* ── Primary download button loading state ────────────────────────────
 * When a download is in-flight (native file fetch, server conversion),
 * the arrow icon fades out and a coral-ring spinner fades in. Button is
 * also `disabled` at the same time so double-clicks can't fire parallel
 * downloads. */
.artifact-download-primary.loading {
  cursor: wait;
  position: relative;
}

.artifact-download-primary.loading svg {
  opacity: 0;
  transition: opacity 0.12s ease;
}

.artifact-download-primary.loading::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  top: 50%;
  left: 50%;
  margin-top: -7px;
  margin-left: -7px;
  border: 1.8px solid var(--border-light);
  border-top-color: var(--accent-coral, #c08b5c);
  border-radius: 50%;
  animation: artifact-download-spin 0.7s linear infinite;
}

@keyframes artifact-download-spin {
  to { transform: rotate(360deg); }
}

/* Pulse ring around the whole group while either primary or a menu row
 * is downloading — makes the location of the feedback obvious even if
 * the user has scrolled away. Uses box-shadow so it doesn't disrupt
 * layout. */
.artifact-download-group:has(.artifact-download-primary.loading),
.artifact-download-group:has(.artifact-download-menu-item[aria-disabled="true"]) {
  position: relative;
}

.artifact-download-group:has(.artifact-download-primary.loading)::after,
.artifact-download-group:has(.artifact-download-menu-item[aria-disabled="true"])::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 8px;
  border: 1.5px solid var(--accent-coral, #c08b5c);
  opacity: 0;
  animation: artifact-download-halo 1.4s ease-out infinite;
  pointer-events: none;
}

@keyframes artifact-download-halo {
  0% { opacity: 0.6; transform: scale(0.98); }
  100% { opacity: 0; transform: scale(1.12); }
}

/* Dropdown menu — anchored below the group, right-aligned so it doesn't
 * spill off the canvas edge. Opens downward (unlike the composer dropdowns
 * which open upward). Hidden by default; .open class reveals it. */
.artifact-download-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.10), 0 2px 6px rgba(0, 0, 0, 0.04);
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.14s ease, visibility 0.14s, transform 0.14s ease;
  z-index: 1000;
}

.artifact-download-group.open .artifact-download-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.artifact-download-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text-primary);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background 0.12s;
}

.artifact-download-menu-item:hover,
.artifact-download-menu-item:focus-visible {
  background: var(--bg-cream);
  outline: none;
}

.artifact-download-menu-item[aria-disabled="true"] {
  opacity: 0.55;
  cursor: wait;
}

.artifact-download-menu-label {
  font-weight: 500;
}

.artifact-download-menu-ext {
  font-family: 'Monaco', 'Menlo', ui-monospace, monospace;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 2px 7px;
  background: var(--bg-cream);
  border-radius: 4px;
}

.artifact-download-menu-item:first-child .artifact-download-menu-ext {
  color: var(--accent-coral);
  background: rgba(192, 139, 92, 0.10);
}

/* Inline spinner shown on a row while a server conversion is in flight */
.artifact-download-menu-spinner {
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--border-light);
  border-top-color: var(--accent-coral);
  border-radius: 50%;
  animation: art-dl-spin 0.7s linear infinite;
  display: none;
}

.artifact-download-menu-item[aria-disabled="true"] .artifact-download-menu-spinner {
  display: inline-block;
}
.artifact-download-menu-item[aria-disabled="true"] .artifact-download-menu-ext {
  display: none;
}

@keyframes art-dl-spin {
  to { transform: rotate(360deg); }
}

.artifact-body {
  flex: 1;
  min-height: 0; /* allow shrink so iframe fills viewport; sheet tabs stay visible */
  position: relative;
  overflow: hidden;
  background: var(--bg-white);
}

.artifact-pane {
  display: none;
  position: absolute;
  inset: 0;
  overflow: auto;
}

.artifact-pane.active {
  display: block;
}

:is(.artifact-preview-pane, .artifact-validated-pane) {
  background: var(--bg-white);
}

/* HTML iframe fills the preview pane */
:is(.artifact-preview-pane, .artifact-validated-pane) iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: white;
}

/* Enterprise-grade markdown artifact rendering. Mirrors the docx
   styling rules so the canvas preview and the downloaded .docx look
   like the same document. Navy → blue → teal heading hierarchy on a
   warm cream wash, coral accent rule under the cover h1, navy-header
   tables with alternating cream rows, coral pull-quote callouts. */
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown {
  padding: 44px 64px 60px;
  /* Wider editorial measure so the magazine layout (floated figures +
     wrapping prose) has room to breathe. At 760px a 48% figure left only
     a cramped ~360px prose column; ~1000px gives a clean 1/3-figure :
     2/3-prose split. Content still centres in a wider canvas pane. */
  max-width: 1000px;
  margin: 0 auto;
  font-family: 'Source Serif 4', 'Charter', 'Iowan Old Style', Georgia, serif;
  font-size: 17px;
  line-height: 1.7;
  color: #1a202c;
  background: #fdfaf6;
  border-radius: 8px;
  overflow: hidden;  /* prevent wide children from escaping the pane */
}
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown > *:first-child { margin-top: 0; }
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown > *:last-child  { margin-bottom: 0; }

/* First h1 acts as the cover headline — coral rule below; subsequent
   h1s are smaller and don't get the rule. */
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown > h1:first-child {
  font-family: 'Georgia', 'Source Serif 4', serif;
  font-size: 30px;
  font-weight: 700;
  color: #1a365d;
  margin: 0 0 10px 0;
  padding-bottom: 12px;
  border-bottom: 3px solid #c08b5c;
  line-height: 1.2;
}
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown h1 {
  font-family: 'Georgia', 'Source Serif 4', serif;
  font-size: 24px;
  font-weight: 700;
  color: #1a365d;
  margin: 32px 0 12px 0;
  line-height: 1.25;
}
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown h2 {
  font-family: 'Inter', 'Source Sans 3', system-ui, sans-serif;
  font-size: 19px;
  font-weight: 600;
  color: #2c5282;
  margin: 28px 0 8px 0;
  padding-bottom: 5px;
  border-bottom: 1px solid #e2e8f0;
  line-height: 1.3;
}
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown h3 {
  font-family: 'Inter', 'Source Sans 3', system-ui, sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: #2c7a7b;
  margin: 22px 0 6px 0;
  letter-spacing: 0.2px;
}
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown h4,
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown h5,
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown h6 {
  font-family: 'Inter', 'Source Sans 3', system-ui, sans-serif;
  font-weight: 600;
  color: #4a5568;
  margin: 18px 0 4px 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown p {
  margin: 0 0 14px 0;
}

:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown strong { font-weight: 700; color: #1a365d; }
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown em     { font-style: italic; }

/* Lists — restrained spacing, inherit body serif from .artifact-markdown */
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown ul,
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown ol {
  padding-left: 24px;
  margin: 8px 0 14px 0;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown li {
  margin: 4px 0;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown li > p  { margin: 0; }

/* Code — inline cream chip, blocks with navy accent rule */
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown code {
  font-family: 'JetBrains Mono', 'SF Mono', Consolas, 'Monaco', 'Menlo', monospace;
  font-size: 13.5px;
  background: rgba(45, 55, 72, 0.06);
  padding: 1px 5px;
  border-radius: 3px;
  color: #2c5282;
}
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown pre {
  background: #f7fafc;
  border: 1px solid #e2e8f0;
  border-left: 3px solid #2c5282;
  padding: 12px 16px;
  border-radius: 4px;
  overflow-x: auto;
  font-family: 'JetBrains Mono', 'SF Mono', Consolas, 'Monaco', 'Menlo', monospace;
  font-size: 13px;
  line-height: 1.55;
  color: #1a202c;
  margin: 14px 0;
}
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown pre code {
  background: transparent;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* Blockquotes — coral rule + warm-cream wash for callouts */
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown blockquote {
  margin: 16px 0;
  padding: 10px 16px 10px 18px;
  border-left: 3px solid #c08b5c;
  background: rgba(192, 139, 92, 0.08);
  font-style: italic;
  color: #4a5568;
  border-radius: 0 4px 4px 0;
}
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown blockquote p:last-child { margin-bottom: 0; }

/* Links — restrained underline that brightens on hover */
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown a {
  color: #2c5282;
  text-decoration: underline;
  text-decoration-color: rgba(44, 82, 130, 0.4);
  text-underline-offset: 2px;
}
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown a:hover {
  text-decoration-color: #2c5282;
}

/* Scroll wrapper for wide tables in the preview / validated panes.
 * The markdown renderer wraps every <table> in <div class="table-scroll-wrap">
 * so the table can scroll horizontally without overflowing the panel. */
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown .table-scroll-wrap {
  overflow-x: auto;
  margin: 18px 0 24px 0;
  -webkit-overflow-scrolling: touch;
}
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown .table-scroll-wrap table {
  margin: 0;  /* margin lives on the wrapper, not the table */
}

/* Tables — Anthropic-style: warm tones, clean horizontal dividers,
 * no heavy dark header, generous padding, full container width.
 *
 * Mirrors the Claude.ai data-table aesthetic: light warm header,
 * horizontal-only dividers, sentence-case text, tabular numbers,
 * rounded container with near-invisible border.
 *
 * Layout: `display: table` + `width: 100%` + `table-layout: auto`
 * so columns size based on content distribution. */
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown table {
  display: table;
  width: 100%;
  table-layout: auto;
  border-collapse: separate;
  border-spacing: 0;
  margin: 18px 0 24px 0;
  font-family: inherit;
  font-size: 14px;
  border: 1px solid #e8e2db;
  border-radius: 12px;
  overflow: hidden;
}
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown thead th {
  background: #f3eeea;
  color: #3d3833;
  font-weight: 600;
  padding: 12px 18px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid #e0d9d1;
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0;
  white-space: nowrap;
  overflow-wrap: normal;
}
/* No vertical borders between header cells — clean horizontal look */
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown tbody td {
  padding: 11px 18px;
  border-bottom: 1px solid #eee9e4;
  vertical-align: top;
  color: #2d2824;
  white-space: normal;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown tbody tr:last-child > td {
  border-bottom: none;
}
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown tbody tr:nth-child(even) td {
  background: rgba(243, 238, 234, 0.4);
}
/* First-column label cells — slightly bolder for scannability */
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown tbody td:first-child {
  font-weight: 500;
  color: #1a1a1a;
}

/* Hairline rule — used between sections */
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-markdown hr {
  border: none;
  border-top: 1px solid #e0d9d1;
  margin: 24px 0;
}

/* SVG artifact — centered */
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-svg-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 32px;
}

:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-svg-wrap svg {
  max-width: 100%;
  max-height: 80vh;
  height: auto;
}

/* CSV/JSON table renderer */
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-table-wrap {
  padding: 24px 32px;
  overflow-x: auto;
}

:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13px;
  border: 1px solid #e8e2db;
  border-radius: 12px;
  overflow: hidden;
}

:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-table th,
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-table td {
  border-bottom: 1px solid #eee9e4;
  padding: 10px 14px;
  text-align: left;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-table tbody tr:last-child > td {
  border-bottom: none;
}

:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-table thead th {
  background: #f3eeea;
  color: #3d3833;
  font-weight: 600;
  position: sticky;
  top: 0;
}

:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-table tbody tr:nth-child(even) {
  background: rgba(243, 238, 234, 0.35);
}
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-table tbody td:first-child {
  font-weight: 500;
  color: #1a1a1a;
}

/* Code pane */
.artifact-code-pane {
  background: var(--bg-white);
}

.artifact-code-pane pre {
  margin: 0;
  padding: 24px 28px;
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-white);
  white-space: pre;
  overflow-x: auto;
  min-height: 100%;
}

/* Clickable filename mention in assistant prose. Acts as a fallback when
   the canvas didn't auto-open for a generated document — clicking opens it. */
.filename-link {
  color: var(--accent-coral);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
  border-radius: 3px;
  padding: 0 2px;
  transition: background 0.15s, color 0.15s;
}

.filename-link:hover,
.filename-link:focus {
  background: rgba(196, 145, 123, 0.10);
  text-decoration-style: solid;
  outline: none;
}

/* "Open in canvas" button in the chat stream for completed artifacts */
.inline-artifact-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  margin: 12px 0;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.inline-artifact-card:hover {
  border-color: var(--accent-coral);
  box-shadow: 0 2px 10px rgba(196, 145, 123, 0.12);
}

.inline-artifact-card .artifact-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg-cream);
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-coral);
  flex-shrink: 0;
}

.inline-artifact-card .artifact-card-icon svg {
  width: 18px;
  height: 18px;
}

.inline-artifact-card .artifact-card-info {
  flex: 1;
  min-width: 0;
}

.inline-artifact-card .artifact-card-title {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 17px;
  font-weight: 500;
  color: var(--text-primary);
  margin: 0 0 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inline-artifact-card .artifact-card-type {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: 'Monaco', 'Menlo', monospace;
}

.inline-artifact-card .artifact-card-arrow {
  color: var(--text-secondary);
  flex-shrink: 0;
}

.inline-artifact-card .artifact-card-arrow svg {
  width: 18px;
  height: 18px;
}

/* ── Artifact streaming / skeleton loading ── */
.inline-artifact-card.artifact-streaming {
  border-color: rgba(192, 139, 92, 0.3);
  background: linear-gradient(135deg, rgba(192, 139, 92, 0.03), var(--bg-white));
  position: relative;
  overflow: hidden;
}

.inline-artifact-card.artifact-streaming::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-coral), transparent);
  animation: tool-sweep 1.8s ease-in-out infinite;
}

.inline-artifact-card.artifact-streaming .artifact-card-type {
  color: var(--accent-coral);
  animation: thinking-text-breathe 2s ease-in-out infinite;
}

@keyframes thinking-text-breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* (Artifact thought card removed per user feedback — "that card is
   also not needed". The thought-card-pulse keyframe below is kept
   because it's still referenced by .subagent-card-shimmer (P5) and
   .planner-strip-shimmer (P3); same animation, different consumers.) */
@keyframes thought-card-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(0.85); }
}

/* (Slow-tool elapsed-time hint removed per user feedback — "timer on
   the cards is not required". Defensive cleanup in chat-render.js
   strips any leftover .tool-elapsed nodes from cached DOM.) */

/* ── Sub-agent thought card — redesigned ────────────────────────────
 * Quiet, contained branch under the parent Task tool. Shares the new
 * ink palette and tokens. Slate accent (#7A6F62) so it reads as a
 * neutral "branch" rather than competing with the planning/retrieval/
 * registry phase colors. No gradient header, no uppercase tracking.
 *
 * Indented 24px under the parent Task card with a left-rail thread
 * connecting them visually.
 */
.subagent-card {
  --sa-accent: #7A6F62;
  --sa-accent-soft: rgba(122, 111, 98, 0.10);
  --sa-accent-tint: rgba(122, 111, 98, 0.05);
  margin: 6px 0 14px 24px;
  font-variant-numeric: tabular-nums;
  position: relative;
  /* Thread: a thin vertical line that links the sub-agent card up to
   * its parent Task tool card visually. Sits in the left margin. */
}
.subagent-card::before {
  content: '';
  position: absolute;
  left: -14px;
  top: -6px;
  bottom: 50%;
  width: 2px;
  background: var(--sa-accent-soft);
  border-radius: 1px;
}
.subagent-card::after {
  content: '';
  position: absolute;
  left: -14px;
  top: 50%;
  width: 12px;
  height: 2px;
  background: var(--sa-accent-soft);
  border-radius: 1px;
}
.subagent-card__inner {
  background: #FFFFFF;
  border-radius: 10px;
  border: 1px solid var(--rt-divider, #F2ECE3);
  overflow: hidden;
}
.subagent-card__header {
  /* Mirror the phase status row exactly: dot + name, no tinted band,
   * no border-bottom. The phase body's left rail provides the visual
   * boundary. Same padding/gap/typography as .rtcard__phase-status. */
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px 10px 18px;
  background: transparent;
  border-bottom: 0;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  text-transform: none;
  color: var(--rt-ink-primary, #1F1B17);
  min-height: 22px;
}
.subagent-card-shimmer {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sa-accent);
  box-shadow:
    0 0 0 2px #FFFFFF,
    0 0 0 3px var(--sa-accent);
  animation: rtcard-phase-pulse 1.8s ease-in-out infinite;
  flex-shrink: 0;
}
.subagent-card-status {
  /* The "Sub-agent · running fetch_slot…" status text. Secondary ink for
   * the running indicator; primary for the agent name. Mono is reserved
   * for the embedded tool name only (when emitted via a child span). */
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--rt-ink-secondary, #5C5048);
}
.subagent-card-status::first-letter {
  /* First word "Sub-agent" stays primary ink, rest (the · status text)
   * inherits the secondary tone above. */
  color: var(--rt-ink-primary, #1F1B17);
}
.subagent-card-tail {
  /* Body: matches .rtcard__phase-body — Plus Jakarta Sans 13px with
   * 1.65 line-height. The 17px left padding + 2px accent-soft border
   * exactly mirrors the phase body so the visual rhythm is identical. */
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  font-size: 13px;
  line-height: 1.65;
  letter-spacing: -0.005em;
  color: var(--rt-ink-primary, #1F1B17);
  font-variant-numeric: tabular-nums;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 14em;
  overflow-y: auto;
  margin: 6px 18px 16px 24px;
  padding: 4px 0 0 17px;
  border-left: 2px solid var(--sa-accent-soft);
  background: transparent;
}
.subagent-card-tail::-webkit-scrollbar { width: 4px; }
.subagent-card-tail::-webkit-scrollbar-track { background: transparent; }
.subagent-card-tail::-webkit-scrollbar-thumb {
  background: var(--sa-accent-soft);
  border-radius: 2px;
}

/* ── L9 hybrid fan-out: per-source progressive-disclosure cards ──────────
   Each MCP source is anonymous while consulting, reveals its name +
   contribution once it returns data, and dissolves if it comes back empty. */
/* God-mode "Live findings" card — per-wave cited digests streamed while Nexus runs.
   Shares the trace-card visual language: white surface, hairline border, teal live dot
   (pulsing while gathering, muted once settled), collapsible body. */
.interim-findings-card {
  --if-accent: #0E7C7B;   /* teal */
  margin: 6px 0 12px 0;
  font-variant-numeric: tabular-nums;
}
.interim-findings-card__inner {
  background: #FFFFFF;
  border-radius: 12px;
  border: 1px solid var(--rt-divider, #F2ECE3);
  overflow: hidden;
}
.interim-findings-card__header {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 11px 14px;
  background: #FCFAF6;
  border: 0;
  border-bottom: 1px solid var(--rt-divider-hairline, #EAE2D6);
  cursor: pointer;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--rt-ink-primary, #1F1B17);
  text-align: left;
}
.interim-findings-card__dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--if-accent);
  flex-shrink: 0;
}
.interim-findings-card--streaming .interim-findings-card__dot {
  animation: rtcard-phase-pulse 1.4s ease-in-out infinite;
}
.interim-findings-card--settled .interim-findings-card__dot {
  background: var(--rt-ink-tertiary, #9B9183);
}
.interim-findings-card__title { flex: 1 1 auto; }
.interim-findings-card__chev {
  flex-shrink: 0;
  display: inline-flex;
  color: var(--rt-ink-tertiary, #9B9183);
  transition: transform 0.18s ease;
}
.interim-findings-card__header[aria-expanded="false"] .interim-findings-card__chev {
  transform: rotate(-90deg);
}
.interim-findings-card__body {
  max-height: 320px;
  overflow-y: auto;
  padding: 8px 14px 6px 14px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--rt-ink-secondary, #4A443C);
}
.interim-findings-card__body--collapsed {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
}
.interim-findings-wave + .interim-findings-wave {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px dashed var(--rt-divider-hairline, #EAE2D6);
}
.interim-findings-wave :is(p, ul, ol) { margin: 4px 0; }
.interim-findings-wave ul, .interim-findings-wave ol { padding-left: 18px; }

.hybrid-fanout-card {
  --hf-accent: #0E7C7B;   /* teal */
  --hf-muted: #9B9183;    /* warm gray */
  margin: 6px 0 14px 0;
  font-variant-numeric: tabular-nums;
}
.hybrid-fanout-card__inner {
  background: #FFFFFF;
  border-radius: 12px;
  border: 1px solid var(--rt-divider, #F2ECE3);
  padding: 12px 14px 14px 14px;
}
.hybrid-fanout-card__header {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 10px;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--rt-ink-primary, #1F1B17);
}
.hybrid-fanout-card__dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--hf-accent);
  animation: rtcard-phase-pulse 1.4s ease-in-out infinite;
  flex-shrink: 0;
}
.hf-sources { display: flex; flex-direction: column; gap: 7px; }
.hf-src {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--rt-divider-hairline, #EAE2D6);
  background: #FCFAF6;
  overflow: hidden;
  max-height: 64px;
  transition: opacity .42s ease, max-height .42s ease,
    padding .42s ease, margin .42s ease, border-width .42s ease;
}
.hf-src--consulting { background: #FBF8F3; }
.hf-src__dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--hf-muted);
  animation: rtcard-phase-pulse 1.1s ease-in-out infinite;
  flex-shrink: 0;
}
.hf-src__anon {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  font-size: 12.5px; letter-spacing: -0.005em;
  color: var(--rt-ink-muted, #8C7B6A);
}
.hf-src--revealed { animation: hf-reveal .42s ease both; }
.hf-src__ico {
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  font-size: 13px; font-weight: 700;
  flex-shrink: 0;
  background: rgba(14, 124, 123, 0.10);
  color: var(--hf-accent);
}
.hf-src__body { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.hf-src__name {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  font-size: 13px; font-weight: 600; letter-spacing: -0.005em;
  color: var(--rt-ink-primary, #1F1B17);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hf-src__sub {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  font-size: 11.5px; letter-spacing: -0.005em;
  color: var(--rt-ink-secondary, #5C5048);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hf-src__check { font-size: 13px; color: var(--hf-accent); flex-shrink: 0; }
.hf-src--gone {
  opacity: 0; max-height: 0;
  padding-top: 0; padding-bottom: 0;
  margin-top: 0; margin-bottom: 0;
  border-width: 0;
}
.hf-src--teal   .hf-src__ico { background: rgba(14, 124, 123, 0.10); color: #0E7C7B; }
.hf-src--teal   .hf-src__check { color: #0E7C7B; }
.hf-src--blue   .hf-src__ico { background: rgba(45, 108, 162, 0.10); color: #2D6CA2; }
.hf-src--blue   .hf-src__check { color: #2D6CA2; }
.hf-src--amber  .hf-src__ico { background: rgba(181, 128, 58, 0.12); color: #9A6B2E; }
.hf-src--amber  .hf-src__check { color: #9A6B2E; }
.hf-src--gray   .hf-src__ico { background: rgba(140, 123, 106, 0.12); color: #7A6B5A; }
.hf-src--gray   .hf-src__check { color: #7A6B5A; }
.hf-src--purple .hf-src__ico { background: rgba(107, 91, 149, 0.12); color: #6B5B95; }
.hf-src--purple .hf-src__check { color: #6B5B95; }
.hf-src--coral  .hf-src__ico { background: rgba(197, 106, 74, 0.12); color: #B5563C; }
.hf-src--coral  .hf-src__check { color: #B5563C; }

/* ── god-mode per-MCP trace cards (each MCP = a card; tool calls = persistent pills) ── */
/* god-mode "Consulting sources" — per-source audit cards. Premium, calm,
   business-friendly: tone-coloured source chips, a hairline step timeline,
   plain-language steps, and quiet check/pulse status (never raw tool output). */
.mcp-card {
  border: 0.5px solid rgba(31, 27, 23, 0.07); border-radius: 12px;
  background: #FCFAF6; padding: 11px 13px 10px; margin-bottom: 9px;
  transition: background .35s ease, box-shadow .35s ease, border-color .35s ease;
}
.mcp-card--done {
  background: #FFFFFF; border-color: rgba(31, 27, 23, 0.06);
  box-shadow: 0 1px 3px rgba(31, 27, 23, 0.045);
}
.mcp-card__head { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.mcp-card__ico {
  position: relative; overflow: hidden;
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  font-size: 8.5px; font-weight: 800; letter-spacing: 0.01em; text-transform: uppercase;
  background: rgba(14, 124, 123, 0.12); color: #0E7C7B;
}
.mcp-card__name {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  font-size: 13px; font-weight: 650; letter-spacing: -0.006em;
  color: var(--rt-ink-primary, #1F1B17);
}
.mcp-card__state { margin-left: auto; flex-shrink: 0; width: 8px; height: 8px; }
.mcp-card:not(.mcp-card--done) .mcp-card__state {
  border-radius: 50%; background: var(--hf-accent, #0E7C7B);
  animation: rtcard-phase-pulse 1.2s ease-in-out infinite;
}
/* per-source tone — the avatar-chip + live-dot colour */
.mcp-card--tone-teal   .mcp-card__ico { background: rgba(14, 124, 123, 0.12); color: #0E7C7B; }
.mcp-card--tone-blue   .mcp-card__ico { background: rgba(43, 108, 176, 0.12); color: #2B6CB0; }
.mcp-card--tone-purple .mcp-card__ico { background: rgba(107, 70, 193, 0.13); color: #6B46C1; }
.mcp-card--tone-amber  .mcp-card__ico { background: rgba(180, 120, 30, 0.14); color: #9C6516; }
.mcp-card--tone-coral  .mcp-card__ico { background: rgba(192, 139, 92, 0.16); color: var(--accent-coral-dark, #a87644); }
.mcp-card--tone-gray   .mcp-card__ico { background: rgba(92, 80, 72, 0.10);  color: #5C5048; }
.mcp-card--tone-blue:not(.mcp-card--done)   .mcp-card__state { background: #2B6CB0; }
.mcp-card--tone-purple:not(.mcp-card--done) .mcp-card__state { background: #6B46C1; }
.mcp-card--tone-amber:not(.mcp-card--done)  .mcp-card__state { background: #9C6516; }
.mcp-card--tone-coral:not(.mcp-card--done)  .mcp-card__state { background: var(--accent-coral-dark, #a87644); }
.mcp-card--tone-gray:not(.mcp-card--done)   .mcp-card__state { background: #5C5048; }
/* brand-logo variant — a widened white tile that fits horizontal lockups (RBI /
   MoSPI / PIB / web-search). `.mcp-card` prefix beats the per-tone chip tint so the
   logo reads on white. The source PNGs are whitespace-trimmed to their content bbox,
   so the artwork fills the tile and stays legible at this compact height; caps widened
   so a ~3:1 lockup (MoSPI) is height-, not width-, bound. */
.mcp-card .mcp-card__ico--logo { display: flex; align-items: center; width: auto; min-width: 56px; max-width: 300px; height: 64px; padding: 5px 12px; background: #fff; border-radius: 10px; }
.mcp-card__logo { height: 54px; width: auto; max-width: 272px; object-fit: contain; display: block; }

.mcp-card__tools { position: relative; display: flex; flex-direction: column; gap: 1px; padding-left: 40px; }
/* the hairline timeline the step-nodes sit on */
.mcp-card__tools::before {
  content: ''; position: absolute; left: 14px; top: 10px; bottom: 10px; width: 1.5px;
  background: linear-gradient(rgba(31, 27, 23, 0.11), rgba(31, 27, 23, 0.04));
}
.mcp-tool {
  position: relative; display: flex; align-items: center; gap: 8px; min-height: 23px;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  font-size: 12.5px; color: var(--rt-ink-secondary, #5C5048);
}
/* the step node on the timeline */
.mcp-tool::before {
  content: ''; position: absolute; left: -26px; top: 50%; transform: translateY(-50%);
  width: 7px; height: 7px; border-radius: 50%; background: #fff; z-index: 1;
  box-shadow: 0 0 0 1.5px rgba(31, 27, 23, 0.18);
}
.mcp-tool--running::before {
  background: var(--hf-accent, #0E7C7B); box-shadow: 0 0 0 1.5px rgba(14, 124, 123, 0.35);
  animation: rtcard-phase-pulse 1.1s ease-in-out infinite;
}
.mcp-tool--done::before { background: #1FA463; box-shadow: 0 0 0 1.5px rgba(31, 164, 99, 0.22); }
.mcp-tool__label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mcp-tool--done .mcp-tool__label { color: var(--rt-ink-primary, #2C261F); }
.mcp-tool__status { flex-shrink: 0; width: 14px; text-align: center; font-size: 10.5px; font-weight: 800; color: #1FA463; }
.mcp-reason {
  display: flex; align-items: center; gap: 8px; margin-top: 6px; padding-left: 2px;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  font-size: 12px; color: var(--rt-ink-muted, #8C7B6A);
}
.mcp-reason__dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; background: var(--hf-muted, #B4B2A9); animation: rtcard-phase-pulse 1.1s ease-in-out infinite; }
.mcp-reason__text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-style: italic; }
/* ── Verbatim append-only log rows (god-mode Nexus progress trace) ──
   One row per message, rendered verbatim, sitting on the same hairline timeline
   as .mcp-tool. Unlike pills, these WRAP (URLs / queries / result snippets). */
.mcp-line {
  position: relative; display: flex; align-items: flex-start; min-height: 22px; padding: 2px 0;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  font-size: 12.5px; line-height: 1.45; color: var(--rt-ink-secondary, #5C5048);
}
.mcp-line::before {
  content: ''; position: absolute; left: -26px; top: 9px; width: 6px; height: 6px;
  border-radius: 50%; background: #fff; z-index: 1; box-shadow: 0 0 0 1.5px rgba(31, 27, 23, 0.16);
}
.mcp-line__text { flex: 1; min-width: 0; white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
.mcp-line--result::before { background: #1FA463; box-shadow: 0 0 0 1.5px rgba(31, 164, 99, 0.22); }
.mcp-line--result .mcp-line__text { color: var(--rt-ink-primary, #2C261F); }
.mcp-line--error::before { background: #C0492B; box-shadow: 0 0 0 1.5px rgba(192, 73, 43, 0.25); }
.mcp-line--error .mcp-line__text { color: #9C3318; }
.mcp-line--settled::before { background: #1FA463; box-shadow: 0 0 0 1.5px rgba(31, 164, 99, 0.18); }
/* full-width narration log (the model's own reasoning + system steps) */
.mcp-narration-log { display: flex; flex-direction: column; gap: 1px; margin-top: 6px; padding-left: 2px; }
.mcp-narration-log .mcp-line { padding-left: 0; }
.mcp-narration-log .mcp-line::before { display: none; }
.mcp-narration-log .mcp-line__text { font-style: italic; color: var(--rt-ink-muted, #8C7B6A); }
/* single rolling pulse at the very bottom while the turn runs */
.mcp-pulse {
  display: flex; align-items: center; gap: 8px; margin-top: 6px; padding-left: 2px;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  font-size: 12px; color: var(--rt-ink-muted, #8C7B6A);
}
.mcp-pulse__dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; background: var(--hf-accent, #0E7C7B); animation: rtcard-phase-pulse 1.1s ease-in-out infinite; }
.mcp-pulse__text { flex: 1; min-width: 0; }
@media (prefers-reduced-motion: reduce) {
  .mcp-reason__dot, .mcp-card__state, .mcp-tool--running::before, .mcp-pulse__dot { animation: none !important; opacity: 0.75; }
}
@keyframes hf-reveal {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .hybrid-fanout-card__dot, .hf-src__dot { animation: none; opacity: 0.7; }
  .hf-src--revealed { animation: none; }
}
.subagent-card-tail::-webkit-scrollbar-thumb:hover {
  background: var(--sa-accent);
}
@media (prefers-reduced-motion: reduce) {
  .subagent-card-shimmer { animation: none; opacity: 0.7; }
}

/* ── P3: planner status strip ──
   Single-line strip at the top of the assistant message during the
   8-15s pre-stream wait. Two phases: "running" (shimmer + "Planning…")
   and "done" (level + sub-agent count, briefly visible before tool
   calls land and replace it). */
.planner-strip {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 12px;
  margin: 0 0 10px 0;
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 11px;
  letter-spacing: 0.3px;
  color: var(--text-secondary, #777);
  background: rgba(192, 139, 92, 0.06);
  border: 1px solid rgba(192, 139, 92, 0.18);
  border-radius: 8px;
}
.planner-strip[data-phase="done"] {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.06);
}
.planner-strip-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.planner-strip-shimmer {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-coral, #c0883c);
  animation: thought-card-pulse 1.4s ease-in-out infinite;
  flex-shrink: 0;
}
.planner-strip[data-phase="done"] .planner-strip-shimmer {
  background: var(--text-secondary, #777);
  animation: none;
  opacity: 0.5;
}
/* Stage-1 planner's classification.reasoning, shown on the done-state
   strip's second line. Indent to align with the headline text (past the
   8px shimmer + 8px gap). Slightly subdued colour and tighter line height
   so the strip stays compact even with 1-2 sentences of reasoning. */
.planner-strip-reasoning {
  margin-left: 16px;
  font-family: var(--font-stack, system-ui, sans-serif);
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-tertiary, #999);
  letter-spacing: normal;
  font-style: italic;
}
.planner-strip-reasoning[hidden] { display: none; }

/* Live thinking surface — populated by `planner_thought_delta` events
   while the strip is in running phase. The model's reasoning streams
   into here so the user sees what's happening during the planner's
   pre-stream wait (now budgeted at 60s). Capped height with internal
   scroll so a long thinking trace doesn't push the rest of the chat
   off-screen; we auto-scroll to bottom on each delta to keep the
   latest token visible. Cleared once the plan event arrives — the
   .planner-strip-reasoning element below takes over with the
   final-conclusion summary. */
.planner-strip-thoughts {
  margin-left: 16px;
  margin-top: 4px;
  padding: 6px 8px;
  font-family: var(--font-stack, system-ui, sans-serif);
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-tertiary, #999);
  background: rgba(0, 0, 0, 0.025);
  border-left: 2px solid rgba(192, 139, 92, 0.35);
  border-radius: 4px;
  max-height: 220px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  letter-spacing: normal;
}
.planner-strip-thoughts[hidden] { display: none; }
.planner-strip[data-phase="done"] .planner-strip-thoughts {
  /* Once done, prefer the conclusion (.planner-strip-reasoning) over the
     full thinking trace; CSS hides the live thoughts even if the model
     still has them populated. */
  display: none;
}
@media (prefers-reduced-motion: reduce) {
  .planner-strip-shimmer { animation: none; opacity: 0.7; }
}

/* (P2 .thinking-tail-preview removed per user feedback — gold pill
   stays as it was. The pill now auto-expands while streaming so the
   live reasoning is visible directly in the body, with auto-scroll.) */

/* Canvas streaming state */
.artifact-canvas.artifact-streaming .artifact-type-badge {
  color: var(--accent-coral);
  animation: thinking-text-breathe 2s ease-in-out infinite;
}

/* Skeleton loading in canvas preview pane */
.artifact-skeleton {
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: 100%;
}

.artifact-skeleton .skeleton-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.artifact-skeleton .skeleton-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.skeleton-line {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(110deg, var(--bg-cream) 30%, rgba(192, 139, 92, 0.08) 50%, var(--bg-cream) 70%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.skeleton-title { width: 50%; height: 22px; }
.skeleton-subtitle { width: 30%; height: 14px; }
.skeleton-full { width: 100%; }
.skeleton-medium { width: 75%; }
.skeleton-short { width: 45%; }

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-status {
  font-family: 'EB Garamond', Georgia, serif;
  font-style: italic;
  font-size: 14px;
  color: var(--text-tertiary);
  text-align: center;
  padding-top: 8px;
  animation: thinking-text-breathe 2s ease-in-out infinite;
}

/* Insights generation loader — pulsating DeepInsights mark + flowing lines */
.insights-gen-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 280px;
  padding: 40px 32px;
  gap: 28px;
}

.insights-gen-loader__stage {
  position: relative;
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
}

.insights-gen-loader__logo {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background-color: #fff;
  background-image: url('assets/logo_deepinsights.png');
  background-repeat: no-repeat;
  background-position: left center;
  background-size: auto 100%;
  box-shadow:
    0 6px 24px rgba(42, 56, 153, 0.14),
    inset 0 0 0 1px rgba(255, 255, 255, 0.55);
  animation: insights-gen-pulse 2.4s ease-in-out infinite;
}

.insights-gen-loader__lines {
  display: flex;
  flex-direction: column;
  gap: 11px;
  width: min(340px, 90%);
}

.insights-gen-loader__line {
  display: block;
  height: 9px;
  border-radius: 7px;
  background: linear-gradient(
    90deg,
    rgba(42, 56, 153, 0.05) 0%,
    rgba(90, 158, 219, 0.16) 40%,
    rgba(29, 154, 148, 0.12) 72%,
    rgba(42, 56, 153, 0.04) 100%
  );
  transform-origin: left center;
  opacity: 0;
  animation: insights-gen-line 2.4s ease-in-out infinite;
}

.insights-gen-loader__line--1 { width: 68%; animation-delay: 0s; }
.insights-gen-loader__line--2 { width: 94%; animation-delay: 0.4s; }
.insights-gen-loader__line--3 { width: 52%; animation-delay: 0.8s; }
.insights-gen-loader__line--4 { width: 78%; animation-delay: 1.2s; }

.insights-gen-loader__status {
  margin: 0;
  font-family: 'EB Garamond', Georgia, serif;
  font-style: italic;
  font-size: 15px;
  color: var(--text-tertiary);
  letter-spacing: 0.01em;
  animation: thinking-text-breathe 2.6s ease-in-out infinite;
}

@keyframes insights-gen-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: 0.9; }
}

@keyframes insights-gen-line {
  0% { opacity: 0; transform: scaleX(0.25); }
  22% { opacity: 1; transform: scaleX(1); }
  68% { opacity: 0.88; transform: scaleX(1); }
  100% { opacity: 0; transform: scaleX(0.96); }
}

@media (prefers-reduced-motion: reduce) {
  .insights-gen-loader__logo,
  .insights-gen-loader__line,
  .insights-gen-loader__status {
    animation: none;
  }
  .insights-gen-loader__line {
    opacity: 0.55;
    transform: none;
  }
}

/* Legacy insights loading bar (kept for backward compat if cached HTML references it) */
.insights-loading-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 18px;
  padding: 32px;
}
.insights-loading-bar__shimmer {
  width: 220px;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(
    90deg,
    var(--bg-cream) 0%,
    var(--accent-gold, #c08b5c) 40%,
    var(--bg-cream) 80%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}
.insights-loading-bar__text {
  font-family: 'EB Garamond', Georgia, serif;
  font-style: italic;
  font-size: 15px;
  color: var(--text-tertiary);
  animation: thinking-text-breathe 2s ease-in-out infinite;
}

@media (max-width: 1100px) {
  .artifact-canvas {
    width: 480px;
  }
}

@media (max-width: 900px) {
  .artifact-canvas {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    max-width: 100vw;
    z-index: 50;
  }
}

/* ==================== ASK USER QUESTION CARD ==================== */
.ask-user-card {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 22px 24px;
  margin: 16px 0;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
  max-width: 820px;
}

.ask-user-card.submitted {
  opacity: 0.7;
}

/* Reuse picker — compact card that fits the chat column comfortably */
.ask-user-card.reuse-picker-card {
  border-left: 3px solid var(--accent-coral-dark, #c06a45);
  padding: 10px 12px 12px;
  margin: 8px 0;
  border-radius: 10px;
  max-width: 100%;
  box-shadow: none;
}

.ask-user-card.reuse-picker-card .ask-user-question {
  margin-bottom: 8px;
}

.ask-user-card.reuse-picker-card .ask-user-question:last-of-type {
  margin-bottom: 8px;
}

.ask-user-card.reuse-picker-card .ask-user-chip {
  padding: 2px 7px;
  font-size: 9px;
  letter-spacing: 0.6px;
  margin-bottom: 4px;
  border-radius: 4px;
}

.ask-user-card.reuse-picker-card .ask-user-q-title {
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

/* Dynamic: wrap into columns when the chat pane has room */
.ask-user-card.reuse-picker-card .ask-user-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 6px;
  margin-bottom: 6px;
}

/* Fixed max height — long chats scroll inside the card */
.ask-user-card.reuse-picker-card .reuse-picker-scroll {
  max-height: 220px;
  overflow-y: auto;
  overflow-x: hidden;
  margin-bottom: 6px;
  padding-right: 2px;
  scrollbar-width: thin;
}

.ask-user-card.reuse-picker-card .reuse-picker-scroll .ask-user-options {
  margin-bottom: 0;
}

/* Collapsed "More artifacts" drawer for Ancillary rows */
.ask-user-card.reuse-picker-card .reuse-picker-more {
  border-top: 1px solid var(--border-light, #e8e4df);
  margin: 2px 0 6px;
  padding: 0;
}

.ask-user-card.reuse-picker-card .reuse-picker-more-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  list-style: none;
  cursor: pointer;
  padding: 6px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary, #6b6560);
  user-select: none;
}

.ask-user-card.reuse-picker-card .reuse-picker-more-bar::-webkit-details-marker {
  display: none;
}

.ask-user-card.reuse-picker-card .reuse-picker-more-bar::before {
  content: '▸';
  font-size: 10px;
  color: var(--text-muted, #9a948c);
  flex-shrink: 0;
}

.ask-user-card.reuse-picker-card .reuse-picker-more[open] .reuse-picker-more-bar::before {
  content: '▾';
}

.ask-user-card.reuse-picker-card .reuse-picker-more-label {
  flex: 1;
  min-width: 0;
}

.ask-user-card.reuse-picker-card .reuse-picker-more-count {
  font-weight: 500;
  font-size: 10px;
  color: var(--text-muted, #9a948c);
  white-space: nowrap;
}

.ask-user-card.reuse-picker-card .reuse-picker-ancillary-options {
  max-height: 140px;
  overflow-y: auto;
  margin-bottom: 4px;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.ask-user-card.reuse-picker-card .ask-user-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 7px 28px 7px 10px;
  border-radius: 7px;
  min-width: 0;
}

.ask-user-card.reuse-picker-card .ask-user-option-pill {
  font-size: 8px;
  padding: 1px 5px;
  margin-bottom: 0;
  letter-spacing: 0.03em;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Turn/role pills (reuse picker) */
.ask-user-card.reuse-picker-card .ask-user-option-pill-artifact {
  background: rgba(192, 106, 69, 0.12);
  color: #9a5535;
}
.ask-user-card.reuse-picker-card .ask-user-option-pill-visual {
  background: rgba(59, 130, 246, 0.12);
  color: #2563eb;
}
.ask-user-card.reuse-picker-card .ask-user-option-pill-intermediate {
  background: rgba(107, 114, 128, 0.14);
  color: #4b5563;
}
.ask-user-card.reuse-picker-card .ask-user-option-pill-ancillary {
  background: rgba(148, 163, 184, 0.16);
  color: #64748b;
}

.ask-user-card.reuse-picker-card .ask-user-option-label {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* Descriptions bloat the compact card — keep chips scannable */
.ask-user-card.reuse-picker-card .ask-user-option-desc {
  display: none;
}

.ask-user-card.reuse-picker-card .ask-user-option-check {
  right: 8px;
  width: 14px;
  height: 14px;
}

/* Free-text "other" doesn't map to artifact ids — hide for reuse */
.ask-user-card.reuse-picker-card .ask-user-other {
  display: none;
}

.ask-user-card.reuse-picker-card .ask-user-submit {
  width: auto;
  min-width: 140px;
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 12px;
  margin-top: 4px;
  margin-left: auto;
  margin-right: 0;
}

@keyframes reuse-picker-fadeout {
  0%   { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-6px); max-height: 0; padding: 0 12px; margin: 0; overflow: hidden; }
}
.ask-user-card.reuse-picker-removing {
  animation: reuse-picker-fadeout 0.35s ease-out forwards;
  pointer-events: none;
}

.ask-user-question {
  margin-bottom: 22px;
}

.ask-user-question:last-of-type {
  margin-bottom: 18px;
}

.ask-user-chip {
  display: inline-block;
  padding: 4px 10px;
  background: var(--bg-cream);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--accent-coral-dark);
  font-family: 'Monaco', 'Menlo', monospace;
  margin-bottom: 10px;
}

.ask-user-q-title {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 21px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--text-primary);
  margin-bottom: 14px;
}

.ask-user-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.ask-user-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  padding-right: 40px;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text-primary);
  transition: all 0.15s;
  position: relative;
}

/* L6 consolidate picker — small category pill above each option's title.
 * Server sends `kind_label` ("Report", "Dashboard", "Image", "Table" …)
 * plus `kind_id` (raw artifact type) so we can colour the chip per
 * category. Base style here; per-kind tints below. */
.ask-user-option-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 6px;
  background: rgba(196, 145, 123, 0.12);   /* coral-tinted neutral */
  color: var(--accent-coral);
  border: 1px solid rgba(196, 145, 123, 0.25);
  line-height: 1.4;
  vertical-align: middle;
}
.ask-user-option-pill-html {
  background: rgba(96, 138, 192, 0.12);
  color: #4a78b3;
  border-color: rgba(96, 138, 192, 0.28);
}
.ask-user-option-pill-live_table,
.ask-user-option-pill-csv {
  background: rgba(76, 154, 108, 0.12);
  color: #3f7c54;
  border-color: rgba(76, 154, 108, 0.28);
}
.ask-user-option-pill-image,
.ask-user-option-pill-image-generation {
  background: rgba(178, 122, 178, 0.12);
  color: #8e5a8e;
  border-color: rgba(178, 122, 178, 0.28);
}
.ask-user-option-pill-markdown,
.ask-user-option-pill-docx,
.ask-user-option-pill-pptx {
  background: rgba(196, 145, 123, 0.12);
  color: var(--accent-coral);
  border-color: rgba(196, 145, 123, 0.25);
}

.ask-user-option:hover:not(:disabled) {
  border-color: var(--accent-coral);
  background: #fdfbf8;
}

.ask-user-option.selected {
  border-color: var(--accent-coral);
  background: rgba(196, 145, 123, 0.08);
}

.ask-user-option:disabled {
  cursor: default;
  opacity: 0.7;
}

.ask-user-option-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
}

.ask-user-option-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 3px;
  line-height: 1.45;
}

.ask-user-option-check {
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--accent-coral);
  opacity: 0;
  transition: opacity 0.15s;
}

.ask-user-option.selected .ask-user-option-check {
  opacity: 1;
}

.ask-user-other {
  margin-top: 2px;
}

.ask-user-other-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-cream);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-primary);
  transition: border-color 0.15s;
}

.ask-user-other-input::placeholder {
  color: var(--text-tertiary);
  font-style: italic;
}

.ask-user-other-input:focus {
  outline: none;
  border-color: var(--accent-coral);
  background: var(--bg-white);
}

.ask-user-other-input:disabled {
  opacity: 0.6;
  cursor: default;
}

.ask-user-submit {
  display: block;
  width: 100%;
  padding: 12px 20px;
  background: var(--accent-coral);
  border: none;
  border-radius: 10px;
  color: white;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  margin-top: 6px;
}

.ask-user-submit:hover:not(:disabled) {
  background: var(--accent-coral-dark);
}

.ask-user-submit:disabled {
  background: #d4c4b8;
  cursor: not-allowed;
  color: rgba(255, 255, 255, 0.8);
}

/* ==================== HOME PAGE REDESIGN ==================== */
.home-view {
  padding: 14vh 48px 48px;
  max-height: 100vh;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.home-hero {
  max-width: none;
  margin: 0 auto 24px;
  text-align: center;
}

@media (max-width: 600px) {
  .greeting-text {
    white-space: normal;
    font-size: 26px;
  }
}

.greeting-text {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: clamp(26px, 4.4vw, 40px);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.5px;
  margin: 0;
  white-space: nowrap;
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0) 48%, rgba(255, 255, 255, 0.18) 92%),
    var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* Typewriter caret — visible only while the greeting is being typed out. */
.greeting-text-content {
  display: inline;
}
.greeting-text-content--typing::after {
  content: '';
  display: inline-block;
  width: 2px;
  height: 0.95em;
  margin-left: 4px;
  vertical-align: -0.12em;
  background: var(--brand-indigo);
  opacity: 0.7;
  animation: greetingCaret 0.85s steps(2) infinite;
}

@keyframes greetingCaret {
  50% { opacity: 0; }
}

/* Three "thinking" dots that appear after the greeting finishes typing. */
.greeting-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 12px;
  vertical-align: middle;
}

/* Glues the last word of the greeting to the typing dots so they never
   wrap onto a separate line on their own. */
.greeting-tail {
  display: inline-block;
  white-space: nowrap;
}

.greeting-typing-dots span {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand-indigo);
  opacity: 0.35;
  animation: greetingDotPulse 1.5s ease-in-out infinite;
}

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

@keyframes greetingDotPulse {
  0%, 80%, 100% { opacity: 0.30; transform: translateY(0); }
  40%           { opacity: 1;    transform: translateY(-3px); }
}

@media (prefers-reduced-motion: reduce) {
  .greeting-text-content--typing::after,
  .greeting-typing-dots span {
    animation: none;
    opacity: 0.5;
  }
}

/* Input card: clean + centered */
.home-view .input-container.home-input {
  max-width: 820px;
  margin: 0 auto 20px;
}

.home-view .input-container.home-input .input-wrapper {
  border-radius: 18px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  padding: 4px 8px 4px;
}

/* Suggestion chips — refined pills. Subtle cream gradient, hairline indigo
   border. Hover lifts and intensifies the border. */
/* Always a 2×2 grid: exactly 2 pills per row, 2 rows (renderDailyChips emits
   4). The grid is centred on the page but is intentionally NOT capped to the
   820px chat-box width — long pills may make a row wider than the input above,
   and that overflow is accepted (per design) rather than wrapping to 1-per-row. */
.home-chips {
  margin: 0 auto 32px;
  display: grid;
  grid-template-columns: repeat(2, max-content);
  justify-content: center;
  justify-items: center;
  gap: 10px 12px;
}

.home-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px 9px 14px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
  border: 1px solid rgba(42, 56, 153, 0.14);
  border-radius: 999px;
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.005em;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.22s ease,
              color 0.22s ease,
              background 0.24s ease,
              box-shadow 0.28s ease;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    0 1px 2px rgba(20, 30, 80, 0.03);
}

.home-chip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: var(--brand-indigo);
  opacity: 0.6;
  transition: opacity 0.22s ease, transform 0.22s ease;
  flex-shrink: 0;
}

.home-chip-icon svg {
  width: 16px;
  height: 16px;
}

.home-chip:hover .home-chip-icon {
  opacity: 1;
  transform: scale(1.06);
}

.home-chip:hover {
  border-color: rgba(42, 56, 153, 0.45);
  color: var(--brand-indigo);
  background: linear-gradient(180deg, #ffffff 0%, #f4f7fd 100%);
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 4px 14px rgba(42, 56, 153, 0.10);
}

.home-chip:active {
  transform: translateY(0);
}

.home-chip-label {
  display: inline-block;
}

/* Section blocks */
.home-section {
  max-width: 960px;
  margin: 0 auto 48px;
}

.home-section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 0 4px;
}

.home-section-header h3 {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 24px;
  font-weight: 500;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.3px;
  font-feature-settings: "kern" 1, "onum" 1;
}

.home-section-hint {
  font-size: 12px;
  color: var(--text-tertiary);
}

.home-section.hidden {
  display: none;
}

/* Template grid */
.home-template-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.home-template {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 18px;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: left;
  font-family: inherit;
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.home-template:hover {
  border-color: var(--accent-coral);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(196, 145, 123, 0.12);
}

.home-template-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--bg-cream);
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-coral);
  flex-shrink: 0;
}

.home-template-icon svg {
  width: 18px;
  height: 18px;
}

.home-template-body {
  flex: 1;
  min-width: 0;
}

.home-template-title {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 18px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.15;
  margin-bottom: 4px;
  letter-spacing: -0.1px;
  font-feature-settings: "kern" 1, "onum" 1;
}

.home-template-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
}

/* Recents strip */
.home-recents {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.home-recent-card {
  padding: 14px 16px;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  text-align: left;
  font-family: inherit;
}

.home-recent-card:hover {
  border-color: var(--accent-coral);
  box-shadow: 0 6px 18px rgba(196, 145, 123, 0.1);
}

.home-recent-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.home-recent-meta {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 3px;
}

/* ==================== HOME DASHBOARD ==================== */
.home-dashboard {
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  padding: 8px 0 40px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* Section "View all" / "Manage" link */
.home-section-link {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 13px;
  color: var(--accent-coral);
  cursor: pointer;
  font-weight: 500;
  padding: 0;
}
.home-section-link:hover {
  text-decoration: underline;
}

/* Artifact preview cards on dashboard */
.home-artifacts-preview {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.home-artifact-card {
  padding: 14px 16px;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  text-align: left;
  font-family: inherit;
}
.home-artifact-card:hover {
  border-color: var(--accent-coral);
  box-shadow: 0 6px 18px rgba(196, 145, 123, 0.1);
}

.home-artifact-type {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 8px;
}

.home-artifact-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Plugin summary stats on dashboard */
.home-plugins-summary {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.home-plugin-stat {
  padding: 16px 20px;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  flex: 1;
  min-width: 120px;
  text-align: center;
}

.home-plugin-stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'EB Garamond', Georgia, serif;
}

.home-plugin-stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

@media (max-width: 960px) {
  .home-template-grid,
  .home-recents,
  .home-artifacts-preview {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .home-view { padding: 0 20px 48px; }
  .greeting-text { font-size: 48px; }
  .home-template-grid,
  .home-recents,
  .home-artifacts-preview { grid-template-columns: 1fr; }
  .home-plugins-summary { flex-direction: column; }
}

/* ==================== FLOATING ROUNDED PANELS ==================== */
/* Put breathing room around every major panel and give them all the same
   rounded, soft-shadow treatment. */
.app-container {
  padding: 12px;
  gap: 12px;
  background: var(--bg-cream);
}

.left-sidebar {
  border-radius: 16px;
  border: 1px solid var(--border-light);
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  height: calc(100vh - 24px);
  flex-shrink: 0;
}

.main-content {
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex: 1;
  min-width: 0;
  height: calc(100vh - 24px);
  gap: 12px;
  background: transparent;
}

.home-view {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.04);
  flex: 1;
  min-width: 0;
}

.home-view .home-topbar {
  background: transparent;
}

.chat-view {
  background: transparent;
  flex: 1;
  min-width: 0;
  min-height: 0;
  height: 100%;
  gap: 12px;
}

.chat-view .chat-main {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  flex: 1;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.chat-view .sidebar {
  border-radius: 16px;
  border: 1px solid var(--border-light);
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  height: auto;
}

.artifact-canvas {
  border-radius: 16px;
  border: 1px solid var(--border-light);
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  min-height: 0;
  height: 100%;
}

/* Home button in chat header */
.home-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-light);
  background: var(--bg-white);
  border-radius: 10px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
  margin-right: 10px;
  flex-shrink: 0;
}

.home-btn:hover {
  border-color: var(--accent-coral);
  color: var(--accent-coral-dark);
}

.home-btn svg {
  width: 16px;
  height: 16px;
}

/* ==================== INLINE TOOL CALL (detailed view) ==================== */
/* Vertical timeline rail — multiple consecutive tool cards share a coral
   left-edge guide like a stepper. */
.message-content .inline-tool-call + .inline-tool-call {
  margin-top: 6px;
}

/* ── Tool-grid mode — 2-column wrap when ≥5 tool cards in one message ──
   Added by _relayoutInlineToolGrid() in renderer.js when the count of
   direct `.inline-tool-call` children of a .message-content reaches the
   threshold. Each card carries a `data-grid-pos="0|1"` attribute so we
   can flip the right-margin off on the right column without relying on
   :nth-of-type (which counts ALL same-type siblings, including non-tool
   divs). The stepper rail (::before / ::after) is hidden in grid mode —
   the visual cue from the rail only makes sense for a single vertical
   column, not a 2-column wrap.
   Mobile (≤640px): collapse back to single-column so cards don't get
   squeezed below ~140px and become unreadable. */
.message-content.tool-grid-mode > .inline-tool-call {
  display: inline-block;
  width: calc(50% - 6px);
  vertical-align: top;
  margin: 6px 12px 0 0;
  box-sizing: border-box;
}

.message-content.tool-grid-mode > .inline-tool-call[data-grid-pos="1"] {
  margin-right: 0;
}

.message-content.tool-grid-mode > .inline-tool-call::before,
.message-content.tool-grid-mode > .inline-tool-call::after {
  display: none;
}

@media (max-width: 640px) {
  .message-content.tool-grid-mode > .inline-tool-call {
    display: block;
    width: 100%;
    margin: 6px 0 0 0;
  }
}

.inline-tool-call {
  position: relative;
  animation: tool-card-in 0.25s ease-out;
}

.inline-tool-call::before {
  content: '';
  position: absolute;
  left: -14px;
  top: 22px;
  bottom: -6px;
  width: 2px;
  background: linear-gradient(var(--accent-coral) 0%, rgba(196, 145, 123, 0.15) 100%);
  border-radius: 1px;
  opacity: 0;
  transition: opacity 0.25s;
}

.inline-tool-call + .inline-tool-call::before {
  opacity: 1;
}

.inline-tool-call::after {
  content: '';
  position: absolute;
  left: -18px;
  top: 12px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bg-white);
  border: 2px solid var(--accent-coral);
  box-sizing: border-box;
  transition: all 0.2s;
}

.inline-tool-call.done::after {
  background: var(--accent-coral);
}

/* Spinner / check icons */
.inline-tool-header .tool-spinner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.inline-tool-header .tool-spinner svg {
  width: 18px;
  height: 18px;
  color: var(--accent-coral);
  animation: tool-spin 2.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  transform-origin: center;
  opacity: 0.7;
}

@keyframes tool-spin {
  from { transform: rotate(0deg); opacity: 0.5; }
  50% { opacity: 1; }
  to { transform: rotate(360deg); opacity: 0.5; }
}

/* Gradient sweep at bottom of running tool cards */
@keyframes tool-sweep {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.inline-tool-header .tool-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.inline-tool-header .tool-check svg {
  width: 14px;
  height: 14px;
  color: #3a8a5c;
}

.inline-tool-call.done .tool-spinner { display: none !important; }
.inline-tool-call.done .tool-check { display: inline-flex !important; }

.inline-tool-header .tool-friendly {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Input section code block */
.tool-section.tool-input-section .tool-input-content {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-primary);
  padding: 10px 12px;
  border-radius: 8px;
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 11.5px;
  line-height: 1.5;
  overflow-x: auto;
  max-height: 160px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--border-light);
  margin: 0;
}

/* Output section */
.tool-output-rendered {
  margin-bottom: 8px;
}

/* ── Search Results — Vertical Subway Feed ── */
.tool-result-summary {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-tertiary);
  padding: 0 0 6px 28px;
}

.tool-card-result {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px 8px 0;
  text-decoration: none;
  color: var(--text-primary);
  transition: all 0.15s;
  position: relative;
  margin-left: 10px;
  padding-left: 18px;
  border-left: 2px solid var(--border-light);
}

/* Subway dot */
.tool-card-result::before {
  content: '';
  position: absolute;
  left: -5px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bg-white);
  border: 2px solid var(--accent-coral);
  transition: background 0.15s;
}

.tool-card-result:hover::before {
  background: var(--accent-coral);
}

.tool-card-result:hover {
  text-decoration: none;
  color: var(--accent-coral-dark);
}

/* Last item: no bottom border */
.tool-card-result:last-child {
  border-left-color: transparent;
}

.tool-card-fav {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: var(--bg-cream);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
  overflow: hidden;
}

.tool-card-fav img {
  width: 14px;
  height: 14px;
  display: block;
}

.tool-card-result-title {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.15s;
}

.tool-card-result:hover .tool-card-result-title {
  color: var(--accent-coral-dark);
}

.tool-card-result-domain {
  font-size: 10px;
  color: var(--text-tertiary);
  flex-shrink: 0;
  max-width: 150px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@keyframes tool-card-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==================== CANVAS EXPAND ==================== */
.artifact-canvas.expanded {
  position: fixed;
  top: 12px;
  right: 12px;
  bottom: 12px;
  left: 12px;
  width: auto;
  max-width: none;
  z-index: 100; /* above left-sidebar overlay (80) so expand covers the rail */
}

.chat-view.artifact-expanded .chat-main,
.chat-view.artifact-expanded .sidebar {
  opacity: 0.35;
  pointer-events: none;
  transition: opacity 0.2s;
}

/* ════════════════════════════════════════════════════════════════════════
 * User message — bubble + sources layout
 * Right-aligned vertical stack: file/URL chips on top, prose bubble below.
 * Replaces the old 3-sibling flex-row which caused jagged wrapping when
 * URLs + attachments were combined with prose.
 * ════════════════════════════════════════════════════════════════════════ */

.message.user .message-bubble-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  /* 75% cap keeps long user messages from sprawling all the way across
   * the message column. Right-edge alignment with the composer below is
   * preserved separately by `.message.user { justify-content: flex-end; }`,
   * which pushes the wrap (whatever its width) to the column's right
   * edge — so the bubble's right edge always lines up with the input
   * box, while the cap controls how far it can grow leftward. */
  max-width: 75%;
  min-width: 0;
}

/* Author label — Apple-style: small slate grey, sits above the bubble so
 * the user always knows who's speaking AND when. Two pieces:
 *   .message-author-name — semibold, the speaker's name
 *   .message-author-time — lighter, IST date · 24h time
 * Separated by a small gap; render as a baseline-aligned inline-flex row
 * so name + time stay visually anchored. */
.message-author {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  margin: 0 4px 4px;
  user-select: none;
}
.message-author-name {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(15, 23, 42, 0.62);
}
.message-author-time {
  font-size: 10.5px;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: rgba(15, 23, 42, 0.42);
  font-variant-numeric: tabular-nums;
}
.message-author-user {
  align-self: flex-end;
}
.message-author-assistant {
  align-self: flex-start;
  margin-bottom: 6px;
}
@media (prefers-color-scheme: dark) {
  .message-author-name { color: rgba(255, 255, 255, 0.65); }
  .message-author-time { color: rgba(255, 255, 255, 0.42); }
}

.message-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  max-width: 100%;
}

/* Unified source chip — files AND urls use the same pill style so the
 * row reads as a coherent "sources" bar. Coral-on-cream for warmth. */
.message-source-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px 6px 10px;
  background: var(--bg-white);
  border: 1px solid rgba(192, 139, 92, 0.22);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(26, 15, 5, 0.04);
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
  line-height: 1;
  max-width: 260px;
}

.message-source-chip:hover {
  background: #fefaf5;
  border-color: rgba(192, 139, 92, 0.4);
  transform: translateY(-1px);
}

.message-source-chip svg {
  color: var(--accent-coral);
  flex-shrink: 0;
}

.message-source-chip-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  letter-spacing: -0.1px;
}

/* Slight visual distinction so users can tell files from URLs at a glance */
.message-source-chip-url {
  /* URL chips get a subtle background tint — same coral family */
  background: linear-gradient(180deg, #fefaf5 0%, #fdf5eb 100%);
}

.message-source-chip-url .message-source-chip-label {
  color: var(--accent-coral-dark, #a87644);
  font-weight: 500;
}

/* Placeholder text when the prose bubble would otherwise be empty
 * (e.g. the user dropped a URL alone — we don't want an empty bubble) */
.message-content-placeholder {
  opacity: 0.78;
  font-style: italic;
  font-size: 14px;
}

/* ==================== DOCUMENT ARTIFACT CARD ==================== */
.artifact-document-card-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 32px;
  min-height: 100%;
}

.artifact-document-card {
  background: var(--bg-cream);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 40px 36px 32px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.05);
}

.artifact-document-icon {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-coral);
}

.artifact-document-icon svg {
  width: 28px;
  height: 28px;
}

.artifact-document-title {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 22px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
  letter-spacing: -0.2px;
  word-break: break-word;
}

.artifact-document-meta {
  font-size: 12px;
  color: var(--text-tertiary);
  font-family: 'Monaco', 'Menlo', monospace;
  margin-bottom: 22px;
  word-break: break-all;
}

.artifact-document-btn {
  display: inline-block;
  padding: 10px 24px;
  background: var(--accent-coral);
  color: white;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s;
}

.artifact-document-btn:hover {
  background: var(--accent-coral-dark);
  text-decoration: none;
}

.tool-output-rendered {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-primary);
  padding: 10px 14px;
}

.tool-output-rendered a {
  color: var(--accent-coral-dark);
  text-decoration: underline;
}

.tool-output-rendered .search-result {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
}

.tool-output-rendered .search-result:last-child { border-bottom: none; }

.tool-output-rendered .search-result-title {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.tool-output-rendered .search-result-url {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: 'Monaco', 'Menlo', monospace;
  margin-bottom: 4px;
  word-break: break-all;
}

.tool-output-rendered .search-result-snippet {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ==================== PROJECT FOLDER PICKER ==================== */

/* Folder button in controls */
.folder-btn {
  position: relative;
}

.folder-btn.active {
  color: var(--accent-coral) !important;
  background: rgba(196, 145, 123, 0.08) !important;
}

/* Project indicator below input */
.project-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px 10px;
  font-size: 12px;
  color: var(--accent-coral-dark);
}

.project-indicator svg {
  flex-shrink: 0;
  color: var(--accent-coral);
}

.project-indicator-name {
  font-weight: 500;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-indicator-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: none;
  background: none;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-tertiary);
  transition: all 0.12s;
  padding: 0;
  margin-left: 2px;
}

.project-indicator-clear:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-primary);
}

/* Chat header project badge */
.chat-project-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: rgba(196, 145, 123, 0.08);
  border: 1px solid rgba(196, 145, 123, 0.2);
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
  color: var(--accent-coral-dark);
  cursor: pointer;
  transition: all 0.15s;
  margin-left: 8px;
  max-width: 200px;
  overflow: hidden;
}

.chat-project-badge:hover {
  background: rgba(196, 145, 123, 0.14);
  border-color: rgba(196, 145, 123, 0.35);
}

.chat-project-badge svg {
  flex-shrink: 0;
}

.chat-project-badge span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==================== HOME VIEW CLEANUP ==================== */

/* Simpler recents section below chips */
.home-recents-section {
  max-width: 960px;
  margin: 24px auto 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.home-recents-section .home-recents {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  align-items: stretch;
  justify-content: stretch;
}

.home-recent-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px 18px 14px;
  background:
    linear-gradient(135deg, rgba(42, 56, 153, 0.022) 0%, rgba(255, 255, 255, 0) 42%, rgba(29, 154, 148, 0.028) 100%),
    linear-gradient(180deg, #ffffff 0%, #fafbfd 100%);
  border: 1px solid rgba(20, 30, 80, 0.07);
  border-radius: 14px;
  cursor: pointer;
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 13px;
  color: var(--text-secondary);
  text-align: left;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.28s ease,
              box-shadow 0.32s ease,
              background 0.28s ease;
  min-height: 156px;
  max-width: none;
  overflow: hidden;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 1px 2px rgba(20, 30, 80, 0.025),
    0 6px 16px rgba(20, 30, 80, 0.022);
}

.home-recent-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: var(--brand-gradient-rule);
  opacity: 0;
  transition: opacity 0.28s ease;
  pointer-events: none;
}

.home-recent-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 14px;
  background: radial-gradient(120% 80% at 0% 0%, rgba(42, 56, 153, 0.045) 0%, transparent 55%);
  opacity: 0;
  transition: opacity 0.28s ease;
  pointer-events: none;
}

.home-recent-card:hover {
  border-color: rgba(42, 56, 153, 0.20);
  color: var(--text-primary);
  transform: translateY(-3px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 12px 30px rgba(20, 30, 80, 0.08),
    0 2px 8px rgba(42, 56, 153, 0.05);
}

.home-recent-card:hover::before { opacity: 1; }
.home-recent-card:hover::after { opacity: 1; }

.home-recent-card--pinned {
  background:
    linear-gradient(135deg, rgba(42, 56, 153, 0.045) 0%, rgba(255, 255, 255, 0) 50%, rgba(29, 154, 148, 0.05) 100%),
    linear-gradient(180deg, #fdfdff 0%, #ffffff 60%);
  border-color: rgba(42, 56, 153, 0.18);
}

/* Running session — soft indigo glow on the border to mirror the sidebar. */
.home-recent-card--running {
  border-color: rgba(42, 56, 153, 0.35);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    0 1px 2px rgba(20, 30, 80, 0.025),
    0 0 0 3px rgba(42, 56, 153, 0.05),
    0 6px 16px rgba(42, 56, 153, 0.06);
}

.home-recent-running {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px 3px 7px;
  border-radius: 999px;
  background: rgba(42, 56, 153, 0.09);
  color: var(--brand-indigo);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.home-recent-running-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand-teal);
  box-shadow: 0 0 0 3px rgba(29, 154, 148, 0.18);
  animation: homeRecentRunningPulse 1.4s ease-in-out infinite;
}

@keyframes homeRecentRunningPulse {
  0%, 100% { opacity: 0.55; transform: scale(0.85); }
  50%      { opacity: 1;    transform: scale(1.1); }
}

.home-recent-card--pinned::before { opacity: 0.55; }

.home-recent-pin {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 11px;
  line-height: 1;
  color: var(--brand-indigo);
  opacity: 0.85;
}

.home-recent-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-family: 'EB Garamond', Georgia, serif;
  font-weight: 500;
  font-size: 17px;
  color: var(--brand-indigo);
  line-height: 1.22;
  letter-spacing: -0.005em;
  padding-right: 14px;
  word-break: break-word;
  position: relative;
  z-index: 1;
}

.home-recent-preview {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-tertiary);
  word-break: break-word;
  flex: 1;
  position: relative;
  z-index: 1;
  padding-right: 64px;
}

/* When the preview body is an artifact, switch to a structured layout:
   small indigo title row above a 2-line snippet of the artifact body. */
.home-recent-preview--artifact {
  display: flex;
  flex-direction: column;
  gap: 4px;
  -webkit-line-clamp: unset;
  overflow: hidden;
}

.home-recent-art-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.005em;
  line-height: 1.22;
  color: var(--brand-indigo);
  word-break: break-word;
  padding-right: 14px;
}

.home-recent-art-snippet {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-tertiary);
  word-break: break-word;
}

.home-recent-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid rgba(20, 30, 80, 0.06);
  position: relative;
  z-index: 1;
}

.home-recent-time {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.home-recent-meta {
  font-size: 10.5px;
  color: rgba(20, 30, 80, 0.42);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.home-recent-sep {
  color: rgba(20, 30, 80, 0.22);
  font-size: 10px;
  user-select: none;
}

.home-recent-preview--empty {
  font-style: italic;
  color: rgba(20, 30, 80, 0.32);
  letter-spacing: 0.005em;
}

/* Assistant-reply preview (used when no artifact yet) — slightly stronger
   contrast than the prompt-only summary so the reader's eye lands on the
   actual answer text instead of skimming past it as metadata. */
.home-recent-preview--reply {
  color: var(--text-secondary);
}

.home-recent-mono {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 56px;
  height: 56px;
  object-fit: contain;
  opacity: 0.55;
  pointer-events: none;
  user-select: none;
  transition: opacity 0.36s ease, transform 0.36s ease;
  z-index: 0;
}

.home-recent-card:hover .home-recent-mono {
  opacity: 0.85;
  transform: rotate(-8deg) scale(1.06);
}

.home-recent-badge {
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(42, 56, 153, 0.07);
  color: var(--brand-indigo);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.home-recents-toggle {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  margin-top: 18px;
  border: 1px solid rgba(42, 56, 153, 0.14);
  border-radius: 999px;
  background: var(--bg-white);
  color: var(--text-secondary);
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.22s ease;
  box-shadow: 0 1px 2px rgba(20, 30, 80, 0.03);
}

.home-recents-toggle:hover {
  border-color: rgba(42, 56, 153, 0.32);
  color: var(--brand-indigo);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(42, 56, 153, 0.10);
}

.home-recents-toggle svg {
  width: 12px;
  height: 12px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Fact Validation -- Diff Annotations
   ═══════════════════════════════════════════════════════════════════════════ */

/* Validated pane inherits .artifact-pane positioning + the shared
   :is(.artifact-preview-pane, .artifact-validated-pane) rules for its
   artifact body. The padding / font / p-margin rules that used to live
   here rendered the pane NARROWER than Preview (64px of extra horizontal
   padding), so every table inside came out narrower and formatting
   diverged. Leave those to the shared rules. */

/* Correction wrapper */
.artifact-validated-pane .fv-correction {
  position: relative;
  cursor: help;
  border-radius: 3px;
  padding: 0 1px;
}

/* Deleted / original text */
.artifact-validated-pane del {
  background: #fde8e8;
  color: #991b1b;
  text-decoration: line-through;
  text-decoration-color: #ef4444;
  border-radius: 2px;
  padding: 1px 4px;
  font-style: normal;
}

/* Inserted / corrected text */
.artifact-validated-pane ins {
  background: #dcfce7;
  color: #166534;
  text-decoration: none;
  border-radius: 2px;
  padding: 1px 4px;
  font-weight: 600;
}

/* Outdated data highlight */
.artifact-validated-pane .fv-outdated del {
  background: #fef3c7;
  color: #92400e;
  text-decoration-color: #f59e0b;
}

.artifact-validated-pane .fv-outdated ins {
  background: #fef9c3;
  color: #713f12;
}

/* Unverifiable claims */
.artifact-validated-pane .fv-unverifiable {
  background: #fef9c3;
  border-bottom: 2px dashed #facc15;
  padding: 1px 4px;
  border-radius: 2px;
}

.artifact-validated-pane .fv-unverifiable sup {
  color: #854d0e;
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 10px;
  font-weight: 600;
}

/* Multi-fact tab strip — sits below the dialog .re-head so the close
   button + drag handle stay pinned at the top. Wraps onto multiple
   rows when there are many facts; the dialog's overflow-y: auto
   handles the rest. */
.fv-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0 12px;
  padding: 8px;
  background: rgba(15, 23, 42, 0.04);
  border-radius: 10px;
}
.fv-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 999px;
  background: #fff;
  color: #1f2937;
  font: 500 12px/1.2 'Plus Jakarta Sans', system-ui, sans-serif;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
  max-width: 240px;
}
.fv-tab:hover {
  background: rgba(15, 23, 42, 0.06);
  border-color: rgba(15, 23, 42, 0.16);
}
.fv-tab-active {
  background: #0f172a;
  border-color: #0f172a;
  color: #fff;
}
.fv-tab-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fv-tab-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex: 0 0 auto;
  display: inline-block;
}
.fv-tab-dot-correct      { background: #22c55e; }
.fv-tab-dot-outdated     { background: #f59e0b; }
.fv-tab-dot-inaccurate   { background: #ef4444; }
.fv-tab-dot-unverifiable { background: #facc15; }

/* Dark-mode mirror */
@media (prefers-color-scheme: dark) {
  .fv-tabs {
    background: rgba(255, 255, 255, 0.04);
  }
  .fv-tab {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.10);
    color: #e5e7eb;
  }
  .fv-tab:hover {
    background: rgba(255, 255, 255, 0.10);
    border-color: rgba(255, 255, 255, 0.18);
  }
  .fv-tab-active {
    background: #f8fafc;
    border-color: #f8fafc;
    color: #0f172a;
  }
}

/* Hover tooltip */
.artifact-validated-pane .fv-correction:hover .fv-tooltip {
  display: block;
}

.fv-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: var(--text-primary, #1a1a1a);
  color: #fafafa;
  padding: 10px 14px;
  border-radius: 10px;
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 12px;
  line-height: 1.5;
  max-width: 360px;
  min-width: 200px;
  white-space: normal;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  pointer-events: none;
}

.fv-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 16px;
  border: 6px solid transparent;
  border-top-color: var(--text-primary, #1a1a1a);
}

.fv-tooltip .fv-tooltip-verdict {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.fv-tooltip .fv-tooltip-verdict.inaccurate { color: #fca5a5; }
.fv-tooltip .fv-tooltip-verdict.outdated { color: #fcd34d; }
.fv-tooltip .fv-tooltip-verdict.unverifiable { color: #fde047; }

.fv-tooltip .fv-tooltip-explanation {
  margin-bottom: 6px;
}

.fv-tooltip .fv-tooltip-source {
  color: var(--accent-coral, #c9977a);
  font-size: 11px;
  word-break: break-all;
}

.fv-tooltip .fv-tooltip-freshness {
  color: #a3a3a3;
  font-size: 11px;
  font-style: italic;
  margin-top: 4px;
}

/* ========================================================================
   Validation Dynamic Island
   Floating glassmorphic pill that overlays the artifact body during a
   validation run. Driven by SSE events (phase_start, phase_done,
   validation_result, error). Auto-collapses after success or hides
   immediately on error after a brief shake.
   ====================================================================== */
.fv-island {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%) translateY(-12px) scale(0.92);
  z-index: 25;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  min-height: 40px;
  max-width: calc(100% - 48px);
  /* Liquid glass — translucent light glass with heavy blur + saturation
     boost. Sits on the chat/canvas which is a cream/light surface, so
     the dark variant got drowned by the light bg. The dark-mode mirror
     under prefers-color-scheme: dark reverts to the dark-glass look. */
  background: rgba(255, 255, 255, 0.78);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 999px;
  box-shadow:
    0 14px 36px -10px rgba(15, 23, 42, 0.18),
    0 1px 2px rgba(15, 23, 42, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  /* Spring-ish transition for the morph */
  transition:
    transform 480ms cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 280ms ease,
    background-color 320ms ease,
    border-color 320ms ease,
    box-shadow 320ms ease;
  opacity: 0;
  pointer-events: none;
  cursor: default;
  user-select: none;
}
.fv-island[hidden] { display: none !important; }
.fv-island.fv-island-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0) scale(1);
}
.fv-island-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  background: linear-gradient(135deg, #6366f1 0%, #ec4899 100%);
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.45);
}
.fv-island-text {
  /* Dark slate on the light-glass island (primary). Dark-mode mirror at
     the bottom of this file flips it back to white-on-dark. */
  color: rgba(15, 23, 42, 0.92);
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60ch;
}
.fv-island-meta {
  color: rgba(15, 23, 42, 0.55);
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 11.5px;
  font-weight: 400;
  white-space: nowrap;
  padding-left: 8px;
  border-left: 1px solid rgba(15, 23, 42, 0.12);
  opacity: 0;
  max-width: 0;
  overflow: hidden;
  transition: opacity 240ms ease, max-width 360ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.fv-island.fv-island-has-meta .fv-island-meta {
  opacity: 1;
  max-width: 30ch;
}

/* Per-state palette — the icon's gradient + glow color drive the
   "alive" feel. State changes morph the colors smoothly. */
.fv-island[data-state="reading"] .fv-island-icon {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  box-shadow: 0 0 18px rgba(99, 102, 241, 0.55);
  animation: fv-island-pulse 1.6s ease-in-out infinite;
}
.fv-island[data-state="searching"] .fv-island-icon {
  background: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%);
  box-shadow: 0 0 18px rgba(59, 130, 246, 0.55);
  animation: fv-island-pulse 1.6s ease-in-out infinite;
}
.fv-island[data-state="analyzing"] .fv-island-icon {
  background: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
  box-shadow: 0 0 18px rgba(139, 92, 246, 0.55);
  animation: fv-island-pulse 1.6s ease-in-out infinite;
}
.fv-island[data-state="processing"] .fv-island-icon {
  background: linear-gradient(135deg, #f97316 0%, #ec4899 100%);
  box-shadow: 0 0 18px rgba(249, 115, 22, 0.55);
  animation: fv-island-pulse 1.6s ease-in-out infinite;
}
.fv-island[data-state="success"] {
  background: rgba(209, 250, 229, 0.88);
  border-color: rgba(16, 185, 129, 0.35);
  box-shadow:
    0 14px 36px -10px rgba(15, 23, 42, 0.18),
    0 0 18px rgba(16, 185, 129, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.fv-island[data-state="success"] .fv-island-text { color: #064e3b; }
.fv-island[data-state="success"] .fv-island-icon {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 0 22px rgba(16, 185, 129, 0.5);
  animation: fv-island-celebrate 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.fv-island[data-state="error"] {
  background: rgba(254, 226, 226, 0.88);
  border-color: rgba(239, 68, 68, 0.35);
  animation: fv-island-shake 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}
.fv-island[data-state="error"] .fv-island-text { color: #7f1d1d; }
.fv-island[data-state="error"] .fv-island-icon {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  box-shadow: 0 0 22px rgba(239, 68, 68, 0.45);
}
.fv-island[data-state="warning"] {
  background: rgba(254, 243, 199, 0.88);
  border-color: rgba(251, 191, 36, 0.35);
}
.fv-island[data-state="warning"] .fv-island-text { color: #78350f; }
.fv-island[data-state="warning"] .fv-island-icon {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  box-shadow: 0 0 18px rgba(251, 191, 36, 0.4);
}

@keyframes fv-island-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}
@keyframes fv-island-celebrate {
  0% { transform: scale(0.85); }
  60% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
@keyframes fv-island-shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-3px, 0, 0); }
  40%, 60% { transform: translate3d(3px, 0, 0); }
}

/* ── Polish island ─────────────────────────────────────────────────────
   Inherits all positioning + glass styling from .fv-island (the polish
   island has both classes). Only the per-state palette differs — the
   artifact-writer's polish doesn't progress through reading/searching/
   analyzing the way fact-validation does, so we override just the two
   states it actually uses: 'polishing' and 'final'. */
.polish-island { cursor: pointer; }
.polish-island[data-state="polishing"] .fv-island-icon {
  /* Coral → teal gradient — matches the navy/coral/teal artifact palette
     baked into docx-builder, so the island reads as part of the same
     design system as the artifact it represents. */
  background: linear-gradient(135deg, #C08B5C 0%, #2C7A7B 100%);
  box-shadow: 0 0 18px rgba(192, 139, 92, 0.50);
  animation: fv-island-pulse 1.6s ease-in-out infinite;
}
.polish-island[data-state="final"] {
  background: rgba(209, 250, 229, 0.88);
  border-color: rgba(16, 185, 129, 0.35);
  box-shadow:
    0 14px 36px -10px rgba(15, 23, 42, 0.18),
    0 0 18px rgba(16, 185, 129, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.polish-island[data-state="final"] .fv-island-text { color: #064e3b; }
.polish-island[data-state="final"] .fv-island-icon {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 0 22px rgba(16, 185, 129, 0.5);
  animation: fv-island-celebrate 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Finalize island ───────────────────────────────────────────────────
   Inherits all positioning + glass styling from .fv-island. Surfaces
   the post-stream pipeline state (citation resolution + followup
   suggestions) so the user knows the page is still doing work after
   the artifact has landed on canvas. Teal/sage gradient on the icon —
   the "finalizing pass" color, distinct from polish-island's coral
   ("artifact-writer polish") and redesign-island's orange ("redesign
   transform"). Driven by _renderCanvasFromModel via
   _isPostStreamPolishPending. */
.finalize-island { cursor: default; }
.finalize-island[data-state="finalizing"] .fv-island-icon {
  background: linear-gradient(135deg, #2C7A7B 0%, #14b8a6 100%);
  box-shadow: 0 0 18px rgba(20, 184, 166, 0.50);
  animation: fv-island-pulse 1.6s ease-in-out infinite;
}
.finalize-island[data-state="finalizing"] {
  /* Subtly tint the glass toward teal so the island reads as a member
   * of the teal palette even before the user has parsed the icon. */
  background: rgba(240, 253, 251, 0.85);
  border-color: rgba(20, 184, 166, 0.22);
}
/* Keep finalize pipeline behavior intact but suppress its visual pill. */
#finalizeIsland { display: none !important; }

/* ── Image-gen island ──────────────────────────────────────────────────
   Fifth sibling in the canvas-status island family. Tracks the parallel
   image-generation orchestrator's progress: slides in on
   image_gen_started, updates "N of M done" on each image_gen_progress
   done/failed event, fades on image_gen_complete. Cobalt → cyan gradient
   on the icon — matches the DEA-MER chart palette so it reads as part
   of the same design system as the charts it represents. */
.image-gen-island { cursor: default; }
.image-gen-island[data-state="generating"] .fv-island-icon {
  background: linear-gradient(135deg, #2E4899 0%, #56CCF2 100%);
  box-shadow: 0 0 18px rgba(86, 204, 242, 0.55);
  animation: fv-island-pulse 1.6s ease-in-out infinite;
}
.image-gen-island[data-state="generating"] {
  background: rgba(232, 240, 255, 0.85);
  border-color: rgba(68, 114, 196, 0.28);
}
.image-gen-island[data-state="complete"] {
  background: rgba(209, 250, 229, 0.88);
  border-color: rgba(16, 185, 129, 0.35);
  box-shadow:
    0 14px 36px -10px rgba(15, 23, 42, 0.18),
    0 0 18px rgba(16, 185, 129, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.image-gen-island[data-state="complete"] .fv-island-text { color: #064e3b; }
.image-gen-island[data-state="complete"] .fv-island-icon {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 0 22px rgba(16, 185, 129, 0.5);
  animation: fv-island-celebrate 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Image-generation deck — canvas layout ────────────────────────────
   Multi-image deck artifacts (one or more charts) render as a vertical
   stack of full-width image blocks. Each block: caption (title + brief)
   above, image (or skeleton/error) below, action row at the bottom.
   Designed to read like a print-quality visual brief, not a chat
   attachment. */
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-image-deck {
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding: 8px 0 32px;
}
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-image-deck-title {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 30px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: #1a365d;
  margin: 0 0 8px 0;
  padding-bottom: 14px;
  border-bottom: 2px solid #1a365d;
}
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-image-block {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  background: #FFFFFF;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-image-block.status-failed {
  border-color: rgba(192, 0, 0, 0.22);
  background: rgba(192, 0, 0, 0.02);
}
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-image-caption {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-image-caption h3 {
  font-family: 'Inter', sans-serif;
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: #2E4899;
  margin: 0;
}
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-image-caption p {
  font-size: 13.5px;
  line-height: 1.55;
  color: #4a5568;
  margin: 0;
}
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-image {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.10);
}
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-image-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-image-action {
  font-size: 12px;
  font-weight: 500;
  color: #2E4899;
  text-decoration: none;
  padding: 5px 12px;
  border: 1px solid rgba(46, 72, 153, 0.25);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.6);
  transition: background 0.15s ease, border-color 0.15s ease;
}
:is(.artifact-preview-pane, .artifact-validated-pane) .artifact-image-action:hover {
  background: rgba(46, 72, 153, 0.06);
  border-color: rgba(46, 72, 153, 0.4);
}
.artifact-image-error {
  padding: 18px;
  color: #7f1d1d;
  background: rgba(192, 0, 0, 0.05);
  border: 1px dashed rgba(192, 0, 0, 0.25);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
}

/* Skeleton tile while a per-image generation is in flight. 16:9 aspect
   with a shimmer gradient and a caption labelling which image is in
   progress. Inherits the aphPulse keyframes already defined for the
   phase pill. */
.artifact-image-skeleton {
  position: relative;
  aspect-ratio: 16 / 9;
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(232, 240, 255, 0.5);
  border: 1px solid rgba(68, 114, 196, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
}
.artifact-image-skeleton-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    100deg,
    rgba(232, 240, 255, 0) 30%,
    rgba(46, 72, 153, 0.10) 50%,
    rgba(232, 240, 255, 0) 70%
  );
  background-size: 200% 100%;
  animation: artifact-image-skeleton-shimmer 1.8s ease-in-out infinite;
}
@keyframes artifact-image-skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -100% 0; }
}
.artifact-image-skeleton-caption {
  position: relative;
  z-index: 1;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: #2E4899;
  margin: 0;
  text-align: center;
  padding: 12px 24px;
}

/* ── Redesign island ───────────────────────────────────────────────────
   Third sibling in the canvas-status island family. Distinct gradient
   (coral → orange) so users can tell at a glance which of the three
   processes is running, but identical positioning + glass styling for
   visual consistency. Driven by design-canvas.js. */
.redesign-island { cursor: pointer; }
.redesign-island[data-state="working"] .fv-island-icon {
  background: linear-gradient(135deg, #C08B5C 0%, #f97316 100%);
  box-shadow: 0 0 18px rgba(249, 115, 22, 0.50);
  animation: fv-island-pulse 1.6s ease-in-out infinite;
}
.redesign-island[data-state="applying"] .fv-island-icon {
  background: linear-gradient(135deg, #f97316 0%, #ec4899 100%);
  box-shadow: 0 0 18px rgba(236, 72, 153, 0.55);
  animation: fv-island-pulse 1.2s ease-in-out infinite;
}
.redesign-island[data-state="success"] {
  background: rgba(209, 250, 229, 0.88);
  border-color: rgba(16, 185, 129, 0.35);
  box-shadow:
    0 14px 36px -10px rgba(15, 23, 42, 0.18),
    0 0 18px rgba(16, 185, 129, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.redesign-island[data-state="success"] .fv-island-text { color: #064e3b; }
.redesign-island[data-state="success"] .fv-island-icon {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 0 22px rgba(16, 185, 129, 0.5);
  animation: fv-island-celebrate 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.redesign-island[data-state="error"] {
  background: rgba(254, 226, 226, 0.88);
  border-color: rgba(239, 68, 68, 0.35);
  animation: fv-island-shake 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}
.redesign-island[data-state="error"] .fv-island-text { color: #7f1d1d; }
.redesign-island[data-state="error"] .fv-island-icon {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  box-shadow: 0 0 22px rgba(239, 68, 68, 0.45);
}

/* ── Indexing island ───────────────────────────────────────────────────
   Fourth sibling. Cyan→indigo gradient — distinct from the other three
   islands so a glance tells the user which type of background work is
   running. Reads as "data being pulled into the system" which matches
   the chunking + embedding pipeline that drives it. */
.indexing-island { cursor: pointer; }
.indexing-island[data-state="queuing"] .fv-island-icon {
  background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);
  box-shadow: 0 0 16px rgba(100, 116, 139, 0.45);
  animation: fv-island-pulse 1.6s ease-in-out infinite;
}
.indexing-island[data-state="indexing"] .fv-island-icon {
  background: linear-gradient(135deg, #06b6d4 0%, #6366f1 100%);
  box-shadow: 0 0 18px rgba(99, 102, 241, 0.55);
  animation: fv-island-pulse 1.4s ease-in-out infinite;
}
.indexing-island[data-state="success"] {
  background: rgba(209, 250, 229, 0.88);
  border-color: rgba(16, 185, 129, 0.35);
  box-shadow:
    0 14px 36px -10px rgba(15, 23, 42, 0.18),
    0 0 18px rgba(16, 185, 129, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.indexing-island[data-state="success"] .fv-island-text { color: #064e3b; }
.indexing-island[data-state="success"] .fv-island-icon {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 0 22px rgba(16, 185, 129, 0.5);
  animation: fv-island-celebrate 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.indexing-island[data-state="error"] {
  background: rgba(254, 226, 226, 0.88);
  border-color: rgba(239, 68, 68, 0.35);
  animation: fv-island-shake 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}
.indexing-island[data-state="error"] .fv-island-text { color: #7f1d1d; }
.indexing-island[data-state="error"] .fv-island-icon {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  box-shadow: 0 0 22px rgba(239, 68, 68, 0.45);
}

/* ── Chat-status island ────────────────────────────────────────────────
   Fifth island, anchored to the chat view (not the canvas) so it's
   visible regardless of canvas state. Fires on chat navigation when
   activity happened while the user was elsewhere. Distinct emerald→
   teal gradient reads as "fresh / new content arrived". The
   .chat-status-island scope nudges position because it lives inside
   .chat-main rather than the canvas pane that fv-island assumes. */
.chat-status-island {
  /* chat-main has its own offset stack; anchor this island to its top
     center so it sits just below the chat header, above the messages. */
  position: absolute;
  top: 64px;
  left: 50%;
  transform: translateX(-50%) translateY(-12px) scale(0.92);
  cursor: pointer;
  z-index: 30;
}
.chat-status-island.fv-island-visible {
  transform: translateX(-50%) translateY(0) scale(1);
}
.chat-status-island[data-state="running"] .fv-island-icon {
  background: linear-gradient(135deg, #14b8a6 0%, #06b6d4 100%);
  box-shadow: 0 0 18px rgba(20, 184, 166, 0.50);
  animation: fv-island-pulse 1.6s ease-in-out infinite;
}
.chat-status-island[data-state="finished"] {
  background: rgba(209, 250, 229, 0.88);
  border-color: rgba(16, 185, 129, 0.35);
  box-shadow:
    0 14px 36px -10px rgba(15, 23, 42, 0.18),
    0 0 18px rgba(16, 185, 129, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.chat-status-island[data-state="finished"] .fv-island-text { color: #064e3b; }
.chat-status-island[data-state="finished"] .fv-island-icon {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 0 22px rgba(16, 185, 129, 0.5);
  animation: fv-island-celebrate 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
/* chat-main needs to be a positioning context for the absolute island. */
.chat-main { position: relative; }

/* ── Artifact tab flash ────────────────────────────────────────────────
   When a polish completes for an artifact the user isn't currently
   viewing, flash that artifact's tab in the canvas tab strip so the user
   knows to navigate back. Cleared when the user clicks the tab. The
   flash is a soft accent glow + animated dot pulse — distinctive but
   not jarring, since multiple artifacts can be polishing in parallel. */
.artifact-session-tab.has-update {
  color: var(--text-primary);
  animation: artifact-tab-flash 1.6s ease-in-out infinite;
}
.artifact-session-tab.has-update .ast-dot {
  background: #10b981;
  opacity: 1;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.65);
  animation: artifact-tab-dot-pulse 1.2s ease-in-out infinite;
}
@keyframes artifact-tab-flash {
  0%, 100% { background: transparent; }
  50% { background: rgba(16, 185, 129, 0.10); }
}
@keyframes artifact-tab-dot-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.45); }
}

/* ── Inline polish note (in chat) ──────────────────────────────────────
   Lands inside the assistant's message div right after the artifact
   card. Tells the user the artifact is a draft + polish is happening +
   they can keep going. Auto-removes when polish completes. */
.message-polish-note {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 9px 14px;
  background: rgba(192, 139, 92, 0.06);
  border: 1px dashed rgba(192, 139, 92, 0.40);
  border-radius: 10px;
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 12.5px;
  color: var(--text-secondary, #4A5568);
  line-height: 1.45;
  transition: opacity 240ms ease, background 320ms ease, border-color 320ms ease;
}
.message-polish-note .mpn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, #C08B5C 0%, #2C7A7B 100%);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 0 10px rgba(192, 139, 92, 0.40);
  animation: fv-island-pulse 1.6s ease-in-out infinite;
}
.message-polish-note.is-final {
  background: rgba(16, 185, 129, 0.08);
  border-style: solid;
  border-color: rgba(16, 185, 129, 0.40);
  color: #064e3b;
}
.message-polish-note.is-final .mpn-icon {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.45);
  animation: none;
}
.message-polish-note.is-fading {
  opacity: 0;
}

/* Validation island stays light glass regardless of OS color scheme —
   it lives over the chat/canvas surface which is always cream/light,
   so the dark mirror gets dropped on purpose. */

/* Validation summary bar */
.fv-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 14px 18px;
  background: var(--bg-cream, #faf8f5);
  border: 1px solid var(--border-light, #e5e2dc);
  border-radius: 10px;
  margin-bottom: 24px;
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 13px;
  color: var(--text-secondary, #6b6b6b);
}

.fv-summary-title {
  font-weight: 600;
  color: var(--text-primary, #1a1a1a);
  margin-right: 8px;
}

.fv-stat {
  display: flex;
  align-items: center;
  gap: 6px;
}

.fv-stat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.fv-stat-dot.correct { background: #22c55e; }
.fv-stat-dot.outdated { background: #f59e0b; }
.fv-stat-dot.inaccurate { background: #ef4444; }
.fv-stat-dot.unverifiable { background: #facc15; }

.fv-stat-count {
  font-weight: 600;
  color: var(--text-primary, #1a1a1a);
}

/* Corrections table at bottom */
.fv-corrections-table {
  margin-top: 32px;
  border-top: 2px solid var(--border-light, #e5e2dc);
  padding-top: 20px;
}

.fv-corrections-table h4 {
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary, #1a1a1a);
}

.fv-corrections-table table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 12px;
}

.fv-corrections-table th {
  text-align: left;
  padding: 8px 10px;
  background: var(--bg-cream, #faf8f5);
  border-bottom: 2px solid var(--border-light, #e5e2dc);
  font-weight: 600;
  color: var(--text-secondary, #6b6b6b);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.fv-corrections-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-light, #e5e2dc);
  vertical-align: top;
  line-height: 1.4;
}

.fv-corrections-table .fv-verdict-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.fv-verdict-badge.inaccurate { background: #fde8e8; color: #991b1b; }
.fv-verdict-badge.outdated { background: #fef3c7; color: #92400e; }
.fv-verdict-badge.unverifiable { background: #fef9c3; color: #854d0e; }
.fv-verdict-badge.correct { background: #dcfce7; color: #166534; }

/* Sub-tab island inside the Validated pane (Annotated | Facts).
   Floating glass pill, centered, sits above the body content. Matches
   the dynamic-island vocabulary: same blur, same border, same shadow.
   The island floats over the body's scroll content (it lives in the
   pane, not in the scroll container) so it stays put while the user
   scrolls the annotated artifact or facts table. */
.fv-subtab-island {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 42;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow:
    0 14px 36px -10px rgba(15, 23, 42, 0.18),
    0 1px 2px rgba(15, 23, 42, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.fv-subtab-chip {
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  border: 0;
  background: transparent;
  color: rgba(15, 23, 42, 0.6);
  cursor: pointer;
  white-space: nowrap;
  transition: background 160ms ease, color 160ms ease,
              box-shadow 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.fv-subtab-chip:hover {
  background: rgba(15, 23, 42, 0.05);
  color: rgba(15, 23, 42, 0.85);
}
.fv-subtab-chip.active {
  background: linear-gradient(180deg, #ffffff 0%, #faf8f5 100%);
  color: #0f172a;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.08),
    0 4px 8px rgba(15, 23, 42, 0.06);
}

/* Verdict tally chips inline in the same floating pill — replaces the
   old solid `.fv-summary` bar. Each stat shows a colored dot, the
   count, and a soft label, so the user reads the validation breakdown
   at a glance without leaving the floating island. */
.fv-island-divider {
  width: 1px;
  align-self: stretch;
  margin: 4px 4px 4px 6px;
  background: rgba(15, 23, 42, 0.1);
}
.fv-island-stat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font: 600 11.5px/1 'Plus Jakarta Sans', -apple-system, sans-serif;
  color: rgba(15, 23, 42, 0.7);
  white-space: nowrap;
}
.fv-island-stat b {
  color: #0f172a;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.fv-island-stat-label {
  color: rgba(15, 23, 42, 0.55);
  font-weight: 500;
}
.fv-island-stat-dot {
  width: 7px; height: 7px;
  border-radius: 999px;
  display: inline-block;
}
.fv-island-stat-dot--correct      { background: #22c55e; }
.fv-island-stat-dot--outdated     { background: #f59e0b; }
.fv-island-stat-dot--inaccurate   { background: #ef4444; }
.fv-island-stat-dot--unverifiable { background: #facc15; }

/* The sub-tab body is the effective render target for either Annotated
   or Facts. Annotated needs to carry the iframe/markdown render, so
   it mimics the artifact-pane sizing. Top padding clears the floating
   island so the first line of content isn't tucked under it. */
.fv-subtab-body {
  position: absolute;
  /* Start BELOW the floating island (top:56px) so content can never
     scroll up into the island area. Previously top:0 + padding-top:56px
     left the padding scrollable, causing rows to appear behind the island. */
  top: 56px; left: 0; right: 0; bottom: 0;
  overflow: auto;
}
.fv-subtab-body iframe { width: 100%; height: 100%; border: 0; }
.fv-subtab-body .artifact-markdown,
.fv-subtab-body .artifact-table-wrap,
.fv-subtab-body .artifact-svg-wrap { background: var(--bg-white, #fff); }

/* Facts table */
.fv-facts-body { padding: 0 18px 32px; }
.fv-facts-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-tertiary, #999);
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 13px;
}
.fv-facts-wrap {
  width: 100%;
  /* overflow-x is intentionally NOT set here — overflow is handled by
     .fv-subtab-body which is the real scroll container. The table uses
     a min-width so it can grow wider than the pane without breaking
     position:sticky on the header row. */
}
.fv-facts-table {
  width: 100%;
  min-width: 700px;
  table-layout: fixed;
  /* border-collapse:separate (not collapse) is required so that
     position:sticky on <th> works correctly — collapsed borders cause
     body rows to mis-align with the sticky header and borders to
     vanish during horizontal scroll. border-spacing:0 restores the
     visually-collapsed look. */
  border-collapse: separate;
  border-spacing: 0;
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 12.5px;
  background: var(--bg-white, #fff);
}
.fv-facts-table th {
  position: sticky;
  /* top:0 sticks the header at the top edge of .fv-subtab-body's scrollport.
     The 56px padding-top on that container already clears the floating island,
     so the header naturally starts below the island and sticks to 0 as the
     user scrolls. */
  top: 0;
  z-index: 2;
  text-align: left;
  padding: 10px 12px;
  background: var(--bg-cream, #faf8f5);
  /* Use box-shadow instead of border-bottom so the line travels with
     the sticky cell during horizontal scroll (border-bottom gets clipped
     at the edge of the scroll container with border-collapse:separate). */
  box-shadow: inset 0 -2px 0 var(--border-light, #e5e2dc);
  font-weight: 600;
  color: var(--text-secondary, #6b6b6b);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.fv-facts-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light, #e5e2dc);
  vertical-align: top;
  line-height: 1.45;
  color: var(--text-primary, #1a1a1a);
  /* Allow wrapping inside long unbreakable tokens (URLs, code, hashes)
     so cells stay within their column width. `anywhere` is the modern
     equivalent of `break-word` and is what we want for URLs. */
  overflow-wrap: anywhere;
  word-break: break-word;
}
.fv-facts-row.fv-row-applied td { opacity: 0.55; }
.fv-facts-row.fv-row-applied .fv-facts-orig,
.fv-facts-row.fv-row-applied .fv-facts-corrected { text-decoration: line-through; }
.fv-facts-orig { font-weight: 600; }
.fv-facts-corrected {
  margin-top: 4px;
  color: var(--text-secondary, #6b6b6b);
  font-weight: 500;
}
.fv-facts-arrow { color: var(--accent, #14b8a6); font-weight: 700; margin-right: 2px; }
.fv-facts-context-snippet {
  color: var(--text-secondary, #6b6b6b);
  font-size: 12px;
  max-height: 4.5em;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fv-facts-cell-evidence { font-size: 12px; color: var(--text-secondary, #6b6b6b); }
.fv-facts-evidence-src a { color: var(--accent, #0d9488); text-decoration: none; }
.fv-facts-evidence-src a:hover { text-decoration: underline; }
/* Compact URL line under the source-name link. Smaller, low-contrast,
   monospace-like so it reads as "where this came from" without competing
   with the actual evidence text. */
.fv-facts-evidence-url {
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-tertiary, #94a3b8);
  word-break: break-all;
}
.fv-facts-evidence-url a {
  color: inherit;
  text-decoration: none;
}
.fv-facts-evidence-url a:hover { text-decoration: underline; }
.fv-facts-evidence-expl { margin-top: 4px; color: var(--text-primary, #1a1a1a); }
.fv-facts-evidence-fresh { margin-top: 4px; color: var(--text-tertiary, #999); font-style: italic; font-size: 11px; }
.fv-src-date { color: var(--text-tertiary, #999); }
.fv-facts-muted { color: var(--text-tertiary, #bbb); }
.fv-facts-state-chip {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 600;
  background: var(--bg-cream, #faf8f5);
  color: var(--text-secondary, #6b6b6b);
  border-radius: 4px;
  text-transform: uppercase;
}
.fv-facts-cell-actions { white-space: nowrap; }
.fv-facts-btn {
  display: inline-block;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  border-radius: 6px;
  border: 1px solid var(--border-light, #e5e2dc);
  background: var(--bg-white, #fff);
  color: var(--text-primary, #1a1a1a);
  cursor: pointer;
  margin-right: 4px;
  margin-bottom: 4px;
}
.fv-facts-btn:hover { background: var(--bg-cream, #faf8f5); }
.fv-facts-btn-apply {
  background: var(--accent, #0d9488);
  color: #fff;
  border-color: var(--accent, #0d9488);
}
.fv-facts-btn-apply:hover { background: #0f766e; }
.fv-facts-btn-dismiss { color: #991b1b; border-color: #fecaca; }
.fv-facts-btn:disabled { opacity: 0.6; cursor: wait; }

/* Telemetry — Validations detail tables */
.vtel-section { font-family: 'Plus Jakarta Sans', -apple-system, sans-serif; }
.vtel-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary, #6b6b6b);
  margin-bottom: 6px;
}
.vtel-summary-table, .vtel-output-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  background: #fff;
  border: 1px solid var(--border-light, #e5e2dc);
  border-radius: 6px;
  overflow: hidden;
}
.vtel-summary-table td { padding: 6px 10px; border-bottom: 1px solid var(--border-light, #e5e2dc); }
.vtel-summary-table tr:last-child td { border-bottom: 0; }
.vtel-sum-k { color: var(--text-secondary, #6b6b6b); width: 40%; font-weight: 600; }
.vtel-sum-v { color: var(--text-primary, #1a1a1a); font-family: 'SF Mono', ui-monospace, monospace; font-size: 11.5px; }
.vtel-output-table th {
  text-align: left;
  padding: 8px 10px;
  background: var(--bg-cream, #faf8f5);
  border-bottom: 2px solid var(--border-light, #e5e2dc);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-secondary, #6b6b6b);
  text-transform: uppercase;
}
.vtel-output-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-light, #e5e2dc);
  vertical-align: top;
  line-height: 1.4;
}
.vtel-output-table tr:last-child td { border-bottom: 0; }

/* Validate button states */
.artifact-validate-btn {
  transition: color 0.2s ease;
}

.artifact-validate-btn.validating {
  animation: pulse-validate 1.5s ease-in-out infinite;
  color: var(--accent-coral, #c9977a);
}

.artifact-validate-btn.validated {
  color: #22c55e;
}

@keyframes pulse-validate {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Validated tab highlight */
.artifact-tab[data-tab="validated"] {
  color: #22c55e;
}

/* Badge validated indicator */
.artifact-type-badge.validated::after {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  margin-left: 6px;
  display: inline-block;
  vertical-align: middle;
}


/* ════════════════════════════════════════════════════════════════════════
 * Chat search modal
 * Triggered from the sidebar "Search chats" button or ⌘K. Overlays the
 * entire app with a centred card containing a live-filtering list of
 * all chats. Keyboard nav: ↑/↓ to move, ↵ to open, esc to close.
 * ════════════════════════════════════════════════════════════════════════ */

/* Small kbd pill shown after the "Search chats" label */
.sidebar-action-kbd {
  margin-left: auto;
  font-family: 'Monaco', 'Menlo', ui-monospace, monospace;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(26, 15, 5, 0.05);
  color: var(--text-tertiary);
  border: 1px solid rgba(26, 15, 5, 0.07);
  line-height: 1;
}

.left-sidebar.collapsed .sidebar-action-kbd {
  display: none;
}

/* Backdrop — dims the app and centers the modal */
.chat-search-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 15, 5, 0.22);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 14vh;
  animation: chatSearchFadeIn 0.18s ease-out;
}

.chat-search-modal-backdrop.hidden {
  display: none;
}

@keyframes chatSearchFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.chat-search-modal {
  width: 640px;
  max-width: calc(100vw - 40px);
  background: var(--bg-white);
  border-radius: 14px;
  box-shadow: 0 20px 60px -10px rgba(26, 15, 5, 0.22),
              0 6px 18px rgba(26, 15, 5, 0.08);
  border: 1px solid rgba(26, 15, 5, 0.06);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 72vh;
  animation: chatSearchSlideIn 0.22s cubic-bezier(0.2, 0.9, 0.25, 1);
}

@keyframes chatSearchSlideIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header: search icon + input + close button */
.chat-search-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
}

.chat-search-icon {
  width: 18px;
  height: 18px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.chat-search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 16px;
  color: var(--text-primary);
  padding: 4px 0;
}

.chat-search-input::placeholder {
  color: var(--text-tertiary);
  font-weight: 400;
}

.chat-search-close {
  background: none;
  border: none;
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-tertiary);
  transition: background 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-search-close svg {
  width: 16px;
  height: 16px;
}

.chat-search-close:hover {
  background: rgba(26, 15, 5, 0.05);
  color: var(--text-primary);
}

/* Results list — scrollable */
.chat-search-results {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
  min-height: 80px;
}

.chat-search-section-label {
  font-family: 'Monaco', 'Menlo', ui-monospace, monospace;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-tertiary);
  padding: 8px 18px 4px;
}

.chat-search-result {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  cursor: pointer;
  transition: background 0.1s;
  position: relative;
}

.chat-search-result:hover,
.chat-search-result.selected {
  background: var(--bg-cream, #f4f5f7);
}

.chat-search-result-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-search-result-icon svg {
  width: 16px;
  height: 16px;
}

.chat-search-result-title {
  flex: 1;
  font-size: 14px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 400;
}

.chat-search-result-meta {
  font-size: 12px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

/* Return arrow — appears on the selected row */
.chat-search-result-enter {
  opacity: 0;
  font-family: 'Monaco', 'Menlo', ui-monospace, monospace;
  font-size: 13px;
  color: var(--text-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(26, 15, 5, 0.05);
  transition: opacity 0.12s;
}

.chat-search-result.selected .chat-search-result-enter {
  opacity: 1;
}

/* Highlighted match term in titles */
.chat-search-match {
  background: rgba(192, 139, 92, 0.22);
  color: var(--text-primary);
  font-weight: 600;
  border-radius: 2px;
  padding: 1px 0;
}

/* Empty state */
.chat-search-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-tertiary);
  font-family: 'EB Garamond', Georgia, serif;
  font-style: italic;
  font-size: 15px;
}

/* Footer hints */
.chat-search-footer {
  display: flex;
  gap: 18px;
  padding: 10px 18px;
  border-top: 1px solid var(--border-light);
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: #fafaf8;
}

.chat-search-footer kbd {
  font-family: 'Monaco', 'Menlo', ui-monospace, monospace;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--bg-white);
  border: 1px solid rgba(26, 15, 5, 0.08);
  color: var(--text-secondary);
  margin-right: 4px;
}

/* ══════════════════════════════════════════════════════════════════════
 * Settings: no italics anywhere on this page. Per-page override that
 * clears font-style on every settings surface — tab text, titles,
 * card names, descriptions, capability bullets, input placeholders,
 * etc. Scoped to .settings-page so other pages (artifacts cards,
 * inbox article cards, dashboard captions) keep their italics.
 * ════════════════════════════════════════════════════════════════════ */
.settings-page,
.settings-page *,
.settings-page *::placeholder,
.settings-page *::before,
.settings-page *::after { font-style: normal; }

/* ══════════════════════════════════════════════════════════════════════
 * My Files (Library) page. Reuses `.artifacts-page` for the outer
 * frame; adds a top-level Uploads / Artifacts switch and a file-row
 * list layout for uploads.
 * ════════════════════════════════════════════════════════════════════ */
#libraryPage .library-tab {
  padding: 0;
  margin: 0;
  background: transparent;
  border: 0;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: color 0.15s ease;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  position: relative;
}
#libraryPage .library-tab + .library-tab {
  margin-left: 28px;
  padding-left: 28px;
}
#libraryPage .library-tab + .library-tab::before {
  content: '/';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-55%);
  color: rgba(26, 15, 5, 0.18);
  font-weight: 400;
}
#libraryPage .library-tab:hover { color: var(--text-primary); }
#libraryPage .library-tab.active { color: var(--text-primary); }
#libraryPage .library-tab.active::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  bottom: -23px;
  height: 2px;
  background: var(--brand-gradient-rule);
  border-radius: 2px;
}
#libraryPage .library-tab + .library-tab.active::after { left: 28px; }

#libraryPage .library-sub-tabs { margin-top: 10px; margin-bottom: 28px; }

.library-pane { width: 100%; }
.library-pane.hidden { display: none; }

.library-loading,
.library-error {
  padding: 22px 10px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.library-error { color: #b03a2e; }

/* Card download overlay — appears on hover on each artifact/file card.
 * Matches the muted catalogue aesthetic: tiny, top-right, fades in. */
.artifact-card-download {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: rgba(255, 253, 249, 0.94);
  color: var(--text-secondary, #5a5040);
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.18s ease, transform 0.18s ease, background 0.12s ease, color 0.12s ease;
  text-decoration: none;
  box-shadow: 0 1px 4px rgba(26, 15, 5, 0.08), 0 0 0 1px rgba(26, 15, 5, 0.06);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.artifact-card:hover .artifact-card-download,
.artifact-card:focus-within .artifact-card-download {
  opacity: 1;
  transform: translateY(0);
}
.artifact-card-download:hover {
  background: var(--accent, #1a0f05);
  color: #fffdf9;
}

/* File-type plates for uploaded files (non-image): big serif ext label. */
.library-file-plate-ext {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(26,15,5,0.025), rgba(26,15,5,0.07));
  color: var(--text-tertiary, #8a7f6d);
  font-family: 'Playfair Display', 'Source Serif Pro', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: 48px;
  letter-spacing: 0.04em;
  user-select: none;
}
.library-file-plate-ext span { opacity: 0.72; }

.library-file-plate-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* File-card size uses the same mono/italic meta styling as the chat
 * label on artifact cards, but without the `FROM` prefix. */
.library-file-size {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  text-transform: uppercase;
  font-style: normal;
}

/* ══════════════════════════════════════════════════════════════════════
 * CREDITS TAB
 * ══════════════════════════════════════════════════════════════════════ */

.credits-page {
  display: flex;
  flex-direction: column;
  gap: 40px;
  max-width: 840px;
}

/* ── Section wrapper ─────────────────────────────────────────────────── */
.credits-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.credits-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.credits-section-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.01em;
}

/* ── Credit pill ─────────────────────────────────────────────────────── */
.credits-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  border-radius: 100px;
  border: 1px solid transparent;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.credits-pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.credits-pill--ok {
  background: #eefaf4;
  border-color: #9ee4be;
  color: #1a7a47;
}
.credits-pill--ok .credits-pill-dot { background: #2db870; }

.credits-pill--warn {
  background: #fff8ec;
  border-color: #f5d98b;
  color: #8a5a00;
}
.credits-pill--warn .credits-pill-dot { background: #f0a500; }

.credits-pill--danger {
  background: #fff2f2;
  border-color: #f5aaaa;
  color: #8a1a1a;
}
.credits-pill--danger .credits-pill-dot { background: #e03030; }

/* ── Stats grid ──────────────────────────────────────────────────────── */
.credits-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.credits-stat-card {
  background: var(--bg-cream);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.credits-stat-value {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.credits-stat-value--muted { color: var(--text-tertiary); }

.credits-stat-value--small {
  font-size: 13px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 500;
  letter-spacing: 0;
}

.credits-stat-label {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* ── Progress bar ────────────────────────────────────────────────────── */
.credits-bar-wrap { display: flex; flex-direction: column; gap: 6px; }

.credits-bar-track {
  position: relative;
  height: 6px;
  background: var(--border-light);
  border-radius: 100px;
  overflow: hidden;
  display: flex;
}

.credits-bar-fill {
  height: 100%;
  background: var(--text-primary);
  border-radius: 100px 0 0 100px;
  transition: width 0.5s ease;
}

.credits-bar-reserved {
  height: 100%;
  background: var(--text-tertiary);
  transition: width 0.5s ease;
}

.credits-bar-labels {
  display: flex;
  justify-content: space-between;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 11px;
  color: var(--text-tertiary);
}

/* ── Tier badge ──────────────────────────────────────────────────────── */
.credits-tier-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  background: var(--bg-cream);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
}

.credits-tier-badge--pro {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #3730a3;
}
.credits-tier-badge--team {
  background: #fdf4ff;
  border-color: #e9d5ff;
  color: #6b21a8;
}
.credits-tier-badge--free {
  background: var(--bg-cream);
  color: var(--text-secondary);
}

/* ── Limits grid ─────────────────────────────────────────────────────── */
.credits-limits-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  overflow: hidden;
}

.credits-limit-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13px;
}
.credits-limit-row:last-child { border-bottom: none; }

.credits-limit-label { color: var(--text-secondary); }
.credits-limit-value {
  color: var(--text-primary);
  font-weight: 500;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
}

.credits-limits-loading {
  padding: 20px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13px;
  color: var(--text-tertiary);
}

/* ── Transactions list ───────────────────────────────────────────────── */
.credits-txn-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  overflow: hidden;
}

.credits-txn-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
  gap: 12px;
}
.credits-txn-row:last-child { border-bottom: none; }
.credits-txn-row:hover { background: var(--bg-cream); }

.credits-txn-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.credits-txn-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

.credits-txn-type {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--bg-cream);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}
.credits-txn-type--debit { background: #fff2f2; border-color: #f5c6c6; color: #8a1a1a; }
.credits-txn-type--grant { background: #eefaf4; border-color: #9ee4be; color: #1a7a47; }
.credits-txn-type--refund { background: #eef2ff; border-color: #c7d2fe; color: #3730a3; }
.credits-txn-type--reserve { background: #fff8ec; border-color: #f5d98b; color: #8a5a00; }

.credits-txn-model {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.credits-txn-amount {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 13px;
  font-weight: 600;
  min-width: 60px;
  text-align: right;
}
.credits-txn-amount--debit { color: var(--text-primary); }
.credits-txn-amount--credit { color: #1a7a47; }

.credits-txn-balance {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  color: var(--text-tertiary);
  min-width: 72px;
  text-align: right;
}

.credits-txn-time {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 11px;
  color: var(--text-tertiary);
  min-width: 48px;
  text-align: right;
}

.credits-txn-empty {
  padding: 24px;
  text-align: center;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13px;
  color: var(--text-tertiary);
}

/* ── Refresh button ──────────────────────────────────────────────────── */
.credits-refresh-btn {
  background: none;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 4px 10px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.credits-refresh-btn:hover { border-color: var(--text-tertiary); color: var(--text-primary); }

/* ── Config note ─────────────────────────────────────────────────────── */
.credits-config-note {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 11px;
  color: var(--text-tertiary);
}

/* ── Model rates table ───────────────────────────────────────────────── */
.credits-config-table-wrap {
  border: 1px solid var(--border-light);
  border-radius: 10px;
  overflow: hidden;
}

.credits-config-table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13px;
}

.credits-config-table thead th {
  background: var(--bg-cream);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  border-bottom: 1px solid var(--border-light);
}

.credits-config-th--right { text-align: right; }

.credits-config-table tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background 0.1s;
}
.credits-config-table tbody tr:last-child { border-bottom: none; }
.credits-config-table tbody tr:hover { background: var(--bg-cream); }

.credits-config-table tbody td { padding: 10px 14px; color: var(--text-primary); }

.credits-config-model {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
}

.credits-config-num {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  text-align: right;
  color: var(--text-primary);
}

.credits-config-tier {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--bg-cream);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}
.credits-config-tier--basic { background: #f0fdf4; border-color: #86efac; color: #166534; }
.credits-config-tier--standard { background: #eff6ff; border-color: #93c5fd; color: #1e40af; }
.credits-config-tier--premium { background: #fdf4ff; border-color: #d8b4fe; color: #6b21a8; }

/* ── Admin: all-users credits table ───────────────────────────────────── */
.credits-admin-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}
.credits-admin-input {
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  background: var(--surface-primary);
  color: var(--text-primary);
}
.credits-admin-summary {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}
.credits-admin-wrap { overflow-x: auto; }
.credits-admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.credits-admin-table th,
.credits-admin-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-primary);
  text-align: left;
  vertical-align: middle;
}
.credits-admin-table th {
  font-weight: 600;
  font-size: 12px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.credits-admin-num { text-align: right; font-variant-numeric: tabular-nums; }
.credits-admin-num--muted { color: var(--text-tertiary); }
.credits-admin-uid {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.credits-admin-bar {
  width: 100px;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-secondary, #eee);
  overflow: hidden;
  margin-left: auto;
}
.credits-admin-bar-fill { height: 100%; }
.credits-admin-bar-fill.credits-pill--ok { background: #10b981; }
.credits-admin-bar-fill.credits-pill--warn { background: #f59e0b; }
.credits-admin-bar-fill.credits-pill--danger { background: #ef4444; }
.credits-admin-bar-label {
  font-size: 11px;
  color: var(--text-tertiary);
  text-align: right;
}
/* Tier badge becomes a <select> in the admin table — keep the pill look
   but make it obvious it's clickable + disabled state clear. */
.credits-admin-tier-select {
  font-family: inherit;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 2px 22px 2px 8px;
  cursor: pointer;
  border-radius: 4px;
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(-45deg, transparent 50%, currentColor 50%);
  background-position: calc(100% - 10px) 50%, calc(100% - 6px) 50%;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}
.credits-admin-tier-select:hover { filter: brightness(0.96); }
.credits-admin-tier-select:disabled { opacity: 0.5; cursor: wait; }

.credits-admin-grant-btn {
  padding: 4px 10px;
  font-size: 12px;
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  background: var(--surface-primary);
  color: var(--text-primary);
  cursor: pointer;
}
.credits-admin-grant-btn:hover {
  border-color: var(--text-tertiary);
  background: var(--surface-secondary);
}

/* ── Telemetry page (admin debugging view) ────────────────────────────── */
.telemetry-page {
  padding: 24px 32px;
  overflow-y: auto;
  height: 100%;
  box-sizing: border-box;
}
/* ── Nexus Solve Log viewer (admin dev tool) ── */
.nexus-logs-page {
  padding: 24px 32px;
  height: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Password gate overlay — covers the whole tab until unlocked. */
.nexus-log-gate {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-primary, #0b0f14);
}
.nexus-log-gate.hidden { display: none; }
.nexus-log-gate-card {
  width: min(360px, 90%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 28px;
  border: 1px solid var(--border-primary);
  border-radius: 12px;
  background: var(--surface-secondary, #12181f);
}
.nexus-log-gate-title { margin: 0; font-size: 18px; color: var(--text-primary); }
.nexus-log-gate-dek { margin: 0; font-size: 13px; color: var(--text-tertiary); }
.nexus-log-gate-err { min-height: 16px; font-size: 12.5px; color: #ff8a8a; }
.nexus-log-gate .telemetry-refresh-btn { align-self: flex-start; }
.nexus-log-body {
  flex: 1 1 auto;
  margin: 12px 0 0;
  padding: 14px 16px;
  overflow-y: auto;
  background: #0b0f14;
  color: #d7e0ea;
  border: 1px solid #1d2733;
  border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.nexus-log-line {
  white-space: pre-wrap;
  word-break: break-word;
  padding: 1px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}
.nexus-log-err { color: #ff8a8a; }
.telemetry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.telemetry-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.telemetry-input {
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  background: var(--surface-primary);
  color: var(--text-primary);
  min-width: 140px;
}
.telemetry-input--wide { min-width: 260px; }
.telemetry-refresh-btn {
  padding: 6px 12px;
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  background: var(--surface-primary);
  color: var(--text-primary);
  cursor: pointer;
}
.telemetry-refresh-btn:hover { border-color: var(--text-tertiary); }
.telemetry-auto-refresh {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-tertiary);
}
.telemetry-summary {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}
.telemetry-body { margin-bottom: 12px; }
.telemetry-empty {
  padding: 32px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 14px;
  border: 1px dashed var(--border-primary);
  border-radius: 8px;
}
.telemetry-table-wrap {
  border: 1px solid var(--border-primary);
  border-radius: 8px;
  overflow: auto;
  max-height: calc(100vh - 240px);
  -webkit-overflow-scrolling: touch;
}
.telemetry-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: auto;
}
.telemetry-table th,
.telemetry-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-primary);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}
.telemetry-table td .telemetry-cell-snippet,
.telemetry-table td .telemetry-cell-text {
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.telemetry-table th {
  position: sticky;
  top: 0;
  background: var(--bg-cream);
  font-weight: 600;
  font-size: 12px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  z-index: 1;
  cursor: grab;
  user-select: none;
  min-width: 96px;
}
.telemetry-table th.telemetry-th-dragging {
  opacity: 0.55;
}
.telemetry-table th.telemetry-th-drop-before {
  box-shadow: inset 3px 0 0 var(--accent-coral, #c4917b);
}
.telemetry-table th.telemetry-th-drop-after {
  box-shadow: inset -3px 0 0 var(--accent-coral, #c4917b);
}
.telemetry-table th .telemetry-th-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.telemetry-table th .telemetry-th-grip {
  opacity: 0.35;
  font-size: 10px;
  letter-spacing: -1px;
}
.telemetry-col-order-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.telemetry-col-order-hint button {
  padding: 3px 8px;
  font-size: 11px;
  background: var(--bg-white);
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-secondary);
}
.telemetry-col-order-hint button:hover {
  border-color: var(--text-tertiary);
  color: var(--text-primary);
}

/* Session filter banner — shown when telemetry is pinned to a chat_id */
.telemetry-session-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  margin-bottom: 10px;
  background: rgba(196, 145, 123, 0.08);
  border: 1px solid rgba(196, 145, 123, 0.25);
  border-radius: 8px;
  font-size: 13px;
}
.telemetry-session-banner code {
  font-size: 12px;
  padding: 2px 6px;
  background: var(--bg-white);
  border-radius: 4px;
  border: 1px solid var(--border-primary);
}
.telemetry-session-clear {
  padding: 4px 10px;
  font-size: 12px;
  background: var(--bg-white);
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  cursor: pointer;
}
.telemetry-session-clear:hover {
  background: var(--bg-panel);
}
.telemetry-session-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Clickable session id → filter to that chat */
.telemetry-chat-link {
  color: var(--accent-coral);
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
  cursor: pointer;
}
.telemetry-chat-link:hover { opacity: 0.75; }

/* Internal-search detail card */
.telemetry-search-card {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  background: var(--bg-panel, #fafafa);
}
.telemetry-search-meta {
  font-size: 12px;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* ── Replay tab — captured prompt/response per model call ───────── */
.telemetry-replay { display: flex; flex-direction: column; gap: 16px; }
.telemetry-replay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--surface-secondary, #f6f6f4);
  border: 1px solid var(--border-primary, #e2e2dd);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-primary, #f7f7f7);
}
.telemetry-replay-turn {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.telemetry-replay-turn-head {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary, #8a8a85);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-subtle, #ececea);
}
.telemetry-replay-card {
  border: 1px solid var(--border-primary, #e2e2dd);
  border-radius: 6px;
  background: var(--surface-primary, #fff);
  overflow: hidden;
}
.telemetry-replay-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--surface-secondary, #f9f9f6);
  border-bottom: 1px solid var(--border-primary, #e2e2dd);
  gap: 12px;
  flex-wrap: wrap;
}
.telemetry-replay-call-kind {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  background: #e0e7ff;
  color: #3730a3;
  letter-spacing: 0.02em;
  margin-right: 6px;
  text-transform: uppercase;
}
.telemetry-replay-model {
  font-family: var(--font-mono, ui-monospace, Menlo, monospace);
  font-size: 11px;
  color: var(--text-secondary, #555);
  padding: 1px 6px;
  background: var(--surface-tertiary, #fafaf7);
  border-radius: 3px;
  margin-right: 8px;
}
.telemetry-replay-ts {
  font-size: 11px;
  color: var(--text-tertiary, #999);
  font-variant-numeric: tabular-nums;
}
.telemetry-replay-card-meta {
  font-size: 11px;
  color: var(--text-tertiary, #999);
  font-family: var(--font-mono, ui-monospace, Menlo, monospace);
}
.telemetry-replay-system {
  padding: 8px 12px;
  background: var(--surface-tertiary, #fafaf7);
  border-bottom: 1px solid var(--border-subtle, #ececea);
}
.telemetry-replay-system > summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary, #555);
}
.telemetry-replay-system-blocks {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.telemetry-replay-system-block {
  display: inline-block;
  padding: 2px 8px;
  font-family: inherit;
  font-size: 11px;
  background: #fff;
  border: 1px solid var(--border-primary, #e2e2dd);
  border-radius: 10px;
  color: var(--text-primary, #eaeaea);
}
.telemetry-replay-system-block--marker {
  background: #fef3c7;
  border-color: #fcd34d;
  color: #92400e;
  font-family: var(--font-mono, ui-monospace, Menlo, monospace);
}
.telemetry-replay-messages {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.telemetry-replay-message {
  border-left: 3px solid var(--border-subtle, #ececea);
  padding: 8px 10px;
  background: var(--surface-secondary, #fafaf7);
  border-radius: 0 4px 4px 0;
}
.telemetry-replay-message--user { border-left-color: #94a3b8; background: #f8fafc; }
.telemetry-replay-message--assistant { border-left-color: #10b981; background: #f0fdf4; }
.telemetry-replay-message--tool { border-left-color: #fbbf24; background: #fffbeb; }
.telemetry-replay-message-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.telemetry-replay-message-role {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--text-primary, #eaeaea);
}
.telemetry-replay-message-idx {
  font-size: 10.5px;
  color: var(--text-tertiary, #999);
  font-variant-numeric: tabular-nums;
}
.telemetry-replay-message-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.telemetry-replay-block {
  padding: 6px 8px;
  background: #fff;
  border: 1px solid var(--border-subtle, #ececea);
  border-radius: 4px;
}
.telemetry-replay-block--text { background: #fff; }
.telemetry-replay-block--tool-use { background: #fef3c7; border-color: #fcd34d; }
.telemetry-replay-block--tool-result { background: #f5f3ff; border-color: #ddd6fe; }
.telemetry-replay-block--thinking { background: #fafafa; border-color: #e5e5e5; }
.telemetry-replay-block-tag {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary, #8a8a85);
  margin-bottom: 4px;
}
.telemetry-replay-block-id {
  font-family: var(--font-mono, ui-monospace, Menlo, monospace);
  font-size: 10.5px;
  color: var(--text-tertiary, #999);
}
.telemetry-replay-text {
  margin: 0;
  padding: 8px 10px;
  background: var(--surface-primary, #fff);
  border-radius: 3px;
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-primary, #f7f7f7);
  white-space: pre-wrap;
  word-break: break-word;
}
.telemetry-replay-raw {
  margin: 0;
  padding: 8px 10px;
  background: #1f2937;
  color: #e5e7eb;
  border-radius: 3px;
  font-family: var(--font-mono, ui-monospace, Menlo, monospace);
  font-size: 11.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}
.telemetry-replay-empty {
  font-style: italic;
  color: var(--text-tertiary, #999);
  font-size: 12px;
  padding: 6px 0;
}

/* ── Internal Data tab — tabulated per-question view ───────────────── */
.telemetry-internal { display: flex; flex-direction: column; gap: 16px; }
.telemetry-internal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface-secondary, #f6f6f4);
  border: 1px solid var(--border-primary, #e2e2dd);
  border-radius: 6px;
}
.telemetry-internal-header-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary, #f7f7f7);
}
/* Internal-data questions as TABS (one tab per question) — replaces the
   former vertical stack of all question cards. */
.telemetry-internal-tabs {
  display: flex; flex-wrap: wrap; gap: 6px;
  border-bottom: 1px solid var(--border-primary, #e2e2dd);
  padding-bottom: 8px;
}
.telemetry-internal-tab {
  flex: 0 0 auto; max-width: 240px;
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border-primary, #e2e2dd);
  background: var(--surface-secondary, #f6f6f4);
  color: var(--text-secondary, #6b6b66);
  font-size: 12px; font-weight: 600;
  padding: 6px 11px; border-radius: 7px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background .15s, color .15s, border-color .15s;
}
.telemetry-internal-tab:hover { color: var(--text-primary, #f7f7f7); border-color: var(--border-strong, #cfcfc8); }
.telemetry-internal-tab.is-active {
  background: var(--text-primary, #f7f7f7);
  border-color: var(--text-primary, #f7f7f7);
  color: var(--surface-primary, #fff);
}
.telemetry-internal-tab .tit-qn { opacity: .65; font-variant-numeric: tabular-nums; }
.telemetry-internal-tab.is-active .tit-qn { opacity: .8; }
.telemetry-internal-card {
  border: 1px solid var(--border-primary, #e2e2dd);
  border-radius: 6px;
  background: var(--surface-primary, #fff);
  overflow: hidden;
  display: none;                 /* tabbed — only the active question's card shows */
}
.telemetry-internal-card.is-active { display: block; }
.telemetry-internal-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface-secondary, #f9f9f6);
  border-bottom: 1px solid var(--border-primary, #e2e2dd);
}
.telemetry-internal-card-headline {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-primary, #f7f7f7);
  word-break: break-word;
}
.telemetry-internal-card-meta {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--text-secondary, #6b6b66);
  font-variant-numeric: tabular-nums;
}
.telemetry-internal-card-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.telemetry-internal-action {
  background: var(--surface-primary, #fff);
  border: 1px solid var(--border-primary, #d7d7d1);
  color: var(--text-primary, #eaeaea);
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.4;
  transition: background 120ms ease, border-color 120ms ease;
}
.telemetry-internal-action:hover {
  background: var(--surface-secondary, #f4f4f0);
  border-color: var(--border-strong, #b9b9b3);
}
.telemetry-internal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  table-layout: fixed;
}
.telemetry-internal-col-field { width: 160px; }
.telemetry-internal-table td {
  padding: 10px 12px;
  border-top: 1px solid var(--border-subtle, #ececea);
  vertical-align: top;
  word-break: break-word;
}
.telemetry-internal-table tr:first-child td { border-top: none; }
.telemetry-internal-row-head td {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary, #8a8a85);
  background: var(--surface-tertiary, #fafaf7);
  padding: 6px 12px;
}
.telemetry-internal-field {
  font-family: var(--font-mono, ui-monospace, 'JetBrains Mono', Menlo, monospace);
  font-size: 12px;
  color: var(--text-secondary, #555);
  white-space: nowrap;
}
.telemetry-internal-text {
  margin: 0;
  padding: 8px 10px;
  background: var(--surface-secondary, #fafaf7);
  border: 1px solid var(--border-subtle, #ececea);
  border-radius: 4px;
  font-family: var(--font-mono, ui-monospace, Menlo, monospace);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-primary, #f7f7f7);
}
.telemetry-internal-raw {
  margin: 0;
  padding: 8px 10px;
  background: #1f2937;
  border-radius: 4px;
  color: #e5e7eb;
  font-family: var(--font-mono, ui-monospace, Menlo, monospace);
  font-size: 11.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}
.telemetry-internal-empty {
  font-style: italic;
  color: var(--text-tertiary, #aaa);
  font-size: 12px;
}
.telemetry-internal-list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: telemetry-internal-li;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.telemetry-internal-list-item {
  counter-increment: telemetry-internal-li;
  border: 1px solid var(--border-subtle, #ececea);
  border-radius: 4px;
  background: var(--surface-secondary, #fafaf7);
  padding: 8px 10px 10px 36px;
  position: relative;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-primary, #f7f7f7);
}
.telemetry-internal-list-item::before {
  content: counter(telemetry-internal-li);
  position: absolute;
  top: 8px;
  left: 10px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft, #e2e8f0);
  color: var(--text-primary, #334155);
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.telemetry-internal-list-meta {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary, #8a8a85);
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}
.telemetry-internal-list-body {
  white-space: pre-wrap;
  word-break: break-word;
}
.telemetry-row { cursor: pointer; }
.telemetry-row:hover { background: var(--surface-secondary, rgba(0,0,0,0.03)); }
.telemetry-row-expand > td {
  background: var(--surface-secondary, #f8f8f8);
  border-bottom: 2px solid var(--border-primary);
}
.telemetry-ts { white-space: nowrap; color: var(--text-tertiary); font-variant-numeric: tabular-nums; }

.telemetry-modal-tabs { display: flex; border-bottom: 1px solid var(--border-light); background: var(--surface-secondary); }
.telemetry-tab-btn { background: none; border: none; border-bottom: 2px solid transparent; padding: 12px 16px; cursor: pointer; color: var(--text-secondary); font-size: 14px; font-weight: 500; }
.telemetry-tab-btn:hover { color: var(--text-primary); }
.telemetry-tab-btn.active { color: var(--accent-coral); border-bottom-color: var(--accent-coral); }
.telemetry-modal-pane { display: flex; flex-direction: column; gap: 16px; }

.telemetry-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 10000; display: flex; align-items: center; justify-content: center; }
.telemetry-overlay.hidden { display: none; }
.telemetry-overlay-backdrop { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4); backdrop-filter: blur(2px); }
.telemetry-overlay-panel { position: relative; background: var(--bg-cream); border-radius: 12px; width: 900px; max-width: 95vw; height: 85vh; display: flex; flex-direction: column; box-shadow: 0 12px 40px rgba(0,0,0,0.15); overflow: hidden; }
.telemetry-overlay-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border-light); }
.telemetry-overlay-title { font-size: 18px; font-weight: 600; margin: 0; color: var(--text-primary); }
.telemetry-overlay-close { background: none; border: none; cursor: pointer; font-size: 20px; color: var(--text-secondary); display: flex; align-items: center; justify-content: center; padding: 4px; border-radius: 4px; }
.telemetry-overlay-close:hover { color: var(--text-primary); background: var(--surface-secondary, rgba(0,0,0,0.05)); }
/* Header-actions row + full-screen toggle for the Turn Details overlay.
   The expand glyph (⤢) flips to ⤡ when the panel is already expanded,
   so the button always shows "the action this will do next". State
   persists in localStorage so a user who prefers full-screen doesn't
   re-click it on every open. */
.telemetry-overlay-header-actions { display: flex; align-items: center; gap: 8px; }
.telemetry-overlay-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--surface-secondary, rgba(0,0,0,0.04));
  border: 1px solid var(--border-light, rgba(0,0,0,0.12));
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.telemetry-overlay-action-btn:hover {
  background: var(--surface-tertiary, rgba(0,0,0,0.07));
  border-color: var(--border-default, rgba(0,0,0,0.18));
}
.telemetry-overlay-action-btn svg {
  flex-shrink: 0;
}
.telemetry-overlay-expand {
  background: none; border: none; cursor: pointer;
  font-size: 18px; line-height: 1;
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  padding: 4px 6px; border-radius: 4px;
}
.telemetry-overlay-expand:hover {
  color: var(--text-primary);
  background: var(--surface-secondary, rgba(0,0,0,0.05));
}
.telemetry-overlay-panel--expanded {
  /* Full viewport — overrides the default 900px / 85vh from the base
     .telemetry-overlay-panel rule. !important because the base rule
     uses unscoped width/height/border-radius properties. */
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100vh !important;
  border-radius: 0 !important;
}

.telemetry-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.telemetry-user-cell span { display: inline-block; max-width: 130px; word-break: break-all; white-space: normal; line-height: 1.2; }
.telemetry-copy-btn { opacity: 0; background: none; border: none; cursor: pointer; color: var(--text-tertiary); display: inline-flex; align-items: center; padding: 2px; border-radius: 4px; transition: all 0.15s; }
.telemetry-copy-btn:hover { background: var(--surface-secondary, rgba(0,0,0,0.05)); color: var(--text-primary); }
.telemetry-user-cell:hover .telemetry-copy-btn { opacity: 1; }
.telemetry-cell-text {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Wrapped in a div inside the <td> — applying -webkit-box directly on a
   <td> breaks table-cell layout and shifts every column to its right. */
.telemetry-cell-snippet {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
  word-break: break-word;
  line-height: 1.35;
  max-width: 280px;
}
.telemetry-cell-err { color: #b91c1c; }
.telemetry-expand-cell { padding: 0 !important; background: var(--surface-secondary, #fafafa); }
.telemetry-detail {
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.telemetry-detail-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-primary);
}
.telemetry-meta-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--surface-primary);
  border: 1px solid var(--border-primary);
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text-primary);
}
.telemetry-meta-time {
  font-size: 12px;
  color: var(--text-tertiary);
}
.telemetry-detail-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.telemetry-detail-h {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.telemetry-detail-pre {
  margin: 0;
  padding: 12px 14px;
  background: var(--surface-primary);
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-primary);
}
.telemetry-detail-pre--code { font-size: 12px; }
.telemetry-detail-md {
  padding: 12px 14px;
  background: var(--surface-primary);
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-primary);
}
.telemetry-detail-md p { margin: 0 0 8px; }
.telemetry-detail-md pre { background: rgba(0,0,0,0.05); padding: 8px 10px; border-radius: 4px; overflow: auto; }
.telemetry-detail-md code { background: rgba(0,0,0,0.05); padding: 1px 4px; border-radius: 3px; font-size: 12px; }
.telemetry-detail-md pre code { background: transparent; padding: 0; }
.telemetry-detail-empty { color: var(--text-tertiary); font-style: italic; padding: 8px 0; }
.telemetry-detail-error .telemetry-detail-pre {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
}
.telemetry-detail-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.telemetry-detail-table th, .telemetry-detail-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-primary);
  text-align: left;
}
.telemetry-events { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow: auto; }
.telemetry-event {
  display: grid;
  grid-template-columns: 100px auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--surface-primary);
  border: 1px solid var(--border-primary);
}
.telemetry-event-kind {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--surface-secondary, #eee);
  color: var(--text-primary);
  text-align: center;
}
.telemetry-event--error .telemetry-event-kind { background: #fee2e2; color: #991b1b; }
.telemetry-event--done  .telemetry-event-kind { background: #d1fae5; color: #065f46; }
.telemetry-event-payload {
  margin: 0;
  padding: 4px 8px;
  font-size: 11px;
  background: rgba(0,0,0,0.04);
  border-radius: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 120px;
  overflow: auto;
  grid-column: 1 / -1;
}
.telemetry-raw-toggle {
  align-self: flex-start;
  padding: 4px 10px;
  border: 1px solid var(--border-primary);
  border-radius: 4px;
  background: var(--surface-primary);
  color: var(--text-tertiary);
  font-size: 12px;
  cursor: pointer;
}
.telemetry-raw-toggle:hover { color: var(--text-primary); }
.telemetry-artifacts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.telemetry-artifacts li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border-primary);
  border-radius: 4px;
  background: var(--surface-primary);
  font-size: 13px;
}
.telemetry-artifacts li.telemetry-artifact-open { cursor: pointer; }
.telemetry-artifacts li.telemetry-artifact-open:hover {
  border-color: var(--text-tertiary);
  background: var(--surface-secondary, #f8f8f8);
}
.telemetry-artifact-link {
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 500;
}
.telemetry-artifact-link:hover { text-decoration: underline; }
.telemetry-artifact-type {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--surface-secondary, #eee);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.telemetry-duration { color: var(--text-tertiary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.telemetry-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.telemetry-pill--ok  { background: #d1fae5; color: #065f46; }
.telemetry-pill--err { background: #fee2e2; color: #991b1b; }
.telemetry-pill--mid { background: #fef3c7; color: #92400e; }
/* Distinct error "cases" surfaced under a FAILURE pill (MoSPI args view).
   Collapsed by default; the summary expands to the full chip set. */
.telemetry-errcases { margin-top: 5px; }
.telemetry-errcases-summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10.5px;
  font-weight: 600;
  color: #991b1b;
}
.telemetry-errcases-summary::-webkit-details-marker { display: none; }
.telemetry-errcases-summary::marker { content: ''; }
.telemetry-errcases-summary:hover { text-decoration: underline; }
.telemetry-errcases-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.telemetry-errcase {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10.5px;
  line-height: 1.45;
  padding: 1px 6px;
  border-radius: 4px;
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  white-space: nowrap;
}
.telemetry-json {
  margin: 0;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 420px;
  overflow: auto;
  color: var(--text-primary);
}

/* ── MCP tab — per-call cards ── */
.mcp-tally-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}
.mcp-tally-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  background: var(--surface-secondary, #fafafa);
  border: 1px solid var(--border-light, #e5e5e5);
  border-radius: 999px;
  font-size: 11.5px;
  color: var(--text-secondary, #555);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.mcp-tally-chip-count {
  background: rgba(120, 120, 120, 0.12);
  border-radius: 999px;
  padding: 1px 6px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-primary, #f7f7f7);
}
.mcp-calls-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.mcp-call-card {
  border: 1px solid var(--border-light, #e5e5e5);
  border-radius: 8px;
  background: var(--surface-primary, #fff);
  overflow: hidden;
}
.mcp-call-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  list-style: none;
  background: var(--surface-secondary, #fafafa);
  border-bottom: 1px solid var(--border-light, #e5e5e5);
}
.mcp-call-summary::-webkit-details-marker { display: none; }
.mcp-call-summary::before {
  content: "▶";
  display: inline-block;
  font-size: 9px;
  color: #9aa0a6;
  margin-right: 2px;
  transform: rotate(0deg);
  transition: transform 0.12s ease;
}
.mcp-call-card[open] > .mcp-call-summary::before { transform: rotate(90deg); }
.mcp-call-idx {
  color: var(--text-tertiary, #999);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  min-width: 28px;
}
.mcp-call-server {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary, #f7f7f7);
}
.mcp-call-arrow {
  color: var(--text-tertiary, #aaa);
  font-size: 12px;
}
.mcp-call-tool {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--text-secondary, #555);
}
.mcp-call-meta {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--text-tertiary, #999);
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  gap: 6px;
}
.mcp-call-status {
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.mcp-call-status--ok { background: #d1fae5; color: #065f46; }
.mcp-call-status--err { background: #fee2e2; color: #991b1b; }
.mcp-call-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.mcp-call-section-h {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary, #999);
  margin-bottom: 6px;
  font-weight: 600;
}
.mcp-call-output-pre {
  margin: 0;
  padding: 10px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surface-secondary, #fafafa);
  border: 1px solid var(--border-light, #e5e5e5);
  border-radius: 6px;
  max-height: 400px;
  overflow: auto;
  color: var(--text-primary, #f7f7f7);
}
.mcp-call-output-empty {
  font-style: italic;
  color: var(--text-tertiary, #aaa);
  padding: 6px 0;
  font-size: 12px;
}
.mcp-call-output-banner {
  font-size: 11px;
  color: #92400e;
  background: #fef3c7;
  padding: 4px 10px;
  border-radius: 4px;
  margin-bottom: 6px;
  display: inline-block;
}

/* ── Steps table: Parameters column ── */
.step-params-details {
  display: block;
}
.step-params-details > .step-params-summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: inline-block;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: top;
}
.step-params-details > .step-params-summary::-webkit-details-marker { display: none; }
.step-params-details > .step-params-summary::before {
  content: "▶";
  display: inline-block;
  font-size: 9px;
  color: #9aa0a6;
  margin-right: 6px;
  transform: rotate(0deg);
  transition: transform 0.12s ease;
  vertical-align: 1px;
}
.step-params-details[open] > .step-params-summary::before { transform: rotate(90deg); }
.step-params-details[open] > .step-params-summary {
  white-space: normal;        /* let summary wrap when expanded */
  max-width: none;
}
.step-params-body {
  margin-top: 6px;
  margin-left: 14px;
  padding: 8px 10px;
  background: var(--surface-secondary, #fafafa);
  border: 1px solid var(--border-light, #e5e5e5);
  border-radius: 4px;
  font-size: 11.5px;
  max-width: 540px;
  overflow: auto;
}

/* ── Pretty JSON tree (Raw JSON tab + formatTelemetryBody JSON branch) ── */
.json-pretty-wrap {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  padding: 10px 14px;
  background: var(--surface-secondary, #fafafa);
  border: 1px solid var(--border-light, #e5e5e5);
  border-radius: 6px;
  max-height: 480px;
  overflow: auto;
  color: var(--text-primary, #f7f7f7);
}
.json-pretty-wrap--full { max-height: none; }

.json-tree {
  display: inline-block;
  vertical-align: top;
}
.json-tree > .json-summary {
  display: inline-block;
  cursor: pointer;
  user-select: none;
  list-style: none;
  margin-left: -14px;       /* pull the disclosure caret into the gutter */
  padding-left: 14px;
}
.json-tree > .json-summary::-webkit-details-marker { display: none; }
.json-tree > .json-summary::before {
  content: "▶";
  display: inline-block;
  font-size: 9px;
  color: #9aa0a6;
  margin-right: 6px;
  transform: rotate(0deg);
  transition: transform 0.12s ease;
  vertical-align: 1px;
}
.json-tree[open] > .json-summary::before { transform: rotate(90deg); }
.json-body {
  margin-left: 14px;
  padding-left: 8px;
  border-left: 1px dashed rgba(120, 120, 120, 0.18);
}
.json-row { display: block; }

.json-key     { color: #0550ae; font-weight: 500; }
.json-string  { color: #0a8f3a; word-break: break-word; }
.json-number  { color: #b45309; font-variant-numeric: tabular-nums; }
.json-bool    { color: #6f42c1; font-weight: 500; }
.json-null    { color: #999;    font-style: italic; }
.json-colon   { color: #555; }
.json-bracket { color: #444; font-weight: 600; }
.json-meta {
  color: #9aa0a6;
  font-size: 11px;
  font-style: italic;
  margin-left: 6px;
}

@media (prefers-color-scheme: dark) {
  .json-pretty-wrap {
    background: rgba(255,255,255,0.02);
    border-color: rgba(255,255,255,0.08);
    color: #e6e6e6;
  }
  .json-key     { color: #79b8ff; }
  .json-string  { color: #85e89d; }
  .json-number  { color: #ffab70; }
  .json-bool    { color: #b392f0; }
  .json-bracket { color: #ddd; }
  .json-colon, .json-meta, .json-null { color: #999; }
  .json-body { border-left-color: rgba(255,255,255,0.1); }
}
.telemetry-pagination {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.telemetry-page-btn {
  padding: 6px 14px;
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  background: var(--surface-primary);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 13px;
}
.telemetry-page-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Responsive collapse at narrow widths ────────────────────────────── */
/* ── Input toolbar: inline credit pill + compact selector pills ─────── */
/* The input-controls strip is dense. These rules make the three
   selector pills (model / style / scope) share one compact shape,
   prefix them with a small leading icon, and add a credit balance
   pill before the model choice. Dropdown menus are unchanged — the
   drawer still carries the existing "Smartest / Balanced / Fastest"
   etc. descriptions. */

.credits-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-light);
  background: var(--bg-white);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
}
.credits-inline:hover {
  border-color: var(--accent-coral, var(--text-tertiary));
  color: var(--text-primary);
}
.credits-inline-icon { width: 13px; height: 13px; flex-shrink: 0; }
.credits-inline-label { font-variant-numeric: tabular-nums; }
.credits-inline--low {
  color: #b45309;
  border-color: #f59e0b;
  background: #fffbeb;
}
.credits-inline--danger {
  color: #991b1b;
  border-color: #ef4444;
  background: #fef2f2;
}
.credits-inline--muted {
  color: var(--text-tertiary, #6b7280);
  border-style: dashed;
  opacity: 0.85;
}
.credits-inline--muted .credits-inline-label { font-style: italic; }

/* Shared shape for model / style / scope buttons in the input toolbar.
   Higher specificity than the earlier block rules so these win. */
.input-controls .model-selector,
.input-controls .style-selector,
.input-controls .scope-selector-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border: 1px solid var(--border-light);
  background: var(--bg-white);
  border-radius: 999px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
  max-width: none;
}
.input-controls .model-selector:hover,
.input-controls .style-selector:hover,
.input-controls .scope-selector-btn:hover {
  border-color: var(--text-tertiary);
  color: var(--text-primary);
}
.input-controls .selector-icon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  stroke: currentColor;
}
.input-controls .selector-chevron {
  width: 11px;
  height: 11px;
  flex-shrink: 0;
  opacity: 0.6;
  stroke: currentColor;
}
.input-controls .scope-selector-btn svg:first-child {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

/* Output mode toggle (Data Explorer / Data & Analysis) in chat composer */
.chat-output-mode {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  background: rgba(17, 19, 24, 0.05);
  border: 1px solid rgba(17, 19, 24, 0.06);
  border-radius: 999px;
  flex-shrink: 0;
  min-width: 76px; /* two icon pills — never shrink below icons */
}
.chat-output-mode-option {
  display: inline-flex;
  align-items: center;
  margin: 0;
  cursor: pointer;
  flex-shrink: 0;
}
.chat-output-mode-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.chat-output-mode-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  color: var(--text-secondary);
  white-space: nowrap;
  transition: color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}
.chat-output-mode-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  stroke: currentColor;
}
.chat-output-mode-option input[type="radio"]:checked + .chat-output-mode-label {
  background: var(--bg-white);
  color: var(--brand-indigo);
  box-shadow: 0 1px 3px rgba(42, 56, 153, 0.10), 0 1px 2px rgba(0, 0, 0, 0.04);
}
.chat-output-mode-option:not(:has(input:checked)):hover .chat-output-mode-label {
  color: var(--text-primary);
}
.chat-output-mode-option input[type="radio"]:focus-visible + .chat-output-mode-label {
  outline: 2px solid rgba(42, 56, 153, 0.35);
  outline-offset: 1px;
}

/* Compact composer (class toggled by ResizeObserver when labels would
   overflow the Reply bar). Prefer text; icons only when they don't fit. */
.input-controls.output-mode-compact .chat-output-mode-label {
  padding: 7px 9px;
  gap: 0;
  font-size: 0; /* hide text nodes; SVG keeps explicit width/height */
}
.input-controls.output-mode-compact .right-controls {
  gap: 10px;
}
.input-controls.output-mode-compact .chat-output-mode-icon {
  width: 14px;
  height: 14px;
}
@media (max-width: 480px) {
  .chat-output-mode-label {
    padding: 7px 9px;
    gap: 0;
    font-size: 0;
  }
  .input-controls .right-controls {
    gap: 10px;
  }
}

/* Model and style stay icon-only — their dropdowns do the explaining.
   Scope keeps its label visible so the current source tier (Gold /
   Government / Full Web etc.) is always readable at a glance. */
.input-controls .model-label,
.input-controls .style-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.input-controls .scope-selector-label {
  display: inline-block;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.input-controls .model-selector,
.input-controls .style-selector {
  padding: 5px 7px;
  gap: 3px;
}

.input-controls .selector-icon {
  width: 14px;
  height: 14px;
}

@media (max-width: 680px) {
  .credits-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .credits-txn-balance { display: none; }
  .telemetry-controls { width: 100%; }
  .telemetry-input { min-width: 0; flex: 1 1 140px; }
  .input-controls .model-label,
  .input-controls .style-label,
  .input-controls .scope-selector-label { max-width: 64px; }
}


/* ========================================================================
   Design Canvas v2 (swarm-design branch) — overlay + status chip + pane.
   Overlay floats above the artifact canvas; status chip lives inline in
   the header actions; #artifactRedesignPane hosts the result alongside
   the existing Preview / Code / Validated panes.
   ========================================================================= */

/* Overlay backdrop + modal shell. Body-level so it escapes any aside
   clipping; fades in on .open. Shell adopts the same glassmorphic
   language as the precision-edit dialog (.region-edit-dialog) so the
   two surfaces feel like one design system. */
.dc-overlay-backdrop {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(10, 14, 22, 0.35);
  backdrop-filter: blur(4px);
  display: none; align-items: flex-start; justify-content: center;
  padding: 7vh 20px;
  color-scheme: light;
}
.dc-overlay-backdrop.open { display: flex; }
.dc-overlay-shell {
  width: 620px; max-width: 94vw; max-height: 86vh;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  color: var(--text-primary, #111318);
  border-radius: 14px; overflow: hidden;
  display: flex; flex-direction: column;
  border: 1px solid rgba(17, 19, 24, 0.08);
  box-shadow: 0 18px 48px -12px rgba(17, 19, 24, 0.22),
              0 2px 8px rgba(17, 19, 24, 0.04);
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 13px;
}
.dc-overlay-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border-light, #e2e4e9);
}
.dc-overlay-head h3 { margin: 0; font: 600 14px/1.3 inherit; letter-spacing: -0.01em; color: var(--text-primary, #111318); }
.dc-overlay-close {
  background: transparent; border: 0; color: var(--text-tertiary, #8b8e96);
  width: 28px; height: 28px; border-radius: 6px;
  cursor: pointer; font-size: 20px; line-height: 1; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.12s, color 0.12s;
}
.dc-overlay-close:hover { background: var(--bg-cream, #f4f5f7); color: var(--text-primary, #111318); }
.dc-overlay-body {
  padding: 14px 18px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
}
.dc-overlay-foot {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 12px 18px; border-top: 1px solid var(--border-light, #e2e4e9);
}

/* Shared form primitives adopted from the precision-edit dialog. */
.dc-label {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-tertiary, #8b8e96);
  margin-top: 6px;
}
.dc-textarea {
  width: 100%; min-height: 80px; resize: vertical;
  background: var(--bg-white, #fff);
  color: var(--text-primary, #111318);
  border: 1px solid var(--border-light, #e2e4e9);
  border-radius: 10px;
  padding: 10px 12px;
  font: 13px/1.45 'Plus Jakarta Sans', system-ui, sans-serif;
  box-sizing: border-box;
  box-shadow: var(--shadow-soft, 0 2px 8px rgba(0,0,0,0.06));
  transition: border-color 0.12s, box-shadow 0.12s;
}
.dc-textarea::placeholder { color: var(--text-tertiary, #8b8e96); }
.dc-textarea:focus {
  outline: none;
  border-color: var(--accent-coral, #c08b5c);
  box-shadow: 0 0 0 3px rgba(192, 139, 92, 0.12), var(--shadow-soft, 0 2px 8px rgba(0,0,0,0.06));
}
.dc-select {
  width: 100%;
  background: var(--bg-white, #fff);
  color: var(--text-primary, #111318);
  border: 1px solid var(--border-light, #e2e4e9);
  border-radius: 10px;
  padding: 8px 10px;
  font: 13px/1.3 'Plus Jakarta Sans', system-ui, sans-serif;
  min-width: 0;
  box-shadow: var(--shadow-soft, 0 2px 8px rgba(0,0,0,0.06));
  transition: border-color 0.12s, box-shadow 0.12s;
}
.dc-select:focus {
  outline: none;
  border-color: var(--accent-coral, #c08b5c);
  box-shadow: 0 0 0 3px rgba(192, 139, 92, 0.12), var(--shadow-soft, 0 2px 8px rgba(0,0,0,0.06));
}
.dc-select optgroup { color: var(--text-tertiary, #8b8e96); font-weight: 600; background: #fff; }
.dc-select option { color: var(--text-primary, #111318); background: #fff; font-weight: 400; }
.dc-row-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; margin-top: 4px; }
.dc-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.dc-field .dc-label { margin-top: 0; }
.dc-dropzone {
  border: 1px dashed rgba(17,19,24,0.14);
  border-radius: 10px; padding: 14px; text-align: center;
  background: rgba(17,19,24,0.02);
  transition: background .15s, border-color .15s;
}
.dc-dropzone.dc-dz-over { border-color: var(--accent-coral, #c08b5c); background: rgba(192,139,92,0.08); }
.dc-dz-hint { font-size: 12px; color: var(--text-secondary, #5c5f66); }
.dc-link {
  background: none; border: 0; cursor: pointer; padding: 0;
  color: var(--accent-coral, #c08b5c); text-decoration: underline;
  font: inherit;
}
.dc-tpl-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px;
  background: rgba(192, 139, 92, 0.10);
  border: 1px solid rgba(192, 139, 92, 0.18);
}
.dc-tpl-meta { flex: 1; text-align: left; }
.dc-tpl-name { font-size: 13px; font-weight: 500; color: var(--text-primary, #111318); }
.dc-tpl-sub { font-size: 11px; color: var(--text-tertiary, #8b8e96); }
.dc-tpl-remove {
  background: transparent; border: 0; cursor: pointer;
  color: var(--text-tertiary, #8b8e96);
  font-size: 18px; line-height: 1; padding: 4px 6px; border-radius: 6px;
}
.dc-tpl-remove:hover { background: var(--bg-cream, #f4f5f7); color: var(--text-primary, #111318); }
.dc-saved-templates { margin-top: 4px; font-size: 12px; color: var(--text-secondary, #5c5f66); }
.dc-saved-templates summary { cursor: pointer; padding: 4px 0; user-select: none; }
.dc-saved-templates ul { list-style: none; padding: 2px 0 0; margin: 0; display: flex; flex-direction: column; gap: 2px; }
.dc-saved-templates li { display: flex; align-items: baseline; gap: 6px; }
.dc-saved-pick { font-size: 12px; color: var(--accent-coral, #c08b5c); text-align: left; flex: 1; }
.dc-btn {
  padding: 8px 16px; border-radius: 8px; border: 0; cursor: pointer;
  background: transparent; color: var(--text-secondary, #5c5f66);
  font: 600 12px/1 'Plus Jakarta Sans', system-ui, sans-serif;
  transition: background 0.12s, color 0.12s, opacity 0.12s;
}
.dc-btn:hover:not(:disabled) { background: var(--bg-cream, #f4f5f7); color: var(--text-primary, #111318); }
.dc-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.dc-btn-primary {
  background: var(--accent-coral, #c08b5c); color: #fff;
}
.dc-btn-primary:hover:not(:disabled) { background: var(--accent-coral-dark, #a87644); }
.dc-btn-apply {
  background: var(--accent-coral, #c08b5c); color: #fff;
}
.dc-btn-apply:hover:not(:disabled) { background: var(--accent-coral-dark, #a87644); }

/* Status chip lives in the artifact canvas header next to the Redesign icon.
   Collapsed by default; .open animates in with a subtle progress fill. */
.dc-status-chip {
  display: none; align-items: center; gap: 8px;
  padding: 0 12px; height: 30px;
  border-radius: 999px;
  background: rgba(15,23,42,0.85); color: #e2e8f0;
  border: 1px solid rgba(148,163,184,0.25);
  font: 500 12px/1 'Plus Jakarta Sans', system-ui, sans-serif;
  cursor: pointer; user-select: none;
  position: relative; overflow: hidden;
  max-width: 240px;
}
.dc-status-chip.open { display: inline-flex; }
.dc-status-chip.dc-sc-error { border-color: #ef4444; color: #fecaca; }
.dc-status-chip::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: var(--dc-sc-progress, 0%);
  background: linear-gradient(90deg, rgba(20,184,166,0.18), rgba(20,184,166,0.08));
  transition: width 0.3s ease;
  z-index: 0;
}
.dc-status-chip > * { position: relative; z-index: 1; }
.dc-sc-spinner {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid rgba(148,163,184,0.3); border-top-color: #2dd4bf;
  animation: dc-sc-spin 0.9s linear infinite;
}
.dc-status-chip.dc-sc-error .dc-sc-spinner { border-top-color: #ef4444; }
.dc-sc-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes dc-sc-spin { to { transform: rotate(360deg); } }

/* Re-design tab + pane. The pane fills the artifact-body area and hosts
   a toolbar (status pills + Apply / Re-open / Another round) + iframe. */
.artifact-redesign-pane { padding: 0; height: 100%; overflow: hidden; }
.artifact-redesign-pane.active { display: block; }
.dc-redesign-root { display: flex; flex-direction: column; height: 100%; }
.dc-redesign-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 14px; border-bottom: 1px solid rgba(17,19,24,0.08);
  background: rgba(255,253,249,0.94);
  font: 500 12px/1 'Plus Jakarta Sans', system-ui, sans-serif;
}
.dc-redesign-status { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.dc-applied-pill {
  background: rgba(20,184,166,0.12); color: #0f766e;
  padding: 4px 10px; border-radius: 999px; border: 1px solid rgba(20,184,166,0.3);
}
.dc-pending-pill {
  background: rgba(99,102,241,0.12); color: #4f46e5;
  padding: 4px 10px; border-radius: 999px; border: 1px solid rgba(99,102,241,0.3);
}
.dc-warn-pill {
  background: rgba(245,158,11,0.12); color: #b45309;
  padding: 4px 10px; border-radius: 999px; border: 1px solid rgba(245,158,11,0.3);
}
.dc-redesign-actions { display: flex; gap: 6px; }
.dc-redesign-actions .dc-btn { padding: 6px 12px; height: 30px; }
.dc-redesign-iframe { flex: 1; width: 100%; border: 0; background: #fff; }

/* Artifact-tile "Design" action — added to the library list in renderer.js.
   Positioned next to the download button, appears on hover. */
.artifact-tile-design-action {
  position: absolute; top: 12px; right: 52px; z-index: 4;
  height: 30px; padding: 0 10px; border-radius: 6px;
  background: rgba(255,253,249,0.94);
  color: var(--text-secondary, #5a5040);
  border: 1px solid rgba(26,15,5,0.06);
  font: 500 12px/1 inherit; letter-spacing: 0.02em;
  cursor: pointer; opacity: 0; transform: translateY(-2px);
  transition: opacity .18s ease, transform .18s ease, background .12s, color .12s;
  box-shadow: 0 1px 4px rgba(26,15,5,0.08);
  backdrop-filter: blur(6px);
}
.artifact-card:hover .artifact-tile-design-action,
.artifact-card:focus-within .artifact-tile-design-action { opacity: 1; transform: translateY(0); }
.artifact-tile-design-action:hover { background: #14b8a6; color: #0f172a; border-color: #0f766e; }

/* ========================================================================
   Artifact multi-select — gallery-style selection on /artifacts + /library
   ========================================================================= */

/* Extra scroll space so the bottom dock doesn't cover the last row */
.artifacts-page.artifacts-page--select-active .artifacts-page-grid {
  padding-bottom: 112px;
}

/* ── Header "Select" / "Done" control ─────────────────────────────── */
.artifacts-page-select-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border-light);
  background: var(--bg-white);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition:
    background 0.18s ease,
    color 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.22s ease,
    transform 0.18s ease;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: var(--shadow-soft);
}
.artifacts-page-select-btn:hover {
  background: #fafbfc;
  color: var(--text-primary);
  border-color: #cdd1d9;
  box-shadow: 0 4px 14px rgba(17, 19, 24, 0.07);
}
.artifacts-page-select-btn:active {
  transform: scale(0.98);
}
.artifacts-page-select-btn.active {
  background: linear-gradient(135deg, rgba(42, 56, 153, 0.09) 0%, rgba(29, 154, 148, 0.12) 100%);
  color: var(--brand-indigo);
  border-color: rgba(42, 56, 153, 0.28);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.8) inset,
    0 4px 18px rgba(42, 56, 153, 0.08);
}

.artifacts-page-select-btn-icon {
  position: relative;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.artifacts-page-select-btn-icon svg {
  position: absolute;
  left: 0;
  top: 0;
  width: 18px;
  height: 18px;
}

/* ── Checkbox on thumbnail (inside .artifact-card-thumb) ───────────── */
.artifact-select-indicator {
  position: absolute;
  bottom: 12px;
  right: 12px;
  z-index: 8;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.82);
  transition:
    opacity 0.22s ease,
    transform 0.28s cubic-bezier(0.34, 1.45, 0.44, 1),
    box-shadow 0.2s ease;
}
/* Outer ring — reads clearly on light + dark thumbs */
.artifact-select-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.96);
  border: 2px solid rgba(17, 19, 24, 0.22);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.06),
    0 0 0 1px rgba(255, 255, 255, 0.55) inset;
}
.artifact-select-check {
  position: relative;
  z-index: 1;
  color: transparent;
  stroke: transparent;
  opacity: 0;
  transform: scale(0.5);
  transition:
    opacity 0.16s ease,
    transform 0.22s cubic-bezier(0.34, 1.45, 0.44, 1),
    stroke 0.16s ease,
    color 0.16s ease;
}

.artifacts-page-grid--select-mode .artifact-select-indicator {
  opacity: 1;
  transform: scale(1);
}

.artifacts-page-grid--select-mode .artifact-card--selected .artifact-select-ring {
  background: linear-gradient(145deg, var(--brand-indigo) 0%, var(--brand-teal) 100%);
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow:
    0 2px 8px rgba(42, 56, 153, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.25) inset;
}
.artifacts-page-grid--select-mode .artifact-card--selected .artifact-select-check {
  opacity: 1;
  transform: scale(1);
  stroke: #ffffff;
  color: #ffffff;
}

/* Soft veil over thumbs — titles stay fully readable */
.artifacts-page-grid--select-mode .artifact-card-thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  background: rgba(17, 19, 24, 0.06);
  transition: background 0.22s ease, opacity 0.22s ease;
}
.artifacts-page-grid--select-mode .artifact-card:not(.artifact-card--selected) .artifact-card-thumb::after {
  background: rgba(17, 19, 24, 0.14);
}
.artifacts-page-grid--select-mode .artifact-card:not(.artifact-card--selected):hover .artifact-card-thumb::after {
  background: rgba(17, 19, 24, 0.06);
}
.artifacts-page-grid--select-mode .artifact-card--selected .artifact-card-thumb::after {
  background: linear-gradient(
    180deg,
    rgba(42, 56, 153, 0.06) 0%,
    rgba(29, 154, 148, 0.07) 100%
  );
  opacity: 0.95;
}

/* Selected tile — refined emphasis without fighting catalogue shadows */
.artifacts-page-grid--select-mode .artifact-card--selected .artifact-card-thumb {
  box-shadow:
    0 0 0 2px #ffffff,
    0 0 0 4px rgba(29, 154, 148, 0.65),
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 4px 14px rgba(26, 15, 5, 0.1),
    0 14px 32px -10px rgba(42, 56, 153, 0.18);
}

/* Selection mode: calmer interactions */
.artifacts-page-grid--select-mode .artifact-card:hover {
  transform: none;
}
.artifacts-page-grid--select-mode .artifact-card:hover .artifact-card-title {
  text-decoration: none;
}

/* ── Floating dock — matches cream UI, not a stark dark capsule ───── */
.multi-select-bar {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%) translateY(calc(100% + 48px));
  z-index: 9999;
  max-width: min(520px, calc(100vw - 28px));
  padding: 0;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  border: 1px solid rgba(226, 228, 233, 0.95);
  box-shadow:
    0 4px 6px rgba(17, 19, 24, 0.04),
    0 22px 50px -12px rgba(17, 19, 24, 0.18),
    0 0 0 1px rgba(255, 255, 255, 0.8) inset;
  transition:
    transform 0.38s cubic-bezier(0.32, 1.28, 0.42, 1),
    opacity 0.28s ease;
  opacity: 0;
  pointer-events: none;
}
.multi-select-bar.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.multi-select-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 14px 12px 16px;
}

.multi-select-leading {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.multi-select-count {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.25;
}

.multi-select-hint {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-tertiary);
  line-height: 1.3;
}

.multi-select-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.multi-select-cancel-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid var(--border-light);
  background: var(--bg-white);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}
.multi-select-cancel-btn:hover {
  background: #f6f7f9;
  color: var(--text-primary);
  border-color: #cdd1d9;
}

.multi-select-open-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 10px;
  border: none;
  background: var(--brand-gradient);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: filter 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease, transform 0.15s ease;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(42, 56, 153, 0.28);
}
.multi-select-open-btn:hover:not(:disabled) {
  filter: brightness(1.05);
  box-shadow: 0 6px 20px rgba(42, 56, 153, 0.34);
}
.multi-select-open-btn:active:not(:disabled) {
  transform: translateY(1px);
}
.multi-select-open-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  box-shadow: none;
  filter: grayscale(0.15);
}

@media (max-width: 520px) {
  .multi-select-hint {
    display: none;
  }
  .multi-select-bar-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .multi-select-actions {
    justify-content: stretch;
  }
  .multi-select-cancel-btn,
  .multi-select-open-btn {
    flex: 1;
    justify-content: center;
  }
}

/* Redesign toolbar icon button — subtle teal tint so it's discoverable. */
.artifact-redesign-btn svg { stroke: #2dd4bf; }

/* ========================================================================
   Re-designed tab \u2014 list-of-siblings chip row + iframe for the currently
   selected redesign. Lives inside #artifactRedesignedPane in the canvas.
   ========================================================================= */
.artifact-redesigned-pane { padding: 0; height: 100%; overflow: hidden; }
.artifact-redesigned-pane.active { display: block; }
.dc-rd-root { display: flex; flex-direction: column; height: 100%; }
.dc-rd-toolbar {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  padding: 8px 14px; border-bottom: 1px solid rgba(17,19,24,0.08);
  background: rgba(255,253,249,0.94);
}
.dc-rd-chip {
  padding: 4px 12px; border-radius: 999px;
  background: rgba(15,23,42,0.04); color: var(--text-primary, #111318);
  border: 1px solid rgba(17,19,24,0.08);
  font: 500 12px/1 'Plus Jakarta Sans', system-ui, sans-serif;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.dc-rd-chip:hover { background: rgba(20,184,166,0.14); color: #0f766e; border-color: rgba(20,184,166,0.3); }
.dc-rd-chip.active { background: #14b8a6; color: #0f172a; border-color: #0f766e; }
.dc-rd-chip.dc-rd-orig { font-weight: 600; color: var(--text-secondary, #5c5f66); }
.dc-rd-chip.dc-rd-orig.active { background: rgba(148,163,184,0.5); color: #0f172a; }
.dc-rd-iframe { flex: 1; width: 100%; border: 0; background: #fff; }

/* ========================================================================
   Data Health page — pipeline freshness + extractor lifecycle.
   Populated by renderer/data-health.js.
   ======================================================================== */
.data-health-page {
  padding: 28px 36px; overflow-y: auto; max-height: 100vh;
  background: var(--bg-cream, #fbf8f3); color: var(--text-primary, #111318);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}
/* dh-header > h1 inherits the canonical 40px Fraunces gradient title rule
 * (defined alongside .artifacts-page-title); only the dek styling is
 * redirected here so it picks up the same italic Garamond used by
 * .artifacts-page-header-dek. */
.dh-header-dek {
  font-family: 'EB Garamond', Georgia, serif;
  font-style: italic;
  font-size: 15px;
  color: var(--text-secondary);
  margin: 8px 0 0;
  max-width: 540px;
}

.dh-counters {
  display: flex; flex-wrap: wrap; gap: 20px;
  padding: 16px 18px; margin-bottom: 20px;
  background: var(--bg-white, #fff);
  border: 1px solid var(--border-light, rgba(17,19,24,0.08));
  border-radius: 14px;
}
.dh-counter-group { display: flex; align-items: center; gap: 10px; }
.dh-counter-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-tertiary, #9c8e79); margin-right: 2px;
}
.dh-counter {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 5px 12px; border-radius: 999px;
  font-size: 12.5px; font-weight: 500;
  background: rgba(15,23,42,0.04); border: 1px solid rgba(17,19,24,0.06);
}
.dh-counter b { font-weight: 700; font-size: 13.5px; }

.dh-status-fresh    { background: #e6f7ef; color: #0a6e42; border-color: #b7e4ca; }
.dh-status-due      { background: #fef4d7; color: #7a5a00; border-color: #f5dc88; }
.dh-status-overdue  { background: #fde2e2; color: #8a1d1d; border-color: #f3a9a9; }
.dh-status-failed   { background: #f1d5d5; color: #6a0f0f; border-color: #d98a8a; }
.dh-status-never    { background: rgba(17,19,24,0.04); color: #6a6258; }
.dh-status-running  { background: #e0eefd; color: #0a4f86; border-color: #a2c9ef; }

.dh-life-draft      { background: rgba(17,19,24,0.05); color: #605748; }
.dh-life-probing    { background: #eef2ff; color: #1e3a8a; border-color: #c7d2fe; }
.dh-life-verified   { background: #e0f5f1; color: #0b5a52; border-color: #a7ddd3; }
.dh-life-broken     { background: #fde2e2; color: #6a0f0f; border-color: #d98a8a; }

.dh-chip {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 500; text-transform: lowercase;
  border: 1px solid transparent;
}

.dh-filter-bar { display: flex; gap: 10px; align-items: center; margin: 4px 0 14px; flex-wrap: wrap; }
.dh-filter-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-tertiary, #9c8e79);
}
.dh-filter-bar select {
  padding: 5px 10px; border-radius: 8px; font-size: 13px;
  border: 1px solid var(--border-light, rgba(17,19,24,0.12));
  background: var(--bg-white, #fff); color: var(--text-primary, #111318);
}

.dh-btn {
  padding: 6px 12px; border-radius: 8px; font-size: 12.5px;
  border: 1px solid var(--border-light, rgba(17,19,24,0.12));
  background: var(--bg-white, #fff); color: var(--text-primary, #111318);
  cursor: pointer; transition: background .12s, border-color .12s;
}
.dh-btn:hover { background: #f3efe8; }
.dh-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.dh-btn-small { padding: 3px 8px; font-size: 11.5px; }
.dh-btn-primary {
  background: var(--brand-teal, #1D9A94); color: #fff; border-color: #0f766e;
}
.dh-btn-primary:hover { background: #17827e; }

.dh-table-wrap {
  background: var(--bg-white, #fff);
  border: 1px solid var(--border-light, rgba(17,19,24,0.08));
  border-radius: 14px; overflow: hidden;
}
.dh-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dh-table thead th {
  text-align: left; padding: 10px 12px; font-weight: 600;
  color: var(--text-secondary, #5a5040);
  font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em;
  background: #fbf7f0; border-bottom: 1px solid var(--border-light, rgba(17,19,24,0.08));
}
.dh-table tbody td {
  padding: 10px 12px; border-top: 1px solid rgba(17,19,24,0.05); vertical-align: middle;
}
.dh-table tbody tr:hover { background: rgba(29,154,148,0.04); cursor: pointer; }
.dh-col-source .dh-source-id { font-weight: 600; }
.dh-col-source .dh-source-desc { font-size: 11.5px; color: var(--text-tertiary, #9c8e79); margin-top: 2px; }
.dh-col-records { text-align: right; font-variant-numeric: tabular-nums; }
.dh-col-actions { text-align: right; white-space: nowrap; }
.dh-col-actions .dh-btn + .dh-btn { margin-left: 6px; }
.dh-empty { padding: 20px; text-align: center; color: var(--text-tertiary, #9c8e79); font-style: italic; }

.dh-loading, .dh-error { padding: 40px; text-align: center; color: var(--text-secondary, #5a5040); }
.dh-error { color: #8a1d1d; }

.dh-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 92vw);
  background: var(--bg-white, #fff);
  border-left: 1px solid var(--border-light, rgba(17,19,24,0.08));
  box-shadow: -10px 0 40px rgba(17,19,24,0.12);
  padding: 20px 24px; overflow-y: auto; z-index: 50;
}
.dh-drawer.hidden { display: none; }
.dh-drawer-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.dh-drawer-header h3 { margin: 0 0 2px; font-size: 17px; font-weight: 600; }
.dh-drawer-sub { color: var(--text-tertiary, #9c8e79); font-size: 12.5px; }
.dh-drawer-close { font-size: 20px; line-height: 1; padding: 0 10px; height: 32px; }
.dh-drawer-meta {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px;
  margin: 18px 0 22px; padding: 14px; border-radius: 12px;
  background: #fbf7f0; font-size: 12.5px;
}
.dh-drawer-meta .dh-k {
  display: block; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-tertiary, #9c8e79); margin-bottom: 2px;
}
.dh-drawer-meta a { color: var(--brand-teal, #1D9A94); word-break: break-all; }
.dh-drawer h4 { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-secondary, #5a5040); }
.dh-runs-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.dh-runs-table th, .dh-runs-table td { padding: 6px 8px; text-align: left; border-top: 1px solid rgba(17,19,24,0.05); }
.dh-runs-table thead th { background: #fbf7f0; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-tertiary, #9c8e79); border: 0; }
.dh-col-error { font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; font-size: 11px; color: #8a1d1d; }

/* Per-source notes (source.yaml `comments:` block) above the
 * Run history / Records tabs. Free-form prose authored by the
 * source's owner — release vintages, methodology cadence,
 * known caveats. */
.dh-drawer-comments {
  margin: 18px 0 0;
  padding: 14px 16px;
  background: rgba(29, 154, 148, 0.05);
  border-left: 3px solid var(--brand-teal, #1D9A94);
  border-radius: 0 8px 8px 0;
}
.dh-drawer-comments-label {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-tertiary, #9c8e79);
  margin-bottom: 6px;
}
.dh-drawer-comments-body {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text-primary, #111318);
}
.dh-drawer-comments-body p {
  margin: 0 0 8px;
}
.dh-drawer-comments-body p:last-child { margin-bottom: 0; }
.dh-drawer-comments-body a {
  color: var(--brand-teal, #1D9A94);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

/* Drawer tabs (Run history / Records) */
.dh-drawer-tabs {
  display: flex;
  gap: 2px;
  margin: 18px 0 0;
  border-bottom: 1px solid rgba(17, 19, 24, 0.08);
}
.dh-drawer-tab {
  padding: 8px 14px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: inherit;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary, #9c8e79);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.dh-drawer-tab:hover { color: var(--text-secondary, #5a5040); }
.dh-drawer-tab.dh-drawer-tab-active {
  color: var(--text-primary, #111318);
  border-bottom-color: var(--brand-teal, #1D9A94);
  font-weight: 600;
}
.dh-drawer-pane { padding-top: 12px; }
.dh-drawer-pane-hidden { display: none; }

.dh-records-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 4px 0 10px;
  font-size: 12px;
  color: var(--text-tertiary, #9c8e79);
}
.dh-records-bar select {
  margin: 0 4px;
  padding: 3px 6px;
  font-family: inherit;
  font-size: 12px;
  border: 1px solid rgba(17, 19, 24, 0.1);
  background: #fff;
  border-radius: 5px;
}
.dh-records-meta {
  font-size: 11px;
  color: var(--text-tertiary, #9c8e79);
  margin-bottom: 6px;
  font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace;
}
.dh-records-meta code {
  background: #fbf7f0;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 10.5px;
}

.dh-records-table {
  font-size: 11.5px;
}
.dh-records-table td {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace;
}
.dh-records-table thead th {
  font-size: 10px;
}
.dh-records-table tbody tr:hover { background: rgba(29, 154, 148, 0.04); }
.dh-cell-null { color: var(--text-tertiary, #9c8e79); font-style: italic; }

/* Data Sources reuses the .dh-* table/chip classes; only the wrapper is separate. */
.data-sources-page {
  padding: 28px 36px; overflow-y: auto; max-height: 100vh;
  background: var(--bg-cream, #fbf8f3); color: var(--text-primary, #111318);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}
.dh-cfg {
  background: #fbf7f0; padding: 10px 12px; border-radius: 8px;
  font-size: 11.5px; font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace;
  overflow-x: auto; white-space: pre-wrap; word-break: break-word;
}

/* ─── Automations page ────────────────────────────────────────────────────
   Mounted at #automationsPage by renderer/automations.js. Mirrors the
   data-health page rhythm: full-bleed cream background with rounded
   white cards, gradient title, restrained brand-indigo accents. */

.automations-page {
  flex: 1; min-width: 0; padding: 32px 48px 64px;
  overflow-y: auto; background: var(--bg-cream);
  border-radius: 16px; border: 1px solid var(--border-light);
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.04);
}

.auto-header { max-width: 820px; margin: 0 auto 28px; }
.auto-title {
  font-family: 'Fraunces', 'EB Garamond', Georgia, serif;
  font-size: 40px;
  font-weight: 500;
  line-height: 1.04;
  letter-spacing: -0.022em;
  margin: 0 0 8px;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  font-variation-settings: 'opsz' 144, 'SOFT' 50;
  width: fit-content;
}
.auto-dek {
  margin: 0; font-size: 14px; color: var(--text-secondary);
  font-family: 'Plus Jakarta Sans', sans-serif;
}

/* ── Tab bar ───────────────────────────────────────────────────────────────
   Sits between the header and the active tab panel. "New automation" gets
   a brand-gradient pill so it always reads as the primary action; the
   other tabs are quiet by default and only light up when their badge is
   non-zero. Active tab gets an indigo accent + thin underline. */
.auto-tabs {
  max-width: 820px; margin: 0 auto 22px;
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(20, 30, 80, 0.08);
  border-radius: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85),
              0 1px 2px rgba(20, 30, 80, 0.025);
}
.auto-tab {
  position: relative;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13px; font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease,
              box-shadow 0.18s ease, transform 0.12s ease;
}
.auto-tab:hover { color: var(--text-primary); background: rgba(20, 30, 80, 0.035); }
.auto-tab--active {
  background: #ffffff; color: var(--brand-indigo);
  border-color: rgba(42, 56, 153, 0.18);
  box-shadow: 0 1px 2px rgba(20, 30, 80, 0.04),
              0 4px 12px rgba(42, 56, 153, 0.08);
}
/* The "New automation" tab gets brand-gradient treatment so it always reads
   as the top-of-page primary action — even when not currently active. */
.auto-tab--primary {
  background: var(--brand-gradient); color: #ffffff;
  border-color: transparent;
  box-shadow: 0 2px 6px rgba(42, 56, 153, 0.18);
}
.auto-tab--primary:hover {
  color: #ffffff; background: var(--brand-gradient);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(42, 56, 153, 0.22);
}
.auto-tab--primary.auto-tab--active {
  background: var(--brand-gradient); color: #ffffff;
  border-color: transparent;
  box-shadow: 0 2px 6px rgba(42, 56, 153, 0.22),
              inset 0 0 0 2px rgba(255, 255, 255, 0.18);
}
.auto-tab-label { line-height: 1; }
.auto-tab-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 6px;
  border-radius: 10px;
  background: rgba(20, 30, 80, 0.12); color: var(--text-primary);
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.02em;
  line-height: 1;
}
.auto-tab--primary .auto-tab-badge {
  background: rgba(255, 255, 255, 0.22); color: #ffffff;
}
.auto-tab--active .auto-tab-badge {
  background: rgba(42, 56, 153, 0.10); color: var(--brand-indigo);
}
/* When a non-active tab has a non-zero badge (something needs attention)
   we tint the badge coral to draw the eye — same colour family as the
   sidebar notification pill. */
.auto-tab--has-badge .auto-tab-badge {
  background: var(--accent-coral); color: #ffffff;
  box-shadow: 0 0 0 2px rgba(184, 128, 90, 0.18);
}
.auto-tab--has-badge {
  color: var(--text-primary);
}

.auto-tab-panel {
  /* The panels themselves are full-width — child sections (.auto-card,
     .auto-strip, .auto-tasks) carry their own max-width: 820px so they
     centre cleanly inside the panel. */
  display: block;
  animation: autoTabFadeIn 0.18s ease-out;
}
@keyframes autoTabFadeIn {
  from { opacity: 0; transform: translateY(2px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Empty-state placeholder used inside any tab that has no content yet. */
.auto-empty {
  max-width: 820px; margin: 32px auto;
  padding: 40px 28px; text-align: center;
  background: rgba(255, 255, 255, 0.55);
  border: 1px dashed rgba(20, 30, 80, 0.14);
  border-radius: 14px;
}
.auto-empty-title {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 20px; font-weight: 500; color: var(--brand-indigo);
  margin-bottom: 8px;
}
.auto-empty-body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13.5px; color: var(--text-secondary); line-height: 1.55;
  max-width: 480px; margin: 0 auto;
}

.auto-card {
  max-width: 820px; margin: 0 auto 18px; padding: 22px 24px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
  border: 1px solid rgba(20, 30, 80, 0.08); border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85),
              0 1px 2px rgba(20, 30, 80, 0.025),
              0 6px 16px rgba(20, 30, 80, 0.025);
}

.auto-wizard-eyebrow,
.auto-tasks-eyebrow,
.auto-strip-eyebrow {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--brand-indigo);
  margin-bottom: 6px;
}
.auto-wizard-dek {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 18px; font-weight: 500; color: var(--text-primary);
  margin-bottom: 16px; letter-spacing: -0.005em;
}

.auto-stage { display: flex; flex-direction: column; gap: 12px; }
.auto-textarea {
  width: 100%; padding: 12px 14px; border: 1px solid rgba(42, 56, 153, 0.14);
  border-radius: 10px; background: #fff; font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 14px; line-height: 1.5; color: var(--text-primary); resize: vertical;
  outline: none; transition: border-color 0.18s ease, box-shadow 0.22s ease;
}
.auto-textarea:focus {
  border-color: rgba(42, 56, 153, 0.32);
  box-shadow: 0 0 0 4px rgba(42, 56, 153, 0.06);
}

.auto-primary-btn,
.auto-secondary-btn {
  align-self: flex-start; padding: 10px 18px; border: none; border-radius: 10px;
  font-family: 'Plus Jakarta Sans', sans-serif; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: transform 0.18s ease, box-shadow 0.22s ease, filter 0.2s ease;
}
.auto-primary-btn {
  background: var(--brand-gradient); color: #fff;
  box-shadow: 0 2px 8px rgba(42, 56, 153, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.auto-primary-btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.auto-secondary-btn {
  background: transparent; color: var(--brand-indigo);
  border: 1px solid rgba(42, 56, 153, 0.22);
}
.auto-secondary-btn:hover { background: rgba(42, 56, 153, 0.05); }
.auto-actions { display: flex; gap: 10px; margin-top: 14px; }

.auto-busy {
  font-size: 12.5px; color: var(--text-tertiary); font-style: italic;
  margin-top: 8px;
}
.auto-error {
  background: #fde2e2; color: #8a1d1d; padding: 10px 14px;
  border-radius: 8px; font-size: 13px; margin-bottom: 12px;
}
.auto-warn {
  background: #fef4d7; color: #7a5a00; padding: 10px 14px;
  border-radius: 8px; font-size: 12.5px;
}

.auto-transcript {
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px; background: rgba(42, 56, 153, 0.025);
  border-radius: 10px; max-height: 280px; overflow-y: auto;
}
.auto-bubble {
  padding: 8px 12px; border-radius: 12px;
  font-size: 13px; line-height: 1.45; max-width: 85%;
}
.auto-bubble-user {
  align-self: flex-end; background: var(--brand-indigo); color: #fff;
}
.auto-bubble-asst {
  align-self: flex-start; background: #fff; color: var(--text-primary);
  border: 1px solid rgba(20, 30, 80, 0.08);
}

.auto-preview-grid {
  display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px;
  margin: 0 0 14px; padding: 14px 16px;
  background: rgba(42, 56, 153, 0.03); border-radius: 10px;
}
.auto-preview-grid dt {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--brand-indigo); margin: 0;
}
.auto-preview-grid dd {
  margin: 0; font-size: 13.5px; color: var(--text-primary); word-break: break-word;
}
.auto-prompt-box { margin-top: 12px; }
.auto-prompt-box summary {
  cursor: pointer; font-size: 12px; font-weight: 600; color: var(--text-secondary);
  margin-bottom: 8px;
}

.auto-strip { background: linear-gradient(180deg, #fdfdff 0%, #f6faff 100%); }
.auto-strip-list { display: flex; flex-direction: column; gap: 10px; }
.auto-strip-item {
  display: grid; grid-template-columns: 1fr auto auto auto; gap: 12px;
  align-items: center; padding: 10px 12px;
  background: #fff; border: 1px solid rgba(20, 30, 80, 0.08); border-radius: 10px;
}
.auto-strip-goal {
  font-size: 13.5px; font-weight: 500; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.auto-strip-stage {
  font-size: 11.5px; color: var(--brand-indigo); font-weight: 600;
  letter-spacing: 0.04em;
}
.auto-strip-bar {
  width: 120px; height: 6px; background: rgba(42, 56, 153, 0.08);
  border-radius: 999px; overflow: hidden;
}
.auto-strip-bar > span {
  display: block; height: 100%;
  background: var(--brand-gradient);
  transition: width 0.4s ease;
}
.auto-strip-failed { background: #fef4f4; }
.auto-strip-error {
  font-size: 11.5px; color: #8a1d1d; grid-column: span 3;
}

.auto-tasks-header {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 12px;
}
.auto-tasks-count { font-size: 11.5px; color: var(--text-tertiary); }
.auto-tasks-empty {
  font-size: 13px; color: var(--text-tertiary); font-style: italic;
  padding: 18px; text-align: center;
  background: rgba(42, 56, 153, 0.03); border-radius: 10px;
}
.auto-tasks-list { display: flex; flex-direction: column; gap: 10px; }
.auto-task-card {
  display: flex; flex-direction: column; gap: 6px;
  padding: 12px 14px; background: #fff;
  border: 1px solid rgba(20, 30, 80, 0.07); border-radius: 10px;
}
.auto-task-row {
  display: flex; justify-content: space-between; align-items: center;
}
.auto-task-name {
  font-size: 14px; font-weight: 600; color: var(--text-primary);
}
.auto-task-meta {
  font-size: 11.5px; color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}
.auto-task-actions {
  display: flex; gap: 12px; margin-top: 4px;
}

.auto-link {
  background: none; border: none; padding: 0; cursor: pointer;
  font-family: 'Plus Jakarta Sans', sans-serif; font-size: 12px;
  color: var(--brand-indigo); font-weight: 600;
}
.auto-link:hover { text-decoration: underline; }
.auto-link-danger { color: #8a1d1d; }

.auto-toggle {
  position: relative; display: inline-block; width: 36px; height: 20px;
  cursor: pointer;
}
.auto-toggle input { opacity: 0; width: 0; height: 0; }
.auto-toggle-slider {
  position: absolute; inset: 0; background: rgba(20, 30, 80, 0.18);
  border-radius: 999px; transition: background 0.22s ease;
}
.auto-toggle-slider::before {
  content: ''; position: absolute; left: 2px; top: 2px;
  width: 16px; height: 16px; background: #fff; border-radius: 50%;
  transition: transform 0.22s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.auto-toggle input:checked + .auto-toggle-slider { background: var(--brand-indigo); }
.auto-toggle input:checked + .auto-toggle-slider::before { transform: translateX(16px); }

.auto-approval-card {
  padding: 12px 14px; background: #fff8e6;
  border: 1px solid #f5dc88; border-radius: 10px;
  margin-bottom: 8px;
}
.auto-approval-name { font-weight: 600; font-size: 13.5px; color: var(--text-primary); }
.auto-approval-desc { font-size: 12.5px; color: var(--text-secondary); margin: 4px 0 6px; }
.auto-approval-path {
  font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace;
  font-size: 11px; color: #7a5a00; word-break: break-all;
}

@media (max-width: 720px) {
  .automations-page { padding: 20px 16px 48px; }
  .auto-card { padding: 16px 18px; margin-bottom: 12px; }
  .auto-strip-item { grid-template-columns: 1fr; gap: 4px; }
  .auto-strip-bar { width: 100%; }
}

/* Editable delivery fields in the wizard preview stage. */
.auto-delivery {
  margin-top: 14px; padding: 14px 16px;
  background: rgba(42, 56, 153, 0.03); border-radius: 10px;
  display: flex; flex-direction: column; gap: 12px;
}
.auto-delivery-eyebrow {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--brand-indigo);
  margin-bottom: 2px;
}
.auto-field { display: flex; flex-direction: column; gap: 4px; }
.auto-field label {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 12px; font-weight: 600; color: var(--text-primary);
}
.auto-input {
  padding: 9px 12px; border: 1px solid rgba(42, 56, 153, 0.18);
  border-radius: 8px; background: #fff;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13px; color: var(--text-primary); outline: none;
  transition: border-color 0.18s ease, box-shadow 0.22s ease;
}
.auto-input:focus {
  border-color: rgba(42, 56, 153, 0.36);
  box-shadow: 0 0 0 3px rgba(42, 56, 153, 0.06);
}
.auto-field-hint {
  font-size: 11.5px; color: var(--text-tertiary);
  font-family: 'Plus Jakarta Sans', sans-serif;
}

/* Edit-task modal. */
.auto-modal-backdrop {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(20, 30, 80, 0.32);
  backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 64px 16px; overflow-y: auto;
}
.auto-modal {
  width: 560px; max-width: 100%;
  background: #fff; border-radius: 14px;
  box-shadow: 0 24px 64px rgba(20, 30, 80, 0.18);
  display: flex; flex-direction: column; overflow: hidden;
}
.auto-modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 22px; border-bottom: 1px solid rgba(20, 30, 80, 0.06);
}
.auto-modal-title {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 22px; font-weight: 500; color: var(--brand-indigo);
}
.auto-modal-close {
  background: none; border: none; font-size: 22px; line-height: 1;
  color: var(--text-tertiary); cursor: pointer; padding: 4px 8px;
  border-radius: 6px;
}
.auto-modal-close:hover { background: rgba(20, 30, 80, 0.05); color: var(--text-primary); }
.auto-modal-body {
  padding: 18px 22px; display: flex; flex-direction: column; gap: 14px;
  max-height: 60vh; overflow-y: auto;
}
.auto-modal-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 14px 22px; border-top: 1px solid rgba(20, 30, 80, 0.06);
  background: #fbfcfe;
}

/* Generated-assets section + per-task chips. */
.auto-task-assets {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-top: 6px;
}
.auto-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  background: rgba(42, 56, 153, 0.08); color: var(--brand-indigo);
  border: 1px solid rgba(42, 56, 153, 0.16);
  cursor: pointer; font-family: 'Plus Jakarta Sans', sans-serif;
}
.auto-chip:hover { background: rgba(42, 56, 153, 0.14); }
.auto-task-lastrun {
  font-size: 11px; color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

.auto-assets-subhead {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 12px; font-weight: 600; color: var(--text-secondary);
  margin: 12px 0 6px;
}
.auto-assets-list { display: flex; flex-direction: column; gap: 8px; }
.auto-asset-card {
  padding: 10px 12px; background: #fff;
  border: 1px solid rgba(20, 30, 80, 0.07); border-radius: 10px;
  display: flex; flex-direction: column; gap: 4px;
}
.auto-asset-row {
  display: flex; justify-content: space-between; align-items: center;
}
.auto-asset-name {
  font-size: 13px; font-weight: 600; color: var(--text-primary);
}
.auto-asset-id {
  font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace;
  font-size: 10.5px; color: var(--text-tertiary); word-break: break-all;
}
.auto-asset-desc {
  font-size: 12px; color: var(--text-secondary);
}
.auto-asset-path {
  font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace;
  font-size: 10.5px; color: #7a5a00; word-break: break-all;
}
.auto-asset-status {
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px;
  font-family: 'Plus Jakarta Sans', sans-serif;
}
.auto-status-pending  { background: #fef4d7; color: #7a5a00; }
.auto-status-approved { background: #e6f7ef; color: #0a6e42; }
.auto-status-rejected { background: #fde2e2; color: #8a1d1d; }

.auto-skill-content {
  background: #fafaf7; border: 1px solid rgba(20, 30, 80, 0.06);
  border-radius: 8px; padding: 14px 16px;
  font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace;
  font-size: 12px; line-height: 1.5; color: var(--text-primary);
  white-space: pre-wrap; word-break: break-word;
  max-height: 60vh; overflow-y: auto; margin: 0;
}
.auto-assets-empty {
  font-size: 12.5px; color: var(--text-tertiary); font-style: italic;
  padding: 14px 16px;
  background: rgba(42, 56, 153, 0.03); border-radius: 10px;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

/* Full-page asset editor (VS Code style: tree on the left, Monaco on the right). */
.automations-page--editor { padding: 0; overflow: hidden; }
.auto-editor-page {
  display: flex; flex-direction: column;
  height: calc(100vh - 24px); background: #fff;
  border-radius: 16px; overflow: hidden;
}
.auto-editor-header {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(20, 30, 80, 0.08);
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
}
.auto-editor-title-wrap {
  display: flex; align-items: center; gap: 10px; flex: 1;
  font-family: 'Plus Jakarta Sans', sans-serif;
}
.auto-editor-title {
  font-size: 13px; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--brand-indigo);
}
.auto-editor-subtitle {
  font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace;
  font-size: 12px; color: var(--text-secondary);
}
.auto-editor-dirty {
  color: #b8800a; font-size: 14px; line-height: 1;
}
.auto-editor-save { padding: 7px 16px; }
.auto-editor-save:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.auto-editor-body {
  display: grid; grid-template-columns: 240px 1fr;
  flex: 1; min-height: 0;
}
.auto-editor-tree {
  background: #fafaf7;
  border-right: 1px solid rgba(20, 30, 80, 0.08);
  overflow-y: auto;
  padding: 8px 0 16px;
  font-family: 'Plus Jakarta Sans', sans-serif;
}
.auto-editor-tree-head {
  padding: 8px 14px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-tertiary);
  border-bottom: 1px solid rgba(20, 30, 80, 0.05);
  word-break: break-all;
}
.auto-editor-tree-list { padding: 4px 0; }
.auto-editor-tree-row {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  font-size: 12.5px; color: var(--text-primary);
  cursor: default; user-select: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.auto-editor-tree-row.is-file { cursor: pointer; }
.auto-editor-tree-row.is-file:hover { background: rgba(42, 56, 153, 0.05); }
.auto-editor-tree-row.is-file.active {
  background: rgba(42, 56, 153, 0.10); color: var(--brand-indigo); font-weight: 600;
}
.auto-editor-tree-row.is-dir { color: var(--text-secondary); font-weight: 600; font-size: 11.5px; }
.auto-editor-tree-icon { font-size: 12px; opacity: 0.85; }

.auto-editor-pane {
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
}
.auto-editor-tabbar {
  padding: 6px 14px;
  background: #f3f3ee;
  border-bottom: 1px solid rgba(20, 30, 80, 0.06);
  font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace;
  font-size: 12px; color: var(--text-secondary);
}
.auto-editor-mount {
  flex: 1; min-height: 0; min-width: 0;
}
.auto-editor-empty {
  padding: 32px; color: var(--text-tertiary); font-style: italic;
  text-align: center;
}
.auto-editor-readonly-note {
  padding: 8px 14px; background: #fef4d7; color: #7a5a00;
  font-size: 12px; border-top: 1px solid #f5dc88;
}

/* Channel + format controls in Edit modal and Stage 3. */
.auto-checkrow {
  display: flex; flex-wrap: wrap; gap: 14px 22px;
  padding: 8px 10px; background: #fff;
  border: 1px solid rgba(20, 30, 80, 0.10); border-radius: 8px;
}
.auto-check {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13px; color: var(--text-primary); cursor: pointer;
  user-select: none;
}
.auto-check input { accent-color: var(--brand-indigo); cursor: pointer; }

/* Template uploader. */
.auto-template-wrap {
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px 14px; background: #fff;
  border: 1px solid rgba(20, 30, 80, 0.10); border-radius: 8px;
}
.auto-template-status {
  font-size: 12.5px; color: var(--text-secondary);
}
.auto-template-actions {
  display: flex; gap: 12px; align-items: center;
}

/* In-chat automation draft card. Lives inside #chatMessages alongside
   regular bubbles but visually distinct — system / proposal styling.
   Override the flex-row layout inherited from `.message` so eyebrow / title
   / meta / actions stack vertically instead of squeezing into columns. */
.message-automation-card {
  display: block;
  align-self: stretch;
  max-width: 720px;
  margin: 12px auto;
  padding: 16px 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f6faff 100%);
  border: 1px solid rgba(42, 56, 153, 0.18);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(20, 30, 80, 0.04),
              0 6px 18px rgba(42, 56, 153, 0.06);
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 13px; color: var(--text-primary);
}
.message-automation-card.aut-card-loading {
  font-style: italic; color: var(--text-secondary); text-align: center;
}
.aut-card-eyebrow {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--brand-indigo);
  margin-bottom: 6px;
}
.aut-card-title {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 19px; font-weight: 500; color: var(--brand-indigo);
  letter-spacing: -0.005em; margin-bottom: 10px;
}
.aut-card-meta {
  display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px;
  margin: 0 0 14px;
}
.aut-card-meta dt {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-tertiary); margin: 0;
}
.aut-card-meta dd {
  margin: 0; font-size: 13px; color: var(--text-primary); word-break: break-word;
}
.aut-card-meta code {
  font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace;
  font-size: 11.5px; padding: 1px 5px; border-radius: 4px;
  background: rgba(42, 56, 153, 0.06); color: var(--brand-indigo);
}
.aut-card-actions { display: flex; gap: 10px; }
.aut-card-btn {
  padding: 7px 14px; border-radius: 8px;
  font-family: 'Plus Jakarta Sans', sans-serif; font-size: 12.5px; font-weight: 600;
  background: transparent; border: 1px solid rgba(42, 56, 153, 0.20);
  color: var(--brand-indigo); cursor: pointer;
}
.aut-card-btn--primary {
  background: var(--brand-gradient); color: #fff; border-color: transparent;
  box-shadow: 0 2px 6px rgba(42, 56, 153, 0.20);
}
.aut-card-btn:hover { transform: translateY(-1px); }
.aut-card-error {
  padding: 8px 12px; background: #fde2e2; color: #8a1d1d;
  border-radius: 8px; font-size: 12.5px;
}

/* Automations badge — same two-state pattern as the Pulse #inboxBadge.
   Expanded: coral numeric pill. Collapsed: pulsating teal dot. */
#sidebarAutomationsBtn { position: relative; }
.auto-badge {
  background: var(--accent-coral); color: #fff;
  border-radius: 10px; padding: 1px 6px;
  font-size: 10px; font-weight: 700;
  margin-left: auto; min-width: 18px; text-align: center; line-height: 16px;
  box-shadow: 0 0 0 2px rgba(184, 128, 90, 0.18);
  font-variant-numeric: tabular-nums;
  font-family: 'Plus Jakarta Sans', sans-serif;
}
.auto-badge.hidden { display: none; }
/* Shared pulsating animation for collapsed-state notification dots
   (Pulse + Automations). Tiny scale + opacity wobble — visible peripherally
   without screaming. */
@keyframes sidebarBadgePulse {
  0%, 100% { transform: scale(1);    opacity: 0.95; }
  50%      { transform: scale(1.10); opacity: 0.75; }
}

/* Pending review (drafts) section on the Automations page. */
.auto-drafts {
  border-color: rgba(42, 56, 153, 0.22);
  background:
    linear-gradient(180deg, #fcfcff 0%, #f6faff 100%);
}
.auto-drafts-dek {
  font-size: 12.5px; color: var(--text-secondary);
  margin: 0 0 12px;
}
.auto-draft-card {
  padding: 12px 14px;
  background: #fff;
  border: 1px solid rgba(42, 56, 153, 0.16);
  border-radius: 10px;
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 8px;
}
.auto-draft-name {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 16px; font-weight: 500; color: var(--brand-indigo);
  letter-spacing: -0.005em;
}

/* In-chat assistant-style note used during the /automate conversation
   (clarifying-question prompts, "drafting…" placeholder, errors). Sits
   alongside the regular chat bubbles but stands out as a system/proposal
   communication rather than the model's own output. */
.message-automation-note {
  display: block;
  align-self: stretch;
  max-width: 720px;
  margin: 8px auto;
  padding: 12px 16px;
  background: #fbfcfe;
  border: 1px dashed rgba(42, 56, 153, 0.20);
  border-radius: 12px;
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 13px; color: var(--text-primary);
}
.message-automation-note .aut-card-eyebrow { margin-bottom: 4px; }
.aut-note-questions {
  margin: 6px 0 6px 22px;
  padding: 0;
  font-size: 13px; line-height: 1.55; color: var(--text-primary);
}
.aut-note-hint {
  margin-top: 8px; font-size: 11.5px; color: var(--text-tertiary);
  font-style: italic;
}
/* One-question-at-a-time conversational form-fill. Single line, easy to
   read; tiny progress dots reassure the user the loop is finite. */
.aut-form-prompt {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
}
.aut-form-q {
  flex: 1 1 auto; font-size: 14px; line-height: 1.5;
  color: var(--text-primary); font-weight: 500;
}
.aut-form-progress {
  display: inline-flex; gap: 4px; flex: 0 0 auto;
}
.aut-progress-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(42, 56, 153, 0.18);
  transition: background 0.25s ease;
}
.aut-progress-dot.is-filled { background: var(--brand-indigo); }

/* Slot chips — small pill summary above each clarifying question showing
   which slots have already been filled. The user can glance at this and
   know "we already know X, Y; you're being asked about Z next". */
.aut-slot-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 10px;
}
.aut-slot-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: rgba(42, 56, 153, 0.06);
  border: 1px solid rgba(42, 56, 153, 0.14);
  border-radius: 999px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 11.5px; color: var(--text-primary);
  line-height: 1.3;
}
.aut-slot-chip-key {
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--brand-indigo); opacity: 0.85;
}

/* ============================================================
   Liquid-Glass Tool Call Cards & Reasoning Chips
   Lifts the validation island's frosted-glass aesthetic into
   inline tool cards and reasoning surfaces. Theme follows the
   chat: light glass primary, dark glass under prefers-color-scheme.
   Each chip carries a 26px gradient disc that's category-coded.
   ============================================================ */

/* Shared keyframes — clones of fv-island-* so the validation island
   and the new chips speak the same motion language. */
@keyframes lg-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}
/* Inline chat chips (tools + gold status): gentler pulse so running
   state reads as calm “alive” beside frosted glass, not a frantic beat. */
@keyframes lg-pulse-soft {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
@keyframes lg-celebrate {
  0% { transform: scale(0.85); }
  60% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
@keyframes lg-shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-3px, 0, 0); }
  40%, 60% { transform: translate3d(3px, 0, 0); }
}
@keyframes lg-fade-in {
  from { opacity: 0; transform: translateY(4px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

/* Gradient disc — 26x26 circle holding the category SVG.
   data-category drives the gradient + glow.
   data-status drives the animation. */
/* DeepInsights brand mark — single shared logo for every tool call,
   reasoning surface and status chip. No gradient balls, no per-category
   colour. Same crop technique as the collapsed left sidebar: the PNG
   is a 1280×271 lockup (mark + wordmark); scaling auto/100% with
   left-center anchor crops to just the circular mark on the left. */
.tool-icon-disc {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  background-image: url('assets/logo_deepinsights.png');
  background-repeat: no-repeat;
  background-position: left center;
  background-size: auto 100%;
  transition: transform 320ms ease;
}
.tool-icon-disc img { display: none; }

.tool-icon-disc[data-status="running"] {
  animation: lg-pulse 1.6s ease-in-out infinite;
}
.tool-icon-disc[data-status="success"] {
  animation: lg-celebrate 1.0s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.tool-icon-disc[data-status="error"] {
  animation: lg-shake 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}
.message-content .tool-icon-disc[data-status="running"] {
  animation: lg-pulse-soft 2.75s ease-in-out infinite;
}

/* ── Inline tool call card — liquid glass (light primary) ── */
.message-content .inline-tool-call {
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 18px;
  margin: 12px 0;
  overflow: hidden;
  /* Fill the chat-message column. Without an explicit width, the
     pill collapses to its content width — which truncates the label
     long before the available row is full. */
  width: 100%;
  box-sizing: border-box;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.04),
    0 6px 16px -4px rgba(0, 0, 0, 0.06),
    inset 0 0.5px 0 rgba(255, 255, 255, 0.5);
  animation: lg-fade-in 360ms cubic-bezier(0.34, 1.56, 0.64, 1);
  transition: border-color 240ms ease, box-shadow 240ms ease, background-color 240ms ease;
  position: relative;
}
.message-content .inline-tool-call:hover {
  border-color: rgba(0, 0, 0, 0.10);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.05),
    0 8px 20px -4px rgba(0, 0, 0, 0.08),
    inset 0 0.5px 0 rgba(255, 255, 255, 0.6);
}
/* Retire the old coral timeline rail + dot — disc carries the identity */
.message-content .inline-tool-call::before,
.message-content .inline-tool-call::after {
  display: none !important;
}
.message-content .inline-tool-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.15s ease;
  min-height: 44px;
  background: transparent;
}
.message-content .inline-tool-header:hover {
  background: rgba(15, 23, 42, 0.03);
}
.message-content .inline-tool-header .tool-friendly {
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(15, 23, 42, 0.92);
  /* Single-row label: fill all available width before truncating with
     ellipsis. The min-width: 0 is the canonical fix for "flex item
     doesn't shrink past its content" — without it, flex: 1 won't
     actually let text-overflow: ellipsis trigger because the item
     refuses to shrink below its natural content width. */
  flex: 1 1 0%;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.01em;
  transition: color 0.15s ease;
}
.message-content .inline-tool-header:hover .tool-friendly {
  color: rgba(15, 23, 42, 1);
}
.message-content .inline-tool-header .expand-icon {
  width: 16px;
  height: 16px;
  margin-left: auto;
  color: rgba(15, 23, 42, 0.45);
  transition: transform 0.2s ease, color 0.15s ease;
  flex-shrink: 0;
}
.message-content .inline-tool-call.expanded .expand-icon {
  transform: rotate(180deg);
  color: rgba(15, 23, 42, 0.7);
}
.message-content .inline-tool-result {
  padding: 0 18px 16px;
  max-height: 360px;
  overflow-y: auto;
  border-top: 1px solid rgba(15, 23, 42, 0.06);
}
.message-content .inline-tool-result pre,
.message-content .inline-tool-result .tool-input-content {
  background: rgba(15, 23, 42, 0.04);
  color: rgba(15, 23, 42, 0.78);
  border: none;
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 12.5px;
  line-height: 1.55;
  padding: 10px 14px;
  border-radius: 10px;
  margin-top: 12px;
}
.message-content .inline-tool-result .tool-output-section pre {
  border-left: 3px solid transparent;
  border-radius: 0 10px 10px 0;
}
.message-content .inline-tool-call[data-category="web-search"] .tool-output-section pre { border-left-color: #06b6d4; }
.message-content .inline-tool-call[data-category="internal-data"] .tool-output-section pre { border-left-color: #8b5cf6; }
.message-content .inline-tool-call[data-category="vector-search"] .tool-output-section pre { border-left-color: #ec4899; }
.message-content .inline-tool-call[data-category="mcp-generic"] .tool-output-section pre { border-left-color: #f97316; }
.message-content .inline-tool-call[data-category="fact-validator"] .tool-output-section pre { border-left-color: #10b981; }
.message-content .inline-tool-call[data-category="calendar"] .tool-output-section pre { border-left-color: #fbbf24; }
.message-content .inline-tool-call[data-category="tool-generic"] .tool-output-section pre { border-left-color: #94a3b8; }

/* Hide the legacy spinner / check SVG — disc handles status now */
.message-content .inline-tool-header .tool-spinner,
.message-content .inline-tool-header .tool-check {
  display: none !important;
}

/* Subway feed + tool-card-result colours adapt to the new chip surface.
   Override the coral defaults so the dot + rail match the new palette. */
.message-content .inline-tool-call .tool-card-result {
  border-left-color: rgba(15, 23, 42, 0.08);
}
.message-content .inline-tool-call .tool-card-result::before {
  background: rgba(255, 255, 255, 0.95);
}
.message-content .inline-tool-call[data-category="web-search"] .tool-card-result::before { border-color: #06b6d4; }
.message-content .inline-tool-call[data-category="internal-data"] .tool-card-result::before { border-color: #8b5cf6; }
.message-content .inline-tool-call[data-category="vector-search"] .tool-card-result::before { border-color: #ec4899; }
.message-content .inline-tool-call[data-category="mcp-generic"] .tool-card-result::before { border-color: #f97316; }
.message-content .inline-tool-call[data-category="fact-validator"] .tool-card-result::before { border-color: #10b981; }
.message-content .inline-tool-call[data-category="calendar"] .tool-card-result::before { border-color: #fbbf24; }
.message-content .inline-tool-call[data-category="tool-generic"] .tool-card-result::before { border-color: #94a3b8; }
.message-content .inline-tool-call .tool-card-result:hover::before {
  background: currentColor;
}

/* ── Reasoning surfaces — gold bar (chip) + collapsible block ── */
.message-content .thinking-section {
  background: rgba(255, 255, 255, 0.66);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 16px;
  margin-bottom: 14px;
  font-size: 12px;
  color: rgba(15, 23, 42, 0.78);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.04),
    0 6px 16px -4px rgba(0, 0, 0, 0.05),
    inset 0 0.5px 0 rgba(255, 255, 255, 0.5);
  position: relative;
  overflow: hidden;
  animation: lg-fade-in 360ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.message-content .thinking-section[open] {
  background: rgba(255, 255, 255, 0.78);
  border-color: rgba(0, 0, 0, 0.09);
}
.message-content .thinking-section .thinking-header {
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: rgba(15, 23, 42, 0.78);
  font-style: normal;
  letter-spacing: 0.01em;
  list-style: none;
}
.message-content .thinking-section .thinking-header::-webkit-details-marker,
.message-content .thinking-section .thinking-header::marker {
  display: none;
}
.message-content .thinking-section .thinking-header:hover {
  color: rgba(15, 23, 42, 0.95);
}
.message-content .thinking-section .thinking-icon {
  display: none !important;
}
.message-content .thinking-section .thinking-label {
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-style: normal;
  font-size: 13px;
  font-weight: 500;
  color: rgba(15, 23, 42, 0.78);
  letter-spacing: 0.01em;
  transition: opacity 0.15s ease;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.message-content .thinking-section .thinking-content {
  padding: 14px 20px 18px;
  border-top: 1px solid rgba(15, 23, 42, 0.06);
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 420px;
  overflow-y: auto;
  /* Match base .thinking-content — EB Garamond italic for the reasoning
     trace. Already loaded by the top-of-file @import. */
  font-family: 'EB Garamond', 'Iowan Old Style', 'Iowan', 'Palatino Linotype', 'Palatino', Georgia, serif;
  font-style: italic;
  font-size: 14.5px;
  line-height: 1.75;
  letter-spacing: 0.005em;
  color: rgba(15, 23, 42, 0.78);
}
/* Drop the old shimmer — disc pulse now carries the streaming feel */
.message-content .thinking-section:not([open])::after {
  display: none !important;
}

/* Status (gold-bar) thinking card — liquid-glass dynamic-island pill,
   pinned to the bottom of the streaming assistant bubble.
   Doubles as the reasoning-trace disclosure: <details> with the live
   status as the <summary> and chain-of-thought text as the body. */
.message-content .status-thinking-card {
  display: flex !important;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  padding: 0;
  cursor: default;
  border-radius: 999px;
  /* Liquid-glass dynamic-island pill with a SOFT warm-amber gradient
     hue. Toned down from the first pass — the prior alphas (0.32 →
     0.18 → 0.40 → 0.50) read as too saturated against the white
     surrounding chrome. Lighter shades feel more in-family with the
     other tool cards while still distinguishing the live-status pill.
     The hue is strongest on the left under the DeepInsights disc and
     fades to neutral white at the right end of the pill. */
  background: linear-gradient(
    90deg,
    rgba(247, 197, 109, 0.16) 0%,
    rgba(247, 197, 109, 0.09) 22%,
    rgba(255, 244, 220, 0.22) 50%,
    rgba(255, 255, 255, 0.50) 100%
  );
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid rgba(184, 128, 90, 0.07);
  margin-top: 12px;
  margin-bottom: 4px;
  box-shadow:
    0 1px 2px rgba(184, 128, 90, 0.04),
    0 4px 12px -2px rgba(184, 128, 90, 0.06),
    inset 0 0.5px 0 rgba(255, 255, 255, 0.55);
  transition: border-radius 220ms ease;
}
/* When expanded (reasoning revealed), morph from full-pill to
   rounded-card so the body has somewhere to live without getting
   clipped by the 999px corner radius. */
.message-content .status-thinking-card[open] {
  border-radius: 22px;
}
.message-content .status-thinking-card .thinking-header {
  list-style: none;
  display: flex;
  align-items: center;
  /* Match .inline-tool-header padding (12px 16px) so the DeepInsights
     disc sits at the same horizontal position as the discs inside
     regular tool cards. Was 8px 18px 8px 8px — the 8px left padding
     pushed the disc further left than tool cards, breaking visual
     consistency the user flagged. */
  padding: 12px 16px;
  gap: 12px;
  min-height: 44px;
  min-width: 0;
}
/* Body slot inside the unified pill — only visible when the user
   expands. Padding mirrors legacy .thinking-content; the top border
   gives a subtle separator from the summary row. */
.message-content .status-thinking-card > .thinking-content {
  padding: 14px 22px 18px 22px;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 380px;
  overflow-y: auto;
  /* Reasoning trace inside the live "Updating the task list…" pill.
     Italic EB Garamond reads as "model's own reasoning" — distinct
     from the sans-serif chat prose around it. The user is already
     waiting; the typography signals "this is the model thinking out
     loud" rather than "system status text". */
  font-family: 'EB Garamond', 'Iowan Old Style', 'Iowan', 'Palatino Linotype', 'Palatino', Georgia, serif;
  font-style: italic;
  font-size: 14.5px;
  line-height: 1.75;
  letter-spacing: 0.005em;
  color: rgba(15, 23, 42, 0.78);
}
.message-content .status-thinking-card > .thinking-content[hidden] {
  display: none;
}
.message-content .status-thinking-card > .thinking-content::-webkit-scrollbar { width: 4px; }
.message-content .status-thinking-card > .thinking-content::-webkit-scrollbar-track { background: transparent; }
.message-content .status-thinking-card > .thinking-content::-webkit-scrollbar-thumb {
  background: rgba(184, 128, 90, 0.2);
  border-radius: 2px;
}
/* DeepInsights logo darkens slightly when it sits inside the
   reduced-opacity glass pill — keeps contrast against whatever's
   showing through the blur. Filter (not opacity) so the colours of
   the logo lockup stay rich. */
.message-content .status-thinking-card .tool-icon-disc[data-category="reasoning"] {
  filter: brightness(0.86) contrast(1.08);
}
.message-content .thinking-section.thinking-complete .tool-icon-disc[data-category="reasoning"] {
  animation: none;
}

/* ── Wide Research cards (plan + status) ──────────────────────────── */
.wr-card {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: #ffffff;
  border: 1px solid rgba(26, 15, 5, 0.10);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(26, 15, 5, 0.08), 0 2px 6px rgba(26, 15, 5, 0.04);
  font-family: 'Plus Jakarta Sans', -apple-system, system-ui, sans-serif;
  font-size: 13px;
  color: var(--text-primary, #1a0f05);
  overflow: hidden;
  max-width: 720px;
  margin: 12px 0;
}

.wr-card-head {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(26, 15, 5, 0.06);
  background: rgba(26, 15, 5, 0.02);
  position: relative;
}
.wr-card-controls {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 2px;
}
.wr-card-ctl {
  background: transparent;
  border: 0;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  color: var(--text-secondary, #4a3f35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.wr-card-ctl:hover { background: rgba(26, 15, 5, 0.08); }
.wr-card-slot { margin: 12px 0; }
.wr-card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
}
.wr-card-pill {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(26, 15, 5, 0.08);
  color: var(--text-secondary, #4a3f35);
}
.wr-pill-draft     { background: #e0f2fe; color: #075985; }
.wr-pill-running   { background: #fef3c7; color: #92400e; }
.wr-pill-paused    { background: #f3f4f6; color: #374151; }
.wr-pill-completed { background: #dcfce7; color: #166534; }
.wr-pill-failed    { background: #fde8e8; color: #991b1b; }
.wr-pill-cancelled { background: #f3f4f6; color: #6b7280; }
.wr-pill-approved  { background: #ede9fe; color: #5b21b6; }

.wr-card-request {
  margin-top: 6px;
  font-style: italic;
  font-size: 13px;
  color: var(--text-secondary, #4a3f35);
}
.wr-card-sub {
  margin-top: 4px;
  font-size: 11.5px;
}

.wr-section {
  padding: 12px 18px;
  border-bottom: 1px solid rgba(26, 15, 5, 0.04);
}
.wr-section:last-of-type { border-bottom: 0; }
.wr-section > header {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary, #8a7f75);
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  gap: 6px;
  align-items: baseline;
}
.wr-count {
  font-weight: 400;
  color: var(--text-tertiary, #8a7f75);
}

.wr-rows { display: flex; flex-direction: column; gap: 4px; }
.wr-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 4px 0;
  font-size: 13px;
}
.wr-schema-row .wr-check  { width: 14px; color: #075985; font-weight: 700; }
.wr-schema-row .wr-field  { min-width: 140px; font-weight: 600; }
.wr-schema-row .wr-type   {
  min-width: 60px; font-size: 11px;
  background: rgba(26, 15, 5, 0.05); padding: 2px 6px; border-radius: 4px;
}
.wr-routing-row .wr-field { min-width: 140px; font-weight: 600; }
.wr-routing-row .wr-arrow { color: var(--text-tertiary, #8a7f75); }

.wr-empty {
  font-size: 12px; color: var(--text-tertiary, #8a7f75); font-style: italic; padding: 4px 0;
}
.wr-muted { color: var(--text-tertiary, #8a7f75); font-size: 12px; }

.wr-kv {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 6px 12px;
  font-size: 13px;
}
.wr-kv > span:nth-child(odd) {
  color: var(--text-tertiary, #8a7f75);
  font-size: 12px;
}

.wr-tabs-list {
  margin: 6px 0 0;
  padding-left: 18px;
  font-size: 13px;
  color: var(--text-primary, #1a0f05);
}
.wr-tabs-list li { margin-bottom: 3px; }

.wr-estimate { background: rgba(26, 15, 5, 0.015); }

.wr-actions {
  padding: 12px 18px;
  border-top: 1px solid rgba(26, 15, 5, 0.06);
  background: rgba(26, 15, 5, 0.015);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.wr-btn {
  flex: 0 1 auto;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid rgba(26, 15, 5, 0.14);
  background: #ffffff;
  color: var(--text-primary, #1a0f05);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.wr-btn:hover:not([disabled]) {
  background: rgba(26, 15, 5, 0.04);
  border-color: rgba(26, 15, 5, 0.22);
}
.wr-btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.wr-btn-primary {
  background: #075985; color: #ffffff; border-color: #075985;
}
.wr-btn-primary:hover:not([disabled]) {
  background: #064a6f; border-color: #064a6f;
}

/* status card */
.wr-progress {
  position: relative;
  height: 24px;
  margin: 0 18px 12px;
  background: rgba(26, 15, 5, 0.06);
  border-radius: 4px;
  overflow: hidden;
}
.wr-progress-bar {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, #075985 0%, #0c7ab1 100%);
  transition: width 0.3s ease;
}
.wr-progress-label {
  position: absolute; left: 0; right: 0; top: 0; bottom: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 600; color: #ffffff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.wr-card-terminal {
  padding: 14px 18px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}
.wr-completed { background: #dcfce7; color: #166534; }
.wr-failed    { background: #fde8e8; color: #991b1b; }
.wr-cancelled { background: #f3f4f6; color: #6b7280; }

/* ── Wide Research classify chip ──────────────────────────────────── */
.wr-classify-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  margin: 8px 0;
  border-radius: 8px;
  font-family: 'Plus Jakarta Sans', -apple-system, system-ui, sans-serif;
  font-size: 12.5px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
  user-select: none;
  max-width: 720px;
}
.wr-classify-chip:hover { transform: translateY(-1px); }
.wr-classify-chip:focus { outline: 2px solid #075985; outline-offset: 2px; }

.wr-chip-icon { font-size: 14px; }
.wr-chip-label { flex: 1; min-width: 0; }
.wr-chip-cta {
  font-weight: 600;
  font-size: 11.5px;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
}
.wr-chip-dismiss {
  background: none;
  border: 0;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  color: inherit;
  opacity: 0.55;
  padding: 2px 4px;
  border-radius: 3px;
  margin-left: 4px;
}
.wr-chip-dismiss:hover { opacity: 1; background: rgba(0, 0, 0, 0.08); }

/* prominent — ≥ 0.75 confidence */
.wr-classify-prominent {
  background: #e0f2fe;
  color: #075985;
  border-color: #bae6fd;
}
.wr-classify-prominent:hover {
  background: #d3edfa;
  border-color: #7dd3fc;
}
.wr-classify-prominent .wr-chip-cta {
  background: #075985;
  color: #fff;
}

/* subtle — 0.40 to 0.75 confidence */
.wr-classify-subtle {
  background: rgba(26, 15, 5, 0.04);
  color: var(--text-secondary, #4a3f35);
  border-color: rgba(26, 15, 5, 0.10);
}
.wr-classify-subtle:hover {
  background: rgba(26, 15, 5, 0.07);
  border-color: rgba(26, 15, 5, 0.18);
}
.wr-classify-subtle .wr-chip-cta {
  background: rgba(255, 255, 255, 0.85);
  color: var(--text-primary, #1a0f05);
}

/* loading state — chip fades + disables until planner returns */
.wr-chip-loading {
  opacity: 0.65;
  pointer-events: none;
  cursor: wait;
}
.wr-chip-loading .wr-chip-cta::after {
  content: ' …';
}

/* ambiguous note — appears above the chip when planner reports clarifying questions */
.wr-chip-ambiguous {
  margin: 8px 0 4px;
  padding: 8px 12px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 6px;
  font-size: 12.5px;
  max-width: 720px;
}

/* ── Wide Research Jobs Dock ─────────────────────────────────────── */
.wr-dock {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 9990;
  font-family: 'Plus Jakarta Sans', -apple-system, system-ui, sans-serif;
}
.wr-dock-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(26, 15, 5, 0.10);
  background: #ffffff;
  box-shadow: 0 6px 20px rgba(26, 15, 5, 0.10), 0 2px 6px rgba(26, 15, 5, 0.05);
  cursor: pointer;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-primary, #1a0f05);
  transition: background 0.15s ease, transform 0.08s ease;
}
.wr-dock-chip:hover { transform: translateY(-1px); background: #fafafa; }
.wr-dock-icon { font-size: 14px; }
.wr-dock-chip-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(26, 15, 5, 0.06);
  color: var(--text-secondary, #4a3f35);
  font-size: 11px;
  font-weight: 700;
}
.wr-dock-has-active .wr-dock-chip-count {
  background: #075985;
  color: #ffffff;
}

.wr-dock-drawer {
  position: absolute;
  right: 0;
  bottom: 56px;
  width: 380px;
  max-height: 520px;
  background: #ffffff;
  border: 1px solid rgba(26, 15, 5, 0.10);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(26, 15, 5, 0.16), 0 2px 6px rgba(26, 15, 5, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.wr-dock-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  font-weight: 600;
  font-size: 13px;
  border-bottom: 1px solid rgba(26, 15, 5, 0.06);
  background: rgba(26, 15, 5, 0.02);
}
.wr-dock-close {
  background: none;
  border: 0;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-tertiary, #8a7f75);
  padding: 0 4px;
}
.wr-dock-close:hover { color: #c0392b; }

.wr-dock-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 6px;
}
.wr-dock-empty {
  padding: 24px 14px;
  text-align: center;
  color: var(--text-tertiary, #8a7f75);
  font-size: 12.5px;
  font-style: italic;
}
.wr-dock-foot {
  padding: 8px 14px;
  border-top: 1px solid rgba(26, 15, 5, 0.06);
  background: rgba(26, 15, 5, 0.015);
  font-size: 11.5px;
}

.wr-dock-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s ease;
}
.wr-dock-row:hover { background: rgba(26, 15, 5, 0.04); }
.wr-dock-row:focus { outline: 2px solid #075985; outline-offset: -2px; }

.wr-dock-row-icon {
  font-size: 16px;
  text-align: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.wr-dock-status-running   .wr-dock-row-icon { background: #fef3c7; color: #92400e; }
.wr-dock-status-paused    .wr-dock-row-icon { background: #f3f4f6; color: #374151; }
.wr-dock-status-completed .wr-dock-row-icon { background: #dcfce7; color: #166534; }
.wr-dock-status-failed    .wr-dock-row-icon { background: #fde8e8; color: #991b1b; }
.wr-dock-status-cancelled .wr-dock-row-icon { background: #f3f4f6; color: #6b7280; }
.wr-dock-status-approved  .wr-dock-row-icon { background: #ede9fe; color: #5b21b6; }
.wr-dock-status-draft     .wr-dock-row-icon { background: #e0f2fe; color: #075985; }

.wr-dock-row-body { min-width: 0; }
.wr-dock-row-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary, #1a0f05);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wr-dock-row-sub {
  font-size: 11.5px;
  margin-top: 2px;
}
.wr-dock-row-cta {
  font-size: 11px;
  color: var(--text-tertiary, #8a7f75);
  white-space: nowrap;
}

/* ── Wide Research toast ─────────────────────────────────────────── */
.wr-toast {
  background: #1a0f05;
  color: #ffffff;
  padding: 12px 18px;
  border-radius: 10px;
  font-family: 'Plus Jakarta Sans', -apple-system, system-ui, sans-serif;
  font-size: 13px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: 360px;
}
.wr-toast-completed { background: #166534; }
.wr-toast-failed    { background: #991b1b; }
.wr-toast-cancelled { background: #4a3f35; }
.wr-toast-leaving { opacity: 0; transform: translateY(8px); }



/* ── Reasoning trace card — confidence pill loading state ──────────
 *
 * Skeleton pulse for the `Confidence: …` pill while the Trust engine
 * is auditing the reasoning trace (typically 2–8s after the assistant
 * finishes streaming). The dot fades between full opacity and ~30%
 * to signal "in flight" without being flashy.
 *
 * Driven by msg.confidence_pending which is set by the
 * applyResponseConfidenceStarted reducer and cleared by
 * applyResponseConfidence when the result arrives.
 */
@keyframes reasoning-trace-card__confidence-pulse {
  0%   { opacity: 1; }
  50%  { opacity: 0.32; }
  100% { opacity: 1; }
}

/* ── Follow-up suggestions card ─────────────────────────────────────
 *
 * Post-completion "Suggested next steps" panel that mounts between
 * the response prose and the action buttons. Shows 4 Haiku-generated
 * next-query suggestions in a 2×2 grid. Click → fills the chat
 * input box with the suggestion query (no auto-submit so the user
 * can edit before sending).
 *
 * Visual hierarchy:
 *   - Card has a subtle cream background to separate from the
 *     response prose above but not compete with it.
 *   - Each suggestion is its own button with a shape icon + label
 *     pill on the head row, then the action-led label on the body.
 *   - Hover: gentle lift + accent border so the click target is
 *     obvious.
 */
.followup-suggestions-card {
  margin: 20px 0 12px 0;
  padding: 16px 18px;
  background: linear-gradient(180deg, rgba(253, 248, 238, 0.6) 0%, rgba(253, 248, 238, 0.3) 100%);
  border: 1px solid rgba(196, 145, 123, 0.18);
  border-radius: 14px;
}
.followup-suggestions-card__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 0 2px;
}
.followup-suggestions-card__title {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary, #5a4d3e);
  letter-spacing: -0.005em;
}
.followup-suggestions-card__hint {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-tertiary, #9c8a78);
  font-style: italic;
}
.followup-suggestions-card__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (max-width: 640px) {
  .followup-suggestions-card__grid {
    grid-template-columns: 1fr;
  }
}

.followup-suggestion {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  background: #FFFFFF;
  border: 1px solid rgba(196, 145, 123, 0.18);
  border-radius: 10px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
}
.followup-suggestion:hover {
  border-color: rgba(196, 145, 123, 0.45);
  box-shadow: 0 2px 10px rgba(196, 145, 123, 0.10);
  transform: translateY(-1px);
}
.followup-suggestion:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(196, 145, 123, 0.08);
}
.followup-suggestion__head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.followup-suggestion__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: rgba(196, 145, 123, 0.12);
  color: var(--accent-coral, #C4917B);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
}
.followup-suggestion__shape {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--accent-coral, #C4917B);
}
.followup-suggestion__label {
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text-primary, #1F1B17);
  letter-spacing: -0.005em;
}

/* ── Live-table canvas (L2/L3 skeleton mode) ──────────────────────────
   Excel-style multi-tab artifact. Tabs: Data / Sources / Gaps / Notes.
   Cells progressively fill as skeleton_canvas_cell_update events land
   from server/services/skeleton-canvas.js. */
.live-table-canvas {
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  /* Force light-mode appearance always — canvas table never goes dark */
  color-scheme: light;
  --text-primary: #1F1B17;
  --text-secondary: #555;
  --text-tertiary: #888;
  --accent-teal: #2E6B6B;
  --border-secondary: rgba(150, 150, 155, 0.3);
  --teal-500: #2dd4bf;
  --teal-400: #2dd4bf;
  --gray-300: #d1d5db;
  color: #1F1B17;
  background: #ffffff;
  padding: 16px 20px 24px;
  max-width: 100%;
  /* Fill the parent .artifact-pane (position:absolute; inset:0) and lay
     out as a flex column. Header / chips / tabs keep their natural
     height; .live-table-tab-panes claims the remaining vertical space
     and hands it to the active pane (Data → grid-wrap scrolls only on
     overflow; other panes scroll naturally). */
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  box-sizing: border-box;
  overflow: hidden;
}

/* Header bar */
.live-table-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  /* No padding-bottom: the tab strip now lives in this row and its active
     underline must meet the full-width divider below. */
  border-bottom: 1px solid #eee9e4;
  margin-bottom: 0;
}
/* .live-table-title removed — the live-table pane no longer repeats the
   title (the pane chrome above already shows it); tabs now occupy that row. */
.live-table-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #2E6B6B;
  background: rgba(46, 107, 107, 0.07);
  border: 1px solid rgba(46, 107, 107, 0.30);
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.live-table-download-btn:hover:not(:disabled) {
  background: rgba(46, 107, 107, 0.14);
  border-color: rgba(46, 107, 107, 0.55);
}
.live-table-download-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

/* ── Supplementary tab — raw extracted tables/cards ──────────────────── */
.live-table-supp-intro {
  font-size: 12px;
  color: var(--text-secondary, #666);
  margin: 2px 0 12px;
}
.live-table-supp-block {
  border: 1px solid #e8e2db;
  border-left: 3px solid rgba(46, 107, 107, 0.55);
  border-radius: 10px;
  background: #fff;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.live-table-supp-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.live-table-supp-source {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: rgba(120, 130, 140, 0.12);
  color: var(--text-secondary, #666);
  white-space: nowrap;
}
.live-table-supp-source[data-source="mospi"] { background: rgba(46, 107, 107, 0.14); color: #2E6B6B; }
.live-table-supp-source[data-source="internal"] { background: rgba(100, 130, 200, 0.14); color: #2e4899; }
/* table-targeted internal-SQL fetch (Rosetta) — coral, distinct from the
   black-box internal_data_search blue. */
.live-table-supp-source[data-source="table-fetch"] { background: rgba(204, 120, 92, 0.16); color: #B5573B; }
.live-table-supp-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary, #1F1B17);
}
.live-table-supp-context {
  font-size: 11.5px;
  color: var(--text-secondary, #777);
  margin-bottom: 8px;
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
}
.live-table-supp-scroll {
  overflow-x: auto;
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid #eee9e4;
  border-radius: 6px;
}
.live-table-supp-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
}
.live-table-supp-table th,
.live-table-supp-table td {
  border: 1px solid #f0ece7;
  padding: 4px 8px;
  text-align: left;
  white-space: nowrap;
}
.live-table-supp-table th {
  background: #faf8f6;
  font-weight: 600;
  color: var(--text-primary, #1F1B17);
  position: sticky;
  top: 0;
}
.live-table-supp-table td {
  color: var(--text-secondary, #444);
  font-variant-numeric: tabular-nums;
}
.live-table-supp-text {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-secondary, #555);
  margin-bottom: 8px;
}
.live-table-supp-refs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
}
.live-table-supp-refs a {
  font-size: 12px;
  color: var(--accent, #2E6B6B);
  text-decoration: none;
}
.live-table-supp-refs a:hover { text-decoration: underline; }
.live-table-status-pill {
  display: inline-block;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  background: rgba(180, 200, 220, 0.18);
  color: #3a5a7e;
}
.live-table-status-pill[data-state="live"] {
  background: rgba(95, 178, 156, 0.16);
  color: #2e6b59;
  position: relative;
}
.live-table-status-pill[data-state="live"]::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #5fb29c;
  margin-right: 6px;
  vertical-align: middle;
  animation: live-table-pulse 1.6s ease-in-out infinite;
}
.live-table-status-pill[data-state="complete"] {
  background: rgba(80, 120, 95, 0.14);
  color: #2e6b3a;
}
@keyframes live-table-pulse {
  0%, 100% { opacity: 0.4; transform: scale(0.85); }
  50%      { opacity: 1;   transform: scale(1.15); }
}

/* Summary chips */
.live-table-summary-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.live-table-chip {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  background: rgba(120, 130, 140, 0.1);
  color: var(--text-secondary, #555);
}
.live-table-chip[data-state="filled"]   { background: rgba(95, 178, 156, 0.16); color: #2e6b59; }
.live-table-chip[data-state="disputed"] { background: rgba(220, 160, 60, 0.16);  color: #8a5b15; }
.live-table-chip[data-state="failed"]   { background: rgba(200, 80, 80, 0.14);   color: #8a2727; }
.live-table-chip[data-state="pending"]  { background: rgba(160, 160, 170, 0.16); color: #555; }
.live-table-chip[data-state="sources"]  { background: rgba(100, 130, 200, 0.14); color: #2e4899; }

/* Tab bar */
.live-table-tabs {
  display: flex;
  gap: 2px;
  /* Lives inside .live-table-header now (same row as the status pills). The
     header supplies the full-width divider, so no own margin-top/border here;
     margin-right:auto right-groups the status pills + Excel button. */
  margin-right: auto;
}
.live-table-tab {
  background: transparent;
  border: none;
  padding: 9px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.005em;
  color: var(--text-secondary, #666);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.live-table-tab:hover {
  color: var(--text-primary, #1F1B17);
}
.live-table-tab.is-active {
  color: var(--accent-teal, #2E6B6B);
  border-bottom-color: var(--accent-teal, #2E6B6B);
  font-weight: 600;
}
.live-table-tab-badge {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  background: rgba(120, 130, 140, 0.16);
  color: var(--text-secondary, #555);
  text-align: center;
  line-height: 1.3;
}
.live-table-tab.is-active .live-table-tab-badge {
  background: rgba(46, 107, 107, 0.16);
  color: var(--accent-teal, #2E6B6B);
}

/* Tab panes — flex container that fills remaining vertical space below
   the header/tabs so the active pane can claim it. */
.live-table-tab-panes {
  margin-top: 12px;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.live-table-pane {
  display: none;
}
/* Default active pane: scroll naturally for free-form content (Sources,
   Gaps, Disputes). Data tab overrides below to delegate scrolling to
   the inner grid-wrap (so sticky thead works). */
.live-table-pane.is-active {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
.live-table-pane-data.is-active {
  overflow: hidden;
}

/* ── Data tab: Anthropic-style data grid ──────────────────────────── */
.live-table-grid-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-width: 100%;
  /* Fill the active data pane and only scroll vertically when content
     overflows. max-height: 60vh previously capped the grid even when
     the canvas had plenty of room left below — instead use the flex
     chain to grow up to the parent's bounds. */
  flex: 1 1 auto;
  min-height: 0;
  border: 1px solid #e8e2db;
  border-radius: 12px;
  background: #fff;
}
.live-table-grid {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 13px;
  font-feature-settings: "tnum" 1;
}
/* Sticky header row so columns stay visible on vertical scroll */
.live-table-grid thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #faf8f5;
}
/* Sticky row headers so entity names stay visible on horizontal scroll */
.live-table-grid th[scope="row"] {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #faf8f5;
}
/* Corner cell (top-left) stays fixed on both axes */
.live-table-grid thead th.live-table-corner,
.live-table-grid thead th.live-table-rank-head {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 3;
  background: #faf8f5;
}
.live-table-grid th,
.live-table-grid td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid #eee9e4;
  vertical-align: middle;
}
.live-table-grid tbody tr:last-child td,
.live-table-grid tbody tr:last-child th {
  border-bottom: none;
}
.live-table-corner {
  background: #f3eeea;
  width: 110px;
}
.live-table-col-head {
  background: #f3eeea;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  color: #3d3833;
  text-align: center;
  white-space: nowrap;
  border-bottom: 1px solid #e0d9d1;
}
.live-table-row-head {
  background: rgba(243, 238, 234, 0.5);
  font-size: 12.5px;
  font-weight: 600;
  color: #1a1a1a;
  white-space: nowrap;
  min-width: 110px;
}
.live-table-cell {
  position: relative;
  background: #fff;
  font-feature-settings: "tnum" 1;
  text-align: right;
  min-width: 110px;
  transition: background 0.35s ease;
}
.live-table-cell[data-status="filled"] {
  background: rgba(95, 178, 156, 0.05);
}
.live-table-cell[data-status="disputed"] {
  background: rgba(220, 160, 60, 0.18);
  box-shadow: inset 3px 0 0 rgba(220, 160, 60, 0.85);
}
/* ⚠ marker so a disputed cell is unmistakable at a glance (top-left so it
   doesn't collide with the derived ∑ badge on the right). */
.live-table-cell[data-status="disputed"]::before {
  content: '⚠';
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 10px;
  line-height: 1;
  color: #b8801f;
  opacity: 0.9;
}
.live-table-cell[data-status="disputed"] .live-table-cell-value {
  color: #8a5d12;
  font-weight: 600;
}
.live-table-cell[data-status="failed"] {
  background: rgba(200, 80, 80, 0.06);
  color: #8a2727;
}
.live-table-cell[data-status="unverified"] {
  background: rgba(180, 150, 90, 0.06);
}
.live-table-cell[data-status="pending"] {
  background: rgba(243, 238, 234, 0.5);
  color: #aaa;
}
.live-table-cell[data-derived="1"]::after {
  content: '∑';
  position: absolute;
  top: 3px;
  right: 4px;
  font-size: 9px;
  font-weight: 700;
  color: rgba(46, 107, 107, 0.55);
  letter-spacing: 0;
}
.live-table-cell-value {
  display: block;
  font-weight: 600;
  font-size: 13.5px;
  line-height: 1.3;
  color: #1a1a1a;
}
.live-table-cell[data-status="pending"] .live-table-cell-value {
  color: #b0b0b0;
  font-weight: 400;
}
/* Magnitude outlier — value is >100× or <0.01× the column median.
   Warm amber background + orange value to signal "suspicious, re-searching". */
.live-table-cell[data-outlier="1"] {
  background: #fef3e2;
  border-left: 3px solid #e68a00;
}
.live-table-cell[data-outlier="1"] .live-table-cell-value {
  color: #c05600;
}
.live-table-cell[data-outlier="1"] .live-table-cell-source {
  color: #b45309;
}
.live-table-cell-source {
  display: block;
  font-size: 10.5px;
  font-weight: 400;
  color: #8a8480;
  letter-spacing: 0;
  margin-top: 3px;
}
/* URL-variant: clickable hostname link in teal, no uppercase */
.live-table-cell-source.live-table-cell-source-url {
  color: var(--accent-teal, #0a8a8a);
  text-decoration: none;
  cursor: pointer;
  word-break: break-all;
}
.live-table-cell-source.live-table-cell-source-url:hover {
  text-decoration: underline;
}
/* Per-cell statistical provenance — base year + revision vintage. Smaller +
   fainter + italic vs the source line. Only present when provenance_notes_enabled
   captured it from the source (never inferred). */
.live-table-cell-vintage {
  display: block;
  font-size: 9.5px;
  font-weight: 400;
  font-style: italic;
  color: #a39d97;
  letter-spacing: 0;
  margin-top: 2px;
}

/* ── Sources tab ───────────────────────────────────────────────────── */
.live-table-sources-wrap,
.live-table-gaps-wrap,
.live-table-disputes-wrap {
  padding: 4px 0;
}
.live-table-source-list,
.live-table-gap-list,
.live-table-dispute-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.live-table-source-row {
  padding: 12px 16px;
  border: 1px solid #e8e2db;
  border-left: 3px solid rgba(46, 107, 107, 0.55);
  border-radius: 10px;
  margin-bottom: 8px;
  background: #fff;
}
.live-table-source-slotid {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 10.5px;
  color: var(--text-tertiary, #8b8e96);
  letter-spacing: 0.01em;
  margin-bottom: 3px;
  word-break: break-all;
}
.live-table-source-head {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary, #1F1B17);
}
.live-table-source-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--brand-teal, #1d9a94);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.live-table-source-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 5px;
}
.live-table-source-tier {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: rgba(120, 130, 140, 0.12);
  color: var(--text-secondary, #666);
  white-space: nowrap;
}
.live-table-source-tier[data-tier="mcp"] {
  background: rgba(46, 107, 107, 0.14);
  color: #2E6B6B;
}
.live-table-source-tier[data-tier="internal_data"],
.live-table-source-tier[data-tier="internal_data_search"] {
  background: rgba(100, 130, 200, 0.14);
  color: #2e4899;
}
.live-table-source-tier[data-tier="pinned_doc"] {
  background: rgba(160, 90, 180, 0.14);
  color: #5b2870;
}
.live-table-source-tier[data-tier="tavily_t1"] {
  background: rgba(95, 178, 156, 0.16);
  color: #2e6b59;
}
.live-table-source-tier[data-tier^="tavily_t"] {
  background: rgba(120, 130, 140, 0.12);
  color: var(--text-secondary, #666);
}
.live-table-source-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary, #666);
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
  letter-spacing: -0.01em;
  word-break: break-word;
}
.live-table-source-ref {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-secondary, #777);
  margin-top: 5px;
  word-break: break-word;
}
.live-table-source-ref-link {
  color: var(--accent, #2E6B6B);
  text-decoration: none;
}
.live-table-source-ref-link:hover {
  text-decoration: underline;
}
.live-table-source-count {
  font-size: 12px;
  color: var(--text-secondary, #777);
  font-weight: 500;
}

/* Sources tab — flat provenance TABLE (Slot ID · Slot · Value · Unit ·
   Source · Authority · Reference · Link). Reuses .live-table-grid; tunes
   per-column alignment, widths, and truncation. */
.live-table-sources-table {
  table-layout: auto;
}
.live-table-sources-table th,
.live-table-sources-table td {
  padding: 9px 12px;
  font-size: 12.5px;
  vertical-align: top;
}
.live-table-sources-table tbody tr:hover td {
  background: rgba(95, 178, 156, 0.05);
}
.live-table-sources-table .lt-src-slotid {
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
  font-size: 11px;
  color: var(--text-tertiary, #8a8480);
  white-space: nowrap;
}
.live-table-sources-table .lt-src-slot {
  font-weight: 600;
  color: var(--text-primary, #1a1a1a);
  min-width: 140px;
}
.live-table-sources-table .lt-src-value {
  text-align: right;
  font-weight: 600;
  white-space: nowrap;
  font-feature-settings: "tnum" 1;
}
.live-table-sources-table .lt-src-unit {
  color: var(--text-secondary, #666);
  white-space: nowrap;
}
.live-table-sources-table .lt-src-source {
  white-space: nowrap;
  color: var(--text-secondary, #666);
}
.live-table-sources-table .lt-src-ref {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary, #777);
}
.live-table-sources-table .lt-src-link {
  white-space: nowrap;
}
/* Disputed source rows: tint the value, consistent with the Data tab. */
.live-table-sources-table tr[data-status="disputed"] .lt-src-value {
  color: #b9770e;
}

/* ── Gaps tab ──────────────────────────────────────────────────────── */
.live-table-gap-row {
  padding: 12px 16px;
  border-left: 3px solid rgba(220, 160, 60, 0.7);
  background: rgba(255, 251, 240, 0.6);
  border-radius: 8px;
  margin-bottom: 8px;
}
.live-table-gap-head {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary, #1F1B17);
}
.live-table-gap-meta {
  font-size: 11.5px;
  color: var(--text-secondary, #666);
  margin-top: 2px;
}
.live-table-gap-reason {
  font-size: 12px;
  color: var(--text-secondary, #777);
  margin-top: 4px;
  font-style: italic;
}

/* ── Disputes tab ──────────────────────────────────────────────────── */
.live-table-dispute-row {
  padding: 12px 16px;
  border: 1px solid #e8e2db;
  border-left: 3px solid rgba(220, 160, 60, 0.7);
  border-radius: 10px;
  margin-bottom: 10px;
  background: #fff;
}
.live-table-dispute-head {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary, #1F1B17);
}
.live-table-dispute-meta {
  font-size: 11.5px;
  color: var(--text-secondary, #666);
  margin-top: 2px;
}

/* Resolved winner row — the value shown in the Data tab */
.live-table-dispute-winner {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 10px;
  margin-top: 8px;
  background: rgba(95, 178, 156, 0.08);
  border: 1px solid rgba(95, 178, 156, 0.18);
  border-radius: 5px;
}
.live-table-dispute-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(95, 178, 156, 0.22);
  color: #2e6b59;
}
.live-table-dispute-badge[data-role="winner"] {
  background: rgba(95, 178, 156, 0.22);
  color: #2e6b59;
}
.live-table-dispute-value {
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary, #1F1B17);
  font-feature-settings: "tnum" 1;
}
.live-table-dispute-tier {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: rgba(120, 130, 140, 0.12);
  color: var(--text-secondary, #666);
  white-space: nowrap;
}
.live-table-dispute-tier[data-tier="mcp"] {
  background: rgba(46, 107, 107, 0.14);
  color: #2E6B6B;
}
.live-table-dispute-tier[data-tier="internal_data"],
.live-table-dispute-tier[data-tier="internal_data_search"] {
  background: rgba(100, 130, 200, 0.14);
  color: #2e4899;
}
.live-table-dispute-tier[data-tier="pinned_doc"] {
  background: rgba(160, 90, 180, 0.14);
  color: #5b2870;
}
.live-table-dispute-tier[data-tier="tavily_t1"] {
  background: rgba(95, 178, 156, 0.16);
  color: #2e6b59;
}
.live-table-dispute-tier[data-tier^="tavily_t"] {
  background: rgba(220, 160, 60, 0.12);
  color: #8a5b15;
}
.live-table-dispute-source {
  font-size: 12px;
  color: var(--text-secondary, #666);
  font-family: 'JetBrains Mono', 'SF Mono', monospace;
}
.live-table-dispute-source a {
  color: #2e4899;
  text-decoration: none;
  border-bottom: 1px dotted rgba(46, 72, 153, 0.4);
}
.live-table-dispute-source a:hover {
  color: #1f3270;
  border-bottom-style: solid;
}

/* Alternatives list — the "rest" */
.live-table-dispute-alts {
  margin-top: 10px;
}
.live-table-dispute-alts-head {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary, #888);
  margin-bottom: 6px;
}
.live-table-dispute-alt-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.live-table-dispute-alt {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 6px 10px;
  margin-bottom: 4px;
  background: rgba(248, 249, 250, 0.7);
  border-radius: 4px;
  border: 1px solid rgba(60, 60, 60, 0.05);
}
.live-table-dispute-excerpt {
  flex: 1 1 100%;
  font-size: 11.5px;
  color: var(--text-tertiary, #888);
  font-style: italic;
  margin-top: 4px;
  line-height: 1.35;
}

/* ── Empty state ───────────────────────────────────────────────────── */
.live-table-empty {
  padding: 20px 12px;
  text-align: center;
  font-size: 13px;
  color: var(--text-tertiary, #999);
  font-style: italic;
  background: rgba(248, 249, 250, 0.5);
  border-radius: 6px;
}
.live-table-empty[data-tone="good"] {
  color: #2e6b59;
  background: rgba(95, 178, 156, 0.06);
}

/* Dark-mode tweaks — match the rest of the canvas */
/* Live-table canvas stays in light mode regardless of system theme.
   The tabular artifact should look consistent (light bg, dark text)
   whether the user's OS is in light or dark mode. */

/* ── Ranking decoration (top-N reflow) ──────────────────────────────── */

/* Rank column header + cells */
.live-table-rank-head {
  width: 2rem;
  text-align: center;
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--text-secondary, #8e8e93);
}
.live-table-rank-cell {
  width: 2rem;
  text-align: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--teal-500, #2dd4bf);
  padding: 0.3rem 0.4rem;
}

/* Top N rows: highlighted with teal left border + bolder text */
.live-table-grid.has-ranking tr.rank-highlighted {
  border-left: 3px solid var(--teal-500, #2dd4bf);
  font-weight: 600;
}
.live-table-grid.has-ranking tr.rank-highlighted th,
.live-table-grid.has-ranking tr.rank-highlighted td {
  background: rgba(45, 212, 191, 0.04);
}
.live-table-grid.has-ranking tr.rank-highlighted .live-table-rank-cell {
  color: var(--teal-400, #2dd4bf);
  font-size: 0.9rem;
}

/* Rank 1/2/3 get slightly more emphasis */
.live-table-grid.has-ranking tr.rank-highlighted[data-rank="1"] {
  border-left-color: #fbbf24; /* gold */
}
.live-table-grid.has-ranking tr.rank-highlighted[data-rank="1"] .live-table-rank-cell {
  color: #fbbf24;
}
.live-table-grid.has-ranking tr.rank-highlighted[data-rank="2"] {
  border-left-color: #94a3b8; /* silver */
}
.live-table-grid.has-ranking tr.rank-highlighted[data-rank="2"] .live-table-rank-cell {
  color: #94a3b8;
}
.live-table-grid.has-ranking tr.rank-highlighted[data-rank="3"] {
  border-left-color: #d97706; /* bronze */
}
.live-table-grid.has-ranking tr.rank-highlighted[data-rank="3"] .live-table-rank-cell {
  color: #d97706;
}

/* Rows outside top N: de-emphasized */
.live-table-grid.has-ranking tr.rank-dimmed {
  opacity: 0.5;
  font-size: 0.9em;
}
.live-table-grid.has-ranking tr.rank-dimmed th,
.live-table-grid.has-ranking tr.rank-dimmed td {
  color: var(--text-tertiary, #707075);
}

/* Divider between top N and the rest */
.live-table-grid.has-ranking tr.rank-divider td,
.live-table-grid.has-ranking tr.rank-divider th {
  border-top: 2px dashed var(--border-secondary, rgba(150, 150, 155, 0.3));
}

/* ============================================================
   Claude-flow rail — chat-panel-UI branch
   ------------------------------------------------------------
   Inspired by Claude's chat panel: tool calls and thinking
   sections sit on a single faint vertical rail, no longer each
   in their own bulky glass card. Glass only appears on expand,
   so multi-step sequences read as one continuous flow.

   The DeepInsights disc + friendly label (the "header") are
   preserved — the user explicitly said those are perfect. What
   changes is the chrome AROUND them: kill the per-card border /
   radius / shadow / large margins; add a rail; add a halo on
   each disc so the rail line visually passes through.

   Scoped to `.messages-container .message.assistant
   .message-content …` so user bubbles and non-chat surfaces
   are completely untouched. To revert: delete this whole block.
   ============================================================ */

.messages-container .message.assistant .message-content {
  position: relative;
  padding-left: 32px;
}

/* The rail itself: vertical 1px gray line, faded at both ends */
.messages-container .message.assistant .message-content::before {
  content: '';
  position: absolute;
  left: 14px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: linear-gradient(
    to bottom,
    transparent 0,
    rgba(15, 23, 42, 0.14) 14px,
    rgba(15, 23, 42, 0.14) calc(100% - 14px),
    transparent 100%
  );
  pointer-events: none;
  z-index: 0;
}

/* ── Compact tool-call row (default state) ───────────────────
   Strip the glass card; just the disc + label + chevron sitting
   on the rail. Glass is restored on `.expanded` below. */
.messages-container .message.assistant .message-content .inline-tool-call {
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  border: none;
  border-radius: 12px;
  box-shadow: none;
  margin: 4px 0;
  padding: 0;
  overflow: visible;
  width: 100%;
}
.messages-container .message.assistant .message-content .inline-tool-call:hover {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.messages-container .message.assistant .message-content .inline-tool-call .inline-tool-header {
  padding: 6px 10px 6px 0;
  min-height: 36px;
  background: transparent;
  gap: 12px;
  border-radius: 10px;
  transition: background 160ms ease;
}
.messages-container .message.assistant .message-content .inline-tool-call .inline-tool-header:hover {
  background: rgba(15, 23, 42, 0.03);
}

/* Disc sits ON the rail — the halo punches a hole so the line
   visually passes through the node */
.messages-container .message.assistant .message-content .inline-tool-call .tool-icon-disc {
  position: relative;
  z-index: 1;
  box-shadow:
    0 0 0 4px var(--bg-cream, #f4f5f7),
    0 1px 3px rgba(0, 0, 0, 0.08);
}

.messages-container .message.assistant .message-content .inline-tool-call .tool-friendly {
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(15, 23, 42, 0.72);
  letter-spacing: 0.01em;
}
.messages-container .message.assistant .message-content .inline-tool-call .inline-tool-header:hover .tool-friendly {
  color: rgba(15, 23, 42, 0.92);
}

.messages-container .message.assistant .message-content .inline-tool-call .expand-icon {
  width: 14px;
  height: 14px;
  color: rgba(15, 23, 42, 0.35);
}

/* Tiny status chip — sits before the chevron once the call
   completes. Pure CSS via [data-status]. */
.messages-container .message.assistant .message-content .inline-tool-call[data-status="success"] .inline-tool-header::after,
.messages-container .message.assistant .message-content .inline-tool-call[data-status="error"]   .inline-tool-header::after {
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  font-size: 10.5px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  margin-right: 4px;
  flex-shrink: 0;
}
.messages-container .message.assistant .message-content .inline-tool-call[data-status="success"] .inline-tool-header::after {
  content: 'Result';
  color: rgba(15, 23, 42, 0.5);
  background: rgba(15, 23, 42, 0.05);
}
.messages-container .message.assistant .message-content .inline-tool-call[data-status="error"] .inline-tool-header::after {
  content: 'Error';
  color: #c0492b;
  background: rgba(192, 73, 43, 0.08);
}

/* ── Expanded state: glass body slides in ─────────────────── */
.messages-container .message.assistant .message-content .inline-tool-call.expanded {
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.04),
    0 6px 16px -4px rgba(0, 0, 0, 0.06),
    inset 0 0.5px 0 rgba(255, 255, 255, 0.5);
  margin: 10px 0;
  overflow: hidden;
}
.messages-container .message.assistant .message-content .inline-tool-call.expanded .inline-tool-header {
  padding: 12px 16px;
}

/* ── Thinking section sits on the rail too ────────────────── */
.messages-container .message.assistant .message-content .thinking-section {
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  border: none;
  border-radius: 12px;
  box-shadow: none;
  margin: 4px 0;
  padding: 0;
  overflow: visible;
}
.messages-container .message.assistant .message-content .thinking-section[open] {
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.04),
    0 6px 16px -4px rgba(0, 0, 0, 0.05),
    inset 0 0.5px 0 rgba(255, 255, 255, 0.5);
  margin: 10px 0;
  overflow: hidden;
}

.messages-container .message.assistant .message-content .thinking-section .thinking-header {
  padding: 6px 10px 6px 0;
  min-height: 36px;
  background: transparent;
  border-radius: 10px;
  transition: background 160ms ease;
}
.messages-container .message.assistant .message-content .thinking-section[open] .thinking-header {
  padding: 12px 16px;
}
.messages-container .message.assistant .message-content .thinking-section .thinking-header:hover {
  background: rgba(15, 23, 42, 0.03);
}

.messages-container .message.assistant .message-content .thinking-section .thinking-label {
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(15, 23, 42, 0.65);
  letter-spacing: 0.01em;
}

/* Synthesized clock glyph for thinking summaries that don't
   already carry a DeepInsights disc. Wrapped in a 28px disc-
   shaped halo so it sits on the rail identically to tool discs. */
.messages-container .message.assistant .message-content .thinking-section .thinking-header::before {
  content: '';
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-color: var(--bg-cream, #f4f5f7);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235c5f66' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='9'/><polyline points='12 7 12 12 15 14'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 14px;
  box-shadow:
    0 0 0 4px var(--bg-cream, #f4f5f7),
    inset 0 0 0 1px rgba(15, 23, 42, 0.10);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
/* If a real disc already exists in the thinking-header, hide the
   synthesized clock and let the disc carry the rail node */
.messages-container .message.assistant .message-content .thinking-section .thinking-header:has(.tool-icon-disc)::before {
  display: none;
}
.messages-container .message.assistant .message-content .thinking-section .thinking-header .tool-icon-disc {
  position: relative;
  z-index: 1;
  box-shadow:
    0 0 0 4px var(--bg-cream, #f4f5f7),
    0 1px 3px rgba(0, 0, 0, 0.08);
}

/* ── Tighter rhythm between consecutive rail nodes ────────── */
.messages-container .message.assistant .message-content .inline-tool-call + .inline-tool-call,
.messages-container .message.assistant .message-content .inline-tool-call + .thinking-section,
.messages-container .message.assistant .message-content .thinking-section + .inline-tool-call,
.messages-container .message.assistant .message-content .thinking-section + .thinking-section {
  margin-top: 2px;
}

/* Prose flows naturally on the rail — no extra padding needed
   because .message-content already has padding-left: 32px */
.messages-container .message.assistant .message-content .markdown-content {
  position: relative;
  z-index: 0;
}

/* Status-thinking-card (the live gold pill): keep its own
   chrome, but let the rail pass through its left edge and put
   a halo on its disc */
.messages-container .message.assistant .message-content .status-thinking-card {
  margin-left: 0;
}
.messages-container .message.assistant .message-content .status-thinking-card .tool-icon-disc {
  position: relative;
  z-index: 1;
  box-shadow:
    0 0 0 4px var(--bg-cream, #f4f5f7),
    0 1px 3px rgba(0, 0, 0, 0.08);
}

/* ============================================================
   Canonical-MCP citation hover pill — chat-panel-UI branch
   ------------------------------------------------------------
   The [N] anchor's hover pill used to echo the raw slot_id
   (e.g. tata_motors.ev.fy26m3.monthly_sales_volume). Government
   readers should never see that handle (feedback_ui_rules).

   When decorateCitationsWithSlotTooltips() resolved the slot's
   chosen_source through the canonical-MCP humanizer, it stamps
   data-cite-source-tag (e.g. "RBI") + data-cite-source-name
   (e.g. "Reserve Bank of India") on the anchor. This rule
   replaces the pill's content with that pair, so a hover shows:

       RBI · Reserve Bank of India

   Anchors without a humanized source fall through to the existing
   slot_id pill (older rule above). To revert: delete this block.
   ============================================================ */
a.cite-with-slot[data-cite-source-tag]::after {
  content: attr(data-cite-source-tag) "  ·  " attr(data-cite-source-name);
}

/* ============================================================
   Nexus card-stream (CARD_STREAM_SPEC.md) — structured god-mode
   progress: objective scorecard + per-tool-call cards. Flag-gated
   (GOD_MODE_CARD_STREAM); renders only when msg.nexusCardStream exists.
   ============================================================ */
.ncs {
  /* Anthropic brand palette — SCOPED to the card-stream surface only (the platform
     teal elsewhere is untouched). Clay #d97757 is the primary accent; warm ink on
     ivory washes; blue for links, green for "grounded". */
  --ant-dark: #141413;        /* titles */
  --ant-ink: #2b2a27;         /* body text */
  --ant-muted: #6e6c64;       /* secondary text */
  --ant-faint: #76736b;       /* tertiary / timestamps (darkened to clear WCAG-AA on white) */
  --ant-clay: #d97757;        /* primary accent — source badge, progress, summary */
  --ant-link: #4d77ad;        /* links / citations (readable on white) */
  --ant-green: #788c5d;       /* grounded / ok */
  --ant-amber: #bf8a3c;       /* partial */
  --ant-gap: #c56a4a;         /* gap / error */
  --ant-line: rgba(20,20,19,0.10);
  --ant-line-soft: rgba(20,20,19,0.07);
  --ant-wash: rgba(217,119,87,0.06);
  --ant-wash-line: rgba(217,119,87,0.20);
  margin: 6px 0 14px; display: flex; flex-direction: column; gap: 10px;
}

/* Scorecard — objective coverage panel (§5) */
.ncs-scorecard { border: 1px solid var(--ant-wash-line); border-radius: 12px; background: var(--ant-wash); padding: 12px 14px; }
.ncs-sc__head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.ncs-sc__title { font-weight: 600; font-size: 13.5px; color: var(--ant-dark); letter-spacing: .01em; }
.ncs-sc__count { font-size: 12px; color: var(--ant-muted); font-variant-numeric: tabular-nums; }
.ncs-conf--low { color: var(--ant-amber); } .ncs-conf--med { color: var(--ant-link); } .ncs-conf--high { color: var(--ant-green); }
.ncs-sc__bar { height: 5px; border-radius: 999px; background: rgba(217,119,87,0.16); overflow: hidden; margin-bottom: 10px; }
.ncs-sc__bar > span { display: block; height: 100%; background: var(--ant-clay); border-radius: 999px; transition: width .35s ease; }
.ncs-sc__rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.ncs-sc-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ant-ink); }
.ncs-sc-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: #d3d0c6; }
.ncs-sc-row--grounded .ncs-sc-dot { background: var(--ant-green); }
.ncs-sc-row--partial  .ncs-sc-dot { background: var(--ant-amber); }
.ncs-sc-row--gap      .ncs-sc-dot { background: var(--ant-gap); }
.ncs-sc-row--pending  .ncs-sc-label { color: var(--ant-faint); }
.ncs-sc-label { flex: 1 1 auto; }
.ncs-sc-note { font-size: 11.5px; color: var(--ant-amber); }
.ncs-sc-src { font-size: 11.5px; color: var(--ant-muted); }
.ncs-opt { font-size: 11px; color: var(--ant-faint); }

/* DAG overview on the coverage card — parallel legs converging into a synthesis node.
   Uses the same --ant-* theme vars as the scorecard, so dark mode adapts automatically. */
.ncs-scorecard--dag { padding-bottom: 10px; }
/* Multi-DAG forest: one coverage card per independent DAG, stacked with a per-card state
   accent so completed DAGs visibly settle while others still run. */
.ncs-dags { display: flex; flex-direction: column; gap: 10px; }
.ncs-scorecard--dagmulti.is-done { border-color: var(--ant-green); }
.ncs-scorecard--dagmulti.is-failed { border-color: var(--ant-gap); }
/* DAG coverage card — the "lens": a Query origin FANS OUT to the parallel leg cards
   (divergence), which FAN IN to the synthesis (convergence). Left→right so the legs
   spread ACROSS the flow — that's what makes the diverge/converge read, and what sets it
   apart from the vertical node-progress lanes. The two fan SVGs are drawn from measured
   card centres by _drawDagLens (renderer.js) so any leg count / objective length aligns.
   Full objective always shown under each leg. Narrow panes fall back to .is-vertical. */
.ncs-dag--lens { display: flex; align-items: stretch; width: 100%; margin: 8px 0 4px; }
.ncs-dag__q, .ncs-dag__synth { display: flex; align-items: center; flex: 0 0 auto; }
.ncs-dag__q { flex-basis: 104px; }
.ncs-dag__synth { flex: 1 1 210px; min-width: 168px; }
.ncs-dag__fan { flex: 0 0 56px; align-self: stretch; position: relative; }
.ncs-dag__fan > svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible; }
.ncs-dag__legs { flex: 1 1 auto; min-width: 168px; display: flex; flex-direction: column; gap: 12px; }

.ncs-dag__node, .ncs-dag__endcard { box-sizing: border-box; border-radius: 14px; background: #fff;
  border: 1px solid var(--ant-line); padding: 9px 14px 11px; box-shadow: 0 1px 3px rgba(20,20,19,0.05); transition: border-color .2s ease; }
.ncs-dag__node--leg.is-running { border-color: rgba(217,119,87,0.38); }
.ncs-dag__node--leg.is-done    { border-color: var(--ant-green); }
.ncs-dag__node--leg.is-failed  { border-color: var(--ant-gap); }
.ncs-dag__endcard { width: 100%; background: var(--ant-wash); border-color: var(--ant-clay); }
.ncs-dag__synthcard { border-width: 1.5px; }
.ncs-dag__qsub { font-size: 11px; color: var(--ant-faint); line-height: 1.3; }

.ncs-dag__head { display: flex; align-items: center; gap: 8px; line-height: 1; margin-bottom: 5px; }
.ncs-dag__id { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ant-faint); }
.ncs-dag__node--leg.is-running .ncs-dag__id, .ncs-dag__endcard .ncs-dag__id { color: var(--ant-clay); }
.ncs-dag__node--leg.is-done .ncs-dag__id { color: var(--ant-green); }
.ncs-dag__badge { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--ant-green); font-variant-numeric: tabular-nums; }
.ncs-dag__node--leg.is-running .ncs-dag__badge { color: var(--ant-clay); }
.ncs-dag__node--leg.is-failed .ncs-dag__badge { color: var(--ant-gap); }
.ncs-dag__obj { font-size: 12.5px; line-height: 1.4; color: var(--ant-ink); overflow-wrap: anywhere; }
.ncs-dag__endcard .ncs-dag__obj { color: var(--ant-dark); }

/* Live flow packets running along the drawn fan curves (only while a leg still runs). */
.ncs-dag__flow path { stroke: #f2b79d; stroke-width: 2.4; fill: none; stroke-dasharray: 2 12; animation: ncsDagFlow 1.2s linear infinite; }
@keyframes ncsDagFlow { to { stroke-dashoffset: -14; } }
@keyframes ncsDagPulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

/* Narrow fallback — stack vertically with a straight gutter rail + station per card
   (the fans are hidden; _drawDagLens empties the SVGs below the width threshold). */
.ncs-dag--lens.is-vertical { flex-direction: column; align-items: stretch; gap: 12px; position: relative; padding-left: 34px; }
.ncs-dag--lens.is-vertical .ncs-dag__fan { display: none; }
.ncs-dag--lens.is-vertical .ncs-dag__q, .ncs-dag--lens.is-vertical .ncs-dag__synth { display: block; }
.ncs-dag--lens.is-vertical::before { content: ""; position: absolute; left: 14px; top: 24px; bottom: 24px; width: 2px; background: var(--ant-clay); border-radius: 2px; }
.ncs-dag--lens.is-vertical .ncs-dag__q .ncs-dag__endcard,
.ncs-dag--lens.is-vertical .ncs-dag__legs > .ncs-dag__node,
.ncs-dag--lens.is-vertical .ncs-dag__synth .ncs-dag__endcard { position: relative; }
.ncs-dag--lens.is-vertical .ncs-dag__q .ncs-dag__endcard::after,
.ncs-dag--lens.is-vertical .ncs-dag__legs > .ncs-dag__node::after,
.ncs-dag--lens.is-vertical .ncs-dag__synth .ncs-dag__endcard::after {
  content: ""; position: absolute; left: -25px; top: 22px; transform: translateY(-50%); z-index: 1;
  width: 11px; height: 11px; border-radius: 50%; box-sizing: border-box; background: #fff; border: 2px solid var(--ant-clay); }
.ncs-dag--lens.is-vertical .ncs-dag__node--leg.is-done::after { background: var(--ant-green); border-color: var(--ant-green); }
.ncs-dag--lens.is-vertical .ncs-dag__q .ncs-dag__endcard::after,
.ncs-dag--lens.is-vertical .ncs-dag__synth .ncs-dag__endcard::after { background: var(--ant-clay); }

/* Cards — one per tool call (§4) */
.ncs-cards { display: flex; flex-direction: column; gap: 8px; }
/* Per-branch lane header (compound-query fan-out). A slim divider row grouping the
   cards of one parallel sub-query under its objective. */
/* Sticky lane header — pins to the top of the scrolling progress pane as you read a node's
   cards, until the next node's header pushes it up, so the current node is always labelled.
   Opaque background (cards scroll UNDER it) + z-index above the cards. */
.ncs-lanehead { display: flex; align-items: center; gap: 8px; padding: 6px 10px; margin-top: 6px; border-radius: 8px; background: #FCF6F3; border: 1px solid var(--ant-wash-line); position: sticky; top: 0; z-index: 3; }
.ncs-lanehead:first-child { margin-top: 0; }
/* Collapse toggle — the header folds its node's progress. */
.ncs-lanehead[data-lane-head] { cursor: pointer; user-select: none; }
.ncs-lanehead[data-lane-head]:hover { border-color: var(--ant-clay); }
.ncs-lanehead[data-lane-head]:focus-visible { outline: 2px solid var(--ant-clay); outline-offset: 1px; }
.ncs-lanehead__chev { flex: 0 0 auto; font-size: 10px; line-height: 1; color: var(--ant-faint); transition: transform .18s ease; transform: rotate(90deg); }
.ncs-lanehead.is-lane-collapsed .ncs-lanehead__chev { transform: rotate(0deg); }
.ncs-lanehead__count { flex: 0 0 auto; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ant-green); }
.ncs-lanehead--running .ncs-lanehead__count { color: var(--ant-clay); }
.ncs-lanehead--failed .ncs-lanehead__count { color: var(--ant-gap); }
/* A collapsed header shouldn't dangle its subway rail down into the now-hidden cards. */
.ncs-lanehead.is-lane-collapsed.ncs-lane-item::before { display: none; }
.ncs-lanehead__badge { flex: 0 0 auto; width: 16px; text-align: center; font-size: 12px; font-weight: 700; color: var(--ant-muted, #6b6b68); }
.ncs-lanehead--done .ncs-lanehead__badge { color: #3B6D11; }
.ncs-lanehead--failed .ncs-lanehead__badge { color: #C56A4A; }
.ncs-lanehead__title { flex: 1 1 auto; min-width: 0; font-weight: 650; font-size: 12.5px; color: var(--ant-ink, #141413); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ncs-lanehead__meta { flex: 0 0 auto; font-size: 11px; color: var(--ant-muted, #6b6b68); }
.ncs-lanehead--running .ncs-lanehead__meta { opacity: .8; }
.ncs-lanescore { margin: 2px 0 2px 10px; }

/* ── Per-node subway rail ──────────────────────────────────────────────────
   A branch's members (lane head → its scorecard → its cards) are threaded on
   one continuous vertical line so a node's whole progress reads as a single
   track, visually distinct from its neighbours. The rail lives in a left
   gutter; each member carries a station dot; the line colour follows the
   lane's state. First/last members cap the rail at their own stations so it
   never bleeds into the next lane — the gap between rails IS the divider. */
/* Rail + stations live in a LEFT GUTTER (negative offsets → outside the card box), so the
   line runs beside the cards, never over them. margin-left opens the gutter; the card keeps
   its own padding. */
.ncs-lane-item { position: relative; margin-left: 28px; }
/* A lane head is also a lane-item (for its gutter rail), but must stay STICKY — re-assert it
   here at higher specificity so this later rule beats .ncs-lane-item's position:relative.
   Sticky still establishes the containing block the rail's ::before/::after position against. */
.ncs-lanehead.ncs-lane-item { position: sticky; }
.ncs-lanescore.ncs-lane-item { margin-left: 28px; }
.ncs-lane-item::before {          /* the rail segment (bridges the 8px flex gap both ends) */
  content: ""; position: absolute; left: -19px; width: 2px;
  top: -8px; bottom: -8px; background: var(--ant-wash-line); border-radius: 2px;
}
.ncs-lane--running::before { background: var(--ant-clay); }
.ncs-lane--done::before    { background: var(--ant-green); }
.ncs-lane--failed::before  { background: var(--ant-gap); }
.ncs-lane-item--first::before { top: 15px; }                 /* rail starts at the head station */
.ncs-lane-item--last::before  { top: -8px; bottom: auto; height: 23px; } /* …and stops at the last one */
.ncs-lane-item--first.ncs-lane-item--last::before { display: none; }     /* lone head → no line */
.ncs-lane-item::after {           /* the station (centred on the gutter rail) */
  content: ""; position: absolute; left: -23px; top: 15px; transform: translateY(-50%);
  width: 10px; height: 10px; border-radius: 50%; box-sizing: border-box;
  background: #fff; border: 2px solid var(--ant-wash-line);
}
.ncs-lane--running::after { border-color: var(--ant-clay); }
.ncs-lane--done::after    { border-color: var(--ant-green); }
.ncs-lane--failed::after  { border-color: var(--ant-gap); }
.ncs-lanehead.ncs-lane-item::after { background: var(--ant-clay); border-color: var(--ant-clay); }  /* origin = filled */
.ncs-lanehead.ncs-lane--done.ncs-lane-item::after   { background: var(--ant-green); border-color: var(--ant-green); }
.ncs-lanehead.ncs-lane--failed.ncs-lane-item::after { background: var(--ant-gap); border-color: var(--ant-gap); }
.ncs-lane--running.ncs-lane-item--last::after { animation: ncs-pulse 1.4s ease-in-out infinite; }  /* the live front */
.ncs-card { border: 1px solid var(--ant-line); border-radius: 12px; background: #fff; padding: 12px 14px; transition: border-color .15s ease, box-shadow .15s ease; }
.ncs-card:hover { border-color: rgba(217,119,87,0.30); box-shadow: 0 1px 3px rgba(20,20,19,0.05); }
.ncs-card--running { opacity: .7; }
.ncs-card--st-error, .ncs-card--st-gap { background: #FBF6F3; border-color: rgba(197,106,74,0.22); }
.ncs-card__head { display: flex; align-items: center; gap: 8px; }
.ncs-card__src { font-weight: 600; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ant-clay); }
.ncs-card__tool { font-size: 11.5px; color: var(--ant-muted); }
.ncs-card__status { width: 7px; height: 7px; border-radius: 50%; margin-left: auto; background: var(--ant-green); }
.ncs-card__status--running { background: var(--ant-amber); animation: ncs-pulse 1.1s ease-in-out infinite; }
.ncs-card__status--error, .ncs-card__status--gap { background: var(--ant-gap); }
@keyframes ncs-pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }
.ncs-elapsed { font-size: 11px; color: var(--ant-faint); font-variant-numeric: tabular-nums; }
.ncs-card__label { font-size: 13.5px; font-weight: 600; line-height: 1.45; color: var(--ant-dark); margin-top: 4px; letter-spacing: -.005em; }
.ncs-card__body { margin-top: 9px; }
/* Clean flowing prose for cards whose finding IS the source response (no structured body). */
.ncs-prose { margin-top: 9px; font-size: 13px; line-height: 1.6; color: var(--ant-ink); }
.ncs-prose > :first-child { margin-top: 0; }
.ncs-prose > :last-child { margin-bottom: 0; }
.ncs-prose p { margin: 0 0 8px; }
.ncs-prose ul, .ncs-prose ol { margin: 0 0 8px; padding-left: 18px; }
.ncs-prose li { margin: 2px 0; }
.ncs-prose strong { color: var(--ant-dark); font-weight: 600; }
.ncs-prose table { border-collapse: collapse; font-size: 12px; margin: 4px 0 8px; }
.ncs-prose th, .ncs-prose td { border: 1px solid var(--ant-line); padding: 3px 8px; text-align: left; }
.ncs-prose th { color: var(--ant-muted); font-weight: 600; }
/* Per-source inner tool TRACE + the FULL verbatim answer() response (god-mode canvas). */
.ncs-trace { margin: 6px 0 0; padding: 0 0 0 14px; list-style: none; font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ant-muted); }
.ncs-trace > li { margin: 1px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ncs-trace__tool { color: var(--ant-clay); }
.ncs-trace__args { opacity: .7; }
/* Cache-hit chip on a wave-progress trace step — the step re-served a prior
 * extraction instead of re-fetching. Quiet sage so it reads as an efficiency
 * affordance, not an alert; the shared (cross-pod GCS L2) variant is teal. */
.ncs-trace__cached {
  display: inline-block; margin-left: 6px; padding: 0 5px;
  font-size: 9.5px; font-weight: 600; letter-spacing: .01em;
  border-radius: 4px; vertical-align: baseline;
  background: #ECEFEB; color: #56664E; border: 1px solid #D9E0D2;
}
.ncs-trace__cached.is-shared { background: #E6F1EF; color: #1F635D; border-color: #CFE3DF; }
.ncs-response { margin-top: 9px; border-top: 1px solid var(--ant-line-soft); padding-top: 7px; }
.ncs-response > summary { cursor: pointer; font-size: 11px; font-weight: 500; color: var(--ant-faint); user-select: none; list-style: none; display: inline-flex; align-items: center; gap: 4px; transition: color .12s ease; }
.ncs-response > summary::-webkit-details-marker { display: none; }
.ncs-response > summary::before { content: "›"; display: inline-block; transition: transform .15s ease; font-size: 13px; line-height: 1; }
.ncs-response[open] > summary::before { transform: rotate(90deg); }
.ncs-response > summary:hover { color: var(--ant-clay); }
.ncs-response__body { margin-top: 8px; max-height: 360px; overflow: auto; font-size: 13px; line-height: 1.6; color: var(--ant-ink); }
.ncs-response__body table { border-collapse: collapse; }
.ncs-response__body th, .ncs-response__body td { border: 1px solid var(--ant-line); padding: 3px 7px; }
/* Bare = in-flight tool call with no result yet → a slim one-line row, not a full card.
   The pulsing status dot carries the "working" signal; no "working…" filler text, so the
   user never scrolls through a stack of identical empty cards (CARD_STREAM_SPEC §4). */
.ncs-card--bare { padding: 6px 12px; }
.ncs-card--bare .ncs-card__head { gap: 7px; }
.ncs-card--bare .ncs-card__status { margin-left: 0; }   /* dot leads the row, not pushed right */
.ncs-card__label--inline {
  flex: 1 1 auto;
  min-width: 0;
  margin-top: 0;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--ant-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ncs-chip { font-size: 10.5px; padding: 1px 6px; border-radius: 999px; background: rgba(106,155,204,0.14); color: var(--ant-link); }
.ncs-chip--secondary { background: rgba(217,119,87,0.16); color: #9c4a2a; }

/* Internal-steps strip — collapsed plumbing (ToolSearch / Agent / schema loads): one quiet
   line that conveys motion without a card per call (see _ncsStripHtml). */
.ncs-strip { display: flex; align-items: center; gap: 8px; padding: 5px 2px 2px; font-size: 12px; color: var(--ant-muted); }
.ncs-strip__dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; background: var(--ant-amber); animation: ncs-pulse 1.1s ease-in-out infinite; }
.ncs-strip__tx { color: var(--ant-muted); }
.ncs-strip__n { font-size: 11px; font-variant-numeric: tabular-nums; color: var(--ant-faint); background: rgba(20,20,19,0.05); border-radius: 999px; padding: 0 7px; }
.ncs-strip--done { color: var(--ant-faint); font-size: 11px; }
.ncs-strip--done .ncs-strip__n { background: transparent; padding: 0; color: var(--ant-faint); }

/* Card body — table */
.ncs-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.ncs-table th, .ncs-table td { padding: 4px 8px; border-bottom: 1px solid var(--ant-line-soft); text-align: left; }
.ncs-table th { color: var(--ant-muted); font-weight: 600; }
.ncs-table .ncs-num { text-align: right; font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.ncs-unit { color: var(--ant-faint); font-weight: 400; }
.ncs-note { font-size: 11px; color: var(--ant-faint); margin-top: 4px; font-style: italic; }

/* Card body — finding */
.ncs-facts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.ncs-fact-l { color: var(--ant-muted); } .ncs-fact-v { font-weight: 600; color: var(--ant-dark); } .ncs-fact-p { color: var(--ant-faint); }
.ncs-cite { font-size: 11px; color: var(--ant-link); text-decoration: none; }
.ncs-cite:hover { text-decoration: underline; }
.ncs-ctx { font-size: 12px; color: var(--ant-ink); margin-top: 6px; }
.ncs-quote { margin: 6px 0 0; padding: 4px 10px; border-left: 2px solid rgba(217,119,87,0.35); color: var(--ant-ink); font-size: 12px; }
.ncs-quote cite { display: block; font-size: 11px; color: var(--ant-faint); font-style: normal; margin-top: 2px; }
.ncs-caveat { font-size: 11px; color: var(--ant-amber); margin-top: 6px; }

/* Card body — sources */
.ncs-src-q { font-size: 11.5px; color: var(--ant-muted); margin-bottom: 4px; }
.ncs-sources { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; font-size: 12px; }
.ncs-src-link { color: var(--ant-link); text-decoration: none; }
.ncs-src-link:hover { text-decoration: underline; }
.ncs-src-meta { font-size: 11px; color: var(--ant-faint); }
.ncs-leads { font-size: 10.5px; color: var(--ant-faint); margin-top: 5px; font-style: italic; }

/* Card body — error */
.ncs-err { font-size: 12px; color: var(--ant-gap); }

/* Foot — terminal badge / heartbeat */
.ncs-term { font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: rgba(217,119,87,0.12); color: #b4623d; }
.ncs-term--stall, .ncs-term--deadline, .ncs-term--max_turns { background: rgba(191,138,60,0.15); color: var(--ant-amber); }
.ncs-term--error { background: rgba(197,106,74,0.13); color: var(--ant-gap); }
.ncs-tick { font-size: 11px; color: var(--ant-faint); }
.ncs-term-stats { font-size: 11px; color: var(--ant-muted); }

/* Settled recited summary (verified) */
.ncs-summary { padding: 11px 13px; border-radius: 12px; background: var(--ant-wash); border: 1px solid var(--ant-wash-line); }
.ncs-summary__head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.ncs-summary__lab { font-size: 12px; font-weight: 600; color: var(--ant-clay); }
.ncs-summary__tx { margin: 0; font-size: 12.5px; line-height: 1.6; color: var(--ant-ink); }

@media (prefers-color-scheme: dark) {
  .ncs-card { background: rgba(255,255,255,0.03); border-color: rgba(255,255,255,0.08); }
  .ncs-card:hover { border-color: rgba(217,119,87,0.34); box-shadow: none; }
  .ncs-scorecard, .ncs-summary { background: rgba(217,119,87,0.10); border-color: rgba(217,119,87,0.22); }
  .ncs-card__src, .ncs-summary__lab, .ncs-trace__tool { color: #e3906b; }   /* light clay accent */
  .ncs-sc__title, .ncs-card__label { color: #ECEAE3; }                      /* prominent titles */
  .ncs-prose strong, .ncs-fact-v { color: #F0EEE6; }
  .ncs-prose, .ncs-response__body, .ncs-sc-row, .ncs-quote, .ncs-summary__tx { color: #D2D0C8; }
  .ncs-ctx { color: #B0AEA5; }
  .ncs-strip__n { background: rgba(0,0,0,0.06); }
  .ncs-lane-item::after { background: #1f1e1c; }   /* hollow stations sit on the pane bg (state border still shows) */
  .ncs-lanehead { background: #26211F; }           /* opaque dark tint so cards scroll cleanly under the pinned header */
  .ncs-dag__node { background: rgba(255,255,255,0.03); border-color: rgba(255,255,255,0.09); }
  .ncs-dag__endcard { background: rgba(217,119,87,0.12); border-color: rgba(217,119,87,0.45); }
  .ncs-dag__obj { color: #D2D0C8; }
  .ncs-dag__endcard .ncs-dag__obj { color: #ECEAE3; }
  .ncs-dag--lens.is-vertical .ncs-dag__legs > .ncs-dag__node.is-running::after { background: #1f1e1c; }   /* hollow station on pane bg */
  
  /* EXCEPTION: Force light mode for Progress tab content even in dark mode.
   * Progress tab should look identical in both light and dark browser modes.
   * Override all NCS card stream dark mode styles when inside .canvas-progress. */
  .canvas-progress .ncs-card { background: #ffffff; border-color: rgba(26, 15, 5, 0.08); }
  .canvas-progress .ncs-card:hover { border-color: rgba(217, 119, 87, 0.22); box-shadow: 0 4px 10px rgba(26, 15, 5, 0.04); }
  .canvas-progress .ncs-scorecard,
  .canvas-progress .ncs-summary { background: rgba(217, 119, 87, 0.06); border-color: rgba(217, 119, 87, 0.18); }
  .canvas-progress .ncs-card__src,
  .canvas-progress .ncs-summary__lab,
  .canvas-progress .ncs-trace__tool { color: #d97757; }
  .canvas-progress .ncs-sc__title,
  .canvas-progress .ncs-card__label { color: #111318; }
  .canvas-progress .ncs-prose strong,
  .canvas-progress .ncs-fact-v { color: #111318; }
  .canvas-progress .ncs-prose,
  .canvas-progress .ncs-response__body,
  .canvas-progress .ncs-sc-row,
  .canvas-progress .ncs-quote,
  .canvas-progress .ncs-summary__tx { color: #3A3A3A; }
  .canvas-progress .ncs-ctx { color: #8B8E96; }
  .canvas-progress .ncs-strip__n { background: rgba(217, 119, 87, 0.08); }
  /* Station dots: match the light-mode base value (#fff with clay/green/gap border) */
  .canvas-progress .ncs-lane-item::after { background: #fff; }
  /* Lane head: match the light-mode warm-cream background exactly */
  .canvas-progress .ncs-lanehead { background: #FCF6F3; }
  .canvas-progress .ncs-dag__node { background: #ffffff; border-color: rgba(26, 15, 5, 0.09); }
  .canvas-progress .ncs-dag__endcard { background: rgba(217, 119, 87, 0.06); border-color: rgba(217, 119, 87, 0.24); }
  .canvas-progress .ncs-dag__obj { color: #3A3A3A; }
  .canvas-progress .ncs-dag__endcard .ncs-dag__obj { color: #111318; }
  /* Vertical-layout running-node station: match light-mode base value */
  .canvas-progress .ncs-dag--lens.is-vertical .ncs-dag__legs > .ncs-dag__node.is-running::after { background: #fff; }
}

/* ============================================================
   God-mode report theme (scoped) — centred analyst "brief".
   Applied only to .artifact-markdown.god-report (Nexus skill-md
   / compiler god_report). Everything is scoped so no other
   artifact type is affected. See _godReportEnhance in renderer.js.
   ============================================================ */
.artifact-markdown.god-report {
  background: #FBF8F1;
  color: #24201A;
  max-width: 920px;
  padding: 40px 56px 46px;
  font-family: 'Inter', 'Plus Jakarta Sans', system-ui, sans-serif;
}
/* Masthead ------------------------------------------------- */
.artifact-markdown.god-report .gr-mast {
  text-align: center;
  padding: 0 0 24px;
  border-bottom: 2px solid #1F1B15;
  margin: 0 0 26px;
}
.artifact-markdown.god-report .gr-tag {
  display: flex; align-items: center; justify-content: center;
  gap: 11px; margin: 0 0 20px;
}
.artifact-markdown.god-report .gr-pill {
  font-size: 10px; letter-spacing: .16em; text-transform: uppercase;
  color: #FBF8F1; background: #C15122; font-weight: 700;
  padding: 4px 11px; border-radius: 5px;
}
.artifact-markdown.god-report .gr-kick {
  font-size: 11px; letter-spacing: .19em; text-transform: uppercase;
  color: #8A6535; font-weight: 700;
}
.artifact-markdown.god-report .gr-title {
  font-family: 'Newsreader', 'Fraunces', Georgia, serif;
  font-size: 40px; line-height: 1.1; font-weight: 600; color: #1B1712;
  margin: 0 auto 15px; letter-spacing: -.016em; max-width: 22ch;
  border: 0; padding: 0;
}
.artifact-markdown.god-report .gr-deck {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 18px; line-height: 1.5; color: #635846; font-weight: 400;
  margin: 0 auto 20px; max-width: 54ch;
}
.artifact-markdown.god-report .gr-meta {
  font-size: 10.5px; letter-spacing: .09em; color: #9A8C74;
  font-weight: 600; text-transform: uppercase;
}
/* KPI band ------------------------------------------------- */
.artifact-markdown.god-report .gr-band {
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid #1F1B15; border-bottom: 1px solid #1F1B15;
  margin: 0 0 34px;
}
.artifact-markdown.god-report .gr-st {
  padding: 18px 14px 16px; border-right: .5px solid #E4D9C4;
  text-align: center;
}
.artifact-markdown.god-report .gr-st:last-child { border-right: 0; }
.artifact-markdown.god-report .gr-l {
  font-size: 10px; letter-spacing: .13em; text-transform: uppercase;
  color: #9A8C74; font-weight: 700; margin: 0 0 9px;
}
.artifact-markdown.god-report .gr-n {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 32px; font-weight: 600; color: #C15122;
  line-height: 1; letter-spacing: -.01em;
}
.artifact-markdown.god-report .gr-u { font-size: 16px; color: #D08A5E; margin-left: 1px; }
/* Section headers ----------------------------------------- */
.artifact-markdown.god-report h2 {
  font-family: 'Inter', 'Plus Jakarta Sans', sans-serif;
  font-size: 12px; letter-spacing: .16em; text-transform: uppercase;
  color: #1B1712; font-weight: 700; margin: 30px 0 15px;
  padding: 0; border: 0; display: flex; align-items: center; gap: 11px;
}
.artifact-markdown.god-report h2::before {
  content: ""; width: 20px; height: 3px; background: #C15122;
  border-radius: 2px; flex: none;
}
.artifact-markdown.god-report h3 {
  font-family: 'Inter', sans-serif; font-size: 11px; letter-spacing: .12em;
  text-transform: uppercase; color: #8A6535; font-weight: 700; margin: 22px 0 10px;
}
/* Body ----------------------------------------------------- */
.artifact-markdown.god-report p {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 16.5px; line-height: 1.7; color: #2E281F; margin: 0 0 15px;
}
.artifact-markdown.god-report p strong,
.artifact-markdown.god-report p b { color: #1B1712; font-weight: 600; }
.artifact-markdown.god-report .gr-lead::first-letter {
  -webkit-initial-letter: 2.5; initial-letter: 2.5;
  font-weight: 600; color: #C15122; margin-right: 9px;
  font-family: 'Newsreader', Georgia, serif;
}
/* Bottom-line callout ------------------------------------- */
.artifact-markdown.god-report .gr-bl {
  background: #F5EAD8; border-left: 4px solid #C15122;
  border-radius: 0 9px 9px 0; padding: 16px 22px; margin: 0 0 26px;
  font-size: 17px; line-height: 1.5; color: #2E2519;
}
.artifact-markdown.god-report .gr-bl strong,
.artifact-markdown.god-report .gr-bl b { color: #B0561F; }
/* Source chips -------------------------------------------- */
.artifact-markdown.god-report .gr-src {
  display: inline-block; font-family: 'Inter', sans-serif;
  font-size: 9.5px; letter-spacing: .04em; font-weight: 700;
  text-transform: uppercase; color: #8A5A2B; background: #EFE1CB;
  border-radius: 4px; padding: 1px 7px; vertical-align: 1px;
  margin: 0 1px; white-space: nowrap;
}
/* Lists — match body prose (container is Inter; p overrides to Newsreader) */
.artifact-markdown.god-report ul,
.artifact-markdown.god-report ol {
  padding-left: 24px;
  margin: 0 0 15px;
  font-family: 'Newsreader', Georgia, serif;
  font-size: 16.5px;
  line-height: 1.7;
  color: #2E281F;
}
.artifact-markdown.god-report li { margin: 4px 0; }
.artifact-markdown.god-report li > p {
  margin: 0;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}

/* Tables --------------------------------------------------- */
.artifact-markdown.god-report table {
  font-family: 'Newsreader', Georgia, serif; font-size: 14px;
  border-collapse: collapse; width: 100%; margin: 4px 0 8px;
}
.artifact-markdown.god-report thead th {
  text-align: left; font-size: 10.5px; letter-spacing: .1em;
  text-transform: uppercase; color: #6A5D48; background: #EFE6D5;
  font-weight: 700; padding: 11px 15px; border: 0;
  border-bottom: 2px solid #C15122;
  font-family: inherit;
}
.artifact-markdown.god-report tbody td {
  padding: 12px 15px; border-bottom: .5px solid #E7DFCE; color: #2B2519;
}
.artifact-markdown.god-report tbody tr:last-child td { border-bottom: 0; }
.artifact-markdown.god-report tbody tr:nth-child(even) { background: rgba(31,27,21,.028); }

/* ═══════════════════════════════════════════════════════════════════════════
   DYNAMIC ISLAND — Background Processing Pill
   Floats fixed at the top center of the viewport (above all content).
   Hidden when there are no active background jobs. Expands on click to
   reveal the full job list.
   ═══════════════════════════════════════════════════════════════════════════ */

/* Outer container — fixed, centered, pointer events off while hidden */
.bg-island {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9000;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  font-family: inherit;
}
.bg-island[style*="display: none"],
.bg-island[style*="display:none"] {
  pointer-events: none;
}
.bg-island:not([style*="display: none"]) {
  pointer-events: auto;
}

/* ── Pill button ──────────────────────────────────────────────────────────── */
.bg-island-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px 9px 14px;
  border: 1px solid var(--border-light, #e2e4e9);
  border-radius: 100px;
  background: #ffffff;
  box-shadow:
    0 2px 12px rgba(0, 0, 0, 0.09),
    0 1px 3px rgba(0, 0, 0, 0.05);
  color: var(--text-primary, #111318);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  white-space: nowrap;
  transition:
    transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.2s ease,
    background 0.15s ease;
  animation: bg-island-enter 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.bg-island-pill:hover {
  background: var(--bg-cream, #f4f5f7);
  transform: scale(1.03);
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.12),
    0 1px 4px rgba(0, 0, 0, 0.06);
}
.bg-island-pill:active {
  transform: scale(0.97);
}
.bg-island-pill:focus-visible {
  outline: 2px solid rgba(192, 139, 92, 0.5);
  outline-offset: 2px;
}

@keyframes bg-island-enter {
  from {
    opacity: 0;
    transform: translateY(-12px) scale(0.88);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Spinner */
.bg-island-spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  border: 1.8px solid rgba(192, 139, 92, 0.3);
  border-top-color: var(--accent-coral, #c08b5c);
  border-radius: 50%;
  animation: bg-island-spin 0.85s linear infinite;
}
@keyframes bg-island-spin {
  to { transform: rotate(360deg); }
}

/* Label */
.bg-island-label {
  flex: 1;
  min-width: 0;
  text-overflow: ellipsis;
  overflow: hidden;
  color: var(--text-primary, #111318);
}

/* Chevron */
.bg-island-chevron {
  flex-shrink: 0;
  color: var(--text-secondary, #5c5f66);
  opacity: 0.6;
  transition: transform 0.25s ease, opacity 0.2s ease;
}
.bg-island-pill[aria-expanded="true"] .bg-island-chevron {
  transform: rotate(180deg);
  opacity: 1;
}

/* ── Expanded panel ───────────────────────────────────────────────────────── */
.bg-island-panel {
  margin-top: 8px;
  width: 320px;
  background: #ffffff;
  border: 1px solid var(--border-light, #e2e4e9);
  border-radius: 18px;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.1),
    0 2px 8px rgba(0, 0, 0, 0.06);
  overflow: hidden;
  /* collapsed state */
  opacity: 0;
  transform: translateY(-8px) scale(0.97);
  pointer-events: none;
  max-height: 0;
  transition:
    opacity 0.22s ease,
    transform 0.25s cubic-bezier(0.34, 1.2, 0.64, 1),
    max-height 0.28s ease;
}
.bg-island-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  max-height: 480px;
}

/* Panel header */
.bg-island-panel-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border-light, #e2e4e9);
}
.bg-island-panel-title {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary, #111318);
  letter-spacing: 0.01em;
}
.bg-island-panel-sub {
  display: block;
  font-size: 11px;
  color: var(--text-tertiary, #8b8e96);
  margin-top: 2px;
}

/* Job list */
.bg-island-jobs {
  list-style: none;
  margin: 0;
  padding: 4px 0 6px;
  max-height: 320px;
  overflow-y: auto;
}
.bg-island-jobs::-webkit-scrollbar { width: 3px; }
.bg-island-jobs::-webkit-scrollbar-thumb { background: var(--border-light, #e2e4e9); border-radius: 2px; }

/* Job row */
.bg-island-job {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.12s ease;
}
.bg-island-job:hover,
.bg-island-job:focus-visible {
  background: var(--bg-cream, #f4f5f7);
  outline: none;
}
.bg-island-job:focus-visible {
  box-shadow: inset 0 0 0 1px rgba(192, 139, 92, 0.4);
}

/* Job icon — always a pulsing amber dot (background status only) */
.bg-island-job-icon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--accent-coral, #c08b5c);
  animation: bg-island-dot-pulse 2s ease-in-out infinite;
}

@keyframes bg-island-dot-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.7); }
}

/* Job text */
.bg-island-job-body {
  flex: 1;
  min-width: 0;
}
.bg-island-job-title {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-primary, #111318);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bg-island-job-meta {
  display: block;
  font-size: 10.5px;
  color: var(--text-tertiary, #8b8e96);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Status chip — only one value: "background" */
.bg-island-chip {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  letter-spacing: 0.03em;
  background: rgba(192, 139, 92, 0.12);
  color: var(--accent-coral-dark, #a87644);
}

/* Arrow — shown on hover */
.bg-island-job-arrow {
  flex-shrink: 0;
  opacity: 0;
  color: var(--text-tertiary, #8b8e96);
  transition: opacity 0.12s ease;
}
.bg-island-job:hover .bg-island-job-arrow,
.bg-island-job:focus-visible .bg-island-job-arrow { opacity: 1; }

/* ── "N completed" flash label inside the pill ───────────────────────────────
 * Briefly replaces the count label after a count decrease, then fades back.
 * JS adds .is-completed-flash and removes it after the animation ends.
 * ────────────────────────────────────────────────────────────────────────── */
.bg-island-pill.is-completed-flash .bg-island-label {
  color: #15803d;
  font-weight: 600;
}
.bg-island-pill.is-completed-flash .bg-island-spinner {
  border-color: rgba(34, 197, 94, 0.25);
  border-top-color: #22c55e;
}

/* ── Background-processing notice banner ─────────────────────────────────────
 * Sits between #chatMessages and .chat-input-wrapper.
 * Completely separate from the chat DOM — never interferes with streaming.
 * ─────────────────────────────────────────────────────────────────────────── */
.bg-chat-notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0 16px 12px;
  padding: 14px 18px;
  background: #ffffff;
  border: 1px solid var(--border-light, #e2e4e9);
  border-left: 3px solid var(--accent-coral, #c08b5c);
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  animation: bg-chat-notice-in 0.25s cubic-bezier(0.34, 1.2, 0.64, 1) both;
}
@keyframes bg-chat-notice-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Spinner */
.bg-chat-notice-spinner {
  flex-shrink: 0;
  margin-top: 2px;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(192, 139, 92, 0.25);
  border-top-color: var(--accent-coral, #c08b5c);
  border-radius: 50%;
  animation: bg-island-spin 0.9s linear infinite;
}

/* Body */
.bg-chat-notice-body {
  flex: 1;
  min-width: 0;
}
.bg-chat-notice-title {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary, #111318);
  margin-bottom: 3px;
}
.bg-chat-notice-sub {
  display: block;
  font-size: 12px;
  color: var(--text-secondary, #5c5f66);
  line-height: 1.55;
}

/* ── System notice message (rendered inside the chat bubble area) ──────────── */
.message.system-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  margin: 8px 0;
  background: rgba(217, 119, 87, 0.08);
  border: 1px solid rgba(217, 119, 87, 0.2);
  border-radius: 10px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.65);
  line-height: 1.55;
}
.message.system-notice .system-notice-icon {
  flex-shrink: 0;
  margin-top: 2px;
  width: 16px;
  height: 16px;
  color: #c15122;
}
.message.system-notice .system-notice-content {
  flex: 1;
}

/* ══════════════════════════════════════════════════════════════════════
 * Library File Manager  (.lfm-*)
 *
 * A 3-level file-manager on the My Files / Artifacts tab:
 *   Level 0  Chat folders
 *   Level 1  Turn folders (per AI turn)
 *   Level 2  Artifact file rows
 *
 * Single-click file → highlight  |  Double-click file → open chat canvas
 * Select mode: checkbox per file, floating Transform bar.
 * ════════════════════════════════════════════════════════════════════ */

/* -- Root container -------------------------------------------------- */
.lfm-root {
  display: flex;
  flex-direction: column;
  min-height: 200px;
  position: relative;
}

/* -- Header (breadcrumb + actions) ----------------------------------- */
.lfm-header {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  padding: 0 0 18px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.lfm-breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
}

.lfm-bc-crumb {
  background: none;
  border: none;
  padding: 3px 6px;
  border-radius: 5px;
  color: var(--text-tertiary);
  cursor: pointer;
  font: inherit;
  letter-spacing: inherit;
  transition: color 0.13s, background 0.13s;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lfm-bc-crumb:hover { color: var(--text-primary); background: rgba(0,0,0,0.04); }
.lfm-bc-crumb--active {
  color: var(--text-primary);
  font-weight: 600;
  cursor: default;
  background: none;
}
.lfm-bc-crumb--active:hover { background: none; }

.lfm-bc-sep {
  color: var(--text-tertiary);
  font-size: 16px;
  line-height: 1;
  user-select: none;
  opacity: 0.5;
}

.lfm-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Select toggle button */
.lfm-select-toggle {
  background: transparent;
  border: 1.5px solid var(--border-light);
  border-radius: 8px;
  padding: 5px 14px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.lfm-select-toggle:hover,
.lfm-select-toggle.active {
  border-color: var(--brand-indigo);
  color: var(--brand-indigo);
  background: rgba(42, 56, 153, 0.05);
}

/* -- Body (list area) ------------------------------------------------ */
.lfm-body {
  flex: 1;
  padding-top: 4px;
}

.lfm-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* -- Empty / loading / error states ---------------------------------- */
.lfm-empty {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 32px 8px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.lfm-error { color: #b03a2e; }

/* Spinner animation for loading state */
@keyframes lfm-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.lfm-spin { animation: lfm-spin 0.9s linear infinite; }

/* -- Shared row styles (folders + files) ----------------------------- */
.lfm-folder-row,
.lfm-file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s, box-shadow 0.12s;
  border: 1px solid transparent;
  user-select: none;
  min-height: 44px;
}

.lfm-folder-row:hover {
  background: rgba(42, 56, 153, 0.04);
  border-color: rgba(42, 56, 153, 0.08);
}
.lfm-folder-row:focus-visible {
  outline: 2px solid var(--brand-indigo);
  outline-offset: 1px;
}

/* -- Folder row specific -------------------------------------------- */
.lfm-folder-icon-svg {
  color: var(--brand-indigo);
  opacity: 0.7;
  flex-shrink: 0;
}

/* Turn folder slightly muted */
.lfm-turn-row .lfm-folder-icon-svg {
  color: var(--accent-coral);
  opacity: 0.6;
}

.lfm-row-chevron {
  flex-shrink: 0;
  color: var(--text-tertiary);
  margin-left: auto;
  opacity: 0.5;
  transition: transform 0.15s;
}
.lfm-folder-row:hover .lfm-row-chevron { opacity: 1; transform: translateX(2px); }

/* -- File row specific ---------------------------------------------- */
.lfm-file-icon {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.lfm-file-icon-svg {
  color: var(--text-secondary);
  opacity: 0.7;
}

.lfm-type-badge {
  position: absolute;
  bottom: -4px;
  right: -6px;
  background: var(--brand-indigo);
  color: #fff;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 1px 3px;
  border-radius: 3px;
  line-height: 1.4;
  white-space: nowrap;
}

.lfm-file-hint {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  opacity: 0;
  margin-left: auto;
  flex-shrink: 0;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.lfm-file-row:hover .lfm-file-hint { opacity: 0.8; }

.lfm-file-row:hover {
  background: rgba(0,0,0,0.025);
}

/* Highlighted (single-clicked) */
.lfm-file-row--highlighted {
  background: rgba(42, 56, 153, 0.06);
  border-color: rgba(42, 56, 153, 0.15);
}
.lfm-file-row--highlighted:hover {
  background: rgba(42, 56, 153, 0.09);
}

/* Focus visible */
.lfm-file-row:focus-visible {
  outline: 2px solid var(--brand-indigo);
  outline-offset: 1px;
}

/* Double-click target zone hint */
.lfm-file-row:active {
  transform: scale(0.993);
}

/* -- Shared row internals ------------------------------------------- */
.lfm-row-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
}

.lfm-row-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: 'Inter', 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}

.lfm-row-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
  padding-right: 4px;
}

.lfm-row-count {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  color: var(--text-tertiary);
  letter-spacing: 0.04em;
  background: rgba(0,0,0,0.04);
  padding: 2px 6px;
  border-radius: 5px;
}

.lfm-row-dot {
  color: var(--text-tertiary);
  opacity: 0.4;
  font-size: 13px;
}

.lfm-row-date {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  color: var(--text-tertiary);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* -- Select mode ---------------------------------------------------- */

/* Checkbox area */
.lfm-row-check {
  display: none;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  position: relative;
}

/* Show checkboxes only when select mode is active */
.lfm--select-mode .lfm-files-list .lfm-file-row .lfm-row-check {
  display: flex;
}

.lfm-check-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--border-light);
  transition: border-color 0.13s, background 0.13s;
}

.lfm-check-tick {
  position: relative;
  z-index: 1;
  opacity: 0;
  color: #fff;
  transition: opacity 0.13s;
}

.lfm-file-row--selected .lfm-check-ring {
  background: var(--brand-indigo);
  border-color: var(--brand-indigo);
}
.lfm-file-row--selected .lfm-check-tick { opacity: 1; }
.lfm-file-row--selected {
  background: rgba(42, 56, 153, 0.07);
  border-color: rgba(42, 56, 153, 0.18);
}
.lfm-file-row--selected:hover {
  background: rgba(42, 56, 153, 0.10);
}

/* In select mode: clicking file rows toggles selection; cursor shows it */
.lfm--select-mode .lfm-file-row { cursor: pointer; }
/* Hide double-click hint in select mode */
.lfm--select-mode .lfm-file-hint { display: none; }

/* -- Floating selection bar ----------------------------------------- */
.lfm-select-bar {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 12px) scale(0.95);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 24px;
  background: var(--bg-primary);
  border: 1.5px solid var(--border-light);
  border-radius: 32px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  z-index: 30;
  /* Hidden by default; shown via .lfm-select-bar--visible */
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.lfm-select-bar--visible {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
  pointer-events: auto;
}

.lfm-select-bar-count {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.lfm-select-bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lfm-cancel-select-btn {
  background: transparent;
  border: 1.5px solid var(--border-light);
  border-radius: 8px;
  padding: 7px 16px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.lfm-cancel-select-btn:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

.lfm-transform-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 18px;
  background: var(--brand-indigo);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  letter-spacing: 0.02em;
}
.lfm-transform-btn:hover:not(:disabled) {
  opacity: 0.88;
}
.lfm-transform-btn:active:not(:disabled) { transform: scale(0.96); }
.lfm-transform-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* -- Responsive tweaks ---------------------------------------------- */
@media (max-width: 640px) {
  .lfm-row-date,
  .lfm-row-dot { display: none; }
  .lfm-file-hint { display: none; }
  .lfm-row-count { display: none; }
}

/* -- Multi-Tab Library UI -- */
.library-multi-tab-bar {
  display: flex;
  align-items: center;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
  padding: 8px 16px 0 16px;
  gap: 6px;
}
.library-tabs-list {
  display: flex;
  gap: 6px;
  overflow-x: auto;
}
.library-tabs-list::-webkit-scrollbar { display: none; }
.library-tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  padding: 8px 16px;
  border-radius: 8px 8px 0 0;
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.library-tab-btn:hover {
  background: rgba(0,0,0,0.03);
}
.library-tab-btn.active {
  background: var(--bg-primary);
  border-color: var(--border-light);
  color: var(--text-primary);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.02);
}
.library-tab-close {
  opacity: 0.5;
  font-size: 16px;
  line-height: 1;
}
.library-tab-close:hover { opacity: 1; color: #b03a2e; }
.library-tab-add {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  margin-bottom: 4px;
}
.library-tab-add:hover { background: rgba(0,0,0,0.05); color: var(--text-primary); }

.library-multi-tab-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
.library-multi-tab-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Updated Group Headers */
.lfm-group-header {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 16px 20px 8px;
  border-bottom: 1px solid var(--border-light);
  margin-top: 8px;
}

/* -- Transform Overlay Target Chat ----------------------------------------- */
.at-target-chat-wrapper {
  margin: -8px 0 16px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
}
.at-overlay.at-from-chat .at-target-chat-wrapper {
  display: none;
}
.at-target-chat-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}
.at-target-chat-select {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}
.at-target-chat-select:focus {
  border-color: var(--accent-primary);
}


/* -- File Manager: Context Menu, Move Overlay, Grid Layout --------------- */

/* ── Context Menu ─────────────────────────────────────────────────────── */
.lfm-ctx-menu {
  position: fixed;
  z-index: 99999;
  min-width: 180px;
  background: var(--bg-primary, #ffffff);
  border: 1px solid var(--border-light, #eaeaea);
  border-radius: 8px;
  padding: 4px 0;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35), 0 2px 8px rgba(0,0,0,0.2);
  animation: lfm-ctx-in 0.12s ease-out;
}
@keyframes lfm-ctx-in {
  from { opacity: 0; transform: scale(0.95) translateY(-4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.lfm-ctx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 14px;
  border: none;
  background: none;
  color: var(--text-primary, #1F1B17);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
}
.lfm-ctx-item:hover {
  background: var(--bg-hover, rgba(0,0,0,0.06));
}
.lfm-ctx-item--danger {
  color: #ef4444;
}
.lfm-ctx-item--danger:hover {
  background: rgba(239,68,68,0.1);
}
.lfm-ctx-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.7;
}
.lfm-ctx-item:hover .lfm-ctx-icon { opacity: 1; }
.lfm-ctx-sep {
  height: 1px;
  background: var(--border-light, #eaeaea);
  margin: 4px 10px;
}

/* ── Move Overlay ─────────────────────────────────────────────────────── */
.lfm-move-overlay {
  position: fixed;
  inset: 0;
  z-index: 99998;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: lfm-fade-in 0.15s ease-out;
}
@keyframes lfm-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.lfm-move-panel {
  width: min(520px, 90vw);
  max-height: 70vh;
  background: var(--bg-primary, #ffffff);
  border: 1px solid var(--border-light, #eaeaea);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0,0,0,0.4);
  animation: lfm-panel-in 0.2s ease-out;
}
@keyframes lfm-panel-in {
  from { transform: translateY(16px) scale(0.97); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.lfm-move-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border-light, #eaeaea);
}
.lfm-move-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary, #1F1B17);
}
.lfm-move-close {
  background: none;
  border: none;
  color: var(--text-tertiary, #888);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  border-radius: 4px;
  transition: background 0.15s;
}
.lfm-move-close:hover {
  background: var(--bg-hover, rgba(0,0,0,0.06));
  color: var(--text-primary);
}
.lfm-move-bc {
  padding: 8px 20px;
  font-size: 12px;
  color: var(--text-secondary, #aaa);
  border-bottom: 1px solid var(--border-light, #eaeaea);
}
.lfm-move-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
}
.lfm-move-body .lfm-folder-row {
  border-radius: 6px;
  padding: 10px 12px;
}
.lfm-folder-row--current {
  opacity: 0.55;
}
.lfm-move-current-tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary, #888);
  background: var(--bg-secondary, #f7f7f7);
  border-radius: 4px;
  padding: 2px 6px;
  margin-left: 8px;
}
.lfm-move-turn-row {
  cursor: pointer;
}
.lfm-move-turn-row:hover {
  background: var(--accent-primary, #3b82f6) !important;
  color: #fff !important;
}
.lfm-move-turn-row:hover .lfm-row-meta,
.lfm-move-turn-row:hover .lfm-row-name {
  color: #fff !important;
}

/* ── Grid Layout (folder/turns level) ─────────────────────────────────── */
.lfm-root.lfm-grid-mode .lfm-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  padding: 0 4px;
}
.lfm-root.lfm-grid-mode .lfm-folder-row {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 1px solid var(--border-light, #eaeaea);
  border-radius: 10px;
  padding: 20px 12px 16px;
  gap: 6px;
  height: auto;
}
.lfm-root.lfm-grid-mode .lfm-folder-row:hover {
  border-color: var(--accent-primary, #3b82f6);
  background: var(--bg-secondary, #f7f7f7);
}
.lfm-root.lfm-grid-mode .lfm-row-icon {
  margin-right: 0;
  margin-bottom: 4px;
}
.lfm-root.lfm-grid-mode .lfm-folder-icon-svg {
  width: 28px;
  height: 28px;
}
.lfm-root.lfm-grid-mode .lfm-row-name {
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  width: 100%;
  word-break: break-word;
}
.lfm-root.lfm-grid-mode .lfm-row-meta {
  font-size: 11px;
}
.lfm-root.lfm-grid-mode .lfm-row-chevron {
  display: none;
}

/* ── Layout Toggle Controls ───────────────────────────────────────────── */
.lfm-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 12px;
  padding: 0 16px;
}
.lfm-layout-toggle {
  display: flex;
  background: var(--bg-secondary, #f7f7f7);
  border-radius: 6px;
  padding: 2px;
}
.lfm-layout-btn {
  background: transparent;
  border: none;
  border-radius: 4px;
  padding: 5px;
  color: var(--text-secondary, #aaa);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.lfm-layout-btn:hover {
  color: var(--text-primary);
}
.lfm-layout-btn.active {
  background: var(--bg-primary, #ffffff);
  color: var(--accent-primary, #3b82f6);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

/* ══════════════════════════════════════════════════════════════════════
 * Library browser — production Finder-style shell
 * Kept entirely under #libraryPage/.lfm-* so shared artifact views retain
 * their existing editorial layout.
 * ════════════════════════════════════════════════════════════════════ */
#libraryPage {
  --lfm-blue: #3769d4;
  --lfm-blue-soft: rgba(55, 105, 212, 0.11);
  --lfm-line: rgba(24, 32, 48, 0.11);
  --lfm-surface: rgba(255, 255, 255, 0.94);
  padding: 18px 22px 22px;
  overflow: hidden;
  background:
    radial-gradient(circle at 90% -10%, rgba(125, 176, 224, 0.15), transparent 34%),
    #eef1f5;
}

#libraryPage,
#libraryPage * {
  box-sizing: border-box;
}

#libraryPage .library-multi-tab-bar {
  flex: 0 0 auto;
  min-width: 0;
  height: 42px;
  padding: 7px 10px 0;
  gap: 4px;
  border: 1px solid var(--lfm-line);
  border-bottom: 0;
  border-radius: 14px 14px 0 0;
  background: rgba(225, 229, 235, 0.94);
  backdrop-filter: blur(20px) saturate(1.2);
}

#libraryPage .library-tabs-list {
  min-width: 0;
  gap: 3px;
}

#libraryPage .library-tab-btn {
  min-width: 112px;
  max-width: 210px;
  height: 35px;
  padding: 0 10px 0 13px;
  gap: 8px;
  border-radius: 9px 9px 0 0;
  font-size: 12.5px;
  overflow: hidden;
}

#libraryPage .library-tab-btn.active {
  background: var(--lfm-surface);
  border-color: var(--lfm-line);
  box-shadow: 0 -2px 8px rgba(24, 32, 48, 0.035);
}

#libraryPage .library-tab-label {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

#libraryPage .library-tab-close {
  display: grid;
  place-items: center;
  flex: 0 0 17px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
}

#libraryPage .library-tab-close:hover {
  color: #fff;
  background: #e35d5d;
}

#libraryPage .library-tab-add {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  margin: 0 0 3px 2px;
  border-radius: 7px;
}

#libraryPage .library-multi-tab-content {
  min-height: 0;
  border: 1px solid var(--lfm-line);
  border-radius: 0 0 14px 14px;
  background: var(--lfm-surface);
  box-shadow: 0 18px 42px rgba(29, 39, 59, 0.10), 0 2px 7px rgba(29, 39, 59, 0.05);
}

#libraryPage .library-multi-tab-pane,
#libraryPage .lfm-root {
  min-width: 0;
  min-height: 0;
  height: 100%;
}

#libraryPage .lfm-root {
  overflow: hidden;
  color: #252a33;
  background: #fff;
}

#libraryPage .lfm-header {
  flex: 0 0 52px;
  min-width: 0;
  margin: 0;
  padding: 8px 12px;
  gap: 10px;
  flex-wrap: nowrap;
  border-bottom: 1px solid var(--lfm-line);
  background: linear-gradient(180deg, #fbfcfd 0%, #f4f6f8 100%);
}

#libraryPage .lfm-nav-actions,
#libraryPage .lfm-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

#libraryPage .lfm-toolbar-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  color: #566171;
  background: transparent;
  cursor: pointer;
}

#libraryPage .lfm-toolbar-btn svg {
  width: 17px;
  height: 17px;
}

#libraryPage .lfm-toolbar-btn:hover:not(:disabled),
#libraryPage .lfm-toolbar-btn.active {
  color: #24314a;
  border-color: var(--lfm-line);
  background: #fff;
  box-shadow: 0 1px 2px rgba(20, 30, 48, 0.06);
}

#libraryPage .lfm-toolbar-btn:disabled {
  opacity: 0.28;
  cursor: default;
}

#libraryPage .lfm-breadcrumb {
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: nowrap;
  overflow: hidden;
  font-family: 'Inter', 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 12px;
  letter-spacing: 0;
}

#libraryPage .lfm-bc-crumb {
  min-width: 0;
  max-width: min(220px, 30vw);
  padding: 5px 7px;
  flex: 0 1 auto;
}

#libraryPage .lfm-bc-crumb--active {
  color: #273142;
  font-weight: 650;
}

#libraryPage .lfm-view-control {
  display: flex;
  align-items: center;
  gap: 1px;
  height: 32px;
  padding: 2px;
  border: 1px solid var(--lfm-line);
  border-radius: 7px;
  color: #687383;
  background: rgba(255, 255, 255, 0.8);
}

#libraryPage .lfm-view-btn {
  display: grid;
  place-items: center;
  width: 28px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  color: #687383;
  background: transparent;
  cursor: pointer;
}

#libraryPage .lfm-view-btn svg {
  width: 15px;
  height: 15px;
}

#libraryPage .lfm-view-btn:hover {
  color: #28364b;
  background: rgba(35, 48, 70, 0.07);
}

#libraryPage .lfm-view-btn.active {
  color: #fff;
  background: #566273;
  box-shadow: 0 1px 2px rgba(20, 30, 48, 0.18);
}

#libraryPage .lfm-select-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 11px;
  border: 1px solid var(--lfm-line);
  border-radius: 7px;
  color: #465366;
  background: rgba(255, 255, 255, 0.8);
  font: 600 11.5px/1 'Inter', system-ui, sans-serif;
  letter-spacing: 0;
  text-transform: none;
}

#libraryPage .lfm-select-toggle svg {
  width: 15px;
  height: 15px;
}

#libraryPage .lfm-select-toggle:hover,
#libraryPage .lfm-select-toggle.active {
  color: var(--lfm-blue);
  border-color: rgba(55, 105, 212, 0.32);
  background: var(--lfm-blue-soft);
}

#libraryPage .lfm-browser {
  display: flex;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

#libraryPage .lfm-sidebar {
  flex: 0 0 238px;
  width: 238px;
  min-width: 0;
  padding: 15px 10px;
  overflow-x: hidden;
  overflow-y: auto;
  border-right: 1px solid var(--lfm-line);
  background: linear-gradient(180deg, #f4f6f8 0%, #f8f9fb 100%);
  transition: width 180ms ease, flex-basis 180ms ease, padding 180ms ease;
}

#libraryPage .lfm-sidebar-hidden .lfm-sidebar {
  flex-basis: 0;
  width: 0;
  padding-left: 0;
  padding-right: 0;
  border-right: 0;
  overflow: hidden;
}

#libraryPage .lfm-sidebar-heading {
  padding: 0 9px 9px;
  color: #8a93a1;
  font: 700 10px/1.2 'Inter', system-ui, sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

#libraryPage .lfm-tree,
#libraryPage .lfm-tree-branch,
#libraryPage .lfm-tree-children {
  min-width: 0;
}

#libraryPage .lfm-tree-chat-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  min-width: 0;
}

#libraryPage .lfm-tree-item,
#libraryPage .lfm-tree-disclosure {
  border: 0;
  color: #4d596b;
  background: transparent;
  cursor: pointer;
}

#libraryPage .lfm-tree-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
  height: 30px;
  padding: 0 7px;
  gap: 7px;
  border-radius: 6px;
  text-align: left;
  font: 500 12px/1 'Inter', system-ui, sans-serif;
}

#libraryPage .lfm-tree-root {
  padding-left: 5px;
}

#libraryPage .lfm-tree-spacer {
  width: 13px;
  flex: 0 0 13px;
}

#libraryPage .lfm-tree-item:hover {
  color: #202b3e;
  background: rgba(32, 43, 62, 0.055);
}

#libraryPage .lfm-tree-item.active {
  color: #234f9e;
  background: rgba(55, 105, 212, 0.13);
  font-weight: 650;
}

#libraryPage .lfm-tree-disclosure {
  display: grid;
  place-items: center;
  width: 20px;
  height: 26px;
  padding: 0;
}

#libraryPage .lfm-tree-disclosure span {
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 6px solid #8c95a2;
  transition: transform 130ms ease;
}

#libraryPage .lfm-tree-disclosure.expanded span {
  transform: rotate(90deg);
}

#libraryPage .lfm-tree-icon {
  display: grid;
  place-items: center;
  flex: 0 0 17px;
  width: 17px;
  height: 17px;
}

#libraryPage .lfm-tree-icon svg {
  width: 16px;
  height: 16px;
  color: #6f86b6;
  opacity: 1;
}

#libraryPage .lfm-tree-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#libraryPage .lfm-tree-count {
  flex: 0 0 auto;
  color: #929aa6;
  font-size: 10px;
}

#libraryPage .lfm-tree-children {
  margin: 1px 0 3px 27px;
  padding-left: 8px;
  border-left: 1px solid rgba(50, 63, 85, 0.10);
}

#libraryPage .lfm-tree-turn {
  height: 28px;
  padding-left: 6px;
  font-size: 11.5px;
}

#libraryPage .lfm-tree-buckets,
#libraryPage .lfm-tree-files {
  margin-left: 18px;
}

#libraryPage .lfm-tree-bucket {
  height: 27px;
  font-size: 11px;
}

#libraryPage .lfm-tree-file {
  height: 26px;
  padding-left: 5px;
  color: #697486;
  font-size: 10.5px;
}

#libraryPage .lfm-tree-file .lfm-tree-icon svg {
  width: 14px;
  height: 14px;
  color: #718096;
}

#libraryPage .lfm-tree-empty {
  padding: 10px 28px;
  color: #9aa2ad;
  font: 500 11px/1.4 'Inter', system-ui, sans-serif;
  white-space: nowrap;
}

#libraryPage .lfm-main {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #fff;
}

#libraryPage .lfm-location-summary {
  flex: 0 0 auto;
  min-width: 0;
  padding: 18px 22px 13px;
  border-bottom: 1px solid rgba(24, 32, 48, 0.07);
}

#libraryPage .lfm-location-title {
  overflow: hidden;
  color: #202733;
  font: 680 18px/1.25 'Inter', 'Plus Jakarta Sans', system-ui, sans-serif;
  letter-spacing: -0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#libraryPage .lfm-location-detail {
  margin-top: 3px;
  color: #8a93a0;
  font: 500 11px/1.4 'Inter', system-ui, sans-serif;
}

#libraryPage .lfm-body {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  padding: 10px 14px 22px;
  overflow-x: hidden;
  overflow-y: auto;
}

#libraryPage .lfm-list {
  min-width: 0;
  gap: 2px;
}

#libraryPage .lfm-folder-row,
#libraryPage .lfm-file-row {
  position: relative;
  min-width: 0;
  min-height: 42px;
  padding: 8px 10px;
  gap: 10px;
  border-radius: 7px;
}

#libraryPage .lfm-folder-row:hover,
#libraryPage .lfm-file-row:hover {
  border-color: transparent;
  background: rgba(52, 66, 91, 0.055);
}

#libraryPage .lfm-file-row--highlighted,
#libraryPage .lfm-file-row--selected {
  border-color: rgba(55, 105, 212, 0.18);
  background: var(--lfm-blue-soft);
}

#libraryPage .lfm-row-name {
  min-width: 0;
  max-width: 100%;
  color: #29313e;
  font-size: 12.5px;
  font-weight: 520;
}

#libraryPage .lfm-row-meta {
  min-width: 0;
  max-width: 46%;
}

#libraryPage .lfm-row-count,
#libraryPage .lfm-row-date {
  overflow: hidden;
  color: #8b94a1;
  background: transparent;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 10.5px;
  letter-spacing: 0;
  text-overflow: ellipsis;
}

#libraryPage .lfm-folder-icon-svg {
  color: #5680d4;
  opacity: 0.9;
}

#libraryPage .lfm-turn-row .lfm-folder-icon-svg {
  color: #ce8c53;
  opacity: 0.86;
}

#libraryPage .lfm-bucket-row .lfm-folder-icon-svg {
  color: #43a9d5;
  opacity: 1;
}

#libraryPage .lfm-file-icon-svg {
  color: #68778c;
  opacity: 0.95;
}

#libraryPage .lfm-group-header {
  min-width: 0;
  margin: 8px 0 3px;
  padding: 10px 8px 7px;
  color: #7d8795;
  border-bottom-color: rgba(24, 32, 48, 0.08);
  font-size: 10px;
  letter-spacing: 0.075em;
}

#libraryPage .lfm-empty {
  min-width: 0;
  padding: 40px 12px;
  color: #929ba7;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 12px;
  letter-spacing: 0;
  line-height: 1.55;
  text-transform: none;
  overflow-wrap: anywhere;
}

/* Icon views share the same DOM and handlers as List view. */
#libraryPage .lfm-view--small .lfm-list,
#libraryPage .lfm-view--medium .lfm-list,
#libraryPage .lfm-view--large .lfm-list {
  display: grid;
  align-items: stretch;
  padding: 4px;
}

#libraryPage .lfm-view--small .lfm-list {
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px;
}

#libraryPage .lfm-view--medium .lfm-list {
  grid-template-columns: repeat(auto-fill, minmax(142px, 1fr));
  gap: 11px;
}

#libraryPage .lfm-view--large .lfm-list {
  grid-template-columns: repeat(auto-fill, minmax(184px, 1fr));
  gap: 14px;
}

#libraryPage .lfm-view--small .lfm-group-header,
#libraryPage .lfm-view--medium .lfm-group-header,
#libraryPage .lfm-view--large .lfm-group-header {
  grid-column: 1 / -1;
}

#libraryPage .lfm-view--small .lfm-folder-row,
#libraryPage .lfm-view--small .lfm-file-row,
#libraryPage .lfm-view--medium .lfm-folder-row,
#libraryPage .lfm-view--medium .lfm-file-row,
#libraryPage .lfm-view--large .lfm-folder-row,
#libraryPage .lfm-view--large .lfm-file-row {
  flex-direction: column;
  justify-content: center;
  text-align: center;
  border: 1px solid rgba(24, 32, 48, 0.09);
  background: #fff;
}

#libraryPage .lfm-view--small .lfm-folder-row,
#libraryPage .lfm-view--small .lfm-file-row {
  min-height: 92px;
  padding: 10px 7px;
}

#libraryPage .lfm-view--medium .lfm-folder-row,
#libraryPage .lfm-view--medium .lfm-file-row {
  min-height: 122px;
  padding: 14px 10px;
}

#libraryPage .lfm-view--large .lfm-folder-row,
#libraryPage .lfm-view--large .lfm-file-row {
  min-height: 156px;
  padding: 18px 12px;
}

#libraryPage .lfm-view--small .lfm-folder-row:hover,
#libraryPage .lfm-view--small .lfm-file-row:hover,
#libraryPage .lfm-view--medium .lfm-folder-row:hover,
#libraryPage .lfm-view--medium .lfm-file-row:hover,
#libraryPage .lfm-view--large .lfm-folder-row:hover,
#libraryPage .lfm-view--large .lfm-file-row:hover {
  border-color: rgba(55, 105, 212, 0.30);
  background: #f8faff;
  box-shadow: 0 5px 16px rgba(36, 59, 99, 0.08);
}

#libraryPage .lfm-view--small .lfm-row-icon {
  width: 28px;
  height: 28px;
}

#libraryPage .lfm-view--medium .lfm-row-icon {
  width: 40px;
  height: 40px;
}

#libraryPage .lfm-view--large .lfm-row-icon {
  width: 54px;
  height: 54px;
}

#libraryPage .lfm-view--small .lfm-row-icon svg {
  width: 25px;
  height: 25px;
}

#libraryPage .lfm-view--medium .lfm-row-icon svg {
  width: 37px;
  height: 37px;
}

#libraryPage .lfm-view--large .lfm-row-icon svg {
  width: 50px;
  height: 50px;
}

#libraryPage .lfm-view--small .lfm-row-name,
#libraryPage .lfm-view--medium .lfm-row-name,
#libraryPage .lfm-view--large .lfm-row-name {
  flex: 0 0 auto;
  width: 100%;
  display: -webkit-box;
  overflow: hidden;
  white-space: normal;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

#libraryPage .lfm-view--small .lfm-row-meta,
#libraryPage .lfm-view--medium .lfm-row-meta,
#libraryPage .lfm-view--large .lfm-row-meta {
  justify-content: center;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
}

#libraryPage .lfm-view--small .lfm-row-date,
#libraryPage .lfm-view--small .lfm-row-dot,
#libraryPage .lfm-view--small .lfm-row-chevron,
#libraryPage .lfm-view--small .lfm-file-hint,
#libraryPage .lfm-view--medium .lfm-row-dot,
#libraryPage .lfm-view--medium .lfm-row-chevron,
#libraryPage .lfm-view--medium .lfm-file-hint,
#libraryPage .lfm-view--large .lfm-row-dot,
#libraryPage .lfm-view--large .lfm-row-chevron,
#libraryPage .lfm-view--large .lfm-file-hint {
  display: none;
}

#libraryPage .lfm-view--small .lfm-row-check,
#libraryPage .lfm-view--medium .lfm-row-check,
#libraryPage .lfm-view--large .lfm-row-check {
  position: absolute;
  top: 8px;
  left: 8px;
}

#libraryPage .lfm-view--small .lfm-type-badge,
#libraryPage .lfm-view--medium .lfm-type-badge,
#libraryPage .lfm-view--large .lfm-type-badge {
  right: -8px;
  bottom: -3px;
}

/* Tile view mirrors a modern details/card browser. */
#libraryPage .lfm-view--tiles .lfm-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: 9px;
  padding: 4px;
}

#libraryPage .lfm-view--tiles .lfm-group-header {
  grid-column: 1 / -1;
}

#libraryPage .lfm-view--tiles .lfm-folder-row,
#libraryPage .lfm-view--tiles .lfm-file-row {
  min-height: 68px;
  padding: 10px 12px;
  border: 1px solid rgba(24, 32, 48, 0.09);
  background: #fff;
}

#libraryPage .lfm-view--tiles .lfm-row-icon {
  width: 34px;
  height: 34px;
}

#libraryPage .lfm-view--tiles .lfm-row-icon svg {
  width: 28px;
  height: 28px;
}

#libraryPage .lfm-view--tiles .lfm-row-meta {
  max-width: 38%;
}

#libraryPage .lfm-view--tiles .lfm-file-hint,
#libraryPage .lfm-view--tiles .lfm-row-dot,
#libraryPage .lfm-view--tiles .lfm-row-chevron {
  display: none;
}

#libraryPage .lfm-select-bar {
  width: min(560px, calc(100% - 48px));
  max-width: 100%;
  min-width: 0;
  bottom: 34px;
  padding: 10px 14px 10px 18px;
  border: 1px solid rgba(24, 32, 48, 0.14);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 14px 40px rgba(24, 34, 52, 0.20);
  backdrop-filter: blur(18px);
}

#libraryPage .lfm-select-bar-count {
  min-width: 0;
  overflow: hidden;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 11px;
  letter-spacing: 0;
  text-overflow: ellipsis;
  text-transform: none;
  white-space: nowrap;
}

@media (max-width: 900px) {
  #libraryPage {
    padding: 10px;
  }
  #libraryPage .lfm-sidebar {
    flex-basis: 200px;
    width: 200px;
  }
  #libraryPage .lfm-file-hint,
  #libraryPage .lfm-view-btn[data-view="small"] {
    display: none;
  }
}

@media (max-width: 680px) {
  #libraryPage .lfm-sidebar {
    position: absolute;
    z-index: 20;
    top: 52px;
    bottom: 0;
    left: 0;
    flex-basis: 230px;
    width: 230px;
    box-shadow: 12px 0 26px rgba(26, 36, 54, 0.14);
  }
  #libraryPage .lfm-sidebar-hidden .lfm-sidebar {
    width: 0;
  }
  #libraryPage .lfm-breadcrumb {
    display: none;
  }
  #libraryPage .lfm-header-actions {
    margin-left: auto;
  }
  #libraryPage .lfm-view-btn {
    width: 26px;
  }
  #libraryPage .lfm-select-toggle span {
    display: none;
  }
  #libraryPage .lfm-select-toggle {
    width: 32px;
    padding: 0;
    justify-content: center;
  }
}

/* Keep semantic hierarchy/file colours above the base Library theme. */
#libraryPage .lfm-tree-session.active {
  color: #2058aa;
  background: rgba(47, 111, 205, 0.13);
}
#libraryPage .lfm-tree-turn.active {
  color: #a65f16;
  background: rgba(220, 145, 62, 0.14);
}
#libraryPage .lfm-tree-bucket.active {
  color: #117563;
  background: rgba(34, 165, 141, 0.14);
}
#libraryPage .lfm-file-glyph .lfm-file-icon-svg {
  color: inherit;
}

/* Final hierarchy palette: consistent between sidebar and content pane. */
#libraryPage .lfm-tree-root .lfm-folder-icon-svg {
  color: #64748b;
}
#libraryPage .lfm-session-row {
  border-left-color: rgba(47, 111, 205, 0.55);
}
#libraryPage .lfm-session-row .lfm-folder-icon-svg,
#libraryPage .lfm-tree-session .lfm-folder-icon-svg {
  color: #2f6fcd;
}
#libraryPage .lfm-tree-session.active {
  color: #2058aa;
  background: rgba(47, 111, 205, 0.13);
}
#libraryPage .lfm-turn-row .lfm-folder-icon-svg,
#libraryPage .lfm-tree-turn .lfm-folder-icon-svg {
  color: #d88732;
}
#libraryPage .lfm-bucket-row .lfm-folder-icon-svg,
#libraryPage .lfm-tree-bucket .lfm-folder-icon-svg {
  color: #1d9a82;
}
#libraryPage .lfm-file-glyph--markdown { color: #45627f; }
#libraryPage .lfm-file-glyph--markdown .lfm-file-ext { background: #45627f; }
#libraryPage .lfm-file-glyph--image { color: #cf6c55; }
#libraryPage .lfm-file-glyph--image .lfm-file-ext { background: #cf6c55; }

/* Destructive confirmation dialog ------------------------------------ */
.lfm-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(20, 27, 39, 0.48);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  animation: lfm-fade-in 140ms ease-out;
}

.lfm-confirm-dialog {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  width: min(460px, 100%);
  padding: 22px;
  gap: 4px 15px;
  overflow: hidden;
  border: 1px solid rgba(34, 44, 62, 0.14);
  border-radius: 14px;
  color: #202733;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 24px 70px rgba(17, 25, 39, 0.28);
  animation: lfm-panel-in 180ms ease-out;
}

.lfm-confirm-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  color: #c53f3f;
  background: rgba(197, 63, 63, 0.10);
}

.lfm-confirm-icon svg {
  width: 18px;
  height: 18px;
}

.lfm-confirm-copy {
  min-width: 0;
}

.lfm-confirm-copy h3 {
  margin: 1px 0 7px;
  font: 680 16px/1.3 'Inter', 'Plus Jakarta Sans', system-ui, sans-serif;
  letter-spacing: -0.01em;
}

.lfm-confirm-copy p {
  margin: 0;
  color: #687383;
  font: 450 12.5px/1.58 'Inter', 'Plus Jakarta Sans', system-ui, sans-serif;
  overflow-wrap: anywhere;
}

.lfm-confirm-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.lfm-confirm-actions button {
  min-height: 34px;
  padding: 0 14px;
  border-radius: 7px;
  font: 620 12px/1 'Inter', system-ui, sans-serif;
  cursor: pointer;
}

.lfm-confirm-cancel {
  border: 1px solid rgba(33, 43, 61, 0.14);
  color: #455165;
  background: #fff;
}

.lfm-confirm-delete {
  border: 1px solid #b93636;
  color: #fff;
  background: #c53f3f;
}

.lfm-confirm-cancel:hover {
  background: #f3f5f7;
}

.lfm-confirm-delete:hover {
  background: #ad3030;
}

.lfm-confirm-actions button:focus-visible {
  outline: 2px solid #3769d4;
  outline-offset: 2px;
}

/* Use the supplied format artwork at every hierarchy depth. */
#libraryPage .lfm-file-glyph img.lfm-file-icon-svg {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 1;
  pointer-events: none;
  user-select: none;
}

/* The Library browser is the page surface; avoid nesting it in a second card. */
#libraryPage {
  padding: 0;
  background: #fff;
}
#libraryPage .library-multi-tab-bar {
  border: 0;
  border-bottom: 1px solid var(--lfm-line);
  border-radius: 0;
}
#libraryPage .library-multi-tab-content {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

/* Compact metadata pills and overflow-safe IST dates. */
#libraryPage .lfm-row-count,
#libraryPage .lfm-tree-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  min-height: 20px;
  padding: 2px 7px;
  overflow: hidden;
  border: 1px solid rgba(43, 57, 79, 0.09);
  border-radius: 999px;
  color: #687383;
  background: #eef1f5;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#libraryPage .lfm-tree-count {
  min-width: 20px;
  min-height: 17px;
  padding: 2px 5px;
  font-size: 9px;
}
#libraryPage .lfm-row-date {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Finder-style cascading Download submenu. */
.lfm-ctx-submenu-wrap {
  position: relative;
}
.lfm-ctx-submenu-trigger {
  padding-right: 9px;
}
.lfm-ctx-label {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lfm-ctx-submenu-arrow {
  flex: 0 0 auto;
  margin-left: 12px;
  color: var(--text-tertiary, #7b8490);
  font-size: 18px;
  line-height: 1;
}
.lfm-ctx-submenu {
  position: absolute;
  z-index: 2;
  top: -5px;
  left: calc(100% - 4px);
  display: none;
  min-width: 218px;
  padding: 4px 0;
  border: 1px solid var(--border-light, #e3e6ea);
  border-radius: 8px;
  background: var(--bg-primary, #fff);
  box-shadow: 0 10px 30px rgba(21, 29, 43, 0.20);
}
.lfm-ctx-submenu-wrap:hover > .lfm-ctx-submenu,
.lfm-ctx-submenu-wrap:focus-within > .lfm-ctx-submenu {
  display: block;
}
.lfm-ctx-submenu-wrap--left > .lfm-ctx-submenu {
  right: calc(100% - 4px);
  left: auto;
}

