/* The studio (animate skill). Hand-written. Reads only the network theme's tokens (themes skill: --paper, --ink, --muted,
   --line, --line-strong, --panel, --card, --acid, --on-acid, --focus), so every theme dresses it; style.css sets the
   light ones. Dense tool chrome; Archivo Black only for headings. Motion in the chrome: none, so reduced motion has
   nothing to turn off. The visitor's own animation plays only when they press Play. */
.vh { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
main { display: block; }
.studio {
  --tl-left: 168px; --row: 30px; --gap: 8px;
  display: grid; gap: var(--gap); padding: var(--gap) 16px;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "bar" "work" "transport" "timeline" "status";
  height: max(640px, calc(100dvh - var(--hdr, 100px)));
  grid-template-rows: auto minmax(0, 1fr) auto minmax(150px, 30%) auto;
  color: var(--ink); background: var(--paper);
}
html.embed .studio { height: max(560px, 100dvh); padding: 6px 8px; }
html.embed body { min-width: 0; }
html.embed .sh-wrap, html.embed .sh-drawer, html.embed .foot, html.embed .skip, html.embed #slop-top, html.embed .about { display: none !important; }
.bar { grid-area: bar; } .work { grid-area: work; } .transport { grid-area: transport; } .timeline { grid-area: timeline; } .status { grid-area: status; }

/* buttons: 44 px targets on touch, 34 px with a fine pointer */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; min-width: 34px; padding: 4px 12px; border: 2px solid var(--ink); border-radius: 8px; background: var(--card); color: var(--ink); font: 700 14px/1.1 Arial, Helvetica, sans-serif; cursor: pointer; white-space: nowrap; }
@media (pointer: coarse) { .btn, .mi, .layer-list button, .field input, .field select, .insp input, .insp select { min-height: 44px; } .btn { min-width: 44px; } }
.btn:hover { background: var(--panel); }
.btn.strong, .btn[aria-pressed="true"] { background: var(--acid); color: var(--on-acid); border-color: var(--ink); }
.btn.icon { padding: 4px; }
.btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.btn.play .i-pause { display: none; } .btn.play[aria-pressed="true"] .i-play { display: none; } .btn.play[aria-pressed="true"] .i-pause { display: block; }
.btn.play svg path { fill: currentColor; } .btn.play .i-pause path { fill: none; stroke-width: 3.2; }
.btn[disabled], .btn[aria-disabled="true"], .mi[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
kbd { font: 700 11px/1 "Courier New", monospace; padding: 2px 4px; border: 1px solid currentColor; border-radius: 4px; opacity: .8; }
:where(button, input, select, summary, [tabindex], a, canvas):focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.bar, .transport { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.namebox { flex: 1 1 160px; min-width: 0; max-width: 360px; }
.namebox input { width: 100%; min-height: 34px; padding: 4px 10px; border: 2px solid var(--line-strong); border-radius: 8px; background: var(--paper); color: var(--ink); font: 700 16px Arial, sans-serif; }
@media (pointer: coarse) { .namebox input { min-height: 44px; } }
.btn.song { max-width: 260px; overflow: hidden; } .song-label { overflow: hidden; text-overflow: ellipsis; }
.menu { position: relative; }
.menu > summary { list-style: none; } .menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after { content: ""; width: 0; height: 0; border: 5px solid transparent; border-top-color: currentColor; margin-top: 5px; }
.menu-list { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; min-width: 240px; max-width: min(320px, calc(100vw - 32px)); padding: 6px; display: grid; gap: 2px; border: 2px solid var(--ink); border-radius: 10px; background: var(--card); box-shadow: 4px 4px 0 var(--ink); }
.menu.right .menu-list { left: auto; right: 0; }
.mi { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 36px; padding: 6px 10px; border: 0; border-radius: 6px; background: none; color: var(--ink); font: 14px/1.2 Arial, sans-serif; text-align: left; cursor: pointer; }
.mi:hover, .mi:focus-within { background: var(--panel); }
.mi.file input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.mi.file:focus-within { outline: 3px solid var(--focus); }
.mi-note { margin: 0 10px 6px; color: var(--muted); font-size: 12px; }

/* the three panes */
.work { display: grid; gap: var(--gap); grid-template-columns: 200px minmax(0, 1fr) 260px; min-height: 0; }
.panel { min-width: 0; min-height: 0; overflow: auto; border: 2px solid var(--line-strong); border-radius: 10px; background: var(--panel); padding: 8px; }
.ph { font-size: 15px; letter-spacing: -.2px; margin: 0 0 6px; }
.layer-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.layer-list li { display: flex; align-items: center; gap: 2px; }
.layer-list li.child { padding-left: 16px; }
.layer-list .ln { flex: 1; min-width: 0; min-height: 34px; text-align: left; padding: 4px 8px; border: 2px solid transparent; border-radius: 6px; background: none; color: var(--ink); font: 14px Arial, sans-serif; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.layer-list .ln small { color: var(--muted); }
.layer-list .ln[aria-pressed="true"] { background: var(--acid); color: var(--on-acid); border-color: var(--ink); }
.layer-list .ln[aria-pressed="true"] small { color: inherit; }
.layer-list .lt { flex: none; min-width: 34px; min-height: 34px; border: 0; border-radius: 6px; background: none; color: var(--ink); cursor: pointer; font-size: 13px; }
.layer-list .lt svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.layer-list .lt[aria-pressed="false"] { color: var(--muted); }
.layer-list .empty { color: var(--muted); font-size: 14px; padding: 6px; }

.stage-wrap { position: relative; min-width: 0; min-height: 0; display: grid; place-items: center; border-radius: 10px; background: repeating-conic-gradient(var(--panel) 0 25%, var(--paper) 0 50%) 0 0 / 20px 20px; border: 2px solid var(--line-strong); overflow: hidden; }
#stage { display: block; width: 100%; height: 100%; touch-action: none; cursor: default; }

.insp { display: grid; gap: 8px; font-size: 14px; }
.insp h3 { font: 700 13px Arial, sans-serif; letter-spacing: 0; text-transform: none; margin: 6px 0 0; color: var(--muted); }
.insp .pr { display: grid; grid-template-columns: 74px minmax(0, 1fr) 34px; gap: 4px; align-items: center; }
.insp .pr.wide { grid-template-columns: 74px minmax(0, 1fr); }
.insp label { font-size: 13px; }
.insp input, .insp select, .insp textarea { width: 100%; min-width: 0; min-height: 32px; padding: 3px 6px; border: 2px solid var(--line-strong); border-radius: 6px; background: var(--paper); color: var(--ink); font: 14px Arial, sans-serif; }
.insp input[type="color"] { padding: 1px 2px; }
.insp input[type="checkbox"], .field input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; margin: 0; vertical-align: middle; accent-color: var(--ink); }
.insp label:has(input[type="checkbox"]) { display: inline-flex; align-items: center; gap: 8px; min-height: 34px; }
.insp textarea { min-height: 56px; resize: vertical; }
.insp .kt { min-width: 34px; min-height: 32px; border: 0; background: none; color: var(--ink); cursor: pointer; }
.insp .kt svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2; fill: none; }
.insp .kt[aria-pressed="true"] svg { fill: var(--acid); }
.insp .kt.on-key svg { fill: var(--ink); }
.insp .hint { color: var(--muted); font-size: 13px; margin: 0; }
.insp .row-btns { display: flex; flex-wrap: wrap; gap: 4px; }
.curve { width: 100%; max-width: 220px; aspect-ratio: 1; display: block; border: 2px solid var(--line-strong); border-radius: 8px; background: var(--paper); touch-action: none; }

.time { font: 700 15px/1 "Courier New", monospace; min-width: 10ch; padding: 0 4px; }
.zoom { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; margin-left: auto; }
.zoom input { width: 120px; }

/* the timeline: names on the left (sticky), the ruler on top (sticky), keys as buttons */
.timeline { min-height: 0; border: 2px solid var(--line-strong); border-radius: 10px; background: var(--panel); overflow: hidden; }
.tl-scroll { height: 100%; overflow: auto; overscroll-behavior: contain; }
.tl-inner { position: relative; min-width: 100%; }
.tl-ruler-row { position: sticky; top: 0; z-index: 4; display: flex; height: 48px; background: var(--panel); border-bottom: 2px solid var(--line-strong); }
.tl-corner { position: sticky; left: 0; z-index: 5; flex: 0 0 var(--tl-left); padding: 6px 8px; background: var(--panel); border-right: 2px solid var(--line-strong); font-size: 12px; color: var(--muted); overflow: hidden; }
.tl-ruler { position: relative; flex: 1 0 auto; cursor: ew-resize; touch-action: none; }
.tl-ruler canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.tl-row { display: flex; height: var(--row); border-bottom: 1px solid var(--line); }
.tl-row.sel { background: color-mix(in srgb, var(--acid) 18%, transparent); }
.tl-name { position: sticky; left: 0; z-index: 3; flex: 0 0 var(--tl-left); display: flex; align-items: center; gap: 4px; padding: 0 8px; background: var(--panel); border-right: 2px solid var(--line-strong); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-name.prop { padding-left: 22px; color: var(--muted); }
.tl-name button { all: unset; cursor: pointer; overflow: hidden; text-overflow: ellipsis; }
.tl-name button:focus-visible { outline: 3px solid var(--focus); }
.tl-track { position: relative; flex: 1 0 auto; }
.key { position: absolute; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; padding: 0; border: 0; background: none; cursor: grab; touch-action: none; }
@media (pointer: coarse) { .key { width: 32px; height: 32px; margin: -16px 0 0 -16px; } .studio { --row: 40px; } }
.key::before { content: ""; position: absolute; inset: 5px; transform: rotate(45deg); border: 2px solid var(--ink); background: var(--card); border-radius: 2px; }
.key.sum { pointer-events: none; } .key.sum::before { inset: 7px; background: var(--muted); border-color: var(--muted); }
.key.hold::before { border-radius: 0; transform: none; }
.key[aria-pressed="true"]::before { background: var(--acid); border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink); }
.key:focus-visible { outline: none; } .key:focus-visible::before { outline: 3px solid var(--focus); outline-offset: 2px; }
.playhead { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--ink); pointer-events: none; z-index: 2; }
.playhead::before { content: ""; position: absolute; top: 0; left: -6px; border: 7px solid transparent; border-top: 9px solid var(--ink); }

