/**
 * Photo Montage — Beat Editor mobile shell (stage, chips, transport, dock, sheets).
 */
html.pm-beatshell, html.pm-beatshell body {
  margin: 0;
  padding: 0;
  background: #000;
  color: #eef2f8;
  font-family: 'Inter', 'Plus Jakarta Sans', system-ui, sans-serif;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  height: 100dvh;
}

.pm-app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #000;
  overflow: hidden;
}

.pm-app .hdr {
  flex-shrink: 0;
  z-index: 10;
  padding: calc(env(safe-area-inset-top, 0) + 12px) 14px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #000;
}

.pm-app .hdr-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .06);
  border: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #eef2f8;
  cursor: pointer;
  flex-shrink: 0;
  text-decoration: none;
}

.pm-app .hdr-export {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 15px;
  border-radius: 99px;
  background: linear-gradient(135deg, #3d8ef0, #6b5cff);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  border: 0;
  box-shadow: 0 10px 26px rgba(61, 142, 240, .35);
  cursor: pointer;
}

.pm-app .hdr-export[disabled] {
  opacity: .4;
  box-shadow: none;
  cursor: not-allowed;
}

.pm-app .editor-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-bottom: calc(env(safe-area-inset-bottom, 0) + 92px);
}

.pm-app .stage-wrap {
  flex-shrink: 0;
  padding: 10px 0 0;
}

/* Preview — 9:16 iPhone-style vertical frame */
.pm-app .stage {
  position: relative;
  margin: 0 auto;
  width: min(74vw, 250px, calc(48dvh * 9 / 16));
  aspect-ratio: 9 / 16;
  max-height: min(48dvh, 420px);
  overflow: hidden;
  background: #000;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, .1);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .45);
}

.pm-app .stage-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

.pm-app .stage-empty {
  position: absolute;
  inset: 6px;
  border-radius: 10px;
  border: 1.5px dashed rgba(255, 255, 255, .16);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  padding: 10px;
  background: linear-gradient(180deg, rgba(90, 160, 255, .05), rgba(90, 160, 255, 0));
  pointer-events: none;
  z-index: 2;
}

.pm-app .stage-empty[hidden] { display: none !important; }

.pm-app .stage-empty-icon {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: rgba(61, 142, 240, .14);
  color: #3d8ef0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pm-app .stage-empty-h {
  font-size: 12px;
  font-weight: 800;
  color: #eef2f8;
}

.pm-app .stage-empty-h em {
  font-style: normal;
  color: #5AA0FF;
  font-family: 'Instrument Serif', Georgia, serif;
  font-weight: 400;
}

.pm-app .stage-empty-steps {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  max-width: 220px;
}

.pm-app .stage-empty-step {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .03);
  border: 1px solid rgba(255, 255, 255, .05);
}

