/* ── Reset & Variables ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --bg-page:            #08111a;
  --nav-bg:             rgba(6, 12, 20, 0.72);
  --panel-bg:           rgba(14, 24, 36, 0.88);
  --panel-border:       rgba(255, 255, 255, 0.13);
  --panel-header-border:rgba(255, 255, 255, 0.10);
  --notice-bg:          rgba(255, 255, 255, 0.06);
  --notice-border:      rgba(255, 255, 255, 0.13);
  --sidebar-bg:         rgba(10, 18, 28, 0.88);
  --sidebar-border:     rgba(255, 255, 255, 0.10);
  --item-hover:         rgba(255, 255, 255, 0.06);
  --item-active:        rgba(255, 255, 255, 0.10);
  --text-primary:       #ffffff;
  --text-secondary:     rgba(255, 255, 255, 0.88);
  --text-muted:         rgba(255, 255, 255, 0.60);
  --status-processing:  rgba(220, 170, 80, 0.85);
  --status-done:        rgba(100, 190, 140, 0.80);
  --status-error:       rgba(200, 90, 90, 0.80);
  --status-pending:     rgba(255, 255, 255, 0.30);
  --font-body:  'Cormorant Garamond', Georgia, serif;
  --font-mono:  'JetBrains Mono', 'Fira Code', monospace;
  --nav-height: 58px;
  --db-sidebar-width: 260px;
  --radius: 4px;
  --transition: 150ms ease;
}

html, body {
  height: 100%;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  color: var(--text-primary);
  overflow: hidden;
}

body {
  background-color: var(--bg-page);
  background-image: url('/static/caselaw_bg.jpeg');
  background-size: cover;
  background-position: center bottom;
  background-repeat: no-repeat;
}

/* ── Top Navigation ──────────────────────────────────────────────── */
.topnav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-height);
  z-index: 50;
  display: flex;
  align-items: center;
  padding: 0 28px;
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--panel-border);
}

.nav-logo { display: flex; align-items: center; flex-shrink: 0; margin-right: 36px; }
.nav-logo-img { height: 28px; width: auto; display: block; opacity: 0.92; }

.nav-center {
  display: flex;
  align-items: center;
  gap: 32px;
  flex: 1;
}

.nav-link {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-secondary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color var(--transition);
  white-space: nowrap;
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
}
.nav-link:hover { color: var(--text-primary); }
.nav-link-active {
  color: var(--text-primary);
  border-bottom-color: rgba(255, 255, 255, 0.35);
}

.nav-dot { font-size: 14px; line-height: 1; }

.nav-right {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
  margin-left: auto;
}

.nav-link-sm {
  font-size: 15px;
  font-weight: 400;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition);
  white-space: nowrap;
}
.nav-link-sm:hover { color: var(--text-primary); }

.btn-login {
  padding: 5px 18px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-login:hover { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.5); }

.btn-lang {
  display: flex; align-items: center; gap: 4px;
  background: none; border: none;
  color: var(--text-secondary);
  cursor: pointer; padding: 4px;
  transition: color var(--transition);
}
.btn-lang:hover { color: var(--text-primary); }

.nav-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.20);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-muted);
  transition: all var(--transition);
  flex-shrink: 0;
}
.nav-avatar:hover { background: rgba(255,255,255,0.13); color: var(--text-secondary); }

/* ── View containers ──────────────────────────────────────────────── */
.view {
  position: fixed;
  top: var(--nav-height);
  left: 0; right: 0; bottom: 0;
}
.view[hidden] { display: none !important; }

#view-chat {
  display: flex;
  flex-direction: column;
}

/* ══════════════════════════════════════════════════════════════════
   Chat View
══════════════════════════════════════════════════════════════════ */
.chat-panel {
  flex: 1;
  margin: 16px 16px 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--panel-header-border);
  flex-shrink: 0;
}
.panel-title {
  font-size: 17px;
  font-weight: 400;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}
