/* LYRICAMUNDO — Mobile/PWA layer.
   All rules are gated to small/coarse viewports; desktop files stay untouched.
   Loaded after kit.css so equal-specificity rules win on mobile only. */

@media (max-width: 1099px) {
    html, body { overscroll-behavior-y: none; }
    body {
        min-height: 100vh;
        min-height: 100dvh;                 /* Adressleiste ein-/ausblenden */
        padding-bottom: calc(160px + env(safe-area-inset-bottom));
        -webkit-touch-callout: none;        /* kein iOS-Longpress-Menü */
    }
    #page-header { top: env(safe-area-inset-top); }
    #page-header-warnings { min-width: 0; }

    /* iOS zoomt nicht automatisch, wenn ein Feld <16px ist. */
    input:not([type="range"]):not([type="checkbox"]):not(.swatch),
    select, textarea { font-size: 16px; }

    /* Bei offener Tastatur dürfen feste Leisten das Feld nicht verdecken.
       Im Auswahlmodus ersetzt die Bulk-Leiste die Tab-Leiste. */
    body:has(input:focus, textarea:focus, select:focus) #action-dock,
    body:has(input:focus, textarea:focus, select:focus) .bulk-bar,
    body:has(.bulk-bar:not(.hidden)) #action-dock { display: none; }
    .bulk-bar { z-index: 71; }

    /* Dialoge: Safe-Area, dynamische Höhe, über dem Dock. */
    .video-modal, .transcript-modal {
        padding: calc(12px + env(safe-area-inset-top)) env(safe-area-inset-right)
                 calc(12px + env(safe-area-inset-bottom)) env(safe-area-inset-left);
        overscroll-behavior: contain;
    }
    #video-modal { z-index: 95; }
    #video-modal .video-modal-close { z-index: 96; }
    .video-modal-close, #song-modal .video-modal-close,
    #transcript-modal .video-modal-close {
        top: calc(14px + env(safe-area-inset-top));
        right: calc(18px + env(safe-area-inset-right));
    }
    .video-modal video { max-height: 88dvh; }
    .transcript-panel { max-height: 88dvh; }
    #song-modal .transcript-panel { max-height: 84dvh; }
    .dk-select__listbox { max-height: min(320px, 45dvh); }

    /* Touch-Ziele, die in den Basis-Regeln unter 44px bleiben. */
    .q-effect, .q-cancel, .video-modal-close,
    .sp-play-btn, .sp-toggle, .q-move { min-height: 44px; }
    .q-cancel { padding: 10px 12px; }
    .video-modal-close, .sp-play-btn { width: 44px; height: 44px; }
    .sp-toggle { padding: 0 4px; }
    .sp-handle::after { content: ''; position: absolute; inset: 0 -18px; }
    .sp-slider, .sp-volume { height: 44px; background-clip: content-box; }
    .sp-slider::-webkit-slider-thumb, .sp-volume::-webkit-slider-thumb { width: 24px; height: 24px; }
    .sp-slider::-moz-range-thumb, .sp-volume::-moz-range-thumb { width: 24px; height: 24px; }
    .sp-wave-wrap, .brand-logo, .card-cover, #action-dock { -webkit-user-select: none; user-select: none; }
    .queue-item { flex-wrap: wrap; }
    .q-moves { display: flex; gap: 4px; margin-left: 0; }
    .q-move { min-width: 44px; padding: 0 8px; font-size: 18px; }

    .render-bubble .rb-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

    /* In-App-Meldung statt system- alert() auf Touch-Geräten. */
    .mobile-toast {
        position: fixed;
        left: var(--space-4); right: var(--space-4);
        bottom: calc(16px + env(safe-area-inset-bottom));
        z-index: 120;
        padding: 12px;
        background: var(--surface-raised);
        border: 1px solid var(--border-strong);
        color: var(--text);
        font: 14px/1.4 var(--font-ui);
        box-shadow: var(--shadow-pop);
    }
    .mobile-toast[hidden] { display: none; }
    .mobile-toast button {
        margin-left: 8px; min-height: 44px;
        background: var(--accent); color: var(--on-accent);
        border: 0; padding: 0 12px; font: inherit;
    }
}

@media (max-width: 1099px) and (pointer: coarse) {
    .sp-wave-wrap { touch-action: none; }
}

@media (max-width: 1099px) and (prefers-reduced-motion: reduce) {
    .progress-fill, input, button, .download-btn, .archive-dl { transition: none !important; }
}

@media (max-width: 1099px) and (forced-colors: active) {
    [aria-pressed="true"], .archive-tab.active,
    .drawer-submenu-btn.active { outline: 2px solid Highlight; outline-offset: -2px; }
}

@media (max-width: 600px) {
    #page-header { flex-wrap: wrap; }
    .page-header-warnings { order: 3; flex: 1 1 100%; justify-content: flex-start; }
    .sp-transport { flex-wrap: wrap; }
    .sp-volume { flex: 1 1 60px; width: auto; }
    .sp-summary { flex: 1 1 100%; margin-left: 0; white-space: normal; }
    .transcript-panel { width: 100vw; }
    #song-modal { padding-top: env(safe-area-inset-top); }
}