.pm-app .stage-empty-step .num {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: linear-gradient(135deg, #3A6BFF, #5AA0FF);
  color: #04122a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  font-weight: 800;
}

.pm-app .stage-empty-step .txt {
  flex: 1;
  font-size: 10px;
  color: #c3cad8;
  font-weight: 600;
  text-align: left;
}

.pm-app .stage-empty-step .txt b { font-weight: 800; color: #eef2f8; }

.pm-app .stage-empty-step .ck {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  color: #3fcb7e;
  opacity: 0;
}

.pm-app .stage-empty-step.done { opacity: .55; }
.pm-app .stage-empty-step.done .num {
  background: rgba(63, 203, 126, .18);
  color: #3fcb7e;
}
.pm-app .stage-empty-step.done .ck { opacity: 1; }

.pm-app .add-row {
  display: flex;
  gap: 10px;
  margin: 10px 14px 0;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.pm-app .add-chip {
  position: relative;
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .1);
  color: #c3cad8;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  min-width: 0;
}

.pm-app .add-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pm-app .add-chip.filled {
  background: rgba(63, 203, 126, .08);
  border-color: rgba(63, 203, 126, .35);
  color: #eef2f8;
}

.pm-app .add-chip.photos-chip { border-color: rgba(61, 142, 240, .28); }
.pm-app .add-chip.photos-chip.filled {
  background: rgba(61, 142, 240, .1);
  border-color: rgba(61, 142, 240, .42);
}

.pm-app .transport {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 6px 16px 4px;
  position: relative;
  flex-shrink: 0;
}

.pm-app .t-primary {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #3d8ef0, #6b5cff);
  color: #fff;
  box-shadow: 0 12px 28px rgba(61, 142, 240, .4);
  cursor: pointer;
}

.pm-app .t-primary[disabled] {
  background: rgba(255, 255, 255, .08);
  color: #6a748e;
  box-shadow: none;
  cursor: not-allowed;
}

.pm-app .pm-meta {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  font-weight: 600;
  color: #8b95a8;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.pm-app .tl-wrap {
  flex-shrink: 0;
  padding: 2px 0 4px;
}

.pm-app .tl-wrap .photos {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 14px 8px;
  -webkit-overflow-scrolling: touch;
  min-height: 76px;
}

.pm-app .tl-wrap .photos:empty::after {
  content: "Your photos show up here — add some above";
  color: #5c6780;
  font-size: 12px;
  align-self: center;
  padding: 0 14px;
}

.pm-app .photo {
  position: relative;
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
  border-radius: 10px;
  overflow: hidden;
  cursor: grab;
  background: #000;
  border: 1px solid rgba(255, 255, 255, .1);
}

.pm-app .photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.pm-app .photo .num {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(0, 0, 0, .75);
  color: #fff;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 999px;
}

.pm-app .photo .rm {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0, 0, 0, .75);
  color: #fff;
  border: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
}

.pm-app .pm-foot {
  padding: 0 14px 6px;
  text-align: center;
}

.pm-app .status {
  font-size: 11px;
  color: #8b95a8;
  min-height: 16px;
}

.pm-app .status.err { color: #ff8080; }
.pm-app .status.ok { color: #3fcb7e; }

.pm-app .progress {
  height: 3px;
  background: rgba(255, 255, 255, .06);
  border-radius: 4px;
  overflow: hidden;
  margin: 6px auto 0;
  max-width: 280px;
  display: none;
}

.pm-app .progress.show { display: block; }

.pm-app .progress > div {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #5AA0FF, #62D4FF);
  transition: width .2s;
}

/* Export overlay — Share / save to Photos (matches Beat Editor) */
.pm-export-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) 28px max(28px, env(safe-area-inset-bottom));
  background: rgba(4, 6, 12, .94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  text-align: center;
}

.pm-export-overlay.show { display: flex; }

.pm-export-busy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.pm-export-overlay.done .pm-export-busy { display: none; }

.pm-export-ring {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid rgba(90, 160, 255, .2);
  border-top-color: #5AA0FF;
  animation: pmExportSpin .8s linear infinite;
  margin-bottom: 10px;
}

@keyframes pmExportSpin { to { transform: rotate(360deg); } }

.pm-export-pct {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 42px;
  font-weight: 700;
  color: #eef2f8;
  letter-spacing: -.03em;
  line-height: 1;
}

.pm-export-pct b {
  font-size: 18px;
  font-weight: 600;
  color: #8791a4;
  margin-left: 2px;
}

.pm-export-h {
  margin-top: 12px;
  font-size: 18px;
  font-weight: 800;
  color: #eef2f8;
  letter-spacing: -.02em;
}

.pm-export-sub {
  margin-top: 4px;
  font-size: 13px;
  color: #8791a4;
}

.pm-export-done {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.pm-export-overlay.done .pm-export-done {
  display: flex;
}

.pm-dn-check {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(140deg, #3fcb7e, #2a9d63);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 30px rgba(63, 203, 126, .4);
}

.pm-dn-h {
  margin: 18px 0 4px;
  font-size: 21px;
  font-weight: 700;
  color: #eef2f8;
  letter-spacing: -.02em;
}

.pm-dn-sub {
  margin: 0;
  font-size: 13px;
  color: #c3cad8;
  line-height: 1.5;
  max-width: 280px;
}

.pm-dn-sub b { color: #5AA0FF; }

.pm-dn-meta {
  margin: 8px 0 0;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  color: #6a748e;
  letter-spacing: .02em;
}

.pm-dn-btns {
  display: flex;
  gap: 10px;
  margin-top: 22px;
  flex-wrap: wrap;
  justify-content: center;
}

.pm-dn-share {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 13px 20px;
  border-radius: 13px;
  background: linear-gradient(135deg, #3d8ef0, #6b5cff);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  border: 0;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(61, 142, 240, .4);
}

.pm-dn-done {
  padding: 13px 22px;
  border-radius: 13px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .12);
  color: #c3cad8;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  .pm-export-ring { animation: none; border-top-color: #5AA0FF; }
}

/* Bottom dock */
.pm-app .dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  gap: 2px;
  padding: 8px 6px calc(env(safe-area-inset-bottom, 0) + 8px);
  background: #06080f;
}

.pm-app .dk {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 4px 0 2px;
  background: none;
  border: 0;
  color: #eef2f8;
  cursor: pointer;
  font-size: 9.5px;
  font-weight: 800;
}

.pm-app .dk-box {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: #1a2233;
  border: 1.5px solid rgba(255, 255, 255, .22);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .5);
}

.pm-app .dk.active .dk-box {
  background: linear-gradient(135deg, #3d8ef0, #6b5cff);
  border-color: transparent;
  box-shadow: 0 8px 20px rgba(61, 142, 240, .6);
}

.pm-app .dk:active .dk-box { transform: scale(.94); }

/* Sheets */
.pm-app .scrim {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(2, 4, 10, .55);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}

.pm-app .scrim.show {
  opacity: 1;
  pointer-events: auto;
}

.pm-app .sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom, 0) + 86px);
  z-index: 56;
  max-height: 62%;
  display: flex;
  flex-direction: column;
  background: #0b0f1a;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -20px 50px rgba(0, 0, 0, .6);
  transform: translateY(120%);
  transition: transform .28s cubic-bezier(.2, .8, .25, 1);
  pointer-events: none;
}

.pm-app .sheet.open {
  transform: translateY(0);
  pointer-events: auto;
}

.pm-app .sheet-hdr {
  flex-shrink: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 8px;
}

.pm-app .sheet-handle {
  width: 34px;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .16);
  position: absolute;
  left: 50%;
  top: 8px;
  transform: translateX(-50%);
}

