/* ==========================================================================
   BIM2KnowledgeGraph · IFC Knowledge Graph Studio
   Blueprint ink for the building, warm orange for inference and highlights.
   ========================================================================== */

:root {
  --bg: #eef1f4;
  --surface: #fbfcfd;
  --surface-2: #f2f5f8;
  --surface-3: #e5eaf0;
  --stage: #f6f8fa;
  --line: #dbe2e9;
  --line-strong: #c2ccd6;
  --ink: #12202e;
  --ink-2: #3a4959;
  --ink-3: #5f6f82;
  --accent: #1f5fbf;
  --accent-hover: #194f9f;
  --accent-ink: #ffffff;
  --accent-soft: rgba(31, 95, 191, 0.09);
  --accent-line: rgba(31, 95, 191, 0.34);
  --signal: #c94c0b;
  --signal-bright: #e0560f;
  --signal-soft: rgba(224, 86, 15, 0.1);
  --ok: #1f7a4a;
  --ok-soft: rgba(31, 122, 74, 0.1);
  --warn: #9a5b00;
  --warn-soft: rgba(196, 128, 0, 0.13);
  --danger: #b8232f;
  --danger-soft: rgba(198, 47, 58, 0.1);
  --info: #0e7490;
  --violet: #6a42c2;
  --teal: #237f73;
  --grid-line: color-mix(in srgb, var(--line) 70%, transparent);
  --hud: rgba(251, 252, 253, 0.94);
  --shadow-hud: 0 1px 2px rgba(18, 32, 46, 0.08), 0 8px 24px rgba(18, 32, 46, 0.12);
  --shadow-pop: 0 2px 4px rgba(18, 32, 46, 0.08), 0 18px 48px rgba(18, 32, 46, 0.2);
  --r-control: 6px;
  --r-card: 10px;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --top-h: 56px;
  --side-w: 324px;
  --insp-w: 372px;
  --drawer-h: 300px;
  /* preview-graph discipline colours (match schema.js DOMAINS) */
  --c-spatial: #8b5cf6;
  --c-struct: #dc2626;
  --c-arch: #2563eb;
  --c-hvac: #0891b2;
  --c-plumb: #16a34a;
  --c-elec: #ca8a04;
  --c-sem: #6366f1;
  /* aliases used by inline styles generated in app.js */
  --panel: var(--surface);
  --panel-2: var(--surface-2);
  --border: var(--line);
  --border-strong: var(--line-strong);
  --text: var(--ink);
  --text-2: var(--ink-2);
  --muted: var(--ink-3);
  --accent-bg: var(--accent-soft);
  --accent-border: var(--accent-line);
  --err: var(--danger);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b141c; --surface: #111d28; --surface-2: #172634; --surface-3: #1f3142; --stage: #0b141c; --line: #213345; --line-strong: #2f465c;
    --ink: #e6edf4; --ink-2: #b4c2d0; --ink-3: #8597a9;
    --accent: #6aa8ff; --accent-hover: #8dbcff; --accent-ink: #08131d; --accent-soft: rgba(106, 168, 255, 0.12); --accent-line: rgba(106, 168, 255, 0.4);
    --signal: #ff8a3d; --signal-bright: #ff8a3d; --signal-soft: rgba(255, 138, 61, 0.13);
    --ok: #4cc38a; --ok-soft: rgba(76, 195, 138, 0.13); --warn: #f0b44c; --warn-soft: rgba(240, 180, 76, 0.13); --danger: #ff6b74; --danger-soft: rgba(255, 107, 116, 0.13); --info: #4fc3dc;
    --violet: #b393ff; --teal: #4fd1bd;
    --grid-line: color-mix(in srgb, var(--line) 55%, transparent);
    --hud: rgba(17, 29, 40, 0.94);
    --shadow-hud: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-pop: 0 2px 4px rgba(0, 0, 0, 0.4), 0 18px 48px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b141c; --surface: #111d28; --surface-2: #172634; --surface-3: #1f3142; --stage: #0b141c; --line: #213345; --line-strong: #2f465c;
  --ink: #e6edf4; --ink-2: #b4c2d0; --ink-3: #8597a9;
  --accent: #6aa8ff; --accent-hover: #8dbcff; --accent-ink: #08131d; --accent-soft: rgba(106, 168, 255, 0.12); --accent-line: rgba(106, 168, 255, 0.4);
  --signal: #ff8a3d; --signal-bright: #ff8a3d; --signal-soft: rgba(255, 138, 61, 0.13);
  --ok: #4cc38a; --ok-soft: rgba(76, 195, 138, 0.13); --warn: #f0b44c; --warn-soft: rgba(240, 180, 76, 0.13); --danger: #ff6b74; --danger-soft: rgba(255, 107, 116, 0.13); --info: #4fc3dc;
  --violet: #b393ff; --teal: #4fd1bd;
  --grid-line: color-mix(in srgb, var(--line) 55%, transparent);
  --hud: rgba(17, 29, 40, 0.94);
  --shadow-hud: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-pop: 0 2px 4px rgba(0, 0, 0, 0.4), 0 18px 48px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body.kg {
  margin: 0;
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: var(--accent); }
code, kbd, .mono { font-family: var(--mono); }
.mono { font-size: 11.5px; }
code { font-size: 0.92em; background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
kbd { display: inline-block; font-family: var(--mono); font-size: 11px; line-height: 16px; padding: 0 5px; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--ink-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-control);
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--ink-3); }
.btn:disabled { opacity: 0.45; }
.btn.primary, .btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled), .btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); border-color: transparent; }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; }
.btn.lg { height: 42px; padding: 0 18px; font-size: 14px; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-control);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
  flex: 0 0 auto;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.icon-btn:disabled { opacity: 0.35; }
