:root {
  --bg: #0b1017; --panel: #121923; --line: rgba(255, 255, 255, .1);
  --text: #e8eef4; --mut: #8d9aa8; --accent: #4fd1ff; --warm: #ff9a3c; --pink: #ff5fa2; --green: #8cff6b;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
button, select { font: inherit; color: inherit; cursor: pointer; }

#app { display: grid; grid-template-columns: 1fr 390px; height: 100vh; }
#stage { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden;
  background: radial-gradient(circle at 50% 30%, #17202c 0%, #0b1017 75%); }
#view { position: relative; flex: 1 1 auto; min-height: 280px; }
#main { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }

#clock, #hover, #caption, #busy { position: absolute; background: rgba(11, 16, 23, .78); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 12px; pointer-events: none; }
#clock { top: 12px; left: 12px; padding: 5px 12px; }
#clock small { display: block; color: var(--mut); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
#clock b { font-size: 22px; font-variant-numeric: tabular-nums; }
#clock em { display: block; font-style: normal; color: var(--mut); font-size: 11px; font-variant-numeric: tabular-nums; }
#hover { top: 12px; right: 12px; padding: 7px 11px; font-size: 12px; color: var(--mut); max-width: 250px; line-height: 1.5; font-variant-numeric: tabular-nums; }
#hover:empty { display: none; }
#hover b { color: var(--text); font-weight: 600; }
#caption { left: 12px; right: 12px; bottom: 12px; padding: 8px 14px; font-size: 13.5px; line-height: 1.42; min-height: 3.2em; }
#caption b { display: block; color: var(--accent); font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 2px; }
#caption.warn b { color: var(--warm); }
#caption.alert b { color: var(--pink); }
#busy { top: 50%; left: 50%; transform: translate(-50%, -50%); padding: 12px 18px; text-align: center; font-size: 14px; }
#busy[hidden] { display: none; }
#busy i { display: block; margin-top: 8px; width: 200px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.12); overflow: hidden; }
#busy u { display: block; height: 100%; width: 0; background: var(--accent); text-decoration: none; }

#tools { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 2px; padding: 3px;
  background: rgba(11, 16, 23, .78); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 12px; }
#tools button { background: transparent; border: 0; border-radius: 9px; padding: 6px 11px; font-size: 12.5px; color: var(--mut); }
#tools button:hover { color: var(--text); background: rgba(255,255,255,.08); }
#tools button.on { background: var(--accent); color: #04202b; font-weight: 600; }

#plots { flex: 0 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: 128px 128px; gap: 6px; padding: 6px 10px 10px; border-top: 1px solid var(--line); background: rgba(8, 12, 18, .6); }
#plots figure { margin: 0; position: relative; min-width: 0; background: #0b1017; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
#plots canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

#panel { background: var(--panel); border-left: 1px solid var(--line); padding: 18px 18px 24px; overflow-y: auto; }
#panel h1 { margin: 0 0 4px; font-size: 22px; }
#panel h2 { margin: 18px 0 2px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--mut); }
#panel p { margin: 0; color: var(--mut); font-size: 13px; line-height: 1.45; }
#panel .foot { margin-top: 10px; font-size: 11.5px; }
#budget { font-variant-numeric: tabular-nums; }

.row { display: flex; gap: 8px; margin: 10px 0 6px; }
.row button { flex: 1; padding: 8px 10px; background: rgba(255, 255, 255, .06); border: 1px solid var(--line); border-radius: 10px; font-size: 13px; }
.row button:hover { background: rgba(255, 255, 255, .13); }
.row button.primary { background: var(--accent); color: #04202b; border-color: transparent; font-weight: 600; }
.row button.primary:hover { filter: brightness(1.1); }
.presets button { font-size: 12px; padding: 7px 4px; }
.presets button.on { border-color: var(--accent); background: rgba(79, 209, 255, .16); }

.slider { display: block; margin: 11px 0 0; font-size: 13px; }
.slider output { float: right; font-variant-numeric: tabular-nums; color: var(--accent); }
.slider input { width: 100%; margin: 5px 0 0; accent-color: var(--accent); }
.sel { display: block; margin: 14px 0 0; font-size: 13px; }
.sel select { display: block; width: 100%; margin-top: 5px; padding: 7px 8px; background: #0b1017; border: 1px solid var(--line); border-radius: 8px; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin-top: 12px; font-size: 13px; }
.checks label { display: flex; align-items: center; gap: 6px; cursor: pointer; }

fieldset { margin: 14px 0 0; padding: 8px 12px 10px; border: 1px solid var(--line); border-radius: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
legend { padding: 0 6px; color: var(--mut); font-size: 12px; }
fieldset label { font-size: 13px; display: flex; align-items: center; gap: 6px; cursor: pointer; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }

#stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 12px; }
#stats div { background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 9px; padding: 5px 8px; min-width: 0; }
#stats small { display: block; color: var(--mut); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
#stats b { font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }

@media (max-width: 900px) {
  #app { display: block; height: auto; }
  #stage { height: auto; overflow: visible; }
  #view { flex: none; height: 66vh; min-height: 360px; }
  #plots { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(3, 150px); }
  #panel { border-left: 0; border-top: 1px solid var(--line); }
  #hover { display: none; }
  #tools { left: auto; right: 10px; transform: none; top: 10px; }
  #tools button { padding: 6px 8px; font-size: 12px; }
  #clock { top: 10px; left: 10px; padding: 4px 9px; }
  #clock b { font-size: 18px; }
  #caption { font-size: 12.5px; padding: 6px 10px; left: 8px; right: 8px; bottom: 8px; }
}


details.sci { margin: 12px 0 0; border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px 8px; background: rgba(255,255,255,.03); }
details.sci > summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text); }
details.sci p { margin: 8px 0 0; font-size: 12.5px; }
details.sci code { font-size: 11.5px; color: var(--accent); background: rgba(79,209,255,.08); padding: 1px 4px; border-radius: 4px; }
#chkList { list-style: none; margin: 8px 0 0; padding: 0; font-size: 12px; line-height: 1.4; }
#chkList li { padding: 5px 0; border-top: 1px solid var(--line); color: var(--mut); }
#chkList li:first-child { border-top: 0; }
#chkList li.ok b { color: var(--green); } #chkList li.bad b { color: var(--pink); }
#chkSum { color: var(--mut); font-weight: 400; }
#panel header p { margin-top: 2px; }
body.embed-mode #app { height: 100vh; height: 100dvh; }
@media (max-width: 900px) { body.embed-mode { overflow: auto; } body.embed-mode #app { height: auto; } }
@media (max-width: 900px) { #view { height: 62vh; height: 62dvh; } }
