/* ============================================================================
   ocellio — brand design system. One hand-written sheet, no framework, no
   @import, no external CDN (CSP: default-src 'none'; style/script/font 'self').
   OCELLIO brand kit — navy #102A43 · vivid purple #A05CFF · teal #4FD1C5 ·
   light grey #E4E7EB. Light (default) / dark, both on the brand palette.
   Display/wordmark = Sora · body = Hanken Grotesk · data = monospace.
   Fonts are self-hosted under ./fonts/ (relative → resolves under /assets/<v>/).
   ============================================================================ */

@font-face { font-family: "Sora"; font-style: normal; font-weight: 600; font-display: swap;
  src: url(fonts/sora-600.woff2) format("woff2"); }
@font-face { font-family: "Sora"; font-style: normal; font-weight: 700; font-display: swap;
  src: url(fonts/sora-700.woff2) format("woff2"); }
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(fonts/hanken-400.woff2) format("woff2"); }
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 500; font-display: swap;
  src: url(fonts/hanken-500.woff2) format("woff2"); }
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 600; font-display: swap;
  src: url(fonts/hanken-600.woff2) format("woff2"); }

:root {
  /* brand constants (theme-independent) */
  --purple: #a05cff; --teal-vivid: #4fd1c5; --navy: #102a43;
  --brand-grad: linear-gradient(135deg, #a05cff 0%, #4fd1c5 100%);

  /* light (default) */
  --ink:    #eceff3;   /* page */
  --panel:  #ffffff;   /* surfaces */
  --raised: #f4f7fb;   /* hover / inputs */
  --line:   #dbe1e9;   /* hairlines */
  --fg:     #102a43;   /* navy ink */
  --muted:  #566679;
  --faint:  #6b7888;
  --accent: #7a3df0;   /* brand purple, contrast-tuned on white */
  --accent-hi: #6a2fd6;
  --on-accent: #ffffff;
  --teal:   #168a7f;   /* teal that reads as text on light */
  --danger: #d8453a;
  --ok:     #168a7f;
  --glow:   rgba(160,92,255,0.12);

  --font-display: "Sora", ui-sans-serif, system-ui, sans-serif;
  --font-sans: "Hanken Grotesk", ui-sans-serif, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, monospace;

  --r: 12px; --r-sm: 7px;
  --maxw: 1120px;
  --shadow: 0 14px 40px -18px rgba(16,42,67,0.28);
}

:root[data-theme="dark"] {
  --ink:    #081320;   /* deep navy-black */
  --panel:  #0f2740;
  --raised: #16344f;
  --line:   #26466a;
  --fg:     #e7eef6;
  --muted:  #93a7bd;
  --faint:  #7e98b5;
  --accent: #a05cff;   /* vivid brand purple pops on navy */
  --accent-hi: #b685ff;
  --on-accent: #15052e; /* dark ink on the lighter purple = readable button text */
  --teal:   #4fd1c5;
  --danger: #ff6b5c;
  --ok:     #4fd1c5;
  --glow:   rgba(160,92,255,0.16);
  --shadow: 0 16px 44px -18px rgba(0,0,0,0.55);
}

* { box-sizing: border-box; }
* > * { min-width: 0; }

html { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--fg);
  background: var(--ink);
  /* atmosphere: a soft two-point brand mesh (purple top-right, teal bottom-left) */
  background-image:
    radial-gradient(820px 460px at 90% -12%, color-mix(in oklab, var(--purple) 16%, transparent), transparent 62%),
    radial-gradient(760px 460px at -10% 112%, color-mix(in oklab, var(--teal-vivid) 14%, transparent), transparent 62%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hi); }

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.12;
  letter-spacing: -0.015em; }
h1 { font-size: clamp(1.9rem, 1.3rem + 1.8vw, 2.6rem); margin: 0 0 6px; font-weight: 700; }
h2 { font-size: 1.32rem; margin: 34px 0 12px; font-weight: 600; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; }
code, pre, .mono { font-family: var(--font-mono); }