.pm-app .sheet-title {
  font-size: 13px;
  font-weight: 800;
  color: #eef2f8;
  margin-top: 6px;
}

.pm-app .sheet-x {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .06);
  border: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #8b95a8;
  cursor: pointer;
  margin-top: 6px;
}

.pm-app .sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 16px 20px;
}

.pm-app .len-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.pm-app .len-chip {
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, .1);
  background: #0b0f1a;
  color: #c3cad8;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

.pm-app .len-chip.selected {
  border-color: #3d8ef0;
  background: rgba(61, 142, 240, .12);
  color: #eef2f8;
}

.pm-app .sec-lbl {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #6a748e;
}

.pm-app .hint {
  margin: 8px 0 0;
  font-size: 10.5px;
  color: #6a748e;
  line-height: 1.45;
}

.pm-app .sheet-clear {
  margin-top: 12px;
  width: 100%;
  padding: 11px;
  border-radius: 12px;
  border: 1px solid rgba(255, 120, 120, .28);
  background: rgba(255, 120, 120, .08);
  color: #ff9a9a;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}

.pm-music-start {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, .08);
}

.pm-music-start .sec-lbl {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.pm-music-start-val {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  font-weight: 700;
  color: #fcd34d;
}

.pm-music-start-btn {
  margin-top: 10px;
  width: 100%;
  padding: 11px;
  border-radius: 12px;
  border: 1px solid rgba(90, 160, 255, .32);
  background: rgba(61, 142, 240, .12);
  color: #9cc4ff;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}

/* Music start crop popup (shared with Beat Editor) */
.sb-bt-music-crop-modal {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}

.sb-bt-music-crop-modal[hidden] { display: none; }

.sb-bt-music-crop-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .72);
  backdrop-filter: blur(6px);
}

.sb-bt-music-crop-panel {
  position: relative;
  width: min(640px, 100%);
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 20px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, .1);
  background: linear-gradient(180deg, #0c1828 0%, #08111d 100%);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .55);
  color: #eef2f8;
  overflow: hidden;
}

.sb-bt-music-crop-head h2 {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.02em;
}

.sb-bt-music-crop-sub {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: #8791a4;
}