.panel-controls { display: flex; align-items: center; gap: 6px; }
.panel-ctrl-btn {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  border-radius: 3px;
  transition: all var(--transition);
}
.panel-ctrl-btn:hover { color: var(--text-secondary); background: rgba(255,255,255,0.05); }

.chat-messages {
  flex: 1; overflow-y: auto;
  padding: 20px 20px 16px;
  display: flex; flex-direction: column; gap: 10px;
}

.maintenance-notice {
  margin: auto;
  padding: 18px 28px;
  background: var(--notice-bg);
  border: 1px solid var(--notice-border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 17px; font-weight: 300;
  text-align: center;
  max-width: 480px;
  letter-spacing: 0.01em;
}

/* Messages */
.message {
  width: 100%;
  background: rgba(14, 24, 36, 0.55);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 16px 20px;
  animation: fadeIn 200ms ease;
}
.message.user {
  background: rgba(255,255,255,0.03);
  border-color: rgba(255,255,255,0.05);
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg-header {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 10px;
}
.msg-avatar-img {
  width: 22px; height: 22px;
  object-fit: contain;
  border-radius: 50%;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  padding: 3px;
  flex-shrink: 0;
}
.msg-role {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.message-content { font-size: 17px; line-height: 1.75; color: var(--text-secondary); font-weight: 300; }
.message.user .message-content { color: var(--text-secondary); }
.message-content pre {
  background: rgba(0,0,0,0.3); border: 1px solid var(--panel-border);
  border-radius: 4px; padding: 12px 16px; margin: 8px 0;
  overflow-x: auto; font-family: var(--font-mono); font-size: 12px; line-height: 1.5;
}
.message-content code {
  font-family: var(--font-mono); font-size: 12px;
  background: rgba(0,0,0,0.25); padding: 2px 5px; border-radius: 3px;
}
.message-content pre code { background: none; padding: 0; }
.streaming .message-content::after {
  content: "▊"; display: inline;
  animation: blink 800ms step-end infinite;
  color: var(--text-muted); margin-left: 2px;
}
@keyframes blink { 50% { opacity: 0; } }

/* ── Chat welcome state ───────────────────────────────────────────── */
.chat-welcome {
  margin: auto;
  width: 100%;
  max-width: 740px;
  padding: 8px 0;
}

.chat-welcome-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.chat-ai-avatar {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.15);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  padding: 9px;
  background-image: url('/static/Logo_Small_Gavel-1.png');
  background-size: cover;
}
.chat-ai-avatar img { width: 100%; height: 100%; object-fit: contain; }

.chat-welcome-bubble {
  flex: 1;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 6px;
  padding: 20px 24px;
}
.chat-welcome-bubble > p {
  font-size: 16px;
  font-weight: 300;
  color: var(--text-secondary);
  line-height: 1.78;
  margin-bottom: 20px;
}

.chat-claim-dropzone {
  border: 1px dashed rgba(255,255,255,0.17);
  border-radius: 6px;
  padding: 22px 20px;
  cursor: pointer;
  text-align: center;
  transition: all var(--transition);
}
.chat-claim-dropzone:hover {
  border-color: rgba(255,255,255,0.32);
  background: rgba(255,255,255,0.03);
}
.chat-claim-dropzone.uploaded { border-color: rgba(100,190,140,0.45); }

.chat-claim-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text-muted);
}

.chat-claim-text {
  font-size: 16px;
  font-weight: 400;
  color: var(--text-secondary);
}

.chat-claim-sub {
  font-size: 14px;
  color: var(--text-muted);
}

.chat-claim-status {
  margin-top: 12px;
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.55;
}

/* ── Chat footer ──────────────────────────────────────────────────── */
.chat-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 16px 12px;
  font-size: 13px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.chat-footer a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}
.chat-footer a:hover { color: var(--text-secondary); }
.footer-sep { color: rgba(255,255,255,0.18); }

