:root {
  --bg: #0d0b0a; --sidebar: #0b0908; --panel: #141210; --input: #17130f;
  --line: rgba(180, 150, 110, 0.14); --line2: rgba(180, 150, 110, 0.22);
  --text: #b3a99b; --head: #ece3d1; --soft: #d8cebf; --accent: #d1332e;
  --muted: #8f8779; --dim: #6f685d;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); height: 100vh; overflow: hidden;
  font-family: 'Spectral', Georgia, serif; -webkit-font-smoothing: antialiased;
}
.display { font-family: 'Grenze Gotisch', serif; font-weight: 700; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: #2a241f; border-radius: 6px; border: 3px solid transparent; background-clip: content-box; }

.codex { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar { width: 246px; flex: none; background: var(--sidebar); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.brand { padding: 20px 20px 16px; border-bottom: 1px solid var(--line); }
.brand .title { font-family: 'Grenze Gotisch', serif; font-weight: 700; font-size: 22px; color: var(--head); }
.brand .title .amp { color: var(--accent); }
.brand .sub { font-size: 11.5px; letter-spacing: .22em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.brand .badge { display: inline-block; margin-top: 8px; font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: #b98a4e; border: 1px dashed rgba(185,138,78,.5); border-radius: 4px; padding: 2px 8px; }

.search { padding: 12px 12px 6px; position: relative; flex: none; }
.search input { width: 100%; background: var(--input); border: 1px solid var(--line2); color: var(--head); padding: 9px 12px; border-radius: 6px; font-family: inherit; font-size: 13.5px; outline: none; }
.search input::placeholder { color: #7a7166; }
.results { position: absolute; top: 48px; left: 12px; right: 12px; background: var(--panel); border: 1px solid var(--line2); border-radius: 8px; box-shadow: 0 20px 50px rgba(0,0,0,.6); padding: 6px; z-index: 30; max-height: 320px; overflow-y: auto; }
.results .row, .no-match { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 9px; background: transparent; border: none; border-radius: 6px; cursor: pointer; text-align: left; font-family: inherit; font-size: 13.5px; color: var(--head); }
.results .row:hover { background: rgba(255,255,255,.05); }
.results .row .tag { margin-left: auto; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); flex: none; }
.no-match { color: var(--muted); cursor: default; }

.cats { padding: 16px 12px; flex: 1; overflow-y: auto; }
.cats .label { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--dim); padding: 0 8px 10px; }
.cat-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 11px; border: none; border-radius: 6px; cursor: pointer; background: transparent; font-family: inherit; }
.cat-row:hover { background: rgba(255,255,255,.05); }
.cat-row.active { background: rgba(255,255,255,.06); }
.cat-row .name { flex: 1; text-align: left; font-size: 14px; color: var(--soft); }
.cat-row .count { font-size: 11px; color: var(--dim); }
.dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }

.foot { padding: 12px 20px; border-top: 1px solid var(--line); font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }

/* Main stage */
.main { flex: 1; position: relative; overflow: hidden; background: radial-gradient(120% 90% at 50% 42%, #12100e, #0a0807 80%); min-width: 0; }
.cx-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 15px; }

/* Category grid */
.cat-view { position: absolute; inset: 0; overflow: auto; }
.cat-inner { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 48px 40px; }
.roots-grid { display: flex; flex-wrap: wrap; gap: 18px; justify-content: center; max-width: 860px; }
.root-card { width: 216px; background: var(--panel); border: 1px solid rgba(180,150,110,.18); border-radius: 10px; overflow: hidden; cursor: pointer; padding: 0; text-align: center; transition: transform .12s, border-color .12s; }
.root-card:hover { border-color: rgba(236,227,209,.45); transform: translateY(-2px); }
.root-card .accent { height: 3px; }
.root-card .body { padding: 20px; }
.root-card .rname { font-family: 'Grenze Gotisch', serif; font-weight: 700; font-size: 22px; line-height: 1.08; color: var(--head); }
.root-card.stub .rname { color: #b7ac9c; }
.root-card .rmeta { font-size: 11.5px; letter-spacing: .06em; color: var(--muted); margin-top: 8px; }

/* Card (spatial) view */
.card-view { position: absolute; inset: 0; overflow: hidden; cursor: grab; user-select: none; }
.card-view.grabbing { cursor: grabbing; }
.world { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); will-change: transform; }
.world svg { position: absolute; left: 0; top: 0; pointer-events: none; }
.node { position: absolute; background: #151210; border: 1px solid rgba(180,150,110,.18); border-radius: 9px; padding: 8px 13px; cursor: pointer; overflow: hidden; box-shadow: 0 8px 22px rgba(0,0,0,.45); transition: filter .1s; }
.node:hover { filter: brightness(1.22); }
.node.stub { border-style: dashed; }
.node .nlabel { display: flex; align-items: center; gap: 7px; }
.node .nlabel span.t { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node .nname { font-size: 13px; line-height: 1.14; margin-top: 2px; color: var(--head); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.node.stub .nname { color: #9a9182; }
.ndot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

.center-card { position: absolute; background: linear-gradient(180deg, #161311, #100d0c); border: 1px solid var(--line2); border-radius: 12px; overflow: hidden; box-shadow: 0 30px 70px rgba(0,0,0,.55); display: flex; flex-direction: column; }
.center-card .accent { height: 4px; flex: none; }
.center-card .chead { padding: 19px 22px 11px; flex: none; }
.center-card .meta { display: flex; align-items: center; gap: 11px; flex-wrap: wrap; margin-bottom: 13px; }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 4px 11px; background: var(--input); border: 1px solid rgba(180,150,110,.18); border-radius: 999px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--soft); }
.metatag { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.draft-tag { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: #b98a4e; border: 1px dashed rgba(185,138,78,.5); border-radius: 4px; padding: 2px 8px; }
.hidden-tag { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: #c98bd1; border: 1px dashed rgba(201,139,209,.5); border-radius: 4px; padding: 2px 8px; }
.center-card h1 { font-family: 'Grenze Gotisch', serif; font-weight: 700; font-size: 32px; line-height: 1.05; color: var(--head); margin: 0; }
.center-card .cbody { flex: 1; overflow-y: auto; padding: 0 22px 20px; }
.center-card .effect { font-size: 14.5px; line-height: 1.62; color: var(--text); margin: 0; white-space: pre-line; }
.center-card .unwritten { font-style: italic; font-size: 14px; color: #7a7166; margin: 0; }

.stage-btn { position: absolute; top: 16px; background: var(--input); border: 1px solid var(--line2); color: #cfc6b8; font-family: inherit; font-size: 12px; letter-spacing: .06em; padding: 8px 15px; border-radius: 6px; cursor: pointer; }
.stage-btn:hover { border-color: rgba(236,227,209,.4); }
.back-btn { left: 18px; }
.recenter-btn { right: 18px; }
.pan-hint { position: absolute; left: 18px; bottom: 16px; pointer-events: none; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); background: rgba(10,8,7,.72); padding: 5px 11px; border-radius: 6px; }
.iso-note { position: absolute; left: 0; right: 0; text-align: center; font-style: italic; color: #7a7166; font-size: 13.5px; }