.sb-bt-music-crop-file {
  margin: 8px 0 0;
  font-size: 12px;
  font-weight: 700;
  color: #fcd34d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb-bt-music-crop-track-wrap { display: flex; flex-direction: column; gap: 8px; }

.sb-bt-music-crop-track {
  position: relative;
  height: 96px;
  border-radius: 14px;
  border: 1px solid rgba(90, 160, 255, .35);
  background: rgba(0, 0, 0, .35);
  overflow: hidden;
  touch-action: none;
  cursor: ew-resize;
  user-select: none;
}

.sb-bt-music-crop-wave { display: block; width: 100%; height: 100%; pointer-events: none; }

.sb-bt-music-crop-window {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 2px solid rgba(90, 200, 255, .95);
  background: linear-gradient(180deg, rgba(61, 142, 240, .22), rgba(61, 142, 240, .08));
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(90, 200, 255, .25);
}

.sb-bt-music-crop-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  transform: translateX(-1px);
  pointer-events: none;
}

.sb-bt-music-crop-playhead-cap {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -1px;
  width: 3px;
  border-radius: 2px;
  background: linear-gradient(180deg, #fde68a, #f59e0b);
  box-shadow: 0 0 12px rgba(245, 158, 11, .65);
}

.sb-bt-music-crop-playhead-cap::before {
  content: "";
  position: absolute;
  top: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fbbf24;
  border: 2px solid #fff7ed;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .35);
}

.sb-bt-music-crop-times {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 2px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 14px;
  font-weight: 700;
}

.sb-bt-music-crop-start { color: #fcd34d; }
.sb-bt-music-crop-sep, .sb-bt-music-crop-total { color: #8791a4; }
.sb-bt-music-crop-actions { display: flex; justify-content: center; }
.sb-bt-music-crop-foot { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

.sb-bt-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  color: #eef2f8;
  background: rgba(255, 255, 255, .06);
}

.sb-bt-btn--primary {
  background: linear-gradient(135deg, #3d8ef0, #2563b8);
  color: #fff;
  border-color: rgba(90, 160, 255, .4);
  box-shadow: 0 4px 20px rgba(61, 142, 240, .35);
}

.sb-bt-btn--ghost {
  background: rgba(255, 255, 255, .06);
  border-color: rgba(255, 255, 255, .1);
}

body.sb-bt-music-crop-open { overflow: hidden; }

/* Bottom nav: visible on montage landing, hidden in editor */
html.pm-beatshell .cf-tbar { display: none !important; }
html.pm-beatshell.pm-cover-open .cf-tbar { display: block !important; }
html.pm-beatshell body { padding-bottom: 0 !important; }
html.pm-beatshell.pm-cover-open body {
  padding-bottom: calc(env(safe-area-inset-bottom, 0) + 76px) !important;
}

.cf-tbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9500;
  padding: 8px 10px calc(env(safe-area-inset-bottom, 0) + 8px);
  background: linear-gradient(180deg, rgba(0, 0, 0, .55) 0%, rgba(0, 0, 0, .94) 40%, #000 100%);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border-top: 1px solid rgba(255, 255, 255, .09);
  pointer-events: none;
}

.cf-tbar-inner {
  max-width: 520px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  pointer-events: auto;
}

.cf-tbar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 6px 6px;
  border-radius: 14px;
  background: transparent;
  border: 1px solid transparent;
  color: #98a2b7;
  text-decoration: none;
  transition: transform .12s, background .15s, border-color .15s, color .15s;
  min-height: 56px;
}

.cf-tbar-item:active { transform: scale(.94); }

.cf-tbar-ic {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .09);
  color: #eef2f8;
  transition: background .15s, color .15s, box-shadow .18s;
}

.cf-tbar-ic svg { width: 18px; height: 18px; }

.cf-tbar-lbl {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: -.005em;
  line-height: 1.1;
  text-align: center;
  color: #98a2b7;
}

.cf-tbar-item.is-on .cf-tbar-ic {
  background: linear-gradient(135deg, #3d8ef0, #6b5cff);
  color: #04122a;
  border-color: transparent;
  box-shadow: 0 6px 18px rgba(61, 142, 240, .34);
}

.cf-tbar-item.is-on .cf-tbar-lbl { color: #5AA0FF; }

.cf-tbar-item:hover .cf-tbar-ic { background: rgba(255, 255, 255, .09); }

@media (max-width: 360px) {
  .cf-tbar-lbl { font-size: 9.5px; }
  .cf-tbar-ic { width: 32px; height: 32px; }
}

@media (min-width: 900px) {
  .cf-tbar { display: none !important; }
  html.pm-beatshell.pm-cover-open body { padding-bottom: 0 !important; }
}

/* ── Entry cover (first visit landing) ── */
html.pm-cover-open,
html.pm-cover-open body {
  overflow: hidden;
}

html.pm-cover-skip .pm-cover {
  display: none !important;
}

.pm-cover {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom, 0) + 68px);
  z-index: 300;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(90, 160, 255, .14), transparent 55%),
    linear-gradient(180deg, #060a14 0%, #000 100%);
  color: #eef2f8;
  transition: opacity .32s ease, transform .32s ease;
}

.pm-cover.is-dismissed {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
}

.pm-cover-inner {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(env(safe-area-inset-top, 0) + 16px) 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pm-cover-art {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

/* Storyboard — tall 9:16 phone frame (matches editor export) */
.pm-cp-story {
  --pm-cycle: 12s;
  position: relative;
  margin: 0 auto;
  width: min(74vw, 250px, calc(58dvh * 9 / 16));
  aspect-ratio: 9 / 16;
  max-height: min(58dvh, 480px);
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .12);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .5);
  background: #000;
}

.pm-cp-steps {
  position: relative;
  width: min(74vw, 250px);
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.pm-cp-steps > span {
  position: absolute;
  left: 0;
  right: 0;
  opacity: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.pm-cp-steps b {
  display: block;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: #eef2f8;
  line-height: 1.15;
}

.pm-cp-steps i {
  display: block;
  margin-top: 2px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #8b95a8;
  font-style: normal;
}

.pm-cp-steps .s1 { animation: pmCpStep1 var(--pm-cycle) cubic-bezier(.22, 1, .36, 1) infinite; }
.pm-cp-steps .s2 { animation: pmCpStep2 var(--pm-cycle) cubic-bezier(.22, 1, .36, 1) infinite; }
.pm-cp-steps .s3 { animation: pmCpStep3 var(--pm-cycle) cubic-bezier(.22, 1, .36, 1) infinite; }
.pm-cp-steps .s4 { animation: pmCpStep4 var(--pm-cycle) cubic-bezier(.22, 1, .36, 1) infinite; }

.pm-cp-stage {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(90, 160, 255, .12), transparent 55%),
    linear-gradient(180deg, #0a1220 0%, #000 100%);
}

/* Phase 1 — upload music */
.pm-cp-music-drop {
  position: absolute;
  top: calc(50% - 28px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-radius: 14px;
  background: rgba(10, 16, 32, .97);
  border: 1px solid rgba(90, 160, 255, .42);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .55), 0 0 22px rgba(90, 160, 255, .16);
  opacity: 0;
  animation: pmCpMusicDrop var(--pm-cycle) cubic-bezier(.22, 1, .36, 1) infinite;
  white-space: nowrap;
}

.pm-cp-music-drop .ico {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #5aa0ff, #2e6fd1);
  color: #fff;
}

.pm-cp-music-drop .nm {
  font-size: 12.5px;
  font-weight: 700;
  color: #eef2f8;
  letter-spacing: -.01em;
}

.pm-cp-waveform {
  position: absolute;
  top: calc(50% + 18px);
  left: 50%;
  transform: translateX(-50%);
  width: 72%;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 3px;
  opacity: 0;
  animation: pmCpWaveform var(--pm-cycle) cubic-bezier(.22, 1, .36, 1) infinite;
}

.pm-cp-waveform span {
  flex: 1;
  min-width: 3px;
  border-radius: 99px;
  height: 18%;
  background: linear-gradient(180deg, #c6eeff, #3a6bff);
  transform-origin: center;
  animation: pmCpWaveBar 1s ease-in-out infinite;
}

.pm-cp-waveform span:nth-child(odd) { animation-delay: .1s; }
.pm-cp-waveform span:nth-child(3n) { animation-delay: .25s; }

/* Phase 2 — select photos (fills vertical frame) */
.pm-cp-photo-pick {
  position: absolute;
  inset: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  opacity: 0;
  animation: pmCpPhotoPick var(--pm-cycle) cubic-bezier(.22, 1, .36, 1) infinite;
}

.pm-cp-photo-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 6px;
  flex: 1;
  min-height: 0;
}

.pm-cp-photo-grid figure {
  position: relative;
  margin: 0;
  min-height: 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .1);
  background: #141a28;
}

.pm-cp-photo-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #141a28;
}

.pm-cp-gen-phone .slide,
.pm-cp-done-phone .slide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  background: #141a28;
}

.pm-cp-photo-grid .sel {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #3fcb7e;
  border: 2px solid #fff;
  opacity: 0;
  transform: scale(.4);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .4);
}