.icon-btn.active, .icon-btn[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.link-btn { padding: 0; border: 0; background: none; color: var(--accent); text-align: left; font-size: 12px; text-decoration: underline; text-decoration-color: var(--accent-line); text-underline-offset: 3px; }
.link-btn:hover { text-decoration-color: currentColor; }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 0 7px; font-size: 11.5px; line-height: 18px; border-radius: 9px; color: var(--accent); background: var(--accent-soft); white-space: nowrap; font-weight: 500; }
.pill.gray { color: var(--ink-2); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.pill.ok { color: var(--ok); background: var(--ok-soft); }
.pill.bad { color: var(--danger); background: var(--danger-soft); }
.status-summary { margin-top: 6px; gap: 6px; }
.status-summary .chip b { font-weight: 600; color: var(--ink); }

/* ---------- Top bar ---------- */
.kg-top {
  height: var(--top-h);
  flex: 0 0 var(--top-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  min-width: 0;
  position: relative;
  z-index: 70;
}
.brand { display: flex; align-items: center; gap: 9px; flex: 0 0 auto; color: var(--ink); padding: 4px 8px 4px 4px; margin-left: -4px; border: 0; border-radius: 8px; background: transparent; text-decoration: none; }
.brand:hover { background: var(--surface-2); }
.brand-mark { display: block; flex: 0 0 auto; width: 30px; height: 30px; border-radius: 7px; box-shadow: 0 0 0 1px var(--line); }
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; }
.brand-two { color: var(--signal); }
.brand-short { display: none; }
.brand-tag { font-size: 12px; color: var(--ink-3); white-space: nowrap; padding-left: 12px; border-left: 1px solid var(--line); }

.file-chip { display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 420px; height: 34px; padding: 0 10px; color: var(--ink-2); border: 1px solid var(--line); border-radius: var(--r-control); }
.file-chip svg { flex: 0 0 auto; color: var(--ink-3); }
.kg-file-name { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.kg-file-meta { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--mono); }
.kg-spacer { flex: 1 1 auto; min-width: 8px; }
.kg-top-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.topbar-tools { display: flex; align-items: center; gap: 2px; padding-left: 6px; margin-left: 2px; border-left: 1px solid var(--line); }
.coffee-btn { background: #ffdd00; border-color: #e6c700; color: #1a1300; font-weight: 600; }
.btn.coffee-btn:hover { background: #ffe633; border-color: #d4b800; color: #1a1300; }
body:not(.on-start) .coffee-btn .lbl { display: none; }
body:not(.on-start) .coffee-btn { padding: 0 9px; }

/* menus */
.menu { position: relative; }
.menu-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 300px;
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-pop);
  display: none;
  z-index: 80;
}
.menu-pop.open { display: block; animation: rise 0.16s ease-out; }
.menu-pop h6 { margin: 8px 10px 4px; font-size: 12px; font-weight: 500; color: var(--ink-3); }
.menu-item { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; width: 100%; min-height: 34px; padding: 7px 10px; border: 0; background: transparent; border-radius: 6px; text-align: left; color: var(--ink); font-size: 13px; }
.menu-item:hover { background: var(--surface-2); }
.menu-item small { color: var(--ink-3); font-size: 11.5px; }
.menu-scope { display: flex; gap: 4px; padding: 2px 10px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }

/* ---------- Main layout ---------- */
.kg-main { flex: 1; display: flex; min-height: 0; position: relative; }
.kg-side { width: var(--side-w); flex: 0 0 var(--side-w); display: grid; grid-template-columns: 64px minmax(0, 1fr); background: var(--surface); border-right: 1px solid var(--line); min-height: 0; }
.rail { display: flex; flex-direction: column; gap: 2px; padding: 8px 6px; border-right: 1px solid var(--line); background: var(--surface-2); overflow: auto; }
.rail-tab { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 9px 2px 8px; font-size: 11px; font-weight: 500; color: var(--ink-3); background: transparent; border: 0; border-radius: 8px; }
.rail-tab:hover:not(:disabled) { color: var(--ink); background: var(--surface-3); }
.rail-tab[aria-selected="true"] { color: var(--accent); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.rail-tab:disabled { opacity: 0.45; }
.side-body { overflow-y: auto; overflow-x: hidden; min-width: 0; }
.pane-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 14px 14px 2px; font-size: 14px; font-weight: 600; }
.pane-title .muted { font-size: 12px; font-weight: 400; }
.kg-inspector { width: var(--insp-w); flex: 0 0 var(--insp-w); background: var(--surface); border-left: 1px solid var(--line); overflow-y: auto; overflow-x: hidden; }
.kg-stage {
  flex: 1;
  min-width: 0;
  position: relative;
  overflow: hidden;
  background-color: var(--stage);
  background-image:
    linear-gradient(to right, color-mix(in srgb, var(--line) 45%, transparent) 1px, transparent 1px),
    linear-gradient(to bottom, color-mix(in srgb, var(--line) 45%, transparent) 1px, transparent 1px);
  background-size: 32px 32px;
  background-position: -1px -1px;
}
#graph { position: absolute; inset: 0; }
#graph canvas { display: block; }

/* sidebar sections */
.side-sec { padding: 12px 14px 14px; border-bottom: 1px solid var(--line); }
.side-sec:last-child { border-bottom: 0; }
.side-sec > h3 { margin: 0 0 9px; font-size: 12px; font-weight: 600; color: var(--ink); display: flex; justify-content: space-between; align-items: center; }
.side-sec > h3 button { font-size: 12px; }
.side-hint { margin: 0; padding: 8px 14px 14px; color: var(--ink-3); font-size: 12px; line-height: 1.5; }
.lens-list { display: flex; flex-direction: column; gap: 2px; }
.lens { display: grid; grid-template-columns: 28px 1fr auto; gap: 9px; align-items: center; width: 100%; padding: 6px 8px; border-radius: 8px; border: 1px solid transparent; background: transparent; text-align: left; position: relative; }
.lens:hover { background: var(--surface-2); }
.lens.active { background: var(--accent-soft); }
.lens.active::before { content: ""; position: absolute; left: 0; top: 6px; bottom: 6px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.lens.active .lens-title { color: var(--accent); }
.lens-icon { width: 28px; height: 28px; border-radius: 6px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); }
.lens.active .lens-icon { background: var(--signal-bright); border-color: transparent; color: #fff; }
.lens-title { font-weight: 600; font-size: 13px; min-width: 0; }
.lens-desc { grid-column: 2 / 4; font-size: 11.5px; color: var(--ink-3); line-height: 1.4; margin-top: -4px; }
.lens-count { max-width: 96px; overflow: hidden; text-overflow: ellipsis; font-family: var(--mono); font-size: 10.5px; line-height: 18px; padding: 0 6px; border-radius: 9px; color: var(--ink-3); background: var(--surface-2); white-space: nowrap; }
.lens-count:empty { display: none; }
.lens.disabled { opacity: 0.45; }

.field { display: grid; gap: 4px; margin-bottom: 10px; }
.field > label, .field-label { font-size: 12px; font-weight: 500; color: var(--ink-2); display: flex; justify-content: space-between; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
select, input[type="text"], input[type="number"], input[type="search"] { height: 32px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); border-radius: var(--r-control); padding: 0 8px; min-width: 0; width: 100%; }
select:focus, input:focus { outline: 0; border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.check { display: flex; align-items: center; gap: 7px; padding: 3px 0; cursor: pointer; font-size: 12.5px; color: var(--ink-2); }
.check:hover { color: var(--ink); }
.check input { accent-color: var(--accent); margin: 0; }
.check .count { margin-left: auto; color: var(--ink-3); font-family: var(--mono); font-size: 11px; }
.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; font-size: 11.5px; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.chip:hover { border-color: var(--line-strong); color: var(--ink); }
.chip .sw { width: 8px; height: 8px; border-radius: 2px; flex: 0 0 8px; }
.chip.off { opacity: 0.4; }
.chip.on { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }
.chip small { color: var(--ink-3); font-family: var(--mono); }

.list-box { max-height: 172px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r-control); padding: 4px 8px; background: var(--surface-2); margin-top: 6px; }
.filter-head { display: flex; align-items: center; justify-content: space-between; margin: 12px 0 2px; }
.filter-head .field-label { margin: 0; }

/* ---------- Stage overlays ---------- */
.stage-top { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; gap: 10px; align-items: flex-start; pointer-events: none; z-index: 5; }
.stage-top > * { pointer-events: auto; }
.search { position: relative; width: min(420px, 100%); }
.search input { height: 36px; padding-left: 34px; background: var(--hud); box-shadow: var(--shadow-hud); border-color: var(--line); backdrop-filter: blur(6px); }
.search > svg { position: absolute; left: 11px; top: 10px; color: var(--ink-3); pointer-events: none; }
.search-pop { position: absolute; left: 0; right: 0; top: 42px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow-pop); max-height: 380px; overflow-y: auto; display: none; padding: 4px; }
.search-pop.open { display: block; }
.sr { display: grid; grid-template-columns: 12px 1fr auto; gap: 8px; align-items: center; padding: 7px 8px; cursor: pointer; border-radius: 6px; }
.sr:hover, .sr.kb { background: var(--surface-2); }
.sr .sw { width: 10px; height: 10px; border-radius: 3px; }
.sr-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-sub { font-size: 11.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-tag { font-size: 11px; color: var(--ink-3); font-family: var(--mono); }
.stage-stats { margin-left: auto; display: flex; gap: 2px; background: var(--hud); border: 1px solid var(--line); border-radius: var(--r-card); padding: 4px; box-shadow: var(--shadow-hud); backdrop-filter: blur(6px); }
.stat { padding: 3px 10px; text-align: right; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat b { display: block; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.stat span { font-size: 11px; color: var(--ink-3); }
.stage-notes { position: absolute; top: 60px; left: 12px; max-width: min(560px, calc(100% - 24px)); display: flex; flex-direction: column; gap: 6px; z-index: 4; }
.note { position: relative; padding: 8px 28px 8px 10px; font-size: 12.5px; color: var(--ink-2); background: var(--hud); border: 1px solid var(--line); border-left: 0; border-radius: 0 var(--r-control) var(--r-control) 0; box-shadow: inset 2px 0 0 var(--signal-bright), var(--shadow-hud); }
.note.info { box-shadow: inset 2px 0 0 var(--accent), var(--shadow-hud); }
.note button { position: absolute; right: 4px; top: 4px; border: 0; background: none; color: var(--ink-3); font-size: 15px; line-height: 1; padding: 2px 5px; border-radius: 4px; }
.note button:hover { background: var(--surface-2); }
.stage-tools { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 2px; background: var(--hud); border: 1px solid var(--line); border-radius: var(--r-card); padding: 4px; box-shadow: var(--shadow-hud); z-index: 5; backdrop-filter: blur(6px); }
.stage-tools .div { height: 1px; background: var(--line); margin: 3px 2px; }
.legend { position: absolute; left: 12px; bottom: 12px; width: 256px; max-height: min(46%, calc(100% - 140px)); overflow-y: auto; background: var(--hud); border: 1px solid var(--line); border-radius: var(--r-card); padding: 10px 12px; box-shadow: var(--shadow-hud); font-size: 12px; z-index: 5; backdrop-filter: blur(6px); }
.legend h5 { margin: 0 0 6px; font-size: 12px; font-weight: 600; color: var(--ink); display: flex; justify-content: space-between; align-items: baseline; }
.legend h5 + * { margin-bottom: 10px; }
.legend-row { display: flex; align-items: center; gap: 7px; padding: 1.5px 0; color: var(--ink-2); }
.legend-row.click { cursor: pointer; }
.legend-row.click:hover { color: var(--accent); }
.legend-row .n { margin-left: auto; color: var(--ink-3); font-family: var(--mono); font-size: 11px; padding-left: 10px; }
.legend-row svg { flex: 0 0 auto; }
.legend-shapes { display: flex; flex-wrap: wrap; gap: 3px 10px; color: var(--ink-2); font-size: 11.5px; }
.legend-shapes span { display: inline-flex; align-items: center; gap: 4px; }
.legend-line { width: 18px; height: 0; border-top: 2px solid; flex: 0 0 18px; }
.legend-line.dash { border-top-style: dashed; }
.grad { height: 8px; border-radius: 4px; margin: 3px 0 2px; }
.grad-labels { display: flex; justify-content: space-between; color: var(--ink-3); font-size: 11px; font-family: var(--mono); }
.legend.collapsed > :not(h5:first-child) { display: none; }

.tooltip { position: fixed; pointer-events: none; z-index: 120; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-control); box-shadow: var(--shadow-pop); padding: 7px 10px; font-size: 12px; max-width: 320px; opacity: 0; transition: opacity 0.08s; }
.tooltip.show { opacity: 1; }
.tooltip b { display: block; font-size: 12.5px; font-weight: 600; }
.tooltip .t-sub { color: var(--ink-3); font-size: 11.5px; }

.ctx-menu { position: fixed; z-index: 200; min-width: 230px; padding: 5px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow-pop); display: none; }
.ctx-menu.open { display: block; animation: rise 0.12s ease-out; }
.ctx-menu .ctx-head { padding: 6px 10px 7px; border-bottom: 1px solid var(--line); margin-bottom: 4px; font-weight: 600; max-width: 290px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-menu .ctx-head small { display: block; font-weight: 400; color: var(--ink-3); }

/* toast: card in the bottom-right corner of the stage */
.toast { position: absolute; right: 60px; bottom: 14px; display: flex; align-items: center; gap: 10px; width: 360px; max-width: calc(100% - 80px); padding: 10px 12px; font-size: 12.5px; font-weight: 500; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow-pop); opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity 0.18s, transform 0.18s; z-index: 50; }
.toast::before { content: ""; flex: 0 0 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.toast.show { opacity: 1; transform: none; }

/* loading */
.loading { position: fixed; inset: var(--top-h) 0 0 0; display: none; place-items: center; padding: 16px; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(4px); z-index: 90; }
.loading.show { display: grid; }
.loading-card { width: min(460px, 100%); padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-pop); }
.load-head { display: flex; align-items: center; gap: 12px; }
.load-head > div { flex: 1; min-width: 0; }
.loading-card h4 { margin: 0; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#loadFile { font-family: var(--mono); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 6px; margin: 16px 0 12px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.bar > div { height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width 0.2s; }
#loadText { color: var(--ink-3); font-size: 12px; }
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; flex: 0 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Inspector ---------- */
.insp-empty { padding: 40px 24px; text-align: center; color: var(--ink-3); }
.empty-icon { display: grid; place-items: center; width: 44px; height: 44px; margin: 0 auto 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); }
.insp-empty h3 { margin: 0 0 6px; font-size: 14px; font-weight: 600; color: var(--ink); }
.insp-empty p { margin: 0 auto; max-width: 34ch; line-height: 1.5; }
.insp-head { padding: 14px 16px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.insp-title { display: flex; gap: 10px; align-items: flex-start; }
.insp-title > svg { flex: 0 0 auto; margin-top: 2px; color: var(--accent); }
.insp-title h2 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; word-break: break-word; }
.insp-title .sub { color: var(--ink-3); font-size: 12px; margin-top: 3px; }
.insp-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.insp-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.insp-sec { border-bottom: 1px solid var(--line); }
.insp-sec > summary { list-style: none; cursor: pointer; padding: 12px 16px; font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 8px; user-select: none; }
.insp-sec > summary:hover { background: var(--surface-2); }
.insp-sec > summary::-webkit-details-marker { display: none; }
.insp-sec > summary::after { content: ""; order: 3; width: 7px; height: 7px; margin-left: 4px; border-right: 1.6px solid var(--ink-3); border-bottom: 1.6px solid var(--ink-3); transform: rotate(-45deg); transition: transform 0.15s; }
.insp-sec[open] > summary::after { transform: rotate(45deg); }
.insp-sec > summary .n { margin-left: auto; order: 2; color: var(--ink-3); font-weight: 400; font-family: var(--mono); font-size: 11px; }
.insp-sec > summary:not(:has(.n))::after { margin-left: auto; }
.insp-body { padding: 0 16px 14px; }
.kv { width: 100%; border-collapse: collapse; font-size: 12.5px; table-layout: fixed; }
.kv td { padding: 5px 0; vertical-align: top; border-top: 1px solid var(--line); word-break: break-word; }
.kv tr:first-child td { border-top: 0; }
.kv td:first-child { color: var(--ink-3); width: 40%; padding-right: 10px; }
.kv td .unit { color: var(--ink-3); margin-left: 3px; }
.pset { border: 1px solid var(--line); border-radius: var(--r-control); margin-bottom: 6px; background: var(--surface-2); overflow: hidden; }
.pset > summary { padding: 6px 9px; cursor: pointer; font-weight: 500; font-size: 12px; color: var(--violet); display: flex; gap: 6px; align-items: center; list-style: none; }
.pset > summary::-webkit-details-marker { display: none; }
.pset > summary .n { margin-left: auto; color: var(--ink-3); font-weight: 400; font-family: var(--mono); font-size: 11px; }
.pset:has(.badge.q) > summary { color: var(--teal); }
.pset .kv { background: var(--surface); }
.pset .kv td { padding: 4px 9px; }
.pset .kv td:last-child { font-family: var(--mono); font-size: 11.5px; }
.badge { font-size: 10px; font-weight: 600; padding: 0 5px; line-height: 16px; border-radius: 4px; background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.03em; }
.badge.q { color: var(--teal); border-color: color-mix(in srgb, var(--teal) 40%, transparent); }
.badge.t { color: var(--violet); border-color: color-mix(in srgb, var(--violet) 40%, transparent); }
.badge.inf { color: var(--signal); background: var(--signal-soft); border-color: transparent; }
.crumbs { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; font-size: 12px; }
.crumbs .sep { color: var(--line-strong); }
.crumb { border: 1px solid var(--line); background: var(--surface-2); border-radius: 5px; padding: 1px 7px; color: var(--ink-2); }
.crumb:hover { color: var(--accent); border-color: var(--accent-line); }
.chain { display: flex; flex-wrap: wrap; gap: 3px; font-family: var(--mono); font-size: 11px; }
.chain span { padding: 1px 5px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); }
.chain span:first-child { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.rel-group { margin-bottom: 8px; }
.rel-group h6 { margin: 6px 0 3px; font-size: 12px; font-weight: 500; color: var(--ink-2); display: flex; gap: 6px; align-items: center; }
.rel-group h6 .dir { font-family: var(--mono); color: var(--ink-3); font-weight: 400; }
.rel-item { display: flex; align-items: center; gap: 7px; width: 100%; padding: 4px 6px; border: 0; background: transparent; border-radius: 5px; text-align: left; font-size: 12.5px; color: var(--ink); }
.rel-item:hover { background: var(--surface-2); color: var(--accent); }
.rel-item .sw { width: 8px; height: 8px; border-radius: 2px; flex: 0 0 8px; }
.rel-item .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rel-item .c { margin-left: auto; color: var(--ink-3); font-size: 11px; white-space: nowrap; font-family: var(--mono); }
pre.step { margin: 0; white-space: pre-wrap; word-break: break-all; font-family: var(--mono); font-size: 11px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-control); padding: 8px; max-height: 240px; overflow: auto; color: var(--ink-2); }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; }
.metric { padding: 8px 10px; border-top: 1px solid var(--line); }
.metric:nth-child(-n + 2) { border-top: 0; }
.metric:nth-child(even) { border-left: 1px solid var(--line); }
.metric b { display: block; font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; }
.metric span { font-size: 11.5px; color: var(--ink-3); }
.copy { border: 0; background: none; color: var(--ink-3); padding: 0 2px; }
.copy:hover { color: var(--accent); }
.onto a { font-family: var(--mono); font-size: 11.5px; text-decoration: none; }
.onto a:hover { text-decoration: underline; }

