/* planet-generator/css/app.css — extracted from index.html monolith */
  html, body { background: #000; }
  :root { --pane-w: 360px; --ui-fg: 226, 232, 240; --ui-accent: 245, 158, 11; --ui-bg: 8, 12, 24; }   /* v13: UI palette (RGB triplets) so a future tint applies everywhere */
  html, body { margin: 0; height: 100%; background: #03040a; overflow: hidden;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: #dfe6f3;
    /* iPhone: thumb swipes were selecting/highlighting the whole UI (incl. images). */
    user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
  /* Allow deliberate text entry / copy only in real fields. */
  input, textarea, [contenteditable="true"] {
    user-select: text; -webkit-user-select: text; -webkit-touch-callout: default; }
  #view3d { position: fixed; inset: 0; touch-action: none;
    user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
  #view3d canvas { display: block; touch-action: none;
    user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
  #view2d { position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
    background: radial-gradient(ellipse at center, #0b1020 0%, #03040a 75%); transition: right .28s ease; }
  body.pane-open #view2d { right: var(--pane-w); }
  #view2d .map2d { position: relative; width: min(92%, calc(84vh * 2)); aspect-ratio: 2 / 1;
    border-radius: 6px; overflow: hidden; box-shadow: 0 0 0 1px rgba(255,255,255,.08), 0 20px 60px rgba(0,0,0,.6); }
  #view2d .map2d canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
  #ui { position: fixed; top: 16px; left: 16px; display: flex; flex-wrap: wrap; gap: 8px; z-index: 40; max-width: calc(100vw - 32px);
    user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
  button { background: rgba(20,26,40,.72); color: #e8eefc; border: 1px solid rgba(255,255,255,.14);
    padding: 8px 14px; border-radius: 8px; font-size: 13px; cursor: pointer; backdrop-filter: blur(6px);
    transition: background .15s, border-color .15s; font-family: inherit; }
  button:hover { background: rgba(40,52,80,.85); border-color: rgba(255,255,255,.3); }
  button:disabled { opacity: .5; cursor: wait; }
  button.active { background: rgba(60,90,150,.6); border-color: rgba(140,180,255,.5); }

  /* faceplate: compact icon-first card (adapted from StarCode) */
  /* Standalone faceplate box removed — Code Card back is the summary. Keep selectors inert. */
  #fp, #fpPill { display: none !important; }

  #fp { position: fixed; top: 64px; left: 16px; z-index: 39; width: max-content; min-width: 168px; max-width: 206px; box-sizing: border-box; padding: 12px 12px 10px; text-align: center;
    background: rgba(11,15,26,.86); border: 1px solid rgba(160,180,220,.16); border-radius: 12px; backdrop-filter: blur(8px); color: #dfe6f5;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; user-select: none; -webkit-user-select: none; transition: opacity .5s ease, visibility .5s; }
  body.title-showing #fp, body.title-showing #fpPill, body.title-showing #fpPop { opacity: 0; visibility: hidden; pointer-events: none; transition: none; }
  #fp.hide { display: none; }
  #fp button { padding: 0; backdrop-filter: none; font-family: inherit; }
  #fp .x { position: absolute; top: 7px; right: 7px; width: 24px; height: 24px; border-radius: 50%; background: rgba(255,255,255,.02); border: 1px solid rgba(160,180,220,.2); color: #9aa6bf; display: grid; place-items: center; }
  #fp .x svg { width: 10px; height: 10px; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
  #fp .nm { font-size: 15px; line-height: 1.3; letter-spacing: .3em; text-transform: uppercase; margin: 3px 28px 0; padding-left: .3em; overflow-wrap: anywhere;
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
  #fp .nm.l1 { font-size: 13.5px; letter-spacing: .18em; padding-left: .18em; }
  #fp .nm.l2 { font-size: 12.5px; letter-spacing: .1em; padding-left: .1em; }
  #fp .ds { font-size: 9.5px; letter-spacing: .22em; color: #7d879c; margin: 6px 4px 0; text-transform: uppercase; }
  #fp .ic { display: flex; justify-content: center; gap: 8px; margin: 10px 0 9px; }
  #fp .ic button { width: 30px; height: 30px; border-radius: 5px; background: transparent; border: 1px solid rgba(160,180,220,.2); color: #9aa6bf; display: grid; place-items: center; }
  #fp .ic button:hover, #fp .x:hover { border-color: rgba(200,215,255,.45); color: #e8eefc; background: rgba(60,80,120,.25); }
  #fp .ic button.on { color: #ffb347; border-color: rgba(255,179,71,.5); }
  #fp .ic svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
  #fp .ic button.on svg { fill: currentColor; }
  #fp hr { border: 0; border-top: 1px solid rgba(160,180,220,.22); margin: 0 6px 8px; }
  #fp .st { display: flex; justify-content: center; align-items: center; gap: 6px; min-height: 26px; padding: 2px 0; }
  #fp .st span { display: block; width: 24px; height: 24px; cursor: pointer; flex: none; filter: drop-shadow(0 0 4px currentColor); }
  #fp .st span.sm { width: 17px; height: 17px; }
  #fp .st svg { display: block; width: 100%; height: 100%; fill: currentColor; }
  #fp .bd { display: inline-flex; justify-content: center; gap: 10px; margin-top: 9px; padding: 7px 14px; border-radius: 10px; background: rgba(30,38,56,.6); }
  #fp .dot { position: relative; width: 18px; height: 18px; border-radius: 50%; cursor: pointer; box-shadow: inset -3px -3px 5px rgba(0,0,0,.35); flex: none; }
  #fp .dot.big { width: 24px; height: 24px; }
  #fp .dot .bdg { position: absolute; right: -3px; bottom: -3px; width: 9px; height: 9px; border-radius: 50%; background: #b9bec8; border: 2px solid #0b0f1a; }
  #fp .mw { overflow: hidden; height: 0; }
  #fp .mr { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; padding: 9px 4px 2px; }
  #fp .mr .dot { width: 11px; height: 11px; }
  #fp .ft { display: flex; justify-content: center; gap: 12px; margin-top: 8px; }
  #fp .ft:empty { display: none; }
  #fp .ft i { width: 7px; height: 7px; border-radius: 50%; background: #8c93a3; cursor: pointer; }
  #fpPill { position: fixed; top: 64px; left: 16px; z-index: 39; font-family: ui-monospace, Menlo, monospace; font-size: 11px; letter-spacing: .2em; padding: 6px 12px; border-radius: 999px; background: rgba(11,15,26,.86); }
  #fpPop { position: fixed; z-index: 60; min-width: 150px; max-width: 230px; padding: 9px 12px; background: rgba(13,18,30,.97); border: 1px solid rgba(160,180,220,.22); border-radius: 9px;
    color: #e3e9f6; font: 13px/1.35 system-ui, sans-serif; box-shadow: 0 6px 20px rgba(0,0,0,.5); display: none; }
  #fpPop .h { display: flex; align-items: center; gap: 7px; font-weight: 600; }
  #fpPop .h .n { min-width: 0; overflow-wrap: anywhere; }
  #fpPop .m i { cursor: pointer; }
  #fp .dot, #fpPop .m i, .fpi.dot, #favDrawer .fpi.dot { box-shadow: inset -3px -3px 5px rgba(0,0,0,.35), 0 0 0 1px rgba(225,232,248,.28); }
  #fpPop .m i { box-shadow: inset -1px -1px 2px rgba(0,0,0,.35), 0 0 0 1px rgba(225,232,248,.25); }
  #fp .dot.hab, .fpi.dot.hab { box-shadow: inset -3px -3px 5px rgba(0,0,0,.35), 0 0 0 2px #0d1220, 0 0 0 3.2px #4ade80, 0 0 7px rgba(74,222,128,.45); }
  .fpi { display: inline-block; flex: none; vertical-align: middle; }
  .fpi.dot { width: 11px; height: 11px; border-radius: 50%; }
  .fpi.dot.hab { box-shadow: inset -2px -2px 3px rgba(0,0,0,.35), 0 0 0 1.5px #0d1220, 0 0 0 2.5px #4ade80; }
  .fpi.star { width: 14px; height: 14px; filter: drop-shadow(0 0 3px currentColor); } .fpi.star svg { display: block; width: 100%; height: 100%; fill: currentColor; }
  /* Favourites: fixed wall rail (never moves with panel). Panel slides independently to the left of the rail.
     Closed: triangle points outward (▶); open: flipped (◀) at the same wall spot. Rail is the toggle (not header). */
  :root { --fav-rail-w: 40px; --fav-drawer-w: 236px; --fav-rail-top: 50%; }
  #favTab { position: fixed; right: 0; top: var(--fav-rail-top); z-index: 9400; transform: translateY(-50%); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
    width: var(--fav-rail-w); box-sizing: border-box; padding: 16px 0; overflow: visible;
    border-radius: 10px 0 0 10px; background: rgba(11,15,26,.92); border: 1px solid rgba(160,180,220,.22); border-right: 0; color: #ffb347; font: 600 14px/1 system-ui, sans-serif; cursor: grab;
    -webkit-tap-highlight-color: transparent; touch-action: none; user-select: none; }
  #favTab.dragging { cursor: grabbing; transition: none; }
  /* Closed = outward (right ▶). Open = rotate 180° → left ◀. */
  #favTab .fav-twisty { display: block; width: 0; height: 0; border-style: solid; border-width: 7px 0 7px 11px; border-color: transparent transparent transparent currentColor;
    transition: transform .28s cubic-bezier(.32, .08, .24, 1); transform-origin: 60% 50%; pointer-events: none; }
  #favTab.open .fav-twisty, body:has(#favDrawer.open) #favTab .fav-twisty { transform: rotate(180deg); }
  /* Drawer runs under the rail and past the viewport edge; the rail masks its right side. */
  #favDrawer { position: fixed; right: calc(var(--fav-rail-w) * -1); top: var(--fav-rail-top); z-index: 42; transform: translate(calc(100% + var(--fav-rail-w) + 8px), -50%); transition: transform .28s cubic-bezier(.32, .08, .24, 1); width: calc(var(--fav-drawer-w) + var(--fav-rail-w) * 2); max-height: 64vh; overflow: auto; box-sizing: border-box;
    padding: 10px 10px 8px; border-radius: 10px 0 0 10px; background: rgba(11,15,26,.94); border: 1px solid rgba(160,180,220,.22); border-right: 0; color: #dfe6f5; font: 12px/1.3 system-ui, sans-serif; pointer-events: none; }
  #favDrawer.open { transform: translate(0, -50%); pointer-events: auto; }
  #favDrawer .hd { font-size: 10px; letter-spacing: .22em; color: #7d879c; margin: 0 2px 6px; pointer-events: none; user-select: none; }
  #favDrawer .fav-row { position: relative; overflow: hidden; border-radius: 6px; margin: 1px 0; }
  #favDrawer .fav-back { position: absolute; inset: 0; display: flex; justify-content: flex-end; align-items: stretch; background: #b83232; }
  #favDrawer .fav-back .rm { width: 56px; border: 0; background: transparent; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; -webkit-tap-highlight-color: transparent; }
  #favDrawer .fav-back .rm:hover, #favDrawer .fav-back .rm:focus-visible { background: #9a2424; outline: none; }
  #favDrawer .fav-back .rm svg { width: 18px; height: 18px; fill: currentColor; pointer-events: none; }
  #favDrawer .fav-front { position: relative; z-index: 1; display: flex; align-items: center; gap: 8px; padding: 5px 8px 5px 6px; border-radius: 6px; cursor: pointer; background: rgba(11,15,26,.98); touch-action: pan-y; transition: transform .2s ease; will-change: transform; user-select: none; }
  #favDrawer .fav-front:hover { background: rgba(28,38,58,.98); }
  #favDrawer .fav-row.open .fav-front { transform: translateX(-56px); }
  #favDrawer .fav-front.dragging { transition: none; }
  #favDrawer .tx { flex: 1; min-width: 0; } #favDrawer .tx b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #favDrawer .tx small { color: #ffa133; font-size: 9.5px; letter-spacing: .08em; font-weight: 700; } #favDrawer .tx small i { color: #8c96ab; font-style: normal; font-weight: 400; letter-spacing: 0; }
  #favDrawer .em { color: #7d879c; padding: 6px; }
  body.title-showing #favTab, body.title-showing #favDrawer { display: none; }
  #fpTip { position: fixed; z-index: 62; display: none; pointer-events: none; padding: 3px 8px; border-radius: 5px; background: rgba(13,18,30,.96); border: 1px solid rgba(160,180,220,.22);
    color: #dfe6f5; font: 11.5px/1.3 system-ui, -apple-system, "Segoe UI", sans-serif; white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,.4); }
  #fpPop .h i { width: 9px; height: 9px; border-radius: 50%; flex: none; }
  #fpPop .t { color: #ffa133; font-size: 10.5px; letter-spacing: .08em; font-weight: 700; margin-left: 2px; }
  #fpPop .b { color: #9aa6bf; font-size: 12px; margin-top: 4px; }
  #fpPop .m { display: flex; gap: 5px; margin-top: 7px; flex-wrap: wrap; }
  #fpPop .m i { width: 9px; height: 9px; border-radius: 50%; }
  #fpToast { position: fixed; z-index: 61; padding: 4px 10px; border-radius: 6px; background: rgba(30,60,40,.95); color: #bff5cf; font: 12px system-ui, sans-serif; display: none; }
  @media (max-width: 700px) {
    #fp { top: 104px; left: 8px; min-width: 156px; max-width: 192px; padding: 10px 10px 8px; }
    #fp .nm { font-size: 12.5px; letter-spacing: .24em; margin: 2px 26px 0; }
    #fp .nm.l1 { font-size: 11.5px; letter-spacing: .14em; } #fp .nm.l2 { font-size: 11px; letter-spacing: .08em; }
    #fp .ds { font-size: 8.5px; letter-spacing: .16em; }
    #fp .ic { margin: 8px 0 7px; } #fp .ic button { width: 27px; height: 27px; }
    #fp .st span { width: 21px; height: 21px; } #fp .x { width: 22px; height: 22px; top: 6px; right: 6px; }
    #fpPill { top: 104px; left: 8px; }
  }
  body.pane-open #fp, body.pane-open #fpPill { }
  #info { display: none !important; position: fixed; bottom: 14px; right: 16px; font-size: 12px; opacity: .75; text-align: right;
    line-height: 1.5; z-index: 10; pointer-events: none; transition: right .28s ease; }
  body.pane-open #info { right: calc(var(--pane-w) + 16px); }
  #info b { font-size: 14px; letter-spacing: .04em; }
  #hint { display: none !important; position: fixed; bottom: 14px; left: 16px; font-size: 11px; opacity: .4; z-index: 10; }
  #err { position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); display: none; z-index: 10040;
    background: #2a0e12; border: 1px solid #7a2a33; padding: 16px 20px; border-radius: 8px; max-width: 480px; font-size: 13px; }

  /* ---- Side pane ---- */
  #pane { position: fixed; top: 0; right: 0; bottom: 0; width: var(--pane-w); max-width: calc(100vw - 24px); z-index: 30;
    background: rgba(10,13,22,.92); backdrop-filter: blur(10px); border-left: 1px solid rgba(255,255,255,.08);
    transform: translateX(100%); transition: transform .3s cubic-bezier(.32, .08, .24, 1); overflow-y: auto; box-sizing: border-box;
    padding: 14px 14px 30px; font-size: 12.5px; box-shadow: -10px 0 40px rgba(0,0,0,.4); }
  body.pane-open #pane { transform: none; }
  #pane h2 { margin: 2px 4px 12px; font-size: 16px; font-weight: 600; letter-spacing: .03em; display: flex; justify-content: space-between; align-items: baseline; }
  #pane h2 small { font-size: 11px; font-weight: 400; opacity: .5; }
  #pane details { border: 1px solid rgba(255,255,255,.07); border-radius: 8px; margin-bottom: 10px; background: rgba(255,255,255,.02); }
  #pane summary { cursor: pointer; padding: 9px 12px; font-weight: 600; font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
    color: #b8c6e6; list-style: none; user-select: none; display: flex; align-items: center; gap: 8px; }
  #pane summary::-webkit-details-marker { display: none; }
  #pane summary::before { content: ''; border: 5px solid transparent; border-left: 7px solid #7f93bf; border-right: 0;
    transition: transform .15s; transform-origin: 30% 50%; }
  #pane details[open] > summary::before { transform: rotate(90deg); }
  #pane details > div { padding: 2px 12px 12px; }
  table.kv { width: 100%; border-collapse: collapse; }
  table.kv td { padding: 3px 0; vertical-align: top; border-bottom: 1px solid rgba(255,255,255,.04); }
  table.kv td:first-child { color: #8d9abb; width: 44%; padding-right: 8px; }
  table.kv td:last-child { color: #e6ecfa; font-variant-numeric: tabular-nums; }
  .sub { color: #6f7b99; font-size: 11px; }
  .grp { margin: 10px 0 4px; color: #9fb2dd; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
  .bar { height: 6px; border-radius: 3px; background: rgba(255,255,255,.08); overflow: hidden; margin-top: 3px; }
  .bar i { display: block; height: 100%; background: linear-gradient(90deg, #5c8ff0, #9cc0ff); }
  .swatches { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .sw { display: flex; align-items: center; gap: 8px; padding: 4px; border-radius: 6px; background: rgba(255,255,255,.03); }
  .sw span.c { width: 26px; height: 26px; border-radius: 5px; flex: none; box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); }
  .sw div { line-height: 1.25; } .sw code { font-size: 11px; color: #9aa6c4; }
  .thumbs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .thumb { cursor: zoom-in; } .thumb canvas { width: 100%; aspect-ratio: 2/1; border-radius: 5px; display: block;
    box-shadow: 0 0 0 1px rgba(255,255,255,.12); transition: box-shadow .15s; }
  .thumb:hover canvas { box-shadow: 0 0 0 2px #7fa6ff; }
  .thumb div { margin-top: 4px; font-size: 11px; color: #aeb9d6; } .thumb div span { color: #6f7b99; }
  .storm { display: flex; justify-content: space-between; align-items: center; padding: 3px 0; border-bottom: 1px solid rgba(255,255,255,.04); }
  .storm button { padding: 2px 8px; font-size: 11px; border-radius: 5px; }
  #lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.85); display: none; flex-direction: column;
    align-items: center; justify-content: center; cursor: zoom-out; gap: 10px; }
  #lightbox canvas { max-width: 94vw; max-height: 84vh; aspect-ratio: 2/1; border-radius: 6px; box-shadow: 0 0 0 1px rgba(255,255,255,.15); }
  #lightbox div { font-size: 13px; opacity: .8; }
  /* v9: progressive disclosure */
  #paneLead { margin: 0 4px 12px; }
  #paneLead .lead { margin: 0 0 8px; line-height: 1.45; color: #cfd8ec; font-size: 13px; }
  #paneLead .facts { display: flex; flex-wrap: wrap; gap: 6px; }
  #paneLead .fact { background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08); border-radius: 7px; padding: 5px 8px; line-height: 1.25; }
  #paneLead .fact small { display: block; color: #7f8cab; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
  #paneLead .note { margin: 8px 0 0; font-size: 11.5px; color: #9fb0cc; line-height: 1.4; border-left: 2px solid #5c8ff0; padding-left: 8px; }
  #pane details details { margin: 6px 0; background: rgba(255,255,255,.015); border-color: rgba(255,255,255,.05); }
  #pane details details > summary { text-transform: none; letter-spacing: .02em; font-size: 12px; padding: 6px 9px; color: #a9b8da; }
  #pane details details > div { padding: 0 9px 8px; }
  #pane details details details > summary { font-weight: 500; }
  #moreWrap { position: relative; display: inline-block; }
  #moreMenu { position: absolute; top: calc(100% + 6px); left: 0; display: none; min-width: 210px; padding: 8px; border-radius: 10px; z-index: 45;
    background: rgba(10,13,22,.95); border: 1px solid rgba(255,255,255,.12); box-shadow: 0 10px 30px rgba(0,0,0,.5); backdrop-filter: blur(8px); }
  #moreMenu.open { display: grid; gap: 5px; }
  #moreMenu button { text-align: left; padding: 6px 10px; }
  #moreMenu .mg { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: #7f8cab; margin-top: 4px; }
  #moreMenu .keys { font-size: 11px; color: #9fb0cc; line-height: 1.6; }
  #info .sub2 { opacity: .8; }

  select { background: rgba(20,26,40,.72); color: #e8eefc; border: 1px solid rgba(255,255,255,.14); padding: 7px 10px;
    border-radius: 8px; font-size: 13px; cursor: pointer; font-family: inherit; backdrop-filter: blur(6px); }
  select:hover { border-color: rgba(255,255,255,.3); }
  select option { background: #141a28; }
  .swline { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 5px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); }
  #view2d .map2d canvas.haze2d { mix-blend-mode: normal; }
  #audioPanel { position: fixed; top: 58px; left: 16px; z-index: 12; width: 250px; padding: 12px 14px; border-radius: 12px; display: none;
    background: rgba(14,18,30,.9); border: 1px solid rgba(255,255,255,.12); backdrop-filter: blur(8px); color: #dfe6f5; font-size: 13px; }
  #audioPanel.open { display: grid; gap: 8px; }
  #audioPanel .ah { font-weight: 600; font-size: 14px; }
  #audioPanel .sub { color: #8b96ad; font-size: 11px; font-weight: 400; }
  #audioPanel .chk { display: flex; gap: 8px; align-items: center; cursor: pointer; }
  #audioPanel .sl { display: grid; grid-template-columns: 56px 1fr; align-items: center; gap: 8px; }
  #audioPanel input[type=range] { width: 100%; accent-color: #7aa2ff; }
  /* Audio Tweaker (StarCode Sound Edit) — Dev Tools panel */
  .audio-edit-sheet {
    position: fixed; top: 60px; right: 16px; z-index: 10050; pointer-events: auto;
    width: min(320px, calc(100vw - 32px));
    padding: 12px 14px; border-radius: 12px;
    background: rgba(var(--ui-bg), .94); border: 1px solid rgba(var(--ui-fg), .14);
    box-shadow: 0 8px 32px rgba(0,0,0,.55); backdrop-filter: blur(10px);
    color: rgb(var(--ui-fg)); display: grid; gap: 6px;
  }
  .audio-edit-sheet[hidden] { display: none !important; }
  .audio-edit-sheet > .x-close { position: absolute; top: 8px; right: 8px; }
  .ae-dev-banner { text-align: center; padding: 5px 8px; margin: -12px -14px 4px; border-radius: 12px 12px 0 0;
    font: 600 10px/1.2 ui-monospace, monospace; letter-spacing: .14em; text-transform: uppercase;
    color: #ff9944; background: rgba(180,90,0,.18); border-bottom: 1px solid rgba(255,153,68,.25); }
  .audio-edit-sheet .options-title { font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; color: rgba(var(--ui-fg), .7); padding-right: 40px; }
  .audio-edit-hint { font-size: 11px; color: rgba(var(--ui-fg), .55); line-height: 1.35; }
  .audio-edit-tracks { display: flex; flex-direction: column; gap: 5px; max-height: 168px; overflow-y: auto; margin: 2px 0 4px; }
  .audio-edit-track { font-size: 12px; font-family: ui-monospace, monospace; background: rgba(0,0,0,.35);
    border: 1px solid rgba(var(--ui-fg), .22); border-radius: 8px; padding: 8px 10px; cursor: pointer; color: rgba(var(--ui-fg), .9); text-align: left;
    display: flex; align-items: center; gap: 8px; min-height: 40px; width: 100%;
    pointer-events: auto; -webkit-tap-highlight-color: rgba(var(--ui-accent), .25); touch-action: manipulation; user-select: none; }
  .audio-edit-track:hover { border-color: rgba(var(--ui-accent), .7); }
  .audio-edit-track.active { border-color: rgba(var(--ui-accent), 1); color: #fff; background: rgba(var(--ui-accent), .22);
    box-shadow: inset 0 0 0 1px rgba(var(--ui-accent), .35); }
  .audio-edit-track .ae-kind { flex: 0 0 auto; opacity: .7; font-size: 9px; padding: 2px 5px; border-radius: 4px;
    background: rgba(var(--ui-fg), .1); text-transform: uppercase; letter-spacing: .5px; }
  .audio-edit-track.active .ae-kind { background: rgba(var(--ui-accent), .35); opacity: 1; }
  .audio-edit-track .ae-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .audio-edit-track .ae-edit { flex: 0 0 auto; font-size: 10px; opacity: .45; letter-spacing: .3px; text-transform: uppercase; }
  .audio-edit-track.active .ae-edit { opacity: .9; color: rgb(var(--ui-accent)); }
  .audio-edit-file { font-size: 11px; font-family: ui-monospace, monospace; background: rgba(0,0,0,.28);
    border: 1px solid rgba(var(--ui-fg), .12); border-radius: 8px; padding: 6px 8px; word-break: break-all; }
  .audio-edit-pool { color: rgba(var(--ui-fg), .5); font-size: 11px; min-height: 14px; }
  .audio-edit-sheet .level-row { display: grid; grid-template-columns: 64px 1fr 42px; align-items: center; gap: 8px; font-size: 12px; }
  .audio-edit-sheet .level-row input[type=range] { width: 100%; accent-color: rgb(var(--ui-accent)); }
  .audio-edit-sheet .level-row span:last-child { text-align: right; font-variant-numeric: tabular-nums; font-size: 11px; color: rgba(var(--ui-fg), .65); }
  .audio-edit-buttons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
  .audio-edit-buttons button { flex: 1 1 40%; min-height: 34px; border-radius: 8px; font-size: 12px; font-weight: 600; cursor: pointer;
    background: rgba(var(--ui-fg), .08); border: 1px solid rgba(var(--ui-fg), .14); color: rgb(var(--ui-fg)); }
  .audio-edit-buttons button:hover { border-color: rgba(var(--ui-accent), .7); color: rgb(var(--ui-accent)); }
  .audio-edit-buttons button:disabled { opacity: .4; cursor: default; }
  .audio-edit-sheet.ae-synth .level-row:nth-of-type(3),
  .audio-edit-sheet.ae-synth .level-row:nth-of-type(4) { display: none; }
  .audio-edit-sheet.ae-music .level-row:nth-of-type(1),
  .audio-edit-sheet.ae-music .level-row:nth-of-type(3),
  .audio-edit-sheet.ae-music .level-row:nth-of-type(4) { display: none; }
  .audio-edit-status { min-height: 14px; text-align: center; font-size: 11px; color: rgb(var(--ui-accent)); }
  @media (max-width: 480px) { .audio-edit-sheet { top: 56px; right: 10px; left: 10px; width: auto; } }

  #btnOpt.muted { opacity: .55; }
  /* Options: open just under #btnOpt (gear, top-right) — not left:16 which floated away from the gear. */
  #optPanel { position: fixed; top: calc(max(16px, env(safe-area-inset-top, 0px)) + 48px); right: max(16px, calc(env(safe-area-inset-right, 0px) + 10px)); left: auto; z-index: 12; width: 340px; max-height: calc(100vh - 76px); overflow-x: hidden; overflow-y: auto; padding: 12px 14px; border-radius: 12px; display: none; box-sizing: border-box; transform-origin: 92% 0;
    background: rgba(14,18,30,.94); border: 1px solid rgba(255,255,255,.12); color: #dfe6f5; font-size: 13px; }
  #optPanel.open { display: grid; gap: 9px; }
  #optPanel .ah { font-weight: 600; font-size: 14px; }
  #optPanel .sub { color: #8b96ad; font-size: 11px; font-weight: 400; }
  #optPanel .chk { display: flex; gap: 8px; align-items: center; cursor: pointer; }
  #optPanel .hrow { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px;
    background: rgba(var(--ui-accent), .07); border: 1px solid rgba(var(--ui-accent), .25);
    position: sticky; top: -12px; z-index: 2; backdrop-filter: blur(8px); }
  #optPanel .hrow label { cursor: pointer; font-size: 13px; }
  #optPanel .hrow .sub { display: block; }
  #oHaptic { width: 51px; height: 31px; margin: 0; accent-color: rgb(255,196,92); cursor: pointer; }
  #optPanel .hrow button { padding: 6px 12px; font-size: 12px; min-height: 36px; }
  #optPanel .seg { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
  #optPanel .seg button[data-q=custom] { cursor: default; }
  #optPanel .orow { display: grid; grid-template-columns: minmax(72px, 112px) minmax(0, 1fr) minmax(40px, 64px); align-items: center; gap: 6px; font-size: 12px; max-width: 100%; }
  #optPanel .orow > * { min-width: 0; }
  #optPanel .orow .v { text-align: right; color: #c9d4ea; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #optPanel select { font: inherit; font-size: 12px; background: rgba(20,26,40,.9); color: #e6ecf8; border: 1px solid rgba(255,255,255,.15); border-radius: 6px; padding: 3px 4px; }
  #optPanel input[type=range] { width: 100%; accent-color: #7aa2ff; }
  #optPanel .grp2 { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #8b96ad; margin-top: 4px; border-top: 1px solid rgba(255,255,255,.08); padding-top: 7px; }
  #oFeats { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px; font-size: 12px; }
  #optPanel .info { font-size: 11px; color: #9fb0cc; line-height: 1.35; }
  /* Tap tip (ⓘ): brief player-facing help; no permanent walls in Post effects. */
  #optPanel .otip { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; margin: 0 0 0 4px;
    padding: 0; border-radius: 50%; border: 1px solid rgba(var(--ui-fg), .22); background: rgba(var(--ui-fg), .06);
    color: rgba(var(--ui-fg), .72); font: 11px/1 system-ui, -apple-system, sans-serif; vertical-align: middle;
    cursor: help; flex: none; -webkit-tap-highlight-color: transparent; }
  #optPanel .otip:hover, #optPanel .otip:focus-visible { color: rgb(var(--ui-accent)); border-color: rgba(var(--ui-accent), .55);
    background: rgba(var(--ui-accent), .12); outline: none; }
  #optPanel summary .otip { margin-left: 6px; }
  #optPanel .chk .otip { margin-left: 2px; }
  #optTip { position: fixed; z-index: 9600; max-width: min(260px, calc(100vw - 24px)); padding: 8px 10px; border-radius: 8px;
    background: rgba(13, 18, 30, .97); border: 1px solid rgba(160, 180, 220, .28); color: #dfe6f5;
    font: 12.5px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; box-shadow: 0 8px 24px rgba(0,0,0,.45);
    pointer-events: none; opacity: 0; transform: translateY(4px); transition: opacity .18s ease, transform .18s ease;
    visibility: hidden; }
  #optTip.show { opacity: 1; transform: translateY(0); visibility: visible; }
  #optTip.hide { opacity: 0; transform: translateY(2px); visibility: visible; }
  #optPanel .seg button { padding: 6px 0; font-size: 12px; }
  #optPanel .seg button.on { background: rgba(122,162,255,.35); box-shadow: inset 0 0 0 1px #7aa2ff; }
  #optPanel table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
  #optPanel td { padding: 2px 0; border-bottom: 1px solid rgba(255,255,255,.06); }
  #optPanel td:last-child { text-align: right; color: #c9d4ea; }
  #optPanel td:first-child { white-space: nowrap; padding-right: 10px; }

  /* v17c: Options sheet in StarCode's cosmos-options.css language (small-caps fold sections, accent opens), on PG tokens. */
  #optPanel { width: min(340px, calc(100vw - 32px)); max-height: calc(100dvh - 76px - env(safe-area-inset-bottom, 0px)); background: rgba(var(--ui-bg), .94);
    border-color: rgba(var(--ui-fg), .14); color: rgb(var(--ui-fg)); box-shadow: 0 8px 32px rgba(0,0,0,.55); -webkit-overflow-scrolling: touch;
    overflow-x: hidden; overflow-y: auto; touch-action: pan-y; scrollbar-gutter: stable; box-sizing: border-box; }
  /* Haptic overlays are optional affordances, not controls. Let vertical gestures reach the
     scroll container; the real summary/input/button underneath still handles taps. */
  #optPanel .pg-hsw { pointer-events: none; }
  #optPanel.open { gap: 6px; align-content: start; }
  #optPanel .otitle { display: flex; justify-content: space-between; align-items: baseline; font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: rgba(var(--ui-fg), .6); }
  #optPanel .otitle .sub { letter-spacing: .02em; text-transform: none; }
  #optPanel .opt-section { border-top: 1px solid rgba(var(--ui-fg), .08); }
  #optPanel .opt-section > summary { cursor: pointer; font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: rgba(var(--ui-fg), .66);
    padding: 11px 2px; min-height: 20px; user-select: none; -webkit-user-select: none; list-style-position: inside; }
  #optPanel .opt-section > summary .sub { letter-spacing: 0; text-transform: none; }
  #optPanel .opt-section > summary:hover { color: rgb(var(--ui-fg)); }
  #optPanel .opt-section[open] > summary { color: rgb(var(--ui-accent)); }
  #optPanel .osec { display: grid; gap: 8px; padding: 0 0 12px; max-width: 100%; overflow-x: hidden; box-sizing: border-box; }
  /* Nested collapsible clusters inside an Options section (lens flare, stars, …). Not popups. */
  #optPanel .opt-sub { border: 1px solid rgba(var(--ui-fg), .07); border-radius: 7px; margin: 2px 0;
    background: rgba(var(--ui-fg), .025); }
  #optPanel .opt-sub > summary { cursor: pointer; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase;
    color: rgba(var(--ui-fg), .55); padding: 8px 9px; min-height: 18px; user-select: none; -webkit-user-select: none;
    list-style-position: inside; }
  #optPanel .opt-sub > summary:hover { color: rgb(var(--ui-fg)); }
  #optPanel .opt-sub[open] > summary { color: rgba(var(--ui-accent), .95); }
  #optPanel .opt-sub > .osec { padding: 0 8px 10px; gap: 6px; max-width: 100%; overflow-x: hidden; box-sizing: border-box; }
  #oPerfAdv { display: grid; gap: 5px; padding: 6px 0 2px 10px; margin: 0 0 2px 2px;
    border-left: 2px solid rgba(var(--ui-accent), .28); }
  #oPerfAdv[hidden] { display: none !important; }
  #oPerfAdv .agrp { font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
    color: rgba(var(--ui-fg), .48); margin: 6px 0 0; }
  #oPerfAdv .agrp:first-child { margin-top: 0; }
  #oPerfAdv .chk { min-height: 26px; font-size: 12px; }
  #optPanel input[type=range], #optPanel input[type=checkbox] { accent-color: rgb(var(--ui-accent)); }
  #optPanel input[type=checkbox]:not([switch]) { width: 16px; height: 16px; }
  #optPanel .chk { min-height: 30px; }
  #optPanel #optDebugToggles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  #optPanel #optDebugToggles .chk { min-width: 0; }
  #optPanel .sl { display: grid; grid-template-columns: minmax(56px, 72px) minmax(0, 1fr); align-items: center; gap: 8px; min-height: 30px; max-width: 100%; }
  #optPanel .sl > * { min-width: 0; }
  #optPanel .obtns { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  #optPanel .obtns button { min-height: 38px; font-size: 12px; }
  #optPanel .seg button.on { background: rgba(var(--ui-accent), .28); box-shadow: inset 0 0 0 1px rgb(var(--ui-accent)); color: #fff; }
  #optPanel .hrow { background: rgba(var(--ui-accent), .07); border-color: rgba(var(--ui-accent), .25); }
  #oHaptic { accent-color: rgb(var(--ui-accent)); }
  /* hud: shared round close button (every panel / popup / overlay, top right) */
  button.x-close { flex: none; width: 38px; height: 38px; min-width: 38px; min-height: 38px; padding: 0; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
    background: rgba(var(--ui-bg), .78); border: 1px solid rgba(var(--ui-fg), .22); color: rgb(var(--ui-fg)); line-height: 1; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
  button.x-close:hover, button.x-close:focus-visible { border-color: rgba(var(--ui-accent), .85); color: rgb(var(--ui-accent)); background: rgba(var(--ui-bg), .9); outline: none; }
  button.x-close:active { transform: scale(.92); }
  button.x-close svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; pointer-events: none; }
  .x-tr { position: absolute !important; top: 8px; right: 8px; z-index: 6; }
  /* hud: main HUD = TEST (top left), gear (top right), sparkle (bottom right) */
  #btnOpt { position: fixed; top: max(16px, env(safe-area-inset-top, 0px)); right: max(16px, calc(env(safe-area-inset-right, 0px) + 10px)); min-width: 44px; min-height: 40px; font-size: 16px; }
  @media (min-width: 700px) { body.pane-open #btnOpt { right: calc(var(--pane-w) + 16px); } body.pane-open #optPanel { right: calc(var(--pane-w) + 16px); } }
  #ui { max-width: calc(100vw - 100px); }
  #btnTest { min-height: 40px; letter-spacing: .14em; font-weight: 700; display: inline-flex; align-items: center; gap: 7px; }
  #btnTest[hidden] { display: none !important; }
  #btnTest::after { content: ''; width: 0; height: 0; border: 4px solid transparent; border-top: 5px solid currentColor; border-bottom: 0; opacity: .75; transition: transform .15s; }
  #btnTest.active::after { transform: rotate(180deg); }
  #testMenu { position: fixed; top: calc(max(16px, env(safe-area-inset-top, 0px)) + 48px); left: 16px; z-index: 100; min-width: 236px; max-width: calc(100vw - 32px); padding: 8px; border-radius: 22px;
    background: rgba(22,22,24,.92); -webkit-backdrop-filter: blur(24px) saturate(1.4); backdrop-filter: blur(24px) saturate(1.4); box-shadow: 0 18px 50px rgba(0,0,0,.55), 0 0 0 .5px rgba(255,255,255,.08);
    transform-origin: 12% 0; opacity: 0; transition: opacity .15s ease; }
  #testMenu[hidden] { display: none; }
  #testMenu.on { opacity: 1; }
  #testMenu > button, #testMenu .tsub button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 6px 12px 6px 6px; border: 0; border-radius: 16px; background: transparent !important;
    color: #fff; font: 700 15px/1 system-ui, -apple-system, 'Segoe UI', sans-serif; letter-spacing: .08em; text-align: left; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; -webkit-tap-highlight-color: transparent; }
  #testMenu > button:hover, #testMenu > button:active, #testMenu .tsub button:hover { background: rgba(255,255,255,.07) !important; }
  #testMenu .ic { flex: none; width: 38px; height: 38px; border-radius: 50%; background: #3a3a3c; display: flex; align-items: center; justify-content: center; font-size: 17px; }
  #testMenu .ic svg { width: 19px; height: 19px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  #testMenu .val { margin-left: auto; font-weight: 500; letter-spacing: .02em; color: rgb(var(--ui-accent)); font-size: 13px; }
  #testMenu .tsub { display: grid; gap: 2px; margin: 0 0 4px 50px; }
  #testMenu .tsub[hidden] { display: none; }
  #testMenu .tsub button { min-height: 38px; font-weight: 500; font-size: 14px; letter-spacing: .04em; padding-left: 12px; }
  #testMenu .tsub button.on { color: rgb(var(--ui-accent)); }
  #testMenu .tsub button.on::after { content: '✓'; margin-left: auto; }
  #testMenu #btnNew .pg-hsw { border-radius: 16px; }
  body.title-showing #testMenu, body.nohud #testMenu, body.title-showing #moreMenu, body.nohud #moreMenu { display: none !important; }
  /* Performance assist soft FPS nudge */
  .perf-nudge { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 80;
    width: min(340px, calc(100vw - 28px)); padding: 14px 16px 12px; border-radius: 12px; background: rgba(var(--ui-bg), .94);
    border: 1px solid rgba(var(--ui-fg), .14); color: rgb(var(--ui-fg)); box-shadow: 0 8px 28px rgba(0,0,0,.55); display: grid; gap: 8px; }
  .perf-nudge[hidden] { display: none !important; }
  .perf-nudge-title { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: rgba(var(--ui-fg), .7); padding-right: 36px; }
  .perf-nudge-body { font-size: 13px; line-height: 1.4; color: rgba(var(--ui-fg), .9); }
  .perf-nudge-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .perf-nudge-btns.solo { grid-template-columns: 1fr; }
  .perf-nudge-btns button { min-height: 38px; font-size: 13px; }
  .perf-nudge-btns button[hidden] { display: none; }
  .perf-nudge { position: fixed; }
  .perf-nudge > .x-close { position: absolute; top: 8px; right: 8px; }
  /* hud: DEBUG popup (was the ⋯ menu) */
  #moreMenu { position: fixed !important; top: calc(max(16px, env(safe-area-inset-top, 0px)) + 48px) !important; left: 16px !important; padding: 10px !important; min-width: 236px !important; }
  #moreMenu .mtitle { font-size: 11px; letter-spacing: .22em; font-weight: 700; color: rgb(var(--ui-accent)); padding: 11px 44px 4px 4px; }
  #optPanel > .x-close { position: sticky; top: 0; justify-self: end; margin: -4px -6px -44px 0; z-index: 3; }
  #optPanel .otitle { padding-right: 44px; min-height: 30px; align-items: center; }
  #pane h2 { padding-right: 44px; }
  #pane > .x-close { position: sticky !important; float: right; top: 0; margin: -4px -4px 0 0; }
  #lightbox .x-close { position: absolute; top: max(12px, env(safe-area-inset-top, 0px)); right: 12px; }
  #fpPop .h { padding-right: 34px; min-height: 22px; }
  #fpPop > .x-close { top: 1px; right: 1px; background: transparent; border-color: transparent; }
  /* snaptick: native switch overlay for iOS haptics (see hapticSwitch) */
  #fpTip, #fpToast { z-index: 9500 !important; }
  .pg-hsw { position: absolute !important; inset: 0 !important; width: 100% !important; height: 100% !important; margin: 0 !important; padding: 0 !important; opacity: 0.01 !important; z-index: 5; cursor: pointer; border: 0; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
  @media (max-width: 480px) { #optPanel .orow { grid-template-columns: minmax(64px, 96px) minmax(0, 1fr) minmax(36px, 52px); } #optPanel .seg button { min-height: 38px; } }
  #stats { position: fixed; top: 58px; right: 16px; z-index: 11; font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: #cfe3ff;
    background: rgba(8,12,22,.78); border: 1px solid rgba(255,255,255,.1); border-radius: 8px; padding: 7px 10px; white-space: pre; display: none; pointer-events: none; }
  body.pane-open #stats { right: calc(var(--pane-w) + 16px); }
  #busy { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 11; font-size: 12px; color: #cfd8ee; background: rgba(10,14,24,.75);
    border: 1px solid rgba(255,255,255,.1); border-radius: 20px; padding: 4px 12px; display: none; pointer-events: none; }
  /* Arrival / generation nameplate (StarCode One reveal-system-name.arrival): bright name + faded super-type */
  #pgArrivalName.pg-arrival-name {
    position: fixed; top: max(7%, calc(12px + env(safe-area-inset-top, 0px))); left: 50%; transform: translateX(-50%);
    max-width: min(92vw, 920px); z-index: 35; pointer-events: none; text-align: center;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: clamp(22px, 7vw, 44px); font-weight: 400; letter-spacing: 0.14em; text-transform: uppercase;
    display: flex; flex-direction: column; align-items: center; gap: 0.12em;
    opacity: 0; transition: opacity 0.6s ease;
  }
  #pgArrivalName .pg-arrival-nm {
    display: block; max-width: 100%;
    color: rgba(226, 232, 240, 0.95);
    text-shadow: 0 0 18px rgba(4, 8, 16, 0.92), 0 1px 4px rgba(4, 8, 16, 0.85);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  #pgArrivalName .pg-arrival-sub {
    display: block; max-width: 100%;
    font-size: 0.36em; letter-spacing: 0.28em; font-weight: 400;
    color: rgba(186, 198, 220, 0.42);
    text-shadow: 0 0 12px rgba(4, 8, 16, 0.85);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  #pgArrivalName .pg-arrival-sub[hidden] { display: none; }
  #pgArrivalName.pg-arrival-name.show { opacity: 1; transition: opacity 0.25s ease; }
  #pgArrivalName.pg-arrival-name.fade { opacity: 0; transition: opacity 0.6s ease; }
  @media (max-width: 480px) {
    #pgArrivalName.pg-arrival-name { top: max(6%, calc(10px + env(safe-area-inset-top, 0px))); font-size: clamp(18px, 6.2vw, 32px); letter-spacing: 0.12em; }
    #pgArrivalName .pg-arrival-sub { font-size: 0.34em; letter-spacing: 0.22em; }
  }
  @media (prefers-reduced-motion: reduce) {
    #pgArrivalName.pg-arrival-name, #pgArrivalName.pg-arrival-name.show, #pgArrivalName.pg-arrival-name.fade { transition: none; }
  }

  #busy.on { display: block; }

  /* ui-motion: --pg-m general; --pg-m-launch / --pg-m-spark / --pg-m-menu / --pg-m-fp for split controls.
     html.pg-bounce gates general chrome; html.pg-m-launch|spark|menu|fp gate each path. Element --pg-m overrides inherit. */
  html { --pg-m: 1; --pg-m-launch: 1; --pg-m-spark: 1; --pg-m-menu: 1; --pg-m-fp: 1; }
  @keyframes pgDropIn {
    0%   { opacity: 0; transform: translateY(calc(-18px - 28px * var(--pg-m))) scale(calc(1 - 0.22 * var(--pg-m))); }
    52%  { opacity: 1; transform: translateY(calc(6px + 12px * var(--pg-m))) scale(calc(1 + 0.08 * var(--pg-m))); }
    74%  { opacity: 1; transform: translateY(calc(-2px - 5px * var(--pg-m))) scale(calc(1 - 0.03 * var(--pg-m))); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
  }
  /* Gear / Options: one-phase scale+opacity from transform-origin (near #btnOpt), not translateY bounce. */
  @keyframes pgPopFromOrigin {
    0%   { opacity: 0; transform: scale(calc(1 - 0.32 * var(--pg-m))); }
    100% { opacity: 1; transform: scale(1); }
  }
  /* Generic HUD buttons: squash → stretch overshoot → settle (strength from --pg-m). */
  @keyframes pgPress {
    0%   { transform: scaleX(calc(1 - 0.28 * var(--pg-m))) scaleY(calc(1 + 0.32 * var(--pg-m))); }
    42%  { transform: scaleX(calc(1 + 0.18 * var(--pg-m))) scaleY(calc(1 - 0.14 * var(--pg-m))); }
    100% { transform: scale(1); }
  }
  @keyframes pgPressSpark {
    0%   { transform: scaleX(calc(1 - 0.28 * var(--pg-m-spark))) scaleY(calc(1 + 0.32 * var(--pg-m-spark))); }
    42%  { transform: scaleX(calc(1 + 0.18 * var(--pg-m-spark))) scaleY(calc(1 - 0.14 * var(--pg-m-spark))); }
    100% { transform: scale(1); }
  }
  @keyframes pgPaneIn {
    0%   { transform: translateX(108%); }
    58%  { transform: translateX(calc(-14px * var(--pg-m))); }
    80%  { transform: translateX(calc(5px * var(--pg-m))); }
    100% { transform: translateX(0); }
  }
  @keyframes pgFavIn {
    0%   { transform: translate(calc(100% + var(--fav-rail-w) + 8px), -50%); }
    58%  { transform: translate(calc(-14px * var(--pg-m)), -50%); }
    80%  { transform: translate(calc(5px * var(--pg-m)), -50%); }
    100% { transform: translate(0, -50%); }
  }
  @keyframes pgDropInFp {
    0%   { opacity: 0; transform: translateY(calc(-18px - 28px * var(--pg-m-fp))) scale(calc(1 - 0.22 * var(--pg-m-fp))); }
    52%  { opacity: 1; transform: translateY(calc(6px + 12px * var(--pg-m-fp))) scale(calc(1 + 0.08 * var(--pg-m-fp))); }
    74%  { opacity: 1; transform: translateY(calc(-2px - 5px * var(--pg-m-fp))) scale(calc(1 - 0.03 * var(--pg-m-fp))); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
  }
  /* EXPLORE: unmistakable cartoon squash/stretch (also keeps translateX(-50%)). Strength: --pg-m-launch. */
  @keyframes pgPressTx {
    0%   { transform: translateX(-50%) scaleX(calc(1 + 0.42 * var(--pg-m-launch))) scaleY(calc(1 - 0.48 * var(--pg-m-launch))); }
    18%  { transform: translateX(-50%) scaleX(calc(1 + 0.42 * var(--pg-m-launch))) scaleY(calc(1 - 0.48 * var(--pg-m-launch))); }
    48%  { transform: translateX(-50%) scaleX(calc(1 - 0.28 * var(--pg-m-launch))) scaleY(calc(1 + 0.42 * var(--pg-m-launch))); }
    72%  { transform: translateX(-50%) scaleX(calc(1 + 0.1 * var(--pg-m-launch))) scaleY(calc(1 - 0.08 * var(--pg-m-launch))); }
    100% { transform: translateX(-50%) scale(1); }
  }
  /* LAUNCH: same cartoon press language with translate(-50%, -50%). */
    @keyframes pgPressLaunch {
    0%   { transform: translateX(-50%) scaleX(calc(1 + 0.42 * var(--pg-m-launch))) scaleY(calc(1 - 0.48 * var(--pg-m-launch))); }
    18%  { transform: translateX(-50%) scaleX(calc(1 + 0.42 * var(--pg-m-launch))) scaleY(calc(1 - 0.48 * var(--pg-m-launch))); }
    48%  { transform: translateX(-50%) scaleX(calc(1 - 0.28 * var(--pg-m-launch))) scaleY(calc(1 + 0.42 * var(--pg-m-launch))); }
    72%  { transform: translateX(-50%) scaleX(calc(1 + 0.1 * var(--pg-m-launch))) scaleY(calc(1 - 0.08 * var(--pg-m-launch))); }
    100% { transform: translateX(-50%) scaleX(1) scaleY(1); }
  }
  @keyframes pgSwitchFlick {
    0%   { transform: translateX(0) scale(1); }
    30%  { transform: translateX(var(--pg-flick, 14px)) scaleX(calc(1 + 0.45 * var(--pg-m))) scale(calc(1 + 0.12 * var(--pg-m))); }
    64%  { transform: translateX(calc(var(--pg-flick, 14px) * -.38)) scaleX(calc(1 - 0.1 * var(--pg-m))) scale(calc(1 - 0.04 * var(--pg-m))); }
    100% { transform: translateX(0) scale(1); }
  }
  @keyframes pgChkFlick {
    0%   { transform: scale(1); }
    28%  { transform: scale(calc(1 + 0.55 * var(--pg-m))); }
    62%  { transform: scale(calc(1 - 0.14 * var(--pg-m))); }
    100% { transform: scale(1); }
  }
  #btnOpt, #btnTest { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
  /* Hold squash on pointerdown (.pg-squash); release overshoots (.pg-pop). Not :active — that dies in one frame. */
  html.pg-bounce #btnOpt.pg-squash,
  html.pg-bounce #btnTest.pg-squash {
    transform: scaleX(calc(1 + 0.22 * var(--pg-m))) scaleY(calc(1 - 0.32 * var(--pg-m))) !important;
    transition: transform .07s ease-out !important;
    animation: none !important;
  }
  html.pg-m-spark #pgSpark.pg-squash {
    transform: scaleX(calc(1 + 0.22 * var(--pg-m-spark))) scaleY(calc(1 - 0.32 * var(--pg-m-spark))) !important;
    transition: transform .07s ease-out !important;
    animation: none !important;
  }
  /* Launch + Explore: strong held squash (wide + flat) — cartoon, unmistakable. */
  html.pg-m-launch #titleEnter.pg-squash {
    transform: translateX(-50%) scaleX(calc(1 + 0.55 * var(--pg-m-launch))) scaleY(calc(1 - 0.55 * var(--pg-m-launch))) !important;
    transition: transform .07s ease-out !important;
    animation: none !important;
  }
  html.pg-m-launch #titleLaunchBtn.pg-squash {
    transform: translateX(-50%) scaleX(calc(1 + 0.55 * var(--pg-m-launch))) scaleY(calc(1 - 0.55 * var(--pg-m-launch))) !important;
    transition: transform .07s ease-out !important;
    animation: none !important;
  }
  html.pg-bounce #btnOpt.pg-pop,
  html.pg-bounce #btnTest.pg-pop {
    animation: pgPress .5s cubic-bezier(.15, 1.55, .28, 1) both !important;
  }
  html.pg-m-spark #pgSpark.pg-pop {
    animation: pgPressSpark .5s cubic-bezier(.15, 1.55, .28, 1) both !important;
  }
  html.pg-m-launch #titleEnter.pg-pop { animation: pgPressTx .62s cubic-bezier(.12, 1.65, .28, 1) both !important; }
  html.pg-m-launch #titleLaunchBtn.pg-pop { animation: pgPressLaunch .62s cubic-bezier(.12, 1.65, .28, 1) both !important; }
  /* Panel drop-in replays via .pg-drop (JS removes the class and forces reflow on every open). */
  html.pg-bounce #moreMenu.pg-drop,
  html.pg-bounce #testMenu.pg-drop,
  html.pg-bounce .audio-edit-sheet.pg-drop {
    animation: pgDropIn calc(.42s + .28s * var(--pg-m)) cubic-bezier(.16, 1.25, .28, 1) both;
  }
  /* Options under gear: emerge from #btnOpt (transform-origin: 92% 0) — no upward bounce. */
  html.pg-bounce #optPanel.pg-drop {
    animation: pgPopFromOrigin calc(.28s + .16s * var(--pg-m)) cubic-bezier(.32, .08, .24, 1) both;
  }
  html.pg-m-fp #fp.pg-drop {
    animation: pgDropInFp calc(.42s + .28s * var(--pg-m-fp)) cubic-bezier(.16, 1.25, .28, 1) both;
  }
  /* Favourites drawer + journal pane: bounce on open, smooth slide shut. Strength is General (--pg-m). */
  html.pg-bounce #favDrawer { transition: transform calc(.26s + .14s * var(--pg-m)) cubic-bezier(.32, .08, .24, 1); }
  html.pg-bounce #favDrawer.open.pg-drop {
    transition: none;
    animation: pgFavIn calc(.36s + .22s * var(--pg-m)) cubic-bezier(.16, 1.05, .28, 1) both;
  }
  html.pg-bounce #pane { transition: transform calc(.26s + .14s * var(--pg-m)) cubic-bezier(.32, .08, .24, 1); }
  html.pg-bounce body.pane-open #pane.pg-drop {
    transition: none;
    animation: pgPaneIn calc(.36s + .22s * var(--pg-m)) cubic-bezier(.16, 1.05, .28, 1) both;
  }
  #fp .mw { transition: height calc(.12s + .28s * var(--pg-m-fp, var(--pg-m))) cubic-bezier(.2, .85, .25, 1); }
  html:not(.pg-m-fp) #fp .mw { transition: none; }
  #optPanel .opt-sub > .osec { will-change: height, opacity; }
  html.pg-bounce #optPanel input[type=checkbox][switch]:not(.pg-hsw).pg-flick {
    animation: pgSwitchFlick calc(.34s + .2s * var(--pg-m)) cubic-bezier(.18, 1.7, .3, 1);
  }
  html.pg-bounce #optPanel input[type=checkbox]:not([switch]).pg-flick {
    animation: pgChkFlick calc(.3s + .18s * var(--pg-m)) cubic-bezier(.18, 1.7, .3, 1);
  }

  /* ---- Title screen (v8): StarCode's intro (css/cosmos-title.css + js/launch-gate.js), adapted. Authored at the top of
     <body> so it covers the very first paint. ---- */
  .title-screen { position: fixed; inset: 0; z-index: 10030; background: transparent; overflow: hidden; touch-action: none;
    user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; transition: opacity 1500ms ease;
    --title-cta-x: 50%; --title-cta-bottom: 24.5%; --title-cta-bar-lift: 28px; --title-cta-label-gap: 14px; }
  .title-screen.title-leaving { pointer-events: none; }
  .title-black { position: absolute; inset: 0; background: #000; }
  .title-screen.title-gone { opacity: 0; }
  .title-screen.title-leaving #titleWord, .title-screen.title-leaving .title-enter, .title-screen.title-leaving .title-skip, .title-screen.title-leaving .title-black,
  .title-screen.title-leaving .title-launch { opacity: 0 !important; transition: opacity var(--tfade, 1100ms) ease !important; }
  @keyframes uiIn { from { opacity: 0; } }
  body.ui-enter #ui, body.ui-enter #info, body.ui-enter #hint, body.ui-enter #stats, body.ui-enter #fp, body.ui-enter #fpPill, body.ui-enter #favTab { animation: uiIn 1s ease both; }
  body.title-showing #ui, body.title-showing #info, body.title-showing #hint, body.title-showing #stats, body.title-showing #pane,
  body.title-showing #optPanel, body.title-showing #audioPanel, body.title-showing #busy, body.title-showing #pgArrivalName { visibility: hidden; }
  .title-screen canvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
  /* Logo contrast: normal compositing; JS applies in-glyph luminance only
     (no outer outline, keyline, soft plate, shadowBlur, or outer glow). */
  #titleWord { mix-blend-mode: normal; }
  /* Title CTA layout: Explore position (--title-cta-*) drives loading bar + Launch. */
  .title-enter { position: absolute; left: var(--title-cta-x); bottom: var(--title-cta-bottom); transform: translateX(-50%); min-height: 44px; padding: 12px 30px 12px 34px;
    font: 600 13px "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif; letter-spacing: 0.34em; text-transform: uppercase;
    color: rgba(var(--ui-fg), 0.86); background: rgba(var(--ui-bg), 0.55); border: 1px solid rgba(var(--ui-fg), 0.28); border-radius: 999px;
    cursor: pointer; opacity: 0; transition: border-color 200ms ease, color 200ms ease; backdrop-filter: none; z-index: 3; }
  .title-enter:hover, .title-enter:focus-visible { border-color: rgba(var(--btn-hi), 1) !important; color: #fff; outline: none; background: rgba(var(--ui-bg), 0.55); }
  .title-enter[hidden] { display: none; }
  body.nohud #ui, body.nohud #info, body.nohud #hint, body.nohud #stats, body.nohud #fp, body.nohud #fpPill, body.nohud #favTab, body.nohud #pane,
  body.nohud #optPanel, body.nohud #audioPanel, body.nohud #busy, body.nohud #pgArrivalName { display: none !important; }
  /* v18 chroma unify: Launch + Explore share --explore-accent / --explore-hi from the body/halo scene sample
     (same source as the logo silhouette). Loading Launch no longer uses fixed gold (--ui-accent). */
  #titleEnter, #titleLaunchBtn { overflow: hidden; isolation: isolate; animation: btnBreath 2.4s ease-in-out infinite;
    border-color: rgba(var(--btn-accent), 0.75); color: #fff; box-shadow: 0 0 18px rgba(var(--btn-accent), 0.55), 0 0 44px rgba(var(--btn-accent), 0.25);
    text-shadow: 0 0 8px rgba(var(--btn-accent), 0.9);
    --explore-accent: 123, 79, 214; --explore-hi: 210, 160, 255;
    --btn-accent: var(--explore-accent); --btn-hi: var(--explore-hi); }
  #titleLaunchBtn { color: rgba(255, 255, 255, 0.9); }
  #titleEnter::before, #titleLaunchBtn::before { content: ""; position: absolute; inset: 0; z-index: -2; pointer-events: none; border-radius: inherit;
    background: radial-gradient(120% 160% at 50% 110%, rgba(var(--btn-accent), 0.65), rgba(var(--btn-accent), 0.22) 55%, rgba(var(--btn-accent), 0.06) 85%);
    opacity: 0.6; animation: btnCore 2.4s ease-in-out infinite; }
  #titleEnter::after, #titleLaunchBtn::after { content: ""; position: absolute; inset: -2px; z-index: -1; pointer-events: none; border-radius: inherit;
    background: linear-gradient(110deg, transparent 38%, rgba(var(--btn-hi), 0.35) 45%, rgba(255, 250, 235, 0.95) 50%, rgba(var(--btn-accent), 0.55) 55%, transparent 62%) no-repeat;
    background-size: 250% 100%; background-position: 140% 0; animation: btnShimmer 3.5s ease-in-out 0.6s infinite; }
  @keyframes btnBreath {
    0%, 100% { box-shadow: 0 0 14px rgba(var(--btn-accent), 0.45), 0 0 34px rgba(var(--btn-accent), 0.18); border-color: rgba(var(--btn-accent), 0.6);
      text-shadow: 0 0 6px rgba(var(--btn-accent), 0.6); scale: 1; }
    50% { box-shadow: 0 0 26px rgba(var(--btn-accent), 1), 0 0 70px rgba(var(--btn-accent), 0.65), 0 0 120px rgba(var(--btn-accent), 0.3), inset 0 0 18px rgba(var(--btn-accent), 0.55);
      border-color: rgba(var(--btn-hi), 1); text-shadow: 0 0 10px rgba(var(--btn-accent), 1), 0 0 22px rgba(var(--btn-accent), 0.8); scale: 1.06; } }
  @keyframes btnCore { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }
  @keyframes btnShimmer { 0% { background-position: 140% 0; } 40%, 100% { background-position: -40% 0; } }
  @media (prefers-reduced-motion: reduce) {
    #titleEnter, #titleLaunchBtn, #titleEnter::before, #titleLaunchBtn::before { animation: none; }
    #titleEnter::after, #titleLaunchBtn::after { animation: none; opacity: 0; }
    #titleEnter, #titleLaunchBtn { box-shadow: 0 0 24px rgba(var(--btn-accent), 0.95), 0 0 64px rgba(var(--btn-accent), 0.5), inset 0 0 14px rgba(var(--btn-accent), 0.45);
      border-color: rgba(var(--btn-hi), 1); text-shadow: 0 0 10px rgba(var(--btn-accent), 1), 0 0 20px rgba(var(--btn-accent), 0.7); }
    #titleEnter::before, #titleLaunchBtn::before { opacity: 1; } }
  .title-launch { position: absolute; inset: 0; z-index: 2; transition: opacity 500ms ease; }
  .title-launch.done { opacity: 0; pointer-events: none; }
  .title-launch-bar[hidden], .title-launch-label[hidden] { display: none; }
  /* Loading bar + Launch sit on the same CTA anchor as title Explore (--title-cta-*). */
  .title-launch-btn { top: auto; bottom: var(--title-cta-bottom); left: var(--title-cta-x); transform: translateX(-50%); color: rgba(255, 255, 255, 0.34);
    border-color: rgba(255, 255, 255, 0.16); background: none; transition: opacity 700ms ease, border-color 200ms ease, color 200ms ease; }
  .title-launch-btn:hover, .title-launch-btn:focus-visible { color: #fff; border-color: rgba(var(--btn-hi), 0.95) !important; background: none; }
  .title-launch-bar { position: absolute; left: var(--title-cta-x); top: auto; bottom: calc(var(--title-cta-bottom) + var(--title-cta-bar-lift)); width: 140px; height: 2px;
    transform: translateX(-50%); margin-left: 0; background: rgba(255, 255, 255, 0.38); overflow: hidden; border-radius: 1px; }
  .title-launch-bar i { display: block; width: 100%; height: 100%; background: rgba(255, 255, 255, 0.85); transform: scaleX(0); transform-origin: left center;
    will-change: transform; backface-visibility: hidden;
    transition: transform 480ms cubic-bezier(0.22, 0.61, 0.36, 1); }
  .title-launch-label { position: absolute; left: 0; right: 0; top: auto; bottom: calc(var(--title-cta-bottom) - var(--title-cta-label-gap)); margin: 0; text-align: center;
    font: 10px/1 monospace; letter-spacing: 3px; text-transform: uppercase; color: rgba(255, 255, 255, 0.18); }
  .title-skip { position: absolute; right: 56px; bottom: 16px; z-index: 3; font: 10px/1 monospace; letter-spacing: 3px; text-transform: uppercase;
    color: rgba(255, 255, 255, 0.18); opacity: 0; transition: opacity 700ms ease; pointer-events: none; }


  /* Left-handed: mirror TEST / gear / favourites rail. Sparkle stays bottom-right. */
  body.ui-left #ui { left: auto; right: 16px; }
  body.ui-left #btnOpt { right: auto; left: max(16px, calc(env(safe-area-inset-left, 0px) + 10px)); }
  body.ui-left #optPanel { right: auto; left: max(16px, calc(env(safe-area-inset-left, 0px) + 10px)); transform-origin: 8% 0; }
  body.ui-left #testMenu { left: auto; right: 16px; transform-origin: 88% 0; }
  body.ui-left #moreMenu { left: auto !important; right: 16px !important; }
  body.ui-left #audioPanel { left: auto; right: 16px; }
  body.ui-left #favTab {
    right: auto; left: 0; border-radius: 0 10px 10px 0; border-right: 1px solid rgba(160,180,220,.22); border-left: 0;
  }
  body.ui-left #favTab .fav-twisty {
    border-width: 7px 11px 7px 0; border-color: transparent currentColor transparent transparent; transform-origin: 40% 50%;
  }
  body.ui-left #favTab.open .fav-twisty, body.ui-left:has(#favDrawer.open) #favTab .fav-twisty { transform: rotate(180deg); }
  body.ui-left #favDrawer {
    right: auto; left: calc(var(--fav-rail-w) * -1);
    transform: translate(calc(-100% - var(--fav-rail-w) - 8px), -50%);
    border-radius: 0 10px 10px 0; border-left: 0; border-right: 1px solid rgba(160,180,220,.22);
  }
  body.ui-left #favDrawer.open { transform: translate(0, -50%); }
  @keyframes pgFavInLeft {
    0%   { transform: translate(calc(-100% - var(--fav-rail-w) - 8px), -50%); }
    70%  { transform: translate(6px, -50%); }
    100% { transform: translate(0, -50%); }
  }
  html.pg-bounce body.ui-left #favDrawer.open.pg-drop {
    animation: pgFavInLeft calc(.36s + .22s * var(--pg-m)) cubic-bezier(.16, 1.05, .28, 1) both;
  }
  @media (min-width: 700px) {
    body.ui-left.pane-open #btnOpt { left: calc(var(--pane-w) + 16px); right: auto; }
    body.ui-left.pane-open #optPanel { left: calc(var(--pane-w) + 16px); right: auto; }
  }
