:root{
  --ink:#f2f5f9;
  --ink-dim:rgba(242,245,249,.72);
  --ink-faint:rgba(242,245,249,.48);
  /* smoked, not clear: the chrome has to stay legible over Sunlit and
     Snowdrift as well as over the dark scenes */
  --glass:rgba(9,13,20,.46);
  --glass-hi:rgba(255,255,255,.13);
  --edge:rgba(255,255,255,.18);
  --edge-soft:rgba(255,255,255,.11);
  --ease:cubic-bezier(.22,.61,.36,1);
  /* the frost axis — driven by the Look panel, remembered per scene */
  --frost:9px; --frost-far:36px;
  --bloom-x:70%; --bloom-y:24%;
  --bloom-c:120,150,190; --bloom-a:.0;
  --grade-c:90,120,160; --grade-a:.10;
}
*{margin:0;padding:0;box-sizing:border-box}
html,body{height:100%;overflow:hidden;background:#05070c}
body{
  font-family:'Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
  color:var(--ink);
  -webkit-font-smoothing:antialiased;
  cursor:default;
}

/* ─────────────────────────  THE WINDOW  ───────────────────────── */
#stage{position:fixed;inset:0;overflow:hidden;z-index:0}

/* the world outside — rendered sharp, diffused by CSS so drop lenses can
   sample the untouched pixel data underneath */
#sky,#skyEdge{
  /* overscan: keeps the blur's own soft edge off screen even at the top
     of the frost range. Must stay in step with PAD in the script. */
  position:absolute;left:-96px;top:-96px;
  width:calc(100% + 192px);height:calc(100% + 192px);
  display:block;
}
#sky{filter:blur(var(--frost)) saturate(1.06)}
#skyEdge{
  filter:blur(var(--frost-far)) saturate(1.12);
  -webkit-mask-image:radial-gradient(ellipse 76% 70% at 50% 44%,transparent 34%,#000 100%);
  mask-image:radial-gradient(ellipse 76% 70% at 50% 44%,transparent 34%,#000 100%);
}
/* The renderers. Both stay alive at once and dissolve between each other
   by opacity — cutting one with display:none is what made leaving
   Rainfall snap. #rfx starts transparent and the frame loop sets it. */
#gl,#rfx{position:absolute;inset:0;width:100%;height:100%;display:block}
#rfx{opacity:0}

/* The 2D buffers still do all the scene drawing, they are just never
   shown: the shaders read them as textures. */
#sky,#skyEdge,#glass,#grain,#vignette{display:none}

/* the near face: sheen, smudges, and what the room throws back at you */
#surface{
  position:absolute;inset:0;pointer-events:none;opacity:var(--surface-a,.55);
  mix-blend-mode:screen;transition:opacity 1.2s var(--ease);
  background-repeat:no-repeat;
  background-size:100% 100%;
}

#grain{
  position:absolute;inset:0;opacity:.05;mix-blend-mode:overlay;
  background-repeat:repeat;background-size:140px 140px;pointer-events:none;
}
#bloom{
  position:absolute;inset:-10%;pointer-events:none;mix-blend-mode:screen;
  opacity:var(--bloom-mul,1);
  background:radial-gradient(circle 46vmax at var(--bloom-x) var(--bloom-y),
    rgba(var(--bloom-c),var(--bloom-a)) 0%,rgba(var(--bloom-c),0) 62%);
  transition:background 2.6s var(--ease);
}
#grade{
  position:absolute;inset:0;pointer-events:none;mix-blend-mode:soft-light;
  opacity:var(--grade-mul,1);
  background:rgba(var(--grade-c),var(--grade-a));
  transition:background 2.6s var(--ease);
}
/* window bevel: you are behind the glass, not in front of it */
#bezel{
  position:absolute;inset:0;pointer-events:none;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.10),
    inset 0 0 0 1px rgba(255,255,255,.045),
    inset 0 -120px 160px -110px rgba(0,0,0,.75),
    inset 0 130px 150px -110px rgba(255,255,255,.06);
}
#vignette{
  position:absolute;inset:0;pointer-events:none;
  background:radial-gradient(ellipse 92% 86% at 50% 46%,transparent 44%,rgba(0,0,0,.58) 100%);
}

