:root {
  --bg: #070711;
  --panel: rgba(10, 9, 24, .88);
  --panel-solid: #0d0c1c;
  --ink: #f4f0ff;
  --muted: #aaa3bd;
  --hair: rgba(214, 198, 255, .16);
  --violet: #a88cff;
  --cyan: #7ce6ff;
  --rose: #ff79c8;
  --red: #ff3f4f;
  --safe: #7affbe;
  --radius: 18px;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--sans); }
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, canvas:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }

#topology { position: fixed; inset: 0; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#topology.dragging { cursor: grabbing; }
.grid-field { position: fixed; inset: 72px 0 0; pointer-events: none; background-image: linear-gradient(90deg, #ffffff05 1px, transparent 1px), linear-gradient(#ffffff04 1px, transparent 1px); background-size: 78px 78px; -webkit-mask-image: radial-gradient(circle, #000 10%, transparent 75%); mask-image: radial-gradient(circle, #000 10%, transparent 75%); }
.noise { position: fixed; inset: 72px 0 0; pointer-events: none; opacity: .18; mix-blend-mode: screen; background: repeating-radial-gradient(circle at 22% 31%, #ffffff14 0 1px, transparent 1px 7px) 0 0/173px 149px, repeating-radial-gradient(circle at 78% 66%, #ff00990b 0 1px, transparent 1px 11px) 0 0/211px 187px; }

.topbar { position: fixed; z-index: 20; top: 0; left: 0; right: 0; height: 86px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 8px 22px; border-bottom: 1px solid var(--hair); background: linear-gradient(180deg, rgba(7,7,17,.96), rgba(7,7,17,.55), transparent); }
.brand { appearance: none; border: 0; background: none; display: flex; align-items: center; padding: 0; text-align: left; width: max-content; cursor: pointer; }
.brand-logo { display: block; width: auto; height: 70px; object-fit: contain; mix-blend-mode: screen; }
.modes { display: flex; gap: 3px; padding: 4px; border: 1px solid var(--hair); border-radius: 99px; background: rgba(13,12,28,.72); backdrop-filter: blur(10px); }
.mode { border: 0; border-radius: 99px; background: transparent; color: var(--muted); padding: 8px 13px; font-size: 11px; cursor: pointer; }
.mode.active { color: var(--ink); background: rgba(168,140,255,.17); box-shadow: inset 0 0 0 1px rgba(168,140,255,.2); }
.top-actions { justify-self: end; display: flex; align-items: center; gap: 10px; }
.quiet-button, .lang-button, .icon-button, .card-close, .editor-head button { border: 1px solid var(--hair); background: rgba(12,11,28,.66); border-radius: 50%; cursor: pointer; }
.quiet-button, .lang-button { width: 36px; height: 36px; }
.lang-button { font-size: 10px; letter-spacing: .08em; }
.metaculture-logo { display: block; width: 112px; height: 34px; object-fit: contain; opacity: .9; }
.metaculture-link { display: inline-flex; align-items: center; line-height: 0; }
.metaculture-link:hover .metaculture-logo { opacity: 1; }

.breadcrumb { position: fixed; z-index: 11; top: 99px; left: 22px; right: 22px; color: #d9d0ed; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; pointer-events: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.breadcrumb span { color: #6d667e; padding: 0 7px; }
.stats-line { position: fixed; z-index: 11; top: 119px; left: 22px; color: #777084; font: 9px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .07em; }

.explorer { position: fixed; z-index: 18; top: 140px; left: 18px; bottom: 74px; width: min(356px, calc(100vw - 36px)); display: flex; flex-direction: column; padding: 18px; border: 1px solid var(--hair); border-radius: var(--radius); background: rgba(10,9,24,.965); backdrop-filter: none; box-shadow: 0 30px 90px rgba(0,0,0,.28); transition: transform .45s cubic-bezier(.22,.8,.24,1), opacity .35s ease; }
.explorer.closed { transform: translateX(calc(-100% - 28px)); opacity: 0; pointer-events: none; }
.explorer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.explorer h1 { margin: 4px 0 13px; font-size: 24px; font-weight: 520; letter-spacing: -.035em; }
.eyebrow { color: var(--violet); font-size: 9px; text-transform: uppercase; letter-spacing: .2em; }
.icon-button { width: 30px; height: 30px; color: var(--muted); }
.search-box { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; padding: 10px 11px; border: 1px solid var(--hair); border-radius: 11px; background: rgba(255,255,255,.025); }
.search-box input { min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 12px; }
.search-box input::placeholder { color: #777082; }
kbd { border: 1px solid var(--hair); padding: 2px 5px; border-radius: 5px; color: #756e84; font-size: 9px; }
.filter-summary { display: flex; gap: 6px; overflow-x: auto; padding-top: 10px; scrollbar-width: none; }
.filter-summary:empty { display: none; }
.filter-pill { flex: none; border: 1px solid rgba(168,140,255,.35); border-radius: 99px; padding: 5px 8px; color: #d7caff; background: rgba(168,140,255,.11); font-size: 9px; cursor: pointer; }
.filters { border-bottom: 1px solid var(--hair); }
.filters summary { list-style: none; display: flex; align-items: center; justify-content: space-between; padding: 12px 1px; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .12em; cursor: pointer; }
.filters summary::-webkit-details-marker { display: none; }
#activeFilterCount { min-width: 22px; text-align: center; padding: 3px 5px; border-radius: 99px; background: rgba(255,255,255,.06); }
#filterGroups { max-height: 238px; overflow: auto; padding: 0 2px 9px; }
.filter-group { margin: 0 0 12px; }
.filter-group h3 { margin: 0 0 6px; color: #736c82; font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: .13em; }
.filter-choice { display: flex; align-items: center; gap: 8px; padding: 4px 0; color: #c5bdd3; font-size: 11px; cursor: pointer; }
.filter-choice input { accent-color: var(--violet); }
.filter-choice em { margin-left: auto; color: #696174; font-style: normal; font-size: 9px; }
.text-button { border: 0; background: none; padding: 0 0 11px; color: var(--violet); font-size: 10px; cursor: pointer; }
.result-meta { padding: 12px 1px 8px; color: #777083; font: 9px ui-monospace, SFMono-Regular, Consolas, monospace; text-transform: uppercase; letter-spacing: .07em; }
.result-list { flex: 1; min-height: 0; overflow: auto; padding-right: 3px; scrollbar-color: rgba(168,140,255,.3) transparent; }
.result-row { width: 100%; display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 10px; padding: 9px 4px; border: 0; border-bottom: 1px solid rgba(255,255,255,.055); background: none; text-align: left; cursor: pointer; }
.result-row:hover { background: rgba(255,255,255,.025); }
.result-thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: radial-gradient(circle at 35% 30%, #6d5c9c, #181426 65%); }
.result-symbol { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--hair); border-radius: 50%; color: var(--violet); font-size: 9px; }
.result-row b, .result-row small { display: block; }
.result-row b { overflow: hidden; color: #e7e0f0; font-size: 11px; font-weight: 540; white-space: nowrap; text-overflow: ellipsis; }
.result-row small { overflow: hidden; margin-top: 4px; color: #7f778d; font-size: 9px; white-space: nowrap; text-overflow: ellipsis; }
.result-row em { color: #655e72; font-size: 9px; font-style: normal; }
.more-button { width: 100%; margin-top: 9px; padding: 9px; border: 1px solid var(--hair); border-radius: 9px; background: rgba(255,255,255,.03); color: var(--muted); font-size: 10px; cursor: pointer; }
.hidden { display: none !important; }

.card-panel { position: fixed; z-index: 19; top: 140px; right: 18px; bottom: 74px; width: min(420px, calc(100vw - 36px)); overflow: hidden; border: 1px solid var(--hair); border-radius: var(--radius); background: rgba(10,9,24,.975); backdrop-filter: none; box-shadow: 0 34px 100px rgba(0,0,0,.42); transform: translateX(calc(100% + 28px)); opacity: 0; transition: transform .55s cubic-bezier(.22,.8,.24,1), opacity .35s ease; }
.card-panel.open { transform: translateX(0); opacity: 1; }
.card-scroll { height: 100%; overflow: auto; overscroll-behavior: contain; }
.sheet-handle { display: none; }
.card-close { position: absolute; z-index: 3; top: 12px; right: 12px; width: 32px; height: 32px; margin: 0; background: rgba(5,5,12,.72); }
.card-media { min-height: 0; background: #11101c; }
.card-media img { display: block; width: 100%; max-height: 46vh; object-fit: contain; background: #0a0911; }
.card-media.empty { display: none; }
.card-copy { padding: 23px 24px 28px; }
.card-type { color: var(--violet); font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .17em; }
.card-copy h2 { margin: 9px 0 5px; font-size: clamp(25px, 3vw, 38px); font-weight: 470; line-height: 1.02; letter-spacing: -.045em; }
.card-author { color: #c3b8d2; font-size: 12px; }
.card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 19px 0; background: var(--hair); border: 1px solid var(--hair); }
.card-grid div { padding: 10px; background: rgba(11,10,23,.96); }
.card-grid small, .card-grid b { display: block; }
.card-grid small { margin-bottom: 5px; color: #6f687b; font-size: 8px; text-transform: uppercase; letter-spacing: .1em; }
.card-grid b { font-size: 10px; font-weight: 480; line-height: 1.4; }
.card-detail { color: #b8b0c5; font-size: 12px; line-height: 1.65; white-space: pre-line; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 17px 0; }
.tag { padding: 5px 8px; border: 1px solid var(--hair); border-radius: 99px; color: #9e94ad; font-size: 9px; }
.source-link, .ended-label { display: flex; align-items: center; justify-content: space-between; width: 100%; margin-top: 21px; padding: 12px 14px; border-radius: 10px; text-decoration: none; font-size: 10px; letter-spacing: .04em; }
.source-link { border: 1px solid rgba(124,230,255,.28); color: var(--cyan); background: rgba(124,230,255,.06); }
.ended-label { border: 1px solid rgba(255,121,200,.24); color: #e8a9d0; background: rgba(255,121,200,.055); }

.graph-controls { position: fixed; z-index: 12; bottom: 20px; left: 18px; display: flex; gap: 6px; }
.graph-controls button { border: 1px solid var(--hair); border-radius: 9px; background: rgba(10,9,24,.82); backdrop-filter: blur(12px); color: #c8c1d7; padding: 9px 11px; font-size: 9px; text-transform: uppercase; letter-spacing: .08em; cursor: pointer; }
.graph-controls button:hover { color: var(--ink); border-color: rgba(255,255,255,.22); }
.legend { position: fixed; z-index: 10; right: 19px; bottom: 22px; display: flex; gap: 13px; color: #6f687b; font-size: 8px; text-transform: uppercase; letter-spacing: .08em; }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend b { font-weight: 500; }
.dot { width: 6px; height: 6px; border-radius: 50%; }
.dot-space { background: #57eaff; box-shadow: 0 0 10px rgba(87,234,255,.68); }
.dot-section { background: #4e8fff; box-shadow: 0 0 10px rgba(78,143,255,.56); }
.dot-author { background: #c478ff; box-shadow: 0 0 10px rgba(196,120,255,.48); }
.dot-work { background: #cbff58; box-shadow: 0 0 10px rgba(203,255,88,.44); }
.hint { position: fixed; z-index: 9; bottom: 24px; left: 50%; transform: translateX(-50%); color: #575160; font: 8px ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .06em; pointer-events: none; }
.perf-meter { display: none; position: fixed; z-index: 60; right: 10px; bottom: 10px; padding: 7px 9px; border: 1px solid rgba(122,255,190,.28); border-radius: 8px; color: #9dffd0; background: rgba(4,10,9,.92); font: 9px ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .03em; pointer-events: none; }
body.debug .perf-meter { display: block; }

.editor { position: fixed; z-index: 30; top: 91px; right: 18px; width: min(320px, calc(100vw - 36px)); padding: 18px; border: 1px solid rgba(255,63,79,.28); border-radius: var(--radius); background: rgba(12,9,22,.95); backdrop-filter: blur(26px); box-shadow: 0 25px 90px #0008; transform: translateX(calc(100% + 30px)); opacity: 0; transition: .4s cubic-bezier(.22,.8,.24,1); }
.editor.open { transform: translateX(0); opacity: 1; }
.editor-head { display: flex; align-items: center; justify-content: space-between; color: var(--red); font-size: 10px; letter-spacing: .16em; }
.editor-head button { width: 28px; height: 28px; }
.editor p { color: #81788b; font-size: 10px; line-height: 1.5; }
.editor label:not(.check-row) { display: grid; grid-template-columns: 1fr auto; gap: 4px; margin: 12px 0; color: #aaa1b8; font-size: 10px; }
.editor output { color: var(--violet); font: 9px ui-monospace, monospace; }
.editor input[type="range"] { grid-column: 1 / -1; width: 100%; accent-color: var(--red); }
.check-row { display: flex; align-items: center; gap: 8px; margin: 14px 0; color: #aaa1b8; font-size: 10px; }
.editor-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 17px 0 8px; }
.editor-actions button { border: 1px solid var(--hair); border-radius: 8px; background: rgba(255,255,255,.04); padding: 9px 6px; color: #beb4cc; font-size: 9px; cursor: pointer; }
.editor > small { color: #514a59; font: 8px ui-monospace, monospace; }

.loader { position: fixed; z-index: 50; inset: 0; display: grid; place-content: center; justify-items: center; gap: 9px; background: #070711; transition: opacity .8s ease, visibility .8s; }
.loader.ready { opacity: 0; visibility: hidden; }
.loader span { width: 48px; height: 48px; border: 1px solid rgba(168,140,255,.2); border-top-color: var(--violet); border-radius: 50%; animation: spin 1.2s linear infinite; }
.loader b { margin-top: 8px; font-size: 11px; letter-spacing: .23em; }
.loader small { color: #696274; font-size: 9px; }
@keyframes spin { to { transform: rotate(360deg); } }

body.hero-mode {
  --bg: #06080c;
  --panel: rgba(7, 10, 15, .82);
  --panel-solid: #0a0d12;
  --ink: #edf1f4;
  --muted: #97a1ad;
  --hair: rgba(215, 224, 232, .11);
  --violet: #c4ccd5;
  --cyan: #dce6ef;
  --rose: #afabb5;
  --red: #d4b279;
  --safe: #a6b8b5;
}

body.hero-mode .topbar,
body.hero-mode .breadcrumb,
body.hero-mode .stats-line,
body.hero-mode .explorer,
body.hero-mode .card-panel,
body.hero-mode .graph-controls,
body.hero-mode .legend,
body.hero-mode .hint,
body.hero-mode .perf-meter,
body.hero-mode .editor {
  display: none !important;
}

body.hero-mode .grid-field,
body.hero-mode .noise {
  inset: 0;
}

body.hero-mode .grid-field {
  opacity: .42;
  background-image:
    linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 92px 92px;
  -webkit-mask-image: radial-gradient(circle at 50% 50%, #000 0, #000 38%, transparent 78%);
  mask-image: radial-gradient(circle at 50% 50%, #000 0, #000 38%, transparent 78%);
}

body.hero-mode .noise {
  opacity: .09;
  mix-blend-mode: screen;
}

body.hero-mode #topology {
  cursor: default;
}

body.hero-mode .loader {
  background:
    radial-gradient(circle at 50% 46%, rgba(212, 178, 121, .08), transparent 22%),
    #06080c;
}

body.hero-mode .loader span {
  border-color: rgba(220, 230, 239, .12);
  border-top-color: rgba(212, 178, 121, .68);
}

@media (max-width: 800px) {
  .topbar { height: 74px; grid-template-columns: 1fr auto; padding: 7px 13px; }
  .brand-logo { height: 58px; }
  .modes { position: fixed; top: 84px; left: 50%; transform: translateX(-50%); }
  .metaculture-logo { display: none; }
  .breadcrumb { top: 131px; left: 14px; right: 14px; }
  .stats-line { top: 150px; left: 14px; }
  .explorer { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 64vh; border-radius: 20px; transform: translateY(calc(100% + 14px)); }
  .explorer:not(.closed) { transform: translateY(0); }
  .explorer.closed { transform: translateY(calc(100% + 14px)); }
  .card-panel { --sheet-offset: calc(100% + 16px); z-index: 21; top: max(8px, env(safe-area-inset-top)); left: 8px; right: 8px; bottom: max(8px, env(safe-area-inset-bottom)); width: auto; height: calc(100dvh - max(16px, env(safe-area-inset-top) + env(safe-area-inset-bottom))); max-height: none; border-radius: 20px; transform: translateY(var(--sheet-offset)); transition: transform .32s cubic-bezier(.22,.8,.24,1), opacity .2s ease; will-change: transform; }
  .card-panel.open { transform: translateY(var(--sheet-offset)); opacity: 1; }
  .card-panel.open[data-sheet-state="half"] { --sheet-offset: calc(100% - min(52dvh, 100%)); }
  .card-panel.open[data-sheet-state="full"] { --sheet-offset: 0px; }
  .card-panel.sheet-dragging { --sheet-offset: var(--sheet-drag-offset); transition: none; user-select: none; }
  .card-scroll { padding-top: 34px; overscroll-behavior: contain; touch-action: pan-y; }
  .sheet-handle { position: absolute; z-index: 4; top: 0; left: 50%; display: grid; place-items: center; width: 72px; height: 34px; padding: 0; border: 0; background: transparent; cursor: grab; transform: translateX(-50%); touch-action: none; }
  .sheet-handle:active { cursor: grabbing; }
  .sheet-handle span { width: 34px; height: 4px; border-radius: 99px; background: rgba(244,240,255,.52); }
  .sheet-handle:focus-visible { outline: 2px solid var(--cyan); outline-offset: -4px; border-radius: 12px; }
  .card-close { top: 6px; right: 10px; }
  .card-media img { max-height: 20dvh; }
  .card-copy { padding: 16px 18px calc(24px + env(safe-area-inset-bottom)); }
  .card-copy h2 { font-size: 27px; }
  .graph-controls { bottom: 13px; left: 10px; }
  .legend, .hint { display: none; }
  .editor { top: 73px; right: 8px; width: calc(100vw - 16px); }
  .grid-field, .noise { inset: 74px 0 0; }
  .noise { opacity: .12; mix-blend-mode: screen; }
  .modes, .explorer, .card-panel, .graph-controls button { backdrop-filter: none; }
  .explorer, .card-panel { background: rgba(10,9,24,.975); }

  body.hero-mode .grid-field,
  body.hero-mode .noise { inset: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.modes { max-width: 58vw; overflow-x: auto; scrollbar-width: none; }
.modes::-webkit-scrollbar { display: none; }
.mode { white-space: nowrap; }
.graph-controls { flex-wrap: wrap; max-width: calc(100vw - 36px); }
.graph-controls button { white-space: nowrap; }

.semantic-node-label { color: var(--ink); }
body.day { --bg: #f4f1eb; --panel: rgba(244,241,235,.92); --panel-solid: #ebe7de; --ink: #18212c; --muted: #576370; --hair: rgba(24,33,44,.14); --violet: #6a5acd; --cyan: #2f7ed1; --rose: #c44a8a; }
body.day .topbar { background: linear-gradient(180deg, rgba(244,241,235,.96), rgba(244,241,235,.55), transparent); }
body.day .explorer, body.day .card-panel { background: rgba(244,241,235,.975); color: var(--ink); }
body.day .result-row b { color: #18212c; }
body.day .result-row small { color: #576370; }
body.day .card-grid { background: var(--hair); }
body.day .card-grid div { background: rgba(244,241,235,.96); }
body.day .grid-field { background-image: linear-gradient(90deg, rgba(0,0,0,.04) 1px, transparent 1px), linear-gradient(rgba(0,0,0,.03) 1px, transparent 1px); }
body.day .graph-controls button { background: rgba(244,241,235,.92); color: #33404f; }
body.day .graph-controls button:hover { border-color: rgba(24,33,44,.28); }
body.day .legend { color: #6a6473; }