/* Input */
.chat-input-area {
  padding: 12px 20px 16px;
  flex-shrink: 0;
  border-top: 1px solid var(--panel-header-border);
}
.input-wrapper { display: flex; align-items: flex-end; gap: 10px; }
#chat-input {
  flex: 1; background: transparent; border: none;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  color: var(--text-primary);
  font-family: var(--font-body); font-size: 17px; font-weight: 300;
  font-style: italic; line-height: 1.5; resize: none; outline: none;
  max-height: 140px; padding: 8px 0;
  transition: border-color var(--transition);
}
#chat-input::placeholder { color: var(--text-muted); font-style: italic; }
#chat-input:focus { border-bottom-color: rgba(255,255,255,0.25); font-style: normal; }
.btn-send {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; border-radius: 3px; flex-shrink: 0;
  transition: color var(--transition); padding-bottom: 4px;
}
.btn-send:hover { color: var(--text-secondary); }
.btn-send:disabled { opacity: 0.3; cursor: default; }

/* ══════════════════════════════════════════════════════════════════
   Discovery Brief View
══════════════════════════════════════════════════════════════════ */
.db-layout {
  display: flex;
  height: 100%;
}

/* ── Sidebar ──────────────────────────────────────────────────────── */
.db-sidebar {
  width: var(--db-sidebar-width);
  min-width: var(--db-sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.db-sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.db-sidebar-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.db-sidebar-controls { display: flex; align-items: center; gap: 6px; }

.db-sort-select {
  background: transparent;
  border: 1px solid var(--sidebar-border);
  border-radius: 3px;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 3px 6px;
  cursor: pointer;
  outline: none;
  transition: all var(--transition);
}
.db-sort-select:hover { color: var(--text-secondary); border-color: rgba(255,255,255,0.15); }
.db-sort-select option { background: #0d1a28; }

.db-btn-new-project {
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px;
  background: none;
  border: 1px solid var(--sidebar-border);
  border-radius: 3px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.db-btn-new-project:hover { color: var(--text-primary); border-color: rgba(255,255,255,0.2); }

/* Inline new-project input */
.db-new-project-row {
  padding: 8px 12px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.db-inline-input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 3px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  padding: 5px 8px;
  outline: none;
  transition: border-color var(--transition);
}
.db-inline-input:focus { border-color: rgba(255,255,255,0.3); }

/* Project list */
.db-projects-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

.db-project-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  cursor: pointer;
  border-radius: 0;
  transition: background var(--transition);
  border-left: 2px solid transparent;
  position: relative;
}
.db-project-item:hover { background: var(--item-hover); }
.db-project-item.active {
  background: var(--item-active);
  border-left-color: rgba(255,255,255,0.3);
}

.db-project-icon {
  flex-shrink: 0;
  color: var(--text-muted);
  display: flex;
}

.db-project-info { flex: 1; min-width: 0; }
.db-project-name {
  display: block;
  font-size: 15px;
  font-weight: 400;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--transition);
}
.db-project-item:hover .db-project-name,
.db-project-item.active .db-project-name { color: var(--text-primary); }

.db-project-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 1px;
}

.db-processing-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--status-processing);
  animation: pulse 1.4s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

.db-project-delete {
  opacity: 0;
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  padding: 2px 4px; border-radius: 3px;
  font-size: 16px; line-height: 1;
  transition: all var(--transition);
  flex-shrink: 0;
}
.db-project-item:hover .db-project-delete { opacity: 1; }
.db-project-delete:hover { color: var(--status-error); }

/* ── Discovery Main ───────────────────────────────────────────────── */
.db-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(8, 14, 22, 0.55);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

/* Empty state */
.db-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  height: 100%;
  color: var(--text-muted);
  font-size: 16px;
  font-weight: 300;
  letter-spacing: 0.02em;
}

