/* ============================================================
   Bicameral Mind — Design System
   Dark, calm, Material Design 3 language.
   "An archive at deep night."
   ============================================================ */

/* ---------- Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Newsreader:ital,opsz,wght@0,6..72,300..600;1,6..72,300..500&family=Hanken+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@20..48,300,0..1,0&display=swap');

/* ---------- Tokens ---------- */
:root {
  /* base surfaces (deep slate-indigo, not pure black) */
  --bg:          #0a0d13;
  --surface-1:   #0f131b;
  --surface-2:   #141924;
  --surface-3:   #1b2130;
  --surface-4:   #232b3c;
  --hover:       rgba(142, 155, 240, 0.06);
  --hover-strong:rgba(142, 155, 240, 0.10);

  /* lines */
  --border:      #222a3a;
  --border-soft: #1a2130;
  --border-hi:   #303b52;

  /* text */
  --text-hi:     #eef1f8;
  --text:        #b9c1d2;
  --text-lo:     #7c8598;
  --text-faint:  #5a6478;

  /* brand duality */
  --primary:     #8e9bf0;   /* cool indigo — interface / structure */
  --primary-hi:  #a9b3f6;
  --primary-dim: #5c68b8;
  --primary-wash:rgba(142, 155, 240, 0.12);
  --primary-line:rgba(142, 155, 240, 0.28);

  --gold:        #e3b476;   /* warm amber — knowledge / relevance */
  --gold-wash:   rgba(227, 180, 118, 0.12);
  --gold-line:   rgba(227, 180, 118, 0.30);

  /* status */
  --success:     #5fb88e;
  --success-wash:rgba(95, 184, 142, 0.12);
  --warning:     #e0a458;
  --warning-wash:rgba(224, 164, 88, 0.12);
  --danger:      #e0685e;
  --danger-wash: rgba(224, 104, 94, 0.12);

  /* type */
  --serif: "Newsreader", Georgia, serif;
  --sans:  "Hanken Grotesk", system-ui, -apple-system, sans-serif;
  --mono:  "JetBrains Mono", ui-monospace, monospace;

  /* geometry */
  --r-sm: 8px;
  --r:    12px;
  --r-lg: 16px;
  --r-xl: 22px;

  --sidebar-w: 256px;
  --topbar-h:  64px;

  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 8px 24px -12px rgba(0,0,0,.7);
  --shadow-3: 0 24px 60px -24px rgba(0,0,0,.8);

  --ease: cubic-bezier(.2,.7,.2,1);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
::selection { background: var(--primary-wash); color: var(--text-hi); }

/* subtle app-wide scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--surface-4) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 20px; border: 3px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--surface-4); }

/* ---------- Icons ---------- */
.mi {
  font-family: "Material Symbols Rounded";
  font-weight: normal;
  font-style: normal;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  direction: ltr;
  font-variation-settings: 'opsz' 24, 'wght' 300, 'GRAD' 0, 'FILL' 0;
  -webkit-font-feature-settings: 'liga';
  user-select: none;
  font-size: 20px;
  vertical-align: middle;
}
.mi.fill { font-variation-settings: 'FILL' 1, 'opsz' 24, 'wght' 300; }
.mi.sm { font-size: 22px; }
.mi.xs { font-size: 18px; }
.mi.lg { font-size: 32px; }

/* ============================================================
   App shell
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  background: var(--surface-1);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 20px 20px 16px;
}
.brand__mark {
  width: 34px; height: 34px;
  border-radius: 10px;
  position: relative;
  flex: none;
  background:
     radial-gradient(120% 120% at 30% 20%, var(--primary-wash), transparent 60%),
     linear-gradient(150deg, var(--surface-4), var(--surface-2));
  border: 1px solid var(--border-hi);
  overflow: hidden;
}
/* two chambers motif */
.brand__mark::before, .brand__mark::after {
  content: ""; position: absolute; top: 50%; width: 8px; height: 8px; border-radius: 50%;
  transform: translateY(-50%);
}
.brand__mark::before { left: 8px;  background: var(--primary); box-shadow: 0 0 10px var(--primary); }
.brand__mark::after  { right: 8px; background: var(--gold);    box-shadow: 0 0 10px var(--gold); }
.brand__name {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 500;
  color: var(--text-hi);
  letter-spacing: .1px;
  line-height: 1.1;
}
.brand__name small { display: block; font-family: var(--sans); font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--text-faint); font-weight: 600; margin-top: 2px; }