/* ---------- Bottom drawer ---------- */
.kg-drawer { height: var(--drawer-h); flex: 0 0 auto; background: var(--surface); border-top: 1px solid var(--line); display: flex; flex-direction: column; min-height: 40px; position: relative; z-index: 20; }
.kg-drawer.collapsed { height: 40px !important; }
.drawer-handle { position: absolute; top: -4px; left: 0; right: 0; height: 8px; cursor: ns-resize; z-index: 3; }
.drawer-handle::after { content: ""; position: absolute; left: 0; right: 0; top: 3px; height: 2px; background: transparent; transition: background 0.12s; }
.drawer-handle:hover::after { background: var(--accent); }
.drawer-tabs { display: flex; align-items: center; gap: 2px; padding: 0 8px; border-bottom: 1px solid var(--line); height: 40px; flex: 0 0 40px; overflow-x: auto; background: var(--surface); }
.tab { position: relative; height: 40px; padding: 0 12px; border: 0; background: transparent; color: var(--ink-3); font-weight: 500; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.tab:hover:not(:disabled) { color: var(--ink); }
.tab:disabled { opacity: 0.5; }
.tab.active { color: var(--ink); }
.tab.active::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 2px 2px 0 0; background: var(--signal-bright); }
.tab .tc { font-family: var(--mono); font-size: 11px; line-height: 18px; padding: 0 6px; border-radius: 9px; background: var(--surface-2); color: var(--ink-3); }
.drawer-body { flex: 1; overflow: auto; padding: 14px 16px; background: var(--bg); }
.kg-drawer.collapsed .drawer-body { display: none; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 12px 14px; min-width: 0; }
.card h4 { margin: 0 0 10px; font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card h4 small { font-weight: 400; color: var(--ink-3); font-size: 12px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(122px, 1fr)); gap: 0; margin-bottom: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; }
.kpi { padding: 10px 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 -1px -1px 0; }
.kpi b { display: block; font-size: 19px; font-weight: 500; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi span { font-size: 12px; color: var(--ink-3); }
.kpi em { font-style: normal; font-size: 11.5px; color: var(--signal); display: block; }
.hbar { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; gap: 8px; align-items: center; padding: 3px 0; font-size: 12px; }
.hbar.click { cursor: pointer; }
.hbar.click:hover .hb-l { color: var(--accent); }
.hb-l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.hb-t { height: 10px; background: var(--surface-2); border-radius: 0 4px 4px 0; overflow: hidden; }
.hb-t > div { height: 100%; border-radius: 0 4px 4px 0; }
.hb-n { font-family: var(--mono); font-size: 11.5px; color: var(--ink-2); min-width: 42px; text-align: right; }

table.data { width: 100%; border-collapse: collapse; font-size: 12px; }
table.data th { text-align: left; font-weight: 500; color: var(--ink-3); padding: 7px 8px; border-bottom: 1px solid var(--line-strong); position: sticky; top: 0; background: var(--surface); white-space: nowrap; z-index: 1; }
table.data th.sort { cursor: pointer; }
table.data th.sort:hover { color: var(--accent); }
table.data td { padding: 5px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
table.data tr.click { cursor: pointer; }
table.data tr.click:hover td { background: var(--accent-soft); }
table.data td.num { text-align: right; font-family: var(--mono); font-size: 11.5px; }
.table-wrap { border: 1px solid var(--line); border-radius: var(--r-card); overflow: auto; max-height: calc(var(--drawer-h) - 120px); background: var(--surface); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.toolbar input[type="search"] { width: 240px; }
.toolbar .grow { flex: 1; }

.check-row { display: grid; grid-template-columns: 10px minmax(160px, 1.5fr) minmax(120px, 1fr) 76px auto; gap: 10px; align-items: center; padding: 8px 4px; border-top: 1px solid var(--line); }
.card > .check-row:nth-of-type(1) { border-top: 0; }
.sev { width: 9px; height: 9px; border-radius: 50%; }
.sev.error { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.sev.warning { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.sev.info { background: var(--info); }
.check-title { font-weight: 500; }
.check-desc { color: var(--ink-3); font-size: 12px; }
.score { display: flex; align-items: center; gap: 14px; }
.score-ring { width: 64px; height: 64px; }

.q-row { display: grid; grid-template-columns: minmax(180px, 2fr) 110px minmax(120px, 1.2fr) 32px; gap: 6px; margin-bottom: 6px; }
.q-head { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; margin-bottom: 10px; }
.presets { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.swatch-shape { display: inline-block; flex: 0 0 auto; }

/* ---------- Start page ---------- */
.start {
  position: fixed;
  inset: var(--top-h) 0 0 0;
  z-index: 60;
  overflow: auto;
  background-color: var(--bg);
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: 32px 32px;
  background-position: -1px -1px;
}
.start-inner { width: min(1180px, 100%); margin: 0 auto; padding: clamp(24px, 6vh, 64px) 24px 32px; }
.start-resume { margin-bottom: 14px; }
.start-top { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(300px, 1fr); gap: 20px; align-items: stretch; }
.start-hero { padding: 32px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-hud); }
.start-kicker { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 500; color: var(--ink-2); padding: 3px 10px 3px 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); }
.start-kicker b { font-weight: 600; color: #fff; background: var(--signal-bright); border-radius: 999px; padding: 0 7px; line-height: 18px; font-size: 11px; }
.start-hero h1 { margin: 16px 0 0; font-size: clamp(30px, 4.4vw, 46px); line-height: 1.04; font-weight: 700; letter-spacing: -0.035em; max-width: 17ch; }
.start-hero h1 em { font-style: normal; color: var(--signal); }
.start-hero p { max-width: 60ch; margin: 16px 0 0; font-size: 15px; line-height: 1.6; color: var(--ink-2); }
.start-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.dropzone { display: grid; justify-items: start; gap: 2px; width: 100%; margin-top: 22px; padding: 14px 16px; text-align: left; color: var(--ink-2); background: var(--surface-2); border: 1.5px dashed var(--line-strong); border-radius: var(--r-card); transition: border-color 0.15s, background 0.15s; }
.dropzone svg { color: var(--accent); margin-bottom: 4px; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.formats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.fmt { font-family: var(--mono); font-size: 11px; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); }
.start-privacy { display: flex; align-items: center; gap: 7px; margin-top: 14px; font-size: 12.5px; color: var(--ink-3); }

.preview { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-hud); overflow: hidden; min-height: 420px; }
.preview-bar { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border-bottom: 1px solid var(--line); font-size: 12.5px; font-weight: 600; }
.preview-bar .mono { margin-left: auto; font-weight: 400; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--signal-bright); box-shadow: 0 0 0 3px var(--signal-soft); }
.preview-graph { position: relative; flex: 1; min-height: 320px; background-color: var(--stage); background-image: radial-gradient(color-mix(in srgb, var(--line-strong) 60%, transparent) 1px, transparent 1px); background-size: 20px 20px; }
.preview-graph svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.preview-tip { position: absolute; right: 10px; top: 10px; max-width: 230px; padding: 7px 10px; font-size: 12px; background: var(--hud); border: 1px solid var(--line); border-radius: var(--r-control); box-shadow: var(--shadow-hud); pointer-events: none; }
.preview-tip b { display: block; font-weight: 600; }
.preview-tip small { color: var(--ink-3); }
.preview-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 9px 14px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--ink-2); }
.preview-legend span { display: inline-flex; align-items: center; gap: 5px; }
.preview-legend i { width: 8px; height: 8px; border-radius: 50%; }
.flow { stroke-dasharray: 3 5; animation: flow 1.2s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -16; } }