/* Project view */
.db-project-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.db-project-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px 16px;
  border-bottom: 1px solid var(--panel-header-border);
  flex-shrink: 0;
}

.db-project-title {
  font-size: 22px;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

.db-project-actions { display: flex; align-items: center; gap: 10px; }

.db-btn-upload {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 16px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 3px;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 15px;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.db-btn-upload:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); border-color: rgba(255,255,255,0.35); }

/* Drop zone */
.db-drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 28px;
  padding: 48px 24px;
  border: 1px dashed rgba(255,255,255,0.12);
  border-radius: 6px;
  color: var(--text-muted);
  transition: all var(--transition);
  cursor: pointer;
}
.db-drop-zone.drag-over {
  border-color: rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.03);
  color: var(--text-secondary);
}
.db-drop-zone p { font-size: 16px; font-weight: 300; }
.db-drop-hint { font-size: 13px !important; margin-top: 2px; }
.db-drop-link { color: var(--text-secondary); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.db-drop-link:hover { color: var(--text-primary); }

/* Files list */
.db-files-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.db-file-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition);
}
.db-file-card:hover { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.1); }

.db-file-icon { color: var(--text-muted); flex-shrink: 0; display: flex; }

.db-file-info { flex: 1; min-width: 0; }
.db-file-name {
  display: block;
  font-size: 16px;
  font-weight: 400;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--transition);
}
.db-file-card:hover .db-file-name { color: var(--text-primary); }
.db-file-meta { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.db-file-excerpt {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.55;
  margin-top: 4px;
  font-style: italic;
}

/* Status badges */
.db-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  white-space: nowrap;
  flex-shrink: 0;
}
.db-status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.db-status.pending  { color: var(--status-pending); }
.db-status.pending  .db-status-dot { background: var(--status-pending); }
.db-status.processing { color: var(--status-processing); }
.db-status.processing .db-status-dot {
  background: var(--status-processing);
  animation: pulse 1.4s ease-in-out infinite;
}
.db-status.done    { color: var(--status-done); }
.db-status.done    .db-status-dot { background: var(--status-done); }
.db-status.error   { color: var(--status-error); }
.db-status.error   .db-status-dot { background: var(--status-error); }

.db-file-reprocess {
  opacity: 0;
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  padding: 4px; border-radius: 3px;
  display: flex; align-items: center;
  transition: all var(--transition);
  flex-shrink: 0;
}
.db-file-card:hover .db-file-reprocess { opacity: 1; }
.db-file-reprocess:hover { color: var(--text-primary); }

.db-file-delete {
  opacity: 0;
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  padding: 4px; border-radius: 3px;
  font-size: 18px; line-height: 1;
  transition: all var(--transition);
  flex-shrink: 0;
}
.db-file-card:hover .db-file-delete { opacity: 1; }
.db-file-delete:hover { color: var(--status-error); }

/* Reprocess button in detail header */
.db-btn-reprocess {
  display: flex; align-items: center; gap: 6px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 3px;
  color: var(--text-muted);
  font-family: var(--font-body); font-size: 14px;
  padding: 4px 12px; cursor: pointer;
  transition: all var(--transition);
  margin-left: 8px;
}
.db-btn-reprocess:hover {
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.05);
}

