#control-buttons #self-tape-open { width: auto; height: auto; min-width: 44px; min-height: 44px; padding: 0; background: transparent; vertical-align: middle; cursor: pointer; }
/* The rehearsal row is displayed as a block by the scene renderer.
   Give every icon the same alignment instead of mixing image baselines. */
#control-buttons > button { display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; }
#control-buttons > button > img { display: block; }
#control-buttons > #delay-control { vertical-align: middle; }
/* Screen blending warms the red circle while preserving the white camera. */
.self-tape-icon { position: relative; display: inline-flex; isolation: isolate; border-radius: 50%; overflow: hidden; }
.self-tape-icon img { display: block; }
.self-tape-icon::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, transparent 15%, rgb(255 170 0 / 75%) 100%);
  mix-blend-mode: screen;
}
#self-tape-open:focus-visible { outline: 2px solid #2563eb; outline-offset: 3px; border-radius: 50%; }

#self-tape-role-notice {
  box-sizing: border-box; width: min(420px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
  padding: 24px; border: 0; border-radius: 16px; overflow-y: auto;
  color: #172033; background: white; font: 16px/1.5 system-ui, sans-serif;
  box-shadow: 0 12px 48px rgb(0 0 0 / 30%);
}
#self-tape-role-notice::backdrop { background: rgb(0 0 0 / 55%); }
#self-tape-role-notice h2 { margin: 0 0 8px; font-size: 1.25rem; }
#self-tape-role-notice p { margin: 0 0 20px; }
#self-tape-role-notice form { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
#self-tape-role-notice button {
  min-height: 44px; padding: 10px 14px; border: 1px solid #cbd5e1; border-radius: 10px;
  font: inherit; color: #172033; background: #f1f5f9; cursor: pointer;
}
#self-tape-role-notice button[value="choose"] { border-color: #b51f35; background: #b51f35; color: white; font-weight: 600; }
#self-tape-role-notice button:focus-visible { outline: 3px solid #2563eb; outline-offset: 3px; }

