/* =====================================================
   DESKTOP.CSS
   Sistema de escritorio para ≥ 1180px
   Ventanas flotantes con drag, resize y taskbar
   ===================================================== */

/* ─────────────────────────────────────────────────────
   Solo activo en modo escritorio
   ───────────────────────────────────────────────────── */
@media (min-width: 1180px) {

  /* ── Fondo del escritorio ── */
  #desktopBackground {
    position: fixed;
    inset: 0;
    z-index: 0;
    background:
      radial-gradient(ellipse at 20% 30%, rgba(102, 126, 234, 0.18) 0%, transparent 55%),
      radial-gradient(ellipse at 80% 70%, rgba(118, 75, 162, 0.15) 0%, transparent 55%),
      linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
    /* Grilla sutil tipo blueprint */
    background-image:
      radial-gradient(ellipse at 20% 30%, rgba(102, 126, 234, 0.18) 0%, transparent 55%),
      radial-gradient(ellipse at 80% 70%, rgba(118, 75, 162, 0.15) 0%, transparent 55%),
      linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
      linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
    background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px, 100% 100%;
  }

  [data-theme="light"] #desktopBackground {
    background:
      radial-gradient(ellipse at 20% 30%, rgba(102, 126, 234, 0.1) 0%, transparent 55%),
      radial-gradient(ellipse at 80% 70%, rgba(118, 75, 162, 0.08) 0%, transparent 55%),
      linear-gradient(rgba(0, 0, 0, 0.04) 1px, transparent 1px),
      linear-gradient(90deg, rgba(0, 0, 0, 0.04) 1px, transparent 1px),
      linear-gradient(135deg, #e2e8f0 0%, #f1f5f9 50%, #e2e8f0 100%);
    background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px, 100% 100%;
  }

  /* ── Tapiz por skin ── */
  [data-skin="lavanda"] #desktopBackground {
    background-image:
      radial-gradient(ellipse at 25% 25%, rgba(130, 100, 220, 0.25) 0%, transparent 55%),
      radial-gradient(ellipse at 75% 75%, rgba(90, 60, 180, 0.2) 0%, transparent 55%),
      linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
      linear-gradient(135deg, #1a1630 0%, #2a1f50 50%, #1a1630 100%);
    background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px, 100% 100%;
  }

  [data-theme="light"][data-skin="lavanda"] #desktopBackground {
    background-image:
      radial-gradient(ellipse at 25% 25%, rgba(130, 100, 220, 0.18) 0%, transparent 55%),
      radial-gradient(ellipse at 75% 75%, rgba(90, 60, 180, 0.12) 0%, transparent 55%),
      linear-gradient(rgba(0, 0, 0, 0.03) 1px, transparent 1px),
      linear-gradient(90deg, rgba(0, 0, 0, 0.03) 1px, transparent 1px),
      linear-gradient(135deg, #dcd5f0 0%, #ece8f8 50%, #dcd5f0 100%);
    background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px, 100% 100%;
  }

  [data-skin="scriptorium"] #desktopBackground {
    background-image:
      radial-gradient(ellipse at 20% 30%, rgba(180, 140, 60, 0.2) 0%, transparent 55%),
      radial-gradient(ellipse at 80% 70%, rgba(100, 70, 20, 0.18) 0%, transparent 55%),
      linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
      linear-gradient(135deg, #1a1208 0%, #2c1e0d 50%, #1a1208 100%);
    background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px, 100% 100%;
  }

  [data-theme="light"][data-skin="scriptorium"] #desktopBackground {
    background-image:
      radial-gradient(ellipse at 20% 30%, rgba(180, 140, 60, 0.15) 0%, transparent 55%),
      radial-gradient(ellipse at 80% 70%, rgba(100, 70, 20, 0.1) 0%, transparent 55%),
      linear-gradient(rgba(0, 0, 0, 0.03) 1px, transparent 1px),
      linear-gradient(90deg, rgba(0, 0, 0, 0.03) 1px, transparent 1px),
      linear-gradient(135deg, #ede8dc 0%, #f7f3ea 50%, #ede8dc 100%);
    background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px, 100% 100%;
  }

  [data-skin="blossom"] #desktopBackground {
    background-image:
      radial-gradient(ellipse at 30% 20%, rgba(220, 60, 120, 0.3) 0%, transparent 55%),
      radial-gradient(ellipse at 70% 80%, rgba(180, 20, 80, 0.22) 0%, transparent 55%),
      linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
      linear-gradient(135deg, #2a0018 0%, #420020 50%, #2a0018 100%);
    background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px, 100% 100%;
  }

  [data-theme="light"][data-skin="blossom"] #desktopBackground {
    background-image:
      radial-gradient(ellipse at 30% 20%, rgba(220, 60, 120, 0.15) 0%, transparent 55%),
      radial-gradient(ellipse at 70% 80%, rgba(180, 20, 80, 0.1) 0%, transparent 55%),
      linear-gradient(rgba(0, 0, 0, 0.03) 1px, transparent 1px),
      linear-gradient(90deg, rgba(0, 0, 0, 0.03) 1px, transparent 1px),
      linear-gradient(135deg, #f8d0e0 0%, #fce8f0 50%, #f8d0e0 100%);
    background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px, 100% 100%;
  }

  [data-skin="ocean"] #desktopBackground {
    background-image:
      radial-gradient(ellipse at 20% 30%, rgba(0, 150, 200, 0.3) 0%, transparent 55%),
      radial-gradient(ellipse at 80% 70%, rgba(0, 80, 160, 0.22) 0%, transparent 55%),
      linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
      linear-gradient(135deg, #001828 0%, #002a40 50%, #001828 100%);
    background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px, 100% 100%;
  }

  [data-theme="light"][data-skin="ocean"] #desktopBackground {
    background-image:
      radial-gradient(ellipse at 20% 30%, rgba(0, 150, 200, 0.15) 0%, transparent 55%),
      radial-gradient(ellipse at 80% 70%, rgba(0, 80, 160, 0.1) 0%, transparent 55%),
      linear-gradient(rgba(0, 0, 0, 0.03) 1px, transparent 1px),
      linear-gradient(90deg, rgba(0, 0, 0, 0.03) 1px, transparent 1px),
      linear-gradient(135deg, #ceeaf5 0%, #e5f5fb 50%, #ceeaf5 100%);
    background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px, 100% 100%;
  }

  [data-skin="sunset"] #desktopBackground {
    background-image:
      radial-gradient(ellipse at 30% 30%, rgba(240, 100, 60, 0.3) 0%, transparent 55%),
      radial-gradient(ellipse at 70% 70%, rgba(180, 60, 140, 0.22) 0%, transparent 55%),
      linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
      linear-gradient(135deg, #1a0815 0%, #2e0f22 50%, #1a0815 100%);
    background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px, 100% 100%;
  }

  [data-theme="light"][data-skin="sunset"] #desktopBackground {
    background-image:
      radial-gradient(ellipse at 30% 30%, rgba(240, 100, 60, 0.15) 0%, transparent 55%),
      radial-gradient(ellipse at 70% 70%, rgba(180, 60, 140, 0.1) 0%, transparent 55%),
      linear-gradient(rgba(0, 0, 0, 0.03) 1px, transparent 1px),
      linear-gradient(90deg, rgba(0, 0, 0, 0.03) 1px, transparent 1px),
      linear-gradient(135deg, #f5d5e0 0%, #fae8f0 50%, #f5d5e0 100%);
    background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px, 100% 100%;
  }

  [data-skin="forest"] #desktopBackground {
    background-image:
      radial-gradient(ellipse at 25% 25%, rgba(40, 160, 80, 0.28) 0%, transparent 55%),
      radial-gradient(ellipse at 75% 75%, rgba(20, 100, 40, 0.2) 0%, transparent 55%),
      linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
      linear-gradient(135deg, #051208 0%, #0d2212 50%, #051208 100%);
    background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px, 100% 100%;
  }

  [data-theme="light"][data-skin="forest"] #desktopBackground {
    background-image:
      radial-gradient(ellipse at 25% 25%, rgba(40, 160, 80, 0.15) 0%, transparent 55%),
      radial-gradient(ellipse at 75% 75%, rgba(20, 100, 40, 0.1) 0%, transparent 55%),
      linear-gradient(rgba(0, 0, 0, 0.03) 1px, transparent 1px),
      linear-gradient(90deg, rgba(0, 0, 0, 0.03) 1px, transparent 1px),
      linear-gradient(135deg, #d0edd8 0%, #e8f5ea 50%, #d0edd8 100%);
    background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px, 100% 100%;
  }

  [data-skin="fire"] #desktopBackground {
    background-image:
      radial-gradient(ellipse at 30% 20%, rgba(255, 100, 0, 0.35) 0%, transparent 55%),
      radial-gradient(ellipse at 70% 80%, rgba(180, 20, 10, 0.25) 0%, transparent 55%),
      linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
      linear-gradient(135deg, #1a0500 0%, #300a00 50%, #1a0500 100%);
    background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px, 100% 100%;
  }

  [data-theme="light"][data-skin="fire"] #desktopBackground {
    background-image:
      radial-gradient(ellipse at 30% 20%, rgba(255, 100, 0, 0.18) 0%, transparent 55%),
      radial-gradient(ellipse at 70% 80%, rgba(180, 20, 10, 0.12) 0%, transparent 55%),
      linear-gradient(rgba(0, 0, 0, 0.03) 1px, transparent 1px),
      linear-gradient(90deg, rgba(0, 0, 0, 0.03) 1px, transparent 1px),
      linear-gradient(135deg, #f5ddd0 0%, #faeee8 50%, #f5ddd0 100%);
    background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px, 100% 100%;
  }

  /* ── Body en modo escritorio: sin padding, overflow hidden ── */
  body {
    padding: 0 !important;
    overflow: hidden;
    background: transparent !important;
  }

  /* Ocultar el layout normal — las ventanas reemplazan todo */
  .app-layout {
    display: none !important;
  }

  /* ── Contenedor de las ventanas flotantes ── */
  #desktopWindowsLayer {
    position: fixed;
    inset: 0;
    bottom: 40px;
    /* espacio para taskbar */
    z-index: 50;
    pointer-events: none;
    /* las ventanas manejan sus propios eventos */
  }

  /* =================================================
     VENTANA BASE
     ================================================= */
  .desktop-window {
    position: fixed;
    display: flex;
    flex-direction: column;
    border-radius: 14px;
    overflow: hidden;
    box-shadow:
      0 28px 72px rgba(0, 0, 0, 0.5),
      0 4px 16px rgba(0, 0, 0, 0.35),
      inset 0 1px 0 rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    pointer-events: all;
    transition: box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 280px;
    min-height: 200px;
    /* El fondo lo pone el contenido interno (.container) */
    background: var(--bg-container);
  }

  .desktop-window:focus-within,
  .desktop-window.focused {
    box-shadow:
      0 36px 90px rgba(0, 0, 0, 0.6),
      0 8px 28px rgba(102, 126, 234, 0.25),
      inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border-color: rgba(102, 126, 234, 0.3);
  }

  /* =================================================
     BARRA DE TÍTULO
     ================================================= */
  .win-titlebar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px;
    height: 42px;
    min-height: 42px;
    background: var(--bg-header);
    color: rgba(255, 255, 255, 0.95);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: var(--font-ui);
    cursor: grab;
    user-select: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
    letter-spacing: 0.02em;
  }

  .win-titlebar:active {
    cursor: grabbing;
  }

  .win-title-icon {
    font-size: 1rem;
  }

  .win-title-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: 0.3px;
  }

  /* ── Botón selector de recurso en título de ventana Desktop ── */
  .win-recursos-selector-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    padding: 3px 10px;
    color: inherit;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
  }

  .win-recursos-selector-btn:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: var(--studio-accent, #c69214);
    color: var(--studio-accent, #f0be3d);
  }

  .win-recursos-sep {
    opacity: 0.5;
    font-size: 0.75rem;
  }

  .win-recursos-active-label {
    color: var(--studio-accent, #f0be3d);
    font-weight: 700;
  }

  .win-recursos-chevron {
    opacity: 0.7;
    transition: transform 0.2s ease;
  }

  .win-recursos-selector-btn:hover .win-recursos-chevron {
    transform: translateY(1px);
    opacity: 1;
  }

  /* ── Controles de ventana ── */
  .win-controls {
    display: flex;
    gap: 6px;
    align-items: center;
  }

  .win-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    font-weight: 700;
    flex-shrink: 0;
  }

  .win-minimize {
    background: rgba(255, 189, 46, 0.85);
    color: #7a4800;
  }

  .win-minimize:hover {
    background: #ffbd2e;
    transform: scale(1.1);
  }

  .win-popout {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary, #e2e8f0);
  }

  .win-popout:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    transform: scale(1.1);
  }

  /* ── Contenido scrollable de la ventana ── */
  .win-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    touch-action: pan-y;
  }

  /* El .container dentro de cada ventana pierde su propio shadow/radius */
  .desktop-window .container {
    max-width: none !important;
    margin: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    width: 100% !important;
    min-height: 100%;
    overflow: visible;
  }

  /* =================================================
     HANDLES DE RESIZE (8 direcciones)
     ================================================= */
  .win-resize-handle {
    position: absolute;
    z-index: 10;
    user-select: none;
  }

  /* Lados */
  .win-resize-n {
    top: 0;
    left: 6px;
    right: 6px;
    height: 5px;
    cursor: n-resize;
  }

  .win-resize-s {
    bottom: 0;
    left: 6px;
    right: 6px;
    height: 5px;
    cursor: s-resize;
  }

  .win-resize-e {
    right: 0;
    top: 6px;
    bottom: 6px;
    width: 5px;
    cursor: e-resize;
  }

  .win-resize-w {
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 5px;
    cursor: w-resize;
  }

  /* Esquinas */
  .win-resize-ne {
    top: 0;
    right: 0;
    width: 12px;
    height: 12px;
    cursor: ne-resize;
  }

  .win-resize-se {
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    cursor: se-resize;
  }

  .win-resize-sw {
    bottom: 0;
    left: 0;
    width: 12px;
    height: 12px;
    cursor: sw-resize;
  }

  .win-resize-nw {
    top: 0;
    left: 0;
    width: 12px;
    height: 12px;
    cursor: nw-resize;
  }

  /* Indicador visual en esquina SE */
  .win-resize-se::after {
    content: '';
    position: absolute;
    bottom: 3px;
    right: 3px;
    width: 8px;
    height: 8px;
    border-right: 2px solid rgba(255, 255, 255, 0.25);
    border-bottom: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 0 0 2px 0;
  }

  /* =================================================
     TASKBAR
     ================================================= */
  #desktopTaskbar {
    overflow: hidden;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.4);
  }

  [data-theme="light"] #desktopTaskbar {
    background: rgba(255, 255, 255, 0.88);
    border-top-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.1);
  }

  .taskbar-left {
    display: flex;
    align-items: center;
    flex-shrink: 0;
  }

  .taskbar-app-name {
    font-size: 0.78rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.6);
    letter-spacing: 0.5px;
    padding-right: 12px;
    border-right: 1px solid rgba(255, 255, 255, 0.12);
  }

  [data-theme="light"] .taskbar-app-name {
    color: rgba(0, 0, 0, 0.45);
  }

  .taskbar-windows {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .taskbar-windows::-webkit-scrollbar {
    display: none;
  }

  .taskbar-win-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.07);
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    height: 28px;
  }

  [data-theme="light"] .taskbar-win-btn {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
    color: rgba(0, 0, 0, 0.65);
  }

  .taskbar-win-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.2);
    color: #fff;
  }

  .taskbar-win-btn.active {
    background: rgba(102, 126, 234, 0.25);
    border-color: rgba(102, 126, 234, 0.5);
    color: #a5b4fc;
  }

  .taskbar-win-btn.minimized {
    opacity: 0.5;
    border-style: dashed;
  }

  .taskbar-right {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    padding-left: 8px;
    border-left: 1px solid rgba(255, 255, 255, 0.12);
  }

  [data-theme="light"] .taskbar-right {
    border-left-color: rgba(0, 0, 0, 0.1);
  }

  #desktopResetLayout {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.55);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
  }

  #desktopResetLayout:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
  }

  [data-theme="light"] #desktopResetLayout {
    border-color: rgba(0, 0, 0, 0.15);
    color: rgba(0, 0, 0, 0.45);
  }

  /* =================================================
     VENTANA: PANEL PRINCIPAL (Biblia)
     ================================================= */
  [id^="desktopWin_"] .win-body,
  .desktop-window .win-body {
    overflow: hidden !important;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    touch-action: pan-y;
  }

  /* Resetear height fijo del app-layout dentro de la ventana */
  [id^="desktopWin_"] .container,
  .desktop-window .container {
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  /* Los paneles de lectura/comparación/concordancia/strong deben crecer */
  [id^="desktopWin_"] .panel-mode,
  .desktop-window .panel-mode {
    flex-shrink: 0;
  }

  /* El contenido con versículos debe ser scrollable */
  [id^="desktopWin_"] .content,
  [id^="desktopWin_"] #content,
  .desktop-window .content,
  .desktop-window #content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
  }

  /* =================================================
     VENTANA: IA PANEL (Modo Escritorio y Ventana Acoplada)
     ================================================= */
  #desktopWinIA .win-body {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 !important;
    overflow: hidden !important;
    width: 100% !important;
    height: 100% !important;
    position: relative !important;
    background: var(--studio-panel-solid, var(--bg-container, #ffffff)) !important;
  }

  #desktopWinIA #iaPanelWrapper,
  #desktopWinIA .ia-modal-backdrop,
  #desktopWinIA .ia-panel-wrapper {
    position: static !important;
    inset: auto !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    padding: 0 !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: none !important;
    z-index: 1 !important;
    font-size: inherit !important;
  }

  #desktopWinIA .ia-modal-card {
    position: static !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    filter: none !important;
    background: transparent !important;
    overflow: hidden !important;
  }

  #desktopWinIA .ia-top-bar {
    display: none !important;
  }

  #desktopWinIA .ia-trigger-bar {
    display: none !important;
  }

  #desktopWinIA .ia-panel {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 !important;
    width: 100% !important;
    height: 100% !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    overflow: hidden !important;
    background: transparent !important;
    min-height: 0 !important;
  }

  #desktopWinIA .ia-tabs {
    flex-shrink: 0 !important;
    display: flex !important;
  }

  #desktopWinIA .ia-tab-panel {
    flex: 1 !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  #desktopWinIA .ia-tab-panel.active {
    display: flex !important;
    flex-direction: column !important;
  }

  #desktopWinIA .ia-results-scroll {
    flex: 1 !important;
    min-height: 0 !important;
    overflow-y: auto !important;
  }

  #desktopWinIA .ia-chat-input-wrapper {
    flex-shrink: 0 !important;
  }

  /* =================================================
     SCROLLBARS personalizados dentro de ventanas
     ================================================= */
  .desktop-window .win-body::-webkit-scrollbar,
  .desktop-window .content::-webkit-scrollbar {
    width: 5px;
  }

  .desktop-window .win-body::-webkit-scrollbar-track {
    background: transparent;
  }

  .desktop-window .win-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
  }

  .desktop-window .win-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
  }

  /* =================================================
     ANIMACIÓN DE APERTURA
     ================================================= */
  @keyframes win-appear {
    from {
      opacity: 0;
      transform: scale(0.96) translateY(8px);
    }

    to {
      opacity: 1;
      transform: scale(1) translateY(0);
    }
  }

  .desktop-window {
    animation: win-appear 0.2s ease forwards;
  }

  /* Los paneles inferiores ahora son el contenido de las ventanas flotantes, 
     por lo que NO los ocultamos aquí por defecto. */


  /* ── Pestañas de modo: solo iconos en escritorio (igual que smartphone) ── */
  #desktopWinMain .tab-text {
    display: none;
  }

  #desktopWinMain .mode-tab {
    padding: 12px 8px;
    gap: 0;
  }

  #desktopWinMain .mode-tabs {
    padding: 0 8px;
  }

  /* =================================================
     OVERLAYS GLOBALES (Asegurar que estén por encima de las ventanas)
     ================================================= */
  .user-panel,
  .sidebar-panel,
  .modal {
    z-index: 100000 !important;
    pointer-events: auto !important;
  }

  /* Asegurar que el z-index del botón de perfil sea accesible */
  .header-actions {
    position: relative;
    z-index: 10001;
  }

  /* =================================================
     VENTANAS CONTEXTUALES: COMMENTARY Y STRONG DICT
     En desktop normal, el panel bottom mobile se oculta.
     El contenido se renderiza en *DesktopInner.
     ================================================= */

  /* Ocultar panel bottom (header+content mobile) dentro de ventanas desktop */
  #desktopWinCommentary .commentary-bottom-panel,
  #desktopWinStrong .strong-bottom-panel {
    display: none !important;
  }

  /* El win-body de commentary y strong actúa como flex container */
  #commentaryDesktopContent,
  #strongDesktopContent {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 !important;
    overflow: hidden !important;
  }

  /* El inner de desktop ocupa todo el espacio disponible */
  #commentaryDesktopInner,
  #strongDesktopInner {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: block;
  }

  /* =================================================
     VENTANA SERMÓN — scroll en modo escritorio
     NOTA: #sermonDesktopContent ES el .win-body de esta ventana.
     Se usa selector de ID único para superar la especificidad
     de la regla genérica .desktop-window .win-body { overflow:hidden }
  ================================================= */
  #desktopWinSermon #sermonDesktopContent {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    min-height: 0 !important;
  }

  /* =================================================
     USER PANEL: posicionar desde abajo (sobre taskbar)
  ================================================= */
  #userPanel.show {
    /* Permitir que el JS controle la posición (top o bottom) */
    max-height: calc(100vh - 60px);
    overflow-y: auto;
  }

  /* =================================================
     SETTINGS PANEL: posicionar desde abajo (sobre taskbar)
  ================================================= */
  .settings-panel.open {
    /* Permitir que el JS controle la posición (top o bottom) */
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    z-index: 100001 !important;
  }



  .biblioteca-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--studio-panel-solid);
    overflow: hidden;
  }

  /* Barra de búsqueda */
  .biblioteca-search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--studio-panel-muted);
    border-bottom: 1px solid var(--studio-line);
    flex-shrink: 0;
  }

  .biblioteca-search-icon {
    color: var(--studio-muted);
    flex-shrink: 0;
  }

  .biblioteca-search-input {
    flex: 1;
    border: none !important;
    background: transparent !important;
    color: var(--studio-ink) !important;
    font-size: 0.82rem !important;
    padding: 0 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    outline: none;
  }

  .biblioteca-search-input::placeholder {
    color: var(--studio-muted);
    font-size: 0.8rem;
  }

  /* Contenido scrollable */
  .biblioteca-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--studio-line) transparent;
  }

  .biblioteca-content::-webkit-scrollbar {
    width: 4px;
  }
  .biblioteca-content::-webkit-scrollbar-thumb {
    background: var(--studio-line);
    border-radius: 2px;
  }

  /* Secciones AT / NT */
  .biblio-section {
    padding: 0 0 8px;
  }

  .biblio-section-title {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px 5px;
    font-family: var(--font-ui);
    font-size: 0.65rem;
    font-weight: 900;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: color-mix(in srgb, var(--studio-accent) 65%, var(--studio-muted));
    position: sticky;
    top: 0;
    background: var(--studio-panel-solid);
    z-index: 1;
  }

  .biblio-section-icon {
    font-size: 0.75rem;
  }

  /* Grid de libros */
  .biblio-books-grid {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 0 6px;
  }

  /* Botón individual de libro */
  .biblio-book-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    border-radius: 9px;
    background: transparent;
    border: none;
    color: var(--studio-ink);
    font-size: 0.82rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.14s, color 0.14s, transform 0.14s;
    min-height: 0;
    width: 100%;
  }

  .biblio-book-btn:hover {
    background: var(--studio-hover);
    transform: translateX(2px);
  }

  .biblio-book-btn.active {
    background: color-mix(in srgb, var(--studio-accent) 16%, transparent);
    color: var(--studio-ink);
    font-weight: 700;
    box-shadow: inset 3px 0 0 var(--studio-accent);
  }

  .biblio-book-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Badge de capítulo activo */
  .biblio-chapter-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--studio-accent);
    color: #111827;
    font-size: 0.66rem;
    font-weight: 900;
    font-family: var(--font-ui);
    flex-shrink: 0;
    margin-left: 6px;
  }

  .biblio-loading,
  .biblio-empty {
    padding: 18px 12px;
    color: var(--studio-muted);
    font-size: 0.82rem;
    font-style: italic;
    text-align: center;
    line-height: 1.5;
  }

  /* =================================================
     TASKBAR PREMIUM — Mejoras visuales con skin-awareness
  ================================================= */

  /* Usar colores del skin activo en la taskbar */
  #desktopTaskbar {
    height: 52px;
    padding: 0 16px;
    background: color-mix(in srgb, var(--studio-chrome, rgba(15,23,42,1)) 95%, black 5%);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 -4px 28px rgba(0, 0, 0, 0.36);
  }

  [data-theme="light"] #desktopTaskbar {
    background: color-mix(in srgb, var(--studio-chrome, rgba(255,255,255,0.9)) 88%, white 12%);
    border-top-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.08);
  }

  /* Nombre de app más elegante */
  .taskbar-app-name {
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    opacity: 0.72;
    color: color-mix(in srgb, var(--studio-accent, #c59a3a) 60%, white 40%);
    padding-right: 14px;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
  }

  [data-theme="light"] .taskbar-app-name {
    color: color-mix(in srgb, var(--studio-accent, #c59a3a) 80%, black 20%);
  }

  /* Botones de ventana en taskbar */
  .taskbar-win-btn {
    height: 30px;
    padding: 0 11px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 700;
    gap: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.7);
  }

  .taskbar-win-btn.active {
    background: color-mix(in srgb, var(--studio-accent) 22%, transparent);
    border-color: color-mix(in srgb, var(--studio-accent) 55%, transparent);
    color: var(--studio-accent);
  }

  /* Reloj */
  .desktop-clock {
    font-size: 0.76rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.65);
    letter-spacing: 0.04em;
    padding-right: 10px;
    font-variant-numeric: tabular-nums;
  }

  [data-theme="light"] .desktop-clock {
    color: rgba(0, 0, 0, 0.45);
  }

  /* Separador derecho antes del reloj */
  #desktopResetLayout {
    width: 30px;
    height: 30px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: rgba(255, 255, 255, 0.5);
    font-size: 1rem;
  }

  #desktopResetLayout:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
  }

  /* Titlebar de ventanas: usa el gradiente del skin */
  .win-titlebar {
    background: linear-gradient(
      145deg,
      var(--studio-chrome, #173553),
      var(--studio-chrome-2, #244d5f)
    );
    color: var(--studio-header-text, #fff8e8);
    font-family: var(--font-ui);
    height: 46px;
    min-height: 46px;
    font-size: 0.83rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  /* Ventana lectura: título con serif */
  #desktopWin_lectura .win-titlebar .win-title-text {
    font-family: var(--font-title);
    font-size: 0.9rem;
  }
}

/* fin @media ≥1180px */

/* ── Adaptar ventanas a contenedores normales en móvil/tablet ── */
@media (max-width: 1179px) {

  #desktopBackground,
  #desktopTaskbar,
  #desktopWindowsLayer {
    display: none !important;
  }

  #commentaryBottomPanel,
  #strongBottomPanel {
    position: fixed !important;
  }

  /* En lugar de ocultar las ventanas, les quitamos su formato para que se vean como antes */
  .desktop-window {
    position: static !important;
    display: block !important;
    width: 100% !important;
    height: auto !important;
    box-shadow: none !important;
    border: none !important;
    background: transparent !important;
    z-index: auto !important;
    transform: none !important;
    min-height: auto !important;
    min-width: auto !important;
  }

  /* Ventanas Bible Panel clonadas: OCULTAR en móvil para evitar contenido duplicado */
  [id^="desktopWin_"] {
    display: none !important;
  }

  /* Ventana de notebook desktop: OCULTAR en móvil (se usa notebookOverlay en su lugar) */
  #desktopWinNotebook {
    display: none !important;
  }

  /* Ocultamos la barra superior de "arrastrar" y los bordes para redimensionar */
  .win-titlebar,
  .win-resize-handle {
    display: none !important;
  }

  /* El body de la ventana pasa a ser un contenedor invisible para no afectar tu diseño móvil */
  .win-body {
    display: contents !important;
  }
}

