/* ═══════════════════════════════════════════════════════════════════
   BRIEFLY AI — Legora-style Legal AI Interface
   Design System: White + Teal, no dark backgrounds, no gradients
   ═══════════════════════════════════════════════════════════════════ */

/* ── RESET & BASE ── */
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  background: var(--bg, #FAFAF8);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── LOGIN PAGE ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg, #FAFAF8);
}
.login-card {
  background: #ffffff;
  border: 1px solid var(--border, #E4EBE7);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  padding: 40px;
  width: 420px;
  max-width: 92vw;
}
.login-brand {
  text-align: center;
  margin-bottom: 32px;
}
.login-brand h1 {
  font-family: 'Noto Sans', 'Roboto', sans-serif;
  font-size: 26px;
  font-weight: 400;
  color: #1a6b5a;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}
.login-brand p {
  font-size: var(--text-base);
  color: #4A5C52;
  margin: 0;
  line-height: 1.5;
}
.login-field {
  margin-bottom: 20px;
}
.login-field label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  color: #4A5C52;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.login-field input {
  width: 100%;
  padding: 12px;
  border: 1.5px solid var(--border, #E4EBE7);
  border-radius: var(--radius-lg);
  font-size: var(--text-base);
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  color: #111C17;
  background: #ffffff;
  outline: none;
  transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
  box-sizing: border-box;
  line-height: 1.5;
}
.login-field input:focus-visible {
  border-color: #1a6b5a;
  box-shadow: 0 0 0 3px rgba(26,107,90,0.1);
}
.login-field input::placeholder { color: #5d7366; }
.login-pass-wrap { position: relative; }
.login-pass-wrap input { padding-right: 44px; }
.login-pass-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: #5d7366;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: color var(--duration-fast) ease;
}
.login-pass-toggle:hover { color: #4A5C52; }
/* Google sign-in button */
.google-btn {
  width: 100%;
  height: 44px;
  padding: 0 16px;
  background: #fff;
  color: #3c4043;
  border: 1px solid #dadce0;
  border-radius: var(--radius-2xl);
  font-size: var(--text-base);
  font-weight: 500;
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all var(--duration-fast) ease;
}
.google-btn:hover { background: #f7f8f8; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.google-btn:active { background: #eee; }
.google-btn:disabled { opacity: 0.6; cursor: not-allowed; }
/* Onboarding welcome */
.onboard-welcome {
  font-size: var(--text-md);
  font-weight: 500;
  color: var(--teal, #1a6b5a);
  text-align: center;
  margin-bottom: 16px;
}
.login-divider {
  display: flex;
  align-items: center;
  margin: 16px 0;
  color: var(--text-mid, #4A5C52);
  font-size: var(--text-sm);
}
.login-divider::before, .login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border, #E4EBE7);
}
.login-divider span { padding: 0 12px; }
.login-btn {
  width: 100%;
  height: 44px;
  padding: 0 16px;
  background: #1a6b5a;
  color: #fff;
  border: none;
  border-radius: var(--radius-2xl);
  font-size: var(--text-base);
  font-weight: 600;
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
  margin-top: 8px;
}
.login-btn:hover { background: #145a4a; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(26,107,90,0.25); }
.login-btn:active { background: #145a4a; transform: translateY(0); box-shadow: none; }
.login-btn:disabled {
  background: var(--border, #E4EBE7);
  color: var(--text-light, #5d7366);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.login-error {
  color: #C0392B;
  font-size: var(--text-sm);
  text-align: center;
  margin-top: 16px;
  display: none;
  line-height: 1.5;
  background: #fef2f2;
  border: 1px solid #f5c6cb;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.login-success {
  color: #1B7A6E;
  font-size: var(--text-sm);
  text-align: center;
  margin-top: 16px;
  line-height: 1.5;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.login-hint {
  color: var(--text-mid);
  font-size: var(--text-sm);
  text-align: center;
  margin-bottom: 16px;
  line-height: 1.5;
}
.login-link {
  text-align: center;
  margin-top: 20px;
  font-size: var(--text-sm);
  color: #4A5C52;
}
.login-link a {
  color: #1a6b5a;
  text-decoration: none;
  cursor: pointer;
  transition: color var(--duration-fast) ease;
}
.login-link a:hover { color: #145a4a; text-decoration: underline; }
.login-footer {
  text-align: center;
  margin-top: 28px;
  font-size: var(--text-xs);
  color: #5d7366;
  letter-spacing: 0.2px;
}
/* ── USER PROFILE (sidebar bottom) ── */
.sb-user {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  height: 56px;
  border-top: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--duration-fast) ease;
  flex-shrink: 0;
  box-sizing: border-box;
  background: var(--white, #ffffff);
}
.sb-user:hover { background: var(--bg2, #EAF4EE); }
.sb-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--teal, #1a6b5a);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm-);
  font-weight: 600;
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  flex-shrink: 0;
}
.sb-user-info {
  flex: 1;
  min-width: 0;
}
.sb-user-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text, #111C17);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.sb-user-email {
  font-size: var(--text-xs);
  color: var(--text-light, #5d7366);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}
.sb-user-chevron {
  color: var(--text-light, #5d7366);
  flex-shrink: 0;
  transition: transform var(--duration-normal) ease, color var(--duration-fast) ease;
}
.sb-user:hover .sb-user-chevron { color: var(--text-mid, #4A5C52); }

/* ── PLAN BADGE ── */
.sb-plan-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: 4px;
  flex-shrink: 0;
  line-height: 1.4;
}
.sb-plan-badge[data-plan="free"] { background: #e8e8e8; color: #666; }
.sb-plan-badge[data-plan="pro"] { background: var(--teal, #1B7A6E); color: #fff; }
.sb-plan-badge[data-plan="enterprise"] { background: #7c3aed; color: #fff; }

/* ── USER DROPDOWN ── */
.user-dropdown {
  display: none;
  position: fixed;
  bottom: 68px;
  left: 8px;
  background: var(--white, #ffffff);
  border: none;
  border-radius: var(--radius-lg, 12px);
  box-shadow: var(--shadow-md, 0 8px 32px rgba(0,0,0,0.10));
  padding: 6px 0;
  min-width: 240px;
  width: 240px;
  z-index: 1100;
  overflow: hidden;
}
.user-dropdown.open { display: block; animation: bfFadeIn 150ms ease; }
.ud-profile {
  padding: 18px 20px 14px;
}
.ud-profile .ud-name {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text, #111C17);
  line-height: 1.4;
}
.ud-profile .ud-email-sub {
  font-size: var(--text-sm-);
  color: var(--text-light, #5d7366);
  margin-top: 2px;
  line-height: 1.4;
}
.ud-divider {
  height: 1px;
  background: var(--border, #E4EBE7);
  margin: 6px 16px;
}
.ud-section {
  padding: 6px 8px;
}
.ud-section .ud-item {
  font-size: var(--text-sm);
  color: var(--text-mid, #4A5C52);
  cursor: pointer;
  background: none;
  border: none;
  height: 42px;
  padding: 0 24px;
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  width: 100%;
  text-align: left;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background var(--duration-fast) ease;
}
.ud-section .ud-item:hover { background: var(--bg2, #EAF4EE); color: var(--text, #111C17); }
.ud-section .ud-item svg { color: var(--teal-light, #4A9B6F); flex-shrink: 0; }
.ud-section .ud-item:hover svg { color: var(--teal, #1a6b5a); }
.ud-section .ud-item.danger { color: var(--danger, #C0392B); }
.ud-section .ud-item.danger svg { color: var(--danger, #C0392B); }
.ud-section .ud-item.danger:hover { background: var(--danger-pale, #fef2f2); color: var(--danger, #C0392B); }
.ud-section .ud-item.danger:hover svg { color: var(--danger, #C0392B); }

/* ── GLOBAL MODAL OVERLAY (outside #bf) ── */
.bf-global-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: bfFadeIn 150ms ease;
}
@keyframes bfFadeIn { from { opacity: 0; } to { opacity: 1; } }
.bf-global-modal {
  background: var(--white, #ffffff);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  width: 420px;
  max-width: 92vw;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}
.bf-global-modal h3 {
  font-family: 'Noto Sans', 'Roboto', sans-serif;
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--text, #111C17);
  margin: 0 0 4px;
  line-height: 1.4;
}
.bf-global-modal .modal-subtitle {
  font-size: var(--text-sm);
  color: var(--text-mid, #4A5C52);
  margin: 0 0 24px;
  line-height: 1.5;
}
.bf-global-modal .modal-field {
  margin-bottom: 16px;
}
.bf-global-modal .modal-field label {
  display: block;
  font-size: var(--text-sm-);
  font-weight: 500;
  color: var(--text-mid, #4A5C52);
  margin-bottom: 8px;
}
.bf-global-modal .modal-field input {
  width: 100%;
  padding: 12px;
  border: 1.5px solid var(--border, #E4EBE7);
  border-radius: var(--radius-lg);
  font-size: var(--text-base);
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  color: var(--text, #111C17);
  background: var(--white, #ffffff);
  outline: none;
  transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
  box-sizing: border-box;
  line-height: 1.5;
}
.bf-global-modal .modal-field input:focus-visible {
  border-color: var(--teal, #1a6b5a);
  box-shadow: 0 0 0 3px rgba(26,107,90,0.1);
}
.bf-global-modal .modal-error {
  color: var(--danger, #C0392B);
  font-size: var(--text-sm);
  text-align: center;
  margin-top: 12px;
  display: none;
}
.bf-global-modal .modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}
.bf-global-modal .btn-cancel {
  height: 36px;
  padding: 0 18px;
  background: var(--bg, #FAFAF8);
  border: 1px solid var(--border, #E4EBE7);
  border-radius: var(--radius-2xl);
  cursor: pointer;
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-mid, #4A5C52);
  transition: all var(--duration-fast) ease;
}
.bf-global-modal .btn-cancel:hover { background: var(--border, #E4EBE7); }
.bf-global-modal .btn-primary {
  height: 36px;
  padding: 0 22px;
  background: var(--teal, #1a6b5a);
  border: none;
  border-radius: var(--radius-2xl);
  color: #fff;
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  transition: background var(--duration-fast) ease;
}
.bf-global-modal .btn-primary:hover { background: var(--teal-mid, #145a4a); }
.bf-global-modal .btn-primary:disabled { background: var(--border, #E4EBE7); cursor: not-allowed; }

/* ── SETTINGS / FIRM MODAL (wide variant) ── */
.bf-settings-modal {
  width: 560px; max-width: 94vw; max-height: 85vh;
  display: flex; flex-direction: column; padding: 0;
}
.bf-settings-modal .sm-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 28px 16px; border-bottom: 1px solid var(--border, #E4EBE7);
  flex-shrink: 0;
}
.bf-settings-modal .sm-header h3 {
  font-family: 'Noto Sans', 'Roboto', sans-serif;
  font-size: 18px; font-weight: 700; color: var(--text, #111C17); margin: 0;
}
.bf-settings-modal .sm-close {
  width: 32px; height: 32px; border-radius: var(--radius-base); border: none;
  background: transparent; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  color: var(--text-light, #5d7366);
  transition: all 150ms ease;
}
.bf-settings-modal .sm-close:hover { background: var(--bg2, #EAF4EE); color: var(--text, #111C17); }
.bf-settings-modal .sm-body {
  flex: 1; overflow-y: auto; padding: 24px 28px;
}
.bf-settings-modal .sm-section {
  margin-bottom: 28px;
}
.bf-settings-modal .sm-section:last-child { margin-bottom: 0; }
.bf-settings-modal .sm-section-title {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-light, #5d7366);
  margin: 0 0 14px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border, #E4EBE7);
}
.bf-settings-modal .sm-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; min-height: 42px;
}
.bf-settings-modal .sm-row + .sm-row {
  border-top: 1px solid color-mix(in srgb, var(--border, #E4EBE7) 50%, transparent);
}
.bf-settings-modal .sm-row-label {
  font-size: 14px; font-weight: 500; color: var(--text, #111C17);
}
.bf-settings-modal .sm-row-sublabel {
  font-size: 12px; color: var(--text-light, #5d7366); margin-top: 2px;
}
.bf-settings-modal .sm-row-value {
  font-size: 14px; color: var(--text-mid, #4A5C52);
  text-align: right;
}
.bf-settings-modal .sm-row-action {
  height: 36px; padding: 0 18px; border-radius: var(--radius-2xl);
  font-size: 13px; font-weight: 500; cursor: pointer;
  font-family: 'Roboto', 'Noto Sans', sans-serif; transition: all 150ms ease;
  border: 1px solid var(--border, #E4EBE7);
  background: var(--white, #fff); color: var(--text-mid, #4A5C52);
}
.bf-settings-modal .sm-row-action:hover {
  background: var(--bg2, #EAF4EE); border-color: var(--teal, #1a6b5a);
  color: var(--teal, #1a6b5a);
}
.bf-settings-modal .sm-row-action.primary {
  background: var(--teal, #1a6b5a); color: #fff; border-color: transparent;
}
.bf-settings-modal .sm-row-action.primary:hover { background: var(--teal-mid, #145a4a); }

/* Firm modal - member list */
.bf-settings-modal .fm-member {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0;
}
.bf-settings-modal .fm-member + .fm-member {
  border-top: 1px solid color-mix(in srgb, var(--border, #E4EBE7) 50%, transparent);
}
.bf-settings-modal .fm-member-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--teal, #1a6b5a); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; flex-shrink: 0;
}
.bf-settings-modal .fm-member-info { flex: 1; min-width: 0; }
.bf-settings-modal .fm-member-name {
  font-size: 14px; font-weight: 500; color: var(--text, #111C17);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bf-settings-modal .fm-member-email {
  font-size: 12px; color: var(--text-light, #5d7366);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bf-settings-modal .fm-member-role {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; padding: 3px 8px; border-radius: var(--radius-xs);
  background: var(--bg2, #EAF4EE); color: var(--teal, #1a6b5a);
  flex-shrink: 0;
}
.bf-settings-modal .fm-member-delete {
  width: 30px; height: 30px; border-radius: var(--radius-sm); border: none;
  background: transparent; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  color: var(--text-light, #5d7366); flex-shrink: 0;
  transition: all 150ms ease; margin-left: 4px;
}
.bf-settings-modal .fm-member-delete:hover {
  background: var(--danger-pale, #fef2f2); color: var(--danger, #C0392B);
}
.bf-settings-modal .fm-empty {
  text-align: center; padding: 24px 0; color: var(--text-light, #5d7366);
  font-size: 14px;
}
.bf-settings-modal .fm-invite-row {
  display: flex; gap: 8px; margin-top: 12px;
}
.bf-settings-modal .fm-invite-input {
  flex: 1; padding: 10px 14px; border: 1.5px solid var(--border, #E4EBE7);
  border-radius: var(--radius-lg); font-size: 13px; font-family: 'Roboto', 'Noto Sans', sans-serif;
  color: var(--text, #111C17); background: var(--white, #fff);
  outline: none; transition: border-color 150ms ease;
}
.bf-settings-modal .fm-invite-input:focus { border-color: var(--teal, #1a6b5a); }
.bf-settings-modal .fm-invite-input::placeholder { color: var(--text-light, #5d7366); }
/* Firm stat cards */
.bf-settings-modal .fm-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px;
}
.bf-settings-modal .fm-stat {
  background: var(--bg, #FAFAF8); border: 1px solid var(--border, #E4EBE7);
  border-radius: var(--radius-xl); padding: 16px 18px; text-align: center;
  box-shadow: var(--shadow-xs);
}
.bf-settings-modal .fm-stat-value {
  font-size: 20px; font-weight: 700; color: var(--teal, #1a6b5a); line-height: 1.2;
}
.bf-settings-modal .fm-stat-label {
  font-size: 11px; color: var(--text-light, #5d7366); margin-top: 4px;
  text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500;
}

/* ── Settings/Firm modal — mobile ── */
@media (max-width: 600px) {
  .bf-settings-modal { max-width: 100vw; max-height: 95vh; border-radius: var(--radius-card); }
  .bf-settings-modal .sm-header { padding: 16px 18px 12px; }
  .bf-settings-modal .sm-header h3 { font-size: 16px; }
  .bf-settings-modal .sm-body { padding: 16px 18px; }
  .bf-settings-modal .sm-section { margin-bottom: 20px; }
  .bf-settings-modal .sm-row { flex-wrap: wrap; gap: 6px; min-height: 44px; }
  .bf-settings-modal .sm-row-label { font-size: 13px; }
  .bf-settings-modal .sm-row-value { font-size: 13px; }
  .bf-settings-modal .fm-stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .bf-settings-modal .fm-stat { padding: 12px 8px; }
  .bf-settings-modal .fm-stat-value { font-size: 16px; }
  .bf-settings-modal .fm-stat-label { font-size: 10px; }
  .bf-settings-modal .fm-member { gap: 10px; }
  .bf-settings-modal .fm-member-name { font-size: 13px; }
  .bf-settings-modal .fm-member-email { font-size: 11px; }
  .bf-settings-modal .fm-member-role { font-size: 10px; padding: 2px 6px; }
  .bf-settings-modal .fm-invite-row { flex-wrap: wrap; }
  .bf-settings-modal .fm-invite-input { min-width: 0; }
}
@media (max-width: 380px) {
  .bf-settings-modal .sm-header { padding: 14px 14px 10px; }
  .bf-settings-modal .sm-body { padding: 14px; }
  .bf-settings-modal .fm-stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .bf-settings-modal .fm-member-avatar { width: 30px; height: 30px; font-size: 11px; }
  .bf-settings-modal .fm-member-delete { width: 36px; height: 36px; }
  .bf-settings-modal .sm-row-action { padding: 0 12px; font-size: 12px; height: 34px; }
}

/* Dark mode for settings/firm modals */
body.dark .bf-settings-modal { background: #1c2128; }
body.dark .bf-settings-modal .sm-header { border-bottom-color: #30363d; }
body.dark .bf-settings-modal .sm-header h3 { color: #e1e8ed; }
body.dark .bf-settings-modal .sm-close { color: #7d8b99; }
body.dark .bf-settings-modal .sm-close:hover { background: #161b22; color: #e1e8ed; }
body.dark .bf-settings-modal .sm-section-title { color: #8b949e; border-bottom-color: #30363d; }
body.dark .bf-settings-modal .sm-row + .sm-row { border-top-color: #30363d; }
body.dark .bf-settings-modal .sm-row-label { color: #e1e8ed; }
body.dark .bf-settings-modal .sm-row-sublabel { color: #8b949e; }
body.dark .bf-settings-modal .sm-row-value { color: #8b949e; }
body.dark .bf-settings-modal .sm-row-action { background: #161b22; border-color: #30363d; color: #8b949e; }
body.dark .bf-settings-modal .sm-row-action:hover { background: #30363d; border-color: #3fb99a; color: #3fb99a; }
body.dark .bf-settings-modal .sm-row-action.primary { background: #3fb99a; color: #0f1419; border-color: transparent; }
body.dark .bf-settings-modal .fm-member + .fm-member { border-top-color: #30363d; }
body.dark .bf-settings-modal .fm-member-avatar { background: #3fb99a; color: #0f1419; }
body.dark .bf-settings-modal .fm-member-name { color: #e1e8ed; }
body.dark .bf-settings-modal .fm-member-email { color: #8b949e; }
body.dark .bf-settings-modal .fm-member-role { background: #161b22; color: #3fb99a; }
body.dark .bf-settings-modal .fm-stat { background: #161b22; border-color: #30363d; }
body.dark .bf-settings-modal .fm-stat-value { color: #3fb99a; }
body.dark .bf-settings-modal .fm-stat-label { color: #8b949e; }
body.dark .bf-settings-modal .fm-member-delete { color: #7d8b99; }
body.dark .bf-settings-modal .fm-member-delete:hover { background: #3d1f1f; color: #f85149; }
body.dark .bf-settings-modal .fm-invite-input { background: #161b22; border-color: #30363d; color: #e1e8ed; }
body.dark .bf-settings-modal .fm-invite-input:focus { border-color: #3fb99a; }

/* ── DOCUMENT COMPARISON ── */
.bf-compare-modal { width: 800px; max-width: 95vw; max-height: 90vh; display: flex; flex-direction: column; }
.bf-compare-modal .compare-body { flex: 1; overflow-y: auto; padding: 0 2px; }
.bf-compare-dropzones { display: flex; gap: 16px; margin-bottom: 20px; }
.bf-compare-dropzone {
  flex: 1; border: 2px dashed var(--border-mid, #C8D9CE); border-radius: var(--radius-lg); padding: 24px 16px;
  text-align: center; cursor: pointer; transition: border-color var(--duration-normal), background var(--duration-normal);
  position: relative;
}
.bf-compare-dropzone:hover, .bf-compare-dropzone.drag-over { border-color: var(--teal, #1a6b5a); background: var(--teal-pale); }
.bf-compare-dropzone.drag-over { border-color: var(--teal, #1a6b5a); background: var(--bg2); border-width: 2.5px; }
.bf-compare-dropzone.has-file { border-color: var(--teal, #1a6b5a); border-style: solid; background: var(--teal-pale); }
.bf-compare-dropzone .dz-label { font-size: var(--text-xs); font-weight: 600; color: var(--teal, #1a6b5a); text-transform: uppercase; margin-bottom: 8px; }
.bf-compare-dropzone .dz-icon { font-size: 28px; margin-bottom: 6px; color: var(--text-light, #5d7366); }
.bf-compare-dropzone.has-file .dz-icon { color: var(--teal, #1a6b5a); }
.bf-compare-dropzone .dz-name { font-size: var(--text-sm-); color: var(--text-mid, #4A5C52); word-break: break-all; margin-top: 4px; font-weight: 500; }
.bf-compare-dropzone .dz-hint { font-size: var(--text-xs); color: var(--text-light, #5d7366); margin-top: 4px; }
.bf-compare-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); margin-bottom: 16px; }
.bf-compare-table th { background: var(--teal-pale); color: var(--teal, #1a6b5a); font-weight: 600; text-align: left; padding: 8px 10px; font-size: var(--text-xs); text-transform: uppercase; border-bottom: 2px solid var(--border-mid); }
.bf-compare-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: top; line-height: 1.5; }
.bf-compare-table tr:hover td { background: var(--bg, #FAFAF8); }
.bf-compare-section { margin-bottom: 20px; }
.bf-compare-section h4 { font-size: var(--text-base); font-weight: 600; color: var(--text, #111C17); margin: 0 0 10px; padding-bottom: 6px; border-bottom: 2px solid var(--teal, #1a6b5a); }
.bf-compare-card { background: var(--bg, #FAFAF8); border-radius: var(--radius-lg); padding: 14px 16px; margin-bottom: 10px; border-left: 3px solid var(--teal, #1a6b5a); }
.bf-compare-card.risk-high { border-left-color: #dc2626; }
.bf-compare-card.risk-medium { border-left-color: #f59e0b; }
.bf-compare-card.risk-low { border-left-color: var(--teal, #1a6b5a); }
.bf-risk-badge { display: inline-block; font-size: var(--text-2xs); font-weight: 600; padding: 2px 8px; border-radius: var(--radius-lg); text-transform: uppercase; }
.bf-risk-badge.high { background: var(--danger-pale, #fef2f2); color: #dc2626; }
.bf-risk-badge.medium { background: var(--warning-pale, #fffbeb); color: var(--warning, #d97706); }
.bf-risk-badge.low { background: var(--teal-pale); color: var(--teal, #1a6b5a); }

/* ── WORKFLOW ── */
.bf-wf-steps { display: flex; gap: 4px; margin-bottom: 20px; }
.bf-wf-step { flex: 1; text-align: center; padding: 8px; border-radius: var(--radius-sm); font-size: var(--text-xs); font-weight: 600; color: var(--text-light, #5d7366); background: var(--bg, #FAFAF8); }
.bf-wf-step.active { background: var(--teal, #1a6b5a); color: #fff; }
.bf-wf-step.done { background: var(--bg2, #EAF4EE); color: var(--teal, #1a6b5a); }
.bf-wf-options { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.bf-wf-option { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border: 1.5px solid var(--border, #E4EBE7); border-radius: var(--radius-md); cursor: pointer; font-size: var(--text-sm); color: var(--text); transition: all var(--duration-fast) ease; }
.bf-wf-option:hover { border-color: var(--teal, #1a6b5a); }
.bf-wf-option.selected { border-color: var(--teal, #1a6b5a); background: var(--teal-pale); color: var(--teal, #1a6b5a); }
.bf-wf-option input[type="checkbox"] { accent-color: var(--teal, #1a6b5a); }
.bf-wf-progress { padding: 16px 0; }
.bf-wf-progress-step { display: flex; align-items: center; gap: 10px; padding: 10px 0; font-size: var(--text-sm); color: #64748b; }
.bf-wf-progress-step.done { color: var(--teal, #1a6b5a); }
.bf-wf-progress-step.active { color: var(--teal, #1a6b5a); font-weight: 500; }
.bf-wf-progress-step .step-icon { width: 24px; text-align: center; }

/* ── SOURCES BUTTON & MENU ── */
.input-actions-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding-left: 4px;
  position: relative;
}
.source-btn-wrap {
  position: relative;
  margin-top: 4px;
  padding-left: 0;
}
.source-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 10px;
  font-size: var(--text-xs);
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  font-weight: 500;
  border: 1px solid var(--border, #E4EBE7);
  border-radius: var(--radius-xl);
  background: var(--bg, #FAFAF8);
  color: var(--text-mid, #4A5C52);
  cursor: pointer;
  transition: all var(--duration-fast) ease;
  white-space: nowrap;
}
.source-btn:hover { border-color: var(--teal, #1a6b5a); color: var(--teal, #1a6b5a); }
.source-count {
  background: var(--teal, #1a6b5a);
  color: #fff;
  font-size: var(--text-2xs);
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-xl);
  min-width: 16px;
  text-align: center;
  line-height: 1.5;
}
/* Plus menu — Claude-style with submenu */
.plus-menu-wrap { position: relative; }
.plus-btn {
  width: 28px; height: 28px;
  border: 1px solid var(--border-mid, #C8D9CE);
  border-radius: var(--radius-md);
  background: var(--white, #fff);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-light, #5d7366);
  transition: all var(--duration-fast) ease;
  flex-shrink: 0;
}
.plus-btn:hover { border-color: var(--teal, #1a6b5a); color: var(--teal, #1a6b5a); background: var(--teal-pale); }
.plus-menu {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: var(--white, #ffffff);
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md, 0 8px 32px rgba(0,0,0,0.10));
  padding: 6px;
  min-width: 240px;
  z-index: 200;
}
.plus-menu.open { display: block; animation: bfTabFade 150ms ease; }
.plus-menu-item {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 14px;
  border: none; background: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--text-base); color: #1f2937;
  width: 100%; text-align: left;
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  transition: background var(--duration-fast) ease;
  position: relative;
  letter-spacing: -0.01em;
}
.plus-menu-item:hover { background: var(--surface-hover, #FAFAF8); }
.plus-menu-item svg { color: var(--text-mid, #4A5C52); flex-shrink: 0; }
.plus-menu-item:hover svg { color: var(--text, #111C17); }
.plus-menu-arrow {
  margin-left: auto;
  color: var(--text-light, #5d7366);
}
/* Submenu — appears to the right */
.plus-menu-sub-wrap { position: relative; }
.plus-sub-menu {
  display: none;
  position: absolute;
  left: calc(100% + 6px);
  bottom: -6px;
  background: var(--white, #ffffff);
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md, 0 8px 32px rgba(0,0,0,0.10));
  padding: 8px;
  min-width: 240px;
  max-height: 400px;
  overflow-y: auto;
  z-index: 201;
}
.plus-sub-menu.open { display: block; animation: bfTabFade 150ms ease; }
/* Source group labels */
.source-group-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  padding: 6px 14px 2px;
}
.source-group-label:first-child { padding-top: 2px; }
/* Court sub-filters */
.court-filters {
  padding: 0 8px 4px 28px;
  display: none;
}
.court-filters.visible { display: block; }
.court-filter-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--teal);
  cursor: pointer;
  padding: 4px 0;
  user-select: none;
}
.court-filter-header:hover { color: var(--teal-mid); }
.court-filter-header svg { transition: transform 150ms ease; }
.court-filters.expanded .court-filter-header svg { transform: rotate(180deg); }
.court-filter-list {
  display: none;
  padding: 2px 0 4px;
}
.court-filters.expanded .court-filter-list { display: block; }
.court-filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 13px;
  color: var(--text-mid);
  cursor: pointer;
}
.court-filter-item:hover { color: var(--text); }
.court-filter-item input[type="checkbox"] {
  accent-color: var(--teal);
  width: 14px;
  height: 14px;
  cursor: pointer;
}
/* Source toggle rows — like Claude's connector toggles */
.source-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--duration-fast) ease;
}
.source-toggle:hover { background: #EAF4EE; }
.source-toggle-info {
  display: flex; align-items: center; gap: 10px;
  font-size: var(--text-base); color: #1f2937;
  font-family: 'Roboto', 'Noto Sans', sans-serif;
}
.source-toggle-info svg { color: #4A5C52; flex-shrink: 0; }
/* Toggle switch */
.source-switch {
  -webkit-appearance: none; appearance: none;
  width: 36px; height: 20px;
  background: #C8D9CE;
  border-radius: var(--radius-lg);
  position: relative;
  cursor: pointer;
  transition: background var(--duration-normal) ease;
  flex-shrink: 0;
}
.source-switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--duration-normal) ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.source-switch:checked { background: #1a6b5a; }
.source-switch:checked::after { transform: translateX(16px); }
/* Active sources label */
.input-action-label {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--text-sm-); color: #5d7366;
  padding: 4px 0;
  font-family: 'Roboto', 'Noto Sans', sans-serif;
}
/* Prompts submenu */
.prompts-sub { min-width: 320px; max-height: 400px; overflow-y: auto; }
.prompts-category {
  font-size: var(--text-2xs); font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.8px; color: #5d7366; padding: 10px 12px 4px;
}
.prompts-category:first-child { padding-top: 4px; }
.prompt-item {
  display: block; width: 100%; text-align: left;
  padding: 8px 12px; border: none; background: none;
  border-radius: var(--radius-sm); cursor: pointer;
  font-size: var(--text-sm); color: #111C17; line-height: 1.4;
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  transition: background var(--duration-fast) ease;
}
.prompt-item:hover { background: var(--teal-pale); color: #1a6b5a; }
/* Keep old class for backward compat */
.source-menu { display: none; }
.source-menu.open { display: block; }
.source-menu-title { display: none; }
.source-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--duration-fast) ease;
}
.source-option:hover { background: var(--bg, #FAFAF8); }
.source-option input[type="checkbox"] {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  accent-color: #1a6b5a;
  flex-shrink: 0;
  cursor: pointer;
}
.source-option svg {
  color: #4A5C52;
  flex-shrink: 0;
  margin-top: 1px;
}
.source-name {
  font-size: var(--text-sm);
  font-weight: 500;
  color: #111C17;
  line-height: 1.4;
}
.source-desc {
  font-size: var(--text-xs);
  color: #5d7366;
  margin-top: 2px;
  line-height: 1.4;
}

/* ── SKELETON LOADING ── */
.skeleton {
  background: linear-gradient(90deg, var(--bg2, #EAF4EE) 25%, var(--border, #E4EBE7) 50%, var(--bg2, #EAF4EE) 75%);
  background-size: 200% 100%;
  animation: bfShimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
@keyframes bfShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-line { height: 12px; margin-bottom: 8px; border-radius: var(--radius-sm); }
.skeleton-line.short { width: 60%; }
.skeleton-line.medium { width: 80%; }
.skeleton-item {
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── APP STYLES ── */
#bf {
  /* ── Color tokens ── */
  --white:      #ffffff;
  --bg:         #FAFAF8;
  --bg2:        #EAF4EE;
  --border:     #E4EBE7;
  --border-mid: #C8D9CE;
  --text:       #111C17;
  --text-mid:   #4A5C52;
  --text-light: #5d7366;
  --teal:       #1a6b5a;
  --teal-mid:   #145a4a;
  --teal-light: #4A9B6F;
  --teal-pale:  #EAF4EE;
  --accent:     var(--teal);
  --danger:     #C0392B;
  --danger-pale:#fef2f2;
  --danger-dark:#991b1b;
  --success:    #16a34a;
  --success-pale:#d1fae5;
  --success-dark:#065f46;
  --warning:    #d97706;
  --warning-pale:#fef3c7;
  --warning-dark:#92400e;
  --info:       #6366f1;
  --info-pale:  #eef2ff;

  /* ── Shadow elevation ── */
  --shadow-xs:  0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm:  0 1px 4px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:     0 2px 12px rgba(0,0,0,0.06), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-md:  0 6px 24px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04);
  --shadow-lg:  0 12px 48px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);

  /* ── Border radius ── */
  --radius-xs:   4px;
  --radius-sm:   6px;
  --radius-base: 8px;
  --radius-md:   10px;
  --radius-card: 12px;
  --radius-lg:   14px;
  --radius-xl:   16px;
  --radius-2xl:  24px;
  --radius-full: 9999px;

  /* ── Spacing scale (4px base) ── */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;

  /* ── Typography scale ── */
  --text-2xs:  10px;
  --text-xs:   11px;
  --text-sm-:  12px;
  --text-sm:   13px;
  --text-base: 14px;
  --text-md:   16px;
  --text-lg:   20px;
  --text-xl:   26px;
  --text-hero: 36px;

  /* ── Transitions ── */
  --ease-default: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast: 150ms;
  --duration-normal: 200ms;
  --duration-slow: 300ms;

  /* ── Z-index layers ── */
  --z-dropdown:  200;
  --z-sticky:    500;
  --z-sidebar:   1000;
  --z-modal:     3000;
  --z-overlay:   5000;
  --z-toast:     9999;
  --z-top:       10000;

  /* ── Semantic surfaces ── */
  --surface:              var(--white);
  --surface-hover:        var(--bg);
  --surface-active:       var(--bg2);
  --surface-border:       var(--border);
  --surface-border-hover: var(--border-mid);

  /* ── Toast ── */
  --toast-bg: #111827;

  /* ── Focus ring ── */
  --focus-ring: 0 0 0 3px rgba(26,107,90,0.1);

  font-family: 'Roboto', 'Noto Sans', sans-serif;
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: none;
  border-radius: 0;
}
#bf * { margin: 0; padding: 0; box-sizing: border-box; }

/* ── Accessibility: focus-visible ── */
#bf :focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}
#bf :focus:not(:focus-visible) {
  outline: none;
}

/* ── Accessibility: reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Global scrollbar styling ── */
#bf ::-webkit-scrollbar { width: 6px; }
#bf ::-webkit-scrollbar-track { background: transparent; }
#bf ::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 3px; }
#bf ::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* ── SIDEBAR ── */
#bf .sb {
  width: 280px;
  min-width: 280px;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--duration-normal) ease, min-width var(--duration-normal) ease;
}
#bf .sb.collapsed {
  width: 0;
  min-width: 0;
  border-right: none;
  overflow: hidden;
}
#bf .sb-toggle {
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  font-size: var(--text-base);
  flex-shrink: 0;
  margin-left: auto;
  transition: background var(--duration-fast) ease, color var(--duration-fast) ease;
}
#bf .sb-toggle:hover {
  background: var(--bg2);
  color: var(--text);
}
/* Sidebar brand area */
#bf .sb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 8px;
}
#bf .sb-brand-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}
#bf .sb-brand-text h1 {
  font-family: 'Noto Sans', 'Roboto', sans-serif;
  font-size: var(--text-lg);
  font-weight: 400;
  color: var(--teal);
  line-height: 1.2;
  letter-spacing: -0.01em;
}
#bf .sb-brand-text .sb-firm {
  font-size: var(--text-xs);
  color: var(--text-light);
  line-height: 1.3;
}
/* Sidebar search */
#bf .sb-search {
  padding: 4px 16px 8px;
}
#bf .sb-search-input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1.5px solid transparent;
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  color: var(--text);
  background: var(--bg2);
  outline: none;
  transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}
#bf .sb-search-input:focus-visible {
  border-color: var(--teal);
  background: var(--white);
}
#bf .sb-search-input::placeholder { color: var(--text-light); }
#bf .sb-top {
  padding: 8px 16px 12px;
  border-bottom: none;
}
#bf .new-btn {
  width: 100%;
  height: 40px;
  padding: 0 var(--space-4);
  background: var(--teal);
  border: none;
  border-radius: var(--radius-lg);
  color: var(--white);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  transition: all var(--duration-fast) ease;
}
#bf .new-btn:hover { background: var(--teal-mid); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(26,107,90,0.25); }
#bf .new-btn:active { background: var(--teal-mid); transform: translateY(0); box-shadow: none; }
#bf .sb-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px;
}
/* scrollbar handled by global #bf ::-webkit-scrollbar */
/* Collapsible section headers */
#bf .sb-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 8px 6px;
  cursor: pointer;
  user-select: none;
}
#bf .sb-section-header:hover .sb-label { color: var(--text-mid); }
#bf .sb-section-toggle {
  font-size: var(--text-2xs);
  color: var(--text-light);
  transition: transform var(--duration-normal) ease;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
}
#bf .sb-section-toggle.collapsed { transform: rotate(-90deg); }
#bf .sb-section-content {
  overflow: hidden;
  transition: max-height var(--duration-normal) ease;
}
#bf .sb-section-content.collapsed {
  max-height: 0 !important;
  overflow: hidden;
}
#bf .sb-label {
  font-size: var(--text-2xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-light);
  padding: 16px 8px 6px;
  transition: color var(--duration-fast) ease;
}
#bf .sb-add-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-light);
  font-size: var(--text-md);
  line-height: 1;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--duration-fast) ease;
}
#bf .sb-add-btn:hover {
  color: var(--teal);
  background: var(--bg2);
}
/* Collapse arrow for sidebar sections */
.sb-collapse-arrow { transition: transform var(--duration-normal) ease; }
.sb-collapse-arrow.collapsed { transform: rotate(-90deg); }
#bf .sb-scroll .collapsed { max-height: 0; overflow: hidden; }
/* ── REUSABLE BUTTON CLASSES ── */
.bf-btn-primary-sm {
  padding: 0 14px;
  height: 36px;
  background: var(--teal);
  color: var(--white);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  white-space: nowrap;
  transition: all var(--duration-fast) ease;
}
.bf-btn-primary-sm:hover { background: var(--teal-mid); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(26,107,90,0.25); }
.bf-btn-primary-sm:active { transform: translateY(0); box-shadow: none; }
/* ── Conversation item ── */
#bf .conv-item {
  padding: 8px 10px;
  height: 36px;
  border-radius: var(--radius-md);
  cursor: pointer;
  margin-bottom: 2px;
  transition: background var(--duration-fast) ease;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  border-left: 3px solid transparent;
}
#bf .conv-item:hover { background: var(--bg2); }
#bf .conv-item.active { background: var(--teal-pale); border-left-color: var(--teal); }
#bf .conv-drag {
  cursor: grab;
  color: var(--text-light);
  font-size: var(--text-sm-);
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--duration-fast) ease;
  user-select: none;
  padding: 2px;
}
#bf .conv-item:hover .conv-drag { opacity: 0.7; }
#bf .conv-item.dragging { opacity: 0.4; }
#bf .conv-info { flex: 1; min-width: 0; }
#bf .conv-title {
  font-size: var(--text-sm);
  color: var(--text-mid);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  outline: none;
  line-height: 1.4;
}
#bf .conv-item.active .conv-title { color: var(--teal); font-weight: 500; }
#bf .conv-title[contenteditable="true"] {
  background: var(--white);
  border: 1px solid var(--teal);
  border-radius: var(--radius-xs);
  padding: 2px 6px;
  white-space: nowrap;
  overflow: hidden;
  color: var(--text);
  font-weight: 400;
  box-shadow: var(--focus-ring);
}
#bf .conv-stream-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--teal);
  margin-right: 5px;
  vertical-align: middle;
  animation: bfpulse 1.2s ease-in-out infinite;
}
#bf .conv-meta { font-size: var(--text-2xs); color: var(--text-light); margin-top: 2px; line-height: 1.4; }
#bf .conv-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--duration-fast) ease;
}
#bf .conv-item:hover .conv-actions { opacity: 1; }
#bf .conv-act {
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  font-size: var(--text-sm-);
  transition: all var(--duration-fast) ease;
}
#bf .conv-act:hover { background: var(--bg2); color: var(--text); }
#bf .conv-act.del:hover { color: var(--danger); background: rgba(239,68,68,0.08); }
#bf .drop-line {
  height: 2px;
  background: var(--teal);
  border-radius: 1px;
  margin: 1px 4px;
  display: none;
}
#bf .drop-line.active { display: block; }

/* ── Move-to-case dropdown ── */
#bf .move-menu {
  position: absolute;
  right: 0;
  top: 100%;
  background: var(--white);
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: 500;
  min-width: 180px;
  max-height: 220px;
  overflow-y: auto;
}
#bf .move-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  font-size: var(--text-sm-);
  color: var(--text-mid);
  background: none;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all var(--duration-fast) ease;
}
#bf .move-menu-item:hover { background: var(--bg2); color: var(--teal); }
#bf .move-menu-item.new-case { color: var(--teal); font-weight: 500; border-top: 1px solid var(--border); margin-top: 2px; padding-top: 8px; }
/* ── PREVIEW PANEL — Claude-style artifact viewer ── */
#bf .preview-panel {
  width: 0;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--white);
  border-left: 1px solid var(--border);
  transition: width var(--duration-slow) var(--ease-default), min-width var(--duration-slow) var(--ease-default);
  position: relative;
}
#bf .preview-panel.open {
  width: 45%;
  min-width: 380px;
  max-width: 600px;
  flex-shrink: 0;
}
#bf .preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--white);
  flex-shrink: 0;
  min-height: 52px;
  gap: 12px;
}
#bf .preview-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
#bf .preview-icon { color: var(--teal); flex-shrink: 0; }
#bf .preview-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#bf .preview-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
#bf .preview-dl-wrap {
  display: flex;
  gap: 4px;
}
#bf .preview-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border: 1px solid var(--border-mid);
  border-radius: 7px;
  background: var(--white);
  font-size: var(--text-sm-);
  font-weight: 500;
  font-family: inherit;
  color: var(--text-mid);
  cursor: pointer;
  transition: all var(--duration-fast) ease;
  white-space: nowrap;
}
#bf .preview-btn:hover { background: var(--bg2); color: var(--teal); border-color: var(--teal); }
#bf .preview-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-light);
  transition: all var(--duration-fast) ease;
}
#bf .preview-close:hover { background: var(--bg2); color: var(--text); }
#bf .preview-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm-);
  color: var(--teal);
  flex-shrink: 0;
}
#bf .preview-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal);
  animation: previewPulse 1.2s ease-in-out infinite;
}
@keyframes previewPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
#bf .preview-body {
  flex: 1;
  overflow-y: auto;
  padding: 32px 24px;
  background: #f5f5f0;
}
#bf .preview-doc {
  max-width: 210mm;
  margin: 0 auto;
  background: var(--white);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.04);
  border-radius: 2px;
  padding: 40px 48px;
  min-height: 60vh;
  font-family: 'Times New Roman', 'Georgia', serif;
  font-size: var(--text-sm);
  line-height: 1.6;
  color: #111;
}
#bf .preview-doc h1 { font-size: var(--text-lg); text-align: center; text-transform: uppercase; margin: 24px 0 16px; font-weight: 700; }
#bf .preview-doc h2 { font-size: var(--text-base); font-weight: 700; margin: 18px 0 10px; }
#bf .preview-doc h3 { font-size: var(--text-base); font-weight: 700; font-style: italic; margin: 14px 0 8px; }
#bf .preview-doc p { margin: 0 0 10px; text-align: justify; }
#bf .preview-doc ul, #bf .preview-doc ol { margin: 0 0 10px; padding-left: 24px; }
#bf .preview-doc li { margin-bottom: 4px; }
#bf .preview-doc table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: var(--text-sm-); }
#bf .preview-doc table th, #bf .preview-doc table td { border: 1px solid #ccc; padding: 6px 10px; text-align: left; }
#bf .preview-doc table th { background: #f0f0f0; font-weight: 600; }
#bf .preview-doc hr { border: none; border-top: 1px solid #ddd; margin: 20px 0; }
/* Empty state */
/* Draft-active mode: chat stays visible, preview takes right half */
#bf .preview-doc[contenteditable="true"] { outline: none; cursor: text; }
#bf .preview-doc[contenteditable="true"]:focus { box-shadow: 0 0 0 2px var(--teal-light, rgba(26,107,90,0.15)); }
/* Revision input bar at bottom of preview panel */
#bf .preview-revision-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--white);
  flex-shrink: 0;
}
#bf .preview-revision-input {
  flex: 1;
  padding: 8px 14px;
  border: 1.5px solid var(--border-mid, #d1d5db);
  border-radius: var(--radius-base);
  font-size: 13px;
  font-family: inherit;
  background: var(--bg2, #f9fafb);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  resize: none;
  max-height: 80px;
  min-height: 36px;
}
#bf .preview-revision-input:focus { border-color: var(--teal); }
#bf .preview-revision-input::placeholder { color: var(--text-light); }
#bf .preview-revision-send {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-base);
  border: none;
  background: var(--teal);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
#bf .preview-revision-send:hover { background: var(--teal-dark, #145a4a); }
#bf .preview-revision-send:disabled { opacity: 0.5; cursor: default; }
/* Empty state */
#bf .preview-doc:empty::after {
  content: '';
  display: block;
}

/* ── DRAFT ARTIFACT CARD ── */
#bf .draft-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  margin: 12px 0;
  transition: background var(--duration-fast) ease, border-color var(--duration-fast) ease;
}
#bf .draft-card:hover { background: var(--surface-hover); border-color: var(--surface-border-hover); }
#bf .draft-card-icon {
  width: 40px;
  height: 40px;
  background: var(--surface-active);
  border: none;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
#bf .draft-card-icon svg { color: var(--text-light); }
#bf .draft-card-info { flex: 1; min-width: 0; }
#bf .draft-card-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#bf .draft-card-meta {
  font-size: var(--text-sm-);
  color: var(--text-light);
  margin-top: 2px;
}
#bf .draft-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
#bf .draft-card-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  background: var(--white);
  font-size: var(--text-sm-);
  font-weight: 500;
  font-family: inherit;
  color: var(--text-mid);
  cursor: pointer;
  transition: all var(--duration-fast) ease;
  white-space: nowrap;
}
#bf .draft-card-btn:hover { background: var(--bg2); color: var(--teal); border-color: var(--teal); }
#bf .draft-card-btn img { width: 18px; height: 18px; }
/* draft-card dark mode handled by surface token overrides */
/* draft-card icon/btn dark mode handled by surface token overrides */

/* ── PINNED DOCUMENTS SECTION ── */
#bf .pinned-docs { margin-top: 20px; }
#bf .pinned-docs-title {
  font-size: var(--text-sm-);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  margin-bottom: 10px;
  padding-left: 2px;
}
#bf .pinned-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  margin-bottom: 8px;
  transition: background var(--duration-fast) ease, border-color var(--duration-fast) ease;
  cursor: default;
}
#bf .pinned-card:hover { background: var(--surface-hover); border-color: var(--surface-border-hover); }
#bf .pinned-card-icon {
  width: 40px; height: 40px;
  background: var(--surface-active);
  border: none;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
#bf .pinned-card-icon svg { color: var(--teal); }
#bf .pinned-card-info { flex: 1; min-width: 0; }
#bf .pinned-card-title {
  font-size: var(--text-base); font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#bf .pinned-card-meta {
  font-size: var(--text-sm-); color: var(--text-light); margin-top: 2px;
  display: flex; align-items: center; gap: 6px;
}
#bf .pinned-card-meta .pin-badge {
  display: inline-flex; align-items: center; gap: 3px;
  color: var(--teal); font-weight: 500;
}
#bf .pinned-card-actions {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}
#bf .pinned-card-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 12px; border: 1px solid var(--border-mid); border-radius: var(--radius-md);
  background: var(--white); color: var(--text-mid); font-size: var(--text-sm-);
  font-weight: 500; cursor: pointer; transition: all var(--duration-fast) ease; white-space: nowrap;
  font-family: inherit;
}
#bf .pinned-card-btn:hover { background: var(--bg2); color: var(--teal); border-color: var(--teal); }
/* pinned-card dark mode handled by surface token overrides */
/* Pin toggle in library */
#bf .lib-pin-btn {
  background: none; border: none; cursor: pointer; padding: 4px;
  color: var(--text-light); transition: color var(--duration-fast) ease; font-size: var(--text-md);
}
#bf .lib-pin-btn:hover, #bf .lib-pin-btn.pinned { color: var(--teal); }

/* ── MAIN AREA ── */
#bf .main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}
#bf .chat-header {
  height: 56px;
  padding: 0 32px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  background: var(--white);
}
#bf .header-title {
  font-family: 'Noto Sans', 'Roboto', sans-serif;
  font-size: 20px;
  font-weight: 400;
  color: var(--text);
  flex: 1;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
#bf .header-pill {
  font-size: var(--text-sm-);
  height: 32px;
  padding: 0 14px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border-mid);
  background: var(--bg);
  color: var(--text-mid);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--duration-fast) ease;
}
#bf .header-pill:hover { border-color: var(--teal); color: var(--teal); background: var(--bg2); }
/* Conversation download button */
#bf .conv-dl-wrap { position: relative; display: inline-flex; }
#bf .conv-dl-btn {
  background: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 5px 8px; cursor: pointer; color: var(--text-mid); display: flex; align-items: center;
  transition: all 0.15s;
}
#bf .conv-dl-btn:hover { border-color: var(--teal); color: var(--teal); background: var(--bg2); }
#bf .conv-dl-menu {
  display: none; position: absolute; top: 100%; right: 0; margin-top: 4px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1); z-index: 100; min-width: 140px;
}
#bf .conv-dl-menu.open { display: block; }
#bf .conv-dl-menu button {
  display: block; width: 100%; padding: 8px 14px; border: none; background: none;
  text-align: left; cursor: pointer; font-size: var(--text-sm); color: var(--text);
  font-family: 'Roboto', 'Noto Sans', sans-serif;
}
#bf .conv-dl-menu button:hover { background: var(--bg2); color: var(--teal); }
#bf .chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  scroll-behavior: smooth;
}
/* chat-body scrollbar handled by global #bf ::-webkit-scrollbar */
/* ── WELCOME SCREEN ── */
#bf .welcome {
  max-width: 600px !important;
  width: 100% !important;
  margin: 32px auto 0;
  text-align: center;
  animation: bfin 300ms ease;
  padding: 0 20px;
  box-sizing: border-box;
}
@keyframes bfin {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
#bf .welcome h2 {
  font-family: 'Noto Sans', 'Roboto', sans-serif;
  font-size: var(--text-hero);
  font-weight: 400;
  color: var(--text);
  letter-spacing: -0.01em;
  margin-bottom: var(--space-3);
  line-height: 1.2;
}
#bf .welcome p {
  font-size: var(--text-md);
  color: var(--text-mid);
  line-height: 1.6;
  max-width: 420px;
  margin: 0 auto var(--space-8);
  padding: 0;
}
/* Horizontal scrolling pill suggestions */
#bf .sug-grid {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 0 12px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  text-align: left;
}
#bf .sug-grid::-webkit-scrollbar { display: none; }
#bf .sug {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-2xl);
  padding: 12px 20px;
  cursor: pointer;
  transition: all var(--duration-normal) ease;
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  text-align: left;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  white-space: normal;
  width: 280px;
  min-height: 60px;
}
#bf .sug:hover {
  border-color: var(--teal);
  color: var(--text);
  background: var(--surface-active);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(26,107,90,0.12);
}
#bf .sug:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
#bf .sug-icon { font-size: var(--text-md); display: inline; flex-shrink: 0; margin-bottom: 0; }
#bf .sug-text {
  font-size: var(--text-sm);
  font-weight: 450;
  color: var(--text-mid);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* ── MESSAGES ── */
#bf .msgs { max-width: 720px; margin: 0 auto; }
#bf .msg  { margin-bottom: 24px; animation: bfin 250ms ease; }
#bf .msg-user { display: flex; justify-content: flex-end; margin-bottom: 16px; }
#bf .bubble-user {
  background: var(--teal);
  color: #fff;
  padding: var(--space-3) 18px;
  border-radius: 18px 18px 4px 18px;
  max-width: 70%;
  font-size: var(--text-base);
  line-height: 1.5;
}
#bf .msg-ai { display: flex; gap: 12px; align-items: flex-start; }
#bf .ai-av {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--teal);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-2xs);
  font-weight: 700;
  color: #fff;
  font-family: 'JetBrains Mono', monospace;
  flex-shrink: 0;
  margin-top: 2px;
}
#bf .ai-body { flex: 1; min-width: 0; }
#bf .ai-from {
  font-size: var(--text-2xs);
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 8px;
  line-height: 1.4;
}
/* ── Answer Card — clean document typography ── */
#bf .answer-card {
  font-size: var(--text-base);
  line-height: 1.8;
  color: var(--text);
}
/* Error card */
#bf .error-card {
  border: 1px solid #e8a9a3;
  color: var(--danger);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  background: #fef2f2;
  line-height: 1.5;
}
#bf .bf-retry-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 16px;
  border: 1px solid var(--danger);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--danger);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background .15s, color .15s;
}
#bf .bf-retry-btn:hover {
  background: var(--danger);
  color: #fff;
}
#bf .answer-card h1 {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text);
  margin: 0 0 16px;
  line-height: 1.35;
  letter-spacing: -0.01em;
}
#bf .answer-card h2 {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--text);
  margin: 28px 0 10px;
  display: block;
  line-height: 1.35;
  letter-spacing: -0.01em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}
#bf .answer-card h2::before { display: none; }
#bf .answer-card h3 {
  font-size: var(--text-base);
  font-weight: 700;
  font-style: normal;
  color: var(--text);
  margin: 22px 0 8px;
  line-height: 1.35;
}
#bf .answer-card h4 {
  font-size: var(--text-base);
  font-weight: 600;
  font-style: normal;
  color: var(--text);
  margin: 16px 0 4px;
  line-height: 1.35;
}
#bf .answer-card p { margin-bottom: 12px; }
#bf .answer-card p:last-child { margin-bottom: 0; }
#bf .answer-card ul, #bf .answer-card ol { padding-left: 24px; margin-bottom: 12px; }
#bf .answer-card li { margin-bottom: 6px; }
#bf .answer-card strong { font-weight: 600; }
#bf .answer-card em { color: var(--text); font-style: italic; }
#bf .answer-card blockquote {
  border-left: 3px solid var(--teal, #1a6b5a);
  background: rgba(26,107,90,0.04);
  margin: 12px 0;
  padding: 10px 16px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text);
  font-size: var(--text-base);
  line-height: 1.7;
}
#bf .answer-card blockquote em {
  color: var(--text-mid);
}
#bf .answer-card hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
#bf .answer-card code {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-sm-);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
}
#bf .answer-card table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: var(--text-sm);
}
#bf .answer-card th {
  padding: 8px 12px;
  text-align: left;
  font-weight: 700;
  color: var(--text);
  border-bottom: 2px solid var(--text);
}
#bf .answer-card td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
#bf .answer-card tr:last-child td { border-bottom: none; }
/* Links */
#bf .answer-card a {
  color: var(--teal);
  border-bottom: none;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(26,107,90,0.3);
  text-underline-offset: 2px;
  transition: color var(--duration-fast) ease;
}
#bf .answer-card a:hover { color: var(--teal-mid); }
#bf .answer-card a.case-link { font-weight: 500; }
#bf .cite-wrap { display: inline; position: relative; }
#bf .cite-copy {
  display: inline-block;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  padding: 1px 4px;
  margin-left: 4px;
  vertical-align: middle;
  opacity: 0.5;
  transition: opacity 0.15s;
  line-height: 1;
}
#bf .cite-copy:hover { opacity: 1; background: var(--bg2); }

/* ── Sources ── */
#bf .sources {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
#bf .src-label {
  font-size: var(--text-2xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-light);
  margin-bottom: 8px;
}
#bf .src-row { font-size: var(--text-sm); color: var(--text-mid); line-height: 1.9; }
#bf .src-row a {
  color: var(--teal);
  border-bottom: none;
  font-size: var(--text-sm);
  text-decoration: underline;
  text-decoration-color: rgba(26,107,90,0.3);
  text-underline-offset: 2px;
  transition: color var(--duration-fast) ease;
}
#bf .src-row a:hover { color: var(--teal-mid); }

/* ── Message actions ── */
#bf .msg-actions { display: flex; gap: 6px; margin-top: 10px; opacity: 0; transition: opacity var(--duration-fast) ease; }
#bf .msg-ai:hover .msg-actions { opacity: 1; }
#bf .act {
  font-size: var(--text-xs);
  height: 28px;
  color: var(--text-mid);
  background: var(--white);
  border: 1px solid var(--border);
  padding: 0 10px;
  border-radius: var(--radius-xl);
  cursor: pointer;
  transition: all var(--duration-fast) ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  font-weight: 500;
}
#bf .act:hover { color: var(--teal); border-color: var(--teal); }
#bf .act.liked    { color: var(--success); border-color: #86efac; background: var(--success-pale); }
#bf .act.disliked { color: var(--danger); border-color: #e8a9a3; background: var(--danger-pale); }
#bf .act.fb-sent  { color: var(--teal); border-color: var(--teal); background: var(--bg2); }
#bf .act.pinned   { color: var(--teal); border-color: var(--teal); background: var(--bg2); }
/* ── FEEDBACK MODAL ── */
#bf .fb-modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4); z-index: 3000;
  display: flex; align-items: center; justify-content: center;
  animation: bfin 150ms ease;
}
#bf .fb-modal {
  background: var(--white); border-radius: var(--radius-xl); padding: 28px 32px;
  width: 420px; max-width: 90vw;
  box-shadow: var(--shadow-md);
}
#bf .fb-modal h3 { margin: 0 0 8px; font-size: var(--text-md); color: var(--text); font-weight: 600; }
#bf .fb-modal p { margin: 0 0 16px; font-size: var(--text-sm); color: var(--text-mid); line-height: 1.5; }
#bf .fb-modal textarea {
  width: 100%; height: 100px; border: 1.5px solid var(--border-mid); border-radius: var(--radius-lg);
  padding: 12px; font-size: var(--text-sm); font-family: 'Roboto', 'Noto Sans', sans-serif;
  resize: vertical; color: var(--text); outline: none; background: var(--white);
  transition: border-color var(--duration-fast) ease;
  line-height: 1.5;
}
#bf .fb-modal textarea:focus-visible { border-color: var(--teal); box-shadow: var(--focus-ring); }
#bf .fb-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
#bf .fb-modal-actions button {
  height: 36px; padding: 0 18px; border-radius: var(--radius-2xl); font-size: var(--text-sm);
  font-family: 'Roboto', 'Noto Sans', sans-serif; cursor: pointer; font-weight: 500;
  transition: all var(--duration-fast) ease;
}
#bf .fb-modal .btn-cancel { background: var(--bg2); border: 1px solid var(--border); color: var(--text-mid); }
#bf .fb-modal .btn-cancel:hover { background: var(--border); }
#bf .fb-modal .btn-send { background: var(--teal); border: none; color: #fff; }
#bf .fb-modal .btn-send:hover { background: var(--teal-mid); }
/* ── PROJECTS ── */
#bf .proj-item {
  padding: 8px 10px;
  height: 36px;
  border-radius: var(--radius-md);
  cursor: pointer;
  margin-bottom: 2px;
  transition: background var(--duration-fast) ease;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}
#bf .proj-item:hover { background: var(--bg2); }
#bf .proj-item.active { background: var(--teal-pale); }
#bf .proj-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-light); flex-shrink: 0;
  transition: background var(--duration-fast) ease;
}
#bf .proj-item.active .proj-dot { background: var(--teal); }
#bf .proj-name {
  font-size: var(--text-sm); color: var(--text-mid);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
  line-height: 1.4;
}
#bf .proj-item.active .proj-name { color: var(--teal); font-weight: 500; }
#bf .proj-actions { display:flex; gap:2px; flex-shrink:0; opacity:0; transition: opacity var(--duration-fast) ease; }
#bf .proj-item:hover .proj-actions { opacity:1; }
/* ── PROJECT MODAL ── */
#bfProjModal {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.4); z-index: 9000;
  align-items: center; justify-content: center;
}
#bfProjModal.open { display: flex; animation: bfFadeIn 150ms ease; }
#bfProjModal .modal-box {
  background: var(--white); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  padding: 28px 32px;
  width: 420px; max-width: 95vw;
}
#bfProjModal h3 {
  font-family: 'Noto Sans', 'Roboto', sans-serif; font-size: var(--text-md);
  font-weight: 700; color: var(--text); margin-bottom: 20px;
  line-height: 1.4;
}
#bfProjModal label {
  display: block; font-size: var(--text-xs); font-weight: 600;
  color: var(--text-mid); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px;
}
#bfProjModal input, #bfProjModal textarea {
  width: 100%; border: 1.5px solid var(--border-mid); border-radius: var(--radius-lg);
  padding: 12px; font-size: var(--text-base); font-family: 'Roboto', 'Noto Sans', sans-serif;
  color: var(--text); background: var(--white); outline: none;
  transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
  line-height: 1.5;
}
#bfProjModal input:focus-visible, #bfProjModal textarea:focus-visible {
  border-color: var(--teal);
  box-shadow: var(--focus-ring);
}
#bfProjModal textarea { resize: vertical; min-height: 80px; }
#bfProjModal .modal-field { margin-bottom: 16px; }
#bfProjModal .modal-actions {
  display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px;
}
#bfProjModal .btn-cancel {
  height: 36px; padding: 0 18px; background: var(--bg2);
  border: 1px solid var(--border); border-radius: var(--radius-2xl);
  font-size: var(--text-sm); font-weight: 500; cursor: pointer; font-family: 'Roboto', 'Noto Sans', sans-serif;
  color: var(--text-mid); transition: all var(--duration-fast) ease;
}
#bfProjModal .btn-cancel:hover { background: var(--border); }
#bfProjModal .btn-save {
  height: 36px; padding: 0 22px; background: var(--teal);
  border: none; border-radius: var(--radius-2xl); color: #fff;
  font-size: var(--text-sm); font-weight: 500; cursor: pointer;
  font-family: 'Roboto', 'Noto Sans', sans-serif; transition: background var(--duration-fast) ease;
}
#bfProjModal .btn-save:hover { background: var(--teal-mid); }
#bfProjModal .btn-save:disabled { background: var(--border-mid); cursor: not-allowed; }

/* Collab tags */
#bfProjModal .collab-list { display:flex; flex-wrap:wrap; gap:6px; margin-top:8px; }
#bfProjModal .collab-tag {
  display:flex; align-items:center; gap:4px;
  background: var(--bg2); border:1px solid rgba(26,107,90,0.2); border-radius:20px;
  padding:4px 10px; font-size:12px; color: var(--teal);
}
#bfProjModal .collab-tag button {
  background:none; border:none; cursor:pointer; color:rgba(26,107,90,0.5);
  font-size:14px; line-height:1; padding:0; display:flex; align-items:center;
  transition: color var(--duration-fast) ease;
}
#bfProjModal .collab-tag button:hover { color:#1a6b5a; }

/* Active project pill in header */
#bfProjPill {
  display: none; align-items: center; gap: 5px;
  font-size: var(--text-xs); height: 28px; padding: 0 12px; border-radius: var(--radius-2xl);
  background: var(--bg2); border: 1px solid rgba(26,107,90,0.15);
  color: var(--teal); font-weight: 500; cursor: pointer;
  white-space: nowrap; overflow: hidden; max-width: 180px;
  text-overflow: ellipsis; transition: all var(--duration-fast) ease;
}
#bfProjPill:hover { background: rgba(26,107,90,0.08); }
#bfProjPill.visible { display: flex; }
/* ── DOWNLOAD DROPDOWN ── */
#bf .dl-wrap { position: relative; display: inline-block; }
#bf .dl-menu {
  position: absolute; bottom: calc(100% + 6px); left: 0;
  background: var(--white); border: none; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md); padding: 6px;
  display: none; z-index: 200; min-width: 120px;
}
#bf .dl-menu.open { display: block; animation: bfTabFade 150ms ease; }
#bf .dl-opt {
  display: block; width: 100%; text-align: left; padding: 8px 12px;
  font-size: var(--text-sm-); color: var(--text-mid); background: none; border: none;
  cursor: pointer; border-radius: var(--radius-sm); font-family: 'Roboto', 'Noto Sans', sans-serif; white-space: nowrap;
  transition: all var(--duration-fast) ease;
}
#bf .dl-opt:hover { background: var(--bg); color: var(--teal); }
/* ── LOADING STATUS ── */
#bf .think-status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--text-sm);
  color: var(--text-light);
  padding: 4px 0;
}
#bf .think-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--teal);
  flex-shrink: 0;
  animation: bfpulse 1.2s ease-in-out infinite;
}
@keyframes bfpulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.7); }
}
#bf .think-timer {
  margin-left: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-xs);
  color: var(--text-light);
}
/* ── INPUT AREA ── */
/* ── Usage bar (free plan) ── */
.usage-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 4px 24px;
  background: #f8f9fa;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-light, #666);
}

/* ── Free-plan limit lock ──────────────────────────────────────────────
   Applied when a Free user has used all 10 monthly actions. The textarea
   is set readOnly (not disabled) so click events still reach our handler;
   the visual cues below tell the user it's locked, and a click anywhere
   on the input-wrap routes them to the upgrade modal (see
   _applyChatInputLimitGate + the global click-capture in app.js). */
.input-wrap.at-limit {
  cursor: not-allowed;
}
.input-wrap.at-limit textarea#bfIn {
  cursor: not-allowed;
  background: #f5f5f5;
  color: #999;
  pointer-events: none; /* let clicks bubble to the wrap-level handler */
}
.input-wrap.at-limit .send-btn,
.input-wrap.at-limit .plus-btn,
.input-wrap.at-limit .enhance-btn {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
.input-wrap.at-limit .input-box {
  background: #fafafa;
  border-color: #e0e0e0;
}
.usage-bar .usage-text { font-weight: 500; }
.usage-bar .usage-text.near-limit { color: #d97706; }
.usage-bar .usage-text.at-limit { color: #dc2626; font-weight: 600; }
.usage-bar .usage-upgrade {
  font-size: 11px;
  font-weight: 600;
  color: var(--teal, #1B7A6E);
  text-decoration: none;
  padding: 2px 8px;
  border: 1px solid var(--teal, #1B7A6E);
  border-radius: 4px;
  transition: background 0.15s;
}
.usage-bar .usage-upgrade:hover { background: var(--teal, #1B7A6E); color: #fff; }

#bf .input-wrap {
  padding: 10px 24px 12px;
  background: var(--white);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Document chips */
#bf .doc-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; padding: 0 4px; }
/* Source bar + collapsible chips */
#bf .source-bar {
  padding: 4px 4px 2px;
}
#bf .source-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--white);
  color: var(--text-mid);
  font-size: 12px;
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
#bf .source-pill:hover { border-color: var(--teal); color: var(--teal); }
#bf .source-pill svg { flex-shrink: 0; }
#bf .source-pill-count {
  background: var(--teal);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}
#bf .source-pill-arrow {
  transition: transform 0.2s;
}
#bf .source-bar.expanded .source-pill-arrow {
  transform: rotate(180deg);
}
#bf .source-bar.expanded .source-pill {
  border-color: var(--teal);
  color: var(--teal);
}
#bf .source-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 0 2px;
}
#bf .src-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--white);
  color: var(--text-mid);
  font-size: 11px;
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
#bf .src-chip:hover { border-color: var(--teal); color: var(--teal); }
#bf .src-chip.active {
  background: rgba(26,107,90,0.08);
  border-color: var(--teal);
  color: var(--teal);
}
#bf .src-chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
}
#bf .src-chip.active .src-chip-dot { background: var(--teal); }

/* ── File cards (Claude-style) ─────────────────────────────────────── */
#bf .doc-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg2, #f8f9fa);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  padding: 8px 12px;
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  transition: border-color 0.15s, box-shadow 0.15s;
  max-width: 320px;
}
#bf .doc-card:hover {
  border-color: var(--teal, #009688);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
/* While uploading the chip stays visible (so the % counter is readable)
   but is slightly muted to signal "not yet usable". `position: relative`
   anchors the absolutely-positioned progress-fill bar inside the chip. */
#bf .doc-card.uploading {
  opacity: 0.85;
  position: relative;
  overflow: hidden;
}
/* Thin progress bar at the bottom edge of the chip. Its width is set
   inline via style="width:NN%" so we don't need a CSS variable round-trip. */
#bf .doc-card-progress {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  background: var(--teal, #009688);
  transition: width 0.15s linear;
  pointer-events: none;
}
/* Compact percentage / "processing..." label shown next to the filename
   while uploading. Kept short so it fits even on the 320px-wide chip. */
#bf .doc-card-status {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--teal, #009688);
  font-variant-numeric: tabular-nums;  /* keeps width stable as % counter ticks */
}
#bf .doc-card-status-failed { color: #c2413a; }

#bf .doc-card-icon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 44px;
  flex-shrink: 0;
  color: var(--teal, #009688);
}
#bf .doc-card-icon svg { width: 32px; height: 36px; }
#bf .doc-card-ext {
  position: absolute;
  bottom: 0;
  right: -2px;
  background: var(--teal, #009688);
  color: #fff;
  font-size: 8px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  letter-spacing: 0.3px;
  line-height: 1.2;
}

#bf .doc-card-info {
  flex: 1;
  min-width: 0;
}
#bf .doc-card-name {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text, #1a1a2e);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#bf .doc-card-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
#bf .doc-card-btn {
  background: var(--teal, #009688);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  cursor: pointer;
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  transition: opacity 0.15s;
}
#bf .doc-card-btn:hover { opacity: 0.85; }
#bf .doc-card-btn-remove {
  background: none;
  color: var(--text-light, #999);
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 4px;
}
#bf .doc-card-btn-remove:hover {
  background: rgba(0,0,0,0.06);
  color: var(--text, #333);
}
/* Cancel button shown only while uploading. Same affordance as the remove
   button but coloured to suggest "stop in progress" rather than "delete". */
#bf .doc-card-btn-cancel {
  background: none;
  border: 1px solid var(--border, #e2e8f0);
  color: var(--text-light, #999);
  font-size: 14px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
#bf .doc-card-btn-cancel:hover {
  background: #fdecea;
  color: #c2413a;
  border-color: #c2413a;
}

/* ── In-chat document cards ──────────────────────────────────────────── */
#bf .doc-inchat-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 600px;
}
#bf .doc-inchat-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg2, #f8f9fa);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  padding: 10px 14px;
  min-width: 200px;
  max-width: 290px;
  flex: 1;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#bf .doc-inchat-card:hover {
  border-color: var(--teal, #009688);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
#bf .doc-inchat-icon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 40px;
  flex-shrink: 0;
  color: var(--teal, #009688);
}
#bf .doc-inchat-ext {
  position: absolute;
  bottom: -2px;
  right: -4px;
  background: var(--teal, #009688);
  color: #fff;
  font-size: 7px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  letter-spacing: 0.3px;
}
#bf .doc-inchat-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
#bf .doc-inchat-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text, #1a1a2e);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#bf .doc-inchat-meta {
  font-size: 11px;
  color: var(--text-light, #999);
}
/* OCR status pill — sits next to the page-count meta on the in-chat
   doc card. Three visual states, mutated in place by bfPollDocOcrStatus:
     .doc-inchat-ocr-badge          → pending (orange, with spinner)
     .doc-inchat-ocr-badge.ready    → success (green, with check, fades out)
     .doc-inchat-ocr-badge.failed   → error   (red, no spinner)                */
#bf .doc-inchat-ocr-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
  margin-top: 2px;
  width: fit-content;
  transition: opacity 0.6s ease;
}
#bf .doc-inchat-ocr-badge.doc-inchat-ocr-ready {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
}
#bf .doc-inchat-ocr-badge.doc-inchat-ocr-failed {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
}
#bf .doc-inchat-ocr-spinner {
  width: 10px;
  height: 10px;
  border: 1.5px solid rgba(180, 83, 9, 0.3);
  border-top-color: #b45309;
  border-radius: 50%;
  animation: bf-ocr-spin 0.9s linear infinite;
  flex-shrink: 0;
}
#bf .doc-inchat-ocr-check {
  font-weight: 700;
  font-size: 12px;
  line-height: 1;
}
@keyframes bf-ocr-spin {
  to { transform: rotate(360deg); }
}
#bf .doc-inchat-view {
  background: none;
  border: 1px solid var(--border, #e2e8f0);
  color: var(--teal, #009688);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  cursor: pointer;
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  flex-shrink: 0;
  transition: all 0.15s;
}
#bf .doc-inchat-view:hover {
  background: var(--teal, #009688);
  color: #fff;
  border-color: var(--teal, #009688);
}
#bf .doc-inchat-remove {
  background: none;
  border: none;
  color: var(--text-light, #999);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  flex-shrink: 0;
  border-radius: 4px;
  transition: all 0.15s;
}
#bf .doc-inchat-remove:hover {
  background: rgba(0,0,0,0.06);
  color: var(--text, #333);
}

/* Upload progress in chat */
#bf .doc-upload-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg2, #f8f9fa);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  font-size: 13px;
  color: var(--text-mid, #666);
  max-width: 500px;
}
#bf .doc-upload-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border, #e2e8f0);
  border-top-color: var(--teal, #009688);
  border-radius: 50%;
  animation: bfSpin 0.8s linear infinite;
  flex-shrink: 0;
}
/* Right-side stack inside .doc-upload-progress: filename row, meta row,
   then a 4px progress bar pinned below. The bar fill width is updated
   inline via JS to drive the visible 0-100% animation. */
#bf .doc-upload-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
#bf .doc-upload-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text, #1a1a2e);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#bf .doc-upload-meta {
  font-size: 11px;
  color: var(--text-light, #999);
  font-variant-numeric: tabular-nums;
}
#bf .doc-upload-bar {
  margin-top: 4px;
  height: 4px;
  background: var(--border, #e2e8f0);
  border-radius: 2px;
  overflow: hidden;
}
#bf .doc-upload-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--teal, #009688);
  transition: width 0.15s linear;
}
/* Server-processing phase: bar held at 95% with a slow opacity pulse so
   the user sees "still working, not yet done". Never reaches 100% —
   the chip is replaced wholesale when the upload promise resolves. */
#bf .doc-upload-bar-fill.processing {
  animation: bfUploadPulse 1.6s ease-in-out infinite;
}
@keyframes bfUploadPulse {
  0%, 100% { opacity: 1;    }
  50%      { opacity: 0.45; }
}
@keyframes bfSpin {
  to { transform: rotate(360deg); }
}
#bf .doc-privacy {
  font-size: var(--text-xs);
  color: var(--text-light);
  margin: 4px 0 0;
  font-family: 'Roboto', 'Noto Sans', sans-serif;
}
#bf .doc-badge {
  font-size: 9px;
  padding: 2px 6px;
  border-radius: var(--radius-md);
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
#bf .doc-badge.temp {
  background: var(--bg2);
  color: var(--text-mid);
}
#bf .doc-badge.saved {
  background: var(--bg2);
  color: var(--teal);
}
#bf .bf-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--toast-bg);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-2xl);
  font-size: var(--text-sm);
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  z-index: 9999;
  opacity: 0;
  transition: opacity var(--duration-slow) ease;
  pointer-events: none;
  max-width: 90%;
  text-align: center;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
#bf .bf-toast.show { opacity: 1; pointer-events: auto; }
#bf .bf-toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--teal);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  animation: toastProgress linear forwards;
}
@keyframes toastProgress {
  from { width: 100%; }
  to { width: 0%; }
}

/* ── Custom alert/confirm modal ── */
#bf .bf-dialog-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  animation: bfin 150ms ease;
}
#bf .bf-dialog {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 28px 32px;
  width: 400px;
  max-width: 90vw;
  box-shadow: var(--shadow-md);
  font-family: 'Roboto', 'Noto Sans', sans-serif;
}
#bf .bf-dialog-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.4;
}
#bf .bf-dialog-title img,
#bf .bf-dialog-title svg { width: 20px; height: 20px; }
#bf .bf-dialog-msg {
  font-size: var(--text-base);
  color: var(--text-mid);
  line-height: 1.5;
  margin: 0 0 24px;
}
#bf .bf-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
#bf .bf-dialog-actions button {
  height: 38px;
  padding: 0 20px;
  border-radius: var(--radius-2xl);
  font-size: var(--text-sm);
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  cursor: pointer;
  font-weight: 500;
  transition: all var(--duration-fast) ease;
}
#bf .bf-dialog .btn-secondary {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text-mid);
}
#bf .bf-dialog .btn-secondary:hover { background: var(--border); }
#bf .bf-dialog .btn-primary {
  background: var(--teal);
  border: none;
  color: #fff;
}
#bf .bf-dialog .btn-primary:hover { background: var(--teal-mid); }
#bf .bf-dialog .btn-danger {
  background: var(--danger);
  border: none;
  color: #fff;
}
#bf .bf-dialog .btn-danger:hover { opacity: 0.85; }
/* ── Attach & Input ── */
#bf .attach-btn {
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  color: var(--text-light);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  transition: color var(--duration-fast) ease;
}
#bf .attach-btn:hover { color: var(--text-mid); }
#bf .input-inner { max-width: 720px; margin: 0 auto; }
#bf .input-box {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  background: var(--white);
  border: 1.5px solid var(--border-mid);
  border-radius: var(--radius-xl);
  padding: 12px 16px;
  min-height: 52px;
  transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
  box-sizing: border-box;
  box-shadow: var(--shadow-sm);
}
#bf .input-box:focus-within {
  border-color: var(--teal);
  box-shadow: var(--focus-ring), var(--shadow-sm);
}
#bf .input-box textarea {
  flex: 1;
  border: none;
  background: none;
  outline: none;
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  font-size: var(--text-base);
  color: var(--text);
  resize: none;
  line-height: 1.5;
  max-height: 120px;
  min-height: 22px;
  padding: 4px 0;
}
#bf .input-box textarea::placeholder { color: var(--text-light); }
#bf .enhance-btn {
  width: 34px;
  height: 34px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-light);
  transition: all var(--duration-fast) ease;
}
#bf .enhance-btn:hover { color: var(--teal); border-color: var(--teal); background: var(--bg2); }
#bf .enhance-btn.loading { animation: bfpulse 1s ease-in-out infinite; pointer-events: none; color: var(--teal); border-color: var(--teal); }
#bf .send-btn {
  width: 44px;
  height: 44px;
  background: var(--teal);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--duration-fast) ease;
}
#bf .send-btn:hover { background: var(--teal-mid); transform: scale(1.05); }
#bf .send-btn:active { background: var(--teal-mid); transform: scale(0.96); }
#bf .send-btn:disabled { background: var(--border); cursor: not-allowed; opacity: 0.4; transform: none; }
#bf .stop-btn {
  width: 34px;
  height: 34px;
  background: var(--danger);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--duration-fast) ease;
}
#bf .stop-btn:hover { opacity: 0.85; }

/* ── Mobile hamburger button (hidden on desktop) ── */
#bf .mob-menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  background: none; border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 0; cursor: pointer; font-size: var(--text-lg); color: var(--text-mid);
  flex-shrink: 0; line-height: 1; transition: all var(--duration-fast) ease;
  align-items: center; justify-content: center;
}
#bf .mob-menu-btn:hover { background: var(--bg); color: var(--text); }

/* ── Sidebar backdrop (mobile overlay) ── */
#bf .sb-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.4); z-index: 999;
}
#bf .sb-backdrop.open { display: block; animation: bfFadeIn 200ms ease; }

/* ── Tablet ── */
@media (max-width: 900px) {
  #bf .welcome { max-width: 100% !important; }
}

/* ── Mobile: sidebar as slide-in overlay ── */
@media (max-width: 700px) {
  .app-topbar { padding: 0 12px; height: 46px; }
  .app-topbar-brand h1 { font-size: 16px; }
  .product-switcher-btn { padding: 5px 12px; font-size: 12px; }
  .product-switcher-btn svg { width: 12px; height: 12px; }
  #bf { border-radius: 0; border-left: none; border-right: none; border-top: none; }
  #bf .sb {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 1000;
    transform: translateX(-280px); transition: transform var(--duration-normal) ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.1);
  }
  #bf .sb.open { transform: translateX(0); }
  #bf .mob-menu-btn { display: flex; }
  #bf .chat-header { height: 48px; padding: 0 12px; gap: 8px; }
  #bf .header-pill { display: none; }
  #bf .wf-pill span:not(.wf-badge) { display: none; }
  #bf .wf-pill { padding: 0 8px; min-width: 32px; justify-content: center; }
  #bf .chat-body { padding: 16px 12px; }
  #bf .welcome { margin-top: 8px; max-width: 100% !important; }
  #bf .welcome h2 { font-size: 20px; }
  #bf .welcome p { font-size: var(--text-sm); margin-bottom: 20px; white-space: normal; }
  #bf .sug { padding: 8px 14px; font-size: var(--text-sm-); }
  #bf .msgs { max-width: 100%; }
  #bf .bubble-user { max-width: 88%; font-size: var(--text-base); }
  #bf .answer-card { font-size: var(--text-base); line-height: 1.75; }
  #bf .msg-ai { gap: 8px; }
  #bf .ai-av { width: 24px; height: 24px; font-size: 9px; border-radius: var(--radius-sm); }
  #bf .input-wrap { padding: 8px 12px 12px; }
  #bf .input-inner { max-width: 100%; }
  #bf .input-box textarea { font-size: var(--text-base); }
  #bf .dl-menu { bottom: auto; top: calc(100% + 6px); }
  #bf .sb-brand { padding: 12px 16px 4px; }
  #bf .sb-toggle { display: none; }
  /* Touch-friendly minimum 44px targets */
  #bf .conv-item { min-height: 44px; }
  #bf .proj-item { min-height: 44px; }
  #bf .case-tab { min-height: 44px; }
  #bf .new-btn { min-height: 44px; }
  #bf .send-btn { width: 44px; height: 44px; }
  #bf .attach-btn { width: 44px; height: 44px; }
}

@media (max-width: 420px) {
  #bf .chat-body { padding: 12px 8px; }
  #bf .input-wrap { padding: 8px 8px 8px; }
  #bf .welcome h2 { font-size: var(--text-lg); }
  #bf .header-title { font-size: var(--text-sm); }
  #bf .msg-ai { gap: 6px; }
  #bf .sug { padding: 8px 12px; }
}

/* ── Workflow detail — mobile responsive ── */
/* Tables: horizontal scroll wrapper */
#bf .wf-result-card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
#bf .wf-result-card table { min-width: 400px; }
.bf-compare-table { min-width: 400px; }
.bf-compare-dropzones { flex-wrap: wrap; }
@media (max-width: 700px) {
  #bf .wf-results-panel { padding: 14px 10px; }
  #bf .wf-result-card { padding: 12px; }
  #bf .wf-result-card table { font-size: var(--text-sm-); }
  #bf .wf-result-card th, #bf .wf-result-card td { padding: 6px 8px; }
  #bf .wf-result-header { flex-direction: column; align-items: flex-start; gap: 4px; }
  #bf .wf-result-header h3 { font-size: var(--text-base); }
  .bf-compare-dropzones { flex-direction: column; }
  .bf-compare-dropzone { min-height: 80px; }
  .bf-compare-section h4 { font-size: var(--text-sm); }
  .bf-compare-card { padding: 10px 12px; }
  .bf-compare-table th, .bf-compare-table td { padding: 6px 8px; font-size: var(--text-sm-); }
  .wf-detail-actions { gap: 8px; }
  .wf-detail-pill { padding: 7px 14px; font-size: 12px; }
  .wf-detail-pill-danger { margin-left: 0; }
  .wf-detail-pill svg { width: 12px; height: 12px; }
  .wf-share-picker { padding: 10px; max-height: 50vh; }
  .wf-share-picker-item { padding: 10px 8px; gap: 10px; }
  .wf-share-picker-name { font-size: 14px; }
  .wf-share-picker-email { font-size: 12px; }
}
/* ── Case Tabs ── */
#bf .case-tabs {
  display: flex; gap: 0; border-bottom: 1px solid var(--border);
  padding: 0 20px; background: var(--bg);
  height: 44px;
}
#bf .case-tab {
  padding: 0 20px; font-size: var(--text-sm); font-weight: 500; color: var(--text-mid);
  border: none; background: none; cursor: pointer; border-bottom: 2px solid transparent;
  transition: background var(--duration-fast) ease, color var(--duration-fast) ease, border-color var(--duration-fast) ease;
  display: flex; align-items: center;
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
#bf .case-tab:hover { color: var(--text); background: rgba(26,107,90,0.04); }
#bf .case-tab.active { color: var(--teal); border-bottom-color: var(--teal); font-weight: 600; background: rgba(26,107,90,0.06); }
/* ── Workflow Header Pill ── */
#bf .wf-pill {
  display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px;
  border-radius: var(--radius-2xl); border: 1.5px solid var(--border-mid); background: var(--teal-pale);
  cursor: pointer; font-size: var(--text-sm-); font-weight: 600; color: var(--teal);
  font-family: 'Roboto', 'Noto Sans', sans-serif; transition: all var(--duration-fast) ease; flex-shrink: 0;
}
#bf .wf-pill:hover { background: var(--bg2); border-color: var(--teal); }
#bf .wf-pill.active { background: var(--teal); color: white; border-color: var(--teal); }
#bf .wf-pill .wf-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; border-radius: 9px; font-size: var(--text-2xs);
  font-weight: 700; padding: 0 5px;
}
#bf .wf-pill .wf-badge.pending { background: var(--warning-pale); color: var(--warning-dark); }
#bf .wf-pill .wf-badge.done { background: var(--success-pale); color: var(--success-dark); }
#bf .wf-pill.active .wf-badge.done { background: rgba(255,255,255,0.25); color: #fff; }
#bf .wf-pill .wf-badge.error { background: var(--danger-pale); color: var(--danger-dark); }
#bf .wf-spinner {
  display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border-mid);
  border-top-color: var(--teal); border-radius: 50%; animation: spin 0.8s linear infinite;
}
#bf .wf-results-panel {
  flex: 1; overflow-y: auto; padding: 24px; display: none;
}
#bf .wf-results-panel.active { display: block; }
#bf .wf-result-card {
  background: var(--surface); border: 1px solid var(--surface-border); border-radius: var(--radius-lg);
  padding: 16px; margin-bottom: 12px;
  transition: background var(--duration-fast) ease, border-color var(--duration-fast) ease;
}
#bf .wf-result-card:hover { background: var(--surface-hover); border-color: var(--surface-border-hover); }
#bf .wf-result-card h4 { margin: 0 0 12px 0; font-size: var(--text-base); color: var(--text); }
#bf .wf-result-card table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
#bf .wf-result-card th { text-align: left; padding: 8px 12px; background: var(--bg); border-bottom: 1px solid var(--border); font-weight: 600; color: var(--text-mid); font-size: var(--text-sm-); }
#bf .wf-result-card td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
#bf .wf-result-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px;
}
#bf .wf-result-header h3 { margin: 0; font-size: var(--text-md); color: var(--text); }
#bf .wf-result-actions { display: flex; gap: 8px; }
.wf-detail-actions {
  display: flex; gap: 10px; padding-top: 16px; margin-top: 14px;
  border-top: 1px solid var(--border, #E4EBE7); flex-wrap: wrap;
}
.wf-detail-pill {
  display: flex; align-items: center; gap: 6px; padding: 8px 20px;
  border-radius: 20px; border: 1.5px solid var(--border-mid); background: var(--teal-pale);
  color: #1a6b5a; font-size: 13px; font-weight: 600; cursor: pointer;
  font-family: 'Roboto', 'Noto Sans', sans-serif; transition: all 150ms;
}
.wf-detail-pill:hover { background: var(--bg2); border-color: #1a6b5a; }
.wf-detail-pill-danger {
  border-color: var(--danger-pale); background: var(--danger-pale); color: var(--danger-dark); margin-left: auto;
}
.wf-detail-pill-danger:hover { background: var(--danger-pale); border-color: var(--danger-dark); }
.wf-detail-back {
  display: flex; align-items: center; gap: 6px; padding: 6px 14px;
  border-radius: var(--radius-base); border: 1px solid var(--border); background: var(--white);
  color: var(--text-mid); font-size: 13px; font-weight: 500; cursor: pointer;
  margin-bottom: 16px; font-family: 'Roboto', 'Noto Sans', sans-serif;
}
.wf-detail-back:hover { background: var(--bg); border-color: var(--border-mid); }
/* ── Share picker dropdown ── */
.wf-share-picker {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 12px; margin-top: 10px; max-height: 240px; overflow-y: auto;
  -webkit-overflow-scrolling: touch; box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
.wf-share-picker-title {
  font-size: 12px; font-weight: 600; color: var(--text-mid);
  margin-bottom: 8px; padding: 0 4px;
}
.wf-share-picker-empty {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 16px; margin-top: 10px; font-size: 13px; text-align: center;
}
.wf-share-picker-item {
  display: flex; align-items: center; gap: 10px; padding: 8px;
  border-radius: var(--radius-base); cursor: pointer; transition: background 100ms;
  min-height: 44px;
}
.wf-share-picker-item:hover, .wf-share-picker-item:focus { background: var(--teal-pale); }
.wf-share-picker-item:active { background: var(--bg2); }
.wf-share-picker-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--info-pale); color: var(--info);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.wf-share-picker-info { min-width: 0; flex: 1; }
.wf-share-picker-name {
  font-size: 13px; font-weight: 500; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wf-share-picker-email {
  font-size: 11px; color: var(--text-light);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* ── Chain type picker ── */
.chain-type-btn {
  padding: 6px 14px; border-radius: var(--radius-xl); border: 1.5px solid var(--border);
  background: var(--white); color: var(--text-mid); font-size: var(--text-sm-); font-weight: 600;
  cursor: pointer; font-family: 'Roboto', 'Noto Sans', sans-serif; transition: all var(--duration-fast) ease;
}
.chain-type-btn:hover { border-color: var(--teal); color: var(--teal); }
.chain-type-btn.active { background: var(--teal); color: white; border-color: var(--teal); }
#bf .wf-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; color: var(--text-light); font-size: var(--text-base); gap: 8px;
}
/* ── Files tab ── */
#bf .files-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px;
}
#bf .files-header h3 { font-size: var(--text-base); font-weight: 600; color: var(--text); margin: 0; }
#bf .file-upload-btn {
  display: inline-flex; align-items: center; gap: 4px;
  height: 36px; padding: 0 var(--space-4); font-size: var(--text-sm); font-weight: 500;
  color: #fff; background: var(--teal); border: none; border-radius: var(--radius-md); cursor: pointer;
  transition: background var(--duration-fast) ease;
}
#bf .file-upload-btn:hover { background: var(--teal-mid); }
#bf .files-list { display: flex; flex-direction: column; gap: 8px; }
/* Upload progress panel */
#bf .upload-progress-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 12px;
}
#bf .upload-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
#bf .upload-progress-title { font-size: 13px; font-weight: 600; color: var(--text); }
#bf .upload-progress-count { font-size: 12px; color: var(--text-mid); }
#bf .upload-progress-bar-wrap {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 10px;
}
#bf .upload-progress-bar {
  height: 100%;
  background: var(--teal);
  border-radius: 2px;
  transition: width 0.3s ease;
}
#bf .upload-progress-files { display: flex; flex-direction: column; gap: 4px; max-height: 200px; overflow-y: auto; }
#bf .upload-file-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-mid);
  padding: 3px 0;
}
#bf .upload-file-row.uploading { color: var(--teal); }
#bf .upload-file-row.uploading .upload-file-icon { animation: bfSpin 0.8s linear infinite; display: inline-block; }
#bf .upload-file-row.done { color: var(--teal); }
#bf .upload-file-row.done .upload-file-icon { color: #27ae60; }
#bf .upload-file-row.failed { color: #c0392b; }
#bf .upload-file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#bf .upload-file-size { flex-shrink: 0; color: var(--text-light); font-size: 11px; }
#bf .file-bulk-bar {
  display: flex; align-items: center; gap: 16px;
  padding: 8px 14px; margin-bottom: 4px;
  background: var(--bg2); border-radius: var(--radius-md);
  border: 1px solid var(--border);
}
#bf .file-bulk-delete {
  margin-left: auto;
  background: var(--danger, #e53e3e); color: #fff; border: none;
  border-radius: var(--radius-md); padding: 4px 14px;
  font-size: 13px; font-weight: 500; cursor: pointer;
}
#bf .file-bulk-delete:hover { opacity: 0.85; }
#bf .file-item {
  display: flex; align-items: center; gap: 12px;
  height: 52px; padding: 0 14px;
  background: var(--surface); border: 1px solid var(--surface-border); border-radius: var(--radius-lg);
  transition: background var(--duration-fast) ease, border-color var(--duration-fast) ease;
}
#bf .file-item:hover { background: var(--surface-hover); border-color: var(--surface-border-hover); }
#bf .file-icon { font-size: 20px; flex-shrink: 0; }
#bf .file-info { flex: 1; min-width: 0; }
#bf .file-name { font-size: var(--text-sm); font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.4; }
#bf .file-meta { font-size: var(--text-xs); color: var(--text-light); margin-top: 2px; }