/* ─────────────────────────  CHROME  ───────────────────────── */
#ui{
  position:fixed;inset:0;z-index:10;pointer-events:none;
  transition:opacity .8s var(--ease),transform .8s var(--ease);
}
body.idle #ui{opacity:0;transform:translateY(6px)}
body.hidden-ui #ui{opacity:0}
#ui > *{pointer-events:auto}
body.hidden-ui #ui,body.hidden-ui #ui *{pointer-events:none}

/* top left identity */
/* these sit straight on the scene, so they carry their own legibility */
#mark,#clock,#hint{
  text-shadow:0 1px 14px rgba(0,0,0,.6),0 0 3px rgba(0,0,0,.45);
}
#mark{
  position:absolute;top:34px;left:38px;
  display:flex;align-items:baseline;gap:14px;
}
#mark .wm{
  font-size:13px;font-weight:500;letter-spacing:.42em;text-transform:uppercase;
  color:var(--ink);text-indent:.42em;
}
#mark .sep{width:16px;height:1px;background:var(--edge);align-self:center}
#scene-name{
  font-size:12px;font-weight:300;letter-spacing:.26em;text-transform:uppercase;
  color:var(--ink-dim);transition:opacity .5s var(--ease);
}

/* top right clock */
#clock{
  position:absolute;top:30px;right:38px;text-align:right;
}
#clock .t{
  font-size:26px;font-weight:200;letter-spacing:.04em;
  font-variant-numeric:tabular-nums;color:var(--ink);line-height:1.1;
}
#clock .d{
  font-size:10.5px;font-weight:300;letter-spacing:.24em;text-transform:uppercase;
  color:var(--ink-faint);margin-top:5px;
}

/* bottom dock */
#dock{
  position:absolute;left:50%;bottom:42px;transform:translateX(-50%);
  display:flex;flex-direction:column;align-items:center;gap:12px;
  max-width:calc(100vw - 48px);
}

.pill{
  background:var(--glass);
  -webkit-backdrop-filter:blur(26px) saturate(1.7);
  backdrop-filter:blur(26px) saturate(1.7);
  border:1px solid var(--edge);
  box-shadow:0 24px 64px rgba(0,0,0,.42),inset 0 1px 0 rgba(255,255,255,.16);
  border-radius:999px;
}

#bar{
  display:flex;align-items:center;gap:6px;
  padding:8px 10px;
}

.iconbtn{
  width:40px;height:40px;flex:0 0 auto;border:0;border-radius:50%;
  background:transparent;color:var(--ink);cursor:pointer;
  display:grid;place-items:center;
  transition:background .22s var(--ease),color .22s var(--ease);
}
.iconbtn:hover{background:rgba(255,255,255,.11)}
.iconbtn:focus-visible{outline:2px solid rgba(255,255,255,.6);outline-offset:2px}
.iconbtn svg{width:17px;height:17px;fill:currentColor;display:block}
#play{width:44px;height:44px;background:rgba(255,255,255,.13)}
#play:hover{background:rgba(255,255,255,.22)}
#play svg{width:15px;height:15px;margin-left:1px}
#play.on svg{margin-left:0}

.divider{width:1px;height:22px;background:var(--edge-soft);margin:0 5px;flex:0 0 auto}

/* scene selector */
#scenes{display:flex;align-items:center;gap:2px;position:relative}
.scene-btn{
  position:relative;border:0;background:transparent;cursor:pointer;
  color:var(--ink-faint);
  font:inherit;font-size:10.5px;font-weight:500;letter-spacing:.2em;
  text-transform:uppercase;padding:12px 15px 11px;border-radius:999px;
  transition:color .3s var(--ease);white-space:nowrap;
}
.scene-btn:hover{color:var(--ink-dim)}
.scene-btn[aria-selected="true"]{color:var(--ink)}
.scene-btn:focus-visible{outline:2px solid rgba(255,255,255,.6);outline-offset:-2px}
.scene-btn .dot{
  position:absolute;left:50%;bottom:5px;width:3px;height:3px;margin-left:-1.5px;
  border-radius:50%;background:currentColor;opacity:0;transform:scale(.4);
  transition:opacity .3s var(--ease),transform .3s var(--ease);
}
.scene-btn[aria-selected="true"] .dot{opacity:1;transform:scale(1)}