.instance {
  margin: 4px 12px 14px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface-2);
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
  transition: background .15s var(--ease), border-color .15s var(--ease);
}
.instance:hover { background: var(--surface-3); border-color: var(--border-hi); }
.instance__avatar {
  width: 26px; height: 26px; border-radius: 7px; flex: none;
  background: linear-gradient(135deg, #3b4a7a, #26304a);
  color: var(--primary-hi); font-weight: 700; font-size: 12px;
  display: grid; place-items: center;
}
.instance__meta { min-width: 0; flex: 1; }
.instance__name { color: var(--text-hi); font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.instance__sub  { color: var(--text-faint); font-size: 14px; }
.instance .mi { color: var(--text-lo); margin-left: auto; }

.nav { flex: 1; overflow-y: auto; padding: 4px 12px 12px; }
.nav-group { margin-top: 14px; }
.nav-group__label {
  font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--text-faint); font-weight: 700;
  padding: 4px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 11px; border-radius: 10px;
  color: var(--text-lo); font-weight: 500; font-size: 16px;
  position: relative;
  transition: color .14s var(--ease), background .14s var(--ease);
}
.nav-item .mi { font-size: 20px; color: var(--text-faint); transition: color .14s var(--ease); }
.nav-item:hover { background: var(--hover); color: var(--text-hi); }
.nav-item:hover .mi { color: var(--text-lo); }
.nav-item.is-active { background: var(--primary-wash); color: var(--primary-hi); }
.nav-item.is-active .mi { color: var(--primary); }
.nav-item.is-active::before {
  content: ""; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--primary);
}
.nav-item__badge { margin-left: auto; font-family: var(--mono); font-size: 14px; color: var(--text-faint); }

.sidebar__foot {
  border-top: 1px solid var(--border-soft);
  padding: 12px;
}
.userchip {
  display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px;
  transition: background .15s var(--ease);
}
.userchip:hover { background: var(--hover); }
.userchip__avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, #6a5230, #3a2f1c);
  color: var(--gold); display: grid; place-items: center; font-weight: 700; font-size: 12px;
}
.userchip__meta { min-width: 0; }
.userchip__name { color: var(--text-hi); font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.userchip__sub  { color: var(--text-faint); font-size: 14px; }
.userchip .mi { margin-left: auto; color: var(--text-faint); }

/* ---- Main column ---- */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border-soft);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  padding: 0 28px;
}
.crumb { display: flex; align-items: center; gap: 8px; min-width: 0; }
.crumb__parent { color: var(--text-lo); font-size: 14.5px; }
.crumb__sep { color: var(--text-faint); font-size: 18px; }
.crumb__title {
  font-family: var(--serif); font-weight: 500; font-size: 19px; color: var(--text-hi);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar__spacer { flex: 1; }

.search {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 12px; width: 300px; max-width: 34vw;
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.search:focus-within { border-color: var(--primary-line); background: var(--surface-3); }
.search .mi { color: var(--text-faint); font-size: 19px; }
.search input {
  background: none; border: none; outline: none; color: var(--text-hi);
  font-family: inherit; font-size: 14.5px; width: 100%;
}
.search input::placeholder { color: var(--text-faint); }
.search kbd {
  font-family: var(--mono); font-size: 10.5px; color: var(--text-faint);
  border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px;
}

/* ---- View ---- */
.view { padding: 28px; max-width: 1240px; width: 100%; margin: 0 auto; }
.view--wide { max-width: 1480px; }

/* ============================================================
   Primitives
   ============================================================ */

.page-head { margin-bottom: 22px; }
.page-head__row { display: flex; align-items: flex-start; gap: 18px; flex-wrap: wrap; }
.page-title {
  font-family: var(--serif); font-weight: 400; font-size: 30px; line-height: 1.1;
  color: var(--text-hi); letter-spacing: .2px; margin: 0;
}
.page-sub { color: var(--text-lo); font-size: 16px; margin: 8px 0 0; max-width: 62ch; }
.page-head__actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 15px; border-radius: 10px; font-weight: 600; font-size: 14.5px;
  border: 1px solid transparent; background: none; color: var(--text);
  transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), transform .05s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn .mi { font-size: 19px; }
.btn--ghost { border-color: var(--border); color: var(--text); background: var(--surface-2); }
.btn--ghost:hover { background: var(--surface-3); border-color: var(--border-hi); color: var(--text-hi); }
.btn--primary {
  background: linear-gradient(180deg, var(--primary), var(--primary-dim));
  color: #0a0d13; border-color: transparent; box-shadow: var(--shadow-1);
}
.btn--primary:hover { filter: brightness(1.06); }
.btn--quiet { color: var(--text-lo); }
.btn--quiet:hover { background: var(--hover); color: var(--text-hi); }
.btn--sm { padding: 6px 11px; font-size: 12.5px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-lo);
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text-hi); border-color: var(--border-hi); }

