/* Layout: desktop cockpit owns the first 100dvh; the guide scrolls below. */
.app { height: 100dvh; min-height: 560px; display: grid; grid-template-columns: 360px minmax(0, 1fr) 316px; grid-template-rows: 52px minmax(0, 1fr) auto; grid-template-areas: "header header header" "library stage inspector" "library dock dock"; gap: 10px; padding: 10px; width: 100%; max-width: none; transition: grid-template-columns var(--cx-dur-slow) var(--cx-spring-snap); }
.app[data-inspector="closed"] { grid-template-columns: 360px minmax(0, 1fr) 0px; }
.app > * { min-width: 0; min-height: 0; }

.topbar { grid-area: header; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 4px 0 6px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--cx-ink-1); text-decoration: none; min-width: 0; }
.brand img { width: 24px; height: auto; }
.brand-name { font-weight: 500; font-size: 15px; letter-spacing: -0.01em; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 6px; min-width: 0; }
.audio-chip span { max-width: 160px; overflow: hidden; text-overflow: ellipsis; }

.pane { background: var(--cx-surface-1); border-radius: var(--cx-radius-shell); box-shadow: var(--cx-catch), var(--cx-shadow-plate); position: relative; isolation: isolate; }
.pane::before { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: -1; background: radial-gradient(380px circle at var(--mx) var(--my), var(--cx-tint-1), transparent 60%); }

.library { grid-area: library; display: flex; flex-direction: column; gap: 8px; padding: 12px; overflow: hidden; }
.inspector { grid-area: inspector; overflow: hidden; }
.inspector-body { height: 100%; overflow-y: auto; overscroll-behavior: contain; padding: 12px; width: 316px; max-width: 100%; transition: opacity var(--cx-dur) ease, transform var(--cx-dur-slow) var(--cx-spring-snap); }
.app[data-inspector="closed"] .inspector-body { opacity: 0; transform: translateX(24px); pointer-events: none; }

.stage { grid-area: stage; position: relative; border-radius: var(--cx-radius-shell); overflow: hidden; background: var(--cx-stage-bg); box-shadow: var(--cx-well-shadow); }
#stage-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
#stage-canvas:focus-visible { box-shadow: inset 0 0 0 2px var(--cx-accent); }
.hud { position: absolute; left: 12px; right: 12px; display: flex; align-items: center; gap: 10px; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-top { top: 12px; justify-content: space-between; flex-wrap: wrap; }
.hud-bottom { bottom: calc(clamp(46px, 12%, 84px) + 10px); justify-content: flex-start; color: var(--cx-ink-2); font-size: 12px; }
.hud-readout { display: grid; grid-template-columns: auto auto; align-items: baseline; column-gap: 10px; row-gap: 6px; padding: 8px 12px; border-radius: 10px; background: oklch(0.12 0.004 250 / 0.72); backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3); box-shadow: var(--cx-catch); }
.hud-block { font-weight: 500; font-size: 13px; }
.hud-beat { font-size: 12px; color: var(--cx-ink-2); }
.hud-progress { grid-column: 1 / -1; height: 2px; border-radius: 2px; background: oklch(1 0 0 / 0.1); overflow: hidden; }
.hud-progress span { display: block; height: 100%; width: 100%; background: var(--cx-accent); transform-origin: left; transform: scaleX(0); }
.hud-pills { padding: 4px; border-radius: 999px; background: oklch(0.12 0.004 250 / 0.72); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: var(--cx-catch); max-width: 100%; }
.hud-bottom #hud-project { padding: 4px 10px; border-radius: 999px; background: oklch(0.12 0.004 250 / 0.6); }
.hud-bottom .btn { background: oklch(0.12 0.004 250 / 0.6); }

.focus-card { position: absolute; left: 50%; bottom: calc(clamp(46px, 12%, 84px) + 12px); transform: translateX(-50%); display: flex; align-items: center; gap: 14px; padding: 6px 6px 6px 14px; max-width: calc(100% - 24px); border-radius: 16px; background: var(--cx-glass-oled); backdrop-filter: blur(18px) saturate(1.3); -webkit-backdrop-filter: blur(18px) saturate(1.3); box-shadow: inset 0 0 0 1px oklch(1 0 0 / 0.07), var(--cx-shadow-float); animation: rise var(--cx-dur-drawer) var(--cx-spring-drawer); }
.focus-card::after { content: ""; position: absolute; left: 12%; right: 12%; top: 0; height: 1px; background: var(--cx-specular); pointer-events: none; }
.focus-meta { display: flex; flex-direction: column; min-width: 0; }
.focus-meta strong { font: 500 22px/1.05 var(--cx-font-script); letter-spacing: 0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.focus-hint { font-size: 10.5px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--cx-stage-trace-1, var(--cx-accent)); opacity: 0.85; }
.focus-meta span { font-size: 11px; color: var(--cx-ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.focus-actions { display: flex; gap: 4px; flex: none; }
.stage-empty { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--cx-ink-2); text-align: center; padding: 24px; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 10px); } }

