*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0E0D0B;
  --bg-2: #16140F;
  --bg-3: #1C1A14;
  --bg-hover: #22201A;
  --rule: #2A2620;
  --rule-2: #403A30;
  --text: #EDE7D9;
  --text-2: #A39886;
  --text-3: #6B6354;
  --accent: #E85A2A;
  --accent-dim: #B8441C;
  --accent-glow: rgba(232, 90, 42, 0.14);
  --ok: #8FB339;
  --warn: #D4A535;
  --info: #5BA3F5;
  --err: #E5484D;

  /* Language colors — hand-picked, not rainbow */
  --lang-ts: #5BA3F5;
  --lang-js: #D4A535;
  --lang-py: #8FB339;
  --lang-go: #22D3EE;
  --lang-rs: #E5484D;
  --lang-java: #F97316;
  --lang-c: #A1A1AA;
  --lang-rb: #C084FC;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Public Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  height: 100vh;
}

.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }

/* ────────── LAYOUT ────────── */
.app {
  display: grid;
  grid-template-rows: 44px 1fr 28px;
  grid-template-columns: 240px 1fr 360px;
  grid-template-areas:
    "head head head"
    "rail main inspector"
    "foot foot foot";
  height: 100vh;
}

/* ────────── HEADER ────────── */
header.chrome {
  grid-area: head;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 20px;
  background: var(--bg);
}
.brand {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.brand::before { content: "▌ "; color: var(--accent); }
.brand-tag {
  display: inline-block;
  margin-left: 10px;
  padding: 2px 7px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-3);
  border: 1px solid var(--rule);
  border-radius: 3px;
  vertical-align: middle;
}
.breadcrumb {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-2);
  display: flex;
  gap: 6px;
  align-items: center;
}
.breadcrumb .sep { color: var(--text-3); }
.breadcrumb .git { color: var(--ok); }
.chrome-spacer { flex: 1; }
.cmdk-hint {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-3);
  padding: 4px 10px;
  border: 1px solid var(--rule);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.cmdk-hint:hover { border-color: var(--rule-2); color: var(--text-2); }
.cmdk-hint kbd {
  font-family: inherit;
  font-size: 10px;
  padding: 1px 6px;
  background: var(--bg-3);
  border: 1px solid var(--rule);
  color: var(--text-2);
}

/* ────────── LEFT RAIL ────────── */
nav.rail {
  grid-area: rail;
  border-right: 1px solid var(--rule);
  padding: 16px 0;
  overflow-y: auto;
  background: var(--bg);
}
.rail-section {
  padding: 0 16px;
  margin-bottom: 24px;
}
.rail-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 8px;
  padding-left: 10px;
}
.rail-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  cursor: pointer;
  border-left: 2px solid transparent;
  font-size: 13px;
  color: var(--text-2);
  transition: color 0.1s, background 0.1s;
}
.rail-item:hover {
  color: var(--text);
  background: var(--bg-2);
}
.rail-item.active {
  color: var(--text);
  border-left-color: var(--accent);
  background: var(--bg-2);
}
.rail-item .count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-3);
}
.rail-item.active .count { color: var(--accent); }

/* ────────── MAIN ────────── */
main.stage {
  grid-area: main;
  overflow: hidden;
  position: relative;
  background: var(--bg);
}
.view { display: none; height: 100%; overflow: hidden; }
.view.active { display: block; }

/* ── Graph view ── */
#graph-view { position: relative; overflow: hidden; }
#graph-svg {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}
#graph-svg:active { cursor: grabbing; }
#graph-svg .node { cursor: pointer; }
#graph-svg .node circle { stroke: var(--bg); stroke-width: 1.5px; transition: stroke 0.15s; }
#graph-svg .node:hover circle { stroke: var(--accent); stroke-width: 2px; }
#graph-svg .node.selected circle { stroke: var(--accent); stroke-width: 2.5px; }
#graph-svg .link { stroke: var(--rule); fill: none; }
#graph-svg .link.highlighted { stroke: var(--accent); }
#graph-svg .node-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  fill: var(--text-2);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}
#graph-svg .node:hover .node-label,
#graph-svg .node.selected .node-label,
#graph-svg .node.label-visible .node-label { opacity: 1; }

