/* ================================================================
   CFS / aMemories Universal High-Contrast Dark Theme
   Fixes illegible font colors, low-contrast cards, and KB styling
   ================================================================ */

:root {
  --bg: #080d18;
  --surface: #0f172a;
  --surface-card: #111b30;
  --surface-card-kb: #131f37;
  --surface-border: #1e2e4a;
  --surface-border-bright: #2d436a;
  --text-main: #f1f5f9;
  --text-body: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --green: #10a37f;
  --green-bright: #34d399;
  --cyan: #38bdf8;
  --cyan-bright: #7dd3fc;
  --orange: #fb923c;
  --purple: #c084fc;
  --red: #f87171;
}

body {
  background: #080d18 !important;
  color: #f1f5f9 !important;
}

.wrap, .page-container {
  max-width: 1200px !important;
}

h1 {
  color: #ffffff !important;
  font-weight: 800 !important;
  letter-spacing: -0.02em !important;
}

.lede {
  color: #cbd5e1 !important;
  font-size: 15px !important;
  line-height: 1.6 !important;
}
.lede b {
  color: #ffffff !important;
}
.lede a {
  color: #38bdf8 !important;
}

/* Base Cards */
.card {
  background: linear-gradient(180deg, #111b30 0%, #0d1527 100%) !important;
  border: 1px solid #1e2e4a !important;
  color: #f1f5f9 !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45) !important;
  border-radius: 14px !important;
}

/* Controls & Form Elements */
label {
  color: #e2e8f0 !important;
  font-size: 13.5px !important;
  font-weight: 600 !important;
}
.val {
  color: #34d399 !important;
  font-weight: 700 !important;
}
input[type=range] {
  accent-color: #34d399 !important;
  background: #1e2e4a !important;
}
select, input[type=number], input[type=text] {
  background: #141f35 !important;
  color: #ffffff !important;
  border: 1px solid #2a3d60 !important;
  border-radius: 6px !important;
}
.presets {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.preset {
  background: #141f35 !important;
  color: #cbd5e1 !important;
  border: 1px solid #243552 !important;
  font-weight: 500 !important;
  transition: all 0.15s ease !important;
}
.preset:hover {
  border-color: #38bdf8 !important;
  color: #38bdf8 !important;
  background: rgba(56, 189, 248, 0.12) !important;
}
button.run {
  background: linear-gradient(135deg, #10a37f 0%, #059669 100%) !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  border: 0 !important;
  border-radius: 8px !important;
  box-shadow: 0 4px 16px rgba(16, 163, 127, 0.35) !important;
  transition: all 0.2s ease !important;
}
button.run:hover:not(:disabled) {
  background: linear-gradient(135deg, #34d399 0%, #10a37f 100%) !important;
  box-shadow: 0 4px 24px rgba(52, 211, 153, 0.45) !important;
}

/* Visualization Panel */
.viz {
  background: #090e1a !important;
  border: 1px solid #1c2b45 !important;
  border-radius: 10px !important;
}
.vizcap {
  color: #94a3b8 !important;
  font-size: 13px !important;
  line-height: 1.55 !important;
}
.vizcap b {
  color: #f1f5f9 !important;
}

/* Metrics Table */
table#metrics {
  width: 100%;
  border-collapse: collapse;
}
#metrics th {
  color: #94a3b8 !important;
  border-bottom: 1px solid #1e2e4a !important;
  font-size: 12.5px !important;
  font-weight: 600 !important;
}
#metrics td {
  color: #e2e8f0 !important;
  border-bottom: 1px solid #1a273f !important;
  font-size: 13.5px !important;
}
#metrics td.num {
  color: #ffffff !important;
  font-weight: 700 !important;
  font-family: ui-monospace, Menlo, monospace !important;
}
.verdict {
  background: rgba(16, 163, 127, 0.12) !important;
  border: 1px solid rgba(52, 211, 153, 0.35) !important;
  color: #34d399 !important;
  border-radius: 8px !important;
}
.node {
  color: #94a3b8 !important;
  font-size: 13px !important;
}
.node b {
  color: #34d399 !important;
}

/* ================================================================
   KNOWLEDGE BASE CARD: HIGH-CONTRAST READABILITY UPGRADE
   Addresses: web user barely can see
   ================================================================ */
.card.kb, #kb.card {
  background: linear-gradient(180deg, #131f37 0%, #0e172a 100%) !important;
  border: 1px solid #253959 !important;
  border-left: 4px solid #38bdf8 !important;
  border-radius: 14px !important;
  padding: 26px 30px !important;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5) !important;
  margin-top: 26px !important;
}

.card.kb h2, #kb h2 {
  color: #ffffff !important;
  font-size: 21px !important;
  font-weight: 800 !important;
  letter-spacing: -0.015em !important;
  margin: 0 0 6px 0 !important;
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
}