main { max-width: var(--maxw); margin: 0 auto; padding: 40px 22px 96px;
  animation: rise 0.5s cubic-bezier(.2,.7,.2,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { main { animation: none; } }

/* ---- top bar ------------------------------------------------------------ */
.nav {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  padding: 0 22px; height: 56px;
  background: color-mix(in oklab, var(--panel) 86%, transparent);
  backdrop-filter: saturate(1.3) blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.nav > a {
  color: var(--muted); font-size: 0.9rem; padding: 7px 11px; border-radius: var(--r-sm);
  letter-spacing: 0.01em; transition: color .15s, background .15s;
}
.nav > a:hover { color: var(--fg); background: var(--raised); }
.nav .brand { display: flex; align-items: center; gap: 9px; margin-right: 12px;
  padding: 4px 6px 4px 0; text-decoration: none; }
.nav .brand:hover { background: transparent; }
.nav .brand-mark { width: 27px; height: 27px; display: block; flex: none; }
.nav .brand-word { font-family: var(--font-display); font-weight: 700; font-size: 1.14rem;
  color: var(--fg); letter-spacing: -0.02em; transition: color .15s; }
.nav .brand:hover .brand-word { color: var(--accent); }
.nav-controls { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.ctrl-btn {
  background: transparent; color: var(--muted); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 6px 12px; cursor: pointer; font: inherit;
  font-size: 0.82rem; transition: all .15s;
}
.ctrl-btn:hover { color: var(--fg); border-color: var(--accent); }
.nav-logout { display: inline; }

/* ---- flash + show-once token ------------------------------------------- */
.flash {
  max-width: var(--maxw); margin: 18px auto -8px; padding: 11px 16px;
  background: color-mix(in oklab, var(--ok) 14%, var(--panel));
  border: 1px solid color-mix(in oklab, var(--ok) 50%, var(--line));
  border-left: 3px solid var(--ok); border-radius: var(--r-sm); color: var(--fg);
}
.token-box {
  max-width: var(--maxw); margin: 18px auto -8px; padding: 14px 16px;
  background: var(--glow); border: 1px solid var(--accent); border-radius: var(--r);
}
.token-once { display: block; margin-top: 8px; font-family: var(--font-mono);
  font-size: 0.92rem; word-break: break-all; user-select: all; color: var(--accent-hi); }

/* ---- buttons + forms ---------------------------------------------------- */
button, .btn {
  font: inherit; font-size: 0.9rem; font-weight: 500; cursor: pointer;
  background: var(--accent); color: var(--on-accent); border: 1px solid transparent;
  border-radius: var(--r-sm); padding: 8px 16px; transition: transform .08s, filter .15s, background .15s;
}
button:hover, .btn:hover { filter: brightness(1.06); }
button:active, .btn:active { transform: translateY(1px); }
.ctrl-btn, .nav button { font-weight: 400; }
input, select, textarea {
  font: inherit; color: var(--fg); background: var(--raised);
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 9px 11px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 28%, transparent);
}
::placeholder { color: var(--faint); }
fieldset { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 14px; }
legend { color: var(--muted); font-size: 0.78rem; padding: 0 6px; text-transform: uppercase;
  letter-spacing: 0.08em; }

/* ---- auth card (login / bootstrap) — the first impression ---------------- */
.auth-card {
  max-width: 408px; margin: 11vh auto 0; padding: 38px 36px 34px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px;
  position: relative; overflow: hidden; text-align: center;
  animation: rise 0.55s cubic-bezier(.2,.7,.2,1) both;
}
.auth-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--brand-grad);
}
.auth-mark { width: 66px; height: 66px; margin: 2px auto 0; display: block; }
.auth-card h1 { font-size: 2.5rem; margin: -4px 0 0; letter-spacing: -0.03em; color: var(--fg); }
/* Gradient wordmark only where text-clip is supported; otherwise the base rule
   above keeps it a solid, readable navy/off-white (no invisible-text risk). */
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .auth-card h1 { background: var(--brand-grad); -webkit-background-clip: text;
    background-clip: text; -webkit-text-fill-color: transparent; color: transparent; }
}
.auth-card input { padding: 11px 13px; }
.auth-card button[type="submit"], .auth-card #login-btn, .auth-card #bootstrap-btn,
.auth-card #enroll-btn, .auth-card #enroll-continue, .auth-card #passkey-auth {
  padding: 11px; font-size: 0.95rem; margin-top: 4px;
}
/* v1 'initial' mode: the token form IS the login box content */
.auth-card .token-login {
  display: flex; flex-direction: column; gap: 10px; text-align: left;
  margin-top: 4px;
}
.auth-card .token-login label { font-size: 0.82rem; }
/* v1 'passkey' confirm mode: ghost Cancel below the confirm button */
.auth-card .cancel-login { margin-top: 8px; }
.auth-card .cancel-login .btn-ghost {
  width: 100%; padding: 10px; background: transparent; color: var(--muted);
  border: 1px solid var(--line); border-radius: var(--r-sm); cursor: pointer;
}
.auth-card .cancel-login .btn-ghost:hover { color: var(--fg); border-color: var(--muted); }
.auth-card .info {
  color: var(--muted); font-size: 0.88rem; background: var(--raised);
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px;
}
/* one-time token reveal after first-passkey enrollment */
.auth-card #token-reveal { display: flex; flex-direction: column; gap: 10px; }
.auth-card #token-reveal[hidden] { display: none; }
.auth-card #new-token {
  background: var(--glow); border: 1px dashed var(--accent);
  border-radius: var(--r-sm); padding: 10px 12px; margin-top: 0;
}

