:root{
  --bg:#0b0712;
  --panel:rgba(255,255,255,.045);
  --panel-2:rgba(255,255,255,.08);
  --line:rgba(226,196,240,.14);
  --line-2:rgba(226,196,240,.32);
  --text:#f3edf7;
  --text-2:#b5a4c5;
  --text-3:#7e6c90;
  --text-4:#50455e;
  --accent:#d646e8;
  --accent-dim:rgba(214,70,232,.5);
  --sans:'Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;
  --serif:'Instrument Serif',Georgia,'Times New Roman',serif;
  --mono:'IBM Plex Mono',ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
}
*{margin:0;padding:0;box-sizing:border-box}
[hidden]{display:none !important}
body.boot *{transition:none !important; animation:none !important}
html,body{height:100%}
body{
  background:var(--bg); color:var(--text); font-family:var(--sans);
  -webkit-font-smoothing:antialiased;
  background-image:radial-gradient(130% 95% at 50% -8%, #1a0f24 0%, #110a19 50%, #09050f 100%);
  background-attachment:fixed;
}
:focus-visible{outline:2px solid var(--accent); outline-offset:2px; border-radius:6px}
button{font-family:inherit; color:inherit; background:none; border:none}

.page{display:flex; flex-direction:column; min-height:100vh}

/* ---------- top bar ---------- */
.bar{
  display:flex; justify-content:space-between; align-items:center; gap:12px;
  padding:max(14px, env(safe-area-inset-top)) 20px 0; flex:none;
}
.home,.icon{
  display:inline-flex; align-items:center; gap:7px; height:38px;
  color:var(--text); text-decoration:none; font:500 14px/1 var(--sans);
  background:var(--panel); border:1px solid var(--line); border-radius:999px;
  cursor:pointer; transition:background .15s, border-color .15s;
}
.home{padding:0 14px 0 10px}
.home span{font-family:var(--serif); font-size:18px; letter-spacing:.01em}
.icon{width:38px; justify-content:center; padding:0; flex:none}
.home:hover,.icon:hover{background:var(--panel-2); border-color:var(--line-2)}

/* ---------- layout ---------- */
main{
  flex:1; display:grid; grid-template-columns:minmax(0,1fr) 322px;
  gap:24px; padding:10px 20px max(22px, env(safe-area-inset-bottom));
  align-items:start; align-content:start;
  width:100%; max-width:1128px; margin:0 auto;
}
.stage{display:flex; flex-direction:column; gap:12px; min-width:0}
.titleblock{max-width:680px; padding:6px 2px 2px}
.kicker{font-size:11.5px; font-weight:600; letter-spacing:.15em; text-transform:uppercase; color:var(--text-3)}
h1{
  font-family:var(--serif); font-weight:400; font-size:clamp(32px, 4.2vw, 54px);
  line-height:.98; letter-spacing:-.01em; margin:4px 0 8px;
}
.sub{font-size:14.5px; line-height:1.55; color:var(--text-2); max-width:66ch}
.sub b{font-weight:600; color:var(--text)}
.lbl{
  font-size:11px; font-weight:600; letter-spacing:.12em; text-transform:uppercase;
  color:var(--text-3); display:flex; justify-content:space-between; align-items:baseline; gap:8px;
}
.lbl .hint{font:600 11px/1 var(--mono); letter-spacing:.02em; text-transform:none; color:var(--accent)}
.srlive{position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap}

/* ---------- the drawing slate ---------- */
.slate{
  position:relative; width:100%; overflow:hidden; border-radius:14px;
  background:#060308; border:1px solid rgba(226,196,240,.14);
  box-shadow:0 22px 46px -30px #000, 0 1px 0 rgba(240,220,248,.06) inset;
  isolation:isolate; touch-action:none;
}
#grid{display:block; width:100%; height:280px; cursor:crosshair}
.hud{
  position:absolute; left:10px; top:9px; bottom:9px; pointer-events:none;
  display:flex; flex-direction:column; justify-content:space-between;
  font:600 10.5px/1 var(--mono); letter-spacing:.03em; color:rgba(243,237,247,.5);
  text-shadow:0 1px 6px rgba(0,0,0,.9);
}
.hud2{
  position:absolute; right:10px; top:9px; pointer-events:none;
}
.chip{
  display:inline-flex; align-items:center; gap:6px; padding:4px 10px 4px 8px;
  border-radius:999px; background:rgba(214,70,232,.2); color:#f6d8fb;
  font:600 11px/1.3 var(--sans); letter-spacing:.01em;
}
.chip::before{content:''; width:7px; height:7px; border-radius:50%; background:var(--accent); box-shadow:0 0 8px var(--accent)}

.cap{display:flex; justify-content:space-between; gap:7px 18px; flex-wrap:wrap; padding:1px 2px}
.legend{font:500 11px/1.3 var(--sans); color:var(--text-3)}

/* ---------- panel ---------- */
.panel{
  display:flex; flex-direction:column; gap:14px; position:sticky; top:12px;
  background:var(--panel); border:1px solid var(--line); border-radius:16px;
  padding:14px 15px 13px;
}
.grp{display:flex; flex-direction:column; gap:8px}
.note{font-size:11.5px; line-height:1.5; color:var(--text-3)}
.rowbetween{display:flex; justify-content:space-between; align-items:baseline; gap:8px}

.seg{display:flex; gap:5px}
.seg button{
  flex:1; height:34px; border-radius:9px; cursor:pointer; padding:0 4px;
  background:var(--panel-2); border:1px solid var(--line);
  font:600 12.5px/1 var(--sans); color:var(--text-2);
  transition:background .14s, border-color .14s, color .14s;
}
.seg.sm button{font-size:11px; height:30px; border-radius:8px}
.seg button:hover{border-color:var(--line-2); color:var(--text)}
.seg button.is-on{background:var(--accent); border-color:var(--accent); color:#260123}

.seg2{display:grid; grid-template-columns:1fr 1fr; gap:6px}
.seg2 button{
  height:40px; border-radius:9px; cursor:pointer; padding:0 6px;
  background:var(--panel-2); border:1px solid var(--line);
  font:600 12px/1.2 var(--sans); color:var(--text-2);
  transition:background .14s, border-color .14s, color .14s;
}
.seg2 button:hover{border-color:var(--line-2); color:var(--text)}
.seg2 button:active{background:rgba(214,70,232,.18); border-color:var(--accent-dim); color:var(--text)}

input[type=range]{
  -webkit-appearance:none; appearance:none; width:100%; height:26px;
  background:transparent; cursor:pointer; display:block;
}
input[type=range]::-webkit-slider-runnable-track{height:5px; border-radius:99px; background:rgba(255,255,255,.13)}
input[type=range]::-moz-range-track{height:5px; border-radius:99px; background:rgba(255,255,255,.13)}
input[type=range]::-webkit-slider-thumb{
  -webkit-appearance:none; appearance:none; width:19px; height:19px; margin-top:-7px;
  border-radius:50%; background:var(--accent); border:none;
  box-shadow:0 1px 5px rgba(0,0,0,.5), 0 0 0 1px rgba(0,0,0,.25);
}
input[type=range]::-moz-range-thumb{width:19px; height:19px; border-radius:50%; background:var(--accent); border:none; box-shadow:0 1px 5px rgba(0,0,0,.5)}

.btn{
  display:flex; align-items:center; justify-content:center; text-align:center; gap:8px;
  padding:0 10px; height:36px; border-radius:10px; cursor:pointer; width:100%;
  background:var(--panel-2); border:1px solid var(--line);
  font:600 12.5px/1 var(--sans); color:var(--text-2);
  transition:background .14s, border-color .14s, transform .08s, color .14s;
}
.btn:hover{background:rgba(255,255,255,.12); border-color:var(--line-2); color:var(--text)}
.btn:active{transform:translateY(1px)}
.btn.big{height:44px; font-size:14px; color:var(--text)}
.btn.accent{background:rgba(214,70,232,.16); border-color:var(--accent-dim); color:#f6d8fb}
.btn.accent[aria-pressed=true]{background:var(--accent); border-color:var(--accent); color:#260123}

.foot{font-size:11.5px; line-height:1.6; color:#5f5470; border-top:1px solid var(--line); padding-top:12px}
.link{color:var(--accent); cursor:pointer; font:inherit; font-weight:600; text-align:left; text-decoration:underline; text-underline-offset:2px}
.link:hover{color:#ee8bf6}

/* ---------- about ---------- */
dialog{border:none; padding:0; background:transparent; max-width:min(706px, 92vw); max-height:86vh; margin:auto}
dialog::backdrop{background:rgba(6,3,10,.68); backdrop-filter:blur(3px)}
.about{
  position:relative; background:#120a19; border:1px solid rgba(226,196,240,.2);
  border-radius:18px; padding:26px 28px 24px; overflow-y:auto; max-height:86vh;
  box-shadow:0 30px 60px -28px #000;
}
.about h2{font-family:var(--serif); font-weight:400; font-size:31px; line-height:1.05; margin:4px 0 14px; color:var(--text)}
.about h3{font-family:var(--serif); font-weight:400; font-size:22px; line-height:1.1; margin:22px 0 10px; color:var(--text)}
.about p{font-size:14.5px; line-height:1.68; color:var(--text-2); margin-bottom:12px}
.about p b{color:var(--text); font-weight:600}
.about em,.about i{font-style:italic}
.about .fine{font-size:12.5px; color:var(--text-3); border-top:1px solid var(--line); padding-top:12px; margin-top:16px; margin-bottom:0}
.x{
  position:absolute; top:14px; right:14px; width:32px; height:32px; cursor:pointer;
  display:flex; align-items:center; justify-content:center; color:var(--text-3);
  background:var(--panel-2); border:1px solid var(--line); border-radius:999px;
}
.x:hover{color:var(--text); border-color:var(--line-2)}

/* ---------- narrow ---------- */
@media (max-width:920px){
  main{grid-template-columns:minmax(0,1fr); gap:16px; padding:8px 14px max(20px, env(safe-area-inset-bottom))}
  .panel{position:static}
  h1{font-size:clamp(28px, 8.2vw, 40px)}
  .sub{font-size:14px}
  #grid{height:230px}
  .about{padding:22px 20px 20px; border-radius:15px}
  .about h2{font-size:26px}
  .about h3{font-size:20px}
}
@media (max-width:420px){
  .hud{font-size:9.5px}
  #grid{height:200px}
}
