:root {
  --bg: #0c0d10;
  --panel: #14161b;
  --panel-2: #191c22;
  --line: #262a33;
  --text: #e8eaee;
  --muted: #a3acbb;
  --muted-2: #c2c9d4;
  --accent: #d6f24b;
  --accent-ink: #14170a;
  --ok: #4ade80;
  --warn: #fbbf24;
  --radius: 12px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { display: flex; flex-direction: column; overflow: hidden; }

/* ------------------------------------------------------------------ topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #12141a, #0e1014);
}
.brand { display: flex; align-items: center; gap: 12px; }
.mark {
  width: 26px; height: 26px; border-radius: 8px;
  background: conic-gradient(from 210deg, var(--accent), #7dd3fc, #f472b6, var(--accent));
  border: 1px solid rgba(255, 255, 255, .16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22);
}
.brand h1 { margin: 0; font-size: 16px; letter-spacing: -.01em; font-weight: 700; }
.brand .dot { color: var(--accent); }
.brand p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.pill {
  font-size: 12px; letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted); border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 10px;
}
.pill.on { color: var(--accent); border-color: rgba(214,242,75,.35); }

/* ------------------------------------------------------------------ layout */
.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 344px 1fr;
}

.panel {
  border-right: 1px solid var(--line);
  background: var(--panel);
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.panel::-webkit-scrollbar { width: 10px; }
.panel::-webkit-scrollbar-thumb { background: #2a2f39; border-radius: 8px; border: 3px solid var(--panel); }

.block { border-top: 1px solid var(--line); padding-top: 12px; }
.block:first-child { border-top: 0; padding-top: 0; }
.block.grow { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.block h2 {
  margin: 0 0 10px; font-size: 12px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 8px;
}
.count {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 0 7px; color: var(--text); font-size: 12px; letter-spacing: 0;
}

/* ------------------------------------------------------------------ drop */
.drop {
  border: 1.5px dashed #313743; border-radius: var(--radius);
  background: radial-gradient(120% 120% at 50% 0%, #1b1f27, #121419);
  padding: 22px 16px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s, transform .1s;
  outline: none;
}
.drop:hover, .drop:focus-visible, .drop.over {
  border-color: var(--accent); background: radial-gradient(120% 120% at 50% 0%, #232a1c, #131610);
}
.drop.over { transform: scale(.995); }
.drop-inner { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--muted); }
.drop-inner strong { color: var(--text); font-size: 14px; }
.drop-inner span { font-size: 12.5px; color: var(--muted-2); }
.drop.busy { pointer-events: none; opacity: .7; }
.progress { margin-top: 12px; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.progress .bar { height: 4px; flex: 1; border-radius: 4px; background: #23272f; overflow: hidden; position: relative; }
.progress .bar::after {
  content: ""; position: absolute; inset: 0; width: var(--p, 0%);
  background: var(--accent); transition: width .15s;
}

/* ------------------------------------------------------------------ file info */
.file-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.file-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.stat { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px; }
.stat b { display: block; font-size: 14px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.warnings {
  margin-top: 10px; font-size: 12.5px; color: var(--warn);
  background: rgba(251,191,36,.07); border: 1px solid rgba(251,191,36,.22);
  border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; gap: 4px;
}

/* ------------------------------------------------------------------ controls */
.check { display: flex; gap: 9px; align-items: flex-start; margin: 8px 0; cursor: pointer; font-size: 13.5px; }
.check input { accent-color: var(--accent); margin-top: 2px; }
.check em { display: block; color: var(--muted); font-style: normal; font-size: 12px; }
.range { display: block; margin-top: 12px; font-size: 13.5px; }
.range span { display: flex; justify-content: space-between; color: var(--muted); }
.range b { color: var(--text); font-variant-numeric: tabular-nums; }
.range input { width: 100%; accent-color: var(--accent); margin-top: 6px; }

/* ------------------------------------------------------------------ parts */
.parts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.part {
  display: grid; grid-template-columns: 22px 1fr auto; gap: 9px; align-items: center;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px;
  padding: 6px 9px; cursor: pointer; transition: border-color .12s, background .12s;
}
.part:hover { border-color: #3a4150; }
.part.hidden-part { opacity: .42; }
.part.solo { border-color: var(--accent); }
.swatch { width: 20px; height: 20px; border-radius: 6px; border: 1px solid rgba(255,255,255,.34); }
.part-name { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.part-meta { font-size: 12px; line-height: 1.35; color: var(--muted); font-variant-numeric: tabular-nums; }
.part-badge {
  font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
  border-radius: 999px; padding: 2px 6px; border: 1px solid var(--line); color: var(--muted);
}
.part-badge.ok { color: var(--ok); border-color: rgba(74,222,128,.3); }
.part-badge.open { color: var(--warn); border-color: rgba(251,191,36,.3); }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 9px 12px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font: inherit; font-size: 13px;
  font-weight: 600; text-decoration: none; cursor: pointer; transition: background .12s, border-color .12s;
}
.btn:hover { background: #20242c; border-color: #3a4150; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.05); }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 6px 0; }
.btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.ghost {
  background: transparent; color: var(--muted); border: 1px solid var(--line);
  border-radius: 8px; padding: 5px 10px; font: inherit; font-size: 12.5px; cursor: pointer;
}
.ghost:hover { color: var(--text); border-color: #3a4150; }
.ghost.small { padding: 3px 8px; font-size: 12px; }
.hint { margin: 10px 0 0; font-size: 12px; color: var(--muted); }

/* ------------------------------------------------------------------ viewport */
.viewport { position: relative; min-height: 0; background: radial-gradient(90% 70% at 50% 0%, #161a21 0%, #0b0c0f 70%); }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.viewport-tools { position: absolute; top: 12px; right: 12px; display: flex; gap: 6px; }
.viewport-tools .ghost { background: rgba(20,22,27,.7); backdrop-filter: blur(6px); }
.empty {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px; text-align: center; padding: 24px;
  pointer-events: none;
}
.empty h2 { margin: 10px 0 0; font-size: 17px; }
.empty p { margin: 2px 0; font-size: 13.5px; color: var(--muted); max-width: 460px; }
.empty .muted { font-size: 12.5px; opacity: .9; }
.empty-art {
  width: 74px; height: 74px; border-radius: 20px;
  background: conic-gradient(from 140deg, #d6f24b, #7dd3fc, #f472b6, #d6f24b);
  opacity: .18; filter: blur(.4px);
}
.status {
  position: absolute; left: 12px; bottom: 12px; font-size: 12.5px; color: var(--muted-2);
  background: rgba(12,13,16,.7); border: 1px solid var(--line); border-radius: 8px;
  padding: 5px 9px; backdrop-filter: blur(6px); max-width: 70%;
}
.status:empty { display: none; }
.status.err { color: #fca5a5; border-color: rgba(248,113,113,.3); }

/* ------------------------------------------------------------------ modal */
.modal {
  position: fixed; inset: 0; background: rgba(5,6,8,.72); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 20;
}
.modal-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 22px; max-width: 540px; width: 100%;
}
.modal-card h2 { margin: 0 0 12px; font-size: 16px; }
.modal-card ol { margin: 0 0 12px; padding-left: 18px; font-size: 13.5px; color: #d8dee8; display: flex; flex-direction: column; gap: 8px; }
.modal-card code { background: #1d2129; border-radius: 4px; padding: 1px 4px; font-size: 12.5px; }
.modal-card .btn { margin-top: 8px; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .panel { border-right: 0; border-bottom: 1px solid var(--line); max-height: 46vh; }
  .viewport { min-height: 54vh; }
}
