:root {
  --panel: rgba(13, 17, 23, 0.94);
  --panel-w: 400px;
  --ink: #d6dde6;
  --dim: #8b97a6;
  --faint: #4b5563;
  --line: #1f2937;
  --accent: #61afef;
  --accent-2: #98c379;
  --danger: #ff6b6b;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, "Fira Code", monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: #000; color: var(--ink); font: 13px/1.45 var(--font); overflow: hidden; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, select, input { font: inherit; color: inherit; }

#app { position: fixed; inset: 0; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }

/* ---------- left panel ---------- */
#panel {
  position: absolute; top: 0; left: 0; bottom: 0; width: var(--panel-w); max-width: 100vw;
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; overflow: hidden;
  transition: transform .25s ease;
}
#app.hide-panel #panel { transform: translateX(-100%); }
#panel .bar { display: flex; align-items: center; gap: 6px; padding: 10px 12px 6px; }
#panel h1 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: .3px; }
#panel h1 span { color: var(--accent); font-weight: 700; margin-left: 4px; }
.grow { flex: 1; }
.row { display: flex; gap: 8px; padding: 4px 12px 8px; }
.row select { flex: 1; min-width: 0; }

select, button {
  background: #161c25; border: 1px solid #263244; border-radius: 6px; padding: 5px 10px; cursor: pointer;
}
select:hover, button:hover { border-color: #3b4a60; background: #1b2330; }
button:active { transform: translateY(1px); }
button.icon { width: 32px; height: 32px; padding: 0; display: inline-grid; place-items: center; font-size: 15px; line-height: 1; }
button.on { border-color: var(--accent); color: var(--accent); }
button.rec { border-color: var(--danger); color: var(--danger); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .45; } }

.sec-title { display: flex; align-items: center; gap: 8px; padding: 6px 12px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); }
.status { font-size: 11px; text-transform: none; letter-spacing: 0; margin-left: auto; }
.status.ok { color: var(--accent-2); }
.status.err { color: var(--danger); }
.status.busy { color: var(--dim); }

.field { display: flex; flex-direction: column; padding: 0 12px; flex: 0 0 auto; }
#editor { height: min(38vh, 380px); min-height: 120px; }
.errors {
  margin-top: 6px; padding: 6px 8px; border-radius: 6px; background: rgba(255, 107, 107, .12); border: 1px solid rgba(255, 107, 107, .35);
  color: #ffb3b3; font: 12px/1.4 var(--mono); white-space: pre-wrap; max-height: 120px; overflow: auto;
}

/* ---------- settings ---------- */
.settings { flex: 1; overflow-y: auto; padding: 6px 0 12px; scrollbar-width: thin; scrollbar-color: #2b3646 transparent; }
.grp { padding: 6px 12px 2px; }
.grp-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); padding: 8px 0 4px; border-top: 1px solid var(--line); margin-bottom: 2px; }
.grp:first-child .grp-title { border-top: 0; }
.ctl { display: flex; align-items: center; gap: 8px; padding: 3px 0; min-height: 26px; }
.ctl .lbl { flex: 0 0 118px; color: var(--ink); }
.ctl .val { flex: 0 0 66px; text-align: right; color: var(--dim); font-variant-numeric: tabular-nums; font-size: 12px; }
.ctl input[type=range] { flex: 1; min-width: 0; accent-color: var(--accent); height: 20px; cursor: pointer; }
.ctl select { flex: 1; min-width: 0; padding: 3px 8px; }
.ctl input[type=color] { width: 44px; height: 24px; padding: 0; border: 1px solid #263244; border-radius: 6px; background: #161c25; cursor: pointer; }
.ctl input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.ctl input[type=number] { width: 100%; min-width: 0; background: #161c25; border: 1px solid #263244; border-radius: 6px; padding: 3px 6px; font: 12px var(--mono); }
.box-grid { flex: 1; display: grid; grid-template-columns: 34px 1fr 1fr 1fr; gap: 4px; align-items: center; }
.box-grid .k { color: var(--dim); font-size: 11px; }

.about { padding: 8px 12px 10px; font-size: 11px; color: var(--dim); border-top: 1px solid var(--line); }

/* ---------- overlays ---------- */
#toolbar { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; }
#toolbar button { background: rgba(13, 17, 23, .85); }
#stats {
  position: absolute; right: 12px; bottom: 10px; font: 11px/1.4 var(--mono); color: var(--dim);
  background: rgba(13, 17, 23, .6); padding: 3px 8px; border-radius: 6px; pointer-events: none; white-space: nowrap;
}
#toast {
  position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #161c25; border: 1px solid #3b4a60; padding: 8px 14px; border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.5);
}

.modal { position: absolute; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 10; }
.modal-card { width: min(680px, 94vw); max-height: 88vh; display: flex; flex-direction: column; background: #0d1117; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.modal-card header { display: flex; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-card h2 { margin: 0; font-size: 16px; }
.modal-card h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); margin: 16px 0 6px; }
.modal-body { padding: 4px 16px 16px; overflow: auto; }
.modal-body pre { background: #0a0d12; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font: 12px/1.5 var(--mono); overflow: auto; }
.modal-body code { font: 12px var(--mono); color: #e5c07b; }
.modal-body table { border-collapse: collapse; width: 100%; }
.modal-body td { padding: 3px 8px 3px 0; vertical-align: top; border-bottom: 1px solid #141a22; }
.modal-body td:first-child { white-space: nowrap; width: 40%; }

@media (max-width: 700px) {
  :root { --panel-w: 100vw; }
  #panel { width: 100vw; }
  #editor { height: 30vh; }
}
