/* Glyph Atlas — dark spatial UI */
:root {
  --bg: #0b0e14;
  --bg-2: #10141d;
  --panel: #131824;
  --panel-2: #171e2d;
  --line: #232b3d;
  --text: #e6ebf5;
  --text-dim: #8b96ad;
  --accent: #6ea8fe;
  --accent-2: #9d7bff;
  --good: #4ade80;
  --warn: #fbbf24;
  --glyph-font: "Segoe UI Symbol", "Noto Sans Symbols 2", "Noto Sans Symbols", "Apple Color Emoji", "Segoe UI Emoji", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 10px;
  --tray-h: 74px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
html { overflow-x: hidden; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}
#app { display: flex; flex-direction: column; height: 100dvh; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #0d1119, #0b0e14);
  flex: 0 0 auto; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-glyph {
  font-family: var(--glyph-font); font-size: 30px; line-height: 1;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-text h1 { font-size: 16px; margin: 0; letter-spacing: .02em; white-space: nowrap; }
.tagline { margin: 0; font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.search-wrap {
  position: relative; flex: 1 1 auto; max-width: 720px; margin: 0 auto; min-width: 120px;
}
.search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-dim); pointer-events: none;
}
#search {
  width: 100%; padding: 9px 38px 9px 34px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  outline: none; font-size: 14px;
}
#search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(110,168,254,.18); }
.search-kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font: 11px var(--mono); color: var(--text-dim); border: 1px solid var(--line);
  padding: 1px 6px; border-radius: 5px; pointer-events: none;
}
.view-toggle { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.toggle-btn {
  display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent;
  color: var(--text-dim); padding: 8px 14px; min-height: 36px; border-radius: 999px; cursor: pointer; font-size: 13px;
}
.toggle-btn svg { width: 15px; height: 15px; }
.toggle-btn.active { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }

/* ---------- main layout ---------- */
.main { display: grid; grid-template-columns: 248px 1fr 340px; flex: 1 1 auto; min-height: 0; }
.sidebar { border-right: 1px solid var(--line); overflow-y: auto; background: var(--bg-2); }
.side-section { padding: 12px 10px 4px; }
.side-heading { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--text-dim); margin: 0 6px 8px; display: flex; justify-content: space-between; align-items: center; }
.pill { background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; font-size: 10px; }
.side-list { list-style: none; margin: 0; padding: 0; }
.side-list li button {
  width: 100%; text-align: left; display: flex; justify-content: space-between; gap: 8px;
  background: none; border: 0; color: var(--text); padding: 6px 8px; border-radius: 7px; cursor: pointer; font-size: 13px;
}
.side-list li button:hover { background: var(--panel-2); }
.side-list li button.active { background: rgba(110,168,254,.14); color: #cfe0ff; box-shadow: inset 2px 0 0 var(--accent); }
.side-list .count { color: var(--text-dim); font-size: 11px; font-family: var(--mono); }
.block-filter { padding: 0 6px 8px; }
.block-filter input {
  width: 100%; padding: 6px 9px; border-radius: 7px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-size: 12px; outline: none;
}
.block-filter input:focus { border-color: var(--accent); }
.block-list { padding-bottom: 14px; }

/* ---------- stage / grid ---------- */
.stage { position: relative; min-width: 0; display: flex; flex-direction: column; }
.statusbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--bg-2); flex: 0 0 auto; }
.crumbs { font-size: 12px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumbs b { color: var(--text); font-weight: 600; }
.result-count { font: 11px var(--mono); color: var(--text-dim); white-space: nowrap; }
.grid-wrap { position: relative; flex: 1 1 auto; overflow-y: auto; padding: 12px 14px 20px; scroll-behavior: smooth; }
.glyph-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 6px;
}
.cell {
  position: relative; aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
  font-family: var(--glyph-font); font-size: 24px; user-select: none;
  transition: transform .08s ease, border-color .12s ease, background .12s ease;
}
.cell:hover { border-color: var(--accent); transform: translateY(-2px); background: var(--panel-2); }
.cell:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; z-index: 2; }
.cell.selected { border-color: var(--accent); background: rgba(110,168,254,.14); box-shadow: 0 0 0 1px var(--accent); }
.cell.invisible { font-size: 13px; color: var(--warn); font-family: var(--mono); }
.cell.tofu { color: var(--text-dim); }
.cell .cp-tag {
  position: absolute; left: 3px; bottom: 2px; font: 8.5px var(--mono); color: var(--text-dim);
  opacity: 0; transition: opacity .12s ease; pointer-events: none;
}
.cell:hover .cp-tag, .cell:focus-visible .cp-tag { opacity: 1; }
.cell .fav-dot {
  position: absolute; top: 3px; right: 4px; width: 6px; height: 6px; border-radius: 50%;
  background: var(--warn); opacity: 0;
}
.cell.faved .fav-dot { opacity: 1; }
.grid-sentinel { height: 1px; }
.empty-state { text-align: center; color: var(--text-dim); padding: 60px 20px; }
.empty-glyph { font-size: 64px; font-family: var(--glyph-font); opacity: .4; }
.empty-state code { background: var(--panel-2); padding: 1px 6px; border-radius: 5px; }

