/* ResearchCrane application stylesheet (W1).
   Extracted verbatim from the former monolithic inline styles of
   index.html, with two changes: the remote Inter/JetBrains Mono web
   fonts were replaced by system font stacks (see :root below), and all
   former inline style= attributes became the named component classes
   appended after the extracted base. This file must satisfy the strict
   CSP: style-src 'self'; style-src-attr 'none'. */

:root {
  /* System font stack (W1): no remote font origins are used. */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --bg: #090d13;
  --card: #111720;
  --card-hover: #161e2a;
  --border: #1e2836;
  --border-focus: #38bdf8;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent: #38bdf8;
  --accent-glow: rgba(56, 189, 248, 0.15);
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --sidebar-w: 280px;
  --drawer-w: 360px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Top Bar */
header {
  height: 52px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.brand .logo {
  background: linear-gradient(135deg, #38bdf8, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-size: 1.15rem;
}
.brand .tag {
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--border);
  color: var(--text-muted);
  font-weight: 500;
}

.top-telemetry {
  display: flex;
  align-items: center;
  gap: 12px;
}
.pill {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
}
.pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}
.pill.token-pill {
  cursor: pointer;
  color: var(--accent);
}
.pill.token-pill:hover {
  background: rgba(56, 189, 248, 0.1);
}

.user-profile-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 10px 3px 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
}
.user-profile-btn:hover {
  background: rgba(56, 189, 248, 0.1);
  border-color: rgba(56, 189, 248, 0.35);
}
.avatar-circle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  overflow: hidden;
  background: #1e293b;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,0.12);
  flex-shrink: 0;
}
.avatar-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.user-name-text {
  font-size: 0.78rem;
  font-weight: 600;
  color: #fff;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Main Container */
.app-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

footer.page-footer {
  min-height: 30px;
  height: auto;
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 16px;
  padding: 6px 12px;
  font-size: 0.72rem;
  color: var(--text-dim);
  letter-spacing: 0.3px;
  z-index: 10;
}
footer.page-footer a {
  color: var(--accent);
  text-decoration: none;
  margin-left: 0;
}
footer.page-footer a:hover,
footer.page-footer a:focus {
  text-decoration: underline;
}
.footer-credit {
  margin: 0;
}

/* Left Sidebar: Sessions */
aside.sidebar {
  width: var(--sidebar-w);
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sidebar-actions {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.btn-new {
  width: 100%;
  background: var(--border);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s;
}
.btn-new:hover {
  background: var(--card-hover);
  border-color: var(--border-focus);
  color: var(--accent);
}
.session-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.session-item {
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  margin-bottom: 4px;
  transition: background 0.15s;
  border: 1px solid transparent;
}
.session-item:hover {
  background: var(--card-hover);
}
.session-item.active {
  background: var(--card-hover);
  border-color: rgba(56, 189, 248, 0.3);
}
.session-title {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.session-meta {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 4px;
  display: flex;
  justify-content: space-between;
}
.sidebar-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  font-size: 0.68rem;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.3;
}

/* Center: Workspace */
main.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--bg);
  position: relative;
}
.workspace-inner {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 32px 100px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Prompt Box */
.prompt-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.2s;
}
.prompt-card:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 1px var(--border-focus), 0 4px 20px rgba(0,0,0,0.3);
}
.prompt-input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  resize: none;
  min-height: 60px;
  outline: none;
  line-height: 1.5;
}
.prompt-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  gap: 12px;
  flex-wrap: wrap;
}
.prompt-options {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 0.8rem;
}
.followup-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.followup-toggle input {
  accent-color: var(--accent);
  cursor: pointer;
}
.depth-selector {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}
.depth-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}
.depth-btn:hover {
  color: var(--text);
}
.depth-btn.active {
  background: var(--card-hover);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.pricing-pill.pricing-warning {
  color: var(--warning);
  background: rgba(251, 191, 36, 0.1);
  border-color: rgba(251, 191, 36, 0.35);
}
.pricing-pill {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--success);
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.25);
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
}
.btn-submit {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-submit:hover { opacity: 0.9; }
.btn-submit:disabled { opacity: 0.4; cursor: not-allowed; }

/* Progress Stepper */
.progress-stepper {
  display: none;
  background: var(--card);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 8px;
  padding: 16px;
  animation: pulse 2s infinite ease-in-out;
}
.stepper-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
}
.spinner-icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(56, 189, 248, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.stepper-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Report Section */
.report-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 32px;
  line-height: 1.7;
  font-size: 0.92rem;
}
.report-card h1 {
  font-size: 1.4rem;
  color: #fff;
  margin: 24px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.report-card h1:first-child { margin-top: 0; }
.report-card h2 { font-size: 1.2rem; color: #fff; margin: 20px 0 10px; }
.report-card h3 { font-size: 1.05rem; color: var(--text-muted); margin: 16px 0 8px; }
.report-card p { margin-bottom: 14px; color: #cbd5e1; }
.report-card ul { margin-left: 20px; margin-bottom: 14px; }
.report-card li { margin-bottom: 6px; }

/* Citation Badges */
.citation {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-block;
  margin: 0 2px;
  text-decoration: none;
}
.citation.source {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}
.citation.source:hover {
  background: rgba(56, 189, 248, 0.25);
}
.citation.knowledge {
  background: rgba(52, 211, 153, 0.15);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.3);
}

/* Right: Evidence Drawer */
aside.drawer {
  width: var(--drawer-w);
  background: var(--card);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.drawer-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.d-tab {
  flex: 1;
  padding: 10px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  color: var(--text-dim);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.d-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: var(--card);
}
.drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}
.source-card, .know-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 10px;
  font-size: 0.8rem;
}
.source-card .s-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}
.source-card .s-id {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 700;
}
.source-card .s-title {
  font-weight: 600;
  color: #fff;
  margin-bottom: 4px;
}
.source-card .s-url {
  font-size: 0.7rem;
  color: var(--text-dim);
  word-break: break-all;
  margin-bottom: 6px;
}
.source-card .s-excerpt {
  font-size: 0.74rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.badge-chip {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  font-family: var(--font-mono);
}
.badge-chip.corroborated {
  background: rgba(52, 211, 153, 0.15);
  color: var(--success);
  border: 1px solid rgba(52, 211, 153, 0.3);
}
.badge-chip.candidate {
  background: rgba(251, 191, 36, 0.15);
  color: var(--warning);
  border: 1px solid rgba(251, 191, 36, 0.3);
}

/* Modal */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.modal-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
.modal-box h3 { margin-bottom: 8px; font-size: 1.1rem; }
.modal-box p { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 16px; line-height: 1.4; }
.modal-input {
  width: 100%;
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  margin-bottom: 16px;
}

/* Mobile Navigation & Off-Canvas Styles */
.mobile-toggle-btn {
  display: none;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.mobile-toggle-btn:hover {
  background: var(--card-hover);
  color: var(--accent);
}
.mobile-drawer-btn {
  display: none;
  cursor: pointer;
  color: var(--accent);
}
.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  top: 52px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(2px);
  z-index: 45;
}
.mobile-overlay.active {
  display: block;
}
.drawer-close-btn {
  display: none;
  position: absolute;
  top: 10px;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
}
.drawer-close-btn:hover {
  color: #fff;
}

/* Tablet & Medium Screens (<= 1024px) */
@media (max-width: 1024px) {
  aside.drawer {
    position: fixed;
    top: 52px;
    bottom: 0;
    right: 0;
    width: 85vw;
    max-width: 380px;
    z-index: 50;
    transform: translateX(100%);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: -6px 0 24px rgba(0,0,0,0.6);
  }
  aside.drawer.open {
    transform: translateX(0);
  }
  .mobile-drawer-btn {
    display: flex;
  }
  .drawer-close-btn {
    display: block;
  }
  .workspace-inner {
    padding: 20px 24px 100px;
  }
}

/* Mobile Phones (<= 768px) */
@media (max-width: 768px) {
  .mobile-toggle-btn {
    display: flex;
  }
  .brand .tag {
    display: none;
  }
  .brand .logo {
    font-size: 0.98rem;
  }
  #kb-pill, #engine-pill {
    display: none;
  }
  header {
    padding: 0 10px;
    gap: 8px;
  }
  .top-telemetry {
    gap: 6px;
  }
  .pill {
    font-size: 0.7rem;
    padding: 3px 8px;
  }
  .user-profile-btn {
    padding: 2px 6px 2px 3px;
  }
  .user-name-text {
    max-width: 65px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.72rem;
  }
  .token-pill span {
    display: none;
  }
  .token-pill::after {
    content: "✕";
    font-size: 0.8rem;
  }

  aside.sidebar {
    position: fixed;
    top: 52px;
    bottom: 0;
    left: 0;
    width: 85vw;
    max-width: 300px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 6px 0 24px rgba(0,0,0,0.6);
  }
  aside.sidebar.open {
    transform: translateX(0);
  }

  .workspace-inner {
    padding: 12px 10px 90px;
    gap: 16px;
  }
  .prompt-card {
    padding: 12px;
    border-radius: 8px;
  }
  .prompt-input {
    font-size: 0.9rem;
    min-height: 50px;
  }
  .prompt-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .prompt-options {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    width: 100%;
  }
  .depth-selector {
    width: 100%;
    display: flex;
  }
  .depth-btn {
    flex: 1;
    text-align: center;
    padding: 6px 4px;
    font-size: 0.72rem;
  }
  .pricing-pill {
    font-size: 0.7rem;
    text-align: center;
  }
  .btn-submit {
    width: 100%;
    padding: 12px;
    font-size: 0.88rem;
    min-height: 44px;
  }

  .report-card {
    padding: 16px 14px;
  }
  .report-card h1 {
    font-size: 1.25rem;
    margin-top: 20px;
  }
  .report-card h2 {
    font-size: 1.05rem;
    margin-top: 16px;
  }
  .report-card p, .report-card li {
    font-size: 0.88rem;
    line-height: 1.55;
  }

  .modal-box {
    padding: 18px 14px;
    max-width: 94vw;
    max-height: 85vh;
    overflow-y: auto;
  }
  footer.page-footer {
    font-size: 0.65rem;
  }
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }

