/* Root Surface Backplane: the page is the artifact field; 9:16 is guidance only. */
#surfaceMediaHost.root-surface-backplane{
  position:fixed;
  inset:0;
  width:100vw;
  height:100vh;
  overflow:hidden;
  pointer-events:none;
  z-index:0;
  background:#05070c;
}
#surfaceMediaHost .artifact-surface{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  min-height:100%;
  border:0;
  border-radius:0;
  background-color:#05070c;
  background-size:cover;
  background-position:center;
  background-repeat:no-repeat;
  transform:none!important;
  max-width:none!important;
  max-height:none!important;
}
#surfaceMediaHost .artifact-surface>video,
#surfaceMediaHost .artifact-surface>img,
#surfaceMediaHost video,
#surfaceMediaHost img{
  width:100%;
  height:100%;
  object-fit:cover;
  object-position:center;
  transform:none!important;
}
.global-bar,.creator-shell,footer{position:relative;z-index:2}

/* Foreground artifact authority. */
.artifact-root{
  position:relative;
  width:100%;
  min-height:100vh;
  height:auto;
  overflow:visible;
  background:transparent;
}

/* Preserve the former direct-child composition geometry after introducing artifactRoot. */
.artifact-root>.hero-preview{
  position:absolute;
  inset:auto 7% 17%;
  padding:0;
  text-align:left;
}
.artifact-root>.hero-preview h1{font-size:clamp(25px,4vw,38px);margin:0 0 5px}
.artifact-root>.hero-preview p{margin:0 0 14px;font-size:13px}
.artifact-root>.hero-preview .btn-primary{display:inline-block;padding:9px 15px;font-size:10px}

/* SERVICE AUDIO VIEWPORT-BOTTOM LAW.
   This is a viewer rail, not an in-composition module. It is anchored to the
   actual viewport bottom in Edit, Preview, Final, and exported Final. */
#artifactAudioPresentation,
.artifact-root>#artifactAudioPresentation,
body.preview-mode #artifactAudioPresentation,
body.finalized #artifactAudioPresentation,
body[data-exported="true"] #artifactAudioPresentation{
  position:fixed!important;
  left:50%!important;
  right:auto!important;
  top:auto!important;
  bottom:max(12px,env(safe-area-inset-bottom))!important;
  width:min(calc(100vw - 32px),620px)!important;
  max-width:620px!important;
  margin:0!important;
  transform:translateX(-50%)!important;
  z-index:60!important;
}

body[data-public-mp3-visible="false"] #artifactAudioPresentation{
  display:none!important;
}

/* TestStream presentation donor: keep Service Audio compact and polished,
   while preserving the existing MP3 transport and ids unchanged. */
#mp3PlayerControls.mp3-player-controls{
  display:grid;
  grid-template-columns:auto minmax(0,1fr) auto;
  align-items:center;
  gap:12px;
  width:100%;
  padding:10px 12px;
  border:1px solid rgba(126,217,255,.28);
  border-radius:18px;
  background:linear-gradient(145deg,rgba(10,18,31,.94),rgba(18,34,50,.88));
  box-shadow:0 14px 36px rgba(0,0,0,.42),inset 0 1px rgba(255,255,255,.06);
  backdrop-filter:blur(14px) saturate(125%);
  -webkit-backdrop-filter:blur(14px) saturate(125%);
}
#mp3PlayerControls .mp3-icon-button{
  width:42px!important;
  min-width:42px;
  height:42px;
  padding:0!important;
  margin:0!important;
  display:grid;
  place-items:center;
  border-radius:50%;
  border:1px solid rgba(117,240,174,.34);
  background:radial-gradient(circle at 35% 25%,rgba(117,240,174,.25),rgba(10,22,30,.94) 62%);
  box-shadow:inset 0 1px rgba(255,255,255,.08);
}
#mp3PlayerControls .mp3-control-label{font-size:0;line-height:0}
#mp3PlayerControls .mp3-player-main{min-width:0;display:grid;gap:6px}
#mp3PlayerControls .mp3-player-heading{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  color:#c8d9e8;
  font-size:10px;
  letter-spacing:.08em;
}
#mp3PlayerControls .mp3-track-label{
  color:#8fffc1;
  font-weight:900;
  letter-spacing:.16em;
}
#mp3PlayerControls .mp3-seek{
  width:100%;
  margin:0;
  padding:0;
  accent-color:#75f0ae;
}

.artifact-root>#actionButtonSection,
.artifact-root>#nftButtonSection{
  position:relative;
  z-index:5;
  text-align:center;
}
.artifact-root>.codes-container{position:absolute}

body.preview-mode .artifact-root>.hero-preview,
body.finalized .artifact-root>.hero-preview,
body[data-exported="true"] .artifact-root>.hero-preview{
  top:clamp(78px,12vh,150px);
  bottom:auto;
  left:50%;
  right:auto;
  transform:translateX(-50%);
  width:min(calc(100% - 40px),680px);
  text-align:center;
  background:transparent;
}

