/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   Termnova — Enterprise Legal Intelligence Workbench Design System
   Crafted with Plus Jakarta Sans, Obsidian Slate tones & Clean Accents
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

:root {
  /* ── Obsidian Palette ── */
  --bg-canvas: #090B0E;
  --bg-sidebar: #0E1217;
  --bg-surface: #12161F;
  --bg-card: #151A24;
  --bg-card-hover: #1A212E;
  --bg-elevated: #202738;
  --bg-active: #242D3D;

  /* ── Borders & Hairlines ── */
  --border-hairline: rgba(255, 255, 255, 0.07);
  --border-subtle: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.20);
  --border-focus: #3B82F6;

  /* ── Brand & Action Accents ── */
  --brand-blue: #2563EB;
  --brand-blue-hover: #1D4ED8;
  --brand-blue-subtle: rgba(37, 99, 235, 0.12);
  --brand-blue-border: rgba(37, 99, 235, 0.28);
  --accent-gradient: linear-gradient(135deg, #3B82F6 0%, #1D4ED8 100%);

  /* ── Typography & Text ── */
  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --text-subtle: #475569;

  /* ── Status Indicators ── */
  --color-success: #10B981;
  --color-success-bg: rgba(16, 185, 129, 0.10);
  --color-success-border: rgba(16, 185, 129, 0.24);

  --color-warning: #F59E0B;
  --color-warning-bg: rgba(245, 158, 11, 0.10);
  --color-warning-border: rgba(245, 158, 11, 0.24);

  --color-error: #EF4444;
  --color-error-bg: rgba(239, 68, 68, 0.10);
  --color-error-border: rgba(239, 68, 68, 0.24);

  --color-purple: #8B5CF6;
  --color-purple-bg: rgba(139, 92, 246, 0.10);

  /* ── Geometry & Motion ── */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --transition-fast: 140ms ease;
  --transition-smooth: 220ms cubic-bezier(0.16, 1, 0.3, 1);

  /* ── Fonts ── */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* Screen reader & crawler accessibility utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ──── Base Reset ──── */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ──── App Layout ──── */
.app-layout {
  display: grid;
  grid-template-columns: 270px 1fr;
  height: 100vh;
  width: 100vw;
  position: relative;
  overflow: hidden;
}

/* ──── Sidebar ──── */
.sidebar {
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-hairline);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  z-index: 10;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 6px 18px 6px;
  border-bottom: 1px solid var(--border-hairline);
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.25), 0 0 15px rgba(6, 182, 212, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-info {
  display: flex;
  flex-direction: column;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-title-row h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
}

.brand-title-row h1 span {
  color: var(--brand-blue);
}

.version-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  background: var(--bg-card);
  border: 1px solid var(--border-hairline);
  color: var(--text-secondary);
  letter-spacing: 0.04em;
}

.brand-tagline {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-top: 1px;
}

.nav-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  padding: 18px 8px 6px 8px;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
  position: relative;
}

.nav-item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-hairline);
}

.nav-item.active {
  background: var(--brand-blue-subtle);
  border-color: var(--brand-blue-border);
  color: #fff;
  font-weight: 600;
}

.nav-icon {
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

.nav-item.active .nav-icon {
  color: var(--brand-blue);
}

.doc-count-pill {
  margin-left: auto;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  font-weight: 600;
  background: var(--bg-card);
  border: 1px solid var(--border-hairline);
  padding: 2px 7px;
  border-radius: 10px;
  color: var(--text-secondary);
}

.nav-item.active .doc-count-pill {
  background: var(--brand-blue);
  color: #fff;
  border-color: transparent;
}

/* ──── Sidebar Vault Quick-List ──── */
.sidebar-vault-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 4px;
}

.vault-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.vault-item:hover {
  background: var(--bg-card);
}