/* card */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.card--pad { padding: 20px; }
.card__head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border-soft);
}
.card__title { font-size: 16px; font-weight: 600; color: var(--text-hi); }
.card__title .mi { color: var(--text-lo); margin-right: 8px; }
.card__head .btn, .card__head .link { margin-left: auto; }
.card__body { padding: 20px; }

.link { color: var(--primary); font-weight: 600; font-size: 14.5px; display: inline-flex; align-items: center; gap: 4px; }
.link:hover { color: var(--primary-hi); }
.link .mi { font-size: 17px; }

/* chips / badges */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface-3); color: var(--text-lo); border: 1px solid var(--border);
}
.chip .mi { font-size: 15px; }
.chip--primary { background: var(--primary-wash); color: var(--primary-hi); border-color: var(--primary-line); }
.chip--gold { background: var(--gold-wash); color: var(--gold); border-color: var(--gold-line); }

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: none; }
.dot--success { background: var(--success); box-shadow: 0 0 8px var(--success-wash); }
.dot--warning { background: var(--warning); }
.dot--danger  { background: var(--danger); }
.dot--muted   { background: var(--text-faint); }
.dot--primary { background: var(--primary); }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 700; letter-spacing: .02em;
  padding: 3px 9px; border-radius: 7px;
  background: var(--surface-3); color: var(--text-lo); border: 1px solid var(--border);
}
.badge--success { background: var(--success-wash); color: var(--success); border-color: transparent; }
.badge--warning { background: var(--warning-wash); color: var(--warning); border-color: transparent; }
.badge--danger  { background: var(--danger-wash);  color: var(--danger);  border-color: transparent; }
.badge--primary { background: var(--primary-wash); color: var(--primary-hi); border-color: transparent; }
.badge--gold    { background: var(--gold-wash);    color: var(--gold); border-color: transparent; }

.kbdrow { display: flex; gap: 6px; }
.mono { font-family: var(--mono); }
.tnum { font-variant-numeric: tabular-nums; }

/* meta list */
.meta { display: flex; align-items: center; gap: 8px; color: var(--text-lo); font-size: 12.5px; }
.meta .mi { font-size: 18px; color: var(--text-faint); }
.meta__sep { color: var(--text-faint); }