.pm-cp-photo-grid .sel::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 7px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.pm-cp-photo-grid .p1 .sel { animation: pmCpCheck1 var(--pm-cycle) infinite; }
.pm-cp-photo-grid .p2 .sel { animation: pmCpCheck2 var(--pm-cycle) infinite; }
.pm-cp-photo-grid .p3 .sel { animation: pmCpCheck3 var(--pm-cycle) infinite; }
.pm-cp-photo-grid .p4 .sel { animation: pmCpCheck4 var(--pm-cycle) infinite; }
.pm-cp-photo-grid .p5 .sel { animation: pmCpCheck5 var(--pm-cycle) infinite; }
.pm-cp-photo-grid .p6 .sel { animation: pmCpCheck6 var(--pm-cycle) infinite; }

.pm-cp-select-all {
  flex-shrink: 0;
  text-align: center;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #5AA0FF;
}

/* Phase 3 — generate (full-bleed 9:16 preview) */
.pm-cp-generate {
  position: absolute;
  inset: 0;
  opacity: 0;
  animation: pmCpGenerate var(--pm-cycle) cubic-bezier(.22, 1, .36, 1) infinite;
}

.pm-cp-gen-phone,
.pm-cp-done-phone {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #000;
}

.pm-cp-gen-phone .s1 { animation: pmCpGenSlide1 1.8s steps(1) infinite; }
.pm-cp-gen-phone .s2 { animation: pmCpGenSlide2 1.8s steps(1) infinite; }
.pm-cp-gen-phone .s3 { animation: pmCpGenSlide3 1.8s steps(1) infinite; }