.start-steps { list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin: 20px 0 0; padding: 0; }
.start-steps li { display: flex; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); }
.start-steps li > svg { flex: none; margin-top: 2px; color: var(--signal-bright); }
.start-steps b { font-size: 13px; }
.start-steps p { margin: 3px 0 0; font-size: 12px; color: var(--ink-3); line-height: 1.45; }

.start-sec { margin-top: 36px; }
.start-sec > h2 { margin: 0 0 4px; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.start-sec > p { margin: 0 0 14px; color: var(--ink-2); max-width: 75ch; font-size: 13.5px; }
.lens-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 10px; }
.lens-card { display: flex; gap: 12px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); color: inherit; text-decoration: none; transition: border-color 0.15s, box-shadow 0.15s; }
.lens-card:hover { border-color: var(--accent-line); box-shadow: var(--shadow-hud); }
.lens-card .lens-icon { flex: 0 0 34px; width: 34px; height: 34px; color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.lens-card h3 { margin: 0; font-size: 13.5px; font-weight: 600; }
.lens-card p { margin: 3px 0 0; font-size: 12.5px; color: var(--ink-2); line-height: 1.5; }
.lens-card .go { margin-top: 6px; display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--accent); }

.sample-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.sample-card { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); }
.sample-head { display: flex; align-items: center; gap: 8px; }
.sample-head svg { color: var(--accent); flex: none; }
.sample-head h3 { flex: 1; margin: 0; font-size: 14px; }
.sample-card p { margin: 0; color: var(--ink-2); font-size: 12.5px; line-height: 1.5; }
.sample-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 6px; }