/* =================================================
   TASKBAR: BOTONES DE AJUSTES Y USUARIO
   ================================================= */
  .taskbar-icon-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.8);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    padding: 0;
    flex-shrink: 0;
    box-sizing: border-box;
    overflow: hidden;
  }

  .taskbar-icon-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
    color: #fff;
  }

  [data-theme="light"] .taskbar-icon-btn {
    border-color: rgba(0, 0, 0, 0.12);
    color: rgba(0, 0, 0, 0.5);
  }

  [data-theme="light"] .taskbar-icon-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    color: rgba(0, 0, 0, 0.8);
  }

  /* ── Icono SVG dentro del botón ── */
  .taskbar-icon-btn svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
  }

  /* ── Botón Auth en taskbar: tamaño fijo pase lo que pase ── */
  .taskbar-auth-btn {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    min-height: 28px !important;
    max-width: 28px !important;
    max-height: 28px !important;
    border-radius: 50% !important;
    padding: 0 !important;
    overflow: hidden !important;
    border: 2px solid rgba(255, 255, 255, 0.2) !important;
    background: rgba(255, 255, 255, 0.08) !important;
    box-sizing: border-box !important;
    flex-shrink: 0 !important;
    position: relative !important;
  }

  .taskbar-auth-btn:hover {
    border-color: rgba(255, 255, 255, 0.4) !important;
    background: rgba(255, 255, 255, 0.15) !important;
  }

  [data-theme="light"] .taskbar-auth-btn {
    border-color: rgba(0, 0, 0, 0.15) !important;
    background: rgba(0, 0, 0, 0.05) !important;
  }

  [data-theme="light"] .taskbar-auth-btn:hover {
    border-color: rgba(0, 0, 0, 0.3) !important;
  }

  /* CUALQUIER hijo directo del botón auth: forzar 100% */
  .taskbar-auth-btn>* {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden !important;
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
  }

  /* Imágenes dentro del botón auth */
  .taskbar-auth-btn img,
  .taskbar-auth-btn>* img {
    width: 100% !important;
    height: 100% !important;
    max-width: 28px !important;
    max-height: 28px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    display: block !important;
  }

  /* Texto/inicial dentro del botón auth */
  .taskbar-auth-btn .auth-btn-initial,
  .taskbar-auth-btn [class*="initial"],
  .taskbar-auth-btn span,
  .taskbar-auth-btn div:not(:empty) {
    width: 24px !important;
    height: 24px !important;
    font-size: 0.65rem !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* SVG (icono de persona no logueado) */
  .taskbar-auth-btn svg {
    width: 15px !important;
    height: 15px !important;
  }


  /* ── Separador taskbar-right ── */
  .taskbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    padding-left: 8px;
    border-left: 1px solid rgba(255, 255, 255, 0.12);
  }

  [data-theme="light"] .taskbar-right {
    border-left-color: rgba(0, 0, 0, 0.1);
  }

  /* ── Settings y User panel: permitir que el JS controle la posición ── */
  #userPanel.show {
    max-height: calc(100vh - 60px);
    overflow-y: auto;
  }

  .settings-panel.open {
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    z-index: 100001 !important;
  }

  /* =================================================
   POPUP MODE (External Windows) - APLICA INDEPENDIENTE DEL ANCHO
   Sobrescribe todas las reglas medias (desktop y móvil)
   ================================================= */
  body.popup-mode {
    padding: 0 !important;
    overflow: hidden !important;
    background: var(--bg-container) !important;
  }

  body.popup-mode .app-layout,
  body.popup-mode #desktopTaskbar,
  body.popup-mode #desktopBackground,
  body.popup-mode header,
  body.popup-mode .mode-tabs,
  body.popup-mode #sidebarPanel {
    display: none !important;
  }

  /* Mostrar la capa de ventanas flotantes *siempre* */
  body.popup-mode #desktopWindowsLayer {
    display: block !important;
    position: static !important;
  }

  /* Formato unificado a pantalla completa */
  body.popup-mode .desktop-window {
    position: fixed !important;
    width: 100vw !important;
    height: 100vh !important;
    top: 0 !important;
    left: 0 !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    z-index: 99999 !important;
    background: var(--bg-container) !important;
    transform: none !important;
  }

  body.popup-mode .desktop-window.popup-active {
    display: flex !important;
  }

  body.popup-mode .desktop-window:not(.popup-active) {
    display: none !important;
  }

  /* Forzar que el interior de la IA ocupe todo en popup-mode */
  body.popup-mode #desktopWinIA .win-body {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 !important;
    overflow: hidden !important;
    width: 100% !important;
    height: 100% !important;
    position: relative !important;
    background: var(--studio-panel-solid, var(--bg-container, #ffffff)) !important;
  }

  body.popup-mode #desktopWinIA #iaPanelWrapper,
  body.popup-mode #desktopWinIA .ia-modal-backdrop,
  body.popup-mode #desktopWinIA .ia-panel-wrapper {
    position: static !important;
    inset: auto !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    padding: 0 !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: none !important;
    z-index: 1 !important;
    font-size: inherit !important;
  }

  body.popup-mode #desktopWinIA .ia-modal-card {
    position: static !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    filter: none !important;
    background: transparent !important;
    overflow: hidden !important;
  }

  body.popup-mode #desktopWinIA .ia-top-bar {
    display: none !important;
  }

  body.popup-mode #desktopWinIA .ia-trigger-bar {
    display: none !important;
  }

  body.popup-mode #desktopWinIA .ia-panel {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 !important;
    width: 100% !important;
    height: 100% !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    overflow: hidden !important;
    background: transparent !important;
    min-height: 0 !important;
  }

  body.popup-mode #desktopWinIA .ia-tabs {
    flex-shrink: 0 !important;
    display: flex !important;
  }

  body.popup-mode #desktopWinIA .ia-tab-panel {
    flex: 1 !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  body.popup-mode #desktopWinIA .ia-tab-panel.active {
    display: flex !important;
    flex-direction: column !important;
  }

  body.popup-mode #desktopWinIA .ia-results-scroll {
    flex: 1 !important;
    min-height: 0 !important;
    overflow-y: auto !important;
  }

  body.popup-mode #desktopWinIA .ia-chat-input-wrapper {
    flex-shrink: 0 !important;
  }

  body.popup-mode .win-titlebar {
    display: flex !important;
    cursor: default !important;
  }

  body.popup-mode .win-body {
    display: block !important;
    flex: 1 !important;
    overflow-y: auto !important;
  }

  body.popup-mode .win-resize-handle,
  body.popup-mode .win-minimize,
  body.popup-mode #desktopResetLayout {
    display: none !important;
  }

  body.popup-mode .container {
    max-width: none !important;
    margin: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    width: 100% !important;
    min-height: 100% !important;
  }

  /* ── SOPORTE PARA DESACOPLE DE BIBLIA (MAIN) ── */
  body.main-torn-off .container {
    display: none !important;
  }

  body.main-torn-off .desktop-background::after {
    content: "Biblia en ventana externa";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.4rem;
    font-family: inherit;
    opacity: 0.7;
    z-index: 9999;
    pointer-events: none;
  }

  /* ── BOTONES DE DESACOPLE EN VISTA REDUCIDA ── */
  .mobile-popout-btn {
    background: rgba(128, 128, 128, 0.1) !important;
    border-radius: 4px;
    margin: 0 4px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    color: inherit;
    font-size: 1rem;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s, transform 0.2s;
  }

  .mobile-popout-btn:hover {
    opacity: 1;
    transform: scale(1.1);
    background: rgba(128, 128, 128, 0.2) !important;
  }

  /* ── POLÍTICA DE SIDECAR POR SISTEMA OPERATIVO (macOS, Windows, Linux) ── */
  body:not(.supports-sidecar) .win-popout,
  body:not(.supports-sidecar) .mobile-popout-btn,
  body:not(.supports-sidecar) #commentaryPopoutBtn,
  body:not(.supports-sidecar) #strongPopoutBtn,
  body:not(.supports-sidecar) #iaPopoutBtn,
  body:not(.supports-sidecar) #recursosMenuPopoutBtn,
  body.no-sidecar .win-popout,
  body.no-sidecar .mobile-popout-btn,
  body.no-sidecar #commentaryPopoutBtn,
  body.no-sidecar #strongPopoutBtn,
  body.no-sidecar #iaPopoutBtn,
  body.no-sidecar #recursosMenuPopoutBtn {
    display: none !important;
    pointer-events: none !important;
  }

  .recursos-menu-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }

  #recursosMenuPopoutBtn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--studio-panel-muted, rgba(120, 120, 120, 0.1));
    color: var(--text-muted, #666);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #recursosMenuPopoutBtn:hover {
    background: var(--studio-panel-hover, rgba(120, 120, 120, 0.2));
    color: var(--text, #111);
    transform: scale(1.05);
  }

  /* Ocultar botones de popout si estamos en el modo tapiz (desktop) */
  @media (min-width: 1180px) {
    .mobile-popout-btn {
      display: none !important;
    }
  }

  /* Forzar que la Biblia y paneles ocupen todo el espacio en modo popup */
  body.popup-mode #desktopWinMain.popup-active,
  body.popup-mode #desktopWinStrong.popup-active,
  body.popup-mode #desktopWinCommentary.popup-active,
  body.popup-mode #desktopWinIA.popup-active,
  body.popup-mode #desktopWin_concordancia.popup-active {
    width: 100% !important;
    height: 100% !important;
    top: 0 !important;
    left: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    display: flex !important;
    flex-direction: column !important;
  }

  body.popup-mode .desktop-window.popup-active .win-titlebar {
    display: none !important;
  }

  /* La ventana de Recursos (Concordancia/Biblioteca) sí muestra su barra de título con selector en popup */
  body.popup-mode #desktopWin_concordancia.popup-active .win-titlebar,
  body.popup-mode #desktopWin_concordancia .win-titlebar {
    display: flex !important;
    cursor: default !important;
  }

  body.popup-mode #desktopWin_concordancia.popup-active .win-titlebar .win-recursos-selector-btn {
    pointer-events: auto !important;
    cursor: pointer !important;
  }

  body.popup-mode .desktop-window.popup-active .win-body {
    height: 100% !important;
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
  }

  /* ── Sobrescribir paneles inferiores para que actúen como cabeceras en Popups ── */
  body.popup-mode .strong-bottom-panel,
  body.popup-mode .commentary-bottom-panel {
    position: relative !important;
    transform: none !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    flex: 0 0 auto !important;
    /* Cabecera con alto automático */
    width: 100% !important;
    background-color: var(--header-bg) !important;
    border-bottom: 2px solid var(--accent-light) !important;
    display: block !important;
    z-index: 10 !important;
  }

  body.popup-mode .strong-bottom-header,
  body.popup-mode .commentary-bottom-header {
    order: -1 !important;
    /* Solo por si acaso */
  }


  /* Ocultar botones de cierre/popout que ya no tienen sentido aquí */
  body.popup-mode .mobile-popout-btn,
  body.popup-mode .commentary-close-btn,
  body.popup-mode .strong-close-btn {
    display: none !important;
  }

  /* Ocultar las flechas de minimizar/maximizar dentro del popup (redundantes) */
  body.popup-mode #strongBottomMinimize,
  body.popup-mode #strongBottomMaximize,
  body.popup-mode #commentaryBottomMinimize,
  body.popup-mode #commentaryBottomMaximize {
    display: none !important;
  }

  /* El contenido móvil interno debe estar oculto */
  body.popup-mode .strong-bottom-content,
  body.popup-mode .commentary-bottom-content {
    display: none !important;
  }

  /* Forzar que el contenedor desktop ocupe el resto y sea scrolleable */
  body.popup-mode #strongDesktopContent,
  body.popup-mode #commentaryDesktopContent {
    flex: 1 1 auto !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    height: auto !important;
    min-height: 0 !important;
  }

  body.popup-mode #strongDesktopInner,
  body.popup-mode #commentaryDesktopInner {
    flex: 1 1 auto !important;
    display: block !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 15px !important;
  }