/* ---- context chips / filter bars ---------------------------------------- */
.contexts { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.contexts a {
  padding: 5px 13px; border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted); font-size: 0.82rem; transition: all .15s;
}
.contexts a:hover { border-color: var(--accent); color: var(--fg); }
.contexts a.active { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
.search, .filter-bar, .share-form, .token-create form {
  display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0; align-items: flex-end;
}
.search input, .filter-bar input[name="q"] { flex: 1 1 260px; }

/* ---- tables — editorial hairline rules ---------------------------------- */
table { width: 100%; border-collapse: collapse; margin: 10px 0; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line);
  vertical-align: top; }
th { color: var(--faint); font-weight: 600; font-size: 0.7rem; text-transform: uppercase;
  letter-spacing: 0.1em; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: color-mix(in oklab, var(--accent) 6%, transparent); }
td code { font-size: 0.85rem; color: var(--teal); }

/* ---- kind badge --------------------------------------------------------- */
.kind { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.74rem;
  font-family: var(--font-mono); letter-spacing: 0.02em;
  background: color-mix(in oklab, var(--teal) 16%, transparent);
  border: 1px solid color-mix(in oklab, var(--teal) 40%, transparent); color: var(--teal); }

/* ---- entity detail (v1 layout: breadcrumb, badge row, two-column grid) -- */
.breadcrumb { font-size: 0.8rem; color: var(--muted); margin-bottom: 10px;
  overflow-wrap: anywhere; word-break: break-all; }
.breadcrumb .mono { font-family: var(--font-mono); }
.entity-title { overflow-wrap: anywhere; word-wrap: break-word; }
.badge-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  margin: 4px 0 6px; max-width: 100%; color: var(--muted); font-size: 0.85rem; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 0.74rem; color: var(--muted); border: 1px solid var(--line); }
.tag.mono { font-family: var(--font-mono); }
/* v1 .grid: content left, share + connections right; collapses on mobile.
   min-width:0 on children — grid items default to min-width:auto and overflow. */
.grid { display: grid; grid-template-columns: 1fr minmax(280px, 380px);
  gap: 26px; margin-top: 14px; }
.grid > * { min-width: 0; }
@media (max-width: 860px) { .grid { grid-template-columns: 1fr; gap: 0; } }
.card { background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); padding: 16px; margin-bottom: 22px;
  overflow-wrap: anywhere; max-width: 100%; }
.card pre { margin: 0; }
.connection-row { padding: 7px 0; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px; font-size: 0.85rem; }
.connection-row:last-child { border-bottom: none; }
.connection-relation { font-family: var(--font-mono); font-size: 0.69rem;
  color: var(--muted); text-transform: uppercase; min-width: 120px; }
.connection-peer { flex: 1; overflow-wrap: anywhere; }
.secret-flag { color: var(--danger); border: 1px solid var(--danger);
  padding: 1px 9px; border-radius: 999px; font-size: 0.74rem; }
pre {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  border-left: 3px solid color-mix(in oklab, var(--accent) 60%, var(--line));
  padding: 16px; overflow: auto; white-space: pre-wrap; word-break: break-word;
  font-size: 0.88rem; line-height: 1.55;
}
.markdown-body pre.plain { font-family: var(--font-sans); font-size: 1rem; line-height: 1.72;
  border-left-color: var(--accent); }

/* ---- badges / misc ------------------------------------------------------ */
.badge-current { background: var(--glow); border: 1px solid var(--accent);
  color: var(--accent-hi); padding: 2px 10px; border-radius: 999px; font-size: 0.76rem; }