/* ===================================================================
   W1 additions: system fonts, inline-style replacements, component
   classes extracted from the former monolithic inline HTML. Under the
   strict CSP (style-src 'self'; style-src-attr 'none') no element may
   carry a style attribute and script may never touch el.style — every
   dynamic visual state toggles one of these classes instead.
   =================================================================== */

.hidden { display: none !important; }

button { font-family: inherit; color: inherit; }
button.d-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
}

.modal-backdrop.open { display: flex; }
.progress-stepper.open { display: block; }

/* Buttons that were formerly styled divs */
button.pill {
  font-family: var(--font-mono);
  cursor: pointer;
  line-height: 1.4;
}
button.pill.clickable:hover {
  background: rgba(56, 189, 248, 0.1);
  border-color: rgba(56, 189, 248, 0.35);
}
button.pill.logout-pill { color: var(--text-muted); }
.dot.accent { background: #38bdf8; }
.dot.success { background: #34d399; }

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

.avatar-icon { color: #94a3b8; }
.avatar-circle--large {
  width: 52px;
  height: 52px;
  border: 2px solid var(--accent);
  flex-shrink: 0;
}
.avatar-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Sidebar */
.btn-new-plus { font-size: 1.1rem; line-height: 1; }
.list-placeholder {
  font-size: 0.78rem;
  color: var(--text-dim);
  text-align: center;
  padding: 20px;
}

/* Anchoring drawer (URLs & documents) */
.anchoring-details {
  border-top: 1px dashed var(--border);
  padding-top: 8px;
  margin-top: 4px;
}
.anchoring-summary {
  font-size: 0.75rem;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.anchoring-panel {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(0, 0, 0, 0.25);
  padding: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.field-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.url-row {
  display: flex;
  gap: 6px;
}
.url-input {
  margin-bottom: 0;
  font-size: 0.78rem;
}
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.btn-inline { width: auto; }
.btn-inline-compact {
  width: auto;
  font-size: 0.72rem;
  padding: 3px 8px;
}
.btn-accent-outline {
  color: var(--accent);
  border-color: rgba(56, 189, 248, 0.3);
}
.btn-accent-strong {
  color: var(--accent);
  border-color: rgba(56, 189, 248, 0.4);
  font-weight: 600;
}
.btn-indigo-outline {
  color: #818cf8;
  border-color: rgba(129, 140, 248, 0.4);
}
.upload-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.helper-text { font-size: 0.72rem; color: var(--text-dim); }
.privacy-note {
  font-size: 0.7rem;
  color: var(--success);
  display: flex;
  align-items: flex-start;
  gap: 6px;
  background: rgba(52, 211, 153, 0.08);
  padding: 6px 10px;
  border-radius: 4px;
  border: 1px solid rgba(52, 211, 153, 0.2);
  line-height: 1.45;
}
.muted-small { font-size: 0.72rem; color: var(--text-dim); }

/* Chips built in JS (no inline styles) */
.chip-url {
  font-size: 0.7rem;
  gap: 4px;
  border-color: rgba(56, 189, 248, 0.4);
}
.chip-url .chip-label { color: var(--accent); }
.chip-file {
  font-size: 0.7rem;
  gap: 4px;
  border-color: rgba(52, 211, 153, 0.4);
}
.chip-file .chip-label { color: var(--success); }
.chip-remove {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-weight: bold;
  margin-left: 4px;
  font-family: inherit;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0 2px;
}

/* Prompt character counter */
.prompt-counter {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-dim);
  text-align: right;
}
.prompt-counter.near-limit { color: var(--warning); }
.prompt-counter.at-limit { color: var(--danger); }

/* Follow-up option label */
.followup-note { }

/* Stepper */
.stepper-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.step-timer {
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

/* Report */
.report-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 8px;
}
.report-meta {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.badge-template {
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent);
  border: 1px solid rgba(56, 189, 248, 0.3);
  font-weight: 600;
}
.export-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.export-btn {
  width: auto;
  font-size: 0.72rem;
  padding: 4px 8px;
}
.btn-submit-wide {
  width: 100%;
  height: 42px;
}
.btn-submit-lg {
  width: 100%;
  height: 42px;
  font-size: 0.88rem;
}

/* Evidence drawer */
.drawer-header-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border);
  background: #0c1117;
  position: relative;
}
.drawer-portrait {
  width: 80px;
  height: 110px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  background: #000;
}
.drawer-portrait img {
  width: 80px;
  height: 110px;
  object-fit: cover;
  display: block;
}
.drawer-brand-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-top: 6px;
  font-weight: 600;
}
.drawer-placeholder {
  font-size: 0.78rem;
  color: var(--text-dim);
  text-align: center;
  padding: 24px;
}
.drawer-empty-note {
  font-size: 0.75rem;
  color: var(--text-dim);
}
.source-highlight { border-color: var(--accent) !important; }
.know-highlight { border-color: var(--success) !important; }
.know-meta {
  font-size: 0.68rem;
  color: var(--text-dim);
  margin-top: 6px;
}
.audit-metrics {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.8;
  margin-top: 8px;
}
.audit-gaps {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 8px 0 0 16px;
}
.audit-card-spaced { margin-top: 12px; }

/* Modals */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal-header h3 { margin-bottom: 0; }
.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1.3rem;
  line-height: 1;
  font-family: inherit;
}
.modal-close-btn:hover { color: #fff; }
.modal-close-btn--large { font-size: 1.4rem; }
.modal-box--user {
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-box--balance {
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-box--matrix {
  max-width: 680px;
  width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
}

/* Avatar section */
.avatar-section {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  padding: 14px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.avatar-section-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 4px;
}
.avatar-section-btns { display: flex; gap: 8px; }
.avatar-btn {
  width: auto;
  font-size: 0.75rem;
  padding: 4px 10px;
}
.avatar-btn--muted { color: var(--text-dim); }

/* Settings sections */
.settings-section {
  margin-bottom: 20px;
  padding: 14px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.settings-section--spaced { margin-bottom: 18px; }
.settings-section--wallet { margin-bottom: 16px; }
.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.settings-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}
.mono-value {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--accent);
  font-weight: 600;
}
.mono-value--success { color: var(--success); font-weight: 700; }
.mono-total {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 700;
}
.settings-hint {
  margin-top: 10px;
  font-size: 0.72rem;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.settings-note {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-bottom: 10px;
}
.wallet-btn-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.wallet-btn { flex: 1; font-size: 0.75rem; }
.wallet-custom-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}
.wallet-custom-input {
  margin-bottom: 0;
  font-size: 0.78rem;
  flex: 1;
}
.topup-msg { font-size: 0.7rem; margin-top: 6px; }
.topup-msg--pending { color: var(--text-muted); }
.topup-msg--success { color: var(--success); }
.topup-msg--danger { color: var(--danger); }
.topup-msg--warning { color: var(--warning); }
.settings-actions {
  display: flex;
  gap: 8px;
  justify-content: space-between;
}
.btn-danger {
  width: auto;
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.3);
}
.btn-logout-all {
  width: auto;
  font-size: 0.72rem;
  padding: 4px 10px;
  color: var(--warning);
  border-color: rgba(251, 191, 36, 0.4);
}

/* Pro tier card */
.pro-card {
  margin-bottom: 20px;
  padding: 14px;
  background: rgba(56, 189, 248, 0.05);
  border-radius: 8px;
  border: 1px solid rgba(56, 189, 248, 0.25);
}
.pro-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.pro-card-title { font-size: 0.82rem; font-weight: 700; color: #fff; }
.pro-card-price { font-size: 0.7rem; color: var(--text-muted); }
.pro-card-note {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-bottom: 10px;
  line-height: 1.4;
}
.pro-card-actions { display: flex; gap: 8px; }
.pro-btn {
  flex: 1;
  font-size: 0.78rem;
  font-weight: 600;
}
.pro-btn--active { color: var(--success); }
.billing-details {
  font-size: 0.73rem;
  color: var(--text-dim);
  line-height: 1.6;
}
.billing-strong { color: #fff; }

/* Insufficient balance modal */
.balance-heading { margin-bottom: 6px; color: var(--warning); }
.balance-msg {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 16px;
}
.balance-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.balance-row { display: flex; gap: 8px; }
.balance-upgrade-btn {
  flex: 1;
  height: 42px;
  font-weight: 600;
}
.balance-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.balance-footer .btn-inline-compact { font-size: 0.75rem; }
.switch-quick-btn {
  width: auto;
  font-size: 0.75rem;
  color: var(--success);
  border-color: rgba(52, 211, 153, 0.4);
}

/* Onboarding modal */
.onboard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.onboard-brand {
  background: linear-gradient(135deg, #38bdf8, #818cf8);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 700;
  font-size: 1.15rem;
}
.onboard-intro {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 14px;
  line-height: 1.4;
}
.onboard-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.signup-email-input { margin-bottom: 12px; }
.turnstile-slot {
  margin-bottom: 14px;
  min-height: 65px;
  display: flex;
  justify-content: center;
}
.turnstile-fallback-note {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-align: center;
  padding: 12px;
}
.signup-error {
  color: var(--danger);
  font-size: 0.72rem;
  margin-bottom: 10px;
}
.code-sent-msg {
  font-size: 0.8rem;
  color: var(--accent);
  margin-bottom: 10px;
}
.code-input {
  text-align: center;
  letter-spacing: 4px;
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 12px;
}
.resend-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  gap: 8px;
}
.resend-btn {
  width: auto;
  font-size: 0.72rem;
  padding: 4px 10px;
  color: var(--accent);
  border-color: rgba(56, 189, 248, 0.4);
}
.resend-hint { font-size: 0.68rem; color: var(--text-dim); }
.back-btn {
  width: 100%;
  margin-top: 8px;
  font-size: 0.72rem;
}

/* Depth matrix modal */
.matrix-intro { font-size: 0.75rem; color: var(--text-dim); }
.matrix-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 16px;
}
.matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  text-align: left;
}
.matrix-table thead tr {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.matrix-table th {
  padding: 10px 12px;
  font-weight: 600;
}
.matrix-table th.th-muted { color: var(--text-muted); }
.matrix-table th.th-white { color: #fff; }
.matrix-table th.th-accent { color: var(--accent); }
.matrix-table th.th-warning { color: var(--warning); }
.matrix-table th.th-success { color: var(--success); }
.matrix-table tbody tr { border-bottom: 1px solid var(--border); }
.matrix-table tbody tr.row-emphasis { background: rgba(56, 189, 248, 0.03); }
.matrix-table tbody tr.row-total { background: rgba(255, 255, 255, 0.02); border-bottom: none; }
.matrix-table td { padding: 9px 12px; }
.matrix-table td.td-muted { color: var(--text-muted); font-weight: 500; }
.matrix-table td.td-white { color: #fff; font-weight: 600; }
.matrix-table td.td-accent { color: var(--accent); font-weight: 600; }
.matrix-table td.td-warning { color: var(--warning); font-weight: 600; }
.matrix-table td.td-success { color: var(--success); font-weight: 600; }
.matrix-table td.td-total-accent { color: var(--accent); font-weight: 700; }
.matrix-table td.td-total-success { color: var(--success); font-weight: 700; }
.matrix-sub-note { color: var(--text-dim); font-size: 0.7rem; font-weight: 400; }
.matrix-footnote {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-bottom: 14px;
  line-height: 1.4;
}
.matrix-footer { display: flex; justify-content: flex-end; }

/* W2: post-report actions, attachments, follow-up note, session rows */
.post-report-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.post-report-actions .btn-new {
  width: auto;
  flex: 0 1 auto;
  white-space: nowrap;
}
.btn-submit-danger {
  background: linear-gradient(135deg, #b91c1c, #dc2626);
}
.followup-note {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: rgba(56, 189, 248, 0.06);
  border: 1px dashed rgba(56, 189, 248, 0.3);
  border-radius: 4px;
  padding: 6px 10px;
  line-height: 1.4;
}
.anchoring-details.anchoring-disabled {
  opacity: 0.55;
}
.anchoring-details.anchoring-disabled summary {
  pointer-events: none;
}
.session-item-row {
  display: flex;
  align-items: stretch;
  gap: 4px;
}
.session-open-btn {
  flex: 1;
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  cursor: pointer;
  color: inherit;
  font-family: inherit;
}
.session-delete-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 2px 6px;
  align-self: flex-start;
}
.session-delete-btn:hover {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.35);
}
.load-more-btn {
  margin-top: 8px;
  font-size: 0.75rem;
}
.session-attachments {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  font-size: 0.8rem;
}
.attachment-list-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.attachment-retention-note {
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 12px;
}
.attachment-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--border);
  padding: 8px 0;
  flex-wrap: wrap;
}
.attachment-name {
  flex: 1;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 120px;
}
.attachment-expiry {
  font-size: 0.68rem;
  color: var(--text-dim);
  white-space: nowrap;
}
.attachment-delete-btn {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.3);
}
.confirm-secondary {
  font-style: italic;
  color: var(--text-dim);
}

