/* =====================================================================
   Studio en el móvil y la tableta vertical (hasta 960 px): se comporta como una app.
   Arriba, la vista previa; debajo, los controles y la línea de tiempo; abajo del todo, la barra de herramientas.
   Al tocar una herramienta se abre su panel (hoja inferior) y se oculta la línea de tiempo para dejar sitio; al tocarla otra vez, se cierra.
   Exportar va en una hoja propia que se abre desde el botón de arriba. Nada de esto afecta a la versión de escritorio.
   ===================================================================== */
.st-hexp, .st-sheet-h, .st-expback, .st-chg, .st-srcmini { display: none; }

@media (max-width: 960px) {
  html { -webkit-text-size-adjust: 100%; }
  .st-page button, .st-page a, .st-page [role=button], .st-page summary { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
  .st-page input, .st-page textarea, .st-page select { font-size: 16px; }          /* iOS no hace zoom al enfocar un campo */
  .st-page canvas { -webkit-touch-callout: none; }

  /* ---------- cabecera ---------- */
  body.st-editing { overflow: hidden; overscroll-behavior: none; height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
  body.st-editing .topbar { flex: none; }
  body.st-editing .topbar { padding: max(6px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 6px max(12px, env(safe-area-inset-left)); gap: 8px; }
  body.st-editing .topbar .nav-right > a.btn[href="/"], body.st-editing .topbar .nav-right > a.btn[href^="/"][href$="/"] { display: none; }
  body.st-editing .st-hexp { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 15px; border: 1px solid rgba(255, 255, 255, .2); border-radius: 12px; background: linear-gradient(180deg, #74ff40 0%, #53fc18 50%, #44e50e 100%); color: #06100a; font: 800 14px/1 inherit; cursor: pointer; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5); }
  body.st-editing .st-hexp:active { transform: scale(.97); }
  body.st-editing .st-hexp.busy { filter: saturate(.7); }
  body.st-editing .st-hexp svg { flex: none; }

  /* ---------- estructura: una columna que ocupa la pantalla ---------- */
  body.st-editing .st-main { flex: 1 1 0; min-height: 0; height: auto; max-width: none; margin: 0; padding: 0; display: flex; flex-direction: column; overflow: hidden; }
  body.st-editing .st-status:empty { display: none; }
  body.st-editing .st-status { margin: 0; padding: 4px 12px; font-size: 13px; }
  body.st-editing .st-source { display: none; }
  body.st-editing .st-stage { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; align-items: stretch; margin: 0; gap: 0; }
  body.st-editing .st-sidecol, body.st-editing .st-origcol { display: none !important; }
  body.st-editing #stOrigBtn { display: none; }
  body.st-editing .st-left { position: static; flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; padding: 0 max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)); overflow: visible; }
  body.st-editing .st-left > * { flex: none; }

  /* ---------- barra del proyecto ---------- */
  body.st-editing .st-srcmini { position: relative; flex: none; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid var(--p-line-hi, #2a3336); border-radius: 13px; background: #0b0f10; color: var(--muted); cursor: pointer; overflow: visible; }
  body.st-editing .st-srcmini:active { transform: scale(.96); }
  body.st-editing .st-srcmini img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 12px; }
  body.st-editing .st-srcmini.has-img .film { display: none; }
  body.st-editing .st-srcmini i { position: absolute; right: -5px; bottom: -5px; width: 20px; height: 20px; display: grid; place-items: center; border: 2px solid var(--bg, #0b0e0f); border-radius: 50%; background: var(--green); color: #06100a; }
  body.st-editing .st-lrow { flex-direction: row; align-items: center; flex-wrap: nowrap; gap: 8px; margin: 6px 0 6px; }
  body.st-editing .st-lrow .st-proj { flex: 1 1 0; min-width: 0; margin: 0; padding: 4px 4px 4px 10px; }
  body.st-editing .st-proj { min-height: 42px; }
  body.st-editing .st-proj input { height: 32px; font-size: 15px; }
  body.st-editing #stProjDup, body.st-editing #stProjNew { display: none; }
  body.st-editing .st-pvbar { flex: none; gap: 6px; margin: 0; min-height: 0; }
  body.st-editing .st-pvbar .st-grow, body.st-editing .st-saved { display: none; }
  body.st-editing .st-tgl { font-size: 0; gap: 0; width: 40px; height: 40px; padding: 0; justify-content: center; border-radius: 12px; }
  body.st-editing .st-tgl svg { width: 19px; height: 19px; }

  /* ---------- vista previa ---------- */
  body.st-editing .st-grip, body.st-editing .st-help { display: none; }
  body.st-editing .st-left > .st-viewwrap { flex: 1 1 0; min-height: 0; margin: 0 0 6px; padding: 8px; align-items: center; justify-content: center; border-radius: 16px; }
  body.st-editing .st-viewwrap .st-fig { height: 100%; min-height: 0; max-width: 100%; justify-content: center; }
  body.st-editing .st-viewwrap .st-fig canvas { max-height: 100%; min-height: 0; max-width: 100%; touch-action: none; }

  /* ---------- reproducción y herramientas ---------- */
  body.st-editing .st-ctl { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); grid-template-areas: "time step ur"; align-items: center; gap: 4px 8px; margin: 0 0 4px; }
  body.st-editing .st-ur { grid-area: ur; justify-self: end; display: flex; gap: 2px; }
  body.st-editing .st-ctl .st-tool.icon { width: 38px; height: 38px; }
  body.st-editing .st-step { grid-area: step; gap: 4px; }
  body.st-editing .st-step button { width: 38px; height: 38px; }
  body.st-editing .st-step .st-play { width: 44px; height: 44px; }
  body.st-editing .st-time { grid-area: time; justify-self: start; flex: none; min-width: 0; }
  body.st-editing .st-time b { font-size: 15px; }
  body.st-editing .st-time small { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  body.st-editing .st-zoomc { display: none; }   /* el zoom de la línea de tiempo se hace pellizcando con dos dedos */
  body.st-editing .st-tools { flex: none; order: 0; padding: 8px 0 6px; border-top: 0; display: flex; flex-wrap: nowrap; justify-content: safe center; gap: 6px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; -webkit-overflow-scrolling: touch; margin: 0 calc(-1 * max(12px, env(safe-area-inset-left))); padding-left: max(12px, env(safe-area-inset-left)); padding-right: 12px; }
  body.st-editing .st-tools::-webkit-scrollbar { display: none; }
  body.st-editing .st-tools > *, body.st-editing .st-tools .st-menuwrap { flex: none; margin-left: 0; }
  body.st-editing .st-tools .st-tool, body.st-editing .st-tools .st-tool.icon { flex-direction: column; justify-content: center; gap: 3px; flex: 1 1 60px; min-width: 60px; max-width: 78px; height: 54px; padding: 5px 3px 6px; border-radius: 12px; font-size: 10px; font-weight: 650; line-height: 1.1; }
  body.st-editing .st-tools .st-tool svg { width: 18px; height: 18px; }
  body.st-editing .st-tools .st-tool span { display: -webkit-box; max-width: 100%; overflow: hidden; text-align: center; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; white-space: normal; overflow-wrap: anywhere; }
  body.st-editing .st-tools .st-menu { position: fixed; left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); top: auto; min-width: 0; max-height: 60dvh; overflow-y: auto; z-index: 90; }
  body.st-editing .st-tools .st-ext { width: auto; }

  /* ---------- línea de tiempo ---------- */
  body.st-editing .st-tlbody { max-height: min(36vh, 320px); max-height: min(36dvh, 320px); border-radius: 14px; }
  body.st-editing .st-tlsplit { display: none; }
  body.st-editing .st-fxlane:has(> .st-fxl-empty) { display: none; }
  body.st-editing .st-tl { height: 64px; }
  body.st-editing .st-h { width: 22px; }
  body.st-editing .st-h::after { height: 20px; margin-top: -10px; }
  body.st-editing .st-lay .lh, body.st-editing .st-mub .mh, body.st-editing .st-mub .mz, body.st-editing .st-fxa .th, body.st-editing .st-fxa .tz { width: 16px; }
  body.st-editing .st-fxc .rz { width: 16px; }
  body.st-editing .st-knob { width: 20px; height: 20px; margin-left: -10px; top: 0; border-radius: 6px 6px 10px 10px; }
  body.st-editing .st-head::before { left: -16px; right: -16px; }
  body.st-editing .st-scroll { height: 18px; margin-top: 6px; }
  body.st-editing .st-scroll i { min-width: 48px; }

  /* ---------- panel de herramientas: barra inferior + hoja que se abre encima ---------- */
  body.st-editing .st-panel { flex: none; display: flex; flex-direction: column; height: auto; max-height: none; margin: 0; gap: 0; background: #0a0e10; border-top: 1px solid rgba(255, 255, 255, .08); position: relative; }
  body.st-editing .st-ptabs { order: 3; border: 0; border-radius: 0; box-shadow: none; padding: 6px max(6px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left)); gap: 2px; background: #0a0e10; }
  body.st-editing .st-ptabs button { padding: 7px 0 6px; font-size: 10px; letter-spacing: 0; min-width: 0; }
  body.st-editing .st-ptabs button svg { width: 22px; height: 22px; }
  /* sin hoja abierta ninguna pestaña está activa: solo se ve en verde la que tiene su panel abierto */
  body.st-editing:not(.st-sheet) .st-ptabs button.on { background: transparent; box-shadow: none; color: #7c898d; }
  body.st-editing:not(.st-sheet) .st-ptabs button.on svg { opacity: .9; }
  body.st-editing .st-ptabs button:active { background: rgba(255, 255, 255, .06); }
  body.st-editing .st-pscroll { display: none; order: 2; height: min(42vh, 400px); height: min(42dvh, 400px); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 4px max(12px, env(safe-area-inset-right)) 18px max(12px, env(safe-area-inset-left)); background: #0b0f10; flex-direction: column; gap: 12px; }
  body.st-editing.st-sheet .st-pscroll { display: flex; }
  body.st-editing .st-sheet-h { order: 1; display: none; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 8px 0 16px; background: #0b0f10; border-radius: 20px 20px 0 0; }
  body.st-editing.st-sheet .st-sheet-h { display: flex; }
  body.st-editing .st-sheet-h::before { content: ''; position: absolute; left: 50%; top: 6px; width: 38px; height: 4px; margin-left: -19px; border-radius: 4px; background: rgba(255, 255, 255, .18); }
  body.st-editing .st-sheet-h b { padding-top: 10px; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 750; }
  body.st-editing .st-sheet-h button { width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 12px; background: transparent; color: var(--muted); cursor: pointer; }
  body.st-editing .st-sheet-h button:active { background: rgba(255, 255, 255, .07); }
  /* con la hoja abierta: solo la vista previa y la reproducción */
  body.st-editing.st-sheet .st-lrow, body.st-editing.st-sheet .st-source, body.st-editing.st-sheet .st-tools, body.st-editing.st-sheet .st-tlbody, body.st-editing.st-sheet .st-scroll, body.st-editing.st-sheet .st-zoomc { display: none; }
  body.st-editing.st-sheet .st-ctl { margin: 0 0 6px; }
  body.st-editing.st-sheet .st-ur { display: none; }

  /* ---------- exportar: hoja propia ---------- */
  body.st-editing .st-pfoot { position: fixed; left: 0; right: 0; bottom: 0; z-index: 85; margin: 0; padding: 18px max(16px, env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); border-radius: 22px 22px 0 0; border-width: 1px 0 0; transform: translateY(110%); visibility: hidden; transition: transform .26s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .26s; box-shadow: 0 -24px 60px rgba(0, 0, 0, .6); gap: 12px; }
  body.st-editing.st-export .st-pfoot { transform: none; visibility: visible; transition: transform .26s cubic-bezier(.2, .8, .2, 1), visibility 0s; }
  body.st-editing .st-pfoot #stExpHint { display: block; }
  body.st-editing .st-pfoot .st-pfoot-go { grid-template-columns: 1fr auto; }
  body.st-editing .st-pfoot .st-pub { width: 52px; height: 52px; }
  body.st-editing .st-expback { display: block; position: fixed; inset: 0; z-index: 80; background: rgba(3, 6, 7, .6); opacity: 0; pointer-events: none; transition: opacity .22s; }
  body.st-editing.st-export .st-expback { opacity: 1; pointer-events: auto; }

  /* ---------- cambiar de vídeo: hoja con las tres vías ---------- */
  .st-chg { position: fixed; inset: 0; z-index: 300; display: none; align-items: flex-end; background: rgba(3, 6, 7, .66); }
  .st-chg.open { display: flex; animation: stFade .18s ease; }
  .st-chg > div { width: 100%; padding: 8px 16px calc(18px + env(safe-area-inset-bottom)); border-radius: 22px 22px 0 0; border-top: 1px solid rgba(255, 255, 255, .1); background: linear-gradient(180deg, #151c20, #0d1215); animation: stSlide .26s cubic-bezier(.2, .8, .2, 1); }
  @keyframes stSlide { from { transform: translateY(40px); opacity: 0; } }
  .st-chg i.grab { display: block; width: 38px; height: 4px; margin: 4px auto 14px; border-radius: 4px; background: rgba(255, 255, 255, .18); }
  .st-chg h3 { margin: 0 0 12px; font-size: 17px; }
  .st-chg .opt { display: flex; align-items: center; gap: 14px; width: 100%; padding: 13px 14px; margin-bottom: 8px; border: 1px solid var(--p-line-hi, #2a3336); border-radius: 15px; background: rgba(255, 255, 255, .035); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
  .st-chg .opt:active { background: rgba(255, 255, 255, .08); }
  .st-chg .opt .ic { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: rgba(83, 252, 24, .1); color: var(--green); }
  .st-chg .opt b { display: block; font-size: 15px; }
  .st-chg .opt small { display: block; margin-top: 1px; color: var(--muted); font-size: 12.5px; }
  .st-chg form { display: none; gap: 8px; margin: 0 0 8px; }
  .st-chg.link form { display: flex; }
  .st-chg form input { flex: 1; min-width: 0; height: 48px; padding: 0 14px; border: 1px solid var(--p-line-hi, #2a3336); border-radius: 13px; background: #090d0f; color: var(--text); outline: none; }
  .st-chg form input:focus { border-color: var(--green); }
  .st-chg form .btn { height: 48px; padding: 0 20px; }

  /* ---------- pantalla de inicio (antes de abrir un vídeo) ---------- */
  .st-main { padding: 12px max(14px, env(safe-area-inset-right)) 60px max(14px, env(safe-area-inset-left)); }
  body:not(.st-editing) .st-hero { padding: 8px 0 4px; }
  body:not(.st-editing) .st-hero h1 { font-size: clamp(24px, 7.2vw, 34px); text-wrap: balance; }
  body:not(.st-editing) .st-hero p { font-size: 14.5px; }
  body:not(.st-editing) .st-source { margin-top: 14px; gap: 10px; }
  body:not(.st-editing) .em-pick-card { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px 14px; padding: 14px; align-items: center; }
  body:not(.st-editing) .em-pick-ic { width: 46px; height: 46px; border-radius: 14px; }
  body:not(.st-editing) .em-pick-ic svg { width: 22px; height: 22px; }
  body:not(.st-editing) .em-pick-card .btn { grid-column: 1 / -1; height: 48px; }
  body:not(.st-editing) .st-load { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  body:not(.st-editing) .st-load input { grid-column: 1 / -1; flex: none; height: 50px; border-radius: 14px; }
  body:not(.st-editing) .st-load .btn { height: 48px; padding: 0 10px; border-radius: 13px; }
  body:not(.st-editing) .st-recent { margin-top: 20px; }
  body:not(.st-editing) .st-recent-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  body:not(.st-editing) .st-rc { padding: 6px 6px 9px; border-radius: 13px; }
  body:not(.st-editing) .st-rc b { font-size: 12.5px; }
  body:not(.st-editing) .st-rc small { font-size: 11px; }
  body:not(.st-editing) .st-rc .rm { opacity: 1; transform: none; width: 30px; height: 30px; top: 10px; right: 10px; }

  /* ---------- varios ---------- */
  .st-toast { left: 12px; right: 12px; bottom: calc(16px + env(safe-area-inset-bottom)); transform: none; max-width: none; gap: 8px; padding: 8px 8px 8px 16px; }
  body.st-editing .st-toast { bottom: calc(78px + env(safe-area-inset-bottom)); }
  .st-toast #stToastTx { flex: 1 1 auto; min-width: 0; line-height: 1.3; text-wrap: balance; overflow-wrap: anywhere; }
  .st-toast #stToastBtn { flex: none; min-height: 40px; padding: 0 12px; border-radius: 11px; white-space: nowrap; background: rgba(83, 252, 24, .1); }
  .st-toast #stToastBtn:empty { display: none; }
  .st-toast .x { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 11px; }
  body.st-editing .st-pmenu { max-height: 50dvh; }
  .st-trb { width: 28px; height: 28px; margin: -14px 0 0 -14px; }
  .st-join { width: 24px; height: 24px; margin: -12px 0 0 -12px; }
  .st-page .st-row { grid-template-columns: 92px 1fr 52px; }
  .st-page input[type=range] { height: 32px; }
  .st-page input[type=range]::-webkit-slider-thumb { width: 22px; height: 22px; margin-top: -9px; }
  .st-page input[type=range]::-moz-range-thumb { width: 22px; height: 22px; }
  .st-page .st-chip, .st-page .st-seg button { min-height: 42px; }
  .st-page .st-colors button { width: 28px; height: 28px; }
  .st-page .st-colors input[type=color] { width: 30px; height: 30px; }
  .st-page .st-sw { width: 50px; height: 30px; }
  .st-page .st-sw::after { width: 24px; height: 24px; }
  .st-page .st-sw[aria-checked=true]::after { transform: translateX(20px); }
  .st-page input[type=checkbox] { width: 22px; height: 22px; }
  .st-page .st-det > summary { padding: 14px; }
  .st-page .st-fonts button { padding: 11px 12px; }
}

/* pantallas bajas (móviles pequeños): se compacta para que la vista previa conserve el sitio */
@media (max-width: 960px) and (max-height: 700px) {
  body.st-editing .st-lrow { margin-bottom: 4px; }
  body.st-editing .st-proj { min-height: 38px; }
  body.st-editing .st-tgl { width: 38px; height: 38px; }
  body.st-editing .st-tools .st-tool, body.st-editing .st-tools .st-tool.icon { height: 38px; width: 48px; }
  body.st-editing .st-tools .st-tool span { display: none; }
  body.st-editing .st-tlbody { max-height: 24dvh; }
}

/* móviles estrechos: los botones de las barras se reparten el ancho */
@media (max-width: 400px) {
  body.st-editing .st-time small { display: none; }
  body.st-editing .st-step button { width: 36px; }
  body.st-editing .st-step .st-play { width: 42px; }
  body.st-editing .st-ctl { gap: 4px 5px; }
  body.st-editing .st-ctl .st-tool.icon { width: 34px; }
  .st-page .st-colors { gap: 5px; }
  .st-page .st-colors button { width: 25px; height: 25px; }
  .st-page .st-colors input[type=color] { width: 27px; height: 27px; }
}

/* móvil en horizontal (poca altura): vista previa a la izquierda y herramientas a la derecha, sin hoja */
@media (max-width: 960px) and (orientation: landscape) and (max-height: 560px) {
  body.st-editing .st-stage { flex-direction: row; gap: 10px; }
  body.st-editing .st-left { padding-right: 0; }
  body.st-editing .st-source { display: none; }
  body.st-editing .st-panel { width: 340px; max-width: 42vw; height: auto; align-self: stretch; border: 1px solid rgba(255, 255, 255, .08); border-radius: 16px; margin: 0 max(12px, env(safe-area-inset-right)) 8px 0; overflow: hidden; }
  body.st-editing .st-panel .st-ptabs { order: 0; padding: 4px; }
  body.st-editing .st-panel .st-ptabs button { padding: 5px 0 4px; }
  body.st-editing .st-panel .st-ptabs button span { display: none; }
  body.st-editing:not(.st-sheet) .st-panel .st-ptabs button.on { background: linear-gradient(180deg, rgba(83, 252, 24, .17), rgba(83, 252, 24, .07)); box-shadow: inset 0 0 0 1px rgba(83, 252, 24, .36); color: var(--green); }
  body.st-editing .st-sheet-h { display: none !important; }
  body.st-editing .st-pscroll, body.st-editing.st-sheet .st-pscroll { display: flex; order: 1; flex: 1 1 0; min-height: 0; height: auto; border-radius: 0; }
  body.st-editing.st-sheet .st-lrow, body.st-editing.st-sheet .st-tools, body.st-editing.st-sheet .st-tlbody, body.st-editing.st-sheet .st-tlsplit { display: revert; }
  body.st-editing .topbar { padding-top: max(4px, env(safe-area-inset-top)); padding-bottom: 4px; }
  body.st-editing .st-hexp { height: 34px; }
  body.st-editing .brand-wm { height: 20px; }
  body.st-editing .st-lrow { display: none; }
  body.st-editing .st-ctl { margin-bottom: 2px; }
  body.st-editing .st-step button { width: 36px; height: 36px; }
  body.st-editing .st-step .st-play { width: 40px; height: 40px; }
  body.st-editing .st-tlbody { max-height: 34vh; }
  body.st-editing .st-tl { height: 46px; }
  body.st-editing .st-ruler { height: 20px; }
  body.st-editing .st-tools .st-tool, body.st-editing .st-tools .st-tool.icon { height: 36px; width: 46px; }
  body.st-editing .st-tools .st-tool span { display: none; }
}

/* ---------- cabecera en móvil: todo cabe, con la cuenta y «Volver» solo con icono ---------- */
@media (max-width: 560px) {
  .st-page .topbar { gap: 8px; }
  .st-page .topbar .brand { min-width: 0; flex: 0 1 auto; gap: 8px; }
  .st-page .topbar .nav-right { margin-left: auto; flex: none; gap: 8px; }
  .st-page .topbar .st-acct-btn:not(.in) { width: 42px; height: 42px; padding: 0; justify-content: center; border-radius: 13px; }
  .st-page .topbar .st-acct-btn:not(.in) span { display: none; }
  .st-page .topbar .nav-right > a.btn { position: relative; width: 42px; height: 42px; padding: 0; font-size: 0; border-radius: 13px; }
  .st-page .topbar .nav-right > a.btn::before { content: ''; position: absolute; inset: 0; margin: auto; width: 20px; height: 20px; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 5l-7 7 7 7'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 5l-7 7 7 7'/%3E%3C/svg%3E") center / contain no-repeat; }
}
@media (max-width: 400px) { .st-page .topbar .brand-sep, .st-page .topbar .brand-text { display: none; } }

/* ---------- biblioteca de clips en móvil: filtros compactos y todo el sitio para los clips ---------- */
@media (max-width: 700px) {
  .em-lib { padding: 0; }
  .em-lib-panel { width: 100%; height: 100%; max-height: none; border-radius: 0; border: 0; padding-top: env(safe-area-inset-top); }
  .em-lib-head { padding: 10px 14px 4px; gap: 10px; }
  .em-lib-titlebox { flex: 1; min-width: 0; }
  .em-lib-head h2 { margin: 2px 0 8px; font-size: 18px; }
  .em-lib-x { width: 38px; height: 38px; border-radius: 12px; }
  .em-lib-mode { display: flex; margin: 0 0 8px; padding: 3px; width: 100%; }
  .em-lib-mode button { flex: 1; justify-content: center; padding: 8px 10px; font-size: 13px; }
  /* los canales y las etiquetas van en UNA fila que se desliza, en vez de ocupar media pantalla */
  .em-lib-chips { flex-wrap: nowrap; overflow-x: auto; gap: 6px; margin: 0 -14px; padding: 2px 14px 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .em-lib-chips::-webkit-scrollbar { display: none; }
  .em-lib-chips { -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 26px), transparent); mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 26px), transparent); }
  .em-lib-chips button, .em-v-chips button { flex: none; height: 34px; padding: 0 12px; font-size: 13px; white-space: nowrap; }
  .em-v-chips button { display: inline-flex; align-items: center; gap: 6px; padding-left: 5px; }
  .em-v-chips button:first-child { padding-left: 12px; }
  .em-lib-ch { gap: 6px; margin-top: 2px; }
  .em-lib-ch form { flex: 1 1 100%; padding: 3px 3px 3px 12px; }
  .em-lib-ch input { flex: 1; width: auto; min-width: 0; font-size: 16px; }
  .em-lib-ch .btn { height: 34px; padding: 0 14px; }
  .em-lib-ch img { display: none; }
  /* buscador y filtros: cuadrícula ordenada, sin botones cortados */
  .em-lib-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 6px 14px 8px; overflow: visible; }
  .em-lib-filters > * { min-width: 0; }
  .em-lib-q { grid-column: span 3; width: auto; height: 40px; padding: 0 12px; font-size: 16px; }
  .em-lib-fbtn { grid-column: span 1; display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 40px; padding: 0 12px; border: 1px solid var(--p-line-hi, #2a3336); border-radius: 12px; background: #0b0f10; color: var(--text); font: 700 13.5px/1 inherit; cursor: pointer; }
  .em-lib-fbtn.on { border-color: var(--green); color: var(--green); background: rgba(83, 252, 24, .1); }
  .em-lib-filters { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .em-lib-filters > select, .em-lib-filters > .em-lib-tg { grid-column: span 2; }
  .em-lib-filters.mf-closed > select, .em-lib-filters.mf-closed > .em-lib-tg, .em-lib-filters.mf-closed > .em-link { display: none !important; }
  .em-lib-seg { grid-column: 1 / -1; display: flex; padding: 3px; }
  .em-lib-seg button { flex: 1 1 0; padding: 8px 4px; font-size: 13px; white-space: nowrap; text-align: center; }
  .em-lib-filters select { width: 100%; max-width: none; height: 40px; padding: 0 30px 0 12px; font-size: 14px; text-overflow: ellipsis; }
  .em-lib-tg { height: 40px; padding: 0 10px; justify-content: center; white-space: nowrap; font-size: 13px; }
  .em-lib-filters .em-link { grid-column: 1 / -1; justify-self: start; }
  .em-lib-meta { padding: 2px 14px 4px; min-height: 22px; font-size: 12px; }
  .em-lib-grid { gap: 12px 10px; padding: 6px 12px 10px; }
  .em-lib-pager { min-height: 0; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
  .em-lib-pager .pg { min-width: 40px; height: 40px; }
}

@media (min-width: 701px) { .em-lib-fbtn { display: none; } }
.em-lib-fbtn svg { flex: none; }

/* móviles estrechos: las filas con deslizador (etiqueta · barra · valor) se ajustan para no pasarse del borde */
@media (max-width: 400px) {
  .st-page .st-row, .st-page .st-ts .st-row, .st-page .st-ext .st-row { grid-template-columns: minmax(64px, 84px) minmax(0, 1fr) 44px; gap: 8px; }
  .st-page .st-row > span { min-width: 0; overflow-wrap: anywhere; line-height: 1.2; }
}
