/* Visualizer page: setup screen (mood -> visualizer -> make it yours), then one full-window canvas with a controls overlay that fades when idle.
   Colours come only from the theme tokens, so every theme skins this page automatically. */
html, body.viz { height:100%; overflow:hidden; background:#05060f; }
body.viz { font-family:var(--font,system-ui); color:var(--text); }
body.viz::before, body.viz::after { display:none !important; }
body.viz #fakenav, body.viz #taskbar, body.viz #profile { display:none !important; }
#stage, #stage3d { position:fixed; inset:0; width:100%; height:100%; display:block; transition:opacity .26s ease; }
#stage[hidden], #stage3d[hidden] { display:none; }
#stage.fading, #stage3d.fading { opacity:0; }
body.blank, body.blank.viz { background:#000; }
body.blank #stage, body.blank #stage3d { opacity:0; }
[hidden] { display:none !important; }
.visually-hidden { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }
noscript p { position:fixed; inset:30% 10% auto; text-align:center; color:#eef0ff; font:1.1rem system-ui; }

/* ---- shared bits: buttons, pills, rows ---- */
body.viz button, body.viz select, .btn { font:inherit; font-size:.9rem; color:var(--text); background:color-mix(in srgb,var(--card) 84%,transparent); border:1px solid var(--line); border-radius:9px; padding:7px 12px; cursor:pointer; text-decoration:none; display:inline-flex; align-items:center; gap:4px; }
body.viz button:hover, .btn:hover, body.viz select:hover { border-color:var(--accent); }
body.viz button:disabled { opacity:.45; cursor:default; }
body.viz :focus-visible { outline:3px solid var(--accent); outline-offset:2px; }
body.viz button[aria-pressed="true"], body.viz button[aria-expanded="true"]:not(.grab), body.viz button[aria-selected="true"], body.viz button[aria-checked="true"], body.viz button[aria-current="true"] { background:var(--accent); color:var(--on-accent); border-color:var(--accent); }
body.viz .pill { border-radius:99px; font-weight:700; padding:6px 14px; white-space:nowrap; }
body.viz .primary { background:var(--accent); color:var(--on-accent); border-color:var(--accent); font-weight:800; padding:10px 20px; font-size:1rem; }
body.viz .primary:hover { filter:brightness(1.08); }
body.viz .linkish { background:none; border:none; color:var(--muted); text-decoration:underline; padding:4px; }
.row { display:flex; gap:8px; align-items:center; flex-wrap:wrap; margin:8px 0; }
.row.grow input[type=range] { flex:1; min-width:80px; }
.hint { color:var(--muted); font-size:.82rem; line-height:1.45; margin:4px 0; }
kbd { font:inherit; font-size:.78rem; padding:1px 7px; border:1px solid var(--line); border-radius:5px; background:var(--bg); color:var(--text); }
input[type=range] { accent-color:var(--accent); }
.tabs { display:flex; gap:6px; margin:10px 0; }
.tabs button { flex:1; justify-content:center; }

/* ---- step 1 + 2: the setup screen ---- */
#setup { position:fixed; inset:0; z-index:12; overflow:auto; background:radial-gradient(120% 80% at 50% 0%, color-mix(in srgb,var(--accent) 16%,var(--bg)), var(--bg) 70%); padding:0 16px 40px; }
.su-top { position:sticky; top:0; z-index:2; display:flex; align-items:center; gap:10px; flex-wrap:wrap; padding:12px 0; background:linear-gradient(var(--bg) 60%,transparent); }
.su-top .theme-wrap { position:static; }
.su-steps { display:flex; gap:6px; list-style:none; margin:0 auto; padding:0; flex-wrap:wrap; justify-content:center; }
.su-steps li { color:var(--muted); font-size:.85rem; padding:4px 12px; border:1px solid var(--line); border-radius:99px; }
.su-steps li b { display:inline-grid; place-items:center; width:1.4em; height:1.4em; margin-right:4px; border-radius:50%; background:var(--line); color:var(--text); font-size:.75rem; }
.su-steps li[aria-current="step"] { color:var(--text); border-color:var(--accent); font-weight:700; }
.su-steps li[aria-current="step"] b { background:var(--accent); color:var(--on-accent); }
.su-step { max-width:1100px; margin:0 auto; }
.su-step h1, .su-step h2 { font-family:var(--font-head,inherit); font-size:clamp(1.5rem,4vw,2.4rem); margin:18px 0 4px; text-align:center; outline:none; }
.su-sub { color:var(--muted); text-align:center; margin:0 0 20px; }
.moods { display:grid; grid-template-columns:repeat(auto-fit,minmax(230px,1fr)); gap:14px; }
body.viz .mood { display:flex; flex-direction:column; align-items:flex-start; text-align:left; gap:6px; padding:20px; border-radius:16px; min-height:190px; border:var(--card-border,1px solid var(--line)); background:color-mix(in srgb,var(--card) 92%,transparent); box-shadow:0 8px 24px #0005; transition:transform .15s ease, border-color .15s; }
body.viz .mood:hover { transform:translateY(-3px); }
.mood-icon { font-size:2.2rem; line-height:1; }
.mood-name { font-family:var(--font-head,inherit); font-size:1.35rem; font-weight:800; }
.mood-blurb { color:var(--muted); font-size:.92rem; line-height:1.45; }
.mood-list { margin-top:auto; color:var(--link); font-size:.78rem; line-height:1.5; }
.su-resume { display:flex; justify-content:center; margin:22px 0 0; }
.su-head { display:flex; align-items:center; gap:12px; flex-wrap:wrap; margin:6px 0 16px; }
.su-head > div { flex:1; min-width:200px; }
.su-head h2, .su-head .su-sub { text-align:left; margin:0 0 4px; }
.cards { display:grid; grid-template-columns:repeat(auto-fill,minmax(280px,1fr)); gap:14px; }
body.viz .card { display:flex; flex-direction:column; align-items:stretch; text-align:left; gap:6px; padding:10px; border-radius:14px; border:var(--card-border,1px solid var(--line)); background:color-mix(in srgb,var(--card) 92%,transparent); box-shadow:0 8px 24px #0005; transition:transform .15s ease; }
body.viz .card:hover { transform:translateY(-3px); }
.pvwrap { display:block; position:relative; aspect-ratio:16/10; border-radius:10px; overflow:hidden; background:#000; }
.pvwrap.nogl::after { content:"Needs WebGL"; position:absolute; inset:0; display:grid; place-items:center; color:#aaa; font-size:.8rem; }
canvas.pv { display:block; width:100%; height:100%; }
.card-name { font-weight:800; font-size:1.05rem; padding:2px 4px 0; }
.card-desc { color:var(--muted); font-size:.84rem; line-height:1.4; padding:0 4px 4px; }

/* ---- step 3: the picture runs, settings sit beside it (a bottom sheet on phones) ---- */
#tune { position:fixed; z-index:12; top:12px; right:12px; bottom:12px; width:min(400px,calc(100vw - 24px)); display:flex; flex-direction:column; border:var(--card-border,1px solid var(--line)); border-radius:16px; background:color-mix(in srgb,var(--card) 95%,transparent); box-shadow:0 12px 40px #000a; padding:14px; }
.tune-head { display:flex; gap:10px; align-items:center; }
.tune-head small { color:var(--muted); font-size:.75rem; letter-spacing:.06em; text-transform:uppercase; }
.tune-head h2 { margin:0; font-family:var(--font-head,inherit); font-size:1.25rem; }
.tune-desc { color:var(--muted); font-size:.85rem; margin:8px 0 0; line-height:1.4; }
.tune-body { flex:1; overflow:auto; margin:0 -6px; padding:0 6px; }
.tune-foot { display:flex; align-items:center; justify-content:space-between; gap:10px; padding-top:12px; border-top:1px solid var(--line); flex-wrap:wrap; }
.chk { display:flex; gap:8px; align-items:center; color:var(--text); font-size:.88rem; cursor:pointer; }
body.viz .grab { display:none; }

/* ---- the Options panel contents (same everywhere) ---- */
#tuneLook h3, #optbody h3, #more h3, #soundbody h3 { margin:14px 0 6px; font-size:.75rem; letter-spacing:.14em; text-transform:uppercase; color:var(--link); }
.optpresets { display:flex; flex-wrap:wrap; gap:6px; }
body.viz .optpresets button { font-size:.84rem; padding:5px 11px; border-radius:99px; }
body.viz .optpresets .dice { border-style:dashed; }
.orow { display:grid; grid-template-columns:8.5em 1fr 3.4em; gap:8px; align-items:center; padding:4px 0; }
.orow label, .olabel { color:var(--text); font-size:.88rem; cursor:pointer; }
.orow input[type=range] { width:100%; }
.orow select { width:100%; }
.orow .ov { color:var(--muted); font-size:.78rem; text-align:right; font-variant-numeric:tabular-nums; }
.orow.wide { grid-template-columns:8.5em 1fr; }
.seg { display:flex; flex-wrap:wrap; gap:4px; }
body.viz .seg button { flex:1; justify-content:center; font-size:.8rem; padding:5px 8px; border-radius:7px; }
input.switch { appearance:none; -webkit-appearance:none; width:42px; height:24px; border-radius:99px; background:var(--line); position:relative; cursor:pointer; margin:0; justify-self:start; transition:background .15s; }
input.switch::after { content:""; position:absolute; top:3px; left:3px; width:18px; height:18px; border-radius:50%; background:var(--text); transition:transform .15s; }
input.switch:checked { background:var(--accent); }
input.switch:checked::after { transform:translateX(18px); background:var(--on-accent); }

/* ---- playing: the HUD ---- */
#hud { position:fixed; inset:0; z-index:10; pointer-events:none; transition:opacity .35s ease; }
#hud > * { pointer-events:auto; }
body.idle #hud, body.ui-off #hud { opacity:0; }
body.idle #hud > *, body.ui-off #hud > * { pointer-events:none; }
body.idle, body.idle * { cursor:none !important; }
.viz-top { position:absolute; top:0; left:0; right:0; display:flex; align-items:center; gap:10px; flex-wrap:wrap; padding:10px 14px; background:linear-gradient(color-mix(in srgb,var(--bg) 88%,transparent),transparent); }
.viz-title { display:flex; flex-direction:column; min-width:0; margin-right:auto; }
.viz-title h2 { margin:0; font-size:1.05rem; font-family:var(--font-head,inherit); }
#vdesc { color:var(--muted); font-size:.8rem; max-width:52ch; }
.viz-ctrls { display:flex; gap:6px; align-items:center; flex-wrap:wrap; }
.viz-count { color:var(--muted); font-size:.85rem; font-variant-numeric:tabular-nums; }
.viz-panel { position:absolute; right:14px; top:64px; width:min(380px,calc(100vw - 28px)); max-height:calc(100vh - 90px); overflow:auto; padding:14px; border:var(--card-border,1px solid var(--line)); border-radius:14px; background:color-mix(in srgb,var(--card) 95%,transparent); box-shadow:0 10px 30px #0008; }
.viz-panel.wide { width:min(440px,calc(100vw - 28px)); }
.viz-panel h2 { margin:0 0 8px; font-size:1.05rem; font-family:var(--font-head,inherit); display:flex; justify-content:space-between; align-items:center; }
body.viz .viz-panel h2 .x { padding:2px 10px; }
.groups { display:flex; gap:6px; flex-wrap:wrap; }
body.viz .grp { font-size:.85rem; border-radius:99px; padding:4px 12px; }
.keys-hint { color:var(--muted); font-size:.8rem; line-height:2; }
#more .theme-wrap { position:static; }

/* ---- sound (one box that moves between step 3 and the Sound panel) ---- */
#tracklist { list-style:none; padding:0; margin:6px 0; }
#tracklist { max-height:260px; overflow:auto; }
#tracklist button { width:100%; justify-content:flex-start; text-align:left; margin:2px 0; }
#tracklist .thead { margin:10px 0 4px; font-size:.75rem; letter-spacing:.14em; text-transform:uppercase; color:var(--link); }
#tracklist .thead:first-child { margin-top:0; }
#nowtitle { color:var(--text); font-weight:700; margin:6px 0 2px; }
#time { color:var(--muted); font-size:.8rem; font-variant-numeric:tabular-nums; }
#soundbody .presets { display:grid; grid-template-columns:1fr 1fr; gap:6px; }
#soundbody .presets button, #soundbody .saved button { font-size:.85rem; padding:6px 10px; justify-content:flex-start; text-align:left; }
#soundbody .row input[type=text] { flex:1; min-width:120px; padding:6px 10px; background:var(--bg); color:var(--text); border:1px solid var(--line); border-radius:8px; font:inherit; }
#soundbody .row input[type=range] { flex:1; min-width:90px; }
#soundbody .chk { align-items:flex-start; margin:6px 0; }
.srow { display:grid; grid-template-columns:8.5em 1fr 3em; gap:8px; align-items:center; padding:2px 0; }
.srow label { color:var(--muted); font-size:.86rem; cursor:pointer; } .srow.on label { color:var(--text); font-weight:700; }
.srow input { width:100%; } .srow .sv { color:var(--muted); font-size:.78rem; text-align:right; font-variant-numeric:tabular-nums; }
.saved { display:flex; gap:6px; margin:4px 0; } .saved button:first-child { flex:1; }

/* ---- the guided tour ---- */
#tour { position:fixed; inset:0; z-index:30; display:grid; place-items:center; padding:16px; background:#000a; }
.tour-card { width:min(520px,100%); border:var(--card-border,1px solid var(--line)); border-radius:18px; background:var(--card); color:var(--text); padding:26px 24px 16px; box-shadow:0 20px 60px #000c; text-align:center; }
.tour-icon { font-size:3rem; line-height:1; }
.tour-card h2 { font-family:var(--font-head,inherit); margin:10px 0 8px; font-size:1.4rem; }
.tour-card p { color:var(--muted); line-height:1.55; margin:0 0 14px; }
.tour-keys { display:flex; flex-wrap:wrap; gap:6px; justify-content:center; margin-bottom:14px; }
.kcap { padding:4px 10px; border:1px solid var(--line); border-bottom-width:3px; border-radius:8px; background:var(--bg); font-size:.84rem; }
.tour-dots { display:flex; gap:6px; justify-content:center; margin:6px 0 14px; }
.tour-dots span { width:8px; height:8px; border-radius:50%; background:var(--line); } .tour-dots span.on { background:var(--accent); }
.tour-foot { display:flex; justify-content:space-between; align-items:center; gap:8px; }
#tourkind { margin-top:10px; font-size:.82rem; }

/* ---- toast ---- */
#toast { position:fixed; left:50%; bottom:28px; transform:translate(-50%,12px); z-index:40; max-width:min(90vw,540px); padding:9px 16px; border-radius:99px; border:1px solid var(--line); background:color-mix(in srgb,var(--card) 95%,transparent); color:var(--text); font-size:.9rem; opacity:0; pointer-events:none; transition:opacity .25s,transform .25s; text-align:center; }
#toast.show { opacity:1; transform:translate(-50%,0); }
#soundhome { display:block; }
#viz > #soundhome { display:none; }

/* ---- phones ---- */
@media (max-width:760px) {
  #setup { padding:0 12px 30px; }
  .su-top { gap:6px; } .su-steps { order:3; width:100%; } .su-steps li { font-size:.75rem; padding:3px 8px; }
  .moods { grid-template-columns:1fr 1fr; gap:10px; }
  body.viz .mood { min-height:0; padding:14px; } .mood-blurb, .mood-list { display:none; } .mood-icon { font-size:1.8rem; }
  .cards { grid-template-columns:1fr 1fr; gap:10px; } .card-desc { display:none; } .card-name { font-size:.9rem; }
  #tune { top:auto; left:0; right:0; bottom:0; width:auto; max-height:62vh; border-radius:18px 18px 0 0; padding:6px 14px 12px; }
  #tune.min { max-height:none; } #tune.min .tune-desc, #tune.min .tabs, #tune.min .tune-body { display:none; }
  body.viz .grab { display:flex; justify-content:center; width:100%; background:none; border:none; padding:4px 0 8px; }
  .grab span { width:44px; height:5px; border-radius:99px; background:var(--line); }
  .tune-desc { display:none; }
  .viz-top { padding:8px 10px; gap:6px; } #vdesc, .viz-ctrls .lbl, .viz-count { display:none; }
  .viz-title h2 { font-size:.95rem; }
  .viz-panel, .viz-panel.wide { top:auto; bottom:0; right:0; left:0; width:auto; max-height:72vh; border-radius:18px 18px 0 0; }
  .orow { grid-template-columns:7em 1fr 3em; } .orow.wide { grid-template-columns:7em 1fr; }
  #soundbody .presets { grid-template-columns:1fr; } .srow { grid-template-columns:7em 1fr 2.6em; }
  .keys-hint { display:none; }
}
@media (max-width:380px) { .moods, .cards { grid-template-columns:1fr; } }
@media (prefers-reduced-motion:reduce) { #stage, #hud, #toast, body.viz .mood, body.viz .card { transition:none; } }

/* framed by the desktop's Display Properties window (engine.js: #id~mon / ~play / ~set) */
body.embed #hud, body.embed #tour, body.embed #toast { display:none !important; }
body.embed-set #tuneBack, body.embed-set .tune-foot { display:none; }