.signout-device { margin-top: 22px; }
/* CSP-clean utilities (no inline style= — style-src 'self' forbids it) */
.inline-form { display: inline; }
.pager { margin-top: 16px; }
td.ua { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--muted); font-family: var(--font-mono); font-size: 0.8rem; }
.token-create label { display: flex; flex-direction: column; gap: 5px; font-size: 0.82rem;
  color: var(--muted); }
.token-create .chk { flex-direction: row; align-items: center; gap: 6px; color: var(--fg); }
.share-result { color: var(--ok); word-break: break-all; }

/* ---- inline entity share (step-up + 3 format variants) ------------------ */
.share-card { background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); padding: 16px; }
.share-card .muted { margin: 0 0 12px; font-size: 0.85rem; }
/* [hidden] must win even though sibling rules set display (UA specificity tie). */
#share-status[hidden], #share-result[hidden], #share-error[hidden] { display: none; }
#share-status { margin: 12px 0 0; font-size: 0.85rem; }
#share-error.alert-danger { margin-top: 14px; padding: 12px 14px; color: var(--fg);
  background: color-mix(in oklab, var(--danger) 14%, var(--panel));
  border: 1px solid color-mix(in oklab, var(--danger) 50%, var(--line));
  border-left: 3px solid var(--danger); border-radius: var(--r-sm); }
.share-success { margin-top: 14px; padding: 12px 14px;
  background: color-mix(in oklab, var(--ok) 14%, var(--panel));
  border: 1px solid color-mix(in oklab, var(--ok) 50%, var(--line));
  border-left: 3px solid var(--ok); border-radius: var(--r-sm); }
.share-success > strong { display: block; }
.share-note { margin: 6px 0 12px; font-size: 0.82rem; }
.share-expiry { margin: 12px 0 0; font-size: 0.77rem; }
.share-link-row { margin: 10px 0; }
.share-link-row-label strong { font-size: 0.85rem; }
.share-link-row-label span { color: var(--muted); font-size: 0.78rem; margin-left: 8px; }
.share-link-box { display: flex; align-items: center; gap: 8px; margin-top: 4px;
  background: var(--raised); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 6px 8px; }
.share-link-url { flex: 1; font-family: var(--font-mono); font-size: 0.8rem;
  word-break: break-all; user-select: all; color: var(--fg); }
.share-copy-btn { flex: none; font-size: 0.78rem; padding: 5px 12px;
  background: var(--raised); color: var(--fg); border: 1px solid var(--line); }
.share-copy-btn:hover { border-color: var(--accent); filter: none; }
.share-copy-btn.copied { background: var(--glow); color: var(--accent-hi);
  border-color: var(--accent); }
.share-copy-btn.copied::before { content: "✓ "; }   /* v1 parity: checkmark prefix */

/* ---- graph view — v1 parity (plexus src/ui/pages/graph.ts) --------------
   v1's headExtra viewport lock + inline style= attributes ported to classes
   (strict CSP forbids both); v1 --color-* mapped like the other blocks:
   page→panel, surface→raised, border→line, ink/body→fg, subtle/light→faint. */
body.graph-page { height: 100vh; margin: 0; display: flex; flex-direction: column;
  overflow: hidden; }
body.graph-page .nav { flex-shrink: 0; }
body.graph-page main { flex: 1; overflow: hidden; padding: 0; min-height: 0;
  max-width: none; margin: 0; display: flex; flex-direction: column; animation: none; }
.graph-layout { display: flex; gap: 0; flex: 1; min-height: 0; }
#graph-legend { width: 150px; flex-shrink: 0; padding: 0.62rem 0.77rem;
  background: var(--raised); border-right: 1px solid var(--line); overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px; }
.graph-legend-title { font-size: 0.77rem; font-weight: 700; color: var(--fg);
  margin-bottom: 6px; }
.graph-context-section { margin-bottom: 8px; }
.graph-micro-label { font-size: 0.62rem; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--faint); margin-bottom: 2px; }
#graph-context-filter { width: 100%; padding: 3px 6px; font-size: 0.77rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-sm);
  color: var(--fg); cursor: pointer; }
.graph-kind-row { display: flex; align-items: center; gap: 4px; cursor: pointer;
  white-space: nowrap; }
