:root {
  --bg: #f4f5f4;
  --panel: #ffffff;
  --ink: #111312;
  --ink-2: #4a4e4c;
  --mute: #6a706d; /* ≥4.5:1 on white for small labels */
  --line: #ebedec;
  --line-2: #e2e5e3;
  --chip: #f1f2f1;
  --accent: #111312;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Helvetica Neue", sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 13px/1.35 var(--sans); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
svg { display: block; }
[hidden] { display: none !important; }

.app { display: grid; grid-template-columns: minmax(0, 1fr) 340px; height: 100vh; height: 100dvh; overflow: hidden; }
.main { display: grid; grid-template-rows: auto minmax(0, 1fr); min-width: 0; min-height: 0; overflow: hidden; padding: 18px 22px 16px; gap: 14px; }

/* top bar */
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.crumb { font: 10px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--mute); margin-bottom: 6px; }
h1 { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -.015em; line-height: 1.15; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--panel); cursor: pointer; font-weight: 500; white-space: nowrap; transition: background .15s, border-color .15s, transform .1s; }
.btn:hover { border-color: #cfd3d1; }
.btn:active { transform: scale(.97); }
.btn svg { width: 14px; height: 14px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: #e9ebea; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: #2a2d2c; }
.btn .dim { opacity: .55; font-weight: 400; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.chip { font: 10px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; padding: 7px 10px; border-radius: 999px; background: var(--chip); color: var(--mute); }
.chip.ok { color: #1f7a4d; background: #e3f3ea; }
.chip.warn { color: #9a5b00; background: #fbf0dc; }

/* stage */
.stage { position: relative; min-height: 0; overflow: hidden; }
.frame { position: absolute; border-radius: 18px; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 12px 40px rgba(0,0,0,.10); background: #000; }
.frame canvas { display: block; width: 100%; height: 100%; }
.badge { position: absolute; top: 12px; font: 10px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; padding: 6px 9px; border-radius: 999px; background: rgba(0,0,0,.28); color: rgba(255,255,255,.85); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); pointer-events: none; }
.badge.tl { left: 12px; }
.badge.tr { right: 12px; }
.handles { position: absolute; inset: 0; }
.handle { position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; border: 2.5px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25), 0 3px 10px rgba(0,0,0,.3); cursor: grab; touch-action: none; transition: transform .12s; }
.handle:hover { transform: scale(1.12); }
.handle.sel { transform: scale(1.25); box-shadow: 0 0 0 2px var(--ink), 0 3px 12px rgba(0,0,0,.35); }
.handle.center { width: 18px; height: 18px; margin: -9px 0 0 -9px; background: rgba(255,255,255,.25); backdrop-filter: blur(4px); }
.handle.center::after { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: #fff; }
.handles.hidden { display: none; }

/* transport */
.transport { position: absolute; display: flex; align-items: center; gap: 12px; }
.play { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--panel); display: grid; place-items: center; cursor: pointer; flex: none; }
.play svg { width: 14px; height: 14px; }
.transport input[type=range] { flex: 1; }
.time { font: 11px/1 var(--mono); color: var(--ink-2); min-width: 128px; text-align: right; }

/* sidebar */
.side { background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; padding: 18px 20px 40px; scrollbar-width: thin; }
.side-head { display: flex; justify-content: space-between; align-items: baseline; padding-bottom: 14px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.side-head h2 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.meta { font: 10px/1 var(--mono); letter-spacing: .14em; color: var(--mute); text-transform: uppercase; }
.sec { padding: 16px 0 6px; }
.sec + .sec { border-top: 1px solid var(--line); }
.sec-title { font: 10px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--mute); margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; }
.sec-title .links { display: flex; gap: 10px; }
.link { background: none; border: 0; padding: 0; cursor: pointer; font: 10px/1 var(--mono); letter-spacing: .1em; color: var(--ink-2); text-transform: uppercase; }
.link:hover { color: var(--ink); text-decoration: underline; }
.hint { font-size: 11.5px; color: var(--mute); margin: 2px 0 10px; }
.sub { font: 10px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--mute); margin: 14px 0 10px; }

.ctl { margin-bottom: 12px; }
.ctl-top { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 13px; user-select: none; }
.ctl-top .val { font: 12px/1.35 var(--mono); color: var(--ink-2); }
.ctl-top label { cursor: default; }

/* range */
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 16px; background: transparent; margin: 0; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 2px; background: var(--line-2); border-radius: 2px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: var(--ink); margin-top: -5px; border: 0; transition: transform .1s; }
input[type=range]:active::-webkit-slider-thumb { transform: scale(1.25); }
input[type=range]::-moz-range-track { height: 2px; background: var(--line-2); }
input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--ink); border: 0; }

/* segmented */
.seg { display: flex; background: var(--chip); border-radius: 999px; padding: 3px; margin-bottom: 14px; gap: 2px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 999px; height: 28px; cursor: pointer; color: var(--ink-2); font-size: 12.5px; padding: 0 4px; white-space: nowrap; transition: background .15s, color .15s; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--panel); color: var(--ink); font-weight: 500; box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 0 0 1px rgba(0,0,0,.03); }
.seg.sm button { height: 24px; font-size: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chips button { border: 1px solid var(--line-2); background: var(--panel); border-radius: 10px; height: 30px; padding: 0 10px; font: 12px/1 var(--mono); cursor: pointer; color: var(--ink-2); flex: 1 0 auto; }
.chips button.on { border-color: var(--ink); color: var(--ink); box-shadow: inset 0 0 0 .5px var(--ink); }

/* brand */
.brand-row { display: flex; gap: 6px; margin-bottom: 10px; }
.select { flex: 1; min-width: 0; height: 32px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel); padding: 0 10px; font: inherit; appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%239a9f9c' stroke-width='1.4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 10px; cursor: pointer; }
.btn.sm { height: 32px; padding: 0 12px; border-radius: 10px; }