/* Project-RAG indexing-state badge sits next to the filename in the
   case-files panel. Three colours: teal pulsing for in-progress, muted
   green for ready, red for failed. Compact so the filename stays the
   primary visual element. */
#bf .file-index-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 600;
  border-radius: 10px;
  vertical-align: middle;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
#bf .file-index-badge.indexing {
  background: rgba(0, 150, 136, 0.10);
  color: var(--teal, #009688);
  animation: bfIndexPulse 1.5s ease-in-out infinite;
}
#bf .file-index-badge.indexed {
  background: rgba(0, 150, 136, 0.06);
  color: var(--teal, #009688);
}
#bf .file-index-badge.failed {
  background: #fdecea;
  color: #c2413a;
  cursor: help;
}
@keyframes bfIndexPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}
#bf .file-actions { display: flex; gap: 6px; }
#bf .file-actions button {
  height: 32px; padding: 0 10px; font-size: var(--text-sm-); border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid var(--border); background: var(--white); color: var(--text-mid);
  transition: all var(--duration-fast) ease; font-family: 'Roboto', 'Noto Sans', sans-serif;
}
#bf .file-actions button:hover { background: var(--bg); border-color: var(--border-mid); }
#bf .file-actions button.del:hover { background: #fef2f2; color: #C0392B; border-color: #e8a9a3; }
#bf .files-empty { text-align: center; color: var(--text-light); font-size: var(--text-base); padding: 48px 0; line-height: 1.5; }
/* ── File preview ── */
#bf .file-preview-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 5000;
  display: flex; align-items: center; justify-content: center; animation: bfin 150ms ease;
}
#bf .file-preview-box {
  background: var(--white); border-radius: var(--radius-lg); width: 90vw; max-width: 900px;
  height: 85vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow-md); overflow: hidden;
}
#bf .file-preview-header {
  display: flex; align-items: center; gap: 12px; padding: 16px 20px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