/* Reserve visual clearance so page controls/content are not hidden behind the fixed audio rail. */
body:not([data-public-mp3-visible="false"]){
  padding-bottom:110px;
}
body.preview-mode:not([data-public-mp3-visible="false"]),
body.finalized:not([data-public-mp3-visible="false"]),
body[data-exported="true"]:not([data-public-mp3-visible="false"]){
  padding-bottom:110px;
}

/* Edit: do not render a fake whole-artifact card/window. */
body:not(.preview-mode):not(.finalized):not([data-exported="true"]) .artifact-canvas{
  width:min(82vw,900px);
  min-height:100vh;
  height:auto;
  aspect-ratio:auto!important;
  overflow:visible;
  border:0!important;
  border-radius:0!important;
  box-shadow:none!important;
  background:transparent!important;
}
body:not(.preview-mode):not(.finalized):not([data-exported="true"]) .artifact-root{
  min-height:100vh;
}
body:not(.preview-mode):not(.finalized):not([data-exported="true"]) .artifact-canvas:after{
  display:none!important;
}
body:not(.preview-mode):not(.finalized):not([data-exported="true"]) .portrait-mode .artifact-canvas{
  aspect-ratio:auto!important;
  border:0!important;
  border-radius:0!important;
  box-shadow:none!important;
}

.surface-vid-sound-choice{
  display:flex!important;
  align-items:center;
  gap:8px;
  margin-top:14px!important;
  color:#aeb7c5;
  font-size:11px;
}
.surface-vid-sound-choice input{accent-color:#75f0ae}

/* Viewer control is independent from Service Audio and lives at the lower-left. */
.ambient-sound-control{
  position:fixed;
  left:max(12px,env(safe-area-inset-left));
  bottom:max(12px,env(safe-area-inset-bottom));
  z-index:70;
  width:auto!important;
  padding:7px 12px;
  border:1px solid rgba(255,255,255,.28);
  border-radius:999px;
  background:rgba(17,23,34,.82);
  color:#eef2f7;
  font-size:11px;
  backdrop-filter:blur(12px);
  -webkit-backdrop-filter:blur(12px);
}
.ambient-sound-control[hidden]{display:none!important}

/* The root document is the only scroll authority. */
html,body{min-height:100%;overflow-x:hidden}
body{overflow-y:auto}
.creator-shell,.stage-pane,.artifact-canvas,.artifact-root{overflow:visible}

/* Keep the Surface outside Preview/Final composition wrappers too. */
body.preview-mode #surfaceMediaHost,
body.finalized #surfaceMediaHost,
body[data-exported="true"] #surfaceMediaHost{
  display:block;
}

/* SAFE TESTSTREAM PREVIEW PARITY.
   Edit is intentionally not part of this selector set. The editor shell,
   Pure/Plus controls, and Edit composition geometry remain untouched. */
body.preview-mode .global-bar,
body.preview-mode .editor-pane,
body.preview-mode .stage-heading,
body.preview-mode .stage-note,
body.preview-mode footer{
  display:none!important;
}
body.preview-mode .creator-shell{
  display:block!important;
  width:100%!important;
  min-height:100vh;
  padding:0!important;
}
body.preview-mode .stage-pane{
  position:relative!important;
  width:100%!important;
  min-height:100vh;
  text-align:center;
}
body.preview-mode .artifact-canvas{
  position:relative!important;
  width:100%!important;
  max-width:none!important;
  min-height:100vh!important;
  height:auto!important;
  margin:0 auto!important;
  aspect-ratio:auto!important;
  border:0!important;
  border-radius:0!important;
  box-shadow:none!important;
  background:transparent!important;
  overflow:visible!important;
}
body.preview-mode .artifact-canvas:after{border-radius:0!important}
/* Force the Preview foreground authority to the actual viewport width. This
   prevents a narrowed/inherited parent from shifting hero + spinner together. */