/* ── File Detail ──────────────────────────────────────────────────── */
.db-file-detail {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.db-detail-header {
  padding: 18px 28px 16px;
  border-bottom: 1px solid var(--panel-header-border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.db-btn-back {
  display: flex; align-items: center; gap: 5px;
  background: none; border: none;
  color: var(--text-muted);
  font-family: var(--font-body); font-size: 14px;
  cursor: pointer; padding: 0;
  transition: color var(--transition);
  width: fit-content;
}
.db-btn-back:hover { color: var(--text-secondary); }

.db-detail-title-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.db-detail-filename {
  font-size: 20px;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}

.db-detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
}

/* Processing state in detail */
.db-detail-processing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  height: 100%;
  color: var(--text-muted);
  font-size: 16px;
  font-weight: 300;
}
.db-spinner {
  width: 32px; height: 32px;
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: var(--status-processing);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Summary content */
.db-summary {
  font-size: 17px;
  font-weight: 300;
  line-height: 1.85;
  color: var(--text-secondary);
  white-space: pre-wrap;
}
.db-summary h2 {
  font-size: 19px;
  font-weight: 500;
  color: var(--text-primary);
  margin: 24px 0 8px;
  letter-spacing: 0.02em;
}
.db-summary h2:first-child { margin-top: 0; }
.db-summary strong { color: var(--text-primary); font-weight: 500; }

/* Error state in detail */
.db-detail-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 100%;
  color: var(--status-error);
  font-size: 15px;
  font-weight: 300;
  text-align: center;
}
.db-detail-error p { color: var(--text-muted); font-size: 13px; max-width: 360px; }

/* ── Modal ────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  backdrop-filter: blur(6px);
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: rgba(12,20,30,0.96);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  width: 90%; max-width: 520px;
  padding: 24px;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.modal-header h2 {
  font-size: 17px; font-weight: 500;
  letter-spacing: 0.08em; color: var(--text-primary);
}
.btn-icon {
  background: none; border: 1px solid var(--panel-border);
  color: var(--text-secondary);
  width: 30px; height: 30px; border-radius: 3px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 18px; line-height: 1; transition: all var(--transition);
}
.btn-icon:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }
.modal-body { display: flex; flex-direction: column; gap: 8px; }
.modal-body label {
  font-size: 11px; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted);
}
.input-field {
  width: 100%; padding: 8px 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--panel-border);
  border-radius: 3px; color: var(--text-primary);
  font-family: var(--font-body); font-size: 15px; font-weight: 300;
  outline: none; transition: border-color var(--transition); resize: vertical;
}
.input-field:focus { border-color: rgba(255,255,255,0.2); }
.modal-footer { margin-top: 16px; display: flex; justify-content: flex-end; }
.btn-primary {
  padding: 7px 22px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 3px; color: var(--text-primary);
  font-family: var(--font-body); font-size: 15px; font-weight: 400;
  cursor: pointer; transition: all var(--transition);
}
.btn-primary:hover { background: rgba(255,255,255,0.15); }

/* ── Sidebar search ──────────────────────────────────────────────── */
.db-search-row {
  padding: 8px 12px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.db-search-input {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: 3px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  padding: 5px 10px 5px 28px;
  outline: none;
  transition: border-color var(--transition);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='13' height='13' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.45)' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 8px center;
}
.db-search-input::placeholder { color: var(--text-muted); }
.db-search-input:focus { border-color: rgba(255,255,255,0.28); }

/* ── Disk space ───────────────────────────────────────────────────── */
.db-disk {
  padding: 12px 14px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.db-disk-label {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
}
.db-disk-label span { font-size: 11px; letter-spacing: 0; text-transform: none; color: var(--text-muted); }
.db-disk-bar {
  height: 3px;
  background: rgba(255,255,255,0.10);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 5px;
}
.db-disk-fill {
  height: 100%;
  background: rgba(255,255,255,0.35);
  border-radius: 2px;
  transition: width 0.4s ease;
}
.db-disk-detail {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Watchlist ────────────────────────────────────────────────────── */
.db-watchlist {
  padding: 12px 28px 8px;
  border-bottom: 1px solid var(--panel-header-border);
  flex-shrink: 0;
}

.db-watchlist-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.db-watchlist-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.db-watchlist-input {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  padding: 4px 0;
  outline: none;
  transition: border-color var(--transition);
}
.db-watchlist-input::placeholder { color: var(--text-muted); font-style: italic; }
.db-watchlist-input:focus { border-bottom-color: rgba(255,255,255,0.28); }

.db-watchlist-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  min-height: 0;
}

.db-watchlist-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  background: rgba(220,170,80,0.12);
  border: 1px solid rgba(220,170,80,0.30);
  border-radius: 20px;
  font-size: 13px;
  color: rgba(220,185,100,0.90);
  cursor: default;
}

.db-watchlist-tag-remove {
  background: none; border: none;
  color: inherit; cursor: pointer;
  padding: 0; font-size: 14px; line-height: 1;
  opacity: 0.6;
  transition: opacity var(--transition);
}
.db-watchlist-tag-remove:hover { opacity: 1; }

/* ── Alert badge on file cards ────────────────────────────────────── */
.db-file-alert {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  background: rgba(220,170,80,0.14);
  border: 1px solid rgba(220,170,80,0.35);
  border-radius: 20px;
  font-size: 12px;
  color: rgba(220,185,100,0.92);
  white-space: nowrap;
  flex-shrink: 0;
}
.db-file-alert-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: rgba(220,170,80,0.85);
  flex-shrink: 0;
}

