:root {
  --bg: #07090d;
  --panel: rgba(10, 16, 24, 0.78);
  --line: rgba(80, 220, 255, 0.28);
  --accent: #4de1ff;
  --accent2: #ff5c8a;
  --text: #dbe9f2;
  --muted: #7f95a5;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.4 "Segoe UI", system-ui, sans-serif;
  display: flex; flex-direction: column; overflow: hidden;
}

header {
  display: flex; align-items: center; gap: 16px; padding: 8px 16px;
  border-bottom: 1px solid var(--line); background: #0a0f16;
}
h1 { margin: 0; font-size: 16px; letter-spacing: 0.25em; color: var(--accent); }
h1 span { color: var(--muted); letter-spacing: 0.1em; font-weight: 400; }
.pills { display: flex; gap: 8px; flex: 1; }
.pill {
  padding: 2px 10px; border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted); font-size: 12px;
}
.pill.ok { color: var(--accent); border-color: var(--accent); }
.pill.bad { color: var(--accent2); border-color: var(--accent2); }
.tools { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 12px; }

button {
  background: var(--accent); color: #04222b; border: 0; border-radius: 6px;
  padding: 7px 14px; font: inherit; font-weight: 600; cursor: pointer;
}
button:hover { filter: brightness(1.1); }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
header button { padding: 4px 10px; background: transparent; color: var(--text); border: 1px solid var(--line); }

#workspace { flex: 1; min-height: 0; display: flex; }
#center { flex: 1; min-width: 0; display: grid; place-items: center; }
#stage {
  position: relative; width: 1280px; height: 720px; background: #000;
  overflow: hidden; border: 1px solid var(--line);
}
#cam { position: absolute; inset: 0; width: 100%; height: 100%; transform: scaleX(-1); object-fit: fill; filter: brightness(0.75); }
#gl, #fx { position: absolute; inset: 0; }
#gl { pointer-events: none; }
#gl canvas { display: block; }
#fx { width: 100%; height: 100%; cursor: crosshair; }

#palette {
  position: absolute; left: 12px; top: 12px; bottom: 12px; width: 150px;
  display: flex; flex-direction: column; gap: 6px; justify-content: safe center; overflow-y: auto;
  scrollbar-width: none;
}
.palette-item {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 4px 10px; line-height: 1.3; color: var(--text); cursor: pointer; flex: none; user-select: none;
  backdrop-filter: blur(4px); transition: transform .08s, border-color .08s, background .08s;
}
.palette-item b { display: block; font-size: 13px; }
.palette-item small { color: var(--muted); font-size: 11px; }
.palette-item:hover, .palette-item.hot {
  border-color: var(--accent); background: rgba(77, 225, 255, 0.16); transform: translateX(4px);
}

#trash {
  position: absolute; right: 12px; bottom: 12px; width: 120px; height: 90px;
  display: grid; place-items: center; text-align: center; font-size: 12px; color: var(--muted);
  border: 2px dashed var(--line); border-radius: 12px; background: var(--panel);
}
#trash.armed { border-color: var(--accent2); color: var(--accent2); background: rgba(255, 92, 138, 0.18); }

#partLabel {
  position: absolute; transform: translate(-50%, -100%); pointer-events: none; display: none;
  padding: 3px 10px; border-radius: 6px; background: var(--panel); border: 1px solid var(--accent);
  color: var(--accent); font-size: 12px; white-space: nowrap;
}
#hint {
  position: absolute; left: 180px; right: 150px; bottom: 10px; text-align: center;
  color: var(--muted); font-size: 12px; pointer-events: none; text-shadow: 0 1px 3px #000;
}
#hint b { color: var(--text); }

#splash { position: fixed; inset: 0; background: rgba(4, 7, 11, 0.92); display: grid; place-items: center; z-index: 10; }
#splash.hidden { display: none; }
.card { max-width: 460px; padding: 28px; border: 1px solid var(--line); border-radius: 14px; background: #0b121a; }
.card h2 { margin: 0 0 10px; color: var(--accent); letter-spacing: 0.15em; }
.card p { margin: 0 0 12px; }
.card button { margin: 6px 8px 0 0; }
.small { font-size: 12px; color: var(--muted); }
.err { color: var(--accent2); }

header button.primary { background: var(--accent); color: #04222b; border-color: var(--accent); }

#checklist {
  position: absolute; right: 12px; top: 12px; width: 230px; padding: 10px 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; font-size: 12px;
  backdrop-filter: blur(4px); transition: border-color .2s;
}
#checklist h3 { margin: 0 0 6px; font-size: 11px; letter-spacing: .15em; color: var(--muted); font-weight: 600; }
#checklist div { display: flex; gap: 8px; padding: 1px 0; color: var(--muted); }
#checklist div.ok { color: var(--text); }
#checklist div.ok i { color: #5df2a0; }
#checklist div.opt i { color: var(--muted); }
#checklist i { font-style: normal; width: 14px; text-align: center; color: var(--accent2); }
#checklist small { margin-left: auto; color: var(--muted); }
#checklist.flash { border-color: var(--accent2); }

#simhud {
  position: absolute; left: 12px; top: 12px; display: none; padding: 10px 14px; min-width: 250px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; font-size: 12px; line-height: 1.7;
  font-variant-numeric: tabular-nums;
}
#simhud b { color: var(--accent); }
#simhud button { margin-top: 6px; padding: 3px 10px; }
#simhud kbd { border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; color: var(--text); }