/* grids */
.grid { display: grid; gap: 16px; }
.grid--kpi { grid-template-columns: repeat(4, 1fr); }
.grid--2 { grid-template-columns: 1fr 1fr; }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--main { grid-template-columns: 1.6fr 1fr; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* ---- KPI card ---- */
.kpi { padding: 18px; position: relative; overflow: hidden; }
.kpi__ico {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  background: var(--surface-3); color: var(--primary); margin-bottom: 14px;
}
.kpi__ico .mi { font-size: 21px; }
.kpi__ico--gold { color: var(--gold); }
.kpi__val { font-size: 27px; font-weight: 700; color: var(--text-hi); letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.kpi__label { color: var(--text-lo); font-size: 12.5px; margin-top: 2px; }
.kpi__delta { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; margin-top: 10px; }
.kpi__delta .mi { font-size: 15px; }
.kpi__delta--up { color: var(--success); }
.kpi__delta--down { color: var(--danger); }
.kpi__delta--flat { color: var(--text-lo); }

/* ---- List rows ---- */
.rows { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 14px; padding: 13px 20px;
  border-top: 1px solid var(--border-soft);
  transition: background .13s var(--ease);
}
.row:first-child { border-top: none; }
.row:hover { background: var(--hover); }
.row__ico {
  width: 34px; height: 34px; border-radius: 9px; flex: none; display: grid; place-items: center;
  background: var(--surface-3); color: var(--text-lo);
}
.row__ico .mi { font-size: 19px; }
.row__main { min-width: 0; flex: 1; }
.row__title { color: var(--text-hi); font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row__sub { color: var(--text-lo); font-size: 12.5px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row__aside { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--text-lo); font-size: 12.5px; white-space: nowrap; }

/* ---- Timeline ---- */
.timeline { position: relative; padding-left: 6px; }
.tl {
  position: relative; padding: 0 0 20px 26px; border-left: 1.5px solid var(--border);
}
.tl:last-child { padding-bottom: 4px; }
.tl__node {
  position: absolute; left: -8px; top: 2px; width: 15px; height: 15px; border-radius: 50%;
  background: var(--surface-1); border: 2px solid var(--border-hi); display: grid; place-items: center;
}
.tl__node .mi { font-size: 10px; color: var(--text-lo); }
.tl__node--primary { border-color: var(--primary); }
.tl__node--primary .mi { color: var(--primary); }
.tl__node--gold { border-color: var(--gold); }
.tl__node--gold .mi { color: var(--gold); }
.tl__node--success { border-color: var(--success); }
.tl__node--success .mi { color: var(--success); }
.tl__title { color: var(--text-hi); font-size: 15px; font-weight: 600; }
.tl__title b { font-weight: 700; }
.tl__meta { color: var(--text-lo); font-size: 12px; margin-top: 3px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---- Table ---- */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 14px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-faint); font-weight: 700; padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border-soft); font-size: 14.5px; color: var(--text); vertical-align: middle; }
.table tbody tr { transition: background .12s var(--ease); }
.table tbody tr:hover { background: var(--hover); }
.table tbody tr:last-child td { border-bottom: none; }
.cell-title { color: var(--text-hi); font-weight: 600; }

/* ---- Toolbar / filters ---- */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  padding: 6px 12px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--text-lo);
  background: none; border: none; transition: background .13s var(--ease), color .13s var(--ease);
}
.seg button:hover { color: var(--text-hi); }
.seg button.is-active { background: var(--surface-4); color: var(--text-hi); }
.field {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-lo); font-size: 14.5px;
}
.field .mi { font-size: 22px; color: var(--text-faint); }
.field input, .field select { background: none; border: none; outline: none; color: var(--text-hi); font-family: inherit; font-size: 14.5px; }
.field select option { background: var(--surface-3); }

