/* Brevity IFC Viewer */
:root {
  --bg: #f3f5f9;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --line: #e3e8f0;
  --line-2: #eef1f6;
  --text: #0b1f3a;
  --muted: #5b6b86;
  --faint: #8b98ad;
  --accent: #1e5ff2;
  --accent-ink: #ffffff;
  --accent-weak: #e9f0ff;
  --hover: #f1f4f9;
  --danger: #d7362b;
  --ok: #12855a;
  --stage-top: #f8fafd;
  --stage-bottom: #dde5f0;
  --shadow: 0 1px 2px rgba(11, 31, 58, 0.06), 0 8px 28px rgba(11, 31, 58, 0.1);
  --shadow-sm: 0 1px 2px rgba(11, 31, 58, 0.08), 0 2px 8px rgba(11, 31, 58, 0.06);
  --radius: 10px;
  --left: 312px;
  --right: 348px;
  --row: 28px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, Menlo, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0a111c;
  --panel: #111a29;
  --panel-2: #0e1623;
  --line: #223049;
  --line-2: #1a2538;
  --text: #e9eff9;
  --muted: #9dadc5;
  --faint: #6f819d;
  --accent: #6b97ff;
  --accent-ink: #06122b;
  --accent-weak: #17274a;
  --hover: #18233a;
  --danger: #ff7a70;
  --ok: #4fd1a1;
  --stage-top: #1a2740;
  --stage-bottom: #0a101b;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 13px/1.4 var(--font);
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
[hidden] { display: none !important; }
svg.i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 6px; }
::selection { background: var(--accent-weak); }

.app {
  display: grid;
  grid-template-columns: var(--left) 5px minmax(0, 1fr) 5px var(--right);
  grid-template-rows: 48px minmax(0, 1fr);
  height: 100dvh;
}
.app[data-empty="1"] { grid-template-columns: 0 0 minmax(0, 1fr) 0 0; }
.app[data-empty="1"] .panel, .app[data-empty="1"] .gutter { display: none; }
.app[data-left="0"] { --left: 0px; }
.app[data-right="0"] { --right: 0px; }
.app[data-left="0"] .left, .app[data-left="0"] .gutter-left, .app[data-right="0"] .right, .app[data-right="0"] .gutter-right { display: none; }
.app[data-left="0"], .app[data-right="0"] { }
.app[data-left="0"]:not([data-empty="1"]) { grid-template-columns: 0 0 minmax(0, 1fr) 5px var(--right); }
.app[data-right="0"]:not([data-empty="1"]) { grid-template-columns: var(--left) 5px minmax(0, 1fr) 0 0; }
.app[data-left="0"][data-right="0"]:not([data-empty="1"]) { grid-template-columns: 0 0 minmax(0, 1fr) 0 0; }

