:root{
  --bg:#0b0d10;
  --panel:rgba(255,255,255,.045);
  --panel-2:rgba(255,255,255,.075);
  --line:rgba(190,210,224,.14);
  --line-2:rgba(190,210,224,.30);
  --text:#eef3f6;
  --text-2:#aab8c2;
  --text-3:#76838c;
  --text-4:#4c5660;
  --accent:#4fa3d1;
  --warm:#4fa3d1;
  --lock:#3ddc97;
  --retract:#d9a441;
  --metal:#c8d0d6;
  --barrel:#20262c;
  --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%, #121a20 0%, #0d1216 52%, #080b0d 100%);
  background-attachment:fixed;
}
:focus-visible{outline:2px solid var(--warm); 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}
.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(34px, 4.4vw, 58px);
  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;
}
.srlive{position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap}

/* ---------- the scene ---------- */
.slate{
  position:relative; width:100%; overflow:hidden; border-radius:14px;
  background:#0a0b0d; border:1px solid var(--line);
  box-shadow:0 22px 46px -30px #000, 0 1px 0 rgba(200,220,235,.06) inset;
  isolation:isolate;
}
#scene{display:block; width:100%; max-width:380px; margin:0 auto; aspect-ratio:260/400; height:auto; max-height:56vh}
.hud{
  position:absolute; left:0; top:0; right:0; pointer-events:none;
  display:flex; align-items:flex-start; justify-content:space-between; gap:10px;
  padding:9px 12px; font:600 11.5px/1.4 var(--mono); letter-spacing:.03em;
  color:rgba(238,243,246,.8); text-shadow:0 1px 6px rgba(0,0,0,.9);
}
.hud .rt{text-align:right; color:rgba(238,243,246,.56)}
.chip{
  display:inline-flex; align-items:center; gap:6px; padding:4px 10px 4px 8px;
  border-radius:999px; background:rgba(217,164,65,.22); color:#ffe2ad;
  text-transform:none; letter-spacing:.01em; text-shadow:none;
}
.chip::before{content:''; width:7px; height:7px; border-radius:50%; background:var(--retract); box-shadow:0 0 8px var(--retract)}
.chip.locked{background:rgba(61,220,151,.2); color:#c6ffe4}
.chip.locked::before{background:var(--lock); box-shadow:0 0 8px var(--lock)}

/* ---------- main scene svg ---------- */
.barrel-body{fill:var(--barrel); stroke:#060708; stroke-width:1.4}
.barrel-sheen{fill:none; stroke:rgba(200,220,235,.1); stroke-width:1.2}
.barrel-cone{fill:var(--barrel); stroke:#060708; stroke-width:1.4}
.barrel-slot{fill:var(--bg)}
.btn-cap{fill:var(--metal); stroke:#060708; stroke-width:1.4}
.btn-cap.pressing{fill:#9aa6ad}
.rod{fill:#4a5258; stroke:#060708; stroke-width:1}
.cam-ring{fill:#2c343a; stroke:var(--metal); stroke-width:1.6; transition:stroke .2s, filter .2s}
.cam-ring.on{stroke:var(--lock); filter:drop-shadow(0 0 5px rgba(61,220,151,.55))}
.cam-tooth{fill:var(--metal)}
.cam-group{transition:transform .36s cubic-bezier(.3,1.5,.5,1)}
.assembly{transition:transform .36s cubic-bezier(.22,1.1,.4,1)}
.assembly.pressing{transition:transform .14s ease-in}
.nib-collar{fill:#3a4248; stroke:#060708; stroke-width:1}
.nib-ball{fill:#4fa3d1}
.spring{fill:none; stroke:#5a646c; stroke-width:2; stroke-linecap:round}
@media (prefers-reduced-motion:reduce){
  .assembly,.cam-group,.comb-top{transition:none !important}
}

/* ---------- mesh inset (unrolled cam) ---------- */
.sensorwrap{
  display:flex; align-items:center; gap:16px; width:100%; border-radius:12px;
  background:rgba(255,255,255,.028); border:1px solid var(--line); padding:10px 14px;
}
#mesh{display:block; width:220px; height:110px; flex:none}
.sensorNote{font-size:11.5px; line-height:1.5; color:var(--text-3)}
.comb-top{fill:var(--metal); transition:transform .36s cubic-bezier(.22,1.1,.4,1)}
.comb-top.pressing{transition:transform .14s ease-in}
.comb-bot{fill:#3a4248}
.meshgap{stroke:var(--text-4); stroke-width:1; stroke-dasharray:2 3}
.meshlabel{font:600 10.5px var(--mono); fill:var(--text-3); letter-spacing:.02em}

/* ---------- 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)}
.note b{color:var(--text-2); font-weight:600}

.readout{
  border-radius:11px; padding:10px 12px; border:1px solid var(--line);
  background:var(--panel-2); font-size:12.5px; line-height:1.5; color:var(--text-2);
}
.readout .big{
  display:block; font:400 25px/1.1 var(--serif); color:var(--text); margin-bottom:4px;
  letter-spacing:.01em;
}
.readout .dim{color:var(--text-3); font-size:12px}
.readout.alt{background:none; border-color:var(--line); font-size:11.5px}
.readout.alt dl{display:grid; grid-template-columns:auto 1fr; gap:4px 10px; align-items:baseline}
.readout.alt dt{color:var(--text-3)}
.readout.alt dd{font:600 12px/1.3 var(--mono); color:var(--text); text-align:right}
.readout.alt dd span{color:var(--text-3); font-weight:400}

.btn{
  display:flex; align-items:center; justify-content:center; text-align:center; gap:8px;
  padding:0 10px; height:34px; border-radius:10px; cursor:pointer; width:100%;
  background:var(--panel-2); border:1px solid var(--line);
  font:600 12px/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:46px; font-size:13.5px; color:var(--text)}
.btn.click{background:rgba(79,163,209,.16); border-color:rgba(79,163,209,.4)}
.btn.click:hover{background:rgba(79,163,209,.26)}

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

/* ---------- about ---------- */
dialog{
  border:none; padding:0; background:transparent; max-width:min(706px, 92vw);
  max-height:86vh; margin:auto;
}
dialog::backdrop{background:rgba(5,8,10,.68); backdrop-filter:blur(3px)}
.about{
  position:relative; background:#10151a; border:1px solid var(--line-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(30px, 8.6vw, 42px)}
  .sub{font-size:14px}
  #scene{max-height:48vh}
  .sensorwrap{flex-direction:column; align-items:flex-start; gap:8px}
  #mesh{width:200px; height:100px}
  .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:10.5px; padding:8px 10px}
  .readout .big{font-size:21px}
}