/* volume */
#volwrap{display:flex;align-items:center;gap:2px;padding-right:4px}
#volslot{
  width:0;overflow:hidden;transition:width .42s var(--ease),opacity .3s var(--ease);
  opacity:0;display:flex;align-items:center;
}
#volwrap:hover #volslot,#volwrap:focus-within #volslot,#volslot.pinned{width:92px;opacity:1}

input[type=range]{
  -webkit-appearance:none;appearance:none;background:transparent;
  width:84px;height:22px;cursor:pointer;margin:0 4px;
}
input[type=range]::-webkit-slider-runnable-track{
  height:3px;border-radius:2px;
  background:linear-gradient(to right,rgba(255,255,255,.85) var(--fill,60%),rgba(255,255,255,.18) var(--fill,60%));
}
input[type=range]::-webkit-slider-thumb{
  -webkit-appearance:none;width:11px;height:11px;border-radius:50%;
  background:#fff;margin-top:-4px;box-shadow:0 1px 6px rgba(0,0,0,.5);
  transition:transform .18s var(--ease);
}
input[type=range]:hover::-webkit-slider-thumb{transform:scale(1.18)}
input[type=range]::-moz-range-track{height:3px;border-radius:2px;background:rgba(255,255,255,.18)}
input[type=range]::-moz-range-progress{height:3px;border-radius:2px;background:rgba(255,255,255,.85)}
input[type=range]::-moz-range-thumb{width:11px;height:11px;border:0;border-radius:50%;background:#fff}
input[type=range]:focus-visible{outline:2px solid rgba(255,255,255,.6);outline-offset:3px;border-radius:999px}

/* disclosure panels */
#mixer,#look{
  width:min(420px,calc(100vw - 48px));
  padding:0 20px;border-radius:20px;
  max-height:0;opacity:0;overflow:hidden;
  transition:max-height .5s var(--ease),opacity .4s var(--ease),padding .5s var(--ease);
}
#mixer.open{max-height:340px;opacity:1;padding:16px 20px 18px}
#look.open{max-height:420px;opacity:1;padding:16px 20px 18px}
#tune{width:min(460px,calc(100vw - 48px));padding:0 20px;border-radius:20px;
  max-height:0;opacity:0;overflow:hidden;
  transition:max-height .5s var(--ease),opacity .4s var(--ease),padding .5s var(--ease)}
#tune.open{max-height:min(62vh,560px);opacity:1;padding:16px 20px 18px;overflow-y:auto}
#tn-list .grp{
  margin:12px 0 5px;font-size:9px;letter-spacing:.24em;text-transform:uppercase;
  color:var(--ink-faint);border-top:1px solid var(--edge-soft);padding-top:10px;
}
#tn-list .grp:first-child{margin-top:0;border-top:0;padding-top:0}
#tn-list .knob label{flex:0 0 92px;font-size:11px}
#tn-list .knob output{flex:0 0 52px}
#tn-reset{padding:4px 10px;font-size:9px}