/* ------------------------------------------------------------------ top bar */
.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px 0 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  min-width: 0;
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; font-size: 14px; letter-spacing: -0.01em; white-space: nowrap; }
.top-actions, .top-right { display: flex; align-items: center; gap: 6px; flex: none; }
.chips { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; padding: 0 4px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 4px 0 9px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--panel-2); white-space: nowrap; max-width: 260px; flex: none; font-size: 12.5px;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.chip .name { overflow: hidden; text-overflow: ellipsis; font-weight: 550; }
.chip .meta { color: var(--faint); font-size: 11.5px; }
.chip button { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; color: var(--faint); }
.chip button:hover { background: var(--hover); color: var(--text); }
.chip.off .name { text-decoration: line-through; color: var(--faint); }
.chip.loading { border-style: dashed; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); font-weight: 550; white-space: nowrap; transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--hover); }
a.btn { text-decoration: none; color: inherit; }
.btn.back { padding: 0 10px 0 8px; color: var(--muted); border-right: 1px solid var(--line); border-radius: 8px 0 0 8px; margin-right: 2px; }
.btn.back:hover { color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.sm { height: 26px; padding: 0 8px; font-size: 12px; border-radius: 6px; gap: 5px; }
.btn.icon { width: 32px; padding: 0; }
.btn.sm.icon { width: 26px; }
.btn[aria-pressed="true"] { background: var(--accent-weak); color: var(--accent); border-color: transparent; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.lg { height: 44px; padding: 0 20px; font-size: 15px; border-radius: 10px; }

/* ------------------------------------------------------------------ panels */
.panel { background: var(--panel); min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.panel.left { grid-column: 1; grid-row: 2; }
.panel.right { grid-column: 5; grid-row: 2; }
.gutter { grid-row: 2; background: var(--line); cursor: col-resize; position: relative; z-index: 3; width: 5px; background-clip: content-box; padding: 0 2px; }
.gutter:hover, .gutter.active { background: var(--accent); background-clip: content-box; }
.gutter-left { grid-column: 2; }
.gutter-right { grid-column: 4; }
.tabs { display: flex; gap: 2px; padding: 8px 8px 0; border-bottom: 1px solid var(--line); flex: none; }
.tab {
  position: relative; height: 32px; padding: 0 10px; border-radius: 7px 7px 0 0; color: var(--muted); font-weight: 550; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.tab:hover { color: var(--text); background: var(--hover); }
.tab[aria-selected="true"] { color: var(--accent); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; background: var(--accent); border-radius: 2px; }
.tab .count { font-size: 11px; color: var(--faint); font-weight: 500; }
.tabs .spacer { flex: 1; }
.search { padding: 8px; flex: none; border-bottom: 1px solid var(--line-2); }
.field {
  display: flex; align-items: center; gap: 7px; height: 32px; padding: 0 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); color: var(--muted);
}
.field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); background: var(--panel); }
.field input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); height: 100%; }
.field input::placeholder { color: var(--faint); }
.field button { color: var(--faint); display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; }
.field button:hover { background: var(--hover); color: var(--text); }
.field kbd { font: 11px var(--font); color: var(--faint); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
.panel-body { flex: 1; min-height: 0; overflow: auto; position: relative; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.panel-note { padding: 28px 22px; color: var(--muted); text-align: center; line-height: 1.5; }
.panel-note svg.i { width: 28px; height: 28px; color: var(--faint); stroke-width: 1.4; margin-bottom: 8px; }
.panel-note b { display: block; color: var(--text); font-size: 14px; margin-bottom: 4px; }
.listbar { display: flex; align-items: center; gap: 6px; padding: 6px 10px; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--line-2); position: sticky; top: 0; background: var(--panel); z-index: 2; }
.listbar .spacer { flex: 1; }
.link { color: var(--accent); font-weight: 550; }
.link:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ virtual list / tree rows */
.vlist { position: relative; }
.vrow {
  position: absolute; left: 0; right: 0; height: var(--row); display: flex; align-items: center; gap: 4px; padding-right: 6px; cursor: default; white-space: nowrap; user-select: none;
}
.vrow:hover { background: var(--hover); }
.vrow.sel { background: var(--accent-weak); }
.vrow.sel .label { color: var(--accent); font-weight: 600; }
.vrow.off .label, .vrow.off .sub { color: var(--faint); opacity: 0.7; }
.vrow .tw { width: 18px; height: 18px; display: grid; place-items: center; color: var(--faint); flex: none; border-radius: 4px; }
.vrow .tw:hover { background: var(--line); color: var(--text); }
.vrow .tw svg { transition: transform 0.1s; width: 12px; height: 12px; }
.vrow.open > .tw svg { transform: rotate(90deg); }
.vrow .ico { width: 16px; height: 16px; flex: none; color: var(--muted); display: grid; place-items: center; }
.vrow .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); margin: 0 3px; }
.vrow .label { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.vrow .sub { color: var(--faint); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
.vrow .grow { flex: 1; min-width: 4px; }
.vrow .n { color: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; padding: 0 4px; flex: none; }
.vrow .eye { width: 22px; height: 22px; border-radius: 5px; display: grid; place-items: center; color: var(--faint); flex: none; opacity: 0; }
.vrow:hover .eye, .vrow.off .eye, .vrow .eye:focus-visible { opacity: 1; }
.vrow .eye:hover { background: var(--line); color: var(--text); }
.vrow .eye svg { width: 14px; height: 14px; }
.vrow.group .label { color: var(--muted); font-weight: 550; }
.vrow.spatial .label { font-weight: 600; }
.vrow mark { background: #ffe58a; color: #3b2f00; border-radius: 2px; padding: 0 1px; }
:root[data-theme="dark"] .vrow mark { background: #6b5a12; color: #fff3c0; }
.vrow .tagbtn { height: 20px; padding: 0 7px; border-radius: 5px; font-size: 11px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); flex: none; opacity: 0; }
.vrow:hover .tagbtn, .vrow .tagbtn[aria-pressed="true"] { opacity: 1; }
.vrow .tagbtn:hover { background: var(--panel); color: var(--text); }
.vrow .tagbtn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ------------------------------------------------------------------ stage */
.stage { container-type: inline-size; grid-column: 3; grid-row: 2; position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--bg); }
.view { position: relative; flex: 1; min-height: 0; overflow: hidden; background: linear-gradient(180deg, var(--stage-top), var(--stage-bottom)); }
.view canvas.gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; cursor: default; }
.view.dragging canvas.gl { cursor: grabbing; }
.view.dragging[data-nav="pan"] canvas.gl { cursor: move; }
.overlay > .pivot-dot {
  width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: var(--accent); border: 2px solid #fff;
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 28%, transparent), 0 1px 6px rgba(11, 31, 58, 0.4);
}
.view[data-tool="measure"] canvas.gl { cursor: crosshair; }
.overlay { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.overlay > div { position: absolute; left: 0; top: 0; will-change: transform; }
.mlabel { background: #e5484d; color: #fff; font-weight: 650; font-size: 12px; padding: 2px 7px; border-radius: 999px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.mdot { width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%; background: #fff; border: 2px solid #e5484d; }
.snap { width: 14px; height: 14px; margin: -7px 0 0 -7px; border: 2px solid #e5484d; border-radius: 50%; background: rgba(229, 72, 77, 0.15); }
.snap.vertex { border-radius: 2px; background: #fff; transform-origin: center; }

.status {
  position: absolute; left: 12px; top: 12px; display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); pointer-events: none;
  background: color-mix(in srgb, var(--panel) 82%, transparent); backdrop-filter: blur(8px); padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line); max-width: 46%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.status:empty { display: none; }
.status .bar { width: 90px; height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; flex: none; }
.status .bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.15s; }
.status b { color: var(--text); font-weight: 600; }

.float { position: absolute; display: flex; gap: 6px; z-index: 2; }
.float.top-left { left: 12px; top: 46px; }
.float .btn { box-shadow: var(--shadow-sm); }

.toolbar {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; align-items: stretch; gap: 2px; padding: 5px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); max-width: calc(100% - 24px); overflow-x: auto; scrollbar-width: none; z-index: 3;
}
.toolbar::-webkit-scrollbar { display: none; }
.tool {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 54px; height: 48px; padding: 0 7px; border-radius: 9px; color: var(--muted);
  font-size: 10.5px; font-weight: 550; white-space: nowrap; flex: none;
}
.tool svg.i { width: 18px; height: 18px; }
.tool:hover { background: var(--hover); color: var(--text); }
.tool[aria-pressed="true"] { background: var(--accent-weak); color: var(--accent); }
.tool:disabled { opacity: 0.4; cursor: default; background: none; }
.toolbar .sep { width: 1px; background: var(--line); margin: 6px 4px; flex: none; }

.toolpanel {
  position: absolute; left: 12px; bottom: 82px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  padding: 12px 14px; width: min(440px, calc(100% - 24px)); z-index: 3;
}
.toolpanel h3 { margin: 0 0 8px; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.toolpanel h3 .spacer { flex: 1; }
.toolpanel p { margin: 0 0 8px; color: var(--muted); }
.secrow { display: grid; grid-template-columns: 20px 96px minmax(120px, 1fr) 70px auto; align-items: center; gap: 8px; height: 34px; }
.secnum { width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.secbtns { display: flex; }
.secadd { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.seccaps { display: flex; align-items: center; gap: 8px; margin-top: 8px; color: var(--muted); }
.overlay > .sec-handle {
  position: absolute; left: 0; top: 0; pointer-events: auto; width: 38px; height: 38px; border-radius: 50%; background: var(--accent); color: #fff; border: 3px solid #fff; display: grid; place-items: center;
  box-shadow: 0 2px 10px rgba(11, 31, 58, 0.35); cursor: grab; touch-action: none;
}
.overlay > .sec-handle.active { cursor: grabbing; box-shadow: 0 0 0 8px color-mix(in srgb, var(--accent) 25%, transparent), 0 2px 10px rgba(11, 31, 58, 0.35); }
.sec-handle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.view[data-tool="section"] canvas.gl { cursor: crosshair; }
.secrow label { font-weight: 550; }
.secrow output { font-variant-numeric: tabular-nums; color: var(--muted); text-align: right; font-size: 12px; }
input[type="range"] { accent-color: var(--accent); width: 100%; }
input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
.mlist { margin: 6px 0 0; padding: 0; list-style: none; max-height: 140px; overflow: auto; }
.mlist li { display: flex; justify-content: space-between; gap: 16px; padding: 3px 0; font-variant-numeric: tabular-nums; border-top: 1px solid var(--line-2); }
.mlist li span { color: var(--muted); }

.legend {
  position: absolute; left: 12px; top: 56px; width: 240px; max-height: min(60%, 420px); display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); z-index: 2; overflow: hidden;
}
.legend header { display: flex; align-items: center; gap: 6px; padding: 8px 8px 8px 12px; font-weight: 650; border-bottom: 1px solid var(--line-2); }
.legend header span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend ul { list-style: none; margin: 0; padding: 4px; overflow: auto; }
.legend li { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 6px; cursor: pointer; }
.legend li:hover { background: var(--hover); }
.legend li i { width: 12px; height: 12px; border-radius: 3px; flex: none; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); }
.legend li span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend li em { font-style: normal; color: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.legend .ramp { height: 10px; margin: 10px 12px 2px; border-radius: 5px; }
.legend .ramp-labels { display: flex; justify-content: space-between; padding: 0 12px 10px; color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }

.hint {
  position: absolute; right: 12px; bottom: 84px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-sm); padding: 10px 12px; z-index: 2;
  display: grid; grid-template-columns: auto auto; gap: 4px 12px; font-size: 12px; color: var(--muted); max-width: 300px;
}
.hint b { color: var(--text); font-weight: 600; }
.hint .close { grid-column: 1 / -1; justify-self: end; color: var(--accent); font-weight: 600; margin-top: 4px; }

/* ------------------------------------------------------------------ view cube */
.cube-wrap { position: absolute; right: 10px; top: 10px; width: 136px; height: 136px; z-index: 2; user-select: none; -webkit-user-select: none; }
.cube-orbit { position: absolute; inset: 0; perspective: 460px; cursor: grab; touch-action: none; }
.cube-orbit.dragging, .cube-orbit.dragging .cell { cursor: grabbing; }
.cube { position: absolute; left: 50%; top: 50%; width: 0; height: 0; transform-style: preserve-3d; }
.cface {
  position: absolute; left: -30px; top: -30px; width: 60px; height: 60px; display: grid; grid-template: 13px 34px 13px / 13px 34px 13px; backface-visibility: hidden;
  background: color-mix(in srgb, var(--panel) 95%, var(--text)); border: 1px solid color-mix(in srgb, var(--line) 60%, var(--muted)); border-radius: 3px;
}
.cface[data-face="top"] { background: var(--panel); }
.cface[data-face="left"], .cface[data-face="right"] { background: color-mix(in srgb, var(--panel) 90%, var(--text)); }
.cface[data-face="bottom"] { background: color-mix(in srgb, var(--panel) 85%, var(--text)); }
.cface .cell { cursor: grab; border-radius: 2px; outline-offset: -2px; }
.cface .cell.hot { background: var(--accent); }
.cface .clabel { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; color: var(--muted); font-size: 10px; font-weight: 650; letter-spacing: 0.02em; text-transform: uppercase; white-space: nowrap; }
.cface:has(.cell:nth-child(5).hot) .clabel { color: var(--accent-ink); }
.cring {
  position: absolute; left: -54px; top: -54px; width: 108px; height: 108px; border-radius: 50%; transform: translate3d(0, 34px, 0) rotateX(90deg); cursor: ew-resize;
  background: repeating-conic-gradient(from -2deg, color-mix(in srgb, var(--muted) 75%, transparent) 0 4deg, color-mix(in srgb, var(--panel) 80%, transparent) 4deg 45deg);
  -webkit-mask: radial-gradient(closest-side, transparent 80%, #000 82%); mask: radial-gradient(closest-side, transparent 80%, #000 82%);
  border: 1px solid var(--muted); opacity: 0.75; transition: opacity 0.15s;
}
.cube-wrap:hover .cring { opacity: 1; }
.cube-wrap .home { position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%; background: var(--panel); border: 1px solid var(--line); display: grid; place-items: center; color: var(--muted); box-shadow: var(--shadow-sm); }
.cube-wrap .home:hover { color: var(--accent); }
.cube-wrap .home svg { width: 13px; height: 13px; }
.cnudge { position: absolute; width: 22px; height: 22px; display: none; place-items: center; color: var(--muted); }
.cube-wrap.at-face .cnudge { display: grid; }
.cnudge::before { content: ""; width: 12px; height: 7px; background: currentColor; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.cnudge:hover { color: var(--accent); }
.cnudge.up { left: 57px; top: -2px; }
.cnudge.down { left: 57px; bottom: -2px; transform: rotate(180deg); }
.cnudge.left { left: -2px; top: 57px; transform: rotate(-90deg); }
.cnudge.right { right: -2px; top: 57px; transform: rotate(90deg); }
.app[data-empty="1"] .cube-wrap, .app[data-empty="1"] .toolbar, .app[data-empty="1"] .status, .app[data-empty="1"] .float { display: none; }

/* ------------------------------------------------------------------ welcome */
.welcome { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; overflow: auto; background: linear-gradient(180deg, var(--stage-top), var(--stage-bottom)); z-index: 4; }
.app:not([data-empty="1"]) .welcome { display: none; }
.wcard { width: min(640px, 100%); text-align: center; }
.wdrop {
  border: 2px dashed color-mix(in srgb, var(--accent) 45%, var(--line)); border-radius: 20px; background: color-mix(in srgb, var(--panel) 86%, transparent); padding: 44px 28px 34px;
  transition: border-color 0.15s, background 0.15s, transform 0.15s; cursor: pointer;
}
.wdrop:hover { border-color: var(--accent); background: var(--panel); }
.wdrop .art { width: 108px; height: 108px; margin: 0 auto 14px; display: block; }
.wdrop h1 { margin: 0 0 6px; font-size: 24px; letter-spacing: -0.02em; line-height: 1.2; }
.wdrop p { margin: 0 auto 20px; color: var(--muted); font-size: 14.5px; max-width: 440px; }
.wdrop .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.wfacts { display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: center; margin-top: 18px; color: var(--muted); font-size: 12.5px; }
.wfacts span { display: inline-flex; align-items: center; gap: 6px; }
.wfacts svg.i { width: 14px; height: 14px; color: var(--ok); }
.dropveil { position: absolute; inset: 0; z-index: 9; background: color-mix(in srgb, var(--accent) 16%, transparent); backdrop-filter: blur(2px); display: grid; place-items: center; pointer-events: none; }
.dropveil > div { background: var(--panel); border: 2px dashed var(--accent); border-radius: 18px; padding: 26px 34px; font-size: 18px; font-weight: 650; color: var(--accent); box-shadow: var(--shadow); }

/* ------------------------------------------------------------------ properties */
.phead { padding: 12px 14px 10px; border-bottom: 1px solid var(--line-2); }
.phead .cls { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; color: var(--accent); background: var(--accent-weak); border-radius: 999px; padding: 2px 9px; }
.phead .cls small { font-weight: 500; opacity: 0.75; font-size: 10.5px; }
.phead h2 { margin: 7px 0 2px; font-size: 16px; line-height: 1.25; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.phead .typ { color: var(--muted); overflow-wrap: anywhere; }
.phead .acts { display: flex; gap: 5px; margin-top: 10px; flex-wrap: wrap; }
.pfilter { padding: 8px 10px; border-bottom: 1px solid var(--line-2); position: sticky; top: 0; background: var(--panel); z-index: 2; }
.psec { border-bottom: 1px solid var(--line-2); }
.psec > summary {
  list-style: none; display: flex; align-items: center; gap: 6px; padding: 8px 12px 8px 8px; cursor: pointer; font-weight: 650; user-select: none; position: sticky; top: 49px; background: var(--panel); z-index: 1;
}
.psec > summary::-webkit-details-marker { display: none; }
.psec > summary .tw { width: 16px; height: 16px; display: grid; place-items: center; color: var(--faint); }
.psec > summary .tw svg { width: 11px; height: 11px; transition: transform 0.1s; }
.psec[open] > summary .tw svg { transform: rotate(90deg); }
.psec > summary .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.psec > summary .badge { font-size: 10.5px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; }
.psec > summary .n { font-size: 11px; color: var(--faint); font-weight: 500; }
.psec > summary:hover { background: var(--hover); }
.ptable { padding: 0 6px 8px 8px; }
.prow { display: grid; grid-template-columns: minmax(90px, 42%) minmax(0, 1fr); gap: 10px; padding: 4px 6px; border-radius: 6px; align-items: baseline; position: relative; }
.prow:hover { background: var(--hover); }
.prow .k { color: var(--muted); overflow-wrap: anywhere; }
.prow .v { overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.prow .v .u { color: var(--faint); margin-left: 3px; }
.prow .v.yes { color: var(--ok); font-weight: 600; }
.prow .v.no { color: var(--faint); }
.prow .v.null { color: var(--faint); }
.prow .v a, .prow .v .go { color: var(--accent); font-weight: 550; cursor: pointer; }
.prow .v .go:hover { text-decoration: underline; }
.prow .copy { position: absolute; right: 4px; top: 3px; width: 22px; height: 22px; border-radius: 5px; display: none; place-items: center; background: var(--panel); border: 1px solid var(--line); color: var(--muted); }
.prow:hover .copy { display: grid; }
.prow .copy svg { width: 12px; height: 12px; }
.prow.child { padding-left: 18px; }
.layers { display: flex; height: 26px; margin: 2px 12px 8px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.layers i { display: block; min-width: 4px; border-right: 1px solid rgba(255, 255, 255, 0.5); }
.layers i:last-child { border-right: 0; }
.mrow { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 8px; padding: 4px 12px; align-items: center; }
.mrow i { width: 10px; height: 10px; border-radius: 3px; }
.mrow span { overflow-wrap: anywhere; }
.mrow em { font-style: normal; color: var(--muted); font-variant-numeric: tabular-nums; }
.mrow small { color: var(--faint); display: block; }
.kv-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px; }
.kv-card { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; min-width: 0; }
.kv-card small { color: var(--muted); display: block; font-size: 11px; }
.kv-card b { font-size: 15px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.bars { padding: 4px 12px 12px; }
.barrow { display: grid; grid-template-columns: minmax(0, 1fr) 46px; gap: 8px; align-items: center; padding: 3px 0; cursor: pointer; border-radius: 6px; }
.barrow:hover .lbl { color: var(--accent); }
.barrow .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; position: relative; padding: 2px 6px; z-index: 0; }
.barrow .lbl::before { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--w); background: var(--accent-weak); border-radius: 5px; z-index: -1; }
.barrow em { font-style: normal; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; font-size: 12px; }
.modelcard { border-bottom: 1px solid var(--line); }
.modelcard > header { display: flex; align-items: center; gap: 8px; padding: 12px 12px 4px; }
.modelcard > header .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.modelcard > header b { flex: 1; overflow-wrap: anywhere; font-size: 14px; }

/* ------------------------------------------------------------------ drawer (data table) */
.drawer { flex: none; height: 300px; background: var(--panel); border-top: 1px solid var(--line); display: flex; flex-direction: column; min-height: 120px; position: relative; }
.drawer .grip { position: absolute; left: 0; right: 0; top: -3px; height: 6px; cursor: row-resize; z-index: 3; }
.drawer .grip:hover { background: var(--accent); opacity: 0.6; }
.dbar { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-bottom: 1px solid var(--line); flex: none; overflow-x: auto; scrollbar-width: none; }
.dbar > * { flex: none; }
.dbar::-webkit-scrollbar { display: none; }
.dbar .tabs { border: 0; padding: 0; }
.dbar .tab { border-radius: 7px; height: 28px; }
.dbar .tab[aria-selected="true"] { background: var(--accent-weak); }
.dbar .tab[aria-selected="true"]::after { display: none; }
.dbar .field { height: 28px; width: 220px; }
.dbar .spacer { flex: 1 0 0; }
.dbar .info { color: var(--muted); font-size: 12px; white-space: nowrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.seg button { height: 26px; padding: 0 9px; color: var(--muted); font-weight: 550; font-size: 12px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent-weak); color: var(--accent); }
.grid { flex: 1; min-height: 0; overflow: auto; position: relative; scrollbar-width: thin; }
.grid table { border-collapse: separate; border-spacing: 0; min-width: 100%; font-variant-numeric: tabular-nums; }
.grid th { position: sticky; top: 0; background: var(--panel-2); z-index: 2; text-align: left; font-weight: 600; color: var(--muted); height: 30px; padding: 0 10px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line-2); white-space: nowrap; cursor: pointer; user-select: none; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.grid th small { display: block; font-weight: 500; color: var(--faint); font-size: 10px; line-height: 1; }
.grid th .srt { color: var(--accent); margin-left: 4px; }
.grid td { height: 26px; padding: 0 10px; border-bottom: 1px solid var(--line-2); border-right: 1px solid var(--line-2); white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.grid td.num { text-align: right; }
.grid tr.r { cursor: pointer; }
.grid tr.r:hover td { background: var(--hover); }
.grid tr.r.sel td { background: var(--accent-weak); }
.grid tr.grp td { background: var(--panel-2); font-weight: 650; position: sticky; }
.grid tr.sum td { font-weight: 650; border-top: 1px solid var(--line); }
.grid .pad td { padding: 0; border: 0; }
.colpick { max-height: 60vh; overflow: auto; width: 320px; }
.colpick .setname { padding: 6px 10px 2px; font-size: 11px; font-weight: 650; color: var(--faint); text-transform: uppercase; letter-spacing: 0.04em; position: sticky; top: 0; background: var(--panel); }
.colpick label { display: flex; align-items: center; gap: 8px; padding: 4px 10px; border-radius: 6px; cursor: pointer; }
.colpick label:hover { background: var(--hover); }
.colpick label span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.colpick label em { font-style: normal; color: var(--faint); font-size: 11px; }

/* ------------------------------------------------------------------ menus, toasts, dialogs */
.menu {
  position: fixed; z-index: 50; min-width: 200px; max-width: 340px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 5px;
  max-height: 80vh; overflow: auto;
}
.menu .mi { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 10px; border-radius: 6px; text-align: left; }
.menu .mi:hover, .menu .mi:focus-visible { background: var(--hover); outline: none; }
.menu .mi svg.i { color: var(--muted); }
.menu .mi span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu .mi kbd { font: 11px var(--font); color: var(--faint); }
.menu .mi.on { color: var(--accent); font-weight: 600; }
.menu .mi.on svg.i { color: var(--accent); }
.menu .mi:disabled { opacity: 0.45; cursor: default; }
.menu hr { border: 0; border-top: 1px solid var(--line-2); margin: 4px 2px; }
.menu .mh { padding: 6px 10px 3px; font-size: 11px; font-weight: 650; color: var(--faint); text-transform: uppercase; letter-spacing: 0.04em; }
.menu .field { margin: 3px 3px 5px; height: 30px; }
.toasts { position: fixed; left: 50%; top: 58px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; align-items: center; pointer-events: none; }
.toast { background: var(--text); color: var(--panel); padding: 8px 14px; border-radius: 10px; box-shadow: var(--shadow); font-weight: 550; max-width: min(520px, 90vw); pointer-events: auto; animation: toast-in 0.18s ease-out; }
.toast.err { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }
.modal-back { position: fixed; inset: 0; z-index: 70; background: rgba(8, 16, 30, 0.45); display: grid; place-items: center; padding: 16px; }
.modal { background: var(--panel); border-radius: 16px; box-shadow: var(--shadow); width: min(560px, 100%); max-height: 86vh; overflow: auto; padding: 20px 22px; }
.modal h2 { margin: 0 0 12px; font-size: 18px; }
.modal .keys { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; align-items: center; }
.modal .keys kbd { font: 12px var(--font); font-weight: 600; background: var(--panel-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 2px 7px; white-space: nowrap; justify-self: start; }
.modal .keys span { color: var(--muted); }
.modal h3 { margin: 16px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--faint); }
.modal .foot { display: flex; justify-content: flex-end; margin-top: 18px; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin 0.7s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

@container (max-width: 820px) {
  .tool { min-width: 42px; height: 40px; padding: 0 5px; }
  .tool span { display: none; }
  .toolbar .sep { margin: 6px 2px; }
}
/* ------------------------------------------------------------------ small screens */
@media (max-width: 900px) {
  .app, .app[data-left="0"]:not([data-empty="1"]), .app[data-right="0"]:not([data-empty="1"]), .app[data-left="0"][data-right="0"]:not([data-empty="1"]) {
    grid-template-columns: minmax(0, 1fr);
  }
  .gutter { display: none; }
  .stage { grid-column: 1; }
  .panel.left, .panel.right {
    grid-column: 1; grid-row: 2; position: absolute; top: 48px; bottom: 0; width: min(88vw, 360px); z-index: 20; box-shadow: var(--shadow); display: none;
  }
  .panel.left { left: 0; border-right: 1px solid var(--line); }
  .panel.right { right: 0; border-left: 1px solid var(--line); }
  .app[data-left="1"]:not([data-empty="1"]) .panel.left, .app[data-right="1"]:not([data-empty="1"]) .panel.right { display: flex; }
  .brand span { display: none; }
  .tool { min-width: 46px; }
  .tool span { display: none; }
  .tool { height: 40px; }
  .toolpanel { bottom: 70px; width: calc(100% - 24px); }
  .secrow { grid-template-columns: 20px 76px minmax(60px, 1fr) 62px auto; }
  .status { max-width: 60%; }
  .cube-wrap { transform: scale(0.8); transform-origin: top right; }
  .btn .lbl { display: none; }
  .hint { display: none; }
  .drawer { height: 46vh; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