.graph-controls {
  position: absolute;
  bottom: 20px;
  left: 20px;
  display: flex;
  gap: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  align-items: center;
  flex-wrap: wrap;
  max-width: 500px;
}
.graph-chip {
  padding: 6px 12px;
  background: var(--bg-2);
  border: 1px solid var(--rule);
  color: var(--text-2);
  cursor: pointer;
}
.graph-chip:hover { border-color: var(--rule-2); color: var(--text); }
.graph-chip.on { border-color: var(--accent); color: var(--accent); }

.graph-search {
  position: absolute;
  top: 20px;
  left: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 0;
  max-width: 600px;
}
.graph-search input {
  flex: 1;
  padding: 10px 14px;
  background: rgba(22, 20, 15, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid var(--rule);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  outline: none;
}
.graph-search input:focus { border-color: var(--accent); }
.graph-search input::placeholder { color: var(--text-3); }

.graph-legend {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(22, 20, 15, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid var(--rule);
  padding: 12px 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-3);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.graph-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}
.graph-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.graph-slider-group {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-2);
  border: 1px solid var(--rule);
  color: var(--text-2);
}
.graph-slider-group label { white-space: nowrap; }
.graph-slider-group input[type="range"] {
  width: 100px;
  accent-color: var(--accent);
}
.graph-slider-group .slider-val {
  min-width: 32px;
  text-align: right;
  color: var(--accent);
}

.graph-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(22, 20, 15, 0.95);
  border: 1px solid var(--rule-2);
  padding: 8px 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text);
  display: none;
  z-index: 100;
  white-space: nowrap;
}
.graph-tooltip .tt-path { color: var(--accent); margin-bottom: 2px; }
.graph-tooltip .tt-meta { color: var(--text-3); }

/* ── Search view ── */
#search-view {
  display: none;
  flex-direction: column;
  padding: 0;
}
#search-view.active { display: flex; }

.search-header {
  padding: 24px 32px 16px;
  border-bottom: 1px solid var(--rule);
}
.search-input {
  width: 100%;
  padding: 8px 0;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--rule);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 20px;
  outline: none;
  font-weight: 500;
}
.search-input:focus { border-bottom-color: var(--accent); }
.search-input::placeholder { color: var(--text-3); }
.search-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-3);
  margin-top: 10px;
  display: flex;
  gap: 16px;
}
.search-results {
  flex: 1;
  overflow-y: auto;
  padding: 16px 32px 32px;
}
.result {
  padding: 16px 0;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
}
.result:hover { background: var(--bg-2); margin: 0 -32px; padding: 16px 32px; }
.result-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}
.result-path { color: var(--accent); }
.result-meta { color: var(--text-3); display: flex; gap: 12px; }
.result-type { color: var(--warn); }
.result-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-2);
  white-space: pre-wrap;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
}

/* ── Memories view ── */
#memories-view { padding: 0; overflow-y: auto; }
.view-header {
  padding: 24px 32px 16px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.view-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.view-title::before { content: "▌ "; color: var(--accent); }
.view-subtitle {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-3);
}
.memories-list { padding: 16px 32px 32px; }
.memory {
  padding: 16px 0;
  border-bottom: 1px solid var(--rule);
  display: grid;
  grid-template-columns: 140px 1fr 120px;
  gap: 24px;
  align-items: baseline;
}
.memory-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-3);
}
.memory-meta .cat {
  display: inline-block;
  padding: 2px 8px;
  color: var(--accent);
  border: 1px solid var(--accent);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-bottom: 6px;
}
.memory-meta .git { color: var(--ok); margin-top: 4px; }
.memory-content { font-size: 14px; color: var(--text); line-height: 1.55; }
.memory-stats {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-3);
  text-align: right;
}
.memory.stale { opacity: 0.55; border-left: 2px solid var(--warn); padding-left: 16px; margin-left: -18px; }
.memory.stale .cat { color: var(--warn); border-color: var(--warn); }