.std-list { display: grid; }
.std { display: grid; grid-template-columns: 120px 1fr; gap: 12px; align-items: baseline; padding: 8px 0; border-top: 1px solid var(--line); font-size: 12.5px; }
.std:first-child { border-top: 0; }
.std b { font-family: var(--mono); font-size: 12px; font-weight: 500; color: var(--accent); }
.std span { color: var(--ink-2); }

.cite { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 20px; align-items: start; }
.author { display: flex; gap: 12px; align-items: center; margin-top: 14px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; color: #fff; background: var(--accent); }
.author small { display: block; color: var(--ink-3); }
pre.bib { position: relative; margin: 0; font-family: var(--mono); font-size: 12px; line-height: 1.6; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 14px 16px; overflow-x: auto; }
pre.bib .btn { position: absolute; top: 8px; right: 8px; }

.start-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 24px; margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--line-strong); font-size: 12.5px; color: var(--ink-3); }
.start-foot nav { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.start-foot a { color: var(--ink-2); text-decoration: none; }
.start-foot a:hover { color: var(--accent); }

body.drag-over .start .dropzone { border-color: var(--accent); background: var(--accent-soft); }
body.drag-over:not(.on-start) .kg-stage::after { content: "Drop an .ifc or .ifczip file to open it"; position: absolute; inset: 12px; display: grid; place-items: center; font-size: 15px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border: 2px dashed var(--accent); border-radius: 14px; z-index: 30; pointer-events: none; }

/* ---------- Visitor statistics popover ---------- */
.vc-popover { display: none; position: fixed; top: calc(var(--top-h) + 8px); right: 14px; z-index: 400; width: 794px; max-width: calc(100vw - 28px); max-height: calc(100vh - 80px); overflow-x: hidden; overflow-y: auto; background: #111d28; border: 1px solid #2f465c; border-radius: var(--r-card); box-shadow: var(--shadow-pop); }
.vc-popover.vc-open { display: block; animation: rise 0.16s ease-out; }
.vc-popover-top { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; color: #b4c2d0; font-size: 12.5px; font-weight: 600; border-bottom: 1px solid #213345; }
.vc-pop-close { border: 0; background: transparent; color: #b4c2d0; font-size: 18px; line-height: 1; padding: 0 6px; border-radius: 4px; }
.vc-pop-close:hover { background: #1f3142; color: #fff; }
.vc-flag-link { display: block; padding: 12px; line-height: 0; }
.vc-flag-img { max-width: 100%; height: auto; border-radius: 6px; }

/* ---------- Responsive ---------- */
.insp-close { display: none; }
.mobile-only { display: none !important; }
@media (max-width: 1280px) {
  :root { --insp-w: 340px; --side-w: 300px; }
  .brand-tag { display: none; }
}
@media (max-width: 1100px) {
  .kg-inspector { position: absolute; right: 0; top: 0; bottom: 0; z-index: 25; box-shadow: var(--shadow-pop); transform: translateX(100%); transition: transform 0.2s; }
  .kg-inspector.open { transform: none; }
  .insp-close { display: inline-flex; }
  .file-chip .kg-file-meta { display: none; }
}
@media (max-width: 900px) {
  .start-top, .cite { grid-template-columns: 1fr; }
  .preview { min-height: 360px; }
}
@media (max-width: 820px) {
  .mobile-only { display: inline-grid !important; }
  .kg-side { position: absolute; left: 0; top: 0; bottom: 0; z-index: 26; box-shadow: var(--shadow-pop); transform: translateX(-100%); transition: transform 0.2s; }
  .kg-side.open { transform: none; }
  .kg-inspector { width: min(var(--insp-w), 100%); }
  .brand-full { display: none; }
  .brand-short { display: inline; }
  .file-chip, .stage-stats, #btnExport .lbl, #btnOpen .lbl, .coffee-btn .lbl { display: none; }
  .coffee-btn { padding: 0 9px; }
  :root { --drawer-h: 240px; }
  .kg-top { padding: 0 8px; gap: 6px; }
  .topbar-tools { padding-left: 2px; border-left: 0; }
  .q-row { grid-template-columns: 1fr 90px; }
  .start-inner { padding: 16px 12px 24px; }
  .start-hero { padding: 22px 18px; }
  .std { grid-template-columns: 1fr; gap: 2px; }
  .toast { right: 12px; max-width: calc(100% - 24px); }
}

/* ==========================================================================
   Studio workspaces (2.0)
   ========================================================================== */
body:not(.on-start) .brand-tag { display: none; }
.file-chip { max-width: 330px; }
.ws-nav { display: flex; gap: 2px; padding: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; flex: 0 0 auto; }
.ws-btn { height: 28px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent; color: var(--ink-2); font-weight: 500; font-size: 13px; white-space: nowrap; }
.ws-btn:hover { color: var(--ink); background: var(--surface); }
.ws-btn.active { background: var(--surface); color: var(--accent); box-shadow: 0 1px 2px rgba(15, 30, 45, 0.12), inset 0 0 0 1px var(--line); }
.ws-title { font-weight: 600; font-size: 13px; color: var(--ink); padding: 0 12px 0 6px; margin-right: 4px; border-right: 1px solid var(--line); white-space: nowrap; }
@media (max-width: 1360px) { .file-chip .kg-file-meta { display: none; } }
@media (max-width: 1180px) { .ws-btn { padding: 0 8px; font-size: 12px; } .file-chip { display: none !important; } }

/* inspector only when something is selected (desktop) */
@media (min-width: 1101px) { body:not(.insp-open) .kg-inspector { display: none; } }

/* sidebar: slimmer, grouped lenses */
:root { --side-w: 284px; }
.lens-group { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); padding: 10px 8px 4px; }
.lens-group:first-child { padding-top: 2px; }
.lens { padding: 5px 8px; }
.lens-desc { font-size: 11px; }

/* drawer */
.kg-drawer:not(.collapsed) { box-shadow: 0 -6px 18px rgba(15, 30, 45, 0.06); }
.drawer-body .card h4 small { font-weight: 400; color: var(--ink-3); font-size: 11.5px; margin-left: 6px; }

/* 3D model split view */
.v3d { position: absolute; top: 0; right: 0; bottom: 0; width: 50%; display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line); z-index: 6; }
.kg-stage.split #graph { right: 50%; }
.kg-stage.split .stage-tools { right: calc(50% + 12px); }
.kg-stage.split .stage-top { right: calc(50% + 12px); }
.v3d-bar { display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 8px 0 12px; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.v3d-bar .grow { flex: 1; }
.v3d-info { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.v3d-canvas { flex: 1; min-height: 0; position: relative; }
.v3d-canvas canvas { display: block; }
.stage-tools .icon-btn.active { color: var(--accent); background: var(--accent-soft); }

/* export menu */
.menu-pop { max-height: calc(100vh - 80px); overflow-y: auto; }
.menu-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 6px; }
.menu-sub { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-3); padding: 6px 10px 2px; }
.menu-note { font-size: 11.5px; color: var(--ink-3); padding: 0 10px 6px; }
.menu-item.strong { font-weight: 600; color: var(--accent); border-top: 1px solid var(--line); border-radius: 0; margin-top: 4px; }
.menu-scope select { width: 100%; height: 30px; }
#exportMenu { min-width: 420px; }

/* inspector: relationship rows with provenance button, provenance chain */
.rel-row { display: flex; align-items: stretch; gap: 2px; }
.rel-row .rel-item { flex: 1; min-width: 0; }
.rel-prov { border: 0; background: transparent; color: var(--ink-3); width: 24px; border-radius: 5px; font-size: 13px; }
.rel-prov:hover { background: var(--surface-2); color: var(--accent); }
.prov-step { position: relative; padding: 6px 0 10px 16px; border-left: 2px solid var(--line); margin-left: 4px; font-size: 12.5px; }
.prov-step::before { content: ""; position: absolute; left: -6px; top: 9px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.prov-step:last-child { border-left-color: transparent; }
.prov-step > b { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-3); margin-bottom: 3px; }
.prov-step pre.step { margin-top: 6px; }

/* panels */
.small { font-size: 11.5px; }
.ok { color: var(--ok); font-weight: 600; }
.bad { color: var(--err); font-weight: 600; }
.pcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.pcard { display: grid; gap: 4px; align-content: start; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); cursor: pointer; font-size: 12px; color: var(--ink-2); position: relative; }
.pcard input { position: absolute; opacity: 0; pointer-events: none; }
.pcard b { font-size: 13px; color: var(--ink); }
.pcard.on { border-color: var(--accent-line); box-shadow: inset 0 0 0 1px var(--accent-line); background: var(--accent-soft); }
.pcard details summary { cursor: pointer; color: var(--ink-3); font-size: 11.5px; }
.pcard ul { margin: 4px 0 0; padding-left: 16px; }
.ocards { display: grid; gap: 0; }
.ocard { display: grid; grid-template-columns: 18px 1fr; gap: 6px; padding: 7px 4px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 12.5px; }
.ocard:last-child { border-bottom: 0; }
.ocard input { accent-color: var(--accent); margin-top: 3px; }
.warnlist { font-size: 12px; color: var(--ink-2); display: grid; gap: 3px; max-height: 120px; overflow: auto; padding: 6px 8px; background: var(--warn-soft); border-radius: 6px; margin-top: 6px; }
.nl-bar { display: flex; gap: 6px; margin-bottom: 8px; }
.nl-bar input { flex: 1; height: 34px; font-size: 13.5px; }
.nl-res { padding: 8px 10px; border-radius: 6px; background: var(--accent-soft); font-size: 12.5px; margin-bottom: 8px; }
.nl-res.warn { background: var(--warn-soft); }
.sq-editor { position: relative; height: 210px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); overflow: hidden; }
.sq-editor pre, .sq-editor textarea { position: absolute; inset: 0; margin: 0; padding: 10px 12px; font-family: var(--mono); font-size: 12.5px; line-height: 1.5; white-space: pre; overflow: auto; tab-size: 2; border: 0; }
.sq-editor pre { pointer-events: none; color: var(--ink); background: transparent; }
.sq-editor pre code { font: inherit; }
.sq-editor textarea { resize: none; background: transparent; color: transparent; caret-color: var(--ink); outline: none; }
.sq-editor textarea:focus { box-shadow: inset 0 0 0 2px var(--accent-line); }
.hl-k { color: var(--accent); font-weight: 600; }
.hl-v { color: #b45309; }
.hl-s { color: #15803d; }
.hl-i { color: #7c3aed; }
.hl-p { color: #0e7490; }
.hl-c { color: var(--ink-3); font-style: italic; }
[data-theme="dark"] .hl-v { color: #fbbf24; }
[data-theme="dark"] .hl-s { color: #4ade80; }
[data-theme="dark"] .hl-i { color: #c4b5fd; }
[data-theme="dark"] .hl-p { color: #67e8f9; }
.errbox { margin-top: 10px; padding: 10px 12px; border-radius: 6px; background: var(--danger-soft); color: var(--ink); font-size: 12.5px; }
.errbox pre { white-space: pre-wrap; font-family: var(--mono); font-size: 11.5px; margin: 6px 0; }
.drawer-body .toolbar select { height: 28px; }

/* lens rows: title on one line, count as a sub-line */
.lens { grid-template-columns: 28px minmax(0, 1fr); row-gap: 1px; }
.lens-icon { grid-row: span 2; }
.lens-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lens-count { grid-column: 2; justify-self: start; max-width: 100%; padding: 0; background: none; line-height: 14px; font-size: 10.5px; }
.lens-desc { grid-column: 1 / -1; margin: 4px 0 0; }
.drawer-body .toolbar select, .drawer-body .toolbar input[type="search"] { width: auto; min-width: 140px; max-width: 360px; flex: 0 1 auto; }
.sq-editor pre code { all: unset; font: inherit; white-space: pre; }
.kg-stage.split .stage-stats { display: none; }
.v3d-bar > b { white-space: nowrap; font-size: 13px; }
.data td .muted.small, .data td .small { white-space: normal; }

/* 3D viewer overlay */
.v3d-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.v3d-overlay > * { pointer-events: auto; }
.v3d-side { position: absolute; right: 10px; top: 10px; display: flex; flex-direction: column; gap: 2px; padding: 3px; background: var(--hud); border: 1px solid var(--line); border-radius: 9px; box-shadow: var(--shadow-hud); backdrop-filter: blur(6px); }
.v3d-side button { height: 28px; min-width: 48px; padding: 0 8px; border: 0; border-radius: 6px; background: transparent; color: var(--ink-2); font-size: 12px; font-weight: 500; }
.v3d-side button:hover { background: var(--surface-2); color: var(--ink); }
.v3d-side button.on { background: var(--accent-soft); color: var(--accent); }
.v3d-side .sep { height: 1px; background: var(--line); margin: 3px 2px; }
.v3d-bottom { position: absolute; left: 10px; bottom: 10px; display: flex; align-items: center; gap: 8px; padding: 4px 8px; background: var(--hud); border: 1px solid var(--line); border-radius: 9px; box-shadow: var(--shadow-hud); backdrop-filter: blur(6px); max-width: calc(100% - 90px); }
.v3d-bottom select { height: 26px; width: auto; max-width: 150px; font-size: 12px; }
.v3d-cut { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.v3d-cut input { width: 100px; accent-color: var(--accent); }
.v3d-help { position: absolute; right: 70px; top: 10px; display: grid; gap: 2px; padding: 10px 12px; background: var(--hud); border: 1px solid var(--line); border-radius: 9px; box-shadow: var(--shadow-hud); font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.v3d-help b { color: var(--ink); margin-bottom: 2px; }
.v3d-tip { position: absolute; pointer-events: none; z-index: 5; padding: 4px 8px; font-size: 12px; background: var(--hud); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow-hud); color: var(--ink); white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.v3d-canvas canvas:focus-visible { box-shadow: inset 0 0 0 2px var(--accent-line); }
.ai-box { margin: 0 0 8px; padding: 6px 10px; border: 1px dashed var(--line-strong); border-radius: 6px; font-size: 12.5px; }
.ai-box summary { cursor: pointer; color: var(--ink-2); font-weight: 500; }
.ai-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 6px 10px; margin-top: 8px; }
.ai-grid label { display: flex; flex-direction: column; gap: 2px; color: var(--ink-2); font-size: 12px; }
.ai-grid input, .ai-grid select { width: 100%; box-sizing: border-box; height: 32px; }
.ai-err { color: var(--danger); margin-top: 4px; }