#bf .file-preview-header h3 { flex: 1; font-size: var(--text-base); font-weight: 600; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#bf .file-preview-close {
  width: 32px; height: 32px; border: none; background: var(--bg); border-radius: var(--radius-md);
  cursor: pointer; font-size: var(--text-md); display: flex; align-items: center; justify-content: center;
  color: var(--text-mid); transition: all var(--duration-fast) ease;
}
#bf .file-preview-close:hover { background: var(--bg2); color: var(--text); }
#bf .file-preview-body { flex: 1; overflow: auto; padding: 0; }
#bf .file-preview-body iframe { width: 100%; height: 100%; border: none; }
#bf .file-preview-body img { max-width: 100%; height: auto; display: block; margin: 20px auto; }
#bf .file-preview-body pre {
  padding: 24px; font-family: 'JetBrains Mono', monospace; font-size: var(--text-sm);
  line-height: 1.7; color: var(--text); white-space: pre-wrap; word-break: break-word;
}
/* ── Notes tab ── */
#bf .notes-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
}
#bf .notes-header h3 { font-size: var(--text-base); font-weight: 600; color: var(--text); margin: 0; }
#bf .notes-save-btn {
  height: 36px; padding: 0 var(--space-4); font-size: var(--text-sm); font-weight: 500;
  color: #fff; background: var(--teal);
  border: none; border-radius: var(--radius-md); cursor: pointer;
  transition: background var(--duration-fast) ease;
}
#bf .notes-save-btn:hover { background: var(--teal-mid); }
#bf .notes-area {
  width: 100%; min-height: 300px; padding: 14px; font-size: var(--text-base); line-height: 1.7;
  border: 1.5px solid var(--border-mid); border-radius: var(--radius-lg); /* already correct */ background: var(--white);
  color: var(--text); resize: vertical; box-sizing: border-box; font-family: inherit;
  outline: none; transition: border-color var(--duration-fast) ease;
}
#bf .notes-area:focus-visible { border-color: var(--teal); box-shadow: var(--focus-ring); }
/* ── Generic modal ── */
#bf .bf-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 3000;
  display: flex; align-items: center; justify-content: center; animation: bfin 150ms ease;
}
#bf .bf-modal {
  background: var(--white); border-radius: var(--radius-xl); padding: 28px 32px;
  max-width: 90vw; box-shadow: var(--shadow-md);
}
#bf .bf-modal h3 { margin: 0 0 16px; font-size: var(--text-md); color: var(--text); font-weight: 600; }
/* ── Modal form element classes ── */
#bf .bf-modal-input {
  width: 100%; padding: 8px 12px; border: 1.5px solid var(--border-mid);
  border-radius: var(--radius-base); font-size: 13px; font-family: inherit;
}
#bf .bf-modal-input[rows] { resize: vertical; }
#bf .bf-modal-select {
  width: 100%; padding: 6px 10px; border: 1.5px solid var(--border-mid);
  border-radius: var(--radius-sm); font-size: 13px; font-family: inherit;
}
#bf .bf-modal-btn-cancel {
  height: 36px; padding: 0 18px; background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-2xl); font-size: 13px; font-weight: 500; cursor: pointer;
  font-family: 'Roboto', 'Noto Sans', sans-serif; color: var(--text-mid);
  transition: all var(--duration-fast) ease;
}
#bf .bf-modal-btn-primary {
  height: 36px; padding: 0 22px; background: var(--teal); border: none;
  border-radius: var(--radius-2xl); color: #fff; font-size: 13px; font-weight: 500;
  cursor: pointer; font-family: 'Roboto', 'Noto Sans', sans-serif;
  transition: background var(--duration-fast) ease;
}
#bf .bf-modal-btn-primary:hover { background: var(--teal-mid); }
#bf .bf-modal-btn-cancel:hover { background: var(--border); }
/* ── Workflow card inline-style classes ── */
.wf-card-icon {
  width: 40px; height: 40px; border-radius: var(--radius-md); display: flex;
  align-items: center; justify-content: center; flex-shrink: 0;
}
.wf-card-name {
  font-size: 14px; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}