/* progress */
.bar { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar__fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary-dim), var(--primary)); }
.bar__fill--gold { background: linear-gradient(90deg, #a67a3e, var(--gold)); }

/* section label */
.eyebrow { font-size: 14px; letter-spacing: .16em; text-transform: uppercase; color: var(--text-faint); font-weight: 700; }

/* empty */
.empty { text-align: center; padding: 40px 20px; color: var(--text-lo); }
.empty .mi { font-size: 34px; color: var(--text-faint); margin-bottom: 10px; }

/* ============================================================
   Knowledge / article
   ============================================================ */
.klist { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.kcard {
  display: block; padding: 18px; border-radius: var(--r-lg);
  background: var(--surface-1); border: 1px solid var(--border-soft);
  transition: border-color .15s var(--ease), background .15s var(--ease), transform .15s var(--ease);
}
.kcard:hover { border-color: var(--border-hi); background: var(--surface-2); transform: translateY(-2px); }
.kcard__top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.kcard__ico { width: 32px; height: 32px; border-radius: 9px; background: var(--gold-wash); color: var(--gold); display: grid; place-items: center; flex: none; }
.kcard__ico .mi { font-size: 22px; }
.kcard__title { font-family: var(--serif); font-size: 16.5px; color: var(--text-hi); font-weight: 500; line-height: 1.25; }
.kcard__excerpt { color: var(--text-lo); font-size: 14.5px; line-height: 1.55; margin: 4px 0 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kcard__foot { display: flex; align-items: center; gap: 12px; color: var(--text-faint); font-size: 12px; }

.article { display: grid; grid-template-columns: 1fr 260px; gap: 32px; align-items: start; }
.prose { max-width: 68ch; }
.prose h1 { font-family: var(--serif); font-weight: 400; font-size: 30px; color: var(--text-hi); margin: 0 0 6px; line-height: 1.15; }
.prose h2 { font-family: var(--serif); font-weight: 500; font-size: 20px; color: var(--text-hi); margin: 30px 0 10px; }
.prose h3 { font-size: 15px; color: var(--text-hi); margin: 22px 0 8px; font-weight: 700; }
.prose p { color: var(--text); font-size: 14.5px; line-height: 1.72; margin: 0 0 14px; }
.prose ul { margin: 0 0 14px; padding-left: 20px; color: var(--text); }
.prose li { margin-bottom: 7px; line-height: 1.6; }
.prose strong { color: var(--text-hi); }
.prose code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-3); padding: 1px 6px; border-radius: 6px; color: var(--primary-hi); }
.prose blockquote { border-left: 2px solid var(--gold-line); background: var(--gold-wash); margin: 0 0 16px; padding: 12px 16px; border-radius: 0 8px 8px 0; color: var(--text); font-size: 16px; }
.aside-card { position: sticky; top: 88px; }
.src { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border-soft); }
.src:first-of-type { border-top: none; }
.src__ico { width: 28px; height: 28px; border-radius: 7px; background: var(--surface-3); display: grid; place-items: center; color: var(--text-lo); flex: none; }
.src__ico .mi { font-size: 18px; }
.src__name { color: var(--text-hi); font-size: 12.5px; font-weight: 600; }
.src__meta { color: var(--text-faint); font-size: 14px; }

/* ============================================================
   Entities
   ============================================================ */
.etypes { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.etype {
  flex: 1; min-width: 150px; padding: 14px 16px; border-radius: var(--r);
  background: var(--surface-1); border: 1px solid var(--border-soft);
  display: flex; align-items: center; gap: 12px; transition: border-color .15s, background .15s;
}
.etype:hover, .etype.is-active { border-color: var(--primary-line); background: var(--surface-2); }
.etype.is-active { box-shadow: inset 0 0 0 1px var(--primary-line); }
.etype__ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--primary); flex: none; }
.etype__n { font-size: 20px; font-weight: 700; color: var(--text-hi); line-height: 1; font-variant-numeric: tabular-nums; }
.etype__l { color: var(--text-lo); font-size: 12.5px; margin-top: 3px; }