.graph-kind-row input[type="checkbox"] { margin: 0; }
.graph-kind-row span { font-size: 0.69rem; color: var(--muted); }
/* v1 inlines accent-color per kind on each legend checkbox (TYPE_COLORS) */
.kf-concept { accent-color: #4a7a9b; }    .kf-fact { accent-color: #7a4a9b; }
.kf-decision { accent-color: #9b7a4a; }   .kf-template { accent-color: #4a9b7a; }
.kf-secret { accent-color: #9b4a4a; }     .kf-config { accent-color: #6b7a9b; }
.kf-project { accent-color: #4a7a4a; }    .kf-task { accent-color: #9b9b4a; }
.kf-document { accent-color: #5a6a8a; }   .kf-note { accent-color: #8a8a5a; }
.kf-inbox_item { accent-color: #7a8a9a; } .kf-user { accent-color: #9a7a7a; }
.kf-tag { accent-color: #7a9a8a; }        .kf-skill { accent-color: #c97a3a; }
.graph-meta-section { margin-top: 10px; padding-top: 6px;
  border-top: 1px solid var(--line); }
.graph-meta-section .graph-micro-label { margin-bottom: 4px; }
#graph-meta { display: flex; flex-direction: column; gap: 2px; }
.graph-meta-row { display: flex; justify-content: space-between; font-size: 0.62rem;
  color: var(--muted); line-height: 1.4; }
.graph-meta-value { font-family: var(--font-mono); }
.graph-meta-orphans { color: #c08080; }
.graph-meta-cut { color: var(--faint); }
#graph-container { position: relative; flex: 1; background: var(--raised);
  overflow: hidden; }
#graph-tooltip { position: absolute; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 12px;
  font-size: 0.77rem; color: var(--fg); box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 50; pointer-events: none; max-width: 240px; display: none; }
.graph-tip-strong { font-weight: 600; margin-bottom: 2px; }
.graph-tip-sub { font-size: 0.69rem; color: var(--faint); }
.graph-tip-sub-mt { font-size: 0.69rem; color: var(--faint); margin-top: 2px; }
.graph-msg { padding: 2rem; color: var(--faint); text-align: center; }
.graph-msg-center { position: absolute; inset: 0; display: flex;
  align-items: center; justify-content: center; }

/* ---- error / shared (public) pages -------------------------------------- */
.error-page h1 { font-family: var(--font-display); font-size: 4rem; color: var(--faint); }
.shared { max-width: 760px; margin: 8vh auto 0; }
.shared .kind { margin: 6px 0; }
body.public { background-attachment: fixed; }

/* ---- OAuth consent (nav-less focused modal) ----------------------------- */
main.consent { max-width: 520px; margin: 7vh auto 0; padding: 0 22px 80px; }
.consent-mark { width: 54px; height: 54px; display: block; margin-bottom: 14px; }
.consent-eyebrow { font-size: 0.69rem; color: var(--faint); text-transform: uppercase;
  letter-spacing: 0.12em; margin: 0 0 6px; }
.consent h1 { font-size: 1.9rem; margin: 0 0 6px; }
.consent-card { background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); padding: 16px 18px; margin: 16px 0; }
.consent-card p { margin: 0 0 4px; }
.consent-card p:last-child { margin-bottom: 0; }
.consent-strong { font-weight: 600; font-size: 1rem; color: var(--fg); }
.consent-scope { list-style: none; margin: 0 0 8px; padding: 0; }
.consent-scope li { padding: 3px 0 3px 22px; position: relative; color: var(--fg); }
.consent-scope li::before { content: "✓"; position: absolute; left: 0; color: var(--teal);
  font-weight: 700; }
.consent-actions { display: flex; flex-direction: column; gap: 10px; margin: 22px 0 0; }
.consent-actions button { padding: 12px; font-size: 0.95rem; }
.btn-ghost { background: transparent; color: var(--fg); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--raised); filter: none; border-color: var(--accent); }
.consent-foot { font-size: 0.8rem; margin-top: 18px; }

/* ---- ⌘K command palette ------------------------------------------------- */
.cmdk-backdrop { position: fixed; inset: 0; background: color-mix(in oklab, var(--ink) 70%, transparent);
  backdrop-filter: blur(3px); display: flex; align-items: flex-start; justify-content: center;
  padding-top: 13vh; z-index: 60; }
/* The class above sets display unconditionally, which ties the UA [hidden] rule on
   specificity (author wins) → the overlay would stay permanently visible and block
   the page. This higher-specificity guard restores the `hidden` attribute toggle. */
.cmdk-backdrop[hidden] { display: none; }
.cmdk-modal { width: min(640px, 92vw); background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow);
  animation: rise 0.18s ease both; }
#cmdk-input { width: 100%; box-sizing: border-box; padding: 17px 18px; border: 0;
  border-bottom: 1px solid var(--line); background: transparent; color: var(--fg);
  font-size: 1.02rem; font-family: var(--font-display); }
#cmdk-input:focus { outline: none; box-shadow: none; }
.cmdk-results { list-style: none; margin: 0; padding: 6px; max-height: 52vh; overflow: auto; }
.cmdk-row { display: flex; flex-direction: column; gap: 1px; padding: 9px 13px;
  border-radius: var(--r-sm); color: var(--fg); text-decoration: none; }
.cmdk-row.active { background: var(--glow); }
.cmdk-title { font-weight: 600; }
.cmdk-meta { font-size: 0.76rem; color: var(--muted); font-family: var(--font-mono); }
.cmdk-snip { font-size: 0.82rem; color: var(--muted); }
.cmdk-foot { padding: 9px 15px; border-top: 1px solid var(--line); color: var(--faint);
  font-size: 0.73rem; font-family: var(--font-mono); }

/* ---- dashboard — v1 home parity (plexus src/ui/pages/home.ts + styles.ts).
   v1's inline style= attributes are ported into these classes (CSP forbids
   inline styles); values map v1 --color-* onto the ocellio palette:
   page→panel, surface→raised, border/divider/ghost→line, ink→fg,
   subtle/light→faint. --------------------------------------------------- */
.dash-title { margin-bottom: 0.62rem; }
.ctx-filter-bar { display: flex; align-items: center; gap: 0.62rem;
  margin-bottom: 0.77rem; flex-wrap: wrap; }
.badge { font-size: 0.77rem; font-weight: 600; padding: 0.23rem 0.69rem;
  border-radius: var(--r-sm); display: inline-block; letter-spacing: 0.04em; }
.badge-dev { background: #e8ede9; color: #4a6b50; }
.badge-bemodi { background: #f0e8e8; color: #6b4a4a; }
.badge-ifp-labs { background: #e8edf2; color: #4a5f6b; }
.badge-musik { background: #ece8f2; color: #5f4a6b; }
.badge-privat { background: #ececec; color: #666; }
.badge-status { font-size: 0.77rem; padding: 0.23rem 0.69rem;
  border-radius: var(--r-sm); margin-left: 0.46rem; }
.badge-active { background: var(--glow); color: var(--accent-hi); }
.badge-ctx-plain { color: var(--faint); border: 1px solid var(--line); }
.badge-ctx-active { outline: 2px solid var(--fg); outline-offset: 1px; }
.bento-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1.85rem;
  margin-top: 1.23rem; }
.bento-grid h2 { font-size: 0.69rem; font-weight: 700; margin: 0 0 0.77rem;
  font-family: var(--font-sans); color: var(--faint); text-transform: uppercase;
  letter-spacing: 0.1em; }
.bento-grid .h2-followup { margin-top: 1.23rem; }
.bento-projects { display: flex; flex-direction: column; gap: 0.46rem; }
.bento-sidebar { display: flex; flex-direction: column; gap: 1.23rem; }
.bento-tile { background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 0.77rem 1rem; margin-bottom: 0.46rem;
  transition: background 0.12s; }
.bento-tile:hover { background: var(--raised); }
.tile-link, .tile-link:hover { text-decoration: none; color: inherit; }
.tile-row { display: flex; align-items: center; gap: 10px; }
.mini-ring { flex-shrink: 0; }
.mini-ring-track { stroke: var(--line); }
.mini-ring-text { font-family: var(--font-mono); }
.tile-main { flex: 1; min-width: 0; }
.tile-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tile-title { font-weight: 600; font-size: 0.92rem; color: var(--fg); }
.tile-excerpt { font-size: 0.85rem; color: var(--muted); margin: 2px 0 0; }
.tile-score { text-align: right; flex-shrink: 0; }
.tile-score-pt { font-family: var(--font-mono); font-size: 0.77rem;
  font-weight: 600; color: var(--muted); }
.tile-score-window { font-family: var(--font-mono); font-size: 0.69rem;
  color: var(--faint); }
.tile-meta-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-bottom: 3px; }
.tile-date { margin-left: auto; font-family: var(--font-mono); font-size: 0.69rem;
  color: var(--faint); }
.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-list li { padding: 0.46rem 0; border-bottom: 1px solid var(--line);
  font-size: 0.92rem; color: var(--muted); display: flex; gap: 0.31rem;
  align-items: baseline; flex-wrap: wrap; }
.activity-list time { font-family: var(--font-mono); font-size: 0.77rem;
  color: var(--faint); margin-right: 0.62rem; flex-shrink: 0; }
.act-sep { color: var(--muted); margin: 0 0.31rem; }
.act-target { font-size: 0.85rem; }
.act-link, .act-link:hover { color: inherit; text-decoration: underline;
  text-decoration-color: var(--line); }
.usage-widget { display: flex; gap: 1.23rem; padding: 0.77rem 1.23rem;
  font-size: 0.85rem; color: var(--muted); background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  margin: 1.85rem 0 1.23rem; flex-wrap: wrap; align-items: center; }
.usage-count { white-space: nowrap; }
.usage-count strong { font-family: var(--font-mono); color: var(--fg);
  font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; }
.usage-sep { color: var(--line); }
.truncate-2 { display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden; }
.empty { color: var(--faint); font-size: 0.92rem; padding: 1.23rem 0; }
@media (max-width: 1023px) { .bento-grid { grid-template-columns: 1fr; gap: 1.23rem; } }
@media (max-width: 640px) { .usage-widget { gap: 0.77rem; padding: 0.62rem 0.92rem; } }

/* ---- entities browser — v1 parity (plexus src/ui/pages/entities.ts +
   styles.ts .filter-bar*, .filter-result-count, .entity-grid, .entity-card*).
   v1 --color-* mapped like the dashboard block: page→panel, surface→raised,
   border/ghost→line, ink/body→fg, mid→muted, subtle/light→faint. ---------- */
.subtitle { color: var(--muted); font-size: 0.92rem; margin-bottom: 1.23rem; }
.filter-bar { align-items: center; gap: 0.62rem; padding: 0.77rem 0.92rem;
  background: var(--raised); border: 1px solid var(--line);
  border-radius: var(--r); margin: 0 0 1.54rem; }
/* v1 inlines these icons as data: URIs; ocellio ships them as origin-local
   assets under icons/ (relative → /assets/<v>/, like the fonts) — the strict
   CSP/no-embed rules forbid embedded URIs, the rendered result is identical. */
.filter-bar select { appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background-color: var(--panel);
  background-image: url(icons/chevron.svg);
  background-repeat: no-repeat; background-position: right 0.69rem center;
  background-size: 12px; border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 0.46rem 2.15rem 0.46rem 0.77rem; color: var(--fg); font-size: 0.85rem;
  cursor: pointer; transition: border-color 0.12s, background-color 0.12s;
  min-width: 150px; }
.filter-bar select:hover { border-color: var(--muted); background-color: var(--raised); }
.filter-bar select:focus { outline: none; border-color: var(--fg);
  background-color: var(--panel); box-shadow: none; }
.filter-bar .btn { padding: 0.46rem 0.92rem; font-size: 0.85rem; }
.filter-bar-search { flex: 1 1 260px; min-width: 200px;
  padding: 0.46rem 0.77rem 0.46rem 2.15rem;
  background-color: var(--panel);
  background-image: url(icons/search.svg);
  background-repeat: no-repeat; background-position: left 0.69rem center;
  background-size: 14px; border: 1px solid var(--line); border-radius: var(--r-sm);
  color: var(--fg); font-size: 0.92rem;
  transition: border-color 0.12s, background-color 0.12s; }
.filter-bar-search::placeholder { color: var(--faint); }
.filter-bar-search:hover { border-color: var(--muted); }
.filter-bar-search:focus { outline: none; border-color: var(--fg);
  background-color: var(--panel); box-shadow: none; }
.filter-bar-search::-webkit-search-cancel-button { -webkit-appearance: none;
  height: 14px; width: 14px;
  background-image: url(icons/clear.svg);
  background-repeat: no-repeat; background-position: center; cursor: pointer;
  opacity: 0.6; }
.filter-bar-search::-webkit-search-cancel-button:hover { opacity: 1; }
.filter-bar-check { display: inline-flex; align-items: center; gap: 0.38rem;
  padding: 0.46rem 0.77rem; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-sm); font-size: 0.85rem; color: var(--fg); cursor: pointer;
  user-select: none; transition: border-color 0.12s, background-color 0.12s; }
.filter-bar-check:hover { border-color: var(--muted); }
.filter-bar-check input[type="checkbox"] { appearance: none; -webkit-appearance: none;
  width: 14px; height: 14px; padding: 0; border: 1.5px solid var(--line);
  border-radius: 0.23rem; background: var(--panel); cursor: pointer;
  position: relative; transition: all 0.12s; flex-shrink: 0; }
.filter-bar-check input[type="checkbox"]:checked { background: var(--fg);
  border-color: var(--fg); }
.filter-bar-check input[type="checkbox"]:checked::after { content: '';
  position: absolute; left: 3px; top: 0; width: 4px; height: 8px;
  border: solid var(--panel); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
.filter-result-count { font-size: 0.85rem; color: var(--muted);
  margin-bottom: 0.77rem; padding: 0 0.23rem; }
.filter-result-count strong { color: var(--fg); font-weight: 600;
  font-family: var(--font-mono); font-size: 0.85rem; }
.badge-archived { background: var(--raised); color: var(--muted); }
.entity-grid { display: grid;
  grid-template-columns: repeat(auto-fill, minmax(440px, 1fr));
  gap: 1rem; margin-top: 0.46rem; }
.entity-card { display: flex; flex-direction: column; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 1.08rem 1.23rem 1rem; text-decoration: none; color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  min-height: 172px; }
.entity-card:hover { text-decoration: none; color: inherit;
  border-color: var(--muted); box-shadow: 0 6px 20px rgba(0,0,0,0.05);
  transform: translateY(-1px); }
:root[data-theme="dark"] .entity-card:hover { box-shadow: 0 6px 20px rgba(0,0,0,0.3); }
.entity-card-head { display: flex; align-items: center; gap: 0.46rem;
  flex-wrap: wrap; margin-bottom: 0.69rem; }
.entity-card-time { margin-left: auto; font-family: var(--font-mono);
  font-size: 0.69rem; color: var(--faint); white-space: nowrap; }
.entity-card-title { font-size: 1.04rem; font-weight: 600; color: var(--fg);
  line-height: 1.35; letter-spacing: -0.005em; margin-bottom: 0.54rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; }
.entity-card-body { font-size: 0.88rem; color: var(--muted); line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; flex: 1; }
/* search highlights — subtle accent so matched tokens stand out (v1) */
.entity-card-title mark { background: #fff3b8; color: inherit; padding: 0 0.15rem;
  border-radius: 0.15rem; }
:root[data-theme="dark"] .entity-card-title mark { background: #5a4a1e; color: #f5e8b0; }
@media (max-width: 640px) {
  .entity-grid { grid-template-columns: 1fr; gap: 0.77rem; }
  .entity-card { min-height: auto; padding: 0.92rem 1rem; }
  .filter-bar { padding: 0.62rem 0.77rem; gap: 0.46rem; }
  .filter-bar select { min-width: 0; flex: 1 1 140px; }
}
@media (min-width: 641px) and (max-width: 1023px) {
  .entity-grid { grid-template-columns: repeat(2, 1fr); }
}

/* --- markdown-rendered bodies (S4 entity_detail + shared_entity) --- */
.markdown-body { line-height: 1.6; }
.markdown-body > :first-child { margin-top: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { line-height: 1.25; margin: 1.4em 0 .5em; }
.markdown-body h1 { font-size: 1.5rem; }
.markdown-body h2 { font-size: 1.25rem; }
.markdown-body h3 { font-size: 1.1rem; }
.markdown-body p { margin: .6em 0; }
.markdown-body ul, .markdown-body ol { margin: .6em 0; padding-left: 1.4em; }
.markdown-body li { margin: .2em 0; }
.markdown-body a { color: var(--purple, #a05cff); text-decoration: underline; }
.markdown-body code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; background: rgba(127,127,127,.14); padding: .1em .35em; border-radius: 4px; }
.markdown-body pre { background: rgba(127,127,127,.12); padding: .8em 1em; border-radius: 8px; overflow-x: auto; }
.markdown-body pre code { background: none; padding: 0; }
.markdown-body blockquote { margin: .6em 0; padding: .2em 1em; border-left: 3px solid rgba(127,127,127,.4); color: var(--faint, #6b7a8d); }
.markdown-body table { border-collapse: collapse; margin: .8em 0; }
.markdown-body th, .markdown-body td { border: 1px solid rgba(127,127,127,.3); padding: .35em .7em; text-align: left; }
.markdown-body hr { border: none; border-top: 1px solid rgba(127,127,127,.3); margin: 1.2em 0; }