.status { margin: 0; min-height: 1.4em; font-size: 14px; color: var(--muted); }

/* dialogs */
.dlg { width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); padding: 0; border: 2px solid var(--ink); border-radius: 14px; background: var(--card); color: var(--ink); box-shadow: 6px 6px 0 var(--ink); }
.dlg::backdrop { background: rgba(23, 24, 21, .55); }
.dlg-in { display: grid; gap: 10px; padding: 16px; }
.dlg h2 { font-size: 26px; letter-spacing: -.8px; }
.dlg .note { margin: 0; color: var(--muted); font-size: 14px; }
.dlg-foot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.field { display: grid; gap: 4px; font-size: 13px; font-weight: 700; }
.field input, .field select { min-height: 38px; padding: 4px 8px; border: 2px solid var(--line-strong); border-radius: 8px; background: var(--paper); color: var(--ink); font: 15px Arial, sans-serif; width: 100%; min-width: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; border: 0; }
.seg label { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 4px 12px; border: 2px solid var(--ink); border-radius: 999px; cursor: pointer; font-weight: 700; font-size: 14px; }
.seg label:has(input:checked) { background: var(--acid); color: var(--on-acid); }
.seg label:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.pick-list { list-style: none; margin: 0; padding: 0; max-height: 46dvh; overflow: auto; display: grid; gap: 4px; }
.pick-list button { width: 100%; min-height: 44px; display: grid; gap: 2px; text-align: left; padding: 6px 10px; border: 2px solid var(--line-strong); border-radius: 8px; background: var(--paper); color: var(--ink); cursor: pointer; font: 14px Arial, sans-serif; }
.pick-list button b { font-size: 15px; }
.pick-list button span { color: var(--muted); font-size: 13px; }
.pick-list button:hover { border-color: var(--ink); }
.pick-list .row { display: flex; gap: 4px; } .pick-list .row > button:first-child { flex: 1; } .pick-list .row > button.del { width: auto; }
.art-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; max-height: 50dvh; overflow: auto; }
.art-grid button { width: 100%; padding: 0; border: 2px solid var(--line-strong); border-radius: 8px; background: var(--paper); cursor: pointer; overflow: hidden; color: var(--ink); font: 12px/1.2 Arial, sans-serif; }
.art-grid img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; background: var(--panel); }
.art-grid span { display: block; padding: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
progress { width: 100%; height: 14px; }

.about { max-width: 820px; padding: 32px 16px 24px; margin: 0 auto; }
.about h2 { font-size: clamp(28px, 4vw, 40px); margin-bottom: 10px; }
.about h3 { font-size: 20px; margin: 20px 0 6px; letter-spacing: -.4px; }
.about p { margin: 0 0 10px; }
.keys { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
.keys dd { margin: 0; }
.foot { display: flex; flex-wrap: wrap; gap: 16px 32px; align-items: center; padding: 32px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; max-width: 1440px; margin: 0 auto; }
.foot .brand img { width: 140px; height: auto; display: block; }

/* middle widths: the inspector under the stage */
@media (max-width: 1080px) {
  .work { grid-template-columns: 180px minmax(0, 1fr); grid-template-rows: minmax(260px, 1fr) auto; }
  .inspector { grid-column: 1 / -1; max-height: 260px; }
}
/* phones: stage first, then playback and the timeline; layers and properties below */
@media (max-width: 720px) {
  .studio { --tl-left: 112px; padding: 6px 16px; grid-template-areas: none; grid-template-rows: none; height: auto; }
  .studio > *, .work > * { grid-area: auto; }
  .work { display: contents; }
  .bar { order: 0; } .stage-wrap { order: 1; aspect-ratio: 16 / 9; } .transport { order: 2; } .timeline { order: 3; height: 220px; }
  .status { order: 4; } .layers { order: 5; } .inspector { order: 6; max-height: none; grid-column: auto; }
  .zoom { margin-left: 0; } .zoom input { width: 96px; }
  .btn.song { max-width: 180px; }
}
@media (forced-colors: active) {
  .btn[aria-pressed="true"], .layer-list .ln[aria-pressed="true"] { outline: 3px solid Highlight; }
  .key::before { forced-color-adjust: none; background: Canvas; border-color: CanvasText; }
  .key[aria-pressed="true"]::before { background: Highlight; }
  .playhead, .playhead::before { background: CanvasText; border-top-color: CanvasText; }
}