/* ---------- 3D space ---------- */
.space-wrap { position: absolute; inset: 41px 0 0 0; }
#space-canvas { width: 100%; height: 100%; display: block; cursor: grab; }
#space-canvas:active { cursor: grabbing; }
.space-hud {
  position: absolute; left: 14px; bottom: 12px; right: 14px; display: flex; justify-content: space-between;
  align-items: flex-end; gap: 12px; pointer-events: none;
}
.space-hud-name { font: 12px var(--mono); color: var(--text-dim); background: rgba(11,14,20,.72); border: 1px solid var(--line); padding: 6px 10px; border-radius: 8px; backdrop-filter: blur(4px); }
.space-featured { text-align: right; }
.space-featured .sf-char { font-family: var(--glyph-font); font-size: 44px; line-height: 1; text-shadow: 0 0 24px rgba(110,168,254,.5); }
.space-featured .sf-name { font-size: 12px; color: var(--text); margin-top: 4px; background: rgba(11,14,20,.72); padding: 3px 8px; border-radius: 6px; display: inline-block; }
.space-tooltip {
  position: absolute; pointer-events: none; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; max-width: 240px; z-index: 5;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.space-tooltip .tt-glyph { font-family: var(--glyph-font); font-size: 22px; margin-right: 8px; }

/* ---------- inspector ---------- */
.inspector { border-left: 1px solid var(--line); background: var(--bg-2); overflow-y: auto; }
.inspector-empty { padding: 60px 24px; text-align: center; color: var(--text-dim); }
.inspector-empty-glyph { font-size: 56px; opacity: .35; font-family: var(--glyph-font); }
.inspector-body { padding: 16px 16px 28px; }
.insp-hero { text-align: center; padding: 10px 0 16px; position: relative; }
.insp-char {
  font-family: var(--glyph-font); font-size: 104px; line-height: 1.1;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  display: inline-flex; align-items: center; justify-content: center; min-width: 150px; min-height: 150px; padding: 10px 18px;
}
.insp-char.invisible { font-size: 20px; font-family: var(--mono); color: var(--warn); flex-direction: column; gap: 6px; }
.insp-char .invis-tag { font-size: 11px; letter-spacing: .08em; border: 1px dashed var(--warn); padding: 2px 8px; border-radius: 999px; }
.insp-cp { font: 600 15px var(--mono); margin-top: 12px; letter-spacing: .04em; }
.insp-cp .dec { color: var(--text-dim); font-weight: 400; font-size: 12px; }
.insp-name { font-size: 13px; margin-top: 6px; color: var(--text); }
.insp-meta { display: flex; justify-content: center; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.chip {
  font-size: 10.5px; color: var(--text-dim); border: 1px solid var(--line); border-radius: 999px;
  padding: 2px 9px; background: var(--panel);
}
.chip.block-chip { cursor: pointer; color: var(--accent); }
.insp-actions { display: flex; justify-content: center; gap: 8px; margin: 14px 0 4px; flex-wrap: wrap; }
.act-btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 8px;
  padding: 7px 12px; font-size: 12px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center;
}
.act-btn:hover { border-color: var(--accent); }
.act-btn.primary { background: rgba(110,168,254,.14); border-color: var(--accent); }
.act-btn.faved { border-color: var(--warn); color: var(--warn); }
.prop-list { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.prop-row {
  display: grid; grid-template-columns: 96px 1fr auto; gap: 8px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
}
.prop-row .prop-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); }
.prop-row .prop-value { font: 12.5px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prop-row .copy-btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text-dim); border-radius: 6px;
  padding: 3px 8px; font-size: 11px; cursor: pointer; flex: 0 0 auto;
}
.prop-row .copy-btn:hover { color: var(--text); border-color: var(--accent); }
.prop-row .copy-btn.copied { color: var(--good); border-color: var(--good); }
.related { margin-top: 18px; }
.related h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--text-dim); margin: 0 0 8px; }
.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 5px; }
.related-grid .cell { font-size: 18px; border-radius: 7px; }

