/* Engram console — self-hosted, no external fonts or scripts (CSP-clean). */
:root {
  --bg: #0d0f1a;
  --bg-2: #141826;
  --panel: #181c2e;
  --panel-2: #1f2438;
  --border: #2a3050;
  --text: #e8eaf2;
  --muted: #9aa3c0;
  --faint: #6b7299;
  --accent: #7c6cff;
  --accent-2: #a78bfa;
  --accent-soft: rgba(124, 108, 255, 0.14);
  /* aura palette — shared with the marketing site so the brand reads as one product */
  --a1: #8b5cf6;
  --a2: #22d3ee;
  --a3: #4ade80;
  --grad: linear-gradient(120deg, var(--a1), var(--a2) 58%, var(--a3));
  --good: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 12px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 10px 30px -18px rgba(0, 0, 0, 0.7);
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: radial-gradient(1200px 700px at 70% -10%, #1a1f3a 0%, var(--bg) 55%);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
/* App-wide slim, on-brand scrollbars — replaces the default chunky grey OS bar EVERYWHERE (sidebar,
   panels, modals, code blocks, lists) with a thin, mostly-transparent thumb that only darkens on
   hover. More specific rules below (#memoryScroll etc.) still win where they want a different weight. */
* { scrollbar-width: thin; scrollbar-color: rgba(124, 108, 255, 0.3) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: rgba(124, 108, 255, 0.3); border-radius: 999px; background-clip: padding-box; border: 2px solid transparent; }
*::-webkit-scrollbar-thumb:hover { background: rgba(124, 108, 255, 0.55); }
*::-webkit-scrollbar-corner { background: transparent; }

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.4em; }
code, kbd, pre { font-family: var(--mono); }

/* layout */
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 24px; }
.narrow { max-width: 720px; }
.topbar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px;
  padding: 12px 24px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: rgba(13, 15, 26, 0.82); backdrop-filter: blur(8px); z-index: 10;
}
/* Pin each topbar piece to its grid column EXPLICITLY. With auto-placement, hiding the middle
   brain-switcher (Skills/Settings/Admin views, marketing pages) made the nav slide into the empty
   center column and render centered instead of right-aligned. */