.wf-card-badge {
  font-size: 10px; font-weight: 600; padding: 2px 8px;
  border-radius: var(--radius-base); white-space: nowrap;
}
.wf-card-action-btn {
  width: 28px; height: 28px; border-radius: var(--radius-sm); border: 1px solid var(--border-mid);
  background: var(--teal-pale); color: #1a6b5a; cursor: pointer; display: flex;
  align-items: center; justify-content: center; transition: all 150ms;
}
.wf-card-action-del {
  width: 28px; height: 28px; border-radius: var(--radius-sm); border: 1px solid var(--danger-pale);
  background: var(--danger-pale); color: var(--danger-dark); cursor: pointer; display: flex;
  align-items: center; justify-content: center; transition: all 150ms;
}
@media (max-width: 600px) {
  #bf .bf-modal-input { padding: 10px 12px; font-size: 14px; }
  #bf .bf-modal-select { padding: 8px 10px; font-size: 14px; }
  #bf .bf-modal-btn-cancel, #bf .bf-modal-btn-primary { height: 34px; padding: 0 14px; font-size: 13px; }
  .wf-card-icon { width: 34px; height: 34px; border-radius: var(--radius-base); }
  .wf-card-name { font-size: 13px; }
  .wf-card-badge { font-size: 9px; }
}
@media (max-width: 380px) {
  #bf .bf-modal-btn-cancel, #bf .bf-modal-btn-primary { height: 34px; padding: 0 12px; font-size: 12px; }
  .wf-card-icon { width: 30px; height: 30px; }
}
#bf .tab-content { padding: 24px; animation: bfTabFade 200ms ease; }
@keyframes bfTabFade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
/* ── Drafts tab ── */
#bf .drafts-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px;
}
#bf .drafts-header h3 { font-size: var(--text-base); font-weight: 600; color: var(--text); margin: 0; }
#bf .drafts-list { display: flex; flex-direction: column; gap: 8px; }
#bf .draft-item {
  display: flex; align-items: center; gap: 12px;
  height: 52px; padding: 0 14px;
  background: var(--surface); border: 1px solid var(--surface-border); border-radius: var(--radius-lg);
  cursor: pointer; transition: background var(--duration-fast) ease, border-color var(--duration-fast) ease;
}
#bf .draft-item:hover { background: var(--surface-hover); border-color: var(--surface-border-hover); }
#bf .draft-item-info { flex: 1; min-width: 0; }
#bf .draft-item-title { font-size: var(--text-sm); font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.4; }
#bf .draft-item-meta { font-size: var(--text-xs); color: var(--text-light); margin-top: 2px; }
#bf .draft-editor-wrap { display: flex; flex-direction: column; height: 100%; }
#bf .draft-editor-header {
  display: flex; align-items: center; gap: 12px; padding: 0 0 12px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