.ecard {
  padding: 16px; border-radius: var(--r-lg); background: var(--surface-1);
  border: 1px solid var(--border-soft); transition: border-color .15s, background .15s, transform .15s;
  display: block;
}
.ecard:hover { border-color: var(--border-hi); background: var(--surface-2); transform: translateY(-2px); }
.ecard__top { display: flex; align-items: center; gap: 11px; margin-bottom: 12px; }
.ecard__avatar { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; font-weight: 700; color: var(--text-hi); flex: none; font-size: 15px; }
.ecard__name { color: var(--text-hi); font-weight: 600; font-size: 16px; }
.ecard__type { color: var(--text-faint); font-size: 12px; }
.ecard__stats { display: flex; gap: 16px; padding-top: 12px; border-top: 1px solid var(--border-soft); }
.ecard__stat { font-size: 12px; color: var(--text-lo); display: flex; align-items: center; gap: 5px; }
.ecard__stat b { color: var(--text-hi); font-weight: 700; }
.ecard__stat .mi { font-size: 15px; color: var(--text-faint); }

/* entity detail header */
.ent-hero { display: flex; align-items: center; gap: 18px; margin-bottom: 22px; }
.ent-hero__avatar { width: 64px; height: 64px; border-radius: 16px; display: grid; place-items: center; font-weight: 700; font-size: 24px; color: var(--text-hi); flex: none; }
.ent-hero__name { font-family: var(--serif); font-size: 32px; color: var(--text-hi); font-weight: 500; }
.deflist { display: grid; grid-template-columns: auto 1fr; gap: 12px 20px; }
.deflist dt { color: var(--text-faint); font-size: 12.5px; }
.deflist dd { margin: 0; color: var(--text-hi); font-size: 16px; }

/* ============================================================
   Documents
   ============================================================ */
