  :root {
    --bg: #070807; --panel: #0f1110; --line: #1f2321; --fg: #e8ece9; --muted: #939e98; --dim: #78827c; /* dim: 4.5:1 on the panel (WCAG AA) */
    --jade: #7fe0a0; --jade-ink: #08261a; --warn: #f0b35a;
  }
  * { box-sizing: border-box; }
  html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg);
    font: 14px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
  #app { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 100%; }
  #view { display: flex; align-items: center; justify-content: center; background: #000; }
  #stage { position: relative; touch-action: none; user-select: none; -webkit-user-select: none; }
  canvas { display: block; }
  #stage .stats { position: absolute !important; top: 8px !important; left: 8px !important; z-index: 3; opacity: .92; border-radius: 3px; overflow: hidden; }
  #handle { position: absolute; top: 0; bottom: 0; width: 1px; margin-left: -.5px; background: rgba(255,255,255,.85); cursor: ew-resize; z-index: 2; }
  #handle::after { content: "⇆"; position: absolute; top: 50%; left: -15px; width: 30px; height: 30px; margin-top: -15px; border-radius: 50%;
    background: rgba(255,255,255,.94); color: #111; display: grid; place-items: center; font-size: 15px; box-shadow: 0 2px 12px rgba(0,0,0,.5); }
  #handle::before { content: ""; position: absolute; top: 0; bottom: 0; left: -22px; right: -22px; }
  .tag { position: absolute; bottom: 10px; z-index: 2; font: 600 10px/1 ui-sans-serif, system-ui, sans-serif; letter-spacing: .09em; text-transform: uppercase;
    color: #fff; background: rgba(0,0,0,.5); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); padding: 6px 9px; border-radius: 20px; pointer-events: none; white-space: nowrap; }
  #tagL { right: calc(100% - var(--split) + 10px); }
  #tagR { left: calc(var(--split) + 10px); }

  #panel { background: var(--panel); border-top: 1px solid var(--line); padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 16px; }
  h1 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
  .lede { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
  .lbl { font: 600 10px/1 ui-sans-serif, system-ui, sans-serif; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); margin-bottom: 8px; }
  .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
  .seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #0b0c0c; }
  .seg button { border: 0; background: transparent; color: #b9c2bd; font: inherit; font-size: 13px; padding: 7px 11px; cursor: pointer; }
  .seg button + button { border-left: 1px solid var(--line); }
  .seg button.on { background: var(--jade); color: var(--jade-ink); font-weight: 650; }
  .btn { border: 1px solid var(--line); background: #0b0c0c; color: var(--fg); font: inherit; font-size: 13px; padding: 7px 11px; border-radius: 9px; cursor: pointer; }
  .btn:hover, .seg button:not(.on):hover { background: #161a18; }
  .btn:disabled { opacity: .5; cursor: wait; }
  .side-lbl { width: 54px; color: var(--muted); font-size: 12px; }
  details { border-top: 1px solid var(--line); padding-top: 14px; }
  summary { cursor: pointer; color: var(--muted); font-size: 13px; list-style: none; }
  summary::-webkit-details-marker { display: none; }
  summary::before { content: "▸ "; } details[open] summary::before { content: "▾ "; }
  .group { margin-top: 14px; }
  .cost { display: grid; grid-template-columns: 74px 1fr auto; gap: 6px 10px; align-items: center; font-size: 12px; }
  .cost .name { color: var(--muted); }
  .cost .val { font: 600 12px ui-monospace, SFMono-Regular, Menlo, monospace; text-align: right; }
  .cost .detail { grid-column: 2 / 4; color: var(--dim); font-size: 11px; margin-top: -4px; }
  .bar { height: 6px; border-radius: 3px; background: #1a1e1c; overflow: hidden; }
  .bar i { display: block; height: 100%; width: 0; background: var(--jade); transition: width .4s ease; }
  .bar i.over { background: var(--warn); }
  .budget { color: var(--dim); font-size: 11px; margin-top: 8px; }
  #device { color: var(--dim); font-size: 11px; margin-top: 6px; }
  .foot { margin-top: auto; color: var(--dim); font-size: 11px; line-height: 1.5; }
  .foot a { color: var(--muted); }
  #err { color: #f88; padding: 16px; }
  :focus-visible { outline: 2px solid var(--jade); outline-offset: 2px; }

  @media (min-width: 900px) {
    #app { grid-template-columns: minmax(0, 1fr) 320px; height: 100%; }
    #view { height: 100vh; }
    #panel { border-top: 0; border-left: 1px solid var(--line); overflow-y: auto; padding: 22px 20px; }
    details summary { display: none; }
    details { border-top: 0; padding-top: 0; }
  }