#bf .draft-back-btn {
  height: 36px; padding: 0 14px; font-size: var(--text-sm); border: 1px solid var(--border);
  background: var(--white); border-radius: var(--radius-md); cursor: pointer; color: var(--text-mid);
  font-family: inherit; transition: all var(--duration-fast) ease; font-weight: 500;
}
#bf .draft-back-btn:hover { background: var(--bg); border-color: var(--border-mid); }
#bf .draft-title-text { flex: 1; font-size: var(--text-base); font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#bf .draft-version { font-size: var(--text-xs); color: var(--text-light); flex-shrink: 0; }
#bf .draft-editor-actions { display: flex; gap: 6px; flex-shrink: 0; }
#bf .draft-editor-actions button {
  height: 32px; padding: 0 12px; font-size: var(--text-sm-); border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid var(--border); background: var(--white); color: var(--text-mid);
  font-family: inherit; transition: all var(--duration-fast) ease; font-weight: 500;
}
#bf .draft-editor-actions button:hover { background: var(--bg); border-color: var(--border-mid); }
#bf .draft-editor-actions button:disabled { opacity: 0.35; cursor: not-allowed; }
#bf .draft-editor-actions button:disabled:hover { background: var(--white); border-color: var(--border); }
/* ── Wizard ── */
#bf .wiz-step { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
#bf .wiz-header {
  display: flex; align-items: center; gap: 12px; padding: 12px 24px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
#bf .wiz-title { flex: 1; font-size: var(--text-base); font-weight: 600; color: var(--text); }
#bf .wiz-step-indicator {
  font-size: var(--text-xs); color: var(--text-light); background: var(--bg);
  padding: 4px 12px; border-radius: var(--radius-lg); font-weight: 500;
}
#bf .wiz-form {
  flex: 1; overflow-y: auto; padding: 24px;
}
/* wiz-form scrollbar handled by global #bf ::-webkit-scrollbar */
#bf .wiz-row { display: flex; gap: 12px; margin-bottom: 16px; }
#bf .wiz-field { flex: 1; }
#bf .wiz-field.full { flex: 1 1 100%; }
#bf .wiz-field label {
  display: block; font-size: var(--text-xs); font-weight: 600; color: var(--text-mid);
  margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.4px;
}
#bf .wiz-field input, #bf .wiz-field select, #bf .wiz-field textarea {
  width: 100%; padding: 12px; border: 1.5px solid var(--border-mid);
  border-radius: var(--radius-lg); font-size: var(--text-sm); font-family: inherit; color: var(--text);
  background: var(--white); outline: none; transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
  line-height: 1.5;
}
#bf .wiz-field input:focus-visible, #bf .wiz-field select:focus-visible, #bf .wiz-field textarea:focus-visible {
  border-color: var(--teal);
  box-shadow: var(--focus-ring);
}
#bf .wiz-field textarea { resize: vertical; min-height: 64px; }
#bf .wiz-section-label {
  font-size: var(--text-sm-); font-weight: 700; color: var(--teal); margin: 20px 0 10px;
  padding-bottom: 8px; border-bottom: 1px solid var(--bg2);
}
#bf .wiz-footer {
  padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; flex-shrink: 0;
}
#bf .wiz-btn-next {
  height: 40px; padding: 0 28px; background: var(--teal);
  border: none; border-radius: var(--radius-2xl);
  color: #fff; font-size: var(--text-base); font-weight: 500; cursor: pointer;
  font-family: inherit; transition: background var(--duration-fast) ease;
}
#bf .wiz-btn-next:hover { background: var(--teal-mid); }
#bf .wiz-btn-next:disabled { background: var(--border-mid); cursor: not-allowed; }
#bf .wiz-generating {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 48px;
}
#bf .wiz-generating h3 { font-size: var(--text-md); color: var(--text); margin-bottom: 8px; font-weight: 600; }

/* Step 3: Editor + AI below */
#bf .wiz-editor-scroll { flex: 1; overflow-y: auto; background: #e8e8e8; }
/* wiz-editor-scroll scrollbar handled by global #bf ::-webkit-scrollbar */
#bf .wiz-doc-area {
  width: 210mm; max-width: 100%; margin: 24px auto; padding: 25mm;
  background: #ffffff; min-height: 297mm;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
/* The document page — legal typography */
#bf .draft-content {
  min-height: 200mm; outline: none;
  font-family: 'Times New Roman', 'Liberation Serif', Georgia, serif;
  font-size: 12pt; line-height: 1.5; color: #000000; text-align: justify;
}
#bf .draft-content:focus { outline: none; }
#bf .draft-content h1 {
  font-size: 14pt; font-weight: 700; text-align: center; text-transform: uppercase;
  margin: 0 0 12pt; font-family: inherit;
}
#bf .draft-content h2 {
  font-size: 12pt; font-weight: 700; margin: 12pt 0 6pt; font-family: inherit;
}
#bf .draft-content h3 {
  font-size: 12pt; font-weight: 700; font-style: italic; margin: 10pt 0 4pt; font-family: inherit;
}
#bf .draft-content p { margin: 0 0 6pt; }
#bf .draft-content ol, #bf .draft-content ul { margin: 0 0 6pt; padding-left: 36pt; }
#bf .draft-content li { margin: 0 0 3pt; }

/* ── Legal multilevel list — auto-numbering via CSS counters ──────────────
   The model emits clause structure as nested <ol class="legal">. Numbers are
   computed from the list position, not stored as characters — so when the
   lawyer adds, removes, or reorders clauses, every number renumbers
   automatically and stays consistent with cross-references at render time.

   Hierarchy follows Cyprus/English legal drafting conventions:
     Level 1: 1.        bold (clauses)
     Level 2: 1.1       (sub-clauses)
     Level 3: 1.1.1     (sub-sub-clauses)
     Level 4: (a)       lower-alpha
     Level 5: (i)       lower-roman
*/
#bf .draft-content ol.legal {
  counter-reset: l1;
  list-style: none;
  padding-left: 0;
  margin: 6pt 0;
}
#bf .draft-content ol.legal > li {
  counter-increment: l1;
  position: relative;
  padding-left: 28pt;
  margin: 8pt 0;
}
#bf .draft-content ol.legal > li::before {
  content: counter(l1) ".";
  position: absolute; left: 0;
  font-weight: 700;
}

#bf .draft-content ol.legal > li > ol {
  counter-reset: l2;
  list-style: none;
  padding-left: 0;
  margin: 4pt 0;
}
#bf .draft-content ol.legal > li > ol > li {
  counter-increment: l2;
  position: relative;
  padding-left: 36pt;
  margin: 4pt 0;
}
#bf .draft-content ol.legal > li > ol > li::before {
  content: counter(l1) "." counter(l2);
  position: absolute; left: 0;
  font-weight: 600;
}

#bf .draft-content ol.legal > li > ol > li > ol {
  counter-reset: l3;
  list-style: none;
  padding-left: 0;
}
#bf .draft-content ol.legal > li > ol > li > ol > li {
  counter-increment: l3;
  position: relative;
  padding-left: 44pt;
  margin: 3pt 0;
}
#bf .draft-content ol.legal > li > ol > li > ol > li::before {
  content: counter(l1) "." counter(l2) "." counter(l3);
  position: absolute; left: 0;
}

#bf .draft-content ol.legal > li > ol > li > ol > li > ol {
  counter-reset: l4;
  list-style: none;
  padding-left: 0;
}
#bf .draft-content ol.legal > li > ol > li > ol > li > ol > li {
  counter-increment: l4;
  position: relative;
  padding-left: 28pt;
  margin: 2pt 0;
}
#bf .draft-content ol.legal > li > ol > li > ol > li > ol > li::before {
  content: "(" counter(l4, lower-alpha) ")";
  position: absolute; left: 0;
}

#bf .draft-content ol.legal > li > ol > li > ol > li > ol > li > ol {
  counter-reset: l5;
  list-style: none;
  padding-left: 0;
}
#bf .draft-content ol.legal > li > ol > li > ol > li > ol > li > ol > li {
  counter-increment: l5;
  position: relative;
  padding-left: 28pt;
  margin: 2pt 0;
}
#bf .draft-content ol.legal > li > ol > li > ol > li > ol > li > ol > li::before {
  content: "(" counter(l5, lower-roman) ")";
  position: absolute; left: 0;
}

/* Same rules in the chat-window draft preview (so refinements look identical) */
#bf .answer-card.draft-answer ol.legal,
#bf .answer-card.draft-answer ol.legal ol { list-style: none; padding-left: 0; }
#bf .answer-card.draft-answer ol.legal { counter-reset: l1; }
#bf .answer-card.draft-answer ol.legal > li { counter-increment: l1; position: relative; padding-left: 28pt; }
#bf .answer-card.draft-answer ol.legal > li::before { content: counter(l1) "."; position: absolute; left: 0; font-weight: 700; }
#bf .answer-card.draft-answer ol.legal > li > ol { counter-reset: l2; }
#bf .answer-card.draft-answer ol.legal > li > ol > li { counter-increment: l2; position: relative; padding-left: 36pt; }
#bf .answer-card.draft-answer ol.legal > li > ol > li::before { content: counter(l1) "." counter(l2); position: absolute; left: 0; font-weight: 600; }
#bf .answer-card.draft-answer ol.legal > li > ol > li > ol { counter-reset: l3; }
#bf .answer-card.draft-answer ol.legal > li > ol > li > ol > li { counter-increment: l3; position: relative; padding-left: 44pt; }
#bf .answer-card.draft-answer ol.legal > li > ol > li > ol > li::before { content: counter(l1) "." counter(l2) "." counter(l3); position: absolute; left: 0; }
#bf .draft-content table {
  width: 100%; border-collapse: collapse; margin: 6pt 0; font-size: 11pt;
}
#bf .draft-content th, #bf .draft-content td {
  border: 1px solid #000; padding: 4pt 6pt; text-align: left;
}
#bf .draft-content th { font-weight: 700; background: #f5f5f5; }
#bf .draft-content u { text-decoration: underline; }

/* Legal styling for draft content rendered in the chat window */
#bf .answer-card.draft-answer {
  font-family: 'Times New Roman', 'Liberation Serif', Georgia, serif;
  font-size: 12pt; line-height: 1.5; color: #000; text-align: justify;
  background: #fff; padding: 24px; border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
#bf .answer-card.draft-answer h1 {
  font-size: 14pt; font-weight: 700; text-align: center; text-transform: uppercase;
  margin: 0 0 12pt; font-family: inherit;
}
#bf .answer-card.draft-answer h2 { font-size: 12pt; font-weight: 700; margin: 12pt 0 6pt; font-family: inherit; }
#bf .answer-card.draft-answer h3 { font-size: 12pt; font-weight: 700; font-style: italic; margin: 10pt 0 4pt; font-family: inherit; }
#bf .answer-card.draft-answer p { margin: 0 0 6pt; }
#bf .answer-card.draft-answer ol, #bf .answer-card.draft-answer ul { margin: 0 0 6pt; padding-left: 36pt; }
#bf .answer-card.draft-answer table { width: 100%; border-collapse: collapse; margin: 6pt 0; font-size: 11pt; }
#bf .answer-card.draft-answer th, #bf .answer-card.draft-answer td { border: 1px solid #000; padding: 4pt 6pt; }
#bf .answer-card.draft-answer th { font-weight: 700; background: #f5f5f5; }

