/* =====================================================================
   IAPG CMS — Diseño para celular (≤ 860 px)
   ===================================================================== */
.m-tabbar, .m-sheet, .m-scrim, .m-publish { display: none; }

@media (max-width: 860px) {
  html, body { height: 100dvh; overflow: hidden; }
  .workspace { display: flex !important; flex-direction: column; height: 100dvh; width: 100%; }

  /* Barra superior en dos filas */
  .topbar { flex: 0 0 auto; display: flex; flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 12px 8px; height: auto; }
  .tb-left { display: flex; align-items: center; gap: 8px; width: 100%; }
  .tb-brand { flex: 0 0 34px; width: 34px; overflow: hidden; }
  .tb-logo-img { width: 120px; height: 30px; object-fit: cover; object-position: left center; }
  .tb-title-input { flex: 1 1 auto; max-width: none !important; min-width: 0; height: 40px; font-size: 14px; }
  .tb-right { display: flex; width: 100%; justify-content: space-between; gap: 4px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,.08); overflow: visible; }
  .tb-edit-group { display: contents; }
  .tb-sep { display: none; }
  .tb-btn.icon-only, .tb-right .tb-btn { width: 44px; height: 44px; padding: 0; justify-content: center; flex: 0 0 auto; }
  .tb-status-badge { flex: 0 0 auto; }

  .m-publish { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border: 0; border-radius: 12px;
    background: linear-gradient(160deg, #e11d6a, #be123c); color: #fff; font: 700 13px 'Inter', sans-serif; flex: 0 0 auto;
    box-shadow: 0 8px 18px -8px rgba(225,29,106,.8); }
  .m-publish svg { width: 17px; height: 17px; }

  /* Contenido */
  .navrail, .panel-resizer { display: none !important; }
  .editor-col { flex: 1 1 auto; min-height: 0; width: 100%; padding: 14px 14px calc(92px + env(safe-area-inset-bottom)); overflow-y: auto; overflow-x: hidden; }
  .panel-head { margin-bottom: 14px; }
  .panel-head h2 { font-size: 20px; }
  .panel-head { flex-direction: column; align-items: stretch; gap: 12px; }
  .fgrid { grid-template-columns: 1fr !important; }
  .fgrid > * { grid-column: 1 / -1 !important; }
  .ecard { padding: 16px 14px; }
  .input, input[type="text"], input[type="url"], input[type="number"], select, textarea { min-height: 46px; font-size: 16px !important; }
  textarea { min-height: 84px; }
  .btn { min-height: 44px; }
  input[type="checkbox"] { width: 22px !important; height: 22px !important; }

  /* ===== Edición en vivo: el programa a pantalla completa y las herramientas en un panel que sube y baja ===== */
  .tb-right { display: none !important; }
  .workspace { height: var(--vv, 100dvh); }
  .preview-col { display: none !important; }
  #mLiveHead { display: none; }

  .workspace.mv-live .preview-col {
    display: flex !important; flex-direction: column; position: fixed; left: 0; right: 0; width: 100%; padding: 0; z-index: 1;
    top: var(--top, 112px); bottom: calc(var(--tb, 72px) + var(--hh, 56px) + var(--sh, 0px)); transition: bottom .22s cubic-bezier(.2,.7,.2,1);
  }
  .workspace.mv-live.dragging .preview-col, .workspace.mv-live.dragging .editor-col, .workspace.mv-live.dragging #mLiveHead { transition: none !important; }
  .workspace.mv-live .pv-toolbar { padding: 8px 12px; justify-content: center; flex: 0 0 auto; background: #0b1324; }
  .pv-seg:has([data-pv-device]), .pv-seg:has([data-pv-os]), .pv-sep { display: none !important; }
  .pv-seg button { min-height: 36px; padding: 0 18px; }
  .pv-bottom-bar { display: none; }
  .pv-stage, .pv-stage.is-demo { flex: 1 1 auto; min-height: 0; padding: 0 !important; background: #0b1324; }
  .pv-stage .pv-demo-wrap { display: none !important; }
  .pv-stage #pvFrameWrap, .pv-stage.is-demo #pvFrameWrap {
    display: flex !important; width: 100% !important; max-width: none !important; height: 100% !important; aspect-ratio: auto !important;
    border-radius: 0 !important; margin: 0 !important; }
  .pv-frame-overlay { display: none !important; }
  .pv-frame-wrap .pv-iframe { position: static !important; width: 100%; height: 100% !important; padding: 0 !important; border-radius: 0 !important; background: #fff; }

  .workspace.mv-live .editor-col {
    position: fixed; left: 0; right: 0; bottom: var(--tb, 72px); height: var(--sh, 300px); z-index: 5; width: 100%;
    padding: 6px 14px 28px; background: #0b1324; transition: height .22s cubic-bezier(.2,.7,.2,1);
  }
  .workspace.mv-live[data-sheet="min"] .editor-col { display: none; }
  .workspace.mv-live #mLiveHead {
    display: flex; flex-direction: column; position: fixed; left: 0; right: 0; z-index: 6; height: var(--hh, 56px);
    bottom: calc(var(--tb, 72px) + var(--sh, 0px)); background: #131d33; border-radius: 20px 20px 0 0; border-top: 1px solid rgba(255,255,255,.10);
    box-shadow: 0 -16px 32px -14px rgba(0,0,0,.75); transition: bottom .22s cubic-bezier(.2,.7,.2,1); touch-action: none;
  }
  .m-grab { flex: 0 0 18px; display: flex; align-items: center; justify-content: center; }
  .m-grab::before { content: ""; width: 40px; height: 4px; border-radius: 4px; background: #4a5d82; }
  .m-head-row { flex: 1; display: flex; align-items: center; gap: 4px; padding: 0 8px 4px 16px; min-height: 0; }
  .m-head-title { flex: 1; font: 800 14px 'Inter', sans-serif; color: #f8fafc; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .m-head-btn { width: 40px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; color: #cbd5e1; border-radius: 10px; }
  .m-head-btn:disabled { opacity: .35; }
  .m-head-btn:active { background: rgba(255,255,255,.08); }
  .m-head-btn svg { width: 20px; height: 20px; }
  .m-head-btn.chev svg { transition: transform .2s; }
  .workspace[data-sheet="min"] .m-head-btn.chev svg { transform: rotate(180deg); }

  /* Fuera del modo en vivo (Inicio): contenido normal con aire para la barra inferior */
  .workspace:not(.mv-live) .editor-col { padding-bottom: calc(92px + env(safe-area-inset-bottom)); }

  /* Barra inferior */
  .m-tabbar { display: grid; grid-template-columns: repeat(6, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: rgba(11,18,34,.96); backdrop-filter: blur(14px);
    border-top: 1px solid rgba(255,255,255,.10); box-shadow: 0 -10px 30px -12px rgba(0,0,0,.6); }
  .m-tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; height: 56px; border: 0; background: transparent;
    color: #94a3b8; font: 600 10.5px 'Inter', sans-serif; border-radius: 14px; position: relative; }
  .m-tab svg { width: 22px; height: 22px; }
  .m-tab.active { color: #fff; background: linear-gradient(160deg, #0ea5e9, #0369a1); box-shadow: 0 8px 18px -8px rgba(2,132,199,.8); }

  /* Hojas inferiores */
  .m-scrim { display: block; position: fixed; inset: 0; z-index: 91; background: rgba(2,6,15,.55); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .m-scrim.open { opacity: 1; pointer-events: auto; }
  .m-sheet { display: block; position: fixed; left: 8px; right: 8px; bottom: calc(var(--tb, 72px) + 8px); z-index: 92; padding: 8px 10px 12px;
    background: #131d33; border: 1px solid #24324f; border-radius: 22px; box-shadow: 0 -20px 50px -10px rgba(0,0,0,.7);
    transform: translateY(24px); opacity: 0; pointer-events: none; transition: transform .22s cubic-bezier(.2,.7,.2,1), opacity .18s; }
  .m-sheet.open { transform: none; opacity: 1; pointer-events: auto; }
  .m-sheet-grab { width: 38px; height: 4px; border-radius: 4px; background: #35476b; margin: 4px auto 10px; }
  .m-sheet-title { font: 800 13px 'Inter', sans-serif; color: #94a3b8; letter-spacing: .06em; text-transform: uppercase; padding: 0 8px 8px; }
  .m-sheet-item { display: flex; align-items: center; gap: 14px; width: 100%; height: 54px; padding: 0 12px; border: 0; background: transparent;
    color: #f8fafc; font: 600 15px 'Inter', sans-serif; border-radius: 14px; text-align: left; }
  .m-sheet-item:active { background: rgba(2,132,199,.18); }
  .m-sheet-item svg { width: 22px; height: 22px; color: #38bdf8; flex: 0 0 auto; }

  /* Inicio */
  .home-wrap { padding: 12px 10px 0; }
  .home-container { padding: 22px 14px 20px; gap: 20px; margin: 4px auto 14px; }
  .home-title { font-size: 20px; }
  .home-subtitle { font-size: 13px; }
  .home-actions-grid { gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .home-act-card { padding: 16px 10px; min-height: 132px; }
  .home-act-card h3 { font-size: 14px; }
  .home-act-card p { font-size: 11px; }
  .home-recents-head > div:last-child { width: 100%; }
  #homeServerSearch { flex: 1; width: auto !important; }

  /* Ventanas emergentes como hoja inferior */
  .cms-modal-backdrop { align-items: flex-end; padding: 0; }
  .cms-modal { max-width: 100% !important; width: 100%; max-height: 92dvh; overflow-y: auto; border-radius: 22px 22px 0 0;
    padding: 20px 16px calc(18px + env(safe-area-inset-bottom)); }
  .cms-modal-foot { gap: 10px; flex-wrap: wrap; }
  .cms-modal-foot > div { width: 100%; }
  .cms-modal-foot .btn, #publishNowBtn { flex: 1 1 100%; min-height: 48px; justify-content: center; }
  #publishNowBtn { order: -1; }
  .exp-tab { min-height: 44px; }
  #toast, .toast { bottom: calc(86px + env(safe-area-inset-bottom)); }

  /* Logo compacto: solo el isotipo */
  .tb-brand { flex: 0 0 76px !important; width: 76px !important; height: 34px; overflow: hidden;
    background: url('../recursos/logo-app-dark.svg') left center / auto 100% no-repeat !important; }
  .tb-brand .tb-logo-img { display: none !important; }

  /* Días: dos por fila, y Agregar / Eliminar debajo (2 + 2) */
  .days-bar { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .day-label-full { display: inline !important; }
  .day-num-short { display: none !important; }
  .days-bar .btn-lbl, .sch-top-actions .btn-lbl { display: inline !important; }
  .days-bar .day-pill, .days-bar .btn { min-height: 46px; }

  /* Acciones de cabecera: principal arriba, secundarias en 2 columnas */
  .sch-top-actions { display: grid !important; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
  .sch-top-actions .btn { justify-content: center; padding: 8px 10px; }
  .sch-top-actions .btn.brand { grid-column: 1 / -1; order: -1; }
  .panel-head > div:last-child[style] { display: grid !important; grid-template-columns: 1fr 1fr; gap: 8px !important; width: 100%; }
  .panel-head > div:last-child[style] .btn { justify-content: center; white-space: normal; text-align: center; line-height: 1.2; }
  .panel-head > div:last-child[style] .btn.brand { grid-column: 1 / -1; order: -1; }

  /* Filas de charlas legibles */
  .sess-row { gap: 10px; padding: 10px 10px; }
  .sess-time-inp { width: 62px !important; font-size: 14px; padding: 6px 4px; }
  .sess-title { font-size: 14px; }
  .sess-row .btn, .sess-row button { min-width: 40px; min-height: 40px; }
}
@media (max-width: 860px) { .m-sheet-sep { height: 1px; background: #24324f; margin: 6px 10px; } .m-sheet { max-height: 70dvh; overflow-y: auto; } }
/* ===== Interfaz limpia: barra superior de una sola fila, selector flotante, menos botones ===== */
@media (max-width: 860px) {
  .workspace.mv-live .pv-toolbar { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 4; padding: 0; background: rgba(8,13,26,.72); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,.14); border-radius: 999px; box-shadow: 0 6px 18px rgba(0,0,0,.45); }
  .workspace.mv-live .pv-toolbar .pv-seg { background: transparent; border: 0; padding: 3px; }
  .workspace.mv-live .pv-toolbar .pv-seg button { min-height: 32px; padding: 0 16px; border-radius: 999px; font-size: 12px; }
  .tb-status-badge .tb-status-ic { display: none !important; }
  .tb-status-badge { min-width: 0; padding: 0 !important; background: transparent !important; border: 0 !important; width: 20px; justify-content: center; }
  .tb-title-input { background: transparent !important; border-color: transparent !important; font-weight: 700; }
  .tb-title-input:focus { background: rgba(255,255,255,.06) !important; border-color: #24324f !important; }
  .m-head-btn[data-m-click-id="exportJsonBtn"] { display: none; }
  .m-tab[data-m-tab="preview"] { display: none; }
  .m-tabbar { grid-template-columns: repeat(5, 1fr) !important; }
}
/* Barra superior mínima: solo nombre + Publicar */
@media (max-width: 860px) {
  .tb-brand, .tb-status-badge { display: none !important; }
  .tb-title-input { flex: 1 1 auto; min-width: 0; font-size: 16px; }
  .topbar .tb-left { gap: 10px; flex: 1; min-width: 0; }
}
/* Barra inferior deslizante + Inicio arriba */
@media (max-width: 860px) {
  .m-tabbar { display: flex !important; overflow-x: auto; overflow-y: hidden; gap: 4px; padding-left: 8px; padding-right: 8px; scrollbar-width: none; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
  .m-tabbar::-webkit-scrollbar { display: none; }
  .m-tabbar .m-tab { flex: 0 0 auto; min-width: 66px; scroll-snap-align: center; }
  .m-tab[data-m-tab="preview"] { display: none; }
  .m-homebtn { flex: 0 0 auto; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 14px; border: 1px solid #24324f; background: #131d33; color: #e2e8f0; }
  .m-homebtn svg { width: 22px; height: 22px; }
  .m-homebtn:active { background: #1b2a47; }
}
@media (min-width: 861px) { .m-homebtn { display: none !important; } }
@media (max-width: 860px) { .workspace.mv-live .pv-toolbar { left: 12px !important; transform: none !important; } }
/* Flechas para reordenar (solo celular) */
.sess-move { display: none !important; }
@media (max-width: 860px) {
  .sess-move { display: inline-flex !important; }
  .sess-move:disabled { opacity: .28; }
  .sess-actions { gap: 2px; }
  .drag-handle { display: none !important; }
}
@media (max-width: 860px) {
  .sess-actions [data-act="preview-sess"] { display: none !important; }
  .sess-time-inp { width: 64px !important; min-width: 0; padding-left: 6px; padding-right: 6px; font-size: 14px; }
  .workspace.mv-live .pv-toolbar { top: auto !important; bottom: 10px; left: auto !important; right: 12px; }
}
@media (max-width: 860px) { .workspace.mv-live .preview-col { height: auto !important; min-height: 0 !important; max-height: none !important; } }

/* Pastilla Portada / Programa: arriba, solo dos íconos */
@media (max-width: 860px) {
  .workspace.mv-live .pv-toolbar { top: 8px !important; bottom: auto !important; left: 50% !important; right: auto !important; transform: translateX(-50%) !important; }
  .workspace.mv-live .pv-toolbar .pv-seg button.m-pv-ic { min-height: 34px; width: 44px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
  .m-pv-ic svg { width: 19px; height: 19px; }
}
.tap-flash { outline: 2px solid #38bdf8 !important; outline-offset: -2px; border-radius: 12px; animation: tapf 1.6s ease-out; }
@keyframes tapf { 0% { box-shadow: 0 0 0 6px rgba(56,189,248,.45); } 100% { box-shadow: 0 0 0 0 rgba(56,189,248,0); } }
/* Inicio: 4 botones en una sola fila y sin temblor al tocar */
.home-act-card { touch-action: manipulation; -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; }
@media (hover: none), (max-width: 860px) {
  .home-act-card, .home-act-card:hover, .home-act-card:active, .home-act-card:focus { transform: none !important; transition: background-color .12s, border-color .12s !important; }
  .home-act-card:hover { box-shadow: none !important; }
  .home-act-card:active { background: rgba(14,165,233,.16) !important; border-color: #0ea5e9 !important; }
}
@media (max-width: 860px) {
  .home-actions-grid { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; gap: 6px !important; align-items: stretch; }
  .home-act-card { padding: 12px 3px 10px !important; gap: 7px !important; min-width: 0; justify-content: flex-start; }
  .home-act-card p { display: none !important; }
  .home-act-card h3 { font-size: 10.5px !important; line-height: 1.2; font-weight: 800; overflow-wrap: anywhere; hyphens: auto; }
  .home-act-ic { width: 36px !important; height: 36px !important; border-radius: 11px !important; }
  .home-act-ic svg { width: 19px !important; height: 19px !important; }
}
@media (max-width: 860px) {
  .home-recents-section .input { min-width: 0; flex: 1 1 0; }
  [data-act="refresh-server-projects"] { flex: 0 0 auto; padding-left: 10px; padding-right: 10px; white-space: nowrap; }
}