/* Alert matches in detail view */
.db-alert-matches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 16px;
  background: rgba(220,170,80,0.07);
  border: 1px solid rgba(220,170,80,0.20);
  border-radius: 6px;
  margin-bottom: 20px;
}
.db-alert-matches-label {
  width: 100%;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(220,185,100,0.70);
  margin-bottom: 4px;
}
.db-alert-match-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  background: rgba(220,170,80,0.15);
  border: 1px solid rgba(220,170,80,0.30);
  border-radius: 20px;
  font-size: 13px;
  color: rgba(220,185,100,0.92);
}

/* ── In-project keyword search ────────────────────────────────────── */
.db-project-search-row {
  padding: 12px 28px 0;
  flex-shrink: 0;
}
.db-project-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.db-project-search-wrap svg {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  pointer-events: none;
  flex-shrink: 0;
}
.db-project-search-input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: 3px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 16px;
  padding: 7px 12px 7px 34px;
  outline: none;
  transition: border-color var(--transition);
}
.db-project-search-input::placeholder { color: var(--text-muted); }
.db-project-search-input:focus { border-color: rgba(255,255,255,0.28); }

/* Search results */
.db-search-results {
  padding: 14px 28px 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.db-search-results-label {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.db-search-result-card {
  padding: 10px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition);
}
.db-search-result-card:hover { background: rgba(255,255,255,0.07); border-color: rgba(255,255,255,0.16); }
.db-search-result-name { font-size: 15px; font-weight: 500; color: var(--text-primary); margin-bottom: 4px; }
.db-search-result-excerpt {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.db-search-result-excerpt mark {
  background: rgba(255,220,100,0.25);
  color: var(--text-primary);
  border-radius: 2px;
  padding: 0 2px;
}
.db-search-no-results {
  font-size: 15px;
  color: var(--text-muted);
  padding: 4px 0;
}

/* ── Summary table ────────────────────────────────────────────────── */
.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 17px;
  font-weight: 300;
}
.summary-table td {
  padding: 14px 16px;
  vertical-align: top;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  line-height: 1.75;
}
.summary-table tr:last-child td { border-bottom: none; }
.summary-label {
  width: 200px;
  min-width: 160px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding-top: 16px !important;
  white-space: nowrap;
}
.summary-content {
  color: var(--text-secondary);
  line-height: 1.8;
}
.summary-content strong { color: var(--text-primary); font-weight: 500; }
.summary-content em { font-style: italic; }
.summary-meta-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
  font-size: 15px;
}
.summary-meta-table td { padding: 6px 12px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.summary-meta-table td:first-child {
  width: 140px; font-size: 11px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--text-muted);
}
.summary-meta-table td:last-child { color: var(--text-secondary); }