/* AI Below Document */
#bf .wiz-ai-below {
  max-width: 720px; margin: 0 auto; padding: 0 32px 24px;
  border-top: 1px solid var(--border);
}
#bf .wiz-ai-header {
  padding: 16px 0 12px; font-size: var(--text-xs); font-weight: 700; color: #1a6b5a;
  text-transform: uppercase; letter-spacing: 0.6px;
}
#bf .wiz-ai-chat {
  display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px;
}
#bf .wiz-ai-msg-user {
  align-self: flex-end; background: #1a6b5a; color: #fff;
  padding: 10px 14px; border-radius: 16px 16px 4px 16px;
  font-size: var(--text-sm); max-width: 80%; line-height: 1.5;
}
#bf .wiz-ai-msg-ai {
  align-self: flex-start; background: var(--bg); border: 1px solid var(--border);
  padding: 12px 16px; border-radius: 4px 16px 16px 16px;
  font-size: var(--text-sm); max-width: 80%; line-height: 1.5; color: var(--text);
}
#bf .wiz-ai-msg-ai p { margin: 0 0 4px; }
#bf .wiz-ai-msg-ai p:last-child { margin: 0; }
#bf .wiz-ai-input {
  display: flex; gap: 8px; align-items: flex-end;
}
#bf .wiz-ai-input textarea {
  flex: 1; border: 1.5px solid var(--border-mid); border-radius: var(--radius-lg);
  padding: 10px 12px; font-size: var(--text-sm); font-family: inherit;
  resize: none; outline: none; min-height: 20px; max-height: 80px;
  line-height: 1.5; color: var(--text); background: var(--white);
  transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}
#bf .wiz-ai-input textarea:focus {
  border-color: #1a6b5a;
  box-shadow: 0 0 0 3px rgba(26,107,90,0.08);
}

@media (max-width: 700px) {
  #bf .wiz-doc-area { padding: 16px; }
  #bf .wiz-ai-below { padding: 0 16px 16px; }
  #bf .wiz-row { flex-direction: column; gap: 8px; }
  /* Preview panel — full-screen overlay on mobile */
  #bf .preview-panel.open {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    z-index: 999;
    border-left: none;
  }
  #bf .preview-doc { padding: 24px 16px; }
  #bf .preview-btn span { display: none; }
}
#bf #bfDraftEditor { display: none; flex-direction: column; height: 100%; }

/* ═══════════════════════════════════════════════════════════════
   LIBRARY PANEL — Design System
   ═══════════════════════════════════════════════════════════════ */