body.preview-mode .artifact-root{
  width:100vw!important;
  max-width:none!important;
  min-height:max(100vh,860px);
  margin-left:calc(50% - 50vw)!important;
  margin-right:calc(50% - 50vw)!important;
}
body.preview-mode .artifact-brand{
  position:absolute!important;
  top:clamp(24px,5vh,64px)!important;
  left:50%!important;
  right:auto!important;
  width:min(88vw,680px)!important;
  transform:translateX(-50%)!important;
  justify-content:center!important;
  text-align:center!important;
}
body.preview-mode .artifact-canvas .system-spinner{
  position:absolute!important;
  top:clamp(245px,30vh,380px)!important;
  left:50%!important;
  width:min(78vw,430px)!important;
  transform:translateX(-50%)!important;
}
/* Preview hero/message must share the same full-viewport centerline as the spinner. */
body.preview-mode .artifact-root>.hero-preview{
  position:absolute!important;
  top:clamp(78px,12vh,150px)!important;
  bottom:auto!important;
  left:50%!important;
  right:auto!important;
  width:min(calc(100vw - 40px),680px)!important;
  max-width:680px!important;
  margin:0!important;
  transform:translateX(-50%)!important;
  text-align:center!important;
}
body.preview-mode .artifact-root>#actionButtonSection{
  position:absolute!important;
  left:50%!important;
  right:auto!important;
  bottom:104px!important;
  width:auto!important;
  padding:0!important;
  transform:translateX(-50%)!important;
  text-align:center!important;
  z-index:7!important;
}
body.preview-mode #actionButtonSection .action-btn,
body.finalized #actionButtonSection .action-btn,
body[data-exported="true"] #actionButtonSection .action-btn,
body.preview-mode #nftButtonSection .nft-btn,
body.finalized #nftButtonSection .nft-btn,
body[data-exported="true"] #nftButtonSection .nft-btn{
  display:inline-flex!important;
  align-items:center;
  justify-content:center;
  width:auto!important;
  max-width:min(92vw,620px);
  margin:0!important;
  border-radius:999px;
}
body.preview-mode #nftButtonSection,
body.finalized #nftButtonSection,
body[data-exported="true"] #nftButtonSection{
  width:auto!important;
  max-width:min(92vw,620px);
  margin-inline:auto!important;
  text-align:center!important;
}
body.preview-mode .mode-controls{
  position:relative!important;
  z-index:80!important;
  display:flex!important;
  justify-content:center!important;
  align-items:center!important;
  gap:10px!important;
  width:auto!important;
  margin:24px auto 0!important;
  padding:0 16px 28px!important;
  background:transparent!important;
}
body.preview-mode .mode-controls #toggleModeBtn,
body.preview-mode .mode-controls #finalizeMainBtn{
  width:auto!important;
  min-width:150px;
  margin:0!important;
  border-radius:999px!important;
}

@media(max-width:640px){
  #artifactAudioPresentation,
  .artifact-root>#artifactAudioPresentation,
  body.preview-mode #artifactAudioPresentation,
  body.finalized #artifactAudioPresentation,
  body[data-exported="true"] #artifactAudioPresentation{
    width:min(calc(100vw - 20px),620px)!important;
    bottom:max(8px,env(safe-area-inset-bottom))!important;
  }
  #mp3PlayerControls.mp3-player-controls{gap:8px;padding:8px 10px;border-radius:15px}
  #mp3PlayerControls .mp3-icon-button{width:38px!important;min-width:38px;height:38px}
  body.preview-mode .artifact-canvas .system-spinner{width:min(86vw,390px)!important}
  body.preview-mode .artifact-root>#actionButtonSection{bottom:96px!important}
}

/* Creator audio cleanup: compact native transport and a separate timing readout. */
#artifactAudioPresentation.audio-preview-shell,
.artifact-root>#artifactAudioPresentation.audio-preview-shell{
  width:min(calc(100% - 24px),25rem)!important;
  max-width:25rem!important;
  padding:6px 8px 5px;
  display:grid;
  gap:4px;
  border:1px solid rgba(126,217,255,.28);
  border-radius:16px;
  background:linear-gradient(145deg,rgba(10,18,31,.94),rgba(18,34,50,.88));
  box-shadow:0 12px 30px rgba(0,0,0,.38),inset 0 1px rgba(255,255,255,.06);
}
.audio-preview-shell audio{display:block;width:100%;max-width:100%;height:32px;min-width:0}
#mp3-player-time{color:rgba(255,255,255,.86);font:600 10px/1.2 ui-monospace,SFMono-Regular,Menlo,monospace;font-variant-numeric:tabular-nums;text-align:center}
/* In the editor the rail belongs to the artifact, so it cannot cover Preview. */
body:not(.preview-mode):not(.finalized):not([data-exported="true"]) #artifactAudioPresentation.audio-preview-shell{position:absolute!important;left:50%!important;right:auto!important;bottom:3.5%!important;transform:translateX(-50%)!important;margin:0!important;z-index:4!important}
/* Preview keeps audio and its action in document flow with a durable gap. */
body.preview-mode #artifactAudioPresentation.audio-preview-shell{position:relative!important;inset:auto!important;transform:none!important;width:min(calc(100% - 24px),25rem)!important;margin:78vh auto 0!important;z-index:60!important}
body.preview-mode .mode-controls{margin-top:24px!important}
@media(max-width:640px){#artifactAudioPresentation.audio-preview-shell,.artifact-root>#artifactAudioPresentation.audio-preview-shell{width:min(calc(100% - 16px),24rem)!important;padding:5px 6px 4px;border-radius:14px}}