/* look panel */
.knob{display:flex;align-items:center;gap:12px;padding:5px 0}
.knob label{
  flex:0 0 62px;font-size:11.5px;letter-spacing:.05em;color:var(--ink-dim);
}
.knob input[type=range]{flex:1;width:auto}
.knob output{
  flex:0 0 44px;text-align:right;font-size:10.5px;color:var(--ink-faint);
  font-variant-numeric:tabular-nums;
}
.bd{margin-top:10px;padding-top:11px;border-top:1px solid var(--edge-soft)}
.bd-row{display:flex;align-items:center;justify-content:space-between;gap:10px}
.bd-label{font-size:11.5px;letter-spacing:.05em;color:var(--ink-dim)}
.bd-actions{display:flex;gap:6px}
.ghost{
  border:1px solid var(--edge);background:rgba(255,255,255,.05);color:var(--ink-dim);
  font:inherit;font-size:10px;letter-spacing:.12em;text-transform:uppercase;
  padding:6px 11px;border-radius:999px;cursor:pointer;
  transition:background .2s var(--ease),color .2s var(--ease),border-color .2s var(--ease);
}
.ghost:hover{background:rgba(255,255,255,.12);color:var(--ink)}
.ghost:focus-visible{outline:2px solid rgba(255,255,255,.6);outline-offset:2px}
.ghost.danger:hover{background:rgba(255,116,108,.20);border-color:rgba(255,140,132,.5);color:#ffd9d6}
.bd-state{
  margin-top:8px;font-size:10px;letter-spacing:.06em;color:var(--ink-faint);
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.bd-thumb{
  margin-top:9px;display:block;width:132px;height:74px;border-radius:8px;
  border:1px solid var(--edge);object-fit:cover;
}
body.dragging #stage::after{
  content:'';position:absolute;inset:14px;border-radius:14px;pointer-events:none;
  border:1.5px dashed rgba(255,255,255,.5);background:rgba(255,255,255,.05);
}
.mx-head{
  display:flex;justify-content:space-between;align-items:baseline;gap:12px;
  font-size:9.5px;letter-spacing:.24em;text-transform:uppercase;
  color:var(--ink-faint);margin-bottom:12px;
}
.layer{display:flex;align-items:center;gap:12px;padding:5px 0}
.layer .nm{
  flex:0 0 108px;font-size:11.5px;font-weight:400;letter-spacing:.05em;
  color:var(--ink-dim);cursor:pointer;background:none;border:0;text-align:left;
  font-family:inherit;transition:color .2s var(--ease),opacity .2s var(--ease);
  display:flex;align-items:center;gap:7px;
}
.layer .nm:hover{color:var(--ink)}
.layer .nm .led{
  width:5px;height:5px;border-radius:50%;background:currentColor;flex:0 0 auto;
  box-shadow:0 0 7px currentColor;transition:opacity .25s var(--ease);
}
.layer.muted .nm{opacity:.34}
.layer.muted .nm .led{opacity:.2;box-shadow:none}
.layer input[type=range]{flex:1;width:auto}
.layer .cat{
  font-size:9px;letter-spacing:.16em;text-transform:uppercase;color:var(--ink-faint);
  flex:0 0 auto;width:52px;text-align:right;
}
.mx-note{
  margin-top:12px;padding-top:11px;border-top:1px solid var(--edge-soft);
  font-size:10px;font-weight:300;letter-spacing:.06em;color:var(--ink-faint);line-height:1.6;
}
[hidden]{display:none!important}

/* hint */
#hint{
  margin-top:4px;
  font-size:9.5px;letter-spacing:.2em;text-transform:uppercase;color:rgba(242,245,249,.32);
  white-space:nowrap;transition:opacity .6s var(--ease);pointer-events:none;
}

/* ─────────────────────────  GATE  ───────────────────────── */
/* The gate carries its own diffusion, not the Frost axis. Whatever the
   user has dialled in applies to the window they opened — before they
   open it they are looking at closed glass, and closed glass is frosted.
   It also covers the moment the plate behind is still a 24px placeholder.

   7px, not 16. The droplets are the thing that says "this is rain", and
   they are only tens of pixels across — at 16 the gate wiped them off the
   glass and the landing page read as a still photograph behind fog. The
   scene's own frost is already doing most of the work behind this; the
   gate only has to say "closed". */
#gate{
  position:fixed;inset:0;z-index:30;display:grid;place-items:center;
  background:radial-gradient(ellipse 70% 60% at 50% 50%,rgba(4,7,12,.38),rgba(4,7,12,.78));
  -webkit-backdrop-filter:blur(7px) saturate(1.06);
  backdrop-filter:blur(7px) saturate(1.06);
  transition:opacity 1.1s var(--ease),backdrop-filter 1.4s var(--ease),
             -webkit-backdrop-filter 1.4s var(--ease);
}
#gate.gone{opacity:0;pointer-events:none;
  -webkit-backdrop-filter:blur(0) saturate(1);backdrop-filter:blur(0) saturate(1)}
#gate .inner{
  display:flex;flex-direction:column;align-items:center;text-align:center;
  padding:0 16px;
}
/* Sentence case and near-normal tracking. The wide uppercase treatment was
   built for the four-letter wordmark this replaced; on a sentence — and on
   a brand name, which people read as a word — it stops being a style and
   starts being an obstacle. */