/* W3: Pro depth lock, auto-topup pane */
.depth-btn--locked {
  color: var(--text-dim);
  cursor: not-allowed;
  opacity: 0.75;
}
.depth-btn--locked:hover {
  color: var(--text-dim);
}
.at-prefs {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}
.at-field-label {
  align-self: flex-start;
  margin-bottom: 0;
  white-space: nowrap;
}
.at-consent {
  font-size: 0.68rem;
  color: var(--text-dim);
  line-height: 1.45;
}
.at-warn {
  font-size: 0.72rem;
  color: var(--warning);
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.25);
  border-radius: 4px;
  padding: 6px 10px;
  margin-top: 10px;
  line-height: 1.4;
}

/* Toasts */
.toast-region {
  position: fixed;
  bottom: 44px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  max-width: min(420px, 92vw);
}
.toast {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 0.8rem;
  color: var(--text);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  animation: toast-in 0.18s ease-out;
}
.toast.toast-success { border-left-color: var(--success); }
.toast.toast-warning { border-left-color: var(--warning); }
.toast.toast-danger { border-left-color: var(--danger); }
.toast.toast-exit { opacity: 0; transform: translateY(6px); transition: opacity 0.25s, transform 0.25s; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Expiry warning banner */
.expiry-banner {
  display: none;
  padding: 8px 16px;
  background: rgba(251, 191, 36, 0.12);
  border-bottom: 1px solid rgba(251, 191, 36, 0.35);
  color: var(--warning);
  font-size: 0.75rem;
  text-align: center;
}
.expiry-banner.visible { display: block; }

/* Report content fallback */
.report-placeholder {
  font-size: 0.8rem;
  color: var(--text-dim);
  padding: 8px 0;
}

/* W4 admin Living Brain review */
.modal-box--admin {
  max-width: 920px;
  width: 94vw;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.admin-review-tabs {
  display: flex;
  gap: 8px;
  margin: 8px 0 12px;
  border-bottom: 1px solid var(--border);
}
.admin-review-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 6px 10px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.82rem;
}
.admin-review-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.admin-review-layout {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(280px, 1.4fr);
  gap: 16px;
  min-height: 0;
  flex: 1;
  overflow: hidden;
  width: 100%;
}
.admin-review-list {
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  min-height: 280px;
  max-height: 62vh;
}
.admin-review-detail {
  overflow-y: auto;
  max-height: 62vh;
}
.admin-review-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  cursor: pointer;
  color: var(--text);
}
.admin-review-item:hover { background: var(--card-hover); }
.admin-review-item.active {
  background: var(--accent-glow);
  border-left: 3px solid var(--accent);
}
.admin-review-item-claim {
  font-size: 0.82rem;
  line-height: 1.4;
}
.admin-review-item-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
  font-family: var(--font-mono);
}
.admin-claim-text {
  font-size: 0.92rem;
  line-height: 1.45;
  margin-bottom: 8px;
}
.admin-claim-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.admin-review-panel { min-height: 0; flex: 1; overflow: hidden; display: flex; }
.admin-review-source-list {
  margin: 6px 0 12px 18px;
  font-size: 0.78rem;
}
.admin-review-source { margin-bottom: 10px; }
.admin-review-excerpt {
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--text);
  margin-bottom: 4px;
}
.admin-review-source-list a { color: var(--accent); }
.admin-review-listitem { border-bottom: 1px solid var(--border); }
.admin-review-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.admin-review-reason { width: 100%; min-height: 72px; resize: vertical; }
.admin-review-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}
.admin-review-audit {
  font-size: 0.78rem;
  color: var(--success);
  min-height: 1.2em;
}
@media (max-width: 720px) {
  .admin-review-layout { grid-template-columns: 1fr; }
}