.pm-cp-progress {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 54px;
  z-index: 4;
  height: 4px;
  border-radius: 99px;
  background: rgba(0, 0, 0, .45);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .08);
}

.pm-cp-progress i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, #5AA0FF, #62D4FF);
  animation: pmCpProgress var(--pm-cycle) linear infinite;
}

.pm-cp-gen-btn {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 18px;
  border-radius: 99px;
  background: linear-gradient(135deg, #3d8ef0, #6b5cff);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: -.005em;
  box-shadow: 0 8px 20px rgba(61, 142, 240, .35);
  animation: pmCpGenPulse var(--pm-cycle) ease-in-out infinite;
}

/* Phase 4 — done (full-bleed montage) */
.pm-cp-done {
  position: absolute;
  inset: 0;
  opacity: 0;
  animation: pmCpDoneScene var(--pm-cycle) cubic-bezier(.22, 1, .36, 1) infinite;
}

.pm-cp-done-phone .s1 { animation: pmCpDoneSlide1 2.4s steps(1) infinite; }
.pm-cp-done-phone .s2 { animation: pmCpDoneSlide2 2.4s steps(1) infinite; }
.pm-cp-done-phone .s3 { animation: pmCpDoneSlide3 2.4s steps(1) infinite; }
.pm-cp-done-phone .s4 { animation: pmCpDoneSlide4 2.4s steps(1) infinite; }

.pm-cp-done-bars {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 22%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  padding: 0 8px 8px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, .65));
  z-index: 3;
}