.palette { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; margin-bottom: 8px; }
.swatch { aspect-ratio: 1; border-radius: 10px; border: 1px solid rgba(0,0,0,.06); cursor: pointer; position: relative; transition: transform .1s; }
.swatch:hover { transform: translateY(-1px); }
.swatch.add { display: grid; place-items: center; color: var(--mute); font-size: 18px; background: repeating-conic-gradient(#f2f3f2 0 25%, #fff 0 50%) 0 0/10px 10px; }
.swatch.add input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* stops */
.stop { border: 1px solid var(--line); border-radius: 12px; padding: 9px 10px 6px; margin-bottom: 8px; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.stop:hover { border-color: #d8dbd9; }
.stop.sel { border-color: var(--ink); box-shadow: inset 0 0 0 .5px var(--ink); }
.stop-top { display: flex; align-items: center; gap: 10px; }
.stop .sw { position: relative; width: 26px; height: 26px; border-radius: 7px; border: 1px solid rgba(0,0,0,.08); flex: none; overflow: hidden; }
.stop .sw input { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); opacity: 0; cursor: pointer; }
.stop .hex { flex: 1; min-width: 0; border: 0; background: transparent; font: 12.5px/1 var(--mono); color: var(--ink-2); padding: 4px 0; outline: none; text-transform: uppercase; }
.stop .hex:focus { color: var(--ink); }
.stop .pct { font: 11px/1 var(--mono); color: var(--mute); }
.stop .x, .fx-head .x { border: 0; background: none; color: var(--mute); cursor: pointer; font-size: 15px; line-height: 1; padding: 2px 4px; border-radius: 6px; }
.stop .x:hover, .fx-head .x:hover { color: var(--ink); background: var(--chip); }
.stop input[type=range] { margin-top: 4px; }
.stop .xy { font: 11px/1 var(--mono); color: var(--mute); }
.stop-tools { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.pill-add { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; height: 30px; padding: 0 14px; font: 11px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); cursor: pointer; }
.pill-add:hover { border-color: #cfd3d1; color: var(--ink); }

.toggle-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.num { width: 100%; height: 32px; border-radius: 10px; border: 1px solid var(--line-2); padding: 0 10px; font: 12px var(--mono); }
.wh { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; margin-bottom: 12px; color: var(--mute); }
.out-info { font: 11px/1.5 var(--mono); color: var(--ink-2); background: var(--chip); padding: 9px 11px; border-radius: 10px; margin-top: 2px; }


/* modal + toast */
.modal { position: fixed; inset: 0; background: rgba(20,22,21,.35); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 10; }
.modal[hidden] { display: none; }
.modal-card { width: min(440px, calc(100vw - 32px)); background: var(--panel); border-radius: 18px; padding: 22px; box-shadow: 0 24px 80px rgba(0,0,0,.25); }
.modal-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; }
.bar { height: 6px; background: var(--chip); border-radius: 6px; overflow: hidden; }
.bar div { height: 100%; width: 0; background: var(--ink); border-radius: 6px; transition: width .2s; }
.modal-sub { font: 11.5px/1.5 var(--mono); color: var(--ink-2); margin-top: 12px; white-space: pre-wrap; word-break: break-all; max-height: 200px; overflow: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.toast { position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 9px 14px; border-radius: 999px; font-size: 12.5px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 20; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- responsive ---- */
.topbar, .actions { min-width: 0; }
.transport { min-width: 0; }
@media (max-width: 1280px) {
  .app { grid-template-columns: minmax(0, 1fr) 300px; }
  .btn.ghost .lbl { display: none; }
  .btn.ghost { padding: 0 10px; }
}
@media (max-width: 1080px) {
  .crumb { margin-bottom: 4px; }
  .main { padding: 14px 16px 12px; gap: 10px; }
}
@media (max-height: 760px) {
  .main { padding-top: 10px; padding-bottom: 10px; gap: 8px; }
  .crumb { margin-bottom: 4px; }
  h1 { font-size: 16px; }
  .btn { height: 30px; }
  .play { width: 30px; height: 30px; }
}
/* Tablet / phone: canvas area on top, controls scroll below */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto auto; height: auto; overflow: visible; }
  .main { height: auto; overflow: visible; grid-template-rows: auto auto; }
  .side { border-left: 0; border-top: 1px solid var(--line); overflow: visible; padding: 16px; }
}
@media (max-width: 560px) {
  .main { padding: 10px 12px; }
  h1 { font-size: 15px; }
  .actions { gap: 4px; }
  .btn { padding: 0 10px; }
  .btn .dim { display: none; }
  .time { min-width: 0; font-size: 10px; }
  .frame { border-radius: 12px; }
  .badge { top: 8px; font-size: 9px; padding: 5px 7px; }
  .badge.tl { left: 8px; } .badge.tr { right: 8px; }
}

/* FX stack */
.fx { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; background: var(--panel); }
.fx.off .fx-name, .fx.off .fx-body { opacity: .45; }
.fx-head { display: flex; align-items: center; gap: 2px; padding: 6px 6px 6px 6px; }
.fx-name { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; border: 0; background: none; cursor: pointer; font-weight: 500; font-size: 13px; text-align: left; padding: 4px 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chev { display: inline-block; color: var(--mute); transition: transform .15s; width: 8px; }
.chev.open { transform: rotate(90deg); }
.icon-btn { width: 24px; height: 24px; border: 0; background: none; border-radius: 6px; color: var(--mute); cursor: pointer; display: grid; place-items: center; padding: 0; flex: none; }
.icon-btn:hover { background: var(--chip); color: var(--ink); }
.icon-btn svg { width: 14px; height: 14px; }
.fx-head .x { flex: none; }
.fx-body { padding: 4px 12px 2px; border-top: 1px solid var(--line); padding-top: 12px; }
.fx-colors { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.fx-color { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-2); }
.fx-color .sw { position: relative; width: 24px; height: 24px; border-radius: 7px; border: 1px solid rgba(0,0,0,.08); overflow: hidden; display: block; }
.fx-color .sw input { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); opacity: 0; cursor: pointer; }
.fx-add { width: 100%; margin-top: 2px; color: var(--ink-2); }

/* Looks */
.looks { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 10px; max-height: 340px; overflow-y: auto; }
.look { position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; cursor: pointer; background: var(--panel); transition: border-color .15s, transform .1s; }
.look:hover { border-color: #cfd3d1; }
.look:active { transform: scale(.98); }
.look.on { border-color: var(--ink); box-shadow: inset 0 0 0 .5px var(--ink); }
.look-img { aspect-ratio: 16 / 9; background-size: cover; background-position: center; }
.look-name { font-size: 12px; padding: 6px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.look-x { position: absolute; top: 5px; right: 5px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0,0,0,.45); color: #fff; font-size: 14px; line-height: 1; cursor: pointer; opacity: 0; transition: opacity .15s; }
.look:hover .look-x { opacity: 1; }
.look-row .btn { flex: 1; justify-content: center; }

/* Output bar above the canvas */
.outbar { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; min-width: 0; }
.outbar::-webkit-scrollbar { display: none; }
.ob-group, .ob-info { flex: none; }
.ob-group { display: flex; align-items: center; gap: 8px; }
.ob-label { font: 10px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--mute); }
.outbar .seg { margin: 0; background: #e9ebea; }
.outbar .seg button { flex: none; padding: 0 10px; font-family: var(--mono); font-size: 11.5px; }
.ob-wh { display: flex; align-items: center; gap: 6px; color: var(--mute); }
.ob-num { width: 82px; height: 30px; }
.ob-info { font: 11px/1 var(--mono); color: var(--ink-2); margin-left: auto; white-space: nowrap; }

/* Image layers */
.layer .fx-name { gap: 8px; }
.layer-thumb { width: 26px; height: 26px; border-radius: 6px; object-fit: cover; background: repeating-conic-gradient(#eceeed 0 25%, #fff 0 50%) 0 0/8px 8px; border: 1px solid rgba(0,0,0,.08); flex: none; }
.layer-thumb.missing { background: #fbe3e3; }
.layer-label { overflow: hidden; text-overflow: ellipsis; }
.handle.img { width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 5px; background: rgba(255,255,255,.3); backdrop-filter: blur(4px); }
.handle.img::after { content: ""; position: absolute; inset: 4px; border-radius: 2px; background: #fff; }
.stage.drop .frame { outline: 2px dashed var(--ink); outline-offset: 6px; }

/* Tablet / phone: the output bar flows into wrapped rows (flexbox) instead of scrolling */
@media (max-width: 860px) {
  .outbar { flex-wrap: wrap; overflow: visible; gap: 10px 14px; align-items: flex-end; }
  .ob-group { flex: 1 1 auto; flex-direction: column; align-items: stretch; gap: 6px; min-width: 0; }
  .ob-group:first-child { flex-basis: 340px; }
  .ob-group:nth-child(2) { flex-basis: 180px; }
  .ob-group:nth-child(3) { flex-basis: 200px; }
  .ob-label { text-align: left; }
  .outbar .seg { display: flex; width: 100%; }
  .outbar .seg button { flex: 1 1 0; min-width: 0; padding: 0 2px; height: 30px; }
  .ob-wh { width: 100%; }
  .ob-wh .ob-num { flex: 1 1 0; width: auto; min-width: 0; }
  .ob-info { flex: 1 1 100%; margin-left: 0; white-space: normal; line-height: 1.4; }
}

/* ---- feedback on press (instant, on pointer-down) ---- */
.seg button, .play, .icon-btn, .swatch, .pill-add, .link, .look-x, .stop .x, .fx-head .x { transition: transform 100ms ease-out, background .15s, color .15s; }
.seg button:active, .play:active, .icon-btn:active, .pill-add:active, .stop .x:active, .fx-head .x:active { transform: scale(.94); }
.swatch:active { transform: scale(.94); }
.play:hover { border-color: #cfd3d1; }
.handle.settle { transition: left 280ms cubic-bezier(.2,.9,.3,1), top 280ms cubic-bezier(.2,.9,.3,1); }

/* ---- keyboard focus ---- */
:where(button, select, input:not([type=range]), [role=button], .look):focus { outline: none; }
:where(button, select, input:not([type=range]), [role=button], .look):focus-visible { outline: 2px solid #2f6feb; outline-offset: 2px; }
input[type=range]:focus { outline: none; }
input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(47,111,235,.35); }
input[type=range]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 4px rgba(47,111,235,.35); }
.stop .sw:focus-within, .fx-color .sw:focus-within, .swatch.add:focus-within { outline: 2px solid #2f6feb; outline-offset: 2px; }

/* ---- respect system settings ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; }
  .btn:active, .seg button:active, .play:active, .icon-btn:active, .swatch:active, .look:active, .pill-add:active { transform: none; }
  .handle:hover, .handle.sel, .swatch:hover { transform: none; }
  .toast { transform: translate(-50%, 0); }
}
@media (prefers-reduced-transparency: reduce) {
  .badge { background: #2a2d2c; backdrop-filter: none; -webkit-backdrop-filter: none; }
  .modal { background: rgba(20,22,21,.6); backdrop-filter: none; }
  .handle.center, .handle.img { background: #fff; backdrop-filter: none; }
}
@media (prefers-contrast: more) {
  :root { --mute: #4c514e; --ink-2: #222524; --line: #b9bdbb; --line-2: #a7aca9; }
  .seg, .outbar .seg { background: #dfe2e0; }
  .badge { background: #111312; color: #fff; }
}

/* Looks dropdown */
.look-thumb { width: 54px; height: 32px; flex: none; border-radius: 8px; background-size: cover; background-position: center; border: 1px solid rgba(0,0,0,.08); }
.look-thumb.empty { background: repeating-conic-gradient(#eceeed 0 25%, #fff 0 50%) 0 0/8px 8px; }
.sec-title { gap: 14px; }
.sec-title > span { flex: none; }
.sec-title .links { gap: 6px 10px; flex-wrap: wrap; justify-content: flex-end; }
.look-actions { display: flex; gap: 14px; margin: 2px 0 12px; }

/* Looks picker with previews */
.lp { position: relative; flex: 1; min-width: 0; }
.lp-btn { width: 100%; height: 40px; display: flex; align-items: center; gap: 10px; padding: 0 10px 0 5px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel); cursor: pointer; text-align: left; }
.lp-btn:hover, .lp.open .lp-btn { border-color: #cfd3d1; }
.lp-thumb { width: 52px; height: 29px; flex: none; border-radius: 6px; background-size: cover; background-position: center; border: 1px solid rgba(0,0,0,.08); }
.lp-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.lp-chev { color: var(--mute); font-size: 14px; line-height: 1; transform: translateY(-3px); }
.lp-list { position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 6; background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: 0 2px 6px rgba(0,0,0,.06), 0 16px 40px rgba(0,0,0,.14); padding: 5px; max-height: min(380px, 60vh); overflow-y: auto; transform-origin: top center; animation: lp-in 140ms cubic-bezier(.2,.9,.3,1); }
@keyframes lp-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.lp-item { display: flex; align-items: center; gap: 10px; padding: 5px; border-radius: 8px; cursor: pointer; outline: none; }
.lp-item:hover, .lp-item:focus { background: var(--chip); }
.lp-item:focus-visible { box-shadow: inset 0 0 0 2px #2f6feb; }
.lp-item-thumb { width: 72px; height: 40px; flex: none; border-radius: 6px; background-size: cover; background-position: center; border: 1px solid rgba(0,0,0,.08); }
.lp-thumb.empty, .lp-item-thumb.empty { background: repeating-conic-gradient(#eceeed 0 25%, #fff 0 50%) 0 0/8px 8px; }
.lp-item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.lp-item-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lp-item-meta { font: 10.5px/1.2 var(--mono); color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lp-item[aria-selected="true"] .lp-item-name { font-weight: 600; }
.lp-check { width: 14px; flex: none; color: var(--ink); font-size: 12px; }

/* Export split buttons + format menus */
.split { position: relative; display: inline-flex; }
.split .split-main { border-top-right-radius: 0; border-bottom-right-radius: 0; padding-right: 12px; }
.split .split-caret { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left-width: 0; padding: 0 9px; box-shadow: inset 1px 0 0 var(--line-2); }
.split.primary .split-caret { box-shadow: inset 1px 0 0 rgba(255,255,255,.22); }
.split .split-caret svg { width: 10px; height: 10px; }
.menu { position: absolute; top: calc(100% + 6px); right: 0; z-index: 8; min-width: 250px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; padding: 5px; box-shadow: 0 2px 6px rgba(0,0,0,.06), 0 16px 40px rgba(0,0,0,.16); transform-origin: top right; animation: lp-in 140ms cubic-bezier(.2,.9,.3,1); }
.menu-item { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; text-align: left; padding: 8px 10px 8px 6px; border-radius: 8px; cursor: pointer; color: var(--ink); }
.menu-item:hover, .menu-item:focus { background: var(--chip); outline: none; }
.menu-item:focus-visible { box-shadow: inset 0 0 0 2px #2f6feb; }
.menu-check { width: 14px; flex: none; font-size: 12px; text-align: center; }
.menu-text { display: flex; flex-direction: column; gap: 2px; }
.menu-name { font-weight: 600; font-size: 13px; }
.menu-desc { font-size: 11.5px; color: var(--mute); }
@media (max-width: 560px) {
  .split .split-main { padding: 0 8px 0 10px; }
  .menu { right: auto; left: 0; }
  #vidSplit .menu { left: auto; right: 0; }
}

/* Generate menu + stop locks */
.split.ghost .split-main, .split.ghost .split-caret { background: transparent; border-color: transparent; }
.split.ghost .split-caret { box-shadow: none; padding: 0 8px; }
.split.ghost:hover .split-main, .split.ghost:hover .split-caret { background: #e9ebea; }
.split.ghost:hover .split-caret { box-shadow: inset 1px 0 0 #d9dcdb; }
.gen-menu { min-width: 230px; max-height: min(520px, 80vh); overflow-y: auto; }
.menu-item kbd { margin-left: auto; font: 10.5px/1 var(--mono); color: var(--mute); border: 1px solid var(--line-2); border-radius: 5px; padding: 3px 6px; }
.menu-item.compact { padding-top: 6px; padding-bottom: 6px; }
.menu-item.compact .menu-name { font-weight: 400; }
.menu-item:disabled { opacity: .45; cursor: default; background: none; }
.menu-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.menu-label { font: 10px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--mute); padding: 8px 10px 4px 28px; }
.menu-foot { font-size: 11px; color: var(--mute); padding: 8px 10px 6px 28px; border-top: 1px solid var(--line); margin-top: 5px; }
.stop .lock { border: 0; background: none; color: #b7bcb9; cursor: pointer; padding: 3px; border-radius: 6px; display: grid; place-items: center; transition: transform 100ms ease-out, color .15s, background .15s; }
.stop .lock svg { width: 14px; height: 14px; }
.stop .lock:hover { color: var(--ink); background: var(--chip); }
.stop .lock:active { transform: scale(.9); }
.stop .lock.on { color: var(--ink); }
.stop.locked { background: #fafbfa; }

.lp-group { font: 10px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--mute); padding: 10px 8px 6px; position: sticky; top: -5px; background: var(--panel); z-index: 1; }
.lp-group + .lp-item { margin-top: 0; }
.look-note { font-size: 11px; color: var(--mute); }

.outbar .seg button { padding: 0 8px; }

/* ---- top bar: title + file info | specs | exports ---- */
.topbar { align-items: flex-end; gap: 12px 24px; }
.title { min-width: 0; }
.spec-info { font: 11px/1.3 var(--mono); color: var(--ink-2); margin-top: 6px; white-space: nowrap; }
.actions { align-items: flex-end; justify-content: flex-end; gap: 10px; }
.specs { gap: 8px 12px; flex-wrap: wrap; margin-right: 4px; }
.specs .ob-group { flex-direction: column; align-items: flex-start; gap: 5px; }
.specs .ob-label { font-size: 9.5px; padding-left: 2px; }
.specs .seg { margin: 0; }
.specs .seg button { height: 26px; padding: 0 7px; font-size: 11px; }
.actions > .split .btn { height: 32px; }
/* Generate in the Controls header */
.side-head { align-items: center; }
.side-head .split.gen .btn { height: 30px; font-size: 12.5px; }
.side-head .split.gen .split-main { padding: 0 10px 0 9px; gap: 6px; }
.side-head .split.gen .split-caret { padding: 0 8px; }
.side-head .gen-menu { right: 0; }
@media (max-width: 860px) {
  .topbar { align-items: stretch; }
  .actions { width: 100%; justify-content: flex-start; }
  .specs { flex: 1 1 100%; margin-right: 0; }
  .specs .ob-group { flex: 1 1 auto; align-items: stretch; }
  .specs .seg button { height: 30px; }
  .spec-info { white-space: normal; }
}
.topbar { gap: 12px 18px; }
.actions { gap: 8px; }
.specs .seg button { padding: 0 5px; }
@media (max-width: 1600px) {
  .actions .split-main .dim { display: none; }
  .actions .split .split-main { padding: 0 10px 0 11px; }
}

/* ---- Generate: grayscale gradient call-to-action ---- */
.gen-sec { padding: 14px 0 14px; }
#genSplit.split.gen { display: flex; width: 100%; position: relative; border-radius: 12px;
  /* one continuous gradient across the whole control, black to silver */
  background: linear-gradient(110deg, #b4b9b7 0%, #cdd1cf 30%, #e4e7e5 58%, #f5f6f5 82%, #ffffff 100%);
  background-size: 115% 100%; background-position: 0% 50%;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08), inset 0 1px 0 rgba(255,255,255,.9), 0 1px 2px rgba(0,0,0,.08), 0 6px 16px -6px rgba(0,0,0,.18);
  transition: background-position 700ms cubic-bezier(.2,.9,.3,1), box-shadow .2s; }
#genSplit.split.gen:hover { background-position: 100% 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12), inset 0 1px 0 rgba(255,255,255,.9), 0 1px 2px rgba(0,0,0,.1), 0 10px 22px -6px rgba(0,0,0,.24); }
#genSplit.split.gen .btn { height: 44px; border: 0; background: transparent; font-size: 13.5px; font-weight: 600; letter-spacing: .01em;
  transition: transform 100ms ease-out, filter .2s; }
#genSplit.split.gen .btn:hover { border: 0; background: transparent; }
#genSplit.split.gen .split-main { flex: 1; justify-content: center; gap: 8px; padding: 0 14px; color: var(--ink);
  text-shadow: 0 1px 0 rgba(255,255,255,.6); border-radius: 12px 0 0 12px; position: relative; overflow: hidden; }
#genSplit.split.gen .split-caret { width: 46px; flex: none; justify-content: center; padding: 0; color: #121413;
  border-radius: 0 12px 12px 0; box-shadow: inset 1px 0 0 rgba(0,0,0,.1); }
#genSplit.split.gen .split-main svg { width: 15px; height: 15px; }
#genSplit.split.gen .split-caret svg { width: 11px; height: 11px; }
/* a soft highlight glides across on hover */
#genSplit.split.gen .split-main::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 32%, rgba(255,255,255,.75) 50%, transparent 68%);
  transform: translateX(-120%); transition: transform 800ms cubic-bezier(.2,.9,.3,1); }
#genSplit.split.gen:hover .split-main::after { transform: translateX(130%); }
#genSplit.split.gen .btn:active { transform: scale(.97); filter: brightness(.96); }
#genSplit.split.gen .btn:focus-visible { outline: 2px solid #2f6feb; outline-offset: 2px; }
#genSplit .gen-menu { top: calc(100% + 8px); left: 0; right: 0; min-width: 0; }
@media (prefers-reduced-motion: reduce) {
  #genSplit.split.gen .split-main::after { display: none; }
}
@media (prefers-contrast: more) {
  #genSplit.split.gen { background: #fff; box-shadow: inset 0 0 0 1.5px #111312; }
  #genSplit.split.gen .split-caret { box-shadow: inset 1.5px 0 0 #111312; }
}

/* ---- Grouped panel: grayscale levels + strokes ----
   panel (darkest) > group box > header strip > white controls */
.side { background: #e8eae9; padding: 14px 14px 40px; }
.side-head { border-bottom: 0; padding: 2px 4px 12px; margin-bottom: 0; align-items: center; }
.grp { background: #f7f8f7; border: 1px solid #cdd1cf; border-radius: 14px; margin-bottom: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.grp-head { width: 100%; display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 40px;
  background: #eef0ef; border: 0; border-bottom: 1px solid #d8dcda; border-radius: 13px 13px 0 0;
  cursor: pointer; text-align: left; color: var(--ink); transition: background .15s; }
.grp-head:hover { background: #e7e9e8; }
.grp.collapsed .grp-head { border-bottom: 0; border-radius: 13px; }
.grp-title { font-size: 13px; font-weight: 600; letter-spacing: -.005em; }
.grp-meta { margin-left: auto; font: 10.5px/1 var(--mono); color: var(--mute); max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grp-chev { display: inline-block; width: 10px; color: var(--mute); font-size: 15px; line-height: 1; transform: rotate(90deg); transition: transform .18s ease; }
.grp.collapsed .grp-chev { transform: rotate(0deg); }
.grp-body { padding: 2px 12px 8px; }
.grp-body > .sec { padding: 12px 0 6px; }
.grp-body > .sec + .sec { border-top: 1px solid #e0e3e1; }
.grp-body > .sec:first-child > .sec-title:first-child { margin-top: 2px; }
.grp-body > .gen-sec { padding: 10px 0 8px; }
/* controls sit on white so they read clearly against the gray boxes */
.grp .seg { background: #e7e9e8; }
.grp .seg button.on { background: #fff; }
.grp .stop, .grp .fx { background: #fff; border-color: #dfe2e0; }
.grp .stop.locked { background: #fbfbfb; }
.grp .chips button, .grp .select, .grp .num, .grp .lp-btn, .grp .pill-add { background: #fff; }
.grp input[type=range]::-webkit-slider-runnable-track { background: #dadedc; }
.grp input[type=range]::-moz-range-track { background: #dadedc; }
@media (max-width: 860px) {
  .side { padding: 14px 12px 40px; }
}
@media (prefers-contrast: more) {
  .grp { border-color: #8f9592; }
  .grp-head { border-bottom-color: #a7aca9; }
}

/* ---- Action buttons (were title-styled text links) ---- */
.link { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border: 1px solid #cfd3d1; border-radius: 7px;
  background: #fff; color: var(--ink); font: 500 11.5px/1 var(--sans); letter-spacing: 0; text-transform: none; text-decoration: none;
  cursor: pointer; white-space: nowrap; box-shadow: 0 1px 1px rgba(0,0,0,.04);
  transition: background .15s, border-color .15s, color .15s, transform 100ms ease-out; }
.link:hover { background: #f1f3f2; border-color: #b9bebc; text-decoration: none; color: var(--ink); }
.link:active { transform: scale(.95); }
.link.danger:hover { color: #b42318; border-color: #f0b4ae; background: #fff5f4; }
.sec-title .links { gap: 6px; }
.look-actions { gap: 6px; align-items: center; margin: 4px 0 12px; }
.side-head .link { height: 26px; }
@media (prefers-reduced-motion: reduce) { .link:active { transform: none; } }

/* ---- Apple-design pass: wayfinding, consistency, feedback ---- */
/* Panel header and group titles stay visible while scrolling (translucent material) */
.side-head { position: sticky; top: -14px; z-index: 5; margin: -14px -14px 0; padding: 14px 18px 12px;
  background: rgba(232,234,233,.82); backdrop-filter: blur(14px) saturate(160%); -webkit-backdrop-filter: blur(14px) saturate(160%); }
.grp-head { position: sticky; top: 38px; z-index: 4; }
.grp:not(.collapsed) .grp-head { box-shadow: 0 1px 0 #d8dcda; border-bottom-color: transparent; }
.grp-head:active { background: #e2e5e4; }
.grp-head:active .grp-chev { transform: rotate(90deg) scale(.9); }
.grp.collapsed .grp-head:active .grp-chev { transform: scale(.9); }
/* One style for every "add" action */
.add-btn { display: flex; align-items: center; justify-content: center; width: 100%; height: 34px; margin-top: 4px;
  border: 1px dashed #b9bebc; border-radius: 10px; background: rgba(255,255,255,.6); color: var(--ink-2);
  font: 500 12.5px/1 var(--sans); letter-spacing: 0; text-transform: none; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform 100ms ease-out; }
.add-btn:hover { background: #fff; border-color: #8f9592; color: var(--ink); }
.add-btn:active { transform: scale(.98); }
select.add-btn { text-align: center; text-align-last: center; padding: 0 28px; background-color: rgba(255,255,255,.6); }
.stop-tools { display: block; }
.sub.first { margin-top: 2px; }
.sec-title.links-only { justify-content: flex-end; }
/* slightly larger click targets for small action buttons */
.link { height: 26px; padding: 0 10px; }
@media (prefers-reduced-transparency: reduce) {
  .side-head { background: #e8eae9; backdrop-filter: none; -webkit-backdrop-filter: none; }
}
@media (prefers-reduced-motion: reduce) {
  .add-btn:active, .grp-head:active .grp-chev { transform: none; }
}
@media (max-width: 860px) {
  .side-head { position: static; margin: 0; padding: 2px 4px 12px; background: none; backdrop-filter: none; }
  .grp-head { top: 0; }
}

/* =================================================================
   UI/UX audit pass (apple.com conventions)
   - one typeface: system font everywhere; numbers use tabular figures
   - small labels: sentence case, semibold, secondary gray (no mono caps)
   - neutral, slightly cool grays; size-specific tracking
   ================================================================= */
:root {
  --bg: #f5f5f7; --panel: #ffffff; --ink: #1d1d1f; --ink-2: #424245; --mute: #6e6e73;
  --line: #e5e5ea; --line-2: #d2d2d7; --chip: #ececf0;
}
html, body { font-feature-settings: "kern"; letter-spacing: -0.008em; }
h1 { letter-spacing: -0.022em; font-size: 20px; }
.side-head h2 { letter-spacing: -0.018em; }

/* Labels: sentence case, semibold, gray */
.crumb { font: 600 11px/1 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--mute); margin-bottom: 5px; }
.sec-title, .sub, .ob-label, .lp-group, .menu-label {
  font: 600 12px/1.2 var(--sans) !important; letter-spacing: -0.005em !important; text-transform: none !important; color: var(--mute) !important; }
.specs .ob-label { font-size: 11px !important; }
.sub { margin: 14px 0 8px; }
.sec-title { margin-bottom: 10px; }

/* Values and data: same typeface, evenly spaced numbers */
.ctl-top .val, .grp-meta, .spec-info, .time, .stop .pct, .stop .xy, .lp-item-meta, .menu-item kbd, .num, .modal-sub, .chip, .specs .seg button, .outbar .seg button {
  font-family: var(--sans) !important; font-variant-numeric: tabular-nums; letter-spacing: 0 !important; }
.ctl-top .val { font-size: 12.5px; color: var(--ink-2); }
.grp-meta, .lp-item-meta { font-size: 11.5px; }
.spec-info { font-size: 12px; color: var(--mute); margin-top: 4px; }
.time { font-size: 12px; }
.specs .seg button { font-size: 12px; font-weight: 500; }
.stop .hex { font-size: 12.5px; letter-spacing: .02em; } /* hex codes stay monospaced for legibility */

/* Neutral grays for the panel levels */
.side { background: #e8e8ed; }
.side-head { background: rgba(232,232,237,.82); }
.grp { background: #f9f9fb; border-color: #d2d2d7; }
.grp-head { background: #f1f1f5; border-bottom-color: #dcdce1; }
.grp:not(.collapsed) .grp-head { box-shadow: 0 1px 0 #dcdce1; }
.grp-head:hover { background: #ebebf0; }
.grp-body > .sec + .sec { border-top-color: #e3e3e8; }
.grp .seg { background: #e8e8ed; }
.link { border-color: #d2d2d7; }
.link:hover { background: #f2f2f6; border-color: #b8b8bf; }
.main { background: var(--bg); }

/* The canvas carries no overlays: its type and size are shown under the title */
.badge { display: none !important; }

/* Click-to-type values */
.ctl-top .val.editable { cursor: text; border-radius: 5px; padding: 1px 4px; margin-right: -4px; transition: background .15s; }
.ctl-top .val.editable:hover { background: #e8e8ed; }
.val-input { width: 74px; height: 22px; margin: -2px -4px -2px 0; border: 1px solid #2f6feb; border-radius: 6px; padding: 0 6px;
  font: 12.5px var(--sans); font-variant-numeric: tabular-nums; text-align: right; background: #fff; outline: 3px solid rgba(47,111,235,.18); }

/* Sheets (in-app dialogs) */
.sheet-back { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px;
  background: rgba(29,29,31,.32); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: sheet-fade .16s ease-out; }
.sheet { width: min(380px, 100%); background: #fff; border-radius: 16px; padding: 22px 22px 18px;
  box-shadow: 0 0 0 1px rgba(0,0,0,.06), 0 24px 70px rgba(0,0,0,.28); animation: sheet-in .2s cubic-bezier(.2,.9,.3,1); }
.sheet-title { margin: 0 0 6px; font-size: 16px; font-weight: 600; letter-spacing: -0.015em; }
.sheet-msg { margin: 0 0 14px; font-size: 13px; color: var(--ink-2); line-height: 1.45; }
.sheet-input { width: 100%; height: 36px; margin: 8px 0 16px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 10px;
  font: 14px var(--sans); color: var(--ink); background: #fff; }
.sheet-input:focus { outline: 3px solid rgba(47,111,235,.25); border-color: #2f6feb; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.sheet-btn { height: 34px; padding: 0 16px; border-radius: 999px; font-size: 13px; }
.btn.danger { background: #d92d20; border-color: #d92d20; color: #fff; }
.btn.danger:hover { background: #b42318; }
.sheet.shake { animation: sheet-shake .3s; }
@keyframes sheet-fade { from { opacity: 0; } }
@keyframes sheet-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes sheet-shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.kb-list { display: grid; gap: 2px; margin: 8px 0 14px; }
.kb-row { display: flex; align-items: center; gap: 12px; padding: 6px 0; border-bottom: 1px solid #f0f0f3; font-size: 13px; }
.kb-row:last-child { border-bottom: 0; }
.kb-row kbd { min-width: 132px; font: 500 12px var(--sans); color: var(--ink); }
.side-head-actions { display: flex; gap: 6px; }
.kb-btn { width: 26px; justify-content: center; padding: 0; font-weight: 600; }
@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet-back, .sheet.shake { animation: none; }
}

/* Phone: Aspect gets a full row; Resolution and Frame rate share the next */
@media (max-width: 560px) {
  .specs .ob-group:first-child { flex: 1 1 100%; }
  .specs .ob-group:nth-child(2), .specs .ob-group:nth-child(3) { flex: 1 1 0; min-width: 0; }
  .specs .seg button { flex: 1 1 auto; padding: 0 4px; }
}

/* Specs: buttons on desktop, native dropdowns on phones and tablets */
.ob-select { display: none; }
@media (max-width: 860px) {
  .specs .ob-seg { display: none !important; }
  .specs .ob-select { display: block; width: 100%; height: 36px; font-size: 13.5px; font-variant-numeric: tabular-nums; background-color: #fff; padding-right: 26px; }
  .specs { gap: 10px; flex-wrap: nowrap; }
  .specs .ob-group, .specs .ob-group:first-child, .specs .ob-group:nth-child(2), .specs .ob-group:nth-child(3) { flex: 1 1 0; min-width: 0; }
  .specs .ob-group.ob-size { flex: 2 1 0; }
  .specs .ob-wh { gap: 4px; }
  .specs .ob-wh .ob-num { height: 36px; padding: 0 6px; font-size: 13px; }
}
@media (max-width: 860px) {
  .specs .ob-select { flex: none; padding: 0 22px 0 10px; background-position: right 8px center; }
  .specs .ob-wh .ob-num { flex: 1 1 0; }
}

/* Phones and tablets: title left + export buttons right, specs on the row below */
@media (max-width: 860px) {
  .topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; column-gap: 8px; row-gap: 12px; align-items: center; }
  .topbar .actions { display: contents; }
  .topbar .title { grid-column: 1; grid-row: 1; }
  #imgSplit { grid-column: 2; grid-row: 1; }
  #vidSplit { grid-column: 3; grid-row: 1; }
  .topbar .specs { grid-column: 1 / -1; grid-row: 2; }
  .topbar #helper { grid-column: 1 / -1; grid-row: 3; justify-self: start; }
  .menu, #vidSplit .menu { left: auto; right: 0; }
}
@media (max-width: 560px) {
  .actions > .split .btn { height: 34px; }
  .actions .split .split-main { padding: 0 8px 0 9px; gap: 5px; }
  .actions .split .split-caret { padding: 0 7px; }
  h1 { font-size: 17px; }
}

/* Phones and tablets: the preview, play button and timeline stay pinned while the controls scroll */
@media (max-width: 860px) {
  .app { grid-template-rows: none; }
  .main { display: contents; }
  .topbar { padding: 14px 16px 2px; }
  .stage { position: sticky; top: 0; z-index: 20; margin: 10px 16px 12px; overflow: visible; }
  .stage::before { content: ""; position: absolute; inset: -10px -16px -12px; z-index: -1; background: var(--bg);
    box-shadow: 0 10px 16px -12px rgba(0,0,0,.28); }
  .side { position: relative; z-index: 1; }
  .grp-head { top: var(--stage-stick, 0px); z-index: 4; }
}
@media (max-width: 560px) {
  .topbar { padding: 10px 12px 2px; }
  .stage { margin: 8px 12px 12px; }
  .stage::before { inset: -8px -12px -12px; }
}

@media (max-width: 860px) {
  .stage { top: 8px; }
  .stage::before { top: -18px; } /* fill the 8px above the pinned preview too */
}
@media (max-width: 860px) {
  .stage::before { top: -8px; } /* covers the 8px gap when pinned, without overlapping the dropdowns above */
}

/* Export menus open above the pinned preview on phones/tablets */
@media (max-width: 860px) {
  .topbar { position: relative; z-index: 2; }
  body.menu-open .topbar { z-index: 30; }
}