body.sim #palette, body.sim #trash, body.sim #partLabel, body.sim #checklist, body.sim #hint, body.sim #cam { display: none !important; }
body.sim #simhud { display: block; }
body.sim #btn-sim, body.sim #btn-clear { display: none; }

/* ---- CoppeliaSim-style docks ------------------------------------------------------------ */
.dock { width: 230px; flex: none; background: #0a0f16; border: 0 solid var(--line); overflow-y: auto; font-size: 12px; display: none; }
#tree { border-right-width: 1px; }
#inspector { border-left-width: 1px; width: 250px; }
body.show-tree #tree, body.show-insp #inspector { display: block; }
body.sim .dock { display: none !important; }
.dock-head { padding: 8px 12px; font-size: 10px; letter-spacing: .18em; color: var(--muted); border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #0a0f16; z-index: 1; }
header button.toggle.on { border-color: var(--accent); color: var(--accent); }
header button.stop, body.sim #btn-stop { background: var(--accent2); border-color: var(--accent2); color: #2a0612; }
#btn-stop { display: none; }
body.sim #btn-stop { display: inline-block; }

.node { display: flex; align-items: center; gap: 6px; padding: 3px 8px; cursor: pointer; white-space: nowrap; border-left: 2px solid transparent; }
.node:hover { background: rgba(77,225,255,.08); }
.node.sel { background: rgba(77,225,255,.18); border-left-color: var(--accent); color: #fff; }
.node small { color: var(--muted); margin-left: auto; padding-left: 8px; overflow: hidden; text-overflow: ellipsis; }
.node .dot { width: 8px; height: 8px; border-radius: 2px; background: var(--accent); flex: none; }
.node .ref { color: var(--muted); }
.tree-empty { padding: 14px; color: var(--muted); }

#insp-body { padding: 10px 12px; }
#insp-body h4 { margin: 12px 0 6px; font-size: 10px; letter-spacing: .15em; color: var(--muted); font-weight: 600; }
#insp-body h4:first-child { margin-top: 0; }
#insp-body .title { color: #fff; font-size: 14px; font-weight: 600; }
.prow { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 4px; margin-bottom: 4px; }
.prow.one { grid-template-columns: 1fr 1fr; }
.prow label { display: flex; flex-direction: column; color: var(--muted); font-size: 10px; gap: 2px; }
.prow input { width: 100%; background: #060a10; color: var(--text); border: 1px solid var(--line); border-radius: 4px; padding: 3px 5px; font: inherit; font-size: 12px; }
.prow input:focus { outline: 1px solid var(--accent); }
.kv { display: flex; justify-content: space-between; padding: 1px 0; color: var(--muted); }
.kv b { color: var(--text); font-weight: 500; }
.btns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.btns button { padding: 3px 10px; background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 500; }
.btns button.danger { color: var(--accent2); border-color: var(--accent2); }
.dim { color: var(--muted); }

/* ---- settings / help / toasts ------------------------------------------------------------ */
#settings { position: fixed; right: 12px; top: 52px; width: 290px; max-height: calc(100vh - 70px); overflow-y: auto; z-index: 8;
  background: #0b121a; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 12px; }
#settings[hidden], .modal[hidden] { display: none; }
#settings h3 { margin: 14px 0 6px; font-size: 10px; letter-spacing: .18em; color: var(--muted); }
#settings label { display: block; margin: 6px 0; color: var(--text); }
#settings label output { float: right; color: var(--accent); }
#settings input[type=range] { width: 100%; }
#settings .check { display: flex; gap: 8px; align-items: center; }
#settings .row { display: flex; justify-content: space-between; align-items: center; }
#settings .row.wrap { flex-wrap: wrap; gap: 6px; justify-content: flex-start; }
#settings button { padding: 4px 10px; }
#settings button.ghost, .card button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.x { background: transparent !important; color: var(--muted) !important; padding: 0 6px !important; }
#meter { margin: 4px 0 8px; }
.mrow { display: grid; grid-template-columns: 44px 1fr 38px; align-items: center; gap: 8px; margin: 3px 0; color: var(--muted); }
.mbar { position: relative; height: 10px; background: #060a10; border: 1px solid var(--line); border-radius: 5px; }
.mbar i { position: absolute; top: 0; bottom: 0; left: 0; background: var(--accent); border-radius: 4px; }
.mbar.on i { background: var(--accent2); }
.mbar u { position: absolute; top: -3px; bottom: -3px; width: 2px; background: #fff; opacity: .7; }
.mbar u.off { opacity: .35; }

.modal { position: fixed; inset: 0; background: rgba(4, 7, 11, 0.85); display: grid; place-items: center; z-index: 12; }
#splash { z-index: 14; }
.card ul { padding-left: 18px; margin: 0 0 12px; }
.card li { margin: 4px 0; }

#toasts { position: absolute; left: 50%; bottom: 46px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; z-index: 5; }
.toast { background: rgba(10, 16, 24, .92); border: 1px solid var(--accent); color: var(--text); padding: 5px 14px; border-radius: 999px; font-size: 12px; animation: pop .2s ease-out; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
#calib { position: absolute; inset: 0; display: none; place-items: center; text-align: center; font-size: 26px; color: #fff; background: rgba(4, 7, 11, .55); z-index: 6; pointer-events: none; }
#checklist h3 { cursor: pointer; }
#checklist.collapsed div { display: none; }

@media (max-width: 1000px) { #hint { display: none; } #checklist { width: 190px; } }