.doc-ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.doc-ico .mi { font-size: 19px; }
.doc-ico--pdf { background: rgba(224,104,94,.14); color: #e08d86; }
.doc-ico--doc { background: rgba(142,155,240,.14); color: var(--primary); }
.doc-ico--sheet { background: rgba(95,184,142,.14); color: var(--success); }
.doc-ico--web { background: rgba(227,180,118,.14); color: var(--gold); }
.doc-ico--slack { background: rgba(160,120,220,.14); color: #b499e8; }

/* ============================================================
   Agents
   ============================================================ */
.agent-card { padding: 20px; }
.agent-card__top { display: flex; align-items: flex-start; gap: 14px; }
.agent-avatar {
  width: 46px; height: 46px; border-radius: 13px; flex: none; display: grid; place-items: center;
  background: radial-gradient(120% 120% at 30% 20%, var(--primary-wash), transparent), var(--surface-3);
  color: var(--primary); border: 1px solid var(--border-hi);
}
.agent-avatar .mi { font-size: 24px; }
.agent-card__name { color: var(--text-hi); font-weight: 600; font-size: 15px; }
.agent-card__role { color: var(--text-lo); font-size: 12.5px; margin-top: 2px; }
.agent-metric { display: flex; flex-direction: column; gap: 2px; }
.agent-metric__v { color: var(--text-hi); font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.agent-metric__l { color: var(--text-faint); font-size: 14px; }
.scope-pill { font-size: 14px; padding: 3px 9px; border-radius: 7px; background: var(--surface-3); color: var(--text-lo); border: 1px solid var(--border); font-weight: 600; }

/* ============================================================
   Integrations
   ============================================================ */
.int-card { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.int-card__top { display: flex; align-items: center; gap: 12px; }
.int-logo { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; flex: none; font-weight: 800; font-size: 18px; color: #fff; }
.int-card__name { color: var(--text-hi); font-weight: 600; font-size: 14.5px; }
.int-card__cat { color: var(--text-faint); font-size: 12px; }
.int-stat { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-lo); }
.int-stat b { color: var(--text-hi); font-weight: 600; }

/* ============================================================
   Context Explorer (signature)
   ============================================================ */
.ctx-hero { text-align: center; padding: 8px 0 26px; }
.ctx-hero .eyebrow { justify-content: center; }
.ctx-title { font-family: var(--serif); font-weight: 400; font-size: 34px; color: var(--text-hi); margin: 12px 0 8px; line-height: 1.12; }
.ctx-title em { font-style: italic; color: var(--gold); }
.ctx-lead { color: var(--text-lo); font-size: 14.5px; max-width: 60ch; margin: 0 auto; }

.ask {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface-2); border: 1px solid var(--border-hi);
  border-radius: 16px; padding: 6px 6px 6px 18px; box-shadow: var(--shadow-2);
  max-width: 760px; margin: 22px auto 10px; transition: border-color .18s var(--ease);
}
.ask:focus-within { border-color: var(--primary-line); }
.ask .mi.lead { color: var(--primary); font-size: 22px; }
.ask input { flex: 1; background: none; border: none; outline: none; color: var(--text-hi); font-size: 15px; font-family: inherit; }
.ask input::placeholder { color: var(--text-faint); }

.suggestions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; max-width: 760px; margin: 0 auto; }
.suggestion { font-size: 12.5px; padding: 6px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-lo); transition: all .13s var(--ease); }
.suggestion:hover { border-color: var(--primary-line); color: var(--text-hi); background: var(--surface-3); }

.ctx-result { margin-top: 30px; display: grid; grid-template-columns: 1fr 380px; gap: 24px; align-items: start; }
.answer-card { padding: 24px; }
.answer-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.answer-head .mi { color: var(--gold); }
.answer-head__t { font-weight: 600; color: var(--text-hi); font-size: 16px; }
.answer-body p { color: var(--text); font-size: 14.5px; line-height: 1.72; margin: 0 0 13px; }
.answer-body strong { color: var(--text-hi); }
.ref {
  display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 5px; background: var(--gold-wash); color: var(--gold); font-family: var(--mono);
  font-size: 10.5px; font-weight: 500; vertical-align: super; margin-left: 2px; border: 1px solid var(--gold-line);
}

.ctx-panel { position: sticky; top: 88px; }
.ctx-panel__head { padding: 16px 18px; border-bottom: 1px solid var(--border-soft); }
.ctx-score { display: flex; align-items: baseline; gap: 8px; }
.ctx-score b { font-size: 22px; color: var(--text-hi); font-weight: 700; }
.ctx-item { padding: 12px 18px; border-top: 1px solid var(--border-soft); display: flex; gap: 12px; align-items: flex-start; }
.ctx-item:hover { background: var(--hover); }
.ctx-item__ico { width: 30px; height: 30px; border-radius: 8px; flex: none; display: grid; place-items: center; }
.ctx-item__ico .mi { font-size: 18px; }
.ctx-item--k .ctx-item__ico { background: var(--gold-wash); color: var(--gold); }
.ctx-item--e .ctx-item__ico { background: var(--primary-wash); color: var(--primary); }
.ctx-item--d .ctx-item__ico { background: var(--surface-3); color: var(--text-lo); }
.ctx-item__name { color: var(--text-hi); font-size: 14.5px; font-weight: 600; }
.ctx-item__type { color: var(--text-faint); font-size: 14px; margin-top: 1px; }
.ctx-item__rel { margin-left: auto; text-align: right; flex: none; }
.ctx-item__pct { font-family: var(--mono); font-size: 14px; color: var(--text-lo); }
.relbar { width: 54px; height: 4px; border-radius: 999px; background: var(--surface-3); margin-top: 4px; overflow: hidden; }
.relbar__f { height: 100%; background: linear-gradient(90deg, var(--gold-line), var(--gold)); border-radius: 999px; }

.payload { font-family: var(--mono); font-size: 12px; line-height: 1.7; color: var(--text-lo); background: var(--surface-1); border: 1px solid var(--border-soft); border-radius: var(--r); padding: 16px; overflow-x: auto; }
.payload .k { color: var(--primary-hi); }
.payload .s { color: var(--success); }
.payload .g { color: var(--gold); }
.payload .c { color: var(--text-faint); }

/* ============================================================
   Settings
   ============================================================ */
.settings { display: grid; grid-template-columns: 210px 1fr; gap: 30px; align-items: start; }
.settings-nav { position: sticky; top: 88px; display: flex; flex-direction: column; gap: 2px; }
.settings-nav a { padding: 9px 12px; border-radius: 9px; color: var(--text-lo); font-size: 16px; font-weight: 500; transition: background .13s, color .13s; }
.settings-nav a:hover { background: var(--hover); color: var(--text-hi); }
.settings-nav a.is-active { background: var(--primary-wash); color: var(--primary-hi); }
.set-row { display: flex; align-items: center; gap: 16px; padding: 16px 0; border-top: 1px solid var(--border-soft); }
.set-row:first-child { border-top: none; }
.set-row__main { flex: 1; }
.set-row__label { color: var(--text-hi); font-weight: 600; font-size: 16px; }
.set-row__desc { color: var(--text-lo); font-size: 12.5px; margin-top: 2px; }
.input {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px;
  padding: 9px 12px; color: var(--text-hi); font-family: inherit; font-size: 16px; outline: none; width: 100%;
  transition: border-color .15s;
}
.input:focus { border-color: var(--primary-line); }
.switch { width: 42px; height: 24px; border-radius: 999px; background: var(--surface-4); position: relative; flex: none; transition: background .18s var(--ease); border: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--text-lo); transition: transform .18s var(--ease), background .18s; }
.switch.is-on { background: var(--primary-dim); }
.switch.is-on::after { transform: translateX(18px); background: #fff; }

/* avatar color helpers */
.av-blue  { background: linear-gradient(135deg,#3b4a7a,#26304a); color:#a9b3f6; }
.av-gold  { background: linear-gradient(135deg,#6a5230,#3a2f1c); color:#e3b476; }
.av-green { background: linear-gradient(135deg,#2f5645,#1f3a2e); color:#7fd3ac; }
.av-rose  { background: linear-gradient(135deg,#5a3340,#3a2029); color:#e79aa8; }
.av-violet{ background: linear-gradient(135deg,#4a3a6a,#2c2444); color:#b499e8; }
.av-teal  { background: linear-gradient(135deg,#2c5058,#1c363c); color:#7fc9d6; }

/* utilities */
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; } .mt-32 { margin-top: 32px; }
.mb-0 { margin-bottom: 0; } .mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.txt-lo { color: var(--text-lo); } .txt-hi { color: var(--text-hi); } .txt-faint { color: var(--text-faint); }
.gold { color: var(--gold); } .prim { color: var(--primary); }
.flex { display: flex; } .items-center { align-items: center; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.between { justify-content: space-between; } .wrap { flex-wrap: wrap; } .ml-auto { margin-left: auto; }
.divider { height: 1px; background: var(--border-soft); margin: 20px 0; border: none; }

/* ---- responsive ---- */
@media (max-width: 1080px) {
  .grid--kpi { grid-template-columns: repeat(2, 1fr); }
  .grid--main, .grid--2, .grid--3, .ctx-result, .article, .settings, .klist { grid-template-columns: 1fr; }
  .aside-card, .ctx-panel, .settings-nav, .agent-avatar { position: static; }
}
@media (max-width: 860px) {
  :root { --sidebar-w: 0px; }
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 60; width: 256px; transform: translateX(-100%); transition: transform .25s var(--ease); }
  .sidebar.is-open { transform: translateX(0); }
  .topbar__menu { display: grid !important; }
  .search { width: auto; }
  .search .hint { display: none; }
  .backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 55; }
  .backdrop.is-open { display: block; }
  .view { padding: 20px 16px; }
  .grid--kpi { grid-template-columns: 1fr; }
}
.topbar__menu { display: none; }

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* focus visibility */
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }

/* entrance */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.rise { animation: rise .4s var(--ease) both; }
.rise-1 { animation-delay: .04s; } .rise-2 { animation-delay: .08s; } .rise-3 { animation-delay: .12s; } .rise-4 { animation-delay: .16s; }