/* The gate is the quietest moment in the piece and the type should behave
   like it — 42px was shouting over a scene whose whole point is calm.
   Sizes come from the strings: measured in Inter at weight 300 the
   headline is 22.6em wide and the line under it 34.8em, so the viewport
   each needs is font-size × that. The caps below keep the headline to one
   line down to about 360px and the second line to one down to about 430,
   without either of them dominating the frame. */
#gate .wm{
  font-size:clamp(15px, 2.1vw, 26px);font-weight:300;letter-spacing:.012em;
  line-height:1.32;color:var(--ink);text-wrap:balance;
  animation:rise 1.3s var(--ease) both .15s;
}
#gate .tag{
  margin-top:16px;font-size:clamp(10.5px, 1.3vw, 15px);font-weight:300;
  letter-spacing:.05em;line-height:1.55;color:var(--ink-dim);text-wrap:balance;
  animation:rise 1.3s var(--ease) both .3s;
}
#enter{
  position:relative;
  margin-top:52px;width:78px;height:78px;border-radius:50%;cursor:pointer;
  background:rgba(255,255,255,.06);border:1px solid var(--edge);
  -webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);
  color:var(--ink);display:grid;place-items:center;
  box-shadow:0 20px 60px rgba(0,0,0,.5),inset 0 1px 0 rgba(255,255,255,.2);
  transition:transform .45s var(--ease),background .45s var(--ease),box-shadow .45s var(--ease);
  animation:rise 1.3s var(--ease) both .45s;
}
#enter:hover{transform:scale(1.07);background:rgba(255,255,255,.13);box-shadow:0 26px 70px rgba(0,0,0,.55),inset 0 1px 0 rgba(255,255,255,.3)}
#enter:active{transform:scale(1.01)}
#enter:focus-visible{outline:2px solid rgba(255,255,255,.7);outline-offset:5px}
#enter svg{width:19px;height:19px;fill:currentColor;margin-left:3px}
#enter::after{
  content:'';position:absolute;inset:-1px;border-radius:50%;
  border:1px solid rgba(255,255,255,.28);animation:pulse 3.4s ease-out infinite;
  pointer-events:none;
}
#gate .press{
  margin-top:30px;font-size:9.5px;font-weight:300;letter-spacing:.28em;
  text-transform:uppercase;color:rgba(242,245,249,.28);
  animation:rise 1.3s var(--ease) both .6s;
}
@keyframes rise{from{opacity:0;transform:translateY(14px)}to{opacity:1;transform:none}}
@keyframes pulse{
  0%{transform:scale(1);opacity:.5}
  70%{transform:scale(1.55);opacity:0}
  100%{transform:scale(1.55);opacity:0}
}

/* toast */
#toast{
  position:fixed;left:50%;top:28px;transform:translate(-50%,-16px);z-index:40;
  padding:10px 18px;border-radius:999px;font-size:11px;letter-spacing:.08em;
  background:rgba(20,24,32,.82);border:1px solid var(--edge);color:var(--ink-dim);
  -webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);
  opacity:0;pointer-events:none;transition:opacity .4s var(--ease),transform .4s var(--ease);
}
#toast.show{opacity:1;transform:translate(-50%,0)}

@media (max-width:720px){
  #mark{top:24px;left:22px;gap:10px}
  #mark .wm{font-size:11px}
  #scene-name{font-size:10px}
  #clock{top:20px;right:22px}
  #clock .t{font-size:21px}
  #dock{bottom:26px;gap:10px}
  /* the transport will not fit on one line — give the scenes their own row */
  #bar{flex-wrap:wrap;justify-content:center;border-radius:26px;padding:6px 12px 9px}
  #scenes{order:-1;width:100%;justify-content:center;flex-wrap:wrap}
  .scene-btn{padding:10px 9px;font-size:9.5px;letter-spacing:.11em}
  .divider{display:none}
  #volwrap{display:none}
  #hint{display:none}
  /* the dock already names the active scene, so the top rail need not */
  #scene-name,#mark .sep{display:none}
  #mixer{width:calc(100vw - 32px)}
  .layer .nm{flex:0 0 88px;font-size:11px}
  .layer .cat{display:none}
}
@media (prefers-reduced-motion:reduce){
  *{animation-duration:.01ms!important;animation-iteration-count:1!important}
  #enter::after{display:none}
}