/* File type badge */
.db-file-type {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.10);
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ── Results table (AI-generated HTML) ───────────────────────────── */
.resultsOptions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 6px;
}
.resultsOptions a {
  color: var(--text-muted);
  font-size: 15px;
  text-decoration: none;
  transition: color var(--transition);
}
.resultsOptions a:hover { color: var(--text-secondary); }

.tblresults {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  font-weight: 300;
}
.tblresults thead tr {
  border-bottom: 1px solid rgba(255,255,255,0.10);
}
.tblresults th {
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  white-space: nowrap;
}
.tblresults tbody tr {
  border-bottom: 1px solid rgba(255,255,255,0.05);
  transition: background var(--transition);
}
.tblresults tbody tr:hover { background: rgba(255,255,255,0.03); }
.tblresults tbody tr:last-child { border-bottom: none; }
.tblresults td {
  padding: 10px 12px;
  vertical-align: top;
  color: var(--text-secondary);
  line-height: 1.6;
}
.tblresults a {
  color: var(--text-secondary);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color var(--transition);
}
.tblresults a:hover { color: var(--text-primary); }

/* Match percentage badge */
.colMatch {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.colorGreatMatch {
  background: rgba(80, 190, 120, 0.15);
  border: 1px solid rgba(80, 190, 120, 0.35);
  color: rgba(100, 210, 140, 0.95);
}
.colorGoodMatch {
  background: rgba(220, 170, 60, 0.13);
  border: 1px solid rgba(220, 170, 60, 0.32);
  color: rgba(220, 185, 80, 0.95);
}
.colorBadMatch {
  background: rgba(200, 90, 90, 0.12);
  border: 1px solid rgba(200, 90, 90, 0.30);
  color: rgba(210, 100, 100, 0.90);
}

/* Description column loader */
.colDescription { color: var(--text-muted); font-style: italic; }
.loader2 {
  display: inline-block;
  width: 120px;
  height: 10px;
  background: linear-gradient(
    90deg,
    rgba(255,255,255,0.06) 25%,
    rgba(255,255,255,0.12) 50%,
    rgba(255,255,255,0.06) 75%
  );
  background-size: 200% 100%;
  border-radius: 4px;
  animation: shimmer 1.4s infinite linear;
  vertical-align: middle;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Mobile visibility helpers */
@media (max-width: 700px) {
  .hideonMobile { display: none !important; }
}
.showOnlyMobile { display: none; }
@media (max-width: 700px) {
  .showOnlyMobile { display: block; }
}
.txtCourt {
  font-size: 12px;
  color: var(--text-muted);
  margin: 2px 0 0;
}

/* Tool-call indicator shown while database is queried */
.tool-call-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}
.tool-call-indicator::before {
  content: "";
  display: inline-block;
  width: 10px; height: 10px;
  border: 1.5px solid rgba(255,255,255,0.15);
  border-top-color: var(--status-processing);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

/* ── Pricing Modal ────────────────────────────────────────────────── */
.pricing-overlay {
  position: fixed; inset: 0;
  background: rgba(4, 8, 16, 0.88);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 24px 16px;
}
.pricing-overlay[hidden] { display: none; }

.pricing-box {
  position: relative;
  width: 100%; max-width: 700px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  text-align: center;
}

.pricing-close {
  position: absolute;
  top: -4px; right: 0;
  background: none; border: none;
  color: var(--text-muted);
  font-size: 26px; line-height: 1;
  cursor: pointer; padding: 4px 8px;
  transition: color var(--transition);
  z-index: 1;
}
.pricing-close:hover { color: var(--text-primary); }

.pricing-heading {
  font-size: 34px;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: 0.02em;
  margin-bottom: 6px;
}
.pricing-sub {
  font-size: 16px;
  font-weight: 300;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 28px;
}

.pricing-cards {
  display: flex;
  gap: 12px;
  text-align: left;
}

.pc {
  display: flex;
  flex-direction: column;
  background: rgba(16, 28, 44, 0.80);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  overflow: hidden;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.pc--personal {
  flex: 1.65;
  border-color: rgba(255,255,255,0.20);
  background: rgba(22, 36, 52, 0.85);
}
.pc--freemium { flex: 1; }

.pc-top {
  padding: 16px 20px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.pc-badge {
  display: block;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 7px;
}
.pc-name-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.pc-name {
  font-size: 26px;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}
.pc-price {
  font-size: 22px;
  font-weight: 300;
  color: var(--text-primary);
  white-space: nowrap;
}
.pc-price small { font-size: 13px; color: var(--text-muted); }

.pc-rows { display: flex; flex-direction: column; }

.pc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  min-height: 44px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 15px;
}
.pc-row:nth-child(odd) { background: rgba(255,255,255,0.025); }
.pc-row:last-child { border-bottom: none; }
.pc-row--center { justify-content: center; }

.pc-feat { color: var(--text-secondary); font-weight: 300; font-size: 15px; }

.pc-tag {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-primary);
  white-space: nowrap;
}

.pc-check { color: rgba(255,255,255,0.88); font-size: 17px; }
.pc-cross { color: rgba(185,158,70,0.80); font-size: 17px; }

.pc-muted-val {
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: center;
}

.pricing-footnote {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
  text-align: left;
  margin-top: 10px;
  padding: 0 2px;
}

.pricing-actions {
  display: flex;
  gap: 12px;
  margin-top: 22px;
}
.pricing-btn {
  flex: 1;
  padding: 13px 20px;
  border-radius: 50px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.28);
  color: var(--text-primary);
  transition: all var(--transition);
}
.pricing-btn:hover { background: rgba(255,255,255,0.07); border-color: rgba(255,255,255,0.50); }
.pricing-btn--upgrade { flex: 1.65; }
.pricing-btn--continue { flex: 1; }

/* ── Privacy Policy Modal ─────────────────────────────────────────── */
.policy-overlay {
  position: fixed; inset: 0;
  background: rgba(4, 8, 16, 0.88);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 24px 16px;
}
.policy-overlay[hidden] { display: none; }

.policy-box {
  width: 100%; max-width: 720px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  background: rgba(14, 24, 38, 0.96);
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: 8px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  overflow: hidden;
}

.policy-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 32px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.policy-title {
  font-size: 26px;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: 0.02em;
  margin-bottom: 3px;
}
.policy-date {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}
.policy-close {
  background: none; border: none;
  color: var(--text-muted);
  font-size: 26px; line-height: 1;
  cursor: pointer; padding: 2px 6px;
  flex-shrink: 0;
  transition: color var(--transition);
}
.policy-close:hover { color: var(--text-primary); }

.policy-body {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px 36px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.policy-section h3 {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.policy-section p {
  font-size: 16px;
  font-weight: 300;
  color: var(--text-secondary);
  line-height: 1.82;
  margin-bottom: 10px;
}
.policy-section p:last-child { margin-bottom: 0; }
.policy-section ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  padding-left: 4px;
}
.policy-section ul li {
  font-size: 16px;
  font-weight: 300;
  color: var(--text-secondary);
  line-height: 1.72;
  padding-left: 16px;
  position: relative;
}
.policy-section ul li::before {
  content: "–";
  position: absolute; left: 0;
  color: var(--text-muted);
}
.policy-section strong { color: var(--text-primary); font-weight: 500; }
.policy-section a {
  color: rgba(255,255,255,0.60);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color var(--transition);
}
.policy-section a:hover { color: var(--text-secondary); }

.policy-contact {
  margin-top: 6px;
  font-style: normal;
  line-height: 1.9;
}

/* ── Scrollbar ────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .nav-center { gap: 20px; }
  .nav-link-sm { display: none; }
  .topnav { padding: 0 16px; }
  .db-sidebar { width: 200px; min-width: 200px; }
}
@media (max-width: 640px) {
  .db-sidebar { display: none; }
  .btn-login { display: none; }
}
