/* Editor Snap and Preview (RemotePreview). The saved preview keeps playing after edits; Snap renders one
   high-quality still (flash, then a corner thumbnail), Preview plays the edit at 1/4 or 1/2 quality. */
.library-page .template-player-wrap > .remote-preview.has-controls.emo-has-actions {--playback-height: 104px;}
.emo-preview-stage {position: relative; cursor: pointer; overflow: hidden;}
.emo-snap-layer {position: absolute; inset: 0; z-index: 6; pointer-events: none;}

/* Action row under the playback controls. */
.emo-preview-actions {position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px; height: 48px; padding: 0 10px 0 14px; box-sizing: border-box;
  background: var(--brand-surface, #15171c); border-top: 1px solid var(--brand-line, rgb(255 255 255 / .08));}
.emo-preview-hint {min-width: 0; overflow: hidden; color: var(--brand-muted, #8d93a3); font: 500 12px/1.3 var(--brand-font, Poppins, Arial, sans-serif); white-space: nowrap; text-overflow: ellipsis;}
.emo-preview-buttons {display: flex; align-items: center; gap: 8px; flex: none;}
.emo-action {position: relative; display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px 0 10px; border: 0; border-radius: 10px; cursor: pointer;
  font: 600 13px/1 var(--brand-font, Poppins, Arial, sans-serif); letter-spacing: .1px; white-space: nowrap; isolation: isolate; overflow: hidden;
  transition: transform 120ms var(--brand-ease, ease), filter 160ms ease, box-shadow 160ms ease, opacity 160ms ease;}
.emo-action:disabled {opacity: .45; cursor: not-allowed;}
.emo-action:focus-visible, .emo-preview-split button:focus-visible {outline: 2px solid #8fd3ff; outline-offset: 2px;}
.emo-action:not(:disabled):active {transform: scale(.95);}
.emo-action.is-popping {animation: emo-pop 360ms cubic-bezier(.3, 1.6, .5, 1);}
.emo-action svg {display: block; width: 18px; height: 18px;}
.emo-action-icon {display: inline-flex; flex: none;}

.emo-snap-btn {color: #fff; text-shadow: 0 1px 0 rgb(0 30 90 / .35);
  background: linear-gradient(120deg, #6ad6ff 0%, #2f9bff 38%, #1a6bff 72%, #6a5cff 100%); background-size: 180% 100%; background-position: 0 0;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .45), inset 0 -1px 0 rgb(0 0 0 / .2), 0 1px 2px rgb(0 0 0 / .45);}
.emo-snap-btn::after {content: ''; position: absolute; inset: 0; z-index: -1; border-radius: inherit; opacity: 0; pointer-events: none;
  background: linear-gradient(100deg, transparent 30%, rgb(255 255 255 / .38) 48%, transparent 66%); background-size: 240% 100%; background-position: 140% 0;}
.emo-snap-btn:not(:disabled):hover {background-position: 100% 0; filter: brightness(1.05);}
.emo-snap-btn:not(:disabled):hover::after {opacity: 1; animation: emo-sheen 900ms ease;}
.emo-snap-btn.is-snapping {cursor: progress;}

/* Flip: viewfinder turns into a bolt on hover. */
.emo-flip {display: inline-block; width: 18px; height: 18px; perspective: 120px; flex: none;}
.emo-flip-inner {position: relative; display: block; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform 520ms cubic-bezier(.3, 1.55, .45, 1);}
.emo-flip-face {position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;}
.emo-flip-back {transform: rotateY(180deg);}
.emo-snap-btn:not(:disabled):hover .emo-flip-inner, .emo-snap-btn:focus-visible .emo-flip-inner {transform: rotateY(180deg);}
.emo-snap-spinner {width: 16px; height: 16px; border-radius: 50%; border: 2.4px solid rgb(255 255 255 / .35); border-top-color: #fff; animation: emo-spin 700ms linear infinite; flex: none;}

/* Preview: split button, navy-to-indigo gradient, quality menu. */
.emo-preview-split {position: relative; display: inline-flex; align-items: stretch; height: 34px; border-radius: 10px;
  background: linear-gradient(120deg, #172447 0%, #1b2153 55%, #2a1f5e 100%); box-shadow: inset 0 0 0 1px rgb(130 160 255 / .22), inset 0 1px 0 rgb(255 255 255 / .08);}
.emo-preview-split .emo-action {height: 34px; color: #dfe8ff; background: transparent; border-radius: 10px 0 0 10px; padding: 0 12px 0 9px;}
.emo-preview-split .emo-action:not(:disabled):hover {background: rgb(120 150 255 / .12);}
.emo-preview-split .emo-action:not(:disabled):hover .emo-preview-icon {animation: emo-nudge 520ms cubic-bezier(.3, 1.6, .5, 1);}
.emo-preview-icon {display: inline-flex;}
.emo-preview-quality {color: #8fb3ff; font-weight: 600; font-size: 11.5px;}
.emo-preview-more {display: grid; place-items: center; width: 30px; border: 0; border-left: 1px solid rgb(130 160 255 / .2); border-radius: 0 10px 10px 0; color: #a9bfff; background: transparent; cursor: pointer;}
.emo-preview-more:disabled {opacity: .45; cursor: not-allowed;}
.emo-preview-more:not(:disabled):hover {background: rgb(120 150 255 / .12); color: #fff;}
.emo-preview-more svg {width: 16px; height: 16px; transition: transform 200ms ease;}
.emo-preview-more[aria-expanded="true"] svg {transform: rotate(180deg);}
.emo-quality-menu {position: absolute; right: 0; bottom: calc(100% + 8px); z-index: 20; display: grid; gap: 4px; width: 236px; padding: 6px; box-sizing: border-box; border-radius: 12px;
  background: linear-gradient(160deg, #1a2140, #141830); box-shadow: inset 0 0 0 1px rgb(130 160 255 / .2), 0 12px 30px rgb(0 0 0 / .5); animation: emo-menu-in 180ms cubic-bezier(.2, 1.3, .4, 1) both; transform-origin: bottom right;}
.emo-quality-option {display: grid; grid-template-columns: 1fr 18px; align-items: center; gap: 2px 8px; padding: 9px 10px; border: 0; border-radius: 8px; text-align: left; color: #e8eeff; background: transparent; cursor: pointer;
  font: 600 13px/1.2 var(--brand-font, Poppins, Arial, sans-serif);}
.emo-quality-option small {grid-column: 1; color: #8d9ac2; font: 500 11.5px/1.3 var(--brand-font, Poppins, Arial, sans-serif);}
.emo-quality-check {grid-row: 1 / span 2; grid-column: 2; display: grid; width: 16px; height: 16px; color: #6ad6ff; opacity: 0;}
.emo-quality-check svg {width: 16px; height: 16px;}
.emo-quality-option[aria-checked="true"] .emo-quality-check {opacity: 1;}
.emo-quality-option:hover, .emo-quality-option:focus-visible {background: rgb(120 150 255 / .14); outline: none;}

/* Previewing badge. */
.emo-preview-badge {position: absolute; top: 10px; right: 10px; z-index: 5; display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 4px 0 10px; border-radius: 999px;
  color: #e8eeff; font: 600 11.5px/1 var(--brand-font, Poppins, Arial, sans-serif); background: rgb(12 16 34 / .72); box-shadow: inset 0 0 0 1px rgb(130 160 255 / .25); backdrop-filter: blur(6px); cursor: default;}
.emo-preview-badge button {display: grid; place-items: center; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; color: #cfe0ff; background: rgb(255 255 255 / .1); cursor: pointer;}
.emo-preview-badge button:hover {background: rgb(255 255 255 / .2);}
.emo-preview-badge svg {width: 11px; height: 11px;}

/* Peek: flash, corner thumbnail, enlarged still, minimized button. Bracket corners and the "Peek" badge
   mark it as a still frame, not the animation (like ccLeaf's Quick Snap). */
/* iPhone capture: a canvas draws the flash, the lift and the motion-blurred flight; the thumbnail, laid out
   hidden in its corner box, appears exactly where the canvas lands. */
.emo-snap-layer > .emo-snap-flyer {position: absolute; inset: 0; z-index: 1; display: block; width: 100%; height: 100%; max-width: none; margin: 0; pointer-events: none;}
.emo-snap {--peek-a: #6ad6ff; --peek-b: #6a5cff; position: absolute; left: 0; top: 0; width: 100%; height: 100%; box-sizing: border-box; pointer-events: auto; cursor: zoom-in; border-radius: 0;
  background: #14161c; box-shadow: 0 0 0 1px rgb(130 160 255 / .25);
  transition: left 600ms cubic-bezier(.22, 1, .3, 1), top 600ms cubic-bezier(.22, 1, .3, 1), width 600ms cubic-bezier(.22, 1, .3, 1), height 600ms cubic-bezier(.22, 1, .3, 1), border-radius 600ms ease, box-shadow 600ms ease, opacity 200ms ease, transform 200ms ease;}
.emo-snap.is-full {cursor: default;}
.emo-snap.is-full:not(.is-ready) {visibility: hidden;}
.emo-snap-viewport {position: absolute; inset: 0; overflow: hidden; border-radius: inherit; touch-action: none;
  background: #1c1f26 conic-gradient(#262a33 25%, transparent 0 50%, #262a33 0 75%, transparent 0) 0 0 / 16px 16px;}
.emo-snap .emo-snap-viewport > .emo-snap-image {position: absolute; inset: 0; display: block; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; object-fit: contain; object-position: center; user-select: none; transform-origin: 50% 50%; transition: transform 90ms ease-out;}
.emo-snap.is-corner {--snap-r: 12px; left: 12px; top: 12px; width: 24%; height: 24%; min-width: 104px; min-height: 58px; border-radius: var(--snap-r); box-shadow: 0 0 0 1.5px rgb(255 255 255 / .9), 0 10px 26px rgb(0 0 0 / .55);}
.emo-snap.is-corner:hover {transform: scale(1.03);}
.emo-snap.is-expanded {--snap-r: 14px; left: 10px; top: 10px; width: calc(100% - 20px); height: calc(100% - 20px); border-radius: var(--snap-r); cursor: default; box-shadow: 0 0 0 1px rgb(130 160 255 / .28), 0 18px 44px rgb(0 0 0 / .6);}
.emo-snap.is-expanded .emo-snap-viewport {cursor: zoom-in;}
.emo-snap.is-expanded.is-zoomed .emo-snap-viewport {cursor: grab;}
.emo-snap.is-leaving {opacity: 0; transform: scale(.9);}

/* Bracket corners: a gradient L at the top-left and bottom-right that bends around the rounded corner
   (concentric with the Peek's radius) and fades out along both arms. */
.emo-snap-corners {position: absolute; inset: -3px; pointer-events: none; opacity: 0; transition: opacity 260ms ease 160ms;}
.emo-snap.is-corner .emo-snap-corners, .emo-snap.is-expanded .emo-snap-corners {opacity: 1;}
.emo-snap-corner {--arm: 3px; position: absolute; width: 34%; height: 46%; max-width: 160px; max-height: 120px; box-sizing: border-box; border: 0 solid;}
.emo-snap-corner.is-tl {left: 0; top: 0; border-color: var(--peek-a); border-top-width: var(--arm); border-left-width: var(--arm); border-top-left-radius: calc(var(--snap-r, 12px) + 3px);
  -webkit-mask: radial-gradient(farthest-side at 0 0, #000 30%, transparent); mask: radial-gradient(farthest-side at 0 0, #000 30%, transparent);}
.emo-snap-corner.is-br {right: 0; bottom: 0; border-color: var(--peek-b); border-right-width: var(--arm); border-bottom-width: var(--arm); border-bottom-right-radius: calc(var(--snap-r, 12px) + 3px);
  -webkit-mask: radial-gradient(farthest-side at 100% 100%, #000 30%, transparent); mask: radial-gradient(farthest-side at 100% 100%, #000 30%, transparent);}
.emo-snap.is-corner .emo-snap-corner {--arm: 2px; width: 40%; height: 50%;}
.emo-snap.is-flying {visibility: hidden; transition: none;}
.emo-snap.is-flying .emo-snap-corners, .emo-snap.is-flying .emo-snap-expand svg {opacity: 0;}
.emo-snap.is-corner .emo-snap-expand svg {transition: opacity 220ms ease 140ms, background 140ms ease;}

/* Badge, time tag, buttons. */
.emo-snap-badge {position: absolute; top: 10px; right: 10px; display: none; align-items: center; gap: 6px; height: 26px; padding: 0 11px 0 9px; border-radius: 999px; color: #04132b;
  font: 800 11px/1 var(--brand-font, Poppins, Arial, sans-serif); letter-spacing: .08em; text-transform: uppercase; pointer-events: none;
  background: linear-gradient(120deg, #9be4ff, #4fb6ff 55%, #8c7dff); box-shadow: inset 0 1px 0 rgb(255 255 255 / .6), 0 0 0 1px rgb(255 255 255 / .25), 0 4px 12px rgb(0 0 0 / .35);}
.emo-snap-badge svg {width: 13px; height: 13px;}
.emo-snap.is-expanded .emo-snap-badge {display: inline-flex; animation: emo-badge-in 320ms cubic-bezier(.3, 1.5, .5, 1) both;}
.emo-snap-tag {position: absolute; left: 8px; bottom: 8px; padding: 4px 8px; border-radius: 999px; color: #fff; font: 600 10.5px/1 var(--brand-font, Poppins, Arial, sans-serif); background: rgb(10 14 30 / .72); opacity: 0; pointer-events: none; transition: opacity 200ms ease;}
.emo-snap.is-corner:hover .emo-snap-tag, .emo-snap.is-expanded .emo-snap-tag {opacity: 1;}
.emo-snap.is-expanded .emo-snap-tag {left: 12px; bottom: 12px; font-size: 12px;}
.emo-snap-tool {display: grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%; color: #fff; background: rgb(10 14 30 / .72); cursor: pointer; transition: background 140ms ease, transform 140ms ease;}
.emo-snap-tool:hover {background: #1a6bff; transform: scale(1.08);}
.emo-snap-tool svg {width: 12px; height: 12px;}
.emo-snap-tool:focus-visible, .emo-snap-restore:focus-visible, .emo-snap-zoom-button:focus-visible {outline: 2px solid #8fd3ff; outline-offset: 2px;}
.emo-snap-expand, .emo-snap-collapse {position: absolute; top: 6px; left: 6px;}
.emo-snap.is-corner .emo-snap-expand {inset: 0; width: 100%; height: 100%; border-radius: inherit; background: transparent; transform: none;}
.emo-snap.is-corner .emo-snap-expand svg {position: absolute; left: 6px; top: 6px; box-sizing: content-box; width: 12px; height: 12px; padding: 7px; border-radius: 50%; background: rgb(10 14 30 / .72);}
.emo-snap.is-corner .emo-snap-expand:hover svg {background: #1a6bff;}
.emo-snap.is-corner .emo-snap-expand:focus-visible {outline-offset: -3px;}
.emo-snap-collapse, .emo-snap.is-expanded .emo-snap-expand, .emo-snap.is-full .emo-snap-expand {display: none;}
.emo-snap.is-expanded .emo-snap-collapse {display: grid; top: 10px; left: 10px; width: 30px; height: 30px;}
.emo-snap.is-expanded .emo-snap-collapse svg {width: 14px; height: 14px;}
.emo-snap-tools {position: absolute; z-index: 1; top: 6px; right: 6px; display: flex; gap: 4px; opacity: 0; pointer-events: none; transition: opacity 160ms ease;}
.emo-snap.is-corner:hover .emo-snap-tools, .emo-snap.is-corner:focus-within .emo-snap-tools {opacity: 1; pointer-events: auto;}
.emo-snap.is-expanded .emo-snap-tools {opacity: 1; pointer-events: auto; top: 44px; right: 10px;}
.emo-snap.is-full .emo-snap-tools, .emo-snap.is-full .emo-snap-tag {display: none;}
/* On touch, the entire thumbnail is the Enlarge Peek target. Extra actions live in the viewer. */
@media (hover: none), (width <= 760px) {
  .emo-snap.is-corner .emo-snap-tools {display: none;}
  .emo-snap.is-expanded .emo-snap-tool {width: 44px; height: 44px;}
  .emo-snap.is-expanded .emo-snap-tool svg {width: 16px; height: 16px;}
  .emo-snap.is-expanded .emo-snap-collapse {top: 8px; left: 8px;}
  .emo-snap.is-expanded .emo-snap-tools {top: 44px; right: 8px;}
  .emo-snap.is-mini {width: 44px; height: 44px;}
}

/* Zoom pill (enlarged Peek). */
.emo-snap-zoom {position: absolute; right: 12px; bottom: 12px; display: none; align-items: center; gap: 6px; height: 34px; padding: 0 6px; border-radius: 999px;
  background: rgb(10 14 30 / .82); box-shadow: inset 0 0 0 1px rgb(130 160 255 / .25), 0 8px 20px rgb(0 0 0 / .4); backdrop-filter: blur(6px);}
.emo-snap.is-expanded .emo-snap-zoom {display: flex;}
.emo-snap-zoom-button {display: grid; place-items: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%; color: #dfe8ff; background: transparent; cursor: pointer;}
.emo-snap-zoom-button, .emo-snap-zoom-slider {flex: none;}
.emo-snap-zoom-button:hover {color: #fff; background: rgb(255 255 255 / .12);}
.emo-snap-zoom-button svg {width: 15px; height: 15px;}
.emo-snap-zoom-slider {--fill: 0%; appearance: none; -webkit-appearance: none; width: clamp(70px, 14cqi, 130px); height: 4px; margin: 0; border-radius: 99px; cursor: pointer;
  background: linear-gradient(90deg, var(--peek-a), var(--peek-b)) 0 0 / var(--fill) 100% no-repeat, rgb(255 255 255 / .2);}
.emo-snap-zoom-slider::-webkit-slider-thumb {-webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgb(0 0 0 / .5);}
.emo-snap-zoom-slider::-moz-range-thumb {width: 14px; height: 14px; border: 0; border-radius: 50%; background: #fff;}
@media (hover: none), (width <= 760px) {
  .emo-snap.is-expanded .emo-snap-zoom {height: 44px; padding: 0 2px; gap: 4px;}
  .emo-snap.is-expanded .emo-snap-zoom-button {width: 44px; height: 44px;}
}

/* Minimized. */
.emo-snap-restore {display: none;}
.emo-snap.is-mini {width: 40px; height: 40px; min-width: 0; min-height: 0; left: 12px; top: 12px; border-radius: 50%; background: linear-gradient(140deg, #6ad6ff, #1a6bff 70%, #6a5cff); box-shadow: 0 0 0 1.5px rgb(255 255 255 / .9), 0 6px 16px rgb(0 0 0 / .45); cursor: pointer;}
.emo-snap.is-mini > :not(.emo-snap-restore) {display: none;}
.emo-snap.is-mini .emo-snap-restore {display: grid; place-items: center; width: 100%; height: 100%; padding: 0; border: 0; background: transparent; cursor: pointer;}
.emo-snap.is-mini .emo-snap-restore svg {width: 20px; height: 20px;}

@keyframes emo-pop {0% {transform: scale(.92);} 55% {transform: scale(1.05);} 100% {transform: scale(1);}}
@keyframes emo-sheen {from {background-position: 140% 0;} to {background-position: -40% 0;}}
@keyframes emo-spin {to {transform: rotate(360deg);}}
@keyframes emo-nudge {35% {transform: translateX(3px) scale(1.15);} 70% {transform: translateX(-1px);}}
/* Entrances never start fully transparent, so a busy or throttled tab still shows them. */
@keyframes emo-menu-in {from {transform: translateY(6px) scale(.96);}}
@keyframes emo-badge-in {from {transform: translateY(-4px) scale(.9);}}

@media (width <= 760px) {
  /* Keep the remote editor's grid and toolbar from widening the phone's layout viewport. */
  .library-page .template-editor-overlay:has(.emo-has-actions) {width: 100dvw; max-width: 100dvw; height: 100dvh; max-height: 100dvh; right: auto; bottom: auto; grid-template-columns: minmax(0, 1fr); overflow-x: clip;}
  .library-page .template-editor-overlay:has(.emo-has-actions) :is(.template-editor-topbar, .template-editor-body, .template-editor-stage, .template-player-wrap, .remote-preview) {min-width: 0; max-width: 100%;}
  .library-page .template-editor-overlay:has(.emo-has-actions) .template-editor-topbar {grid-template-columns: auto minmax(0, 1fr);}
  .library-page .template-editor-overlay:has(.emo-has-actions) .editor-top-actions {min-width: 0; flex-wrap: wrap;}
  .emo-preview-hint {display: none;}
  .emo-preview-actions {justify-content: flex-end; padding: 0 8px;}
  .emo-snap.is-corner {--snap-r: 10px; width: 38%; height: 38%; left: 8px; top: 8px; min-width: 104px; min-height: 58px;}
  .emo-snap.is-expanded {left: 6px; top: 6px; width: calc(100% - 12px); height: calc(100% - 12px);}
  .emo-snap.is-expanded .emo-snap-zoom {right: 8px; bottom: 8px;}
}
@media (prefers-reduced-motion: reduce) {
  .emo-flip-inner, .emo-snap, .emo-snap .emo-snap-viewport > .emo-snap-image {transition: none;}
  .emo-action.is-popping, .emo-snap-btn:hover::after, .emo-quality-menu, .emo-snap-badge {animation: none;}
}