.vault-item-name {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.type-tag {
  font-size: 0.62rem;
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 2px 5px;
  border-radius: var(--radius-xs);
  letter-spacing: 0.04em;
}

.tag-msa { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.tag-sow { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.tag-nda { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.tag-vendor { background: rgba(139, 92, 246, 0.15); color: #a78bfa; }
.tag-lease { background: rgba(236, 72, 153, 0.15); color: #f472b6; }
.tag-license { background: rgba(14, 165, 233, 0.15); color: #38bdf8; }
.tag-service { background: rgba(20, 184, 166, 0.15); color: #2dd4bf; }
.tag-distributor { background: rgba(249, 115, 22, 0.15); color: #fb923c; }
.tag-partnership { background: rgba(168, 85, 247, 0.15); color: #c084fc; }
.tag-commercial { background: rgba(100, 116, 139, 0.15); color: #94a3b8; }

/* ──── Sidebar Footer ──── */
.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border-hairline);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.system-status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-xs);
  font-size: 0.75rem;
}

.status-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.status-indicator.online {
  background-color: var(--color-success);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

.status-text {
  color: var(--text-secondary);
  font-weight: 500;
}

.author-credits {
  display: flex;
  flex-direction: column;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.author-credits strong {
  color: var(--text-secondary);
}

.version-tag {
  font-size: 0.68rem;
  color: var(--text-subtle);
  margin-top: 2px;
}

/* ──── Main Content Viewport ──── */
.main-content {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background-color: var(--bg-canvas);
  position: relative;
  overflow: hidden;
}

/* ──── Top Header Bar ──── */
.top-header {
  height: 60px;
  min-height: 60px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-hairline);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 5;
}

.header-left {
  display: flex;
  flex-direction: column;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

.breadcrumb-sep {
  color: var(--text-subtle);
}

.breadcrumb-item.active {
  color: var(--text-secondary);
}

.header-left h2 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

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

.scope-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-hairline);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.engine-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-hairline);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.engine-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand-blue);
}

/* ──── View Panels ──── */
.view-panel {
  display: none;
  flex: 1;
  overflow-y: auto;
}

.view-panel.active {
  display: flex;
  flex-direction: column;
}

/* ──── VIEW 1: CHAT STUDIO ──── */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 60px);
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

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

/* ──── Studio Welcome Deck ──── */
.welcome-card {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin: auto 0;
  padding: 10px 0;
}

.studio-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.studio-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  background: var(--brand-blue-subtle);
  border: 1px solid var(--brand-blue-border);
  color: #60a5fa;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  width: fit-content;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #60a5fa;
}

.studio-header h3 {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #fff;
}

.studio-header p {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 820px;
}

/* Studio Metrics Strip */
.studio-metrics-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 6px 0;
}

.metric-chip {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: border-color var(--transition-fast);
}

.metric-chip:hover {
  border-color: var(--border-subtle);
}

.metric-num {
  font-size: 1.15rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.metric-lbl {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.text-success {
  color: var(--color-success) !important;
}

/* Studio Deck 2x2 Grid */
.studio-deck-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.deck-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.deck-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.deck-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
}

.deck-card:hover {
  background: var(--bg-card);
  border-color: var(--border-subtle);
  transform: translateY(-1px);
}

.deck-card-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.icon-blue { background: rgba(59, 130, 246, 0.12); color: #60a5fa; }
.icon-emerald { background: rgba(16, 185, 129, 0.12); color: #34d399; }
.icon-amber { background: rgba(245, 158, 11, 0.12); color: #fbbf24; }
.icon-purple { background: rgba(139, 92, 246, 0.12); color: #a78bfa; }

.deck-card-content h4 {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.deck-card-content p {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* ──── Chat Messages ──── */
.message-row {
  display: flex;
  gap: 14px;
  width: 100%;
  animation: fadeIn 180ms ease forwards;
}

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

.message-row.user {
  flex-direction: row-reverse;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.8rem;
}

.message-row.user .message-avatar {
  background: var(--brand-blue);
  color: #fff;
}

.message-row.assistant .message-avatar {
  background: var(--bg-card);
  border: 1px solid var(--border-hairline);
  color: #60a5fa;
}

.message-content {
  max-width: 82%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message-row.user .message-content {
  align-items: flex-end;
}

.message-bubble {
  padding: 16px 18px;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  line-height: 1.6;
}

.message-row.user .message-bubble {
  background: var(--brand-blue);
  color: #fff;
  border-radius: var(--radius-md) var(--radius-md) var(--radius-xs) var(--radius-md);
}

.message-row.assistant .message-bubble {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  color: var(--text-primary);
  border-radius: var(--radius-md) var(--radius-md) var(--radius-md) var(--radius-xs);
}

.message-bubble strong {
  color: #fff;
  font-weight: 700;
}

.message-bubble ul, .message-bubble ol {
  margin: 10px 0 10px 20px;
}

.message-bubble li {
  margin-bottom: 4px;
}

/* ──── Citations & Interactive Chips ──── */
.citation-badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 7px;
  margin: 0 3px;
  background: var(--brand-blue-subtle);
  border: 1px solid var(--brand-blue-border);
  color: #93c5fd;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.citation-badge:hover {
  background: var(--brand-blue);
  color: #fff;
}

.citations-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-hairline);
}

.citation-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-xs);
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.citation-card:hover {
  border-color: var(--brand-blue);
  color: #fff;
}

.badge-subtle {
  background: var(--bg-canvas);
  border: 1px solid var(--border-hairline);
  color: var(--text-muted);
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
}

/* ──── Audit Meta Row ──── */
.audit-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.audit-tag {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  background: var(--bg-canvas);
  border: 1px solid var(--border-hairline);
  color: var(--text-muted);
}

.audit-tag.success {
  color: var(--color-success);
  border-color: var(--color-success-border);
}

.audit-tag.warning {
  color: var(--color-warning);
  border-color: var(--color-warning-border);
}

/* ──── Chat Command Input Bar ──── */
.chat-input-wrapper {
  padding: 16px 24px 20px 24px;
  background: transparent;
}

.chat-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-container {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
  transition: border-color var(--transition-fast);
}

.input-container:focus-within {
  border-color: var(--border-focus);
}

#query-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  line-height: 1.5;
  resize: none;
  outline: none;
  max-height: 140px;
}

#query-input::placeholder {
  color: var(--text-muted);
}

.input-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-hairline);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 0.86rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  white-space: nowrap;
}

.btn-primary {
  background: var(--brand-blue);
  color: #fff;
}

.btn-primary:hover {
  background: var(--brand-blue-hover);
}

.key-hint {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  padding: 2px 5px;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.btn-secondary {
  background: var(--bg-card);
  border-color: var(--border-hairline);
  color: var(--text-secondary);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.78rem;
}

.btn-link {
  background: transparent;
  border: none;
  color: var(--brand-blue);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

.input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 0 4px;
}

.input-footer strong {
  color: var(--text-secondary);
}

/* ──── VIEW 2: CLAUSE COMPARISON ──── */
.compare-container {
  padding: 24px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.glass-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
  padding: 20px;
}

.card-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
}

.card-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
}

.card-header p {
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.selector-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 16px;
  align-items: flex-end;
}

.select-wrapper,
.select-action {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  justify-content: flex-end;
}

.select-wrapper label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.custom-select {
  background: var(--bg-card);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-xs);
  color: var(--text-primary);
  padding: 10px 14px;
  font-family: var(--font-sans);
  font-size: 0.86rem;
  outline: none;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.custom-select:focus {
  border-color: var(--border-focus);
}

/* Comparison KPI grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.kpi-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kpi-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.kpi-value {
  font-size: 1.5rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.key-diffs-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.key-diffs-list li {
  padding: 8px 12px;
  border-radius: var(--radius-xs);
  background: var(--bg-card);
  border-left: 3px solid var(--color-warning);
  font-size: 0.84rem;
  color: var(--text-primary);
}

.alignments-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.alignment-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.alignment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-hairline);
}

.alignment-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #fff;
}

.diff-ins {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
  text-decoration: none;
  padding: 1px 3px;
  border-radius: 2px;
}

.diff-del {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  text-decoration: line-through;
  padding: 1px 3px;
  border-radius: 2px;
}

/* ──── VIEW 3: DOCUMENTS REPOSITORY ──── */
.documents-container {
  padding: 24px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.drop-zone {
  border: 2px dashed var(--border-hairline);
  border-radius: var(--radius-md);
  padding: 32px 20px;
  text-align: center;
  background: var(--bg-card);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--brand-blue);
  background: var(--brand-blue-subtle);
}

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

.upload-icon-pulse {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-blue);
}

.drop-zone h4 {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
}

.drop-zone p {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.format-pills {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.format-pills .badge {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  color: var(--text-muted);
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.table-responsive {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.data-table th {
  text-align: left;
  padding: 10px 14px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-hairline);
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-hairline);
  color: var(--text-secondary);
}

.data-table tr:hover td {
  background: var(--bg-card);
  color: var(--text-primary);
}

.text-right {
  text-align: right;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 24px !important;
}

/* ──── VIEW 4: ANALYTICS ──── */
.analytics-container {
  padding: 24px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kpi-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.trend-positive {
  color: var(--color-success);
  font-weight: 600;
}

.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.chart-wrapper {
  height: 220px;
  position: relative;
}

/* ──── Source Inspector Drawer ──── */
.source-drawer {
  position: fixed;
  top: 0;
  right: -420px;
  width: 400px;
  height: 100vh;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border-hairline);
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: right var(--transition-smooth);
}

.source-drawer.open {
  right: 0;
}

.drawer-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-hairline);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drawer-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.drawer-title h3 {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
}

.drawer-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.source-metadata-box {
  background: var(--bg-card);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-xs);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
}

.meta-label {
  color: var(--text-muted);
}

.meta-val {
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-weight: 600;
}

.source-excerpt-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.source-excerpt-box label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.excerpt-content {
  background: var(--bg-card);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-xs);
  padding: 14px;
  font-size: 0.82rem;
  font-family: var(--font-mono);
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

/* ──── Toast Hub ──── */
.toast-hub {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-xs);
  padding: 10px 16px;
  font-size: 0.84rem;
  color: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  animation: slideIn 180ms ease forwards;
}

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

