:root{
  --bg:#0f1116;
  --card:#161a23;
  --card2:#111520;
  --text:#e8e6e3;
  --muted:#b8bcc6;
  --head:#f4f2ef;
  --border:rgba(255,255,255,.10);
  --green:#3ddc84;
  --green2:rgba(61,220,132,.20);
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background:var(--bg);
  color:var(--text);
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 18px;
  border-bottom:1px solid var(--border);
  background:linear-gradient(180deg, rgba(22,26,35,.95), rgba(15,17,22,.95));
  position:sticky; top:0; z-index:10;
}

.brand{display:flex; gap:12px; align-items:center}
.dot{
  width:12px; height:12px; border-radius:999px;
  background:var(--green);
  box-shadow:0 0 18px rgba(61,220,132,.55);
}
.title{font-weight:800; letter-spacing:.2px}
.subtitle{font-size:12px; color:var(--muted); margin-top:2px}

.actions{display:flex; gap:10px}
.btn{
  border:1px solid var(--border);
  background:rgba(255,255,255,.03);
  color:var(--head);
  padding:10px 12px;
  border-radius:14px;
  cursor:pointer;
}
.btn:hover{border-color:rgba(255,255,255,.18)}
.btn.primary{
  border-color:rgba(61,220,132,.35);
  background:rgba(61,220,132,.10);
}

.layout{
  display:grid;
  grid-template-columns: 1fr 340px;
  gap:14px;
  padding:14px;
  max-width: 1280px;
  margin:0 auto;
}

.viz{display:flex; flex-direction:column; gap:14px}
.controls{display:flex; flex-direction:column; gap:14px}

.panel{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:18px;
  padding:14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}

.panelHead{display:flex; align-items:baseline; justify-content:space-between; gap:12px}
.panelHead h2{margin:0; font-size:16px; color:var(--head)}
.hint{font-size:12px; color:var(--muted)}

canvas{
  width:100%;
  height:auto;
  display:block;
  margin-top:10px;
  background:rgba(0,0,0,.18);
  border:1px solid rgba(255,255,255,.06);
  border-radius:14px;
}

.grid2{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:14px;
}

.miniRow{
  display:flex;
  gap:10px;
  margin-top:10px;
  flex-wrap:wrap;
}

.pill{
  background:rgba(255,255,255,.04);
  border:1px solid rgba(255,255,255,.08);
  border-radius:999px;
  padding:6px 10px;
  font-size:12px;
  color:var(--muted);
}

.explain{
  margin-top:10px;
  font-size:12.5px;
  color:var(--muted);
  line-height:1.45;
  background:rgba(255,255,255,.03);
  border:1px solid rgba(255,255,255,.07);
  border-radius:14px;
  padding:10px;
}

.code{
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size:12px;
  color:var(--head);
  background:rgba(61,220,132,.08);
  border:1px solid rgba(61,220,132,.18);
  padding:1px 6px;
  border-radius:999px;
}

.ctrl{margin-top:12px}
.ctrl label{display:block; font-size:12px; color:var(--muted); margin-bottom:6px}
.ctrl input[type="range"]{width:100%}
.row{display:flex; justify-content:space-between; font-size:12px; color:var(--muted); margin-top:4px}

.callout{
  margin-top:14px;
  border-radius:16px;
  border:1px solid rgba(61,220,132,.18);
  background:rgba(61,220,132,.06);
  padding:12px;
}
.calloutTitle{font-weight:800; color:var(--head); font-size:13px; margin-bottom:6px}
.calloutBody{font-size:12.5px; color:var(--muted); line-height:1.45}
.calloutBody ul{margin:8px 0 0 18px; padding:0}
.calloutBody li{margin:6px 0}

.footnote{
  margin-top:10px;
  font-size:12px;
  color:rgba(184,188,198,.85);
}

.sticky{position:sticky; top:76px}

@media (max-width: 980px){
  .layout{grid-template-columns:1fr}
  .sticky{position:relative; top:auto}
  .grid2{grid-template-columns:1fr}
}

#btnBalance{padding:4px 12px;font-size:12px;background:#2a2d35;color:#3ddc84;border:1px solid #3ddc84;border-radius:4px;cursor:pointer;}
#btnBalance:hover{background:#3ddc84;color:#1a1d24;}