.dock { grid-area: dock; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 10px 12px 12px; background: var(--cx-surface-1); border-radius: var(--cx-radius-shell); box-shadow: var(--cx-catch), var(--cx-shadow-plate); }
.transport { display: flex; align-items: center; gap: 12px; min-width: 0; }
.play { min-width: 104px; min-height: 44px; font-size: 14px; }
.play-ico { display: grid; }
.readouts { display: flex; align-items: baseline; gap: 6px; min-width: 0; white-space: nowrap; }
.readouts .big { font-size: 20px; font-weight: 500; letter-spacing: -0.02em; }
.readouts.tempo { flex-direction: column; align-items: flex-start; gap: 0; line-height: 1.25; }
.readouts.tempo output { font-size: 13px; }
.tempo-adjust { display: flex; gap: 2px; margin-right: auto; }
.wave-wrap { height: 54px; border-radius: var(--cx-radius-card); background: var(--cx-well); box-shadow: var(--cx-well-shadow); overflow: hidden; }
#wave { width: 100%; height: 100%; display: block; cursor: pointer; }
.score-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.score-actions { display: flex; gap: 2px; flex: none; }
.block-note { margin: 0; font-size: 12px; min-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.mobile-tabs { display: none; }

/* Tablet: details become a drawer over the stage */
@media (max-width: 1180px) {
  .app, .app[data-inspector="closed"] { grid-template-columns: 300px minmax(0, 1fr); grid-template-areas: "header header" "library stage" "library dock"; }
  .inspector { position: fixed; top: 72px; right: 10px; bottom: 10px; width: min(340px, calc(100vw - 20px)); z-index: 40; box-shadow: var(--cx-catch), var(--cx-shadow-float); transition: transform var(--cx-dur-slow) var(--cx-spring-snap), opacity var(--cx-dur) ease; }
  .app[data-inspector="closed"] .inspector { transform: translateX(calc(100% + 24px)); opacity: 0; pointer-events: none; }
  .inspector-body { width: 100%; }
  .brand-name { display: none; }
}

/* Phone: fold hero + panels; sticky transport in the thumb zone */
@media (max-width: 820px) {
  .app, .app[data-inspector="closed"] { display: flex; flex-direction: column; height: auto; min-height: 0; padding: 8px 8px 0; gap: 8px; }
  .topbar { flex-wrap: wrap; height: auto; padding: 2px; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
  #btn-add-files, #btn-inspector { display: none; }
  .audio-chip span { max-width: 84px; }
  .stage { order: 1; height: 56svh; min-height: 300px; flex: none; }
  .hud-bottom { bottom: calc(clamp(46px, 12%, 84px) + 6px); }
  .mobile-tabs { order: 2; display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--cx-surface-1); position: sticky; top: 0; z-index: 30; box-shadow: var(--cx-catch); }
  .mobile-tabs button { flex: 1; min-height: 44px; border: 0; border-radius: 9px; background: transparent; color: var(--cx-ink-2); font-weight: 500; font-size: 13px; cursor: pointer; }
  .mobile-tabs button[aria-selected="true"] { background: var(--cx-surface-3); color: var(--cx-ink-1); }
  .library { order: 3; height: 78svh; }
  .library[data-active="false"] { display: none; }
  .dock { order: 3; }
  .dock[data-active="false"] { padding: 0; background: none; box-shadow: none; }
  .dock[data-active="false"] > :not(.transport) { display: none; }
  .inspector, .app[data-inspector="closed"] .inspector { order: 3; position: static; width: auto; transform: none; opacity: 1; pointer-events: auto; box-shadow: var(--cx-catch); }
  .inspector[data-active="false"] { display: none; }
  .app[data-inspector="closed"] .inspector-body { opacity: 1; transform: none; pointer-events: auto; }
  .transport { position: fixed; left: 8px; right: 8px; bottom: max(8px, env(safe-area-inset-bottom)); z-index: 50; padding: 8px; border-radius: 16px; background: var(--cx-glass); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); box-shadow: var(--cx-catch), var(--cx-shadow-float); gap: 8px; }
  .transport .play { min-width: 96px; }
  .transport .tempo, .tempo-adjust, #btn-record .lbl, .readouts #rd-total { display: none; }
  #btn-record, #btn-export { padding: 0 10px; }
  #btn-export { margin-left: auto; }
  .readouts .big { font-size: 17px; }
  body { padding-bottom: 88px; }
  .score-bar { flex-direction: column; align-items: stretch; }
  .hud-pills { order: 2; flex-basis: 100%; }
  .btn { min-height: 44px; }
  .btn.small, .pill { min-height: 40px; }
  .btn.icon-only { width: 44px; }
  .mini-select select { min-height: 40px; }
}
@media (max-width: 400px) {
  #btn-add-folder .lbl { display: none; }
  #btn-record { display: none; }
}

/* Embed: a compact 380px live card */
html[data-cx-embed="compact"] .manual, html[data-cx-embed="compact"] .library, html[data-cx-embed="compact"] .inspector, html[data-cx-embed="compact"] .mobile-tabs, html[data-cx-embed="compact"] .topbar-actions > :not(#btn-audio), html[data-cx-embed="compact"] .score-actions, html[data-cx-embed="compact"] .block-note, html[data-cx-embed="compact"] #btn-record, html[data-cx-embed="compact"] .tempo-adjust { display: none !important; }
html[data-cx-embed="compact"] body { padding-bottom: 0; }
html[data-cx-embed="compact"] .app { display: flex; flex-direction: column; height: 100dvh; min-height: 0; padding: 8px; gap: 8px; }
html[data-cx-embed="compact"] .stage { flex: 1; height: auto; min-height: 200px; }
html[data-cx-embed="compact"] .dock { flex: none; }
html[data-cx-embed="compact"] .dock > :not(.transport):not(.wave-wrap) { display: none; }
html[data-cx-embed="compact"] .transport { position: static; background: none; box-shadow: none; padding: 0; backdrop-filter: none; }
html[data-cx-embed="compact"] .transport .tempo { display: none; }