.topbar-left { grid-column: 1; display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar > .brand { grid-column: 1; } /* marketing pages: brand is a direct child (no .topbar-left wrapper) */
.topbar-bs { grid-column: 2; justify-self: center; padding: 3px 5px 3px 9px; }
.topbar-bs select { width: 170px; }
.topbar .nav-links { grid-column: 3; justify-self: end; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -0.02em; }
.brand .dot { width: 27px; height: 27px; border-radius: 8px; background: var(--grad); display: inline-flex; align-items: center; justify-content: center; font-size: 15px; box-shadow: 0 4px 14px -4px var(--a1); }
.nav-links { display: flex; gap: 18px; align-items: center; }
.nav-links a { color: var(--muted); font-size: 14px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; text-align: center; gap: 8px; padding: 10px 18px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.15s; font-family: inherit; }
.btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: none; color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { border-color: rgba(248, 113, 113, 0.4); color: var(--bad); }
.btn.danger:hover { background: rgba(248, 113, 113, 0.12); }
.btn.sm { padding: 6px 12px; font-size: 13px; }
/* Square icon-only button (e.g. the Overview refresh) — keeps a tidy footprint, never wraps text. */
.btn.icon-btn { padding: 6px; width: 30px; height: 30px; justify-content: center; flex-shrink: 0; }
.btn.icon-btn svg { display: block; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* hero / landing */
.hero { padding: 72px 0 40px; text-align: center; }
.hero h1 { font-size: 52px; letter-spacing: -0.03em; margin-bottom: 16px; }
.hero h1 .grad { background: linear-gradient(120deg, var(--accent-2), #f0abfc); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p.lede { font-size: 20px; color: var(--muted); max-width: 640px; margin: 0 auto 28px; }
.cta-row { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

.eyebrow { text-transform: uppercase; letter-spacing: 0.12em; font-size: 12px; color: var(--accent-2); font-weight: 700; }

/* sections */
section.block { padding: 48px 0; border-top: 1px solid var(--border); }
.grid { display: grid; gap: 18px; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.main .card { transition: border-color 0.18s; }
.main .card:hover { border-color: #36406b; }
.card h3 { font-size: 17px; }
/* Secondary section (below the hero map) — always shown, no collapse. */
.secondary-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-top: 18px; }
.secondary-card > .secondary-title { margin: 0; padding: 15px 22px 0; font-size: 16px; font-weight: 700; }
.secondary-card > .secondary-title + * { padding: 12px 22px 20px; }

/* Morning-brief teaser (sidebar) — one scannable line + a button; the full brief opens in a modal. */
.brief-teaser { font-size: 13.5px; color: var(--text); line-height: 1.55; }
.brief-teaser strong { font-weight: 700; }
.brief-teaser .brief-hl-due { color: var(--warn, #e0a93b); }
/* Full-brief modal — roomy, sectioned, scannable (one item per row, never a wall of prose). */
/* #modal is given a definite width (via openModal opts) so it doesn't shrink to content on mobile;
   the brief just fills that content box — no viewport math here, so #modal's own padding is respected. */
.brief-modal { display: flex; flex-direction: column; max-height: 84vh; max-height: 84dvh; min-height: 0; width: 100%; }
.brief-modal > .memv-head { flex-shrink: 0; }
.brief-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 4px 2px 2px; scrollbar-width: thin; scrollbar-color: rgba(124,108,255,.5) transparent; }
.brief-foot { flex-shrink: 0; }
.brief-brain { margin-bottom: 8px; }
.brief-brain + .brief-brain { margin-top: 10px; padding-top: 16px; border-top: 1px solid var(--border); }
.brief-brainname { font-size: 15px; font-weight: 700; margin: 2px 0 14px; color: var(--accent-2, #a9a2ff); }
.brief-sec { margin-bottom: 18px; }
.brief-sec .memv-lab { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.brief-count { font-family: var(--mono); font-size: 11px; font-weight: 700; color: var(--muted);
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 999px; padding: 0 7px; letter-spacing: 0; }
.brief-count.tone-due { color: var(--warn, #e0a93b); border-color: rgba(224,169,59,.4); background: rgba(224,169,59,.1); }
.brief-row { display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
  font-size: 13.5px; line-height: 1.5; padding: 8px 12px; border-radius: 8px; background: var(--panel-2);
  border: 1px solid var(--border); margin-bottom: 6px; }
.brief-row > span:first-child { min-width: 0; }
.brief-row.faint { background: none; border: none; color: var(--faint); padding: 4px 12px; }
.brief-due { flex-shrink: 0; font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
.brief-due.overdue { color: var(--bad, #ef6f6f); font-weight: 700; }
.brief-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.brief-pill { font-size: 12.5px; font-weight: 600; padding: 4px 12px; border-radius: 999px; border: 1px solid; }
.brief-pill.hot { color: #ff8a5c; background: rgba(255,138,92,.1); border-color: rgba(255,138,92,.3); }
.brief-pill.warm { color: var(--accent-2, #a9a2ff); background: rgba(124,108,255,.1); border-color: rgba(124,108,255,.3); }
.brief-pill.cold { color: var(--muted); background: rgba(154,163,192,.08); border-color: var(--border); }
.brief-foot { margin-top: 12px; padding-top: 14px; border-top: 1px solid var(--border); line-height: 1.55; }

/* console card headers get a small gradient tick so sections read as distinct, not flat tabs */
.main .card > h3:first-child, #adminBody .card > h3:first-child { position: relative; padding-left: 13px; }
.main .card > h3:first-child::before, #adminBody .card > h3:first-child::before { content: ""; position: absolute; left: 0; top: 2px; bottom: 2px; width: 3px; border-radius: 3px; background: var(--grad); }
.card .num { font-size: 13px; font-weight: 700; color: var(--accent-2); }
/* "Beta" badge on non-Claude connector brands, + the info box on their setup tab. */
.beta-badge { display: inline-block; margin-left: 7px; padding: 1px 7px; border-radius: 999px; font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; vertical-align: middle; color: var(--warn, #fbbf24); background: rgba(251, 191, 36, 0.13); border: 1px solid rgba(251, 191, 36, 0.35); }
.betabox { border: 1px solid rgba(251, 191, 36, 0.3); background: rgba(251, 191, 36, 0.07); border-radius: 8px; padding: 9px 12px; margin: 0 0 12px; color: var(--muted); }
/* Source-provenance tier chips on a memory's source pointers (chat history ≠ live Gmail). */
.tier-chip { display: inline-block; margin-left: 6px; padding: 0 7px; border-radius: 999px; font-size: 10px; font-weight: 700; letter-spacing: 0.03em; vertical-align: middle; border: 1px solid; }
.tier-chip.tier-1 { color: var(--good, #4ade80); background: rgba(74, 222, 128, 0.1); border-color: rgba(74, 222, 128, 0.3); }
.tier-chip.tier-2 { color: var(--accent-2, #a9a2ff); background: rgba(124, 108, 255, 0.12); border-color: rgba(124, 108, 255, 0.35); }
.tier-chip.tier-3 { color: var(--muted); background: rgba(154, 163, 192, 0.1); border-color: var(--border); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 15px; }

/* trust strip */
.trust { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 999px; background: var(--panel); border: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.pill .ic { color: var(--good); }

/* code block */
pre.code { background: #0a0c16; border: 1px solid var(--border); border-radius: 10px; padding: 16px; overflow: auto; font-size: 13px; color: #cdd3f0; position: relative; }
.copywrap { position: relative; }
.copywrap .copy { position: absolute; top: 10px; right: 10px; }

/* key reveal */
.keybox { font-family: var(--mono); font-size: 15px; background: #0a0c16; border: 1px solid var(--accent); border-radius: 10px; padding: 14px 16px; word-break: break-all; color: var(--accent-2); }
.warnbox { border: 1px solid var(--warn); background: rgba(251, 191, 36, 0.08); border-radius: 10px; padding: 12px 14px; font-size: 14px; color: #f6d27a; }

/* app shell */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: calc(100vh - 67px); }
.side { display: flex; flex-direction: column; border-right: 1px solid var(--border); padding: 20px 12px; background: linear-gradient(180deg, rgba(124,108,255,0.04), transparent 240px);
  /* Stay put while the main column scrolls (the topbar is sticky at top:0, ~66px tall). */
  position: sticky; top: 66px; align-self: start; height: calc(100vh - 66px); overflow-y: auto; }
.side a { position: relative; display: flex; align-items: center; gap: 11px; padding: 11px 13px; margin-bottom: 2px; border-radius: 10px; color: var(--muted); font-size: 14px; font-weight: 500; cursor: pointer; transition: background 0.15s, color 0.15s; }
.side a:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.side a.active { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.side a.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--grad); }
.side a .badge { margin-left: auto; background: var(--accent); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; font-weight: 700; }
.side a .navico { width: 18px; height: 18px; flex-shrink: 0; opacity: .8; }
.side a:hover .navico, .side a.active .navico { opacity: 1; }
/* The app column is clamped to the viewport under the topbar (66px), so the PAGE never scrolls;
   long views (Settings/Admin) scroll inside their own panel, and the map views fill the space exactly. */
.main { padding: 20px 28px; min-width: 0; height: calc(100vh - 66px); display: flex; flex-direction: column; overflow: hidden; }
.panelview { display: none; }
.panelview.active { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; overflow-y: auto; animation: fadeUp 0.28s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.page-h h2 { font-size: 25px; letter-spacing: -0.02em; }

/* stat row */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat { background: linear-gradient(180deg, var(--panel), var(--bg-2)); border: 1px solid var(--border); border-radius: var(--radius); padding: 17px; box-shadow: var(--shadow); transition: transform 0.18s, border-color 0.18s; }
.stat:hover { transform: translateY(-2px); border-color: var(--accent); }
.stat .v { font-size: 27px; font-weight: 800; font-family: var(--mono); background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat .l { font-size: 13px; color: var(--muted); }
/* Overview tiles: more compact vertically so the "Your brain" section fits higher on the page. */
#stats { margin-bottom: 14px; }
#stats .stat { padding: 10px 16px; }
#stats .stat .v { font-size: 22px; }

/* checklist */
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; gap: 12px; align-items: flex-start; padding: 14px 0; border-bottom: 1px solid var(--border); }
.checklist li .check { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 13px; }
.checklist li.done .check { background: var(--good); border-color: var(--good); color: #06310f; }
.checklist li .ct { flex: 1; min-width: 0; }
.checklist li .ct .t { font-weight: 600; }
/* Step-action buttons: one standard size so the column reads as a tidy stack — never mismatched, wrapped, or cropped. */
.checklist li > .btn { flex-shrink: 0; align-self: center; min-width: 148px; justify-content: center; text-align: center; white-space: nowrap; }

/* memory + feed items */
.item { position: relative; overflow: hidden; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; transition: background .16s ease, border-color .16s ease, box-shadow .16s ease; }
.item::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--grad); transform: scaleY(0); transition: transform .18s ease; }
.item:hover { border-color: #4a5085; background: var(--panel-2); box-shadow: 0 10px 26px -16px rgba(124,108,255,.6); }
.item:hover::before { transform: scaleY(1); }
.item .row { display: flex; align-items: center; gap: 10px; justify-content: space-between; }

/* Memory list — modern, faded scroll area with a sleek custom scrollbar. */
.memwrap { position: relative; }
.memwrap::before, .memwrap::after { content: ""; position: absolute; left: 2px; right: 12px; height: 22px; pointer-events: none; z-index: 2; }
.memwrap::before { top: 0; background: linear-gradient(to bottom, var(--bg) 10%, transparent); }
.memwrap::after { bottom: 0; background: linear-gradient(to top, var(--bg) 10%, transparent); }
#memoryScroll { scrollbar-width: thin; scrollbar-color: rgba(124,108,255,.55) transparent; }
#memoryScroll::-webkit-scrollbar { width: 12px; }
#memoryScroll::-webkit-scrollbar-track { background: transparent; }
#memoryScroll::-webkit-scrollbar-thumb { background: linear-gradient(180deg, var(--accent), var(--accent-2, #a9a2ff)); border-radius: 999px; border: 4px solid var(--bg); background-clip: padding-box; min-height: 40px; }
#memoryScroll:hover::-webkit-scrollbar-thumb { border-width: 3px; }
#memoryScroll::-webkit-scrollbar-thumb:active { border-width: 2px; }

/* Sleek thin scrollbars for code blocks + the modal (replaces the chunky default bars). */
pre.code { scrollbar-width: thin; scrollbar-color: rgba(124,108,255,.5) transparent; }
pre.code::-webkit-scrollbar { width: 8px; height: 8px; }
pre.code::-webkit-scrollbar-track { background: transparent; }
pre.code::-webkit-scrollbar-thumb { background: rgba(124,108,255,.45); border-radius: 999px; border: 2px solid #0a0c16; background-clip: padding-box; }
pre.code::-webkit-scrollbar-thumb:hover { background: rgba(124,108,255,.75); }
pre.code::-webkit-scrollbar-corner { background: transparent; }
/* Wizard chooser cards (connector modal: brand → tool). */
.wizcard { display: block; width: 100%; text-align: left; padding: 12px 14px; margin-top: 9px; border: 1px solid var(--border); border-radius: 11px; background: var(--panel-2, #141828); color: var(--text); cursor: pointer; transition: border-color .12s, background .12s; }
.wizcard:hover { border-color: var(--accent, #7c6cff); background: var(--panel); }

.modal { scrollbar-width: thin; scrollbar-color: rgba(124,108,255,.45) transparent; }
.modal::-webkit-scrollbar { width: 10px; }
.modal::-webkit-scrollbar-track { background: transparent; }
.modal::-webkit-scrollbar-thumb { background: rgba(124,108,255,.38); border-radius: 999px; border: 3px solid var(--panel); background-clip: padding-box; }
.modal::-webkit-scrollbar-thumb:hover { background: rgba(124,108,255,.6); }
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--border); font-size: 12px; color: var(--muted); margin-right: 5px; }
.type-pill { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent-2); font-weight: 700; }
.proposal .diff { font-family: var(--mono); font-size: 12px; color: var(--muted); background: #0a0c16; border-radius: 8px; padding: 10px; margin: 10px 0; }
.proposal .actions { display: flex; gap: 8px; }
.sample-tag { background: rgba(251,191,36,0.14); color: var(--warn); border-color: rgba(251,191,36,0.4); }

/* forms */
label.field { display: block; margin-bottom: 14px; }
label.field .lab { font-size: 13px; color: var(--muted); margin-bottom: 5px; display: block; }
input[type=text], input[type=email], textarea, select {
  width: 100%; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--bg-2); color: var(--text); font-size: 14px; font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }
.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle input { width: auto; }

/* toast */
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--panel-2); border: 1px solid var(--accent); color: var(--text); padding: 12px 20px; border-radius: 10px; opacity: 0; pointer-events: none; transition: all 0.25s; z-index: 100; font-size: 14px; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* modal */
.overlay { position: fixed; inset: 0; background: rgba(5,7,15,0.7); display: none; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.overlay.show { display: flex; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 24px; max-width: 560px; width: 100%; max-height: 86vh; max-height: 86dvh; overflow: auto; box-shadow: 0 30px 80px -30px rgba(0,0,0,0.8); animation: fadeUp 0.22s ease; }

/* tabs (connector modal) */
.tabbar { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 6px 0 16px; }
.tab { background: none; border: none; border-bottom: 2px solid transparent; color: var(--muted); padding: 8px 14px; cursor: pointer; font-size: 14px; font-weight: 600; font-family: inherit; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tabpane { display: none; }
.tabpane.active { display: block; }
.conntable { width: 100%; border-collapse: collapse; font-size: 13px; }
.conntable td { padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.conntable td:first-child { color: var(--muted); width: 42%; }
.conntable code { background: #0a0c16; padding: 2px 6px; border-radius: 5px; word-break: break-all; }

/* benefits (pain → solution) */
.benefithead { display: flex; gap: 28px; margin: 4px 0 16px; flex-wrap: wrap; }
.benefithead .bv { font-size: 28px; font-weight: 800; font-family: var(--mono); color: var(--accent-2); }
.benefithead .bl { font-size: 12px; color: var(--muted); }
.painrow { display: grid; grid-template-columns: 1fr 22px 1.2fr; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.painrow .pain { color: var(--faint); }
.painrow .arrow { color: var(--accent); text-align: center; font-weight: 700; }
.painrow .sol { color: var(--text); }

/* admin dashboard */
.adgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-top: 16px; }
.adgrid .card { margin: 0; }
.mrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.mrow:last-child { border-bottom: none; }
.mlabel { color: var(--muted); font-size: 13px; }
.mval { font-weight: 700; font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.funrow { margin: 12px 0; }
.funhead { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.funhead .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); }
.bar { height: 10px; background: var(--panel-2, rgba(255,255,255,.05)); border-radius: 6px; overflow: hidden; }
.barfill { height: 100%; border-radius: 6px; transition: width .4s ease; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 52px; margin: 4px 0 6px; }
.sparkbar { flex: 1; display: flex; align-items: flex-end; justify-content: center; height: 100%; }
.sparkfill { width: 100%; border-radius: 3px 3px 0 0; min-height: 2px; }

/* product version badge */
/* Version badge lives at the bottom of the menu (not next to the logo). */
.appver:empty { display: none; }
.appver { margin-top: auto; align-self: flex-start; margin-left: 13px; font-size: 11px; font-weight: 600; color: var(--accent-2); border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px; }

/* Burger menu toggle — mobile only (shown in the media query). */
.burger { display: none; align-items: center; justify-content: center; background: none; border: none; color: var(--text); cursor: pointer; padding: 6px; border-radius: 8px; }
.burger svg { width: 22px; height: 22px; display: block; }
.burger:hover { background: var(--panel); }
#signout { display: inline-flex; align-items: center; gap: 7px; }
.so-ico { width: 18px; height: 18px; }

/* On-screen zoom buttons over the brain map (the only zoom on touch). */
.bm-zoomctl { position: absolute; top: 58px; right: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 5; } /* below the 3D/⛶ buttons (top:12) */
.bm-zoomctl button { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border); background: rgba(20,22,38,0.85); color: var(--text); font-size: 20px; line-height: 1; cursor: pointer; display: grid; place-items: center; -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.bm-zoomctl button:hover { border-color: var(--accent); color: var(--accent-2); }
.bm-zoomctl button:active { transform: scale(0.94); }

/* live indicator (SSE stream status) */

/* sub-tabs (Brain(s): Memories | Echo) */
.subtabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin: 6px 0 18px; }
.subtab { background: none; border: none; border-bottom: 2px solid transparent; color: var(--muted); padding: 9px 14px; cursor: pointer; font-size: 14px; font-weight: 600; font-family: inherit; border-radius: 8px 8px 0 0; }
.subtab:hover { color: var(--text); background: var(--panel); }
.subtab.active { color: var(--text); border-bottom-color: var(--accent); }
.subpane { display: none; }
.subpane.active { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; animation: fadeUp 0.22s ease; }

/* activity feed — "what Echo & your brain are doing" */
.actrow { display: flex; align-items: baseline; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.actrow:last-child { border-bottom: none; }
.acticon { flex-shrink: 0; width: 20px; text-align: center; font-size: 14px; }
.actdetail { flex: 1; min-width: 0; font-size: 13.5px; }
.acttime { flex-shrink: 0; white-space: nowrap; }

/* dynamic brain map (emergent concepts per brain) */
.brainmap { position: relative; background: radial-gradient(420px 240px at 50% 45%, rgba(124,108,255,0.08), transparent 70%); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 8px 6px; }
.brainmap svg { display: block; max-height: 56vh; } /* taller, but viewport-relative so it never spills past the fold */
/* Overview's "Your brain" peek. */
#overviewBrainMap .brainmap svg { max-height: 51vh; }
#overviewBrainMap .brainmap { padding: 6px 8px 4px; }

/* Full-screen brain map modal (the ⛶ control). Fixed cover with an X; the map fills it. */
/* safe-area padding keeps the map + its ✕ clear of the notch / home indicator on phones */
.mapfull { position: fixed; inset: 0; z-index: 1000; background: var(--bg, #0a0c16); display: flex; flex-direction: column; padding: 14px; padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); }
.mapfull-x { position: absolute; top: 14px; right: 16px; top: max(14px, env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right)); z-index: 1001; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: rgba(20,22,38,0.9); color: var(--text); font-size: 18px; cursor: pointer; -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.mapfull-x:hover { border-color: var(--accent); color: var(--accent-2, #a9a2ff); }
.mapfull-body { flex: 1; min-height: 0; display: flex; position: relative; }
/* 70/30 split: the brain map is the hero (left), status/list is the sidebar (right). */
/* 70/30 split fills the panel's height (grid rows stretch); no fixed heights, so it fits any viewport. */
.page2col { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 3fr); gap: 18px;
  align-items: stretch; flex: 1 1 auto; min-height: 0; }
.col-main { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.col-side { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 12px; }
/* Overview sidebar scrolls as one unit if tall; the Brain sidebar keeps its list as the only scroll area. */
#view-overview .col-side { overflow-y: auto; padding-right: 2px; }
.col-side .stats { margin: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); } /* 2×2 tiles in the narrow column */
.col-side .secondary-card { margin: 0; }

/* The brain map is the HERO — a framed canvas the engine fills, sized by flex to the panel's height. */
.brainhero { position: relative; flex: 1 1 auto; min-height: 0; border-radius: 16px;
  overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow);
  background: radial-gradient(125% 120% at 50% 32%, #0e1422 0%, #090d16 52%, #06080d 100%); }
#brainMap.brainhero { margin: 0; }
#overviewBrainMap { position: absolute; inset: 0; } /* fills the .brainhero wrapper on the Overview */

/* Below 1000px the columns stack and the app is allowed to scroll normally again. */
@media (max-width: 1000px) {
  /* Below 1000px the whole page scrolls (main → overflow:visible). The document's own scrollbar showed
     up as a stray light strip against the dark UI the moment this mode kicked in. Hide the VIEWPORT
     bar's chrome only — scrolling (wheel/touch/keys) is unchanged, and inner panels/modals keep their
     themed thin scrollbars. */
  html { scrollbar-width: none; }
  html::-webkit-scrollbar { width: 0; height: 0; display: none; }
  .main { height: auto; overflow: visible; display: block; }
  .panelview.active { display: block; overflow: visible; }
  .page2col { display: block; }
  .brainhero { height: 66vh; height: 66dvh; } /* dvh: exclude the phone's collapsing address bar */
  #view-overview .col-side { overflow: visible; }
  /* The Brain sidebar stacks BELOW the map on mobile. Its memory list is an absolute-positioned
     fill region on desktop (memwrap flex-grows, #memoryScroll = inset:0). With the column now
     block-flow and height:auto that region collapses to ~0 (the list becomes unreachable). Undo the
     inline fill styling so the list flows at natural height and the PAGE scrolls to reach it. */
  .col-side { gap: 14px; }
  .col-side .memwrap { position: static !important; flex: none !important; min-height: 0 !important; }
  .col-side #memoryScroll { position: static !important; inset: auto !important; overflow: visible !important; padding: 4px 2px !important; }
  .col-side .memwrap::before, .col-side .memwrap::after { display: none; } /* scroll-fade gradients assume a fixed viewport */
}
.brainhero-open { position: absolute; top: 14px; left: 14px; z-index: 6; font-size: 13px;
  color: var(--accent-2, #a9a2ff); text-decoration: none; background: rgba(13,17,26,.72);
  padding: 5px 11px; border-radius: 8px; border: 1px solid var(--border); }
.brainhero-open:hover { border-color: var(--accent); }
.bm-legend { text-align: center; padding: 4px 0 6px; }
.bm-node text { paint-order: stroke; pointer-events: none; }
.bm-node:hover circle { filter: brightness(1.15); }
.bm-pulse { animation: bmpulse 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes bmpulse { 0%,100% { opacity: 0.25; } 50% { opacity: 0.9; } }
.brainmap-empty { display: flex; gap: 16px; align-items: center; border: 1px dashed var(--border); border-radius: var(--radius); padding: 22px; background: radial-gradient(360px 160px at 30% 50%, rgba(124,108,255,0.06), transparent 70%); }
.brainmap-empty .bm-core { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-size: 26px; background: var(--panel-2); border: 1px solid var(--accent); flex-shrink: 0; }
.concept-pill { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--accent); color: var(--accent-2); margin-left: 4px; }

/* ---- Memory view/edit "page" (Jira-style two-column modal) ---- */
.flexwrap { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--border); color: var(--text); }
.memv { display: flex; flex-direction: column; min-height: 0; }
.memv-head { display: flex; align-items: center; gap: 12px; padding-bottom: 14px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.memv-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.memv-title { font-size: 22px; line-height: 1.25; margin: 2px 0 0; word-break: break-word; }
.memv-titleinput { font-size: 20px; font-weight: 700; padding: 8px 12px; }
.memv .btn.icon-btn { font-size: 15px; }
/* Two columns: main content (title/body/sources) ~2fr, metadata sidebar ~1fr. */
.memv-cols { display: grid; grid-template-columns: minmax(0, 2.6fr) minmax(0, 1fr); gap: 26px; align-items: start; }
.memv-main { min-width: 0; }
.memv-side { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.memv-block { margin-bottom: 18px; }
.memv-lab { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); font-weight: 700; margin-bottom: 6px; }
/* Body is the focus — roomy, readable, wraps preserved. */
.memv-body { font-size: 15px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; padding: 16px 20px; min-height: 300px; }
/* Rendered-markdown memory bodies + layers ("rich text"): headings, tables, chips, quotes. The `md`
   class switches off pre-wrap (the renderer emits real block elements). */
.md { white-space: normal; }
.md .md-h { margin: 18px 0 8px; line-height: 1.3; letter-spacing: -.2px; }
.md .md-h:first-child { margin-top: 0; }
.md .md-h1 { font-size: 19px; } .md .md-h2 { font-size: 17px; } .md .md-h3, .md .md-h4, .md .md-h5, .md .md-h6 { font-size: 15px; }
.md .md-h2 { padding-bottom: 5px; border-bottom: 1px solid var(--border); }
.md .md-p { margin: 0 0 10px; }
.md .md-list { margin: 0 0 10px; padding-left: 22px; }
.md .md-list li { margin: 3px 0; }
.md .md-code { font-family: var(--mono); font-size: .92em; background: rgba(124,108,255,.10); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; }
.md .md-pre { background: #0a0c16; border: 1px solid var(--border); border-radius: 9px; padding: 12px 14px; overflow-x: auto; font-size: 13px; margin: 0 0 10px; }
.md .md-entity { color: var(--accent-2); background: rgba(56,189,248,.10); border: 1px solid rgba(56,189,248,.25); border-radius: 6px; padding: 0 6px; font-weight: 600; white-space: nowrap; }
.md .md-quote { margin: 0 0 10px; padding: 8px 14px; border-left: 3px solid var(--accent); background: rgba(124,108,255,.06); border-radius: 0 8px 8px 0; color: var(--muted); }
.md .md-hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.md .md-tablewrap { overflow-x: auto; margin: 0 0 12px; }
.md .md-table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.md .md-table th, .md .md-table td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
.md .md-table th { background: rgba(124,108,255,.08); font-weight: 700; }
.md .md-table tr:nth-child(even) td { background: rgba(255,255,255,.02); }
.md a { color: var(--accent-2); }
/* Retracted (superseded) layers: kept for audit, visibly struck. */
.memv-retracted .md { opacity: .55; text-decoration: line-through; }
.memv-retag { color: var(--warn); font-weight: 700; text-transform: uppercase; font-size: 10px; letter-spacing: .08em; margin-left: 6px; }
.memv-bodyedit { min-height: 260px; font-size: 15px; line-height: 1.6; }
.memv-metarow { display: flex; flex-direction: column; }
.memv-box { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.memv-secrow { display: block; padding: 8px 12px; border-top: 1px solid var(--border); }
.memv-secrow:first-child { border-top: none; }
.memv-seckey { color: var(--accent-2); font-family: var(--mono); word-break: break-word; margin-bottom: 2px; }
.memv-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
/* Clickable linked-memory pills (view mode) */
.linkpill { cursor: pointer; background: transparent; font: inherit; line-height: 1.5; transition: background 0.12s, color 0.12s; }
.linkpill:hover { background: var(--accent-soft); color: var(--text); }
/* Pill used for activity/tool breakdown on the benefits card */
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; color: var(--muted); white-space: nowrap; }
/* Edit-mode chip remove (×) + add-row controls for links/sources */
.chip-x { background: none; border: none; color: inherit; cursor: pointer; padding: 0; margin-left: 6px; font-size: 13px; line-height: 1; opacity: 0.6; }
.chip-x:hover { opacity: 1; color: var(--bad); }
.editadd { display: flex; gap: 8px; margin-top: 8px; }
.editadd input { flex: 1; min-width: 0; }
.editrow { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
@media (max-width: 720px) {
  .memv-cols { grid-template-columns: 1fr; gap: 18px; }
  .memv-side { flex-direction: row; flex-wrap: wrap; gap: 18px 28px; }
}

/* brain switcher (lives in the Brain(s) tab header) */
.brainswitch { display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; }
.brainswitch .bs-label { font-size: 14px; opacity: .9; }
.brainswitch select { background: var(--bg-2); border: 1px solid var(--border); border-radius: 7px; color: var(--text); font: inherit; font-size: 13px; font-weight: 600; padding: 5px 9px; width: 180px; cursor: pointer; transition: border-color .15s; text-overflow: ellipsis; }
.brainswitch select:disabled { cursor: default; opacity: .6; }
.brainswitch select:hover { border-color: var(--accent); }
.brainswitch select:focus { outline: none; border-color: var(--accent); }
/* readable dropdown options across browsers (dark popup, light text) */
.brainswitch select option { background: #1a1f33; color: var(--text); }
.brainlist { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; }
.brainrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; }
.brainrow-actions { display: flex; gap: 6px; flex-shrink: 0; }
.brain-new { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 4px; }

/* skills page cards */
.skillgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.skillcard { display: flex; gap: 14px; background: linear-gradient(180deg, var(--panel), var(--bg-2)); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; transition: border-color .2s, transform .2s; }
.skillcard:hover { border-color: var(--accent); transform: translateY(-2px); }
.skillicon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; background: var(--panel-2); border: 1px solid var(--border); flex-shrink: 0; }
.skillicon.sm { width: 34px; height: 34px; font-size: 17px; }
.skillhead { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.bggrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.bgcard { display: flex; gap: 10px; align-items: center; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }

/* package comparison banner */
.cmp { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.cmp.ok { border-color: rgba(74,222,128,0.4); background: rgba(74,222,128,0.08); }
.cmp.upd { border-color: rgba(251,191,36,0.4); background: rgba(251,191,36,0.08); }
.cmp.new { background: var(--panel); }
.cmp ul { padding-left: 18px; }

/* correction trend */
.qualcard { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin: 14px 0; }
.trendbars { display: flex; align-items: flex-end; gap: 6px; height: 42px; margin-top: 10px; }
.trendbars .tbar { flex: 1; background: linear-gradient(180deg, var(--accent-2), var(--accent)); border-radius: 3px 3px 0 0; min-height: 4px; }

/* brain entity overview */
.entgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.entcard { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; cursor: pointer; transition: all 0.15s; }
.entcard:hover { border-color: var(--accent); }
.entcard.sel { border-color: var(--accent); background: var(--accent-soft); }
.entcard .enttop { display: flex; align-items: center; justify-content: space-between; }
.entcard .enticon { font-size: 18px; }
.entcard .entcount { font-size: 24px; font-weight: 800; font-family: var(--mono); }
.entcard .entlabel { font-size: 13px; color: var(--muted); margin-top: 4px; }

.empty { text-align: center; padding: 40px 20px; color: var(--faint); }
.divider { height: 1px; background: var(--border); margin: 22px 0; }
.realvscoming { font-size: 12px; color: var(--faint); border: 1px dashed var(--border); border-radius: 9px; padding: 10px 12px; }

@media (max-width: 820px) {
  .topbar { padding: 11px 14px; gap: 10px; justify-content: flex-start; }
  .burger { display: inline-flex; }
  .nav-links { gap: 12px; margin-left: auto; } /* keep burger + logo left, Live + sign-out right */
  .so-text { display: none; } /* sign-out shows the icon only on mobile */

  /* Side nav becomes a burger-toggled drop-down overlay. */
  .app { grid-template-columns: 1fr; }
  .side {
    position: fixed; left: 0; right: 0; top: 53px; z-index: 30;
    padding: 10px 12px 14px; border-right: none; border-bottom: 1px solid var(--border);
    background: var(--panel-2); max-height: calc(100vh - 53px); max-height: calc(100dvh - 53px); overflow-y: auto;
    transform: translateY(-8px); opacity: 0; pointer-events: none;
    transition: opacity .16s ease, transform .16s ease; box-shadow: 0 14px 34px -14px rgba(0,0,0,.65);
  }
  .side.open { transform: none; opacity: 1; pointer-events: auto; }
  .side a { padding: 13px; } /* taller touch targets */
  .appver { margin-top: 8px; }

  .main { padding: 16px 14px; }
  .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
  .hero h1 { font-size: 38px; }
  .brainmap svg { max-height: 46vh; }
  #overviewBrainMap .brainmap svg { max-height: 48vh; }
  .bm-zoomctl button { width: 38px; height: 38px; } /* bigger touch targets */

  /* Keep the brain switcher + its controls on ONE line; let the select shrink rather than wrap. */
  .brainswitch { margin: 0 !important; min-width: 0; flex-wrap: nowrap; }
  .brainswitch select { width: auto; min-width: 0; flex: 1 1 auto; }
  /* The Engram logo already IS a brain — the decorative 🧠 next to the switcher reads as a duplicate
     icon on small screens. Hide it for the whole burger-mode range. */
  .topbar-bs .bs-label { display: none; }
}

/* Connector-guide label ("Name", "Remote MCP server URL", …) — a fixed-width inline label on
   desktop so values align in a column; stacked on its own line on mobile (see media query below). */
.cw-label { color: var(--muted, #9aa0bd); display: inline-block; min-width: 200px; padding-right: 14px; }

/* Phone-width topbar: burger + logo + brainswitch + refresh/Live/sign-out don't all fit — the
   "Engram" wordmark was getting cropped to "En" on views that show the switcher. Collapse to
   icon-only branding, drop the decorative 🧠, and cap the select so nothing clips. */
@media (max-width: 600px) {
  .topbar-left { gap: 8px; }
  .brand .brand-name { display: none; }
  .topbar-bs { padding: 3px 4px; }
  .topbar-bs .bs-label { display: none; }
  .topbar-bs select { max-width: 34vw; }

  /* Connector guide on a phone: the 200px label column + a long MCP URL can't share a ~240px grid
     cell — the URL ran UNDER the Copy button. Stack the label above the value and let long
     URLs/keys break anywhere. */
  .cw-label { display: block; min-width: 0; padding-right: 0; margin-bottom: 2px; }
  .modal code { word-break: break-all; overflow-wrap: anywhere; }

  /* Settings connection table: two fixed columns don't fit — stack each row's cells. */
  .conntable, .conntable tbody { display: block; }
  .conntable tr { display: block; padding: 7px 0; border-bottom: 1px solid var(--border); }
  .conntable td { display: block; width: auto !important; border-bottom: none; padding: 2px 0; }
}