.modal-box--catalog {
  max-width: 1080px;
}
.admin-catalog-panel {
  min-height: 0;
  flex: 1;
  overflow: hidden;
  display: flex;
}
.catalog-check-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 6px 0 12px;
}
.catalog-check {
  font-size: 0.78rem;
  color: var(--text);
}
.catalog-subtitle {
  margin: 16px 0 8px;
  font-size: 0.9rem;
}
.catalog-hint-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}
.catalog-hint-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.catalog-template-body {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

/* W5b: policy links and standalone legal document */
.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 100;
  padding: 8px 12px;
  background: var(--card);
  color: var(--accent);
  border: 1px solid var(--border-focus);
  border-radius: 4px;
}
.skip-link:focus,
.skip-link:focus-visible {
  left: 8px;
  top: 8px;
}
.policy-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: center;
  margin: 8px 0;
}
.policy-links a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.75rem;
}
.policy-links a:hover,
.policy-links a:focus {
  text-decoration: underline;
}
.policy-links a:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}
.policy-links--onboard {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.privacy-note a {
  color: var(--accent);
  margin-left: 4px;
}
#retention-optout-help {
  flex-basis: 100%;
  margin: 0;
}

body.legal-doc {
  display: block;
  height: auto;
  min-height: 100vh;
  overflow: auto;
  background: var(--bg);
  color: var(--text);
}
.legal-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.legal-brand {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.4px;
}
.legal-brand a {
  color: var(--accent);
  text-decoration: none;
}
.legal-wrap {
  max-width: 46rem;
  margin: 0 auto;
  padding: 24px 20px 64px;
  line-height: 1.55;
}
.legal-wrap h1 {
  font-size: 1.45rem;
  margin: 0 0 12px;
}
.legal-wrap h2 {
  font-size: 1.2rem;
  margin: 2em 0 0.6em;
}
.legal-wrap h3 {
  font-size: 1rem;
  margin: 1.4em 0 0.4em;
  color: var(--text-muted);
}
.legal-wrap p,
.legal-wrap ul {
  margin: 0 0 0.85em;
  color: var(--text);
  font-size: 0.92rem;
}
.legal-wrap ul {
  padding-left: 1.2em;
}
.legal-wrap a {
  color: var(--accent);
}
.legal-wrap article {
  border-top: 1px solid var(--border);
  padding-top: 0.5rem;
  margin-top: 1.5rem;
}