.card.kb .src, #kb .src {
  color: #94a3b8 !important;
  font-size: 13.5px !important;
  margin: 0 0 22px 0 !important;
}
.card.kb .src a, #kb .src a {
  color: #38bdf8 !important;
  font-weight: 600 !important;
  text-decoration: underline !important;
}
.card.kb .src a:hover, #kb .src a:hover {
  color: #7dd3fc !important;
}

/* High Contrast Knowledge Base Body */
.kb-body {
  font-size: 15px !important;
  line-height: 1.8 !important;
  color: #e2e8f0 !important; /* Bright readable slate */
}
.kb-body p {
  color: #e2e8f0 !important;
  font-size: 15px !important;
  line-height: 1.8 !important;
  margin: 0 0 16px 0 !important;
}
.kb-body ul, .kb-body ol {
  color: #e2e8f0 !important;
  margin: 0 0 18px 0 !important;
  padding-left: 24px !important;
}
.kb-body li {
  color: #e2e8f0 !important;
  font-size: 15px !important;
  line-height: 1.75 !important;
  margin: 8px 0 !important;
}

/* Bold Headings & Definitions */
.kb-body b, .kb-body strong {
  color: #ffffff !important;
  font-weight: 700 !important;
}
/* Key definition labels in list items and leading paragraph labels */
.kb-body li > b:first-child,
.kb-body p > b:first-child {
  color: #38bdf8 !important; /* Radiant Cyan */
  font-weight: 750 !important;
}
.kb-body h1, .kb-body h2, .kb-body h3, .kb-body h4 {
  color: #ffffff !important;
  font-weight: 800 !important;
  letter-spacing: -0.01em !important;
  margin: 26px 0 12px 0 !important;
}
.kb-body a {
  color: #38bdf8 !important;
  text-decoration: underline !important;
}
.kb-body a:hover {
  color: #7dd3fc !important;
}
.kb-body code {
  background: #17243c !important;
  color: #38bdf8 !important;
  padding: 3px 8px !important;
  border-radius: 5px !important;
  font-size: 13.5px !important;
  border: 1px solid #263c63 !important;
  font-family: ui-monospace, Menlo, monospace !important;
}
.kb-body pre {
  background: #090e1a !important;
  color: #e2e8f0 !important;
  padding: 16px !important;
  border-radius: 8px !important;
  border: 1px solid #1c2b45 !important;
  overflow-x: auto !important;
}

/* Dark Theme Tables inside Knowledge Base */
.kb-body .kb-tablewrap {
  border: 1px solid #223552 !important;
  border-radius: 10px !important;
  background: #0c1424 !important;
  margin: 22px 0 !important;
  overflow-x: auto !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3) !important;
}
.kb-body table.kb-table {
  background: #0c1424 !important;
  color: #e2e8f0 !important;
  width: 100% !important;
  border-collapse: collapse !important;
}
.kb-body table.kb-table th {
  background: #142138 !important;
  color: #f8fafc !important;
  border-bottom: 1px solid #223552 !important;
  border-right: 1px solid #223552 !important;
  font-weight: 700 !important;
  font-size: 13px !important;
  padding: 11px 16px !important;
}
.kb-body table.kb-table td {
  border-bottom: 1px solid #1a2940 !important;
  border-right: 1px solid #1a2940 !important;
  color: #cbd5e1 !important;
  font-size: 13.5px !important;
  padding: 10px 16px !important;
}
.kb-body table.kb-table tbody tr:nth-child(even) td {
  background: #0f192c !important;
}
.kb-body table.kb-table tbody tr:hover td {
  background: #172744 !important;
}
.kb-body mjx-container {
  color: #f1f5f9 !important;
}

/* Flowchart / Diagram Nodes in KB */
.kb-body .cfs-node.neutral { background: #172238 !important; border-color: #2c3f62 !important; color: #f1f5f9 !important; }
.kb-body .cfs-node.green   { background: #0c2a21 !important; border-color: #1a5640 !important; color: #d6f0e2 !important; }
.kb-body .cfs-node.blue    { background: #102d4d !important; border-color: #1e5287 !important; color: #d7e6f7 !important; }
.kb-body .cfs-node.orange  { background: #3a1c12 !important; border-color: #6e2f1b !important; color: #f3d8ca !important; }
.kb-body .cfs-node-title   { font-weight: 700 !important; color: #ffffff !important; }
.kb-body .cfs-node-sub     { color: #cbd5e1 !important; opacity: 1 !important; }

/* Developer API Box */
.api {
  background: #0c1424 !important;
  border: 1px solid #1e2e4a !important;
  border-radius: 12px !important;
  padding: 22px 24px !important;
  color: #cbd5e1 !important;
  margin-top: 32px !important;
}
.api b {
  color: #ffffff !important;
}
.api code, .api pre {
  background: #080d18 !important;
  color: #e2e8f0 !important;
  border: 1px solid #1e2e4a !important;
}