/* ── Files view ── */
#files-view { padding: 0; overflow-y: auto; }
.files-list { padding: 0; }
.file-row {
  display: grid;
  grid-template-columns: 1fr 80px 80px 60px;
  gap: 16px;
  align-items: center;
  padding: 10px 32px;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
  font-size: 13px;
}
.file-row:hover { background: var(--bg-2); }
.file-row .path { font-family: 'JetBrains Mono', monospace; color: var(--text); }
.file-row .lang { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text-3); }
.file-row .pr { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--accent); text-align: right; }
.file-row .chunks { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text-3); text-align: right; }
.file-row .pr-bar {
  display: inline-block;
  height: 2px;
  background: var(--accent);
  vertical-align: middle;
  margin-right: 6px;
}

/* ── Stats view ── */
#stats-view { padding: 32px; overflow-y: auto; }
.hero-stat {
  padding: 32px 0 24px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 32px;
}
.hero-stat-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 72px;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--accent);
  line-height: 1;
}
.hero-stat-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--text);
  margin-top: 12px;
}
.hero-stat-desc {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 6px;
  max-width: 60ch;
}
.mini-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
}
.mini-stat {
  background: var(--bg);
  padding: 20px;
}
.mini-stat-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin-bottom: 12px;
}
.mini-stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.mini-stat-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-3);
  margin-top: 4px;
}
.lang-bars {
  margin-top: 16px;
  display: flex;
  gap: 2px;
  height: 8px;
  background: var(--bg-3);
}
.lang-bar { height: 100%; }

/* ────────── RIGHT INSPECTOR ────────── */
aside.inspector {
  grid-area: inspector;
  border-left: 1px solid var(--rule);
  overflow-y: auto;
  background: var(--bg);
  padding: 20px;
}
.inspector-empty {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-3);
  padding: 16px 0;
}
.inspector-empty::before { content: "// "; color: var(--accent); }
.inspector-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin-bottom: 8px;
}
.inspector-title::before { content: "// "; color: var(--accent); }
.inspector-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: var(--text);
  word-break: break-all;
  margin-bottom: 20px;
}
.inspector-section { margin-bottom: 24px; }
.inspector-row {
  padding: 6px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--rule);
}
.inspector-row .k { color: var(--text-3); }
.inspector-row .v { color: var(--text); }
.inspector-pill {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 3px 8px;
  background: var(--bg-2);
  border: 1px solid var(--rule);
  color: var(--text-2);
  margin: 2px 4px 2px 0;
}
.inspector-chunk {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 4px 0;
  color: var(--text-2);
}
.inspector-chunk .type { color: var(--accent); }
.inspector-chunk .line { color: var(--text-3); float: right; }

/* ────────── FOOTER ────────── */
footer.status {
  grid-area: foot;
  border-top: 1px solid var(--rule);
  display: flex;
  align-items: center;
  padding: 0 20px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-3);
  gap: 24px;
  background: var(--bg);
}
footer.status .item { display: flex; gap: 6px; }
footer.status .item .k { color: var(--text-3); }
footer.status .item .v { color: var(--text-2); }
footer.status .dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--ok);
  margin-right: 4px;
  vertical-align: middle;
}
footer.status .spacer { flex: 1; }

/* ────────── CMDK PALETTE ────────── */
.cmdk-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14, 13, 11, 0.85);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  padding-top: 15vh;
}
.cmdk-overlay.open { display: block; }
.cmdk-box {
  max-width: 560px;
  margin: 0 auto;
  background: var(--bg-2);
  border: 1px solid var(--rule-2);
}
.cmdk-input {
  width: 100%;
  padding: 16px 20px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--rule);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  outline: none;
}
.cmdk-input::placeholder { color: var(--text-3); }
.cmdk-list {
  max-height: 400px;
  overflow-y: auto;
  padding: 8px 0;
}
.cmdk-item {
  padding: 10px 20px;
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.cmdk-item.selected { background: var(--bg-3); color: var(--accent); }
.cmdk-item .kind { font-size: 11px; color: var(--text-3); }

/* scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--rule); }
::-webkit-scrollbar-thumb:hover { background: var(--rule-2); }
