:root {
  --bg: #12181f;
  --panel: #1a222c;
  --panel2: #212b37;
  --ink: #dfe7ef;
  --muted: #8ba0b5;
  --line: #2c3947;
  --accent: #35c3d8;
  --accent-dim: #1d6c78;
  --canvas-bg: #14191f;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 14px; }
.mono { font-family: var(--mono); }

/* ---------- index page ---------- */
.page .wrap { max-width: 60rem; margin: 0 auto; padding: 3rem 1.5rem; }
.brand { color: var(--accent); font-weight: 800; letter-spacing: .25em; font-size: .8rem; }
.brand.small { font-size: .7rem; text-decoration: none; }
.page h1 { font-size: 1.6rem; line-height: 1.3; margin: .6rem 0; letter-spacing: -0.01em; }
.page .sub { color: var(--muted); max-width: 60ch; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 1.2rem 1.5rem; margin: 1.2rem 0; }
.card h2 { font-size: 1.05rem; margin: 0 0 .8rem; }
.uploader { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; }
.uploader input[type=file] { color: var(--muted); }
.uploader button { background: var(--accent); color: #06232b; font-weight: 700; border: 0; border-radius: 8px; padding: .55rem 1.1rem; cursor: pointer; }
.uploader button:hover { filter: brightness(1.1); }
.hint { color: var(--muted); font-size: .85rem; }
.flash { background: #3a2c14; border: 1px solid #7a5a1e; border-radius: 10px; padding: .8rem 1rem; margin: 1rem 0; }
.flash p { margin: .2rem 0; }
table.models { width: 100%; border-collapse: collapse; }
table.models th { text-align: left; color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; padding: .4rem .6rem; border-bottom: 1px solid var(--line); }
table.models td { padding: .55rem .6rem; border-bottom: 1px solid var(--line); }
table.models tr:last-child td { border-bottom: 0; }
table.models .name { font-weight: 600; }
a.open { color: var(--accent); text-decoration: none; font-weight: 600; }
a.open:hover { text-decoration: underline; }
footer { color: var(--muted); font-size: .8rem; margin-top: 2rem; }

/* ---------- viewer page ---------- */
.viewerpage { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
#topbar { display: flex; align-items: center; gap: 1rem; padding: .5rem .9rem; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: nowrap; }
#filename { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 26ch; }
#spacetabs { display: flex; gap: .3rem; }
#spacetabs button { background: var(--panel2); color: var(--muted); border: 1px solid var(--line); border-radius: 7px; padding: .25rem .7rem; cursor: pointer; font-size: .8rem; }
#spacetabs button.active { background: var(--accent-dim); color: #fff; border-color: var(--accent); }
#search { margin-left: auto; background: var(--panel2); border: 1px solid var(--line); color: var(--ink); border-radius: 8px; padding: .35rem .7rem; width: 240px; }
#stats { color: var(--muted); font-size: .75rem; white-space: nowrap; }
#main { flex: 1; display: flex; min-height: 0; }
aside { width: 230px; background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; flex-shrink: 0; }
#right { width: 300px; border-right: 0; border-left: 1px solid var(--line); }
.panelhead { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); padding: .7rem .9rem .4rem; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; background: var(--panel); }
.panelhead button { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 6px; cursor: pointer; padding: .05rem .4rem; }
#layers { padding: 0 .5rem .8rem; }
.layerrow { display: flex; align-items: center; gap: .5rem; padding: .22rem .4rem; border-radius: 6px; cursor: pointer; font-size: .82rem; }
.layerrow:hover { background: var(--panel2); }
.layerrow .sw { width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(255,255,255,.25); flex-shrink: 0; }
.layerrow .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.layerrow.off .n { color: var(--muted); text-decoration: line-through; }
.layerrow .cnt { margin-left: auto; color: var(--muted); font-size: .72rem; }
#canvaswrap { flex: 1; position: relative; min-width: 0; background: var(--canvas-bg); }
#scene, #overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
#overlay { pointer-events: none; }
#hud { position: absolute; left: .7rem; bottom: .7rem; display: flex; gap: .6rem; align-items: center; }
#hud button { background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; width: 34px; height: 34px; font-size: 1rem; cursor: pointer; }
#coords { color: var(--muted); font-size: .75rem; font-family: var(--mono); background: rgba(20,25,31,.75); padding: .2rem .5rem; border-radius: 6px; }
#loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--canvas-bg); color: var(--muted); font-size: 1rem; z-index: 5; }
#props, #results { padding: .3rem .9rem 1rem; font-size: .84rem; }
#props table { width: 100%; border-collapse: collapse; }
#props td { padding: .22rem 0; vertical-align: top; border-bottom: 1px solid var(--line); }
#props td.k { color: var(--muted); width: 42%; padding-right: .5rem; }
#props td.v { font-family: var(--mono); font-size: .78rem; word-break: break-word; }
#props .typ { display: inline-block; background: var(--accent-dim); color: #fff; border-radius: 6px; padding: .1rem .5rem; font-size: .75rem; font-weight: 700; margin-bottom: .5rem; }
#props .handle { font-family: var(--mono); color: var(--accent); }
.resrow { padding: .3rem .5rem; border-radius: 6px; cursor: pointer; font-size: .8rem; border-bottom: 1px solid var(--line); }
.resrow:hover { background: var(--panel2); }
.resrow .t { color: var(--accent); font-family: var(--mono); font-size: .72rem; }
button.zoomto { margin-top: .6rem; background: var(--accent); border: 0; color: #06232b; font-weight: 700; border-radius: 7px; padding: .35rem .8rem; cursor: pointer; }