/* ---------- tray ---------- */
.tray-bar {
  display: flex; gap: 18px; align-items: center; padding: 8px 16px;
  border-top: 1px solid var(--line); background: var(--bg-2); min-height: var(--tray-h); flex: 0 0 auto;
  overflow-x: auto;
}
.tray-group { display: flex; align-items: center; gap: 10px; }
.tray-title { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--text-dim); margin: 0; white-space: nowrap; }
.tray-hint { text-transform: none; letter-spacing: 0; font-weight: 400; opacity: .7; }
.tray-strip { display: flex; gap: 6px; align-items: center; }
.tray-cell {
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; position: relative;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
  font-family: var(--glyph-font); font-size: 20px; flex: 0 0 auto;
}
.tray-cell:hover { border-color: var(--accent); }
.tray-cell.invisible { font-size: 11px; font-family: var(--mono); color: var(--warn); }
.tray-cell .x {
  position: absolute; top: -6px; right: -6px; width: 15px; height: 15px; border-radius: 50%;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text-dim);
  font-size: 9px; line-height: 13px; text-align: center; display: none; cursor: pointer;
}
.tray-cell:hover .x { display: block; }
.tray-empty { font-size: 11px; color: var(--text-dim); white-space: nowrap; }

/* ---------- toast / hover card ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tray-h) + 18px); transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--good); color: var(--text);
  padding: 8px 16px; border-radius: 999px; font-size: 13px; z-index: 100;
  box-shadow: 0 8px 30px rgba(0,0,0,.5); animation: toast-in .18s ease;
}
.toast .t-val { font-family: var(--mono); color: var(--good); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }
.hover-card {
  position: fixed; z-index: 90; pointer-events: none; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.55); max-width: 260px;
}
.hover-card .hc-row { display: flex; gap: 10px; align-items: center; }
.hover-card .hc-glyph { font-family: var(--glyph-font); font-size: 34px; }
.hover-card .hc-cp { font: 600 12px var(--mono); color: var(--accent); }
.hover-card .hc-name { font-size: 11px; color: var(--text-dim); }

.inspector-fab {
  position: fixed; right: 14px; bottom: calc(var(--tray-h) + 14px); z-index: 60;
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font-size: 18px; cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,.45); display: none;
}
.insp-close {
  display: none;
  width: 100%; padding: 9px; margin-bottom: 6px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); border-radius: 8px; font-size: 12px; cursor: pointer;
}
.insp-close:hover { border-color: var(--accent); }
@media (max-width: 860px) { .insp-close { display: block; } }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .main { grid-template-columns: 210px 1fr 300px; }
}
@media (max-width: 860px) {
  body { overflow-x: clip; }
  .tray-bar { max-width: 100vw; }
  .main { grid-template-columns: 1fr; grid-template-rows: 1fr; position: relative; }
  .sidebar {
    position: absolute; z-index: 40; inset: 0 auto 0 0; width: 250px; transform: translateX(-100%);
    transition: transform .2s ease; border-right: 1px solid var(--line); box-shadow: 0 0 40px rgba(0,0,0,.5);
  }
  .sidebar.open { transform: translateX(0); }
  .inspector {
    position: fixed; z-index: 45; inset: 0 0 0 auto; width: min(340px, 92vw); transform: translateX(100%);
    visibility: hidden; pointer-events: none; transition: transform .2s ease, visibility .2s;
    border-left: 1px solid var(--line); box-shadow: 0 0 40px rgba(0,0,0,.5);
  }
  .inspector.open { visibility: visible; pointer-events: auto; }
  .inspector.open { transform: translateX(0); }
  .inspector-fab { display: block; }
  .tagline { display: none; }
  .topbar { flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
  .search-wrap { order: 3; flex-basis: 100%; max-width: none; }
  .brand-text h1 { font-size: 15px; }
  .glyph-grid { grid-template-columns: repeat(auto-fill, minmax(50px, 1fr)); gap: 5px; }
  .cell { font-size: 21px; }
  .tray-bar { gap: 12px; padding: 8px 10px; }
  .insp-char { font-size: 84px; min-width: 120px; min-height: 120px; }
  .space-wrap { inset-top: 41px; }
}
.menu-fab-note { display: none; }