.pm-cp-done-bars span {
  flex: 1;
  max-width: 5px;
  height: 20%;
  border-radius: 2px;
  background: linear-gradient(180deg, #7cc0ff, #3d8ef0);
  transform-origin: bottom;
  animation: pmCpDoneBar 1.1s cubic-bezier(.5, .05, .3, 1) infinite;
}

.pm-cp-done-bars span:nth-child(1) { --h: 35%; animation-delay: 0s; }
.pm-cp-done-bars span:nth-child(2) { --h: 58%; animation-delay: .06s; }
.pm-cp-done-bars span:nth-child(3) { --h: 82%; animation-delay: .12s; }
.pm-cp-done-bars span:nth-child(4) { --h: 95%; animation-delay: .18s; }
.pm-cp-done-bars span:nth-child(5) { --h: 68%; animation-delay: .24s; }
.pm-cp-done-bars span:nth-child(6) { --h: 42%; animation-delay: .3s; }
.pm-cp-done-bars span:nth-child(7) { --h: 74%; animation-delay: .36s; }
.pm-cp-done-bars span:nth-child(8) { --h: 88%; animation-delay: .42s; }
.pm-cp-done-bars span:nth-child(9) { --h: 52%; animation-delay: .48s; }
.pm-cp-done-bars span:nth-child(10) { --h: 36%; animation-delay: .54s; }

.pm-cp-done-badge {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 99px;
  background: rgba(6, 10, 18, .82);
  border: 1px solid rgba(63, 203, 126, .35);
  font-size: 11.5px;
  font-weight: 800;
  color: #eef2f8;
  backdrop-filter: blur(8px);
}

.pm-cp-done-badge .chk {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #3fcb7e, #22a058);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.pm-cover-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 420px;
  margin: 0 auto;
  width: 100%;
}

.pm-cover-title {
  margin: 0;
  font-size: 26px;
  line-height: 1.12;
  letter-spacing: -.022em;
  font-weight: 800;
}

.pm-cover-title em {
  font-family: 'Instrument Serif', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  color: #5AA0FF;
}

.pm-cover-lead {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: #9aa3b5;
}

.pm-cover-cta {
  margin-top: 6px;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, #3d8ef0, #6b5cff);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -.005em;
  cursor: pointer;
  box-shadow: 0 14px 32px rgba(61, 142, 240, .38);
}

.pm-cover-cta svg {
  width: 16px;
  height: 16px;
}

/* Storyboard keyframes */
@keyframes pmCpStep1 { 0% { opacity: 0; transform: translateY(8px); } 4%, 22% { opacity: 1; transform: none; } 26%, 100% { opacity: 0; transform: translateY(-6px); } }
@keyframes pmCpStep2 { 0%, 26% { opacity: 0; transform: translateY(8px); } 30%, 47% { opacity: 1; transform: none; } 51%, 100% { opacity: 0; transform: translateY(-6px); } }
@keyframes pmCpStep3 { 0%, 51% { opacity: 0; transform: translateY(8px); } 55%, 72% { opacity: 1; transform: none; } 76%, 100% { opacity: 0; transform: translateY(-6px); } }
@keyframes pmCpStep4 { 0%, 76% { opacity: 0; transform: translateY(8px); } 80%, 96% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-6px); } }
@keyframes pmCpMusicDrop { 0%, 2% { opacity: 0; transform: translate(-50%, -12px); } 7%, 23% { opacity: 1; transform: translate(-50%, 0); } 27%, 100% { opacity: 0; transform: translate(-50%, 8px); } }
@keyframes pmCpWaveform { 0%, 5% { opacity: 0; } 9%, 23% { opacity: 1; } 27%, 100% { opacity: 0; } }
@keyframes pmCpWaveBar { 0%, 100% { height: 18%; opacity: .55; } 50% { height: 72%; opacity: 1; } }
@keyframes pmCpPhotoPick { 0%, 27% { opacity: 0; transform: scale(.98); } 31%, 48% { opacity: 1; transform: scale(1); } 52%, 100% { opacity: 0; transform: scale(.98); } }
@keyframes pmCpCheck1 { 0%, 30% { opacity: 0; transform: scale(.4); } 32%, 100% { opacity: 1; transform: scale(1); } }
@keyframes pmCpCheck2 { 0%, 32% { opacity: 0; transform: scale(.4); } 34%, 100% { opacity: 1; transform: scale(1); } }
@keyframes pmCpCheck3 { 0%, 34% { opacity: 0; transform: scale(.4); } 36%, 100% { opacity: 1; transform: scale(1); } }
@keyframes pmCpCheck4 { 0%, 36% { opacity: 0; transform: scale(.4); } 38%, 100% { opacity: 1; transform: scale(1); } }
@keyframes pmCpCheck5 { 0%, 38% { opacity: 0; transform: scale(.4); } 40%, 100% { opacity: 1; transform: scale(1); } }
@keyframes pmCpCheck6 { 0%, 40% { opacity: 0; transform: scale(.4); } 42%, 100% { opacity: 1; transform: scale(1); } }
@keyframes pmCpGenerate { 0%, 51% { opacity: 0; } 55%, 73% { opacity: 1; } 77%, 100% { opacity: 0; } }
@keyframes pmCpProgress { 0%, 54% { width: 0; } 73% { width: 100%; } 77%, 100% { width: 100%; } }
@keyframes pmCpGenPulse { 0%, 51%, 77%, 100% { transform: translateX(-50%) scale(1); box-shadow: 0 8px 20px rgba(61, 142, 240, .35); } 58%, 70% { transform: translateX(-50%) scale(1.04); box-shadow: 0 12px 28px rgba(61, 142, 240, .5); } }
@keyframes pmCpGenSlide1 { 0%, 32% { opacity: 1; } 33%, 100% { opacity: 0; } }
@keyframes pmCpGenSlide2 { 0%, 32% { opacity: 0; } 33%, 65% { opacity: 1; } 66%, 100% { opacity: 0; } }
@keyframes pmCpGenSlide3 { 0%, 65% { opacity: 0; } 66%, 100% { opacity: 1; } }
@keyframes pmCpDoneScene { 0%, 76% { opacity: 0; } 80%, 98% { opacity: 1; } 100% { opacity: 0; } }
@keyframes pmCpDoneSlide1 { 0%, 24% { opacity: 1; } 25%, 100% { opacity: 0; } }
@keyframes pmCpDoneSlide2 { 0%, 24% { opacity: 0; } 25%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes pmCpDoneSlide3 { 0%, 49% { opacity: 0; } 50%, 74% { opacity: 1; } 75%, 100% { opacity: 0; } }
@keyframes pmCpDoneSlide4 { 0%, 74% { opacity: 0; } 75%, 100% { opacity: 1; } }
@keyframes pmCpDoneBar { 0%, 100% { height: 16%; opacity: .5; } 50% { height: var(--h, 55%); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .pm-cp-story *,
  .pm-cover.is-dismissed {
    animation: none !important;
    transition: none;
  }

  .pm-cp-photo-grid .sel { opacity: 1; transform: none; }
  .pm-cp-gen-phone .slide:first-child,
  .pm-cp-done-phone .slide:first-child { opacity: 1; }
}

@media (min-width: 900px) {
  .pm-cover-inner {
    max-width: 520px;
    margin: 0 auto;
    padding-top: 32px;
  }

  .pm-cp-story,
  .pm-cp-steps {
    width: min(100%, 280px);
  }

  .pm-cp-story {
    max-height: 520px;
  }
}

@media (min-width: 900px) {
  html.pm-beatshell, html.pm-beatshell body {
    overflow: auto;
    height: auto;
    min-height: 100vh;
  }

  .pm-app {
    position: relative;
    inset: auto;
    min-height: 100vh;
    max-width: 1180px;
    margin: 0 auto;
    padding-bottom: 24px;
  }

  .pm-app .dock { position: sticky; max-width: 520px; margin: 16px auto 0; border-radius: 16px; }
  .pm-app .stage { width: min(100%, 380px); }
  .pm-app .editor-main {
    display: grid;
    grid-template-columns: min(380px, 34vw) minmax(0, 1fr);
    gap: 0 20px;
    padding: 0 18px;
  }
  .pm-app .stage-wrap { grid-column: 1; grid-row: 1; }
  .pm-app .add-row { grid-column: 2; grid-row: 1; margin: 10px 0 0; }
  .pm-app .transport { grid-column: 1; grid-row: 2; }
  .pm-app .tl-wrap { grid-column: 2; grid-row: 2 / 4; margin-top: 0; }
  .pm-app .pm-foot { grid-column: 1 / -1; }
}