/* Keep modal focus isolation, but use the entire viewport as the camera surface. */
#self-tape-dialog {
  --tape-top: max(12px, env(safe-area-inset-top));
  --tape-bottom: max(12px, env(safe-area-inset-bottom));
  --tape-left: max(12px, env(safe-area-inset-left));
  --tape-right: max(12px, env(safe-area-inset-right));
  position: fixed; inset: 0; box-sizing: border-box;
  width: 100%; height: 100%; height: 100dvh; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; border-radius: 0;
  color: white; background: #080a0d; overflow: hidden;
  font: 16px/1.4 system-ui, sans-serif;
}
#self-tape-dialog::backdrop { background: #080a0d; }
#self-tape-dialog [hidden] { display: none !important; }
#self-tape-dialog video {
  position: absolute; inset: 0; display: block; width: 100%; height: 100%;
  max-width: none; max-height: none; object-fit: contain; background: #080a0d; border-radius: 0;
}
#tape-preview.mirrored { transform: scaleX(-1); }
#tape-preview.zoomable { touch-action: none; }
#tape-prompter {
  position: absolute; z-index: 2; top: calc(var(--tape-top) + 108px);
  bottom: calc(var(--tape-bottom) + 56px); left: var(--tape-left); right: var(--tape-right);
  box-sizing: border-box; width: min(680px, calc(100% - var(--tape-left) - var(--tape-right)));
  height: max-content; max-height: calc(100% - var(--tape-top) - var(--tape-bottom) - 164px);
  margin: 0 auto; padding: 8px 16px; overflow: hidden; border-radius: 12px;
  background: rgb(0 0 0 / 55%);
  color: rgb(255 255 255 / 95%); text-shadow: 0 1px 2px rgb(0 0 0 / 50%);
  font-size: clamp(32px, 4vw, 40px); font-weight: 600; line-height: 1.3; text-align: center;
}
#tape-prompter-character { font-size: .5em; font-weight: 700; margin-bottom: 4px !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#self-tape-dialog[data-state="ready"] #tape-status,
#self-tape-dialog[data-state="preparing"] #tape-status,
#self-tape-dialog[data-state="recording"] #tape-status {
  top: var(--tape-top); left: 50%; transform: translateX(-50%); max-width: 45%;
}
#tape-prompter-text { white-space: pre-wrap; overflow-wrap: anywhere; }
#tape-prompter-control {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px;
  border-radius: 24px; background: rgb(15 20 28 / 85%); cursor: pointer; pointer-events: auto;
}
#tape-prompter-enabled { width: 20px; height: 20px; margin: 0; accent-color: #b51f35; }
#self-tape-dialog header {
  position: absolute; z-index: 2; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: var(--tape-top) var(--tape-right) 12px var(--tape-left);
  background: linear-gradient(rgb(0 0 0 / 65%), transparent); pointer-events: none;
}
#self-tape-dialog header button { pointer-events: auto; }
.tape-header-actions { display: flex; align-items: center; gap: 8px; }
#self-tape-dialog #tape-fullscreen { display: inline-flex; align-items: center; justify-content: center; width: 44px; padding: 9px; }
#tape-fullscreen svg { display: block; }
#self-tape-dialog h2 { margin: 0; color: white; font-size: 1.1rem; text-shadow: 0 1px 4px #000; }
#self-tape-dialog p { margin: 0; }
/* Instructions remain available to assistive technology without covering the shot. */
#tape-help { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#self-tape-dialog button, #self-tape-dialog select, #tape-setup summary {
  box-sizing: border-box; font: inherit; min-height: 44px; padding: 10px 14px;
  border: 1px solid rgb(255 255 255 / 45%); border-radius: 24px;
  background: rgb(15 20 28 / 85%); color: white; cursor: pointer;
}
#self-tape-dialog select { border-radius: 8px; width: 100%; background: #202731; }
#self-tape-dialog button:disabled { opacity: .55; cursor: wait; }
#self-tape-dialog #tape-start:disabled { cursor: not-allowed; }
#self-tape-dialog :focus-visible { outline: 3px solid #8ac7ff; outline-offset: 3px; }
#self-tape-dialog .tape-primary, #self-tape-dialog[data-state="recording"] #tape-stop {
  color: white; background: #b51f35; border: 2px solid white; font-weight: 650;
}
#tape-status {
  position: absolute; z-index: 2; top: calc(var(--tape-top) + 52px); left: var(--tape-left);
  max-width: min(55%, 420px); padding: 6px 10px; border-radius: 12px;
  background: rgb(0 0 0 / 65%); font-size: .9rem; font-weight: 600; pointer-events: none;
}
#tape-status:empty { display: none; }
#self-tape-dialog[data-state="countdown"] #tape-status {
  top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 90%;
  font-size: clamp(1.1rem, 4vw, 2rem); text-align: center; padding: 14px 22px;
}
#tape-error {
  position: absolute; z-index: 5; top: calc(var(--tape-top) + 104px);
  left: var(--tape-left); right: var(--tape-right); margin: 0 auto !important;
  max-width: 560px; max-height: 35%; overflow: auto; padding: 12px;
  color: white; background: #842028; border-radius: 10px;
}
#tape-setup { position: absolute; z-index: 4; top: calc(var(--tape-top) + 104px); right: var(--tape-right); }
#tape-setup summary { list-style: none; width: max-content; margin-left: auto; }
#tape-setup summary::-webkit-details-marker { display: none; }
#tape-setup[open] summary { background: #354458; }
.tape-settings-panel {
  box-sizing: border-box; width: min(340px, calc(100vw - 24px));
  margin-top: 8px; padding: 16px; border: 1px solid #5a626d; border-radius: 12px;
  background: rgb(15 20 28 / 96%); max-height: calc(100dvh - var(--tape-top) - 168px); overflow-y: auto;
}
.tape-settings { display: grid; gap: 14px; padding-bottom: 14px; }
.tape-settings label { display: grid; gap: 5px; }
.tape-settings small, #self-tape-dialog .tape-note, #tape-voice-help { font-size: .85rem; color: #e0e4ea; }
#self-tape-dialog .tape-note, #tape-voice-help { margin-top: 12px; }
#tape-level { width: 100%; min-height: 24px; }
#tape-voice { width: 20px; height: 20px; vertical-align: middle; }
.tape-bottom {
  position: absolute; z-index: 3; bottom: 0; left: 0; right: 0;
  display: grid; justify-items: center; gap: 10px;
  padding: 20px var(--tape-right) var(--tape-bottom) var(--tape-left);
  background: linear-gradient(transparent, rgb(0 0 0 / 70%)); pointer-events: none;
}
#tape-zoom-controls, .tape-actions button { pointer-events: auto; }
#tape-orientation {
  max-width: 340px; padding: 12px 16px; border: 1px solid #f6ce77; border-radius: 12px;
  color: #fff3d6; background: rgb(43 31 9 / 95%); text-align: center; font-weight: 600;
}
#tape-zoom-label {
  display: flex; align-items: center; gap: 10px; box-sizing: border-box;
  padding: 4px 14px; border-radius: 24px; background: rgb(0 0 0 / 70%);
  width: min(320px, calc(100vw - 32px)); font-size: .9rem;
}
#tape-zoom { min-width: 0; flex: 1; min-height: 36px; accent-color: white; }
#tape-zoom-value { min-width: 3ch; }
.tape-actions {
  position: absolute; z-index: 3; top: calc(var(--tape-top) + 52px);
  left: var(--tape-left); right: var(--tape-right);
  display: flex; justify-content: center; flex-wrap: wrap; gap: 8px;
}
/* Review keeps native playback controls at the bottom; export actions sit at the top. */
#self-tape-dialog[data-state="review"] .tape-actions {
  top: calc(var(--tape-top) + 48px);
}
#self-tape-dialog[data-state="review"] #tape-status {
  width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); padding: 0;
}
body.self-tape-active { overflow: hidden !important; }
body.self-tape-active #orientationWarning { display: none !important; }
#control-buttons { flex-wrap: wrap; }
@media (max-width: 600px) {
  #self-tape-dialog .tape-actions button { padding: 10px 12px; font-size: .9rem; }
}
.tape-framing-note { display: none; }
/* Wide phones should show camera imagery beneath every overlay, not side bars.
   This is a display crop only; review retains the entire recorded frame. */
@media (orientation: landscape) {
  #self-tape-dialog #tape-preview { object-fit: cover; object-position: center; }
  #self-tape-dialog .tape-framing-note { display: block; }
}
@media (orientation: landscape) and (max-height: 500px) {
  #self-tape-dialog { --tape-top: max(8px, env(safe-area-inset-top)); --tape-bottom: max(8px, env(safe-area-inset-bottom)); }
  #tape-status { max-width: 50%; }
  .tape-bottom { gap: 4px; padding-top: 8px; }
}

/* Download feedback must remain visible in review, where the recording timer is hidden. */
#tape-export {
  position: absolute; z-index: 5; top: calc(var(--tape-top) + 112px);
  left: var(--tape-left); right: var(--tape-right); margin: 0 auto;
  box-sizing: border-box; max-width: 560px; max-height: calc(100dvh - 190px);
  overflow: auto; padding: 10px 14px; border-radius: 12px;
  color: white; background: rgb(15 20 28 / 95%); font-size: .9rem;
}
#tape-download { display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px; color: #a9d7ff; font-weight: 650; text-decoration: underline; }
@media (max-width: 360px) { #tape-export { top: calc(var(--tape-top) + 160px); max-height: calc(100dvh - 240px); } }