.lib-overlay {
  --lib-green:       var(--teal, #1a6b5a);
  --lib-green-hover: var(--teal-mid, #145a4a);
  --lib-green-pale:  var(--bg2, #EAF4EE);
  --lib-text:        var(--text, #111C17);
  --lib-text-mid:    var(--text-mid, #4A5C52);
  --lib-text-muted:  var(--text-light, #5d7366);
  --lib-border:      var(--border, #E4EBE7);
  --lib-bg:          var(--white, #ffffff);
  --lib-bg-hover:    var(--bg, #FAFAF8);
  --lib-bg-icon:     var(--bg2, #EAF4EE);
  --lib-danger:      var(--danger, #C0392B);
  --lib-danger-pale: var(--danger-pale, #fef2f2);
  --lib-shadow:      0 8px 48px rgba(0,0,0,0.12);
  --lib-radius:      20px;
  --lib-pad-x:       40px;
  --lib-pad-y:       32px;

  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15,20,25,0.35);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9998;
  display: none;
  align-items: center;
  justify-content: center;
}
.lib-overlay.open {
  display: flex;
  animation: libFadeIn 200ms cubic-bezier(0.16,1,0.3,1);
}
@keyframes libFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes libSlideUp {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
/* ── Modal shell ── */
.lib-panel {
  background: var(--lib-bg);
  border-radius: var(--radius-2xl, 20px);
  width: 680px;
  max-width: 94vw;
  height: 620px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0,0,0,0.14), 0 8px 24px rgba(0,0,0,0.06);
  overflow: hidden;
  animation: libSlideUp 280ms cubic-bezier(0.16,1,0.3,1);
  padding: 0;
  position: relative;
}
/* ── Close button (top-right, no title) ── */
.lib-panel-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 12px 16px 0;
  flex-shrink: 0;
}
.lib-panel-header h2 { display: none; }
.lib-panel-close {
  width: 36px; height: 36px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--lib-text-muted);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--duration-fast) ease;
}
.lib-panel-close:hover { background: var(--lib-green-pale); color: var(--lib-text); }
/* ── Tabs ── */
.lib-tabs {
  display: flex;
  gap: 24px;
  padding: 0 24px;
  margin: 0;
  border-bottom: 1px solid var(--lib-border, #E4EBE7);
  background: none;
  flex-shrink: 0;
  justify-content: center;
  height: 44px;
}
.lib-tab {
  padding: 0 8px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--lib-text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  transition: background var(--duration-fast) ease, color var(--duration-fast) ease, border-color var(--duration-fast) ease;
  margin-bottom: -1px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--radius-sm, 6px) var(--radius-sm, 6px) 0 0;
}
.lib-tab svg { width: 14px; height: 14px; }
.lib-tab:hover { color: var(--lib-text-mid); background: rgba(26,107,90,0.04); }
.lib-tab.active {
  color: var(--lib-green);
  font-weight: 600;
  border-bottom-color: var(--lib-green);
  background: rgba(26,107,90,0.06);
}
/* ── Scrollable content area ── */
.lib-tab-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  margin-top: 0;
  display: flex;
  flex-direction: column;
}
.lib-tab-body::-webkit-scrollbar { width: 5px; }
.lib-tab-body::-webkit-scrollbar-track { background: transparent; }
.lib-tab-body::-webkit-scrollbar-thumb { background: #C8D9CE; border-radius: var(--radius-xs); }
.lib-tab-body::-webkit-scrollbar-thumb:hover { background: #5d7366; }
.lib-tab-content { display: none; flex-direction: column; flex: 1; }
.lib-tab-content.active { display: flex; }
/* ── Content card ── */
.lib-card {
  background: transparent;
  border: none;
  border-radius: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
/* ── Action toolbar ── */
.lib-section-actions {
  display: flex;
  gap: 10px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--lib-border);
  background: var(--lib-bg);
  flex-shrink: 0;
}
.lib-action-btn {
  font-size: var(--text-sm);
  padding: 9px 20px;
  border: 1.5px solid var(--lib-border);
  border-radius: var(--radius-2xl);
  background: var(--lib-bg);
  cursor: pointer;
  color: var(--lib-text-mid);
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  font-weight: 500;
  transition: all var(--duration-fast) ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.lib-action-btn:hover {
  border-color: var(--lib-green);
  color: var(--lib-green);
  background: var(--lib-green-pale);
}
.lib-action-btn.danger { border-color: var(--danger-pale); color: var(--lib-danger); }
.lib-action-btn.danger:hover { background: var(--lib-danger-pale); border-color: #f87171; }
/* ── Add button (floating, bottom-right of file list) ── */
.lib-add-wrap { position: absolute; bottom: 20px; right: 20px; z-index: 10; }
.lib-add-btn {
  width: 44px; height: 44px; border-radius: 50%;
  background: #1a6b5a; color: #fff; border: none; cursor: pointer;
  font-size: 22px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: background var(--duration-fast) ease, transform var(--duration-fast) ease;
}
.lib-add-btn:hover { background: #145a4a; transform: scale(1.06); }
.lib-add-menu {
  display: none; position: absolute; bottom: 52px; right: 0;
  background: var(--white, #fff); border: 1px solid var(--border, #E4EBE7); border-radius: var(--radius-lg);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12); min-width: 200px;
  padding: 6px 0; flex-direction: column;
}
.lib-add-menu.open { display: flex; }
.lib-add-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; font-size: var(--text-sm); font-family: 'Roboto', 'Noto Sans', sans-serif;
  color: var(--text, #111C17); background: none; border: none; cursor: pointer;
  transition: background var(--duration-fast) ease; text-align: left;
}
.lib-add-menu-item:hover { background: var(--bg2, #EAF4EE); }
.lib-add-menu-item.coming-soon { opacity: 0.5; cursor: default; }
.lib-add-menu-item.coming-soon:hover { background: none; }
.lib-add-menu-item svg { flex-shrink: 0; color: var(--text-mid, #4A5C52); }
.lib-add-menu-sep { height: 1px; background: var(--border, #E4EBE7); margin: 4px 0; }
/* ── Drag & drop overlay ── */
.lib-drop-zone {
  position: relative;
}
.lib-drop-zone.drag-over::after {
  content: '';
  position: absolute; inset: 0; z-index: 5;
  border: 2px dashed #1a6b5a;
  border-radius: var(--radius-lg);
  background: rgba(26,107,90,0.06);
  pointer-events: none;
}
.lib-file-item.folder.drag-over {
  background: rgba(26,107,90,0.1);
  outline: 2px dashed #1a6b5a;
  outline-offset: -2px;
}
.lib-file-item.dragging {
  opacity: 0.4;
  cursor: grabbing;
}
.lib-file-item[draggable="true"] {
  cursor: grab;
}
.lib-file-item[draggable="true"]:active {
  cursor: grabbing;
}
/* ── File list ── */
.lib-file-list {
  padding: 8px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
}
.lib-file-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  color: var(--lib-text);
  cursor: default;
  transition: background var(--duration-fast) ease;
}
.lib-file-item:hover { background: var(--lib-bg-hover); }
.lib-file-item .lib-icon {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  background: var(--lib-bg-hover);
  border-radius: var(--radius-md);
  transition: background var(--duration-fast) ease;
}
.lib-file-item:hover .lib-icon { background: var(--lib-bg-icon); }
.lib-file-item .lib-info { flex: 1; min-width: 0; }
.lib-file-item .lib-name {
  font-weight: 500;
  font-size: var(--text-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--lib-text);
  line-height: 1.4;
}
.lib-file-item .lib-meta {
  font-size: var(--text-xs);
  color: var(--lib-text-muted);
  margin-top: 2px;
  line-height: 1.3;
}
.lib-file-item .lib-del {
  background: none; border: none; cursor: pointer;
  color: var(--lib-text-muted); padding: 6px; border-radius: var(--radius-sm);
  font-size: var(--text-base); line-height: 1;
  transition: all var(--duration-fast) ease;
  opacity: 0;
}
.lib-file-item:hover .lib-del { opacity: 1; }
.lib-file-item .lib-del:hover { color: var(--lib-danger); background: var(--lib-danger-pale); }
.lib-file-item.folder { cursor: pointer; }
.lib-file-item.folder .lib-icon { background: var(--lib-green-pale); }
.lib-file-item.folder:hover { background: var(--lib-green-pale); }
.lib-file-item.folder .lib-del { margin-right: 4px; }
.lib-file-item .lib-folder-arrow {
  color: var(--lib-text-muted);
  font-size: var(--text-md);
  transition: transform var(--duration-fast) ease, color var(--duration-fast) ease;
}
.lib-file-item.folder:hover .lib-folder-arrow {
  color: var(--lib-green);
  transform: translateX(3px);
}
/* ── Breadcrumb ── */
.lib-breadcrumb {
  padding: 18px 24px 4px;
  font-size: var(--text-sm);
  color: var(--lib-text-muted);
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
}
.lib-breadcrumb span {
  cursor: pointer;
  color: var(--lib-green);
  transition: all var(--duration-fast) ease;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}
.lib-breadcrumb span:hover { color: var(--lib-green-hover); background: var(--lib-green-pale); }
.lib-breadcrumb .lib-crumb-current {
  color: var(--lib-text);
  cursor: default;
  font-weight: 600;
}
.lib-breadcrumb .lib-crumb-current:hover { background: none; }
.lib-breadcrumb .lib-crumb-sep { color: var(--lib-text-muted); cursor: default; padding: 0 2px; opacity: 0.5; }
.lib-breadcrumb .lib-crumb-sep:hover { background: none; }
/* ── Empty state ── */
.lib-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px;
  gap: 12px;
  flex: 1;
  width: 100%;
}
.lib-empty-icon {
  width: 72px; height: 72px;
  background: linear-gradient(135deg, var(--lib-green-pale) 0%, rgba(26,107,90,0.08) 100%);
  border-radius: var(--radius-2xl, 20px);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 8px;
}
.lib-empty-icon svg {
  width: 32px; height: 32px;
  color: var(--lib-green);
  stroke-width: 1.5;
}
.lib-empty-title {
  font-family: 'Noto Sans', 'Roboto', sans-serif;
  font-size: var(--text-lg);
  font-weight: 400;
  color: var(--lib-text);
  line-height: 1.3;
  margin: 0;
}
.lib-empty-sub {
  font-size: var(--text-base);
  color: var(--lib-text-muted);
  line-height: 1.6;
  margin: 0;
  max-width: 360px;
}
.lib-empty-cta {
  margin-top: 20px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 24px;
  border: none;
  border-radius: var(--radius-lg);
  background: var(--lib-green);
  color: #ffffff;
  font-size: var(--text-base);
  font-weight: 600;
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  cursor: pointer;
  transition: all var(--duration-normal) ease;
  box-shadow: 0 2px 8px rgba(26,107,90,0.2);
}
.lib-empty-cta:hover {
  background: var(--lib-green-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(26,107,90,0.25);
}
.lib-empty-cta:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(26,107,90,0.2);
}
.lib-empty-cta svg { flex-shrink: 0; }
/* ── Upload options grid ── */
.lib-upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
}
.lib-upload-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  height: 76px;
  border: 1.5px solid var(--lib-border);
  border-radius: var(--radius-lg);
  background: var(--lib-bg);
  cursor: pointer;
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  transition: all var(--duration-normal) ease;
  text-align: left;
}
.lib-upload-option:hover {
  border-color: var(--lib-green);
  background: var(--lib-green-pale);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(26,107,90,0.08);
}
.lib-upload-option:active {
  transform: translateY(0);
  box-shadow: none;
}
.lib-upload-option.coming-soon { opacity: 0.45; cursor: default; }
.lib-upload-option.coming-soon:hover { opacity: 0.55; transform: none; box-shadow: none; border-color: var(--lib-border); background: var(--lib-bg); }
.lib-upload-option .lib-uopt-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  background: var(--lib-green-pale);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background var(--duration-fast) ease;
}
.lib-upload-option:hover .lib-uopt-icon { background: rgba(26,107,90,0.15); }
.lib-upload-option .lib-uopt-icon svg { width: 18px; height: 18px; color: var(--lib-green); }
.lib-upload-option .lib-uopt-text {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--lib-text);
  line-height: 1.3;
}
.lib-upload-option .lib-uopt-sub {
  font-size: var(--text-xs);
  color: var(--lib-text-muted);
  margin-top: 2px;
  font-weight: 400;
}
/* ── Responsive ── */
@media (max-width: 600px) {
  .lib-panel {
    border-radius: 16px 16px 0 0;
    height: 92vh; max-height: 92vh;
    align-self: flex-end;
  }
  .lib-overlay { --lib-pad-x: 20px; --lib-pad-y: 20px; }
}

/* ══════════════════════════════════════════════════════════════════
   MODAL EXIT ANIMATIONS
   ══════════════════════════════════════════════════════════════════ */
@keyframes bfFadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}
@keyframes bfScaleOut {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(0.95); }
}
#bf .bf-modal-overlay.closing,
#bf .bf-dialog-overlay.closing,
#bf .fb-modal-overlay.closing,
#bf .file-preview-overlay.closing {
  animation: bfFadeOut var(--duration-fast) ease forwards;
}
#bf .bf-modal-overlay.closing .bf-modal,
#bf .bf-dialog-overlay.closing .bf-dialog,
#bf .fb-modal-overlay.closing .fb-modal,
#bf .file-preview-overlay.closing .file-preview-box {
  animation: bfScaleOut var(--duration-fast) ease forwards;
}

/* ══════════════════════════════════════════════════════════════════
   SKELETON LOADER SYSTEM
   ══════════════════════════════════════════════════════════════════ */
#bf .skeleton {
  background: linear-gradient(
    90deg,
    var(--border) 25%,
    var(--bg) 50%,
    var(--border) 75%
  );
  background-size: 200% 100%;
  animation: bfShimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
#bf .skeleton-text {
  height: 14px;
  margin-bottom: 8px;
  border-radius: var(--radius-xs);
}
#bf .skeleton-text:last-child {
  width: 60%;
}
#bf .skeleton-heading {
  height: 20px;
  width: 40%;
  margin-bottom: 16px;
  border-radius: var(--radius-xs);
}
#bf .skeleton-avatar {
  width: 28px;
  height: 28px;
  border-radius: 7px;
}
@keyframes bfShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ══════════════════════════════════════════════════════════════════
   DARK MODE
   ══════════════════════════════════════════════════════════════════ */
body.dark {
  background: #0f1419;
  color: #e1e8ed;
}

/* Draft editor — page stays white in dark mode */
body.dark #bf .wiz-editor-scroll { background: #2a2a2a; }
body.dark #bf .wiz-doc-area { background: #ffffff; }
body.dark #bf .draft-content { color: #000000; }
body.dark #bf .answer-card.draft-answer { background: #fff; color: #000; border-color: #30363d; }

/* Login / Set-Password pages */
body.dark .login-page { background: #0f1419; }
body.dark .login-card { background: #1c2128; border-color: #30363d; box-shadow: 0 8px 32px rgba(0,0,0,0.4); }
body.dark .login-brand h1 { color: #3fb99a; }
body.dark .login-brand p { color: #8b949e; }
body.dark .login-field label { color: #8b949e; }
body.dark .login-field input { background: #161b22; border-color: #30363d; color: #e1e8ed; }
body.dark .login-field input:focus { border-color: #3fb99a; box-shadow: 0 0 0 3px rgba(63,185,154,0.15); }
body.dark .login-field input::placeholder { color: #7d8b99; }
body.dark .login-pass-toggle { color: #7d8b99; }
body.dark .login-pass-toggle:hover { color: #8b949e; }
body.dark .google-btn { background: #2d333b; color: #c9d1d9; border-color: #444c56; }
body.dark .google-btn:hover { background: #373e47; }
body.dark .login-divider { color: #8b949e; }
body.dark .login-divider::before, body.dark .login-divider::after { background: #30363d; }
body.dark .login-btn { background: #3fb99a; color: #0f1419; }
body.dark .login-btn:hover { background: #36a88b; }
body.dark .login-btn:disabled { background: #30363d; color: #7d8b99; }
body.dark .login-link { color: #8b949e; }
body.dark .login-link a { color: #3fb99a; }
body.dark .login-link a:hover { color: #5ad4b5; }
body.dark .login-footer { color: #7d8b99; }

/* Global modal overlays */
body.dark .bf-global-overlay { background: rgba(0,0,0,0.6); }
body.dark .bf-global-modal { background: #1c2128; border-color: #30363d; box-shadow: 0 8px 32px rgba(0,0,0,0.5); }
body.dark .bf-global-modal h3 { color: #e1e8ed; }
body.dark .bf-global-modal .modal-subtitle { color: #8b949e; }
body.dark .bf-global-modal .modal-field label { color: #8b949e; }
body.dark .bf-global-modal .modal-field input { background: #161b22; border-color: #30363d; color: #e1e8ed; }
body.dark .bf-global-modal .modal-field input:focus { border-color: #3fb99a; box-shadow: 0 0 0 3px rgba(63,185,154,0.15); }
body.dark .bf-global-modal .btn-cancel { background: #161b22; border-color: #30363d; color: #8b949e; }
body.dark .bf-global-modal .btn-cancel:hover { background: #30363d; }
body.dark .bf-global-modal .btn-primary { background: #3fb99a; color: #0f1419; }
body.dark .bf-global-modal .btn-primary:hover { background: #36a88b; }
body.dark .bf-global-modal .btn-primary:disabled { background: #30363d; color: #7d8b99; }

/* User profile & dropdown */
body.dark .sb-user { background: #161b22; border-top-color: #30363d; }
body.dark .sb-user:hover { background: #1c2128; }
body.dark .sb-user-avatar { background: #3fb99a; color: #0f1419; }
body.dark .sb-user-name { color: #e1e8ed; }
body.dark .sb-user-email { color: #8b949e; }
body.dark .sb-user-chevron { color: #7d8b99; }
body.dark .sb-user:hover .sb-user-chevron { color: #8b949e; }
body.dark .user-dropdown { background: #1c2128; box-shadow: 0 8px 32px rgba(0,0,0,0.5); }
body.dark .ud-profile .ud-name { color: #e1e8ed; }
body.dark .ud-profile .ud-email-sub { color: #8b949e; }
body.dark .ud-divider { background: #30363d; }
body.dark .ud-section .ud-item { color: #e1e8ed; }
body.dark .ud-section .ud-item:hover { background: #161b22; }
body.dark .ud-section .ud-item svg { color: #8b949e; }
body.dark .ud-section .ud-item:hover svg { color: #e1e8ed; }
body.dark .ud-section .ud-item.danger:hover { background: rgba(248,81,73,0.1); color: #f85149; }
body.dark .ud-section .ud-item.danger:hover svg { color: #f85149; }

/* #bf app container — override CSS variables */
body.dark #bf {
  --white:      #161b22;
  --bg:         #0f1419;
  --bg2:        #1c2128;
  --border:     #30363d;
  --border-mid: #30363d;
  --text:       #e1e8ed;
  --text-mid:   #8b949e;
  --text-light: #7d8b99;
  --teal:       #3fb99a;
  --teal-mid:   #36a88b;
  --teal-light: #3fb99a;
  --teal-pale:  rgba(63,185,154,0.1);
  --accent:     var(--teal);
  --shadow-xs:  0 1px 2px rgba(0,0,0,0.15);
  --shadow-sm:  0 1px 2px rgba(0,0,0,0.2);
  --shadow:     0 1px 3px rgba(0,0,0,0.3);
  --shadow-md:  0 8px 32px rgba(0,0,0,0.5);
  --shadow-lg:  0 16px 48px rgba(0,0,0,0.6);
  --danger:     #f85149;
  --danger-pale:rgba(248,81,73,0.1);
  --danger-dark:#ffa198;
  --success:    #3fb950;
  --success-pale:rgba(63,185,80,0.1);
  --success-dark:#7ee787;
  --warning:    #d29922;
  --warning-pale:rgba(210,153,34,0.1);
  --warning-dark:#e3b341;
  --info:       #a5b4fc;
  --info-pale:  rgba(165,180,252,0.1);
  --toast-bg:   #1c2128;
  --focus-ring: 0 0 0 3px rgba(63,185,154,0.15);
  background: var(--white);
  color: var(--text);
}

/* Sidebar — only overrides not covered by variables */
body.dark #bf .sb-brand-icon { filter: brightness(1.2); }
body.dark #bf .new-btn { color: #0f1419; }
body.dark #bf .new-btn:hover { color: #0f1419; }
body.dark #bf .sb-toggle:hover { background: rgba(255,255,255,0.05); }

/* Sidebar items — uses var(--teal-pale) via variables, but hover needs opacity variant */
body.dark #bf .sb-item:hover { background: rgba(63,185,154,0.08); }
body.dark #bf .sb-item.active { background: rgba(63,185,154,0.15); }

/* Preview panel — only non-variable-covered overrides */
body.dark #bf .preview-doc { box-shadow: 0 1px 4px rgba(0,0,0,0.3); }
body.dark #bf .preview-doc table th { background: #21262d; }
body.dark #bf .preview-btn { background: #21262d; }
body.dark #bf .preview-btn:hover { background: rgba(63,185,154,0.1); }
body.dark #bf .preview-revision-bar { background: #1c2128; border-color: #30363d; }
body.dark #bf .preview-revision-input { background: #161b22; border-color: #30363d; color: #e1e8ed; }
body.dark #bf .preview-revision-input:focus { border-color: #3fb99a; }
body.dark #bf .preview-revision-input::placeholder { color: #7d8b99; }

/* Messages — non-variable-covered overrides only */
body.dark #bf .msg-user { background: rgba(63,185,154,0.1); }
body.dark #bf .answer-card p { color: #c9d1d9; }
body.dark #bf .answer-card code { color: var(--teal); }
body.dark #bf .answer-card blockquote { border-left-color: var(--teal); background: rgba(63,185,154,0.05); color: #c9d1d9; }
body.dark #bf .answer-card th { background: rgba(63,185,154,0.1); color: var(--teal); }
body.dark #bf .answer-card td { color: #c9d1d9; }

/* Input area — non-variable-covered overrides */
body.dark #bf textarea { background: transparent; }
body.dark #bf .send-btn { color: #0f1419; }

/* Source buttons & menus — these are outside #bf scope so need explicit overrides */
body.dark .source-btn { background: #161b22; border-color: #30363d; color: #8b949e; }
body.dark .source-btn:hover { border-color: #3fb99a; color: #3fb99a; }
body.dark .source-count { background: #3fb99a; color: #0f1419; }
body.dark .plus-btn { background: #161b22; border-color: #30363d; color: #8b949e; }
body.dark .plus-btn:hover { border-color: #3fb99a; color: #3fb99a; background: rgba(63,185,154,0.1); }
body.dark #bf .source-pill { background: #21262d; border-color: #30363d; color: #8b949e; }
body.dark #bf .source-pill:hover { border-color: #3fb99a; color: #3fb99a; }
body.dark #bf .source-bar.expanded .source-pill { border-color: #3fb99a; color: #3fb99a; }
body.dark #bf .src-chip { background: #21262d; border-color: #30363d; color: #8b949e; }
body.dark #bf .src-chip:hover { border-color: #3fb99a; color: #3fb99a; }
body.dark #bf .src-chip.active { background: rgba(63,185,154,0.1); border-color: #3fb99a; color: #3fb99a; }
body.dark #bf .src-chip-dot { background: #30363d; }
body.dark #bf .src-chip.active .src-chip-dot { background: #3fb99a; }
body.dark .plus-menu { background: #1c2128; border-color: #30363d; box-shadow: 0 8px 30px rgba(0,0,0,0.4); }
body.dark .plus-menu-item { color: #e1e8ed; }
body.dark .plus-menu-item:hover { background: #161b22; }
body.dark .plus-menu-item svg { color: #8b949e; }
body.dark .plus-menu-item:hover svg { color: #e1e8ed; }
body.dark .plus-sub-menu { background: #1c2128; border-color: #30363d; box-shadow: 0 8px 30px rgba(0,0,0,0.4); }
body.dark .source-group-label { color: #7d8b99; }
body.dark .court-filter-header { color: #3fb99a; }
body.dark .court-filter-header:hover { color: #5fd4b3; }
body.dark .court-filter-item { color: #8b949e; }
body.dark .court-filter-item:hover { color: #e1e8ed; }
body.dark .source-toggle:hover { background: #161b22; }
body.dark .source-toggle-info { color: #e1e8ed; }
body.dark .source-toggle-info svg { color: #8b949e; }
body.dark .source-switch { background: #30363d; }
body.dark .source-switch:checked { background: #3fb99a; }
body.dark .source-switch::after { background: #e1e8ed; }
body.dark .prompts-category { color: #7d8b99; }
body.dark .prompt-item { color: #e1e8ed; }
body.dark .prompt-item:hover { background: rgba(63,185,154,0.1); color: #3fb99a; }
body.dark .source-name { color: #e1e8ed; }
body.dark .source-desc { color: #7d8b99; }
body.dark .source-option:hover { background: rgba(255,255,255,0.03); }
body.dark .input-action-label { color: #7d8b99; }
body.dark .plus-menu-arrow { color: #7d8b99; }

/* Skeleton loading — uses dark-mode variable overrides */
body.dark #bf .skeleton { background: linear-gradient(90deg, var(--bg2) 25%, var(--border) 50%, var(--bg2) 75%); background-size: 200% 100%; }

/* Compare */
body.dark .bf-compare-dropzone { border-color: #30363d; }
body.dark .bf-compare-dropzone:hover,
body.dark .bf-compare-dropzone.drag-over { border-color: #3fb99a; background: rgba(63,185,154,0.05); }
body.dark .bf-compare-dropzone.has-file { border-color: #3fb99a; background: rgba(63,185,154,0.05); }
body.dark .bf-compare-dropzone .dz-label { color: #3fb99a; }
body.dark .bf-compare-dropzone .dz-icon { color: #7d8b99; }
body.dark .bf-compare-dropzone.has-file .dz-icon { color: #3fb99a; }
body.dark .bf-compare-dropzone .dz-name { color: #8b949e; }
body.dark .bf-compare-dropzone .dz-hint { color: #7d8b99; }
body.dark .bf-compare-table th { background: rgba(63,185,154,0.1); color: #3fb99a; border-bottom-color: #30363d; }
body.dark .bf-compare-table td { border-bottom-color: #30363d; color: #c9d1d9; }
body.dark .bf-compare-table tr:hover td { background: rgba(255,255,255,0.02); }
body.dark .bf-compare-section h4 { color: #e1e8ed; border-bottom-color: #3fb99a; }
body.dark .bf-compare-card { background: #1c2128; border-left-color: #3fb99a; }
body.dark .bf-risk-badge.high { background: rgba(248,81,73,0.1); color: #f85149; }
body.dark .bf-risk-badge.medium { background: rgba(210,153,11,0.1); color: #d29b0b; }
body.dark .bf-risk-badge.low { background: rgba(63,185,154,0.1); color: #3fb99a; }

/* Workflow */
body.dark .bf-wf-step { background: #1c2128; color: #7d8b99; }
body.dark .bf-wf-step.active { background: #3fb99a; color: #0f1419; }
body.dark .bf-wf-step.done { background: rgba(63,185,154,0.15); color: #3fb99a; }
body.dark .bf-wf-option { border-color: #30363d; color: #c9d1d9; }
body.dark .bf-wf-option:hover { border-color: #3fb99a; }
body.dark .bf-wf-option.selected { border-color: #3fb99a; background: rgba(63,185,154,0.1); color: #3fb99a; }
body.dark .bf-wf-option input[type="checkbox"] { accent-color: #3fb99a; }
body.dark .bf-wf-progress-step { color: #8b949e; }
body.dark .bf-wf-progress-step.done { color: #3fb99a; }
body.dark .bf-wf-progress-step.active { color: #3fb99a; }

/* Project modal */
/* Library panel — dark mode via custom property overrides */
body.dark .lib-overlay {
  --lib-green: #3fb99a;
  --lib-green-hover: #36a88b;
  --lib-green-pale: rgba(63,185,154,0.1);
  --lib-text: #e1e8ed;
  --lib-text-mid: #8b949e;
  --lib-text-muted: #7d8b99;
  --lib-border: #30363d;
  --lib-bg: #0f1419;
  --lib-bg-hover: rgba(255,255,255,0.03);
  --lib-bg-icon: rgba(63,185,154,0.08);
  --lib-danger: #f85149;
  --lib-danger-pale: rgba(248,81,73,0.1);
  --lib-shadow: 0 0 0 1px rgba(255,255,255,0.04), 0 24px 80px rgba(0,0,0,0.5), 0 8px 24px rgba(0,0,0,0.3);
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(6px);
}
body.dark .lib-panel { background: #1c2128; }
body.dark .lib-panel-header { background: transparent; }
body.dark .lib-tabs { background: #161b22; }
body.dark .lib-tab.active { color: var(--lib-green); border-bottom-color: var(--lib-green); }
body.dark .lib-card { background: #161b22; }
body.dark .lib-section-actions { background: #161b22; border-bottom-color: #21262d; }
body.dark .lib-action-btn { background: #0f1419; }
body.dark .lib-action-btn:hover { border-color: var(--lib-green); color: var(--lib-green); background: rgba(63,185,154,0.06); box-shadow: none; }
body.dark .lib-action-btn.danger:hover { box-shadow: none; }
body.dark .lib-add-menu { background: #1c2128; border-color: #30363d; box-shadow: 0 4px 16px rgba(0,0,0,0.3); }
body.dark .lib-add-menu-item { color: #e1e8ed; }
body.dark .lib-add-menu-item:hover { background: rgba(63,185,154,0.08); }
body.dark .lib-add-menu-item svg { color: #8b949e; }
body.dark .lib-add-menu-sep { background: #30363d; }
body.dark .lib-file-item + .lib-file-item { border-top-color: #21262d; }
body.dark .lib-file-item .lib-icon { background: #0f1419; }
body.dark .lib-file-item.folder .lib-icon { background: rgba(63,185,154,0.08); border-color: rgba(63,185,154,0.15); }
body.dark .lib-file-item.folder:hover { background: rgba(63,185,154,0.06); }
body.dark .lib-file-item.folder:hover .lib-folder-arrow { color: var(--lib-green); }
body.dark .lib-breadcrumb span { color: var(--lib-green); }
body.dark .lib-breadcrumb span:hover { color: #5ad4b5; background: rgba(63,185,154,0.08); }
body.dark .lib-breadcrumb .lib-crumb-current { color: var(--lib-text); }
body.dark .lib-breadcrumb .lib-crumb-current:hover { background: none; }
body.dark .lib-breadcrumb .lib-crumb-sep { color: #30363d; }
body.dark .lib-empty-cta:hover { background: var(--lib-green); color: #0f1419; }
body.dark .lib-tab-body::-webkit-scrollbar-thumb { background: #30363d; }
body.dark .lib-tab-body::-webkit-scrollbar-thumb:hover { background: #7d8b99; }

body.dark #bfProjModal .modal-box { background: #1c2128; border-color: #30363d; box-shadow: 0 8px 32px rgba(0,0,0,0.5); }
body.dark #bfProjModal h3 { color: #e1e8ed; }
body.dark #bfProjModal label { color: #8b949e; }
body.dark #bfProjModal input,
body.dark #bfProjModal textarea { background: #161b22; border-color: #30363d; color: #e1e8ed; }
body.dark #bfProjModal input:focus,
body.dark #bfProjModal textarea:focus { border-color: #3fb99a; box-shadow: 0 0 0 3px rgba(63,185,154,0.15); }
body.dark #bfProjModal input::placeholder,
body.dark #bfProjModal textarea::placeholder { color: #7d8b99; }

/* Tabs */
body.dark #bf .case-tabs { background: #161b22; border-bottom-color: #30363d; }
body.dark #bf .case-tab { color: #8b949e; }
body.dark #bf .case-tab:hover { color: #e1e8ed; }
body.dark #bf .case-tab.active { color: #3fb99a; border-bottom-color: #3fb99a; }

/* Toasts */
body.dark #bf .bf-toast { background: #e1e8ed; color: #0f1419; box-shadow: 0 4px 16px rgba(0,0,0,0.4); }

/* Move menu / context menus */
body.dark #bf .move-menu { background: #1c2128; border-color: #30363d; box-shadow: 0 8px 32px rgba(0,0,0,0.5); }
body.dark #bf .move-menu-item { color: #e1e8ed; }
body.dark #bf .move-menu-item:hover { background: #161b22; color: #3fb99a; }
body.dark #bf .move-menu-item.new-case { color: #3fb99a; border-top-color: #30363d; }

/* Conversation items */
body.dark #bf .conv-item { color: #e1e8ed; }
body.dark #bf .conv-item:hover { background: rgba(63,185,154,0.08); }
body.dark #bf .conv-item.active { background: rgba(63,185,154,0.15); }
body.dark #bf .conv-meta { color: #7d8b99; }
body.dark #bf .conv-act { color: #7d8b99; }
body.dark #bf .conv-act:hover { background: rgba(255,255,255,0.05); color: #e1e8ed; }
body.dark #bf .conv-act.del:hover { color: #f85149; background: rgba(248,81,73,0.1); }

/* Thinking dots */
body.dark .think-dot { background: #3fb99a; }

/* Scrollbar */
body.dark ::-webkit-scrollbar { width: 6px; }
body.dark ::-webkit-scrollbar-track { background: transparent; }
body.dark ::-webkit-scrollbar-thumb { background: #30363d; border-radius: 3px; }
body.dark ::-webkit-scrollbar-thumb:hover { background: #7d8b99; }

/* Chain type buttons */
body.dark .chain-type-btn { background: #161b22; border-color: #30363d; color: #c9d1d9; }
body.dark .chain-type-btn:hover { border-color: #3fb99a; }
body.dark .chain-type-btn.active { border-color: #3fb99a; background: rgba(63,185,154,0.1); color: #3fb99a; }

/* Draft editor */
body.dark #bf #bfDraftEditor { background: #0f1419; }

/* File items */
body.dark #bf .file-item { background: #1c2128; border-color: #30363d; }
body.dark #bf .file-item:hover { border-color: #3fb99a; }

/* Pin items */
body.dark #bf .pin-item { background: #1c2128; border-color: #30363d; }
body.dark #bf .pin-item:hover { border-color: #3fb99a; }

/* Workflow panel */
body.dark #bf .wf-panel { background: #161b22; border-left-color: #30363d; }
body.dark #bf .wf-card { background: #1c2128; border-color: #30363d; }
body.dark #bf .wf-card:hover { border-color: #3fb99a; }
/* Share picker — dark mode */
body.dark .wf-share-picker {
  background: #1c2128; border-color: #30363d;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
body.dark .wf-share-picker-empty {
  background: #1c2128; border-color: #30363d;
}
body.dark .wf-share-picker-title { color: #8b949e; }
body.dark .wf-share-picker-item:hover,
body.dark .wf-share-picker-item:focus { background: rgba(63,185,154,0.12); }
body.dark .wf-share-picker-item:active { background: rgba(63,185,154,0.2); }
body.dark .wf-share-picker-avatar { background: rgba(165,180,252,0.15); color: #a5b4fc; }
body.dark .wf-share-picker-name { color: #e1e8ed; }
body.dark .wf-share-picker-email { color: #7d8b99; }

/* Analysis results — light mode base */
.wf-detail-content table {
  width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 12px;
}
.wf-detail-content th {
  background: var(--bg2, #EAF4EE); color: var(--teal, #1a6b5a); font-weight: 600;
  text-align: left; padding: 8px 12px; border: 1px solid var(--border, #E4EBE7);
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em;
}
.wf-detail-content td {
  padding: 8px 12px; border: 1px solid var(--border, #E4EBE7);
  color: var(--text, #111C17); line-height: 1.5;
}
.wf-detail-content tr:hover td { background: var(--bg, #FAFAF8); }
.wf-detail-content h4 { color: var(--text, #111C17); }
/* Analysis results — dark mode */
body.dark .wf-detail-content th {
  background: rgba(63,185,154,0.1); color: #3fb99a; border-color: #30363d;
}
body.dark .wf-detail-content td { border-color: #30363d; color: #c9d1d9; }
body.dark .wf-detail-content tr:hover td { background: rgba(255,255,255,0.03); }
body.dark .wf-detail-content h4 { color: #e1e8ed; }

/* ══════════════════════════════════════════════════════════════════════════════
   TOP BAR (logo left, product switcher centered)
   ══════════════════════════════════════════════════════════════════════════════ */
.app-topbar {
  display: flex; align-items: center;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 52px; flex-shrink: 0;
  z-index: 100;
  position: relative;
}
.app-topbar-brand {
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.app-topbar-brand img { width: 28px; height: 28px; }
.app-topbar-brand h1 {
  font-family: 'Noto Sans', 'Roboto', sans-serif;
  font-size: var(--text-lg); font-weight: 400;
  color: var(--teal); line-height: 1.2; margin: 0;
}
.app-topbar-center {
  position: absolute; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center;
}
.product-switcher {
  display: flex;
  background: var(--bg2);
  border-radius: var(--radius-2xl);
  padding: 5px;
  gap: 10px;
}
.product-switcher-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 28px;
  border: none; border-radius: var(--radius-2xl);
  font-size: 14px; font-weight: 500;
  color: var(--text-light);
  background: transparent;
  cursor: pointer;
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  transition: all 180ms ease;
  white-space: nowrap;
}
.product-switcher-btn:hover { color: var(--text-mid); background: rgba(255,255,255,0.5); }
.product-switcher-btn.active {
  background: var(--white);
  color: var(--teal);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.product-switcher-btn svg { width: 15px; height: 15px; flex-shrink: 0; }

/* Hub and summaries views fill remaining space */
#hubView { display: flex; flex: 1; min-height: 0; overflow: hidden; }
/* ══════════════════════════════════════════════════════════════════════════════
   CASE SUMMARIES VIEW
   ══════════════════════════════════════════════════════════════════════════════ */
#sumView { flex: 1; display: flex; flex-direction: row; min-height: 0; overflow: hidden; }

/* Left sidebar: favorites + courts */
#bf .sum-sidebar {
  width: 320px; flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
}
#bf .sum-sidebar-scroll {
  flex: 1; overflow-y: auto; min-height: 0;
  padding: 12px 0;
}
#bf .sum-sidebar-scroll::-webkit-scrollbar { width: 4px; }
#bf .sum-sidebar-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
#bf .sum-sb-item {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 20px;
  font-size: 15px; color: var(--text-mid);
  cursor: pointer; transition: all 120ms;
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}
#bf .sum-sb-item:last-child { border-bottom: none; }
#bf .sum-sb-item:hover { background: var(--bg2); color: var(--text); }
#bf .sum-sb-item.active {
  background: rgba(26,107,90,0.08); color: var(--teal); font-weight: 600;
  border-radius: var(--radius-md); margin: 2px 10px; padding: 14px 16px;
  border-bottom: none;
}
#bf .sum-sb-item svg { width: 24px; height: 24px; flex-shrink: 0; color: var(--text-light); }
#bf .sum-sb-item.active svg { color: var(--teal); }
#bf .sum-sb-item-label {
  flex: 1; min-width: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}

/* ── COURT CARDS LANDING GRID ── */
/* List header */
#bf .sum-mob-toggle {
  display: none; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: var(--radius-md);
  border: 1.5px solid var(--border); background: var(--white);
  color: var(--teal); cursor: pointer; flex-shrink: 0;
  transition: all 150ms;
}
#bf .sum-mob-toggle:hover { background: var(--bg2); border-color: var(--teal); }
#bf .sum-sidebar-backdrop { display: none; }
#bf .sum-list-header {
  padding: 32px 48px 0;
  flex-shrink: 0;
}
#bf .sum-list-header-top {
  margin-bottom: 6px;
}
#bf .sum-list-header-top h2 {
  font-family: 'Noto Sans', 'Roboto', sans-serif;
  font-size: 26px; font-weight: 400; color: var(--text);
  margin: 0;
}
#bf .sum-list-subtitle {
  font-size: 14px; color: var(--text-light); margin: 0 0 20px;
  font-family: 'Roboto', 'Noto Sans', sans-serif;
}
#bf .sum-result-count {
  font-size: 13px; color: var(--text-light); font-family: 'Roboto', 'Noto Sans', sans-serif;
  margin-left: 12px;
}
#bf .sum-csv-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  margin-left: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--text-mid);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  vertical-align: middle;
  transition: all 0.15s;
}
#bf .sum-csv-btn:hover { border-color: var(--teal); color: var(--teal); background: var(--bg2); }

/* Main content area */
.sum-main {
  flex: 1; display: flex; flex-direction: column;
  min-width: 0; overflow: hidden;
  background: #fff;
}

/* Search bar */
#bf .sum-search-wrap {
  margin-bottom: 20px;
}
#bf .sum-search-box {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: var(--radius-card); padding: 14px 18px;
  transition: border-color 150ms, box-shadow 150ms;
}
#bf .sum-search-box:focus-within { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(26,107,90,0.08); }
#bf .sum-search-box svg { width: 20px; height: 20px; color: var(--text-light); flex-shrink: 0; }
#bf .sum-search-input {
  flex: 1; border: none; outline: none; font-size: 16px;
  font-family: 'Roboto', 'Noto Sans', sans-serif; background: transparent;
  color: var(--text);
}
#bf .sum-search-input::placeholder { color: #b0b8b3; }

/* Filter pills row */
#bf .sum-filters {
  display: flex; gap: 10px; margin-bottom: 24px;
  flex-shrink: 0; flex-wrap: wrap;
}
#bf .sum-filter {
  padding: 10px 18px; border: 1.5px solid var(--border);
  border-radius: var(--radius-2xl); font-size: 14px;
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  background: var(--white); color: var(--text);
  cursor: pointer; outline: none; font-weight: 500;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23555' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 34px;
  transition: border-color 150ms, box-shadow 150ms;
}
#bf .sum-filter:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(26,107,90,0.06); }

/* Scrollable card list */
#bf .sum-body {
  flex: 1; overflow-y: auto;
  padding: 0 48px 48px;
}
#bf .sum-body::-webkit-scrollbar { width: 5px; }
#bf .sum-body::-webkit-scrollbar-track { background: transparent; }
#bf .sum-body::-webkit-scrollbar-thumb { background: #C8D9CE; border-radius: 4px; }

#bf .sum-grid { display: flex; flex-direction: column; gap: 20px; }

/* Case cards — horizontal layout with image */
#bf .sum-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 24px 28px;
  display: flex; align-items: stretch; gap: 24px;
  transition: border-color 180ms, box-shadow 180ms;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06), 0 1px 4px rgba(0,0,0,0.04);
}
#bf .sum-card:hover { border-color: var(--teal); box-shadow: 0 6px 24px rgba(26,107,90,0.12), 0 2px 8px rgba(0,0,0,0.06); }
/* Card thumbnail */
#bf .sum-card-thumb {
  width: 140px; min-height: 120px; flex-shrink: 0;
  border-radius: var(--radius-card); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
#bf .sum-card-thumb svg { width: 100%; height: 100%; display: block; }
#bf .sum-card-content { flex: 1; min-width: 0; cursor: pointer; display: flex; flex-direction: column; }
#bf .sum-card-title {
  font-size: 17px; font-weight: 700; color: var(--text);
  line-height: 1.45; margin-bottom: 10px;
  font-family: 'Roboto', 'Noto Sans', sans-serif;
}
#bf .sum-card-summary {
  font-size: 14px; color: var(--text-mid); line-height: 1.65;
  margin-bottom: 12px;
}
#bf .sum-card-date { font-size: 13px; color: var(--text-light); }
#bf .sum-card-meta {
  display: flex; align-items: center; gap: 12px;
  font-size: 13px; color: var(--text-light); margin-top: auto; padding-top: 8px;
}
#bf .sum-card-court-badge {
  display: inline-block; padding: 3px 10px;
  background: rgba(26,107,90,0.08); color: var(--teal);
  border-radius: var(--radius-sm); font-size: 12px; font-weight: 500;
}
#bf .sum-card-actions {
  display: flex; flex-direction: row; align-items: center;
  gap: 10px; flex-shrink: 0; align-self: center;
}
#bf .sum-card-open {
  padding: 10px 24px; border-radius: var(--radius-2xl);
  background: var(--teal); color: #fff; border: none;
  font-size: 14px; font-weight: 600; cursor: pointer;
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  transition: background 150ms, transform 100ms;
  white-space: nowrap; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
#bf .sum-card-open:hover { background: var(--teal-mid); transform: translateY(-1px); }
#bf .sum-card-fav {
  width: 44px; height: 44px; border: 1.5px solid var(--border); background: var(--white);
  cursor: pointer; color: var(--text-light); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; transition: all 150ms;
}
#bf .sum-card-fav:hover { color: #d4383b; border-color: #d4383b; background: rgba(212,56,59,0.04); }
#bf .sum-card-fav.active { color: #d4383b; border-color: #d4383b; }

/* Pagination */
#bf .sum-pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 6px; padding: 32px 0 8px;
}
#bf .sum-page-btn {
  min-width: 44px; min-height: 44px;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md); font-size: 14px; background: var(--white);
  color: var(--text-mid); cursor: pointer; font-family: 'Roboto', 'Noto Sans', sans-serif;
  transition: all 150ms; font-weight: 500;
}
#bf .sum-page-btn.active { background: var(--teal); color: #fff; border-color: var(--teal); }
#bf .sum-page-btn:hover:not(:disabled):not(.active) { border-color: var(--teal); color: var(--teal); }
#bf .sum-page-btn:disabled { opacity: 0.35; cursor: default; }
#bf .sum-page-btn.nav-btn { width: auto; padding: 0 18px; gap: 6px; }
#bf .sum-page-info { font-size: 14px; color: var(--text-light); padding: 0 8px; }
#bf .sum-page-ellipsis { min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; color: var(--text-light); font-size: 14px; }

/* Detail modal overlay */
/* Right-side slide-in panel */
@keyframes sumSlideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes sumFadeIn { from { opacity: 0; } to { opacity: 1; } }
#bf .sum-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,20,25,0.3);
  backdrop-filter: blur(2px);
  z-index: 9999;
  display: none; align-items: stretch; justify-content: flex-end;
}
#bf .sum-modal-overlay.open { display: flex; animation: sumFadeIn 200ms ease; }
#bf .sum-modal {
  background: var(--white);
  border-radius: 0;
  width: 54%; max-width: 720px; min-width: 380px;
  height: 100%;
  display: flex; flex-direction: column;
  box-shadow: -8px 0 32px rgba(0,0,0,0.12);
  overflow: hidden;
  animation: sumSlideIn 300ms cubic-bezier(0.16,1,0.3,1);
}
#bf .sum-modal-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 28px 32px 0; gap: 16px; flex-shrink: 0;
}
#bf .sum-modal-title { font-size: 18px; font-weight: 700; color: var(--text); line-height: 1.4; flex: 1; }
#bf .sum-modal-close {
  width: 36px; height: 36px; border: 1.5px solid var(--border); background: var(--white);
  cursor: pointer; color: var(--text-light); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: all 150ms; flex-shrink: 0;
  position: absolute; top: 20px; right: 20px;
}
#bf .sum-modal-close:hover { background: var(--bg2); color: var(--text); border-color: var(--text-light); }
#bf .sum-modal-meta {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 14px 32px 16px;
  flex-shrink: 0;
}
#bf .sum-badge {
  display: inline-flex; padding: 4px 12px;
  background: var(--bg2); border-radius: var(--radius-sm);
  font-size: 12px; color: var(--text-mid); font-weight: 500;
}
#bf .sum-modal-body {
  flex: 1; overflow-y: auto; padding: 0 32px 32px;
  font-size: 14px; color: var(--text); line-height: 1.7;
}
#bf .sum-modal-body::-webkit-scrollbar { width: 5px; }
#bf .sum-modal-body::-webkit-scrollbar-thumb { background: #C8D9CE; border-radius: 4px; }
#bf .sum-modal-body b { color: var(--text); }
#bf .sum-modal-footer {
  padding: 16px 32px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
#bf .sum-modal-open-btn {
  padding: 8px 20px; border-radius: var(--radius-base);
  background: var(--teal); color: #fff; border: none;
  font-size: 14px; font-weight: 600; cursor: pointer;
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  transition: background 150ms; text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
}
#bf .sum-modal-open-btn:hover { background: var(--teal-mid); }
#bf .sum-modal-info {
  font-size: 12px; color: var(--text-light); margin-left: auto;
}

/* Loading / empty */
#bf .sum-loading {
  display: flex; align-items: center; justify-content: center;
  padding: 60px; color: var(--text-light); font-size: 14px;
}
#bf .sum-empty {
  text-align: center; padding: 60px 20px;
  color: var(--text-light); font-size: 14px;
}

/* Dark mode */
body.dark .app-topbar { background: #161b22; border-bottom-color: #30363d; }
body.dark .app-topbar-brand h1 { color: #3fb99a; }
body.dark .product-switcher { background: #21262d; }
body.dark .product-switcher-btn { color: #7d8b99; }
body.dark .product-switcher-btn:hover { color: #8b949e; }
body.dark .product-switcher-btn:hover { color: #8b949e; background: rgba(255,255,255,0.04); }
body.dark .product-switcher-btn.active { background: #2d333b; color: #3fb99a; box-shadow: 0 1px 4px rgba(0,0,0,0.25); }
body.dark #bf .sum-sidebar { background: #161b22; border-right-color: #30363d; }
body.dark #bf .sum-mob-toggle { background: #161b22; border-color: #30363d; color: #3fb99a; }
body.dark #bf .sum-sidebar-backdrop.open { background: rgba(0,0,0,0.5); }
body.dark #bf .sum-sb-item { color: #8b949e; border-bottom-color: #21262d; }
body.dark #bf .sum-sb-item:hover { background: rgba(63,185,154,0.06); color: #c9d1d9; }
body.dark #bf .sum-sb-item.active { background: rgba(63,185,154,0.1); color: #3fb99a; }
body.dark #bf .sum-search-box { background: #161b22; border-color: #30363d; }
body.dark #bf .sum-search-box:focus-within { border-color: #3fb99a; }
body.dark #bf .sum-search-input { color: #e1e8ed; }
body.dark #bf .sum-search-input::placeholder { color: #7d8b99; }
body.dark #bf .sum-filter { background: #161b22; border-color: #30363d; color: #8b949e; }
body.dark #bf .sum-card-court-badge { background: rgba(63,185,154,0.15); color: #3fb99a; }
body.dark #bf .sum-list-header-top h2 { color: #e1e8ed; }
body.dark #bf .sum-list-subtitle { color: #7d8b99; }
body.dark #bf .sum-result-count { color: #7d8b99; }
body.dark #bf .sum-main { background: #0d1117; }
body.dark #bf .sum-card { background: #161b22; border-color: #30363d; box-shadow: 0 2px 12px rgba(0,0,0,0.2), 0 1px 4px rgba(0,0,0,0.15); }
body.dark #bf .sum-card:hover { border-color: #3fb99a; }
body.dark #bf .sum-card-title { color: #e1e8ed; }
body.dark #bf .sum-card-summary { color: #8b949e; }
body.dark #bf .sum-card-date { color: #7d8b99; }
body.dark #bf .sum-card-fav { background: #161b22; border-color: #30363d; color: #7d8b99; }
body.dark #bf .sum-card-fav:hover { color: #d4383b; border-color: #d4383b; background: rgba(212,56,59,0.08); }
body.dark #bf .sum-card-fav.active { color: #d4383b; border-color: #d4383b; }
body.dark #bf .sum-badge { background: rgba(63,185,154,0.08); color: #8b949e; }
body.dark #bf .sum-page-btn { background: #161b22; border-color: #30363d; color: #8b949e; }
body.dark #bf .sum-page-btn:hover:not(:disabled):not(.active) { border-color: #3fb99a; color: #3fb99a; }
body.dark #bf .sum-page-btn.active { background: #3fb99a; color: #fff; border-color: #3fb99a; }
body.dark #bf .sum-page-ellipsis { color: #7d8b99; }
body.dark #bf .sum-modal { background: #1c2128; box-shadow: -8px 0 32px rgba(0,0,0,0.3); }
body.dark #bf .sum-modal-close { background: #1c2128; border-color: #30363d; }
body.dark #bf .sum-modal-title { color: #e1e8ed; }
body.dark #bf .sum-modal-body { color: #c9d1d9; }
body.dark #bf .sum-modal-body b { color: #e1e8ed; }
body.dark #bf .sum-modal-footer { border-top-color: #30363d; }
body.dark #bf .sum-body::-webkit-scrollbar-thumb { background: #30363d; }
@media (max-width: 900px) {
  #bf .sum-list-header { padding: 20px 20px 0; }
  #bf .sum-list-header-top h2 { font-size: 22px; }
  #bf .sum-card { padding: 18px 20px; border-radius: var(--radius-card); }
  #bf .sum-card-title { font-size: 15px; }
  #bf .sum-card-summary { font-size: 13px; }
  #bf .sum-card-thumb { width: 110px; min-height: 100px; }
}
@media (max-width: 700px) {
  #bf .sum-sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 1000;
    transform: translateX(-320px); transition: transform 250ms ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.1); width: 280px;
  }
  #bf .sum-sidebar.open { transform: translateX(0); }
  #bf .sum-sidebar-backdrop {
    display: none; position: fixed; inset: 0; z-index: 999;
    background: rgba(0,0,0,0.3);
  }
  #bf .sum-sidebar.open + .sum-sidebar-backdrop,
  #bf .sum-sidebar-backdrop.open { display: block; }
  #bf .sum-mob-toggle { display: inline-flex; }
  #bf .sum-list-header { padding: 16px 16px 0; }
  #bf .sum-body { padding-left: 16px; padding-right: 16px; }
  #bf .sum-card { padding: 16px; gap: 14px; flex-wrap: wrap; }
  #bf .sum-card-thumb { width: 100%; min-height: 100px; max-height: 140px; }
  #bf .sum-card-actions { width: 100%; justify-content: flex-end; padding-top: 0; }
  #bf .sum-modal { width: 100%; min-width: 0; max-width: 100%; }
  #bf .sum-modal-header { padding: 20px 20px 0; }
  #bf .sum-modal-meta { padding: 10px 20px 12px; }
  #bf .sum-modal-body { padding: 0 20px 20px; }
  #bf .sum-modal-footer { padding: 12px 20px; }
}
/* ── Skip navigation (accessibility) ── */
.bf-skip-nav {
  position: absolute; top: -100%; left: 16px;
  z-index: 100000; padding: 10px 20px;
  background: var(--teal, #1a6b5a); color: #fff;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  font-size: 14px; font-weight: 600; font-family: 'Roboto', 'Noto Sans', sans-serif;
  text-decoration: none; white-space: nowrap;
  transition: top 150ms ease;
}
.bf-skip-nav:focus {
  top: 0; outline: 2px solid #fff; outline-offset: 2px;
}

/* ── Upgrade modal ── */
.bf-upgrade-overlay {
  position: fixed; inset: 0; background: rgba(15,20,25,0.5);
  backdrop-filter: blur(4px); z-index: 99999;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.bf-upgrade-card {
  background: #fff; border-radius: var(--radius-xl); box-shadow: var(--shadow-lg);
  padding: 44px 40px; max-width: 440px; width: 100%;
  text-align: center; font-family: 'Roboto', 'Noto Sans', sans-serif;
  animation: sumSlideIn 300ms cubic-bezier(0.16,1,0.3,1);
}
.bf-upgrade-icon {
  width: 60px; height: 60px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 22px; background: linear-gradient(135deg,#e8f5f0,#d0ebe3);
}
.bf-upgrade-title { margin: 0 0 10px; font-size: 20px; font-weight: 700; color: #111C17; }
.bf-upgrade-text { margin: 0 0 28px; font-size: 15px; line-height: 1.6; color: #4A5C52; }
.bf-upgrade-cta {
  display: inline-block; padding: 12px 36px; background: #1a6b5a; color: #fff;
  border-radius: var(--radius-full); font-size: 15px; font-weight: 600;
  text-decoration: none; transition: all 180ms ease; font-family: 'Roboto', 'Noto Sans', sans-serif;
}
.bf-upgrade-cta:hover { background: #145a4a; transform: translateY(-1px); }
.bf-upgrade-close {
  margin-top: 18px; background: none; border: none; font-size: 14px;
  cursor: pointer; font-family: 'Roboto', 'Noto Sans', sans-serif; padding: 8px 16px;
  color: #4A5C52;
}
/* Upgrade modal — dark mode */
body.dark .bf-upgrade-card { background: #1c2128; }
body.dark .bf-upgrade-icon { background: linear-gradient(135deg,#1a3a30,#1a4a3a); }
body.dark .bf-upgrade-title { color: #e1e8ed; }
body.dark .bf-upgrade-text { color: #8b949e; }
body.dark .bf-upgrade-close { color: #8b949e; }
body.dark .bf-upgrade-close:hover { color: #e1e8ed; }
@media (max-width: 380px) {
  .bf-upgrade-card { padding: 28px 20px; }
  .bf-upgrade-icon { width: 48px; height: 48px; margin-bottom: 16px; }
  .bf-upgrade-icon svg { width: 22px; height: 22px; }
  .bf-upgrade-title { font-size: 17px; }
  .bf-upgrade-text { font-size: 13px; margin-bottom: 20px; }
  .bf-upgrade-cta { padding: 10px 28px; font-size: 14px; }
  .bf-upgrade-close { font-size: 13px; }
}

@media (max-width: 600px) {
  #bf .sum-list-header { padding: 12px 12px 0; }
  #bf .sum-list-header-top h2 { font-size: 19px; }
  #bf .sum-list-subtitle { font-size: 13px; margin-bottom: 14px; }
  #bf .sum-body { padding: 0 12px 24px; }
  #bf .sum-grid { gap: 14px; }
  #bf .sum-card { padding: 14px; gap: 12px; border-radius: var(--radius-md); }
  #bf .sum-card-thumb { display: none; }
  #bf .sum-card-title { font-size: 14px; margin-bottom: 6px; }
  #bf .sum-card-summary { font-size: 13px; margin-bottom: 8px; -webkit-line-clamp: 3; }
  #bf .sum-card-meta { font-size: 12px; gap: 8px; }
  #bf .sum-card-court-badge { font-size: 11px; padding: 2px 8px; }
  #bf .sum-card-actions { flex-direction: row; gap: 8px; }
  #bf .sum-card-open { padding: 8px 16px; font-size: 13px; }
  #bf .sum-card-fav { width: 38px; height: 38px; font-size: 18px; }
  #bf .sum-search-box { padding: 10px 14px; gap: 10px; border-radius: var(--radius-md); }
  #bf .sum-search-input { font-size: 14px; }
  #bf .sum-filter { padding: 8px 14px; font-size: 13px; padding-right: 30px; }
  #bf .sum-filters { gap: 8px; margin-bottom: 16px; }
  #bf .sum-result-count { margin-left: 8px; font-size: 12px; }
  #bf .sum-pagination { gap: 8px; padding-top: 24px; }
  #bf .sum-modal-header { padding: 16px 16px 0; }
  #bf .sum-modal-meta { padding: 8px 16px 10px; }
  #bf .sum-modal-body { padding: 0 16px 16px; font-size: 13px; }
  #bf .sum-modal-footer { padding: 10px 16px; }
}

/* ── SEARCH HIGHLIGHT ── */
#bf mark, mark.bf-hl, .bf-hl {
  background: var(--teal-pale, #EAF4EE); color: var(--teal, #1a6b5a);
  padding: 0 2px; border-radius: 2px; font-weight: 600;
}
body.dark #bf mark, body.dark mark.bf-hl, body.dark .bf-hl {
  background: rgba(63,185,154,0.18); color: #5ad4b5;
}

/* ── BULK SELECT MODE (conversations) ── */
#bf .conv-bulk-toggle {
  width: 24px; height: 24px; border: none; background: none; cursor: pointer;
  color: var(--text-light); border-radius: var(--radius-xs); display: flex;
  align-items: center; justify-content: center; transition: all 150ms;
  flex-shrink: 0;
}
#bf .conv-bulk-toggle:hover { background: var(--bg2); color: var(--teal); }
#bf .conv-bulk-toggle.active { color: var(--teal); }
#bf .conv-bulk-bar {
  display: none; padding: 6px 8px; gap: 6px; align-items: center;
  font-size: 11px; color: var(--text-mid);
}
#bf .conv-bulk-bar.show { display: flex; }
#bf .conv-bulk-bar button {
  height: 26px; padding: 0 10px; border-radius: var(--radius-2xl); font-size: 11px;
  font-weight: 500; cursor: pointer; font-family: 'Roboto', 'Noto Sans', sans-serif; border: none;
  transition: all 150ms;
}
#bf .conv-bulk-bar .bulk-sel-all { background: var(--bg2); color: var(--text-mid); }
#bf .conv-bulk-bar .bulk-sel-all:hover { background: var(--border); }
#bf .conv-bulk-bar .bulk-del {
  background: var(--danger-pale, #fee2e2); color: var(--danger-dark, #991b1b);
  margin-left: auto;
}
#bf .conv-bulk-bar .bulk-del:hover { filter: brightness(0.95); }
#bf .conv-bulk-bar .bulk-del:disabled { opacity: 0.4; cursor: not-allowed; }
#bf .conv-bulk-count { font-weight: 600; color: var(--teal); }
#bf .conv-cb {
  width: 16px; height: 16px; accent-color: var(--teal); cursor: pointer;
  flex-shrink: 0; margin: 0;
}
#bf .conv-item.bulk-mode .conv-drag { display: none; }
#bf .conv-item.bulk-mode .conv-actions { display: none; }

/* ── OFFLINE BANNER ── */
.bf-offline-bar {
  display: none; position: fixed; top: 0; left: 0; right: 0; z-index: 10001;
  background: var(--danger, #C0392B); color: #fff; text-align: center;
  padding: 8px 16px; font-size: 13px; font-weight: 600;
  font-family: 'Roboto', 'Noto Sans', sans-serif;
  animation: bfSlideDown 300ms ease;
}
.bf-offline-bar.show { display: flex; align-items: center; justify-content: center; gap: 8px; }
.bf-offline-bar svg { flex-shrink: 0; }
@keyframes bfSlideDown { from { transform: translateY(-100%); } to { transform: translateY(0); } }
@media print { .bf-offline-bar { display: none !important; } }

/* ── PRINT STYLESHEET ────────────────────────────────────────────────────── */
@media print {
  /* Hide non-content UI */
  .login-wrap, .bf-global-overlay, .bf-toast,
  #bf .sb, #bf .chat-input-wrap, #bf .tab-bar,
  #bf .conv-actions, #bf .conv-drag,
  #bf .draft-editor-actions, #bf .wiz-ai-below,
  #bf .wiz-header button, #bf .draft-back-btn,
  #bf .answer-action-btn, #bf .answer-nav,
  #bf .sum-search-wrap, #bf .sum-sidebar,
  #bf .sum-pagination, #bf .sum-card-fav,
  #bf .preview-actions, #bf .preview-btn,
  #bf .think-status, #bf .typing-indicator,
  .wf-detail-pill, .wf-detail-back, .wf-card-action-btn, .wf-card-action-del,
  #userDropdown, .sb-toggle { display: none !important; }

  /* Reset layout to full width */
  body, html { background: #fff !important; }
  #bf { display: block !important; }
  #bf .main { margin-left: 0 !important; padding: 0 !important; width: 100% !important; }
  #bf .tab-content { padding: 0 !important; }

  /* Chat messages: clean readable output */
  #bf .msgs { max-height: none !important; overflow: visible !important; }
  #bf .ai-body, #bf .answer-card {
    break-inside: avoid; page-break-inside: avoid;
    box-shadow: none !important; border: none !important;
    background: #fff !important; color: #000 !important;
  }
  #bf .answer-card { font-size: 12pt; line-height: 1.6; }

  /* Draft content: document-like print */
  #bf .draft-content, #bf .preview-doc {
    min-height: auto !important; max-height: none !important;
    overflow: visible !important; border: none !important;
    box-shadow: none !important; padding: 0 !important;
    font-size: 12pt; line-height: 1.6;
  }
  #bf .wiz-editor-scroll { overflow: visible !important; max-height: none !important; }
  #bf .wiz-doc-area { max-width: none !important; padding: 0 !important; }

  /* Summaries: clean card print */
  #bf .sum-card {
    break-inside: avoid; page-break-inside: avoid;
    box-shadow: none !important; border: 1px solid #ccc !important;
  }
  #bf .sum-body { max-height: none !important; overflow: visible !important; }

  /* Typography: ensure legibility */
  * { color: #000 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a { text-decoration: underline !important; }
  a[href]::after { content: " (" attr(href) ")"; font-size: 9pt; color: #555 !important; }
  a[href^="#"]::after, a[href^="javascript"]::after { content: none; }

  /* Page setup */
  @page { margin: 2cm; size: A4; }
}

/* ── Floating restore-draft chip ─────────────────────────────────────────── */
.bf-restore-draft-chip {
  position: fixed;
  bottom: 90px;
  right: 24px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg2, #f8f9fa);
  border: 1px solid var(--teal, #009688);
  border-radius: 20px;
  color: var(--teal, #009688);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  transition: background 0.15s, box-shadow 0.15s, transform 0.15s;
  animation: bfChipSlideIn 0.3s ease-out;
}
.bf-restore-draft-chip:hover {
  background: var(--teal, #009688);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
  transform: translateY(-1px);
}
@keyframes bfChipSlideIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