/* ── Custom taskbar structured title next to logo ── */
@media (min-width: 1180px) {
  .taskbar-logo {
    width: 26px;
    height: 26px;
    margin-right: 8px;
    flex-shrink: 0;
    object-fit: contain;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.25));
  }

  .taskbar-app-name.structured {
    display: inline-flex;
    align-items: baseline;
    gap: 5px;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    padding-right: 14px;
    line-height: 1;
  }

  [data-theme="light"] .taskbar-app-name.structured {
    border-right-color: rgba(0, 0, 0, 0.08);
  }

  .taskbar-brit {
    font-family: 'Playfair Display', Georgia, serif;
    font-style: italic;
    font-weight: 600;
    font-size: 0.85rem;
    color: inherit;
    text-transform: none;
  }

  .taskbar-bible {
    font-family: 'Cinzel', serif;
    font-weight: 800;
    font-size: 0.98rem;
    letter-spacing: 0.04em;
    color: inherit;
  }
}

/* ── Corrección de Errores: Selección en Taskbar y Capítulos Biblioteca ── */
@media (min-width: 1180px) {
  /* Ocultar el botón flotante de copia siempre en modo escritorio */
  #copyVersesBtn.floating-action-button {
    display: none !important;
  }

  /* Contenedor de selección en la taskbar */
  .taskbar-selection {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    margin: 0 10px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
  }
  .taskbar-selection::-webkit-scrollbar {
    height: 3px;
  }
  .taskbar-selection::-webkit-scrollbar-thumb {
    background: var(--studio-line);
    border-radius: 3px;
  }

  .taskbar-selection-count {
    font-size: 0.80rem;
    font-weight: 700;
    color: var(--studio-ink);
    margin-right: 4px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* Botones de selección en la taskbar */
  .taskbar-selection-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    height: 28px;
    padding: 0 8px;
    border-radius: 6px;
    background: var(--studio-panel);
    border: 1px solid var(--studio-line);
    color: var(--studio-ink);
    font-size: 0.76rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.12s ease;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .taskbar-selection-btn:hover {
    background: var(--studio-hover);
    border-color: var(--studio-accent);
    transform: translateY(-1px);
  }

  .taskbar-selection-btn.close {
    font-size: 1.15rem;
    font-weight: 700;
    padding: 0 6px;
    color: var(--text-muted);
    background: transparent;
    border: none;
    margin-right: 4px;
  }
  .taskbar-selection-btn.close:hover {
    color: var(--studio-accent);
    background: transparent;
    transform: none;
  }

  @media (max-width: 1650px) {
    .taskbar-selection-btn {
      padding: 0 6px;
      min-width: 28px;
    }
    .taskbar-selection-btn span:not(.taskbar-selection-count) {
      display: none;
    }
    .taskbar-selection-btn .taskbar-btn-icon-img {
      margin: 0;
    }
  }

  /* Estilos de la cuadrícula de capítulos en la biblioteca */
  .biblio-chapters-container {
    padding: 8px 10px;
    background: var(--studio-background);
    border-radius: 8px;
    margin: 4px 6px 8px 6px;
    border: 1px solid var(--studio-line);
    animation: fadeIn 0.2s ease-out;
  }

  .biblio-ch-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
  }

  .biblio-ch-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    border-radius: 6px;
    background: var(--studio-panel);
    border: 1px solid var(--studio-line);
    color: var(--studio-ink);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.12s ease;
  }

  .biblio-ch-btn:hover {
    background: var(--studio-hover);
    border-color: var(--studio-accent);
  }

  .biblio-ch-btn.active {
    background: var(--studio-accent);
    color: #ffffff;
    border-color: var(--studio-accent);
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  }

  .loading-chapters {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
    text-align: center;
    padding: 6px 0;
  }

  .loading-chapters-error {
    font-size: 0.75rem;
    color: #ff4d4d;
    display: block;
    text-align: center;
    padding: 6px 0;
  }

  @keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
  }

  /* Paleta de subrayado en la taskbar */
  .taskbar-hl-palette {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--studio-background);
    padding: 3px 8px;
    border-radius: 20px;
    border: 1px solid var(--studio-line);
    margin-right: 8px;
    flex-shrink: 0;
  }

  .taskbar-hl-palette .mhl-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: transform 0.1s ease;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    line-height: 1;
  }

  .taskbar-hl-palette .mhl-dot:hover {
    transform: scale(1.25);
  }

  .taskbar-hl-palette .mhl-dot.yellow { background-color: #ffd54f; }
  .taskbar-hl-palette .mhl-dot.blue { background-color: #90caf9; }
  .taskbar-hl-palette .mhl-dot.pink { background-color: #f48fb1; }
  .taskbar-hl-palette .mhl-dot.orange { background-color: #ffb74d; }
  .taskbar-hl-palette .mhl-dot.green { background-color: #a5d6a7; }
  .taskbar-hl-palette .mhl-dot.red { background-color: #ef9a9a; }
  .taskbar-hl-palette .mhl-dot.clear {
    background-color: var(--studio-panel);
    color: var(--studio-ink);
    border: 1px solid var(--studio-line);
    font-weight: bold;
  }

  /* Icono premium de los botones */
  .taskbar-btn-icon-img {
    width: 15px;
    height: 15px;
    object-fit: contain;
    display: block;
    flex-shrink: 0;
  }

  /* Popovers flotantes de la Barra de Herramientas de Selección (Escritorio) */
  .taskbar-popover {
    position: fixed;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    width: 320px;
    background: var(--studio-panel);
    border: 1px solid var(--studio-line);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    z-index: 3500;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: taskbarPopoverFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  [data-theme="dark"] .taskbar-popover {
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
  }

  @keyframes taskbarPopoverFadeIn {
    from { opacity: 0; transform: translateX(-50%) translateY(8px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
  }

  .taskbar-popover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--studio-line);
  }

  .taskbar-popover-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--studio-ink);
  }

  .taskbar-popover-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
  }

  .taskbar-popover-close:hover {
    color: var(--studio-accent);
  }

  .taskbar-popover-textarea {
    width: 100%;
    background: var(--studio-background);
    border: 1px solid var(--studio-line);
    border-radius: 6px;
    color: var(--studio-ink);
    padding: 8px;
    font-size: 0.8rem;
    font-family: inherit;
    resize: none;
    box-sizing: border-box;
    outline: none;
  }

  .taskbar-popover-textarea:focus {
    border-color: var(--studio-accent);
  }

  .taskbar-popover-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
  }

  .taskbar-popover-btn {
    height: 26px;
    padding: 0 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.1s ease;
    border: 1px solid var(--studio-line);
    background: var(--studio-background);
    color: var(--studio-ink);
  }

  .taskbar-popover-btn:hover {
    background: var(--studio-hover);
  }

  .taskbar-popover-btn.save {
    background: var(--studio-accent);
    color: #ffffff;
    border-color: var(--studio-accent);
  }

  .taskbar-popover-btn.save:hover {
    filter: brightness(1.05);
  }

  .taskbar-popover-btn.delete {
    color: #ff4d4d;
  }
  .taskbar-popover-btn.delete:hover {
    background: rgba(255, 77, 77, 0.1);
    border-color: #ff4d4d;
  }

  .taskbar-popover-btn.teologo {
    background: var(--studio-accent);
    color: #ffffff;
    border-color: var(--studio-accent);
  }
  .taskbar-popover-btn.teologo:hover {
    filter: brightness(1.05);
  }

  .taskbar-popover-btn.historiador {
    background: #607d8b;
    color: #ffffff;
    border-color: #607d8b;
  }
  .taskbar-popover-btn.historiador:hover {
    filter: brightness(1.05);
  }
}