.toast.info { border-left: 3px solid var(--brand-blue); }
.toast.success { border-left: 3px solid var(--color-success); }
.toast.error { border-left: 3px solid var(--color-error); }

/* ──── Sidebar Legal Links ──── */
.sidebar-legal-links {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.legal-badge-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-hairline);
  color: var(--text-muted);
  font-size: 0.68rem;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.legal-badge-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: var(--border-subtle);
}

.legal-sub-links {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.legal-link-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.68rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  transition: color var(--transition-fast);
}

.legal-link-btn:hover {
  color: var(--brand-blue-light);
}

.dot-sep {
  opacity: 0.4;
}

/* ──── Protected browser session ──── */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 24, 21, 0.96);
  backdrop-filter: blur(12px);
}

.auth-card {
  width: min(100%, 430px);
  padding: 34px;
  background: #f5f1e7;
  color: #17231f;
  border: 1px solid rgba(23, 35, 31, 0.2);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

.auth-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin-bottom: 24px;
  background: #17231f;
  color: #f2c319;
  font: 700 18px/1 var(--font-mono);
}

.auth-kicker,
.auth-field span {
  color: #58635f;
  font: 600 0.68rem/1.2 var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.auth-card h1 {
  margin: 8px 0 10px;
  color: #17231f;
  font: 600 2rem/1.05 var(--font-display);
}

.auth-copy,
.auth-note {
  color: #58635f;
  line-height: 1.55;
}

.auth-field {
  display: grid;
  gap: 8px;
  margin-top: 24px;
}

.auth-field input {
  width: 100%;
  padding: 12px 13px;
  color: #17231f;
  background: #fffdf7;
  border: 1px solid #aeb5b1;
  border-radius: 2px;
  font-family: var(--font-mono);
}

.auth-field input:focus {
  outline: 3px solid rgba(242, 195, 25, 0.35);
  border-color: #8b7000;
}

.auth-error {
  min-height: 20px;
  margin: 9px 0 0;
  color: #b42318;
  font-size: 0.8rem;
}

.auth-submit {
  width: 100%;
  margin-top: 8px;
}

.auth-note {
  margin: 14px 0 0;
  font-size: 0.72rem;
}

.desk-lock-button {
  width: 100%;
  margin: 8px 0;
  padding: 7px 9px;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border-hairline);
  cursor: pointer;
  font: 500 0.68rem/1 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.desk-lock-button:hover {
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

/* ──── Legal Modals ──── */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 150ms ease forwards;
}

.modal-box {
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-hairline);
}

.modal-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-title-row h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--text-secondary);
}

.modal-body p {
  margin-bottom: 12px;
}

.modal-body p strong {
  color: #fff;
}

.legal-alert-box {
  background: rgba(245, 158, 11, 0.12);
  border-left: 3px solid #f59e0b;
  padding: 12px 14px;
  border-radius: var(--radius-xs);
  color: #fbbf24;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-hairline);
  display: flex;
  justify-content: flex-end;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   MOBILE RESPONSIVENESS & OFF-CANVAS NAVIGATION DESIGN SYSTEM
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

/* Mobile Backdrop Overlay */
.mobile-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 998;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-smooth);
}

.mobile-backdrop.open {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

/* Mobile Top App Bar (Hidden on desktop) */
.mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 14px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-hairline);
  flex-shrink: 0;
  z-index: 50;
}

.mobile-menu-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.mobile-menu-btn:hover,
.mobile-menu-btn:active {
  background: var(--brand-blue-subtle);
  border-color: var(--brand-blue);
  color: #fff;
}

.mobile-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mobile-logo-box {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.mobile-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mobile-brand-title {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
}

.mobile-brand-title span {
  color: #3b82f6;
}

.mobile-view-pill {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 9px;
  border-radius: 12px;
  background: var(--brand-blue-subtle);
  border: 1px solid var(--brand-blue-border);
  color: #60a5fa;
}

/* ──── Responsive Breakpoints ──── */

/* Tablet & Mobile (<= 1024px) */
@media screen and (max-width: 1024px) {
  body {
    height: 100%;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .app-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
  }

  .mobile-header {
    display: flex;
  }

  /* Off-canvas sidebar */
  .sidebar {
    position: fixed;
    top: 0;
    left: -300px;
    width: 280px;
    height: 100vh;
    height: 100dvh;
    z-index: 999;
    background: #0d1117;
    border-right: 1px solid var(--border-subtle);
    box-shadow: 6px 0 32px rgba(0, 0, 0, 0.7);
    transition: left var(--transition-smooth);
    overflow-y: auto;
  }

  .sidebar.open {
    left: 0;
  }

  .main-content {
    flex: 1;
    width: 100vw;
    height: calc(100vh - 56px);
    height: calc(100dvh - 56px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .top-header {
    padding: 10px 14px;
    height: auto;
    min-height: 52px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .top-header .engine-badge {
    display: none;
  }

  .top-header .scope-pill {
    padding: 3px 8px;
    font-size: 0.72rem;
  }

  #view-title {
    font-size: 1.05rem;
  }

  .breadcrumbs {
    font-size: 0.72rem;
    margin-bottom: 2px;
  }

  /* Citation Drawer */
  .citation-drawer {
    width: 100vw;
    max-width: 100vw;
    right: -100vw;
  }

  .citation-drawer.open {
    right: 0;
  }
}

/* Small Tablets & Large Phones (<= 768px) */
@media screen and (max-width: 768px) {
  /* Studio Chat */
  .chat-container {
    padding: 8px 8px 0 8px;
    height: 100%;
  }

  .welcome-card {
    padding: 16px 14px;
    margin-bottom: 12px;
  }

  .studio-header h3 {
    font-size: 1.25rem;
  }

  .studio-header p {
    font-size: 0.85rem;
  }

  .studio-metrics-strip {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin: 14px 0;
  }

  .metric-chip {
    padding: 8px 10px;
  }

  .deck-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .deck-card {
    padding: 12px 14px;
  }

  .chat-bubble {
    max-width: 95%;
    padding: 12px 14px;
    font-size: 0.88rem;
  }

  .chat-input-wrapper {
    padding: 10px 8px;
  }

  .chat-input-controls {
    flex-wrap: wrap;
    gap: 6px;
  }

  .input-controls-left {
    flex-wrap: wrap;
    gap: 6px;
  }

  /* Compare / Diff View */
  .compare-container {
    padding: 10px;
    overflow-y: auto;
  }

  .selector-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .select-action {
    margin-top: 4px;
  }

  .select-action .btn {
    width: 100%;
    justify-content: center;
  }

  .compare-kpis {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .alignments-grid {
    grid-template-columns: 1fr;
  }

  .clause-diff-split {
    grid-template-columns: 1fr;
  }

  /* Document Vault */
  .documents-container {
    padding: 10px;
    overflow-y: auto;
  }

  .drop-zone {
    padding: 24px 14px;
  }

  .docs-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Analytics & Observability */
  .analytics-container {
    padding: 10px;
    overflow-y: auto;
  }

  .analytics-kpis-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .analytics-charts-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Modals */
  .modal-content {
    width: 94vw;
    max-width: 96vw;
    margin: 12px auto;
    max-height: 90vh;
  }
}

/* Mobile Phones (<= 480px) */
@media screen and (max-width: 480px) {
  .top-header {
    padding: 8px 10px;
  }

  .header-actions {
    gap: 6px;
  }

  #view-title {
    font-size: 0.95rem;
  }

  .studio-metrics-strip {
    grid-template-columns: 1fr 1fr;
  }

  .chat-input-box {
    padding: 8px 10px;
  }

  .chat-input-box textarea {
    font-size: 0.88rem;
  }

  .btn-send {
    padding: 7px 14px;
    font-size: 0.8rem;
  }

  .modal-header {
    padding: 12px 14px;
  }

  .modal-body {
    padding: 14px;
    font-size: 0.82rem;
  }

  .modal-footer {
    padding: 10px 14px;
  }
}
