/* ==========================================================================
   Cancionero Studio Pro - Hoja de Estilos Principal
   Diseño moderno, ergonómico y de alto contraste para músicos y directos
   ========================================================================== */

:root {
    --bg-app: #0f1117;
    --bg-surface: #181b24;
    --bg-surface-2: #1f2430;
    --bg-surface-3: #282e3d;
    --bg-glass: rgba(24, 27, 36, 0.88);
    --border-color: #2e3446;
    --border-subtle: #232836;

    --text-primary: #f3f4f8;
    --text-secondary: #a6b0c3;
    --text-muted: #6e788c;

    --accent-granate: #9b1b30;
    --accent-granate-light: #d6455b;
    --accent-primary: #e03e52;
    --accent-primary-hover: #f05064;
    --accent-primary-soft: rgba(224, 62, 82, 0.14);

    --accent-blue: #3b82f6;
    --accent-blue-soft: rgba(59, 130, 246, 0.14);
    --accent-emerald: #10b981;
    --accent-emerald-soft: rgba(16, 185, 129, 0.14);
    --accent-amber: #f59e0b;
    --accent-amber-soft: rgba(245, 158, 11, 0.15);
    --accent-purple: #8b5cf6;
    --accent-purple-soft: rgba(139, 92, 246, 0.15);

    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 18px 42px rgba(0, 0, 0, 0.5);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg-app: #f4f5f8;
    --bg-surface: #ffffff;
    --bg-surface-2: #f8f9fc;
    --bg-surface-3: #eef0f6;
    --bg-glass: rgba(255, 255, 255, 0.92);
    --border-color: #dce0ea;
    --border-subtle: #e8ebf2;

    --text-primary: #151821;
    --text-secondary: #4a5368;
    --text-muted: #7b849b;

    --accent-granate: #800000;
    --accent-granate-light: #9b1b30;
    --accent-primary: #a61c2b;
    --accent-primary-hover: #800000;
    --accent-primary-soft: rgba(128, 0, 0, 0.1);

    --shadow-sm: 0 2px 5px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 8px 20px rgba(15, 23, 42, 0.09);
    --shadow-lg: 0 18px 40px rgba(15, 23, 42, 0.15);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    min-height: 100vh;
    background-color: var(--bg-app);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Barra Superior (Topbar)
   ========================================================================== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: 64px;
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    gap: 16px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    cursor: pointer;
    user-select: none;
    text-decoration: none;
    color: var(--text-primary);
}

.brand-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, #800000 0%, #d6304a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 19px;
    box-shadow: 0 4px 12px rgba(214, 48, 74, 0.35);
    flex-shrink: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-title {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.brand-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

.topbar-context {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-left: 16px;
    border-left: 1px solid var(--border-color);
}

.active-json-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    padding: 5px 12px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
}

.active-json-pill .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-emerald);
}

.active-json-pill.dirty .dot {
    background: var(--accent-amber);
    box-shadow: 0 0 8px var(--accent-amber);
}

.save-status-badge {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 3px 9px;
    border-radius: 6px;
    background: var(--bg-surface-2);
}

.save-status-badge.unsaved {
    color: var(--accent-amber);
    background: var(--accent-amber-soft);
    font-weight: 600;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* ==========================================================================
   Botones y Controles
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    user-select: none;
    text-decoration: none;
    font-family: inherit;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 6px;
}

.btn-lg {
    padding: 11px 20px;
    font-size: 14px;
    border-radius: var(--radius-md);
}

.btn-icon {
    padding: 7px;
    width: 34px;
    height: 34px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary) 0%, #b51f33 100%);
    color: #ffffff;
    box-shadow: 0 3px 10px rgba(224, 62, 82, 0.28);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--accent-primary-hover) 0%, #c8253b 100%);
    transform: translateY(-1px);
    box-shadow: 0 5px 14px rgba(224, 62, 82, 0.38);
}

.btn-emerald {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    box-shadow: 0 3px 10px rgba(16, 185, 129, 0.25);
}

.btn-emerald:hover:not(:disabled) {
    filter: brightness(1.08);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-surface-2);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-surface-3);
    border-color: var(--text-muted);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-surface-2);
    color: var(--text-primary);
}

.btn-danger-soft {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.25);
}

.btn-danger-soft:hover:not(:disabled) {
    background: #ef4444;
    color: #ffffff;
}

/* ==========================================================================
   Vista Inicial (Landing Dashboard)
   ========================================================================== */
.container {
    max-width: 1460px;
    margin: 0 auto;
    padding: 28px 24px 64px;
}

.hero-banner {
    background: linear-gradient(135deg, rgba(128, 0, 0, 0.24) 0%, rgba(24, 27, 36, 0.9) 65%);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 28px 32px;
    margin-bottom: 26px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
    box-shadow: var(--shadow-md);
}

.hero-info h1 {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 6px;
}

.hero-info p {
    color: var(--text-secondary);
    max-width: 680px;
    font-size: 14px;
}

.hero-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* Métricas rápidas */
.stats-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: var(--shadow-sm);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.stat-icon.granate { background: var(--accent-primary-soft); color: var(--accent-primary); }
.stat-icon.blue { background: var(--accent-blue-soft); color: var(--accent-blue); }
.stat-icon.emerald { background: var(--accent-emerald-soft); color: var(--accent-emerald); }
.stat-icon.amber { background: var(--accent-amber-soft); color: var(--accent-amber); }

.stat-content .stat-value {
    font-size: 22px;
    font-weight: 800;
    line-height: 1.1;
}

.stat-content .stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Pestañas de navegación del Dashboard */
.dashboard-tabs {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}

.tab-buttons {
    display: flex;
    gap: 6px;
}

.tab-btn {
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

/* Grid de Tarjetas de JSON */
.json-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 22px;
}

.json-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
}

.json-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.json-card-header {
    padding: 20px 22px 16px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.json-file-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: 'JetBrains Mono', Consolas, monospace;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-primary);
    background: var(--accent-primary-soft);
    padding: 4px 10px;
    border-radius: 6px;
    margin-bottom: 10px;
}

.json-type-badge {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 4px 9px;
    border-radius: 999px;
}

.json-type-badge.bolo {
    background: var(--accent-amber-soft);
    color: var(--accent-amber);
}

.json-type-badge.catalogo {
    background: var(--accent-blue-soft);
    color: var(--accent-blue);
}

.json-cover-preview {
    background: var(--bg-surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px;
    margin: 0 22px 16px;
    text-align: center;
    position: relative;
}

.json-cover-preview .cover-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.json-cover-preview .cover-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: pre-line;
}

.json-metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 0 22px 16px;
}

.mini-metric {
    background: var(--bg-surface-2);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    text-align: center;
}

.mini-metric .val {
    font-size: 16px;
    font-weight: 800;
    color: var(--text-primary);
    display: block;
}

.mini-metric .lbl {
    font-size: 11px;
    color: var(--text-muted);
}

.json-pdf-strip {
    margin: 0 22px 16px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: var(--bg-surface-2);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 12px;
}

.json-card-footer {
    margin-top: auto;
    padding: 14px 22px;
    background: var(--bg-surface-2);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

/* ==========================================================================
   Editor de Cancionero Abierto (Workspace)
   ========================================================================== */
.editor-layout {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 22px;
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px 24px 80px;
    align-items: start;
}

@media (max-width: 1120px) {
    .editor-layout {
        grid-template-columns: 1fr;
    }
}

/* Panel Lateral Izquierdo: Portada, Subtítulo y Configuración PDF */
.editor-sidebar {
    position: sticky;
    top: 84px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.panel-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.panel-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    font-size: 14px;
    background: var(--bg-surface-2);
}

.panel-body {
    padding: 18px;
}

.form-group {
    margin-bottom: 14px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    transition: border-color var(--transition);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-primary-soft);
}

.form-textarea {
    resize: vertical;
    min-height: 68px;
}

.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 12.5px;
    color: var(--text-secondary);
    margin-top: 9px;
    cursor: pointer;
    user-select: none;
}

.checkbox-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-primary);
    cursor: pointer;
}

/* Mini Vista Previa Interactiva de Portada + Índice en el Sidebar */
.mini-pdf-preview-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.mini-page-canvas-wrap {
    width: 100%;
    aspect-ratio: 1200 / 1920;
    max-height: 330px;
    background: #ffffff;
    color: #000000;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    padding: 18px 16px;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06), var(--shadow-sm);
    overflow: hidden;
    position: relative;
    cursor: pointer;
}

.mini-cover-title {
    margin-top: 22%;
    text-align: center;
    font-size: 20px;
    font-weight: 600;
    color: #000;
    word-break: break-word;
}

.mini-cover-subtitle {
    margin-top: 18%;
    text-align: center;
    font-size: 12px;
    color: #222;
    white-space: pre-line;
}

.mini-index-list {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 10.5px;
    overflow: hidden;
}

.mini-index-item {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-index-item .t {
    color: #800000;
    font-weight: 600;
}

.mini-index-item .a {
    color: #111;
    font-size: 9px;
}

/* ==========================================================================
   Panel Principal de Canciones (Derecha)
   ========================================================================== */
.songs-workspace {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.workspace-toolbar {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: var(--shadow-sm);
}

.toolbar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 240px;
}

.search-box input {
    width: 100%;
    padding: 9px 34px 9px 36px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13.5px;
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.search-box .search-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search-box .clear-search {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 15px;
    padding: 4px;
}

.toolbar-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding-top: 10px;
    border-top: 1px solid var(--border-subtle);
}

.filter-pills {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.filter-pill {
    padding: 5px 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: var(--bg-surface-2);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all var(--transition);
}

.filter-pill:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.filter-pill.active {
    background: var(--accent-primary-soft);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

/* Secciones de Canciones (Setlist Orden 1..N y Reserva Orden 99) */
.songs-section {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.songs-section-header {
    padding: 14px 20px;
    background: var(--bg-surface-2);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.section-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 800;
}

.section-badge.setlist {
    background: var(--accent-primary-soft);
    color: var(--accent-primary);
}

.section-badge.reserve {
    background: var(--accent-blue-soft);
    color: var(--accent-blue);
}

/* Lista de Canciones y Filas Drag & Drop */
.song-list {
    display: flex;
    flex-direction: column;
    min-height: 56px;
}

.song-row {
    display: grid;
    grid-template-columns: 32px 66px 54px 1fr auto auto;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    transition: background var(--transition), transform var(--transition);
}

.song-row:last-child {
    border-bottom: none;
}

.song-row:hover {
    background: var(--bg-surface-2);
}

.song-row.dragging {
    opacity: 0.45;
    background: var(--accent-primary-soft);
}

.song-row.drag-over-top {
    border-top: 2px solid var(--accent-primary);
}

.song-row.drag-over-bottom {
    border-bottom: 2px solid var(--accent-primary);
}

.song-row.invalid-song {
    background: rgba(239, 68, 68, 0.08);
}

.drag-handle {
    cursor: grab;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    user-select: none;
    height: 36px;
    border-radius: 6px;
}

.drag-handle:hover {
    color: var(--text-primary);
    background: var(--bg-surface-3);
}

.drag-handle:active {
    cursor: grabbing;
}

.order-badge-input {
    width: 60px;
    padding: 5px 6px;
    text-align: center;
    font-weight: 800;
    font-size: 13px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface-2);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
}

.order-badge-input.is-setlist {
    background: var(--accent-primary-soft);
    color: var(--accent-primary);
    border-color: rgba(224, 62, 82, 0.35);
}

.order-badge-input.is-reserve {
    color: var(--text-muted);
}

.song-thumb-wrap {
    position: relative;
    width: 48px;
    height: 64px;
    border-radius: 6px;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid var(--border-color);
    cursor: zoom-in;
    flex-shrink: 0;
}

.song-thumb-wrap img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.multipage-pill {
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: rgba(15, 17, 23, 0.88);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 4px;
}

.song-main-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.song-title-line {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.song-title-text {
    font-weight: 700;
    font-size: 14.5px;
    color: var(--text-primary);
    cursor: pointer;
}

.song-title-text:hover {
    color: var(--accent-primary);
    text-decoration: underline;
}

.song-author-text {
    font-size: 13px;
    color: var(--text-secondary);
}

.song-meta-line {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 11.5px;
    color: var(--text-muted);
}

.file-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 7px;
    border-radius: 4px;
    background: var(--bg-surface-3);
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
}

.file-chip.missing {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.pdf-page-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 7px;
    border-radius: 4px;
    background: var(--accent-emerald-soft);
    color: var(--accent-emerald);
    font-weight: 600;
    font-size: 11px;
}

.memo-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 7px;
    border-radius: 4px;
    background: var(--accent-amber-soft);
    color: var(--accent-amber);
    font-size: 11px;
}

.song-move-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.song-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Vista en Cuadrícula (Grid de Partituras) */
.song-list.grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    padding: 18px;
}

.song-list.grid-view .song-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    gap: 10px;
}

.song-list.grid-view .song-thumb-wrap {
    width: 100%;
    height: 240px;
}

/* ==========================================================================
   Biblioteca de Imágenes y Herramientas de Procesamiento
   ========================================================================== */
.media-summary-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 18px;
    margin-bottom: 14px;
    font-size: 12.5px;
}

.media-summary-metrics {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.media-metric-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-weight: 600;
}

.media-metric-pill.emerald {
    background: var(--accent-emerald-soft);
    color: var(--accent-emerald);
    border-color: rgba(16, 185, 129, 0.25);
}

.media-metric-pill.amber {
    background: var(--accent-amber-soft);
    color: var(--accent-amber);
    border-color: rgba(245, 158, 11, 0.25);
}

.media-metric-pill.blue {
    background: var(--accent-blue-soft);
    color: var(--accent-blue);
    border-color: rgba(59, 130, 246, 0.25);
}

.media-batch-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.12) 0%, rgba(24, 27, 36, 0.95) 100%);
    border: 1px solid rgba(59, 130, 246, 0.35);
    border-radius: var(--radius-md);
    padding: 10px 16px;
    margin-bottom: 16px;
}

[data-theme="light"] .media-batch-bar {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, #ffffff 100%);
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
    gap: 16px;
}

.media-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: all var(--transition);
    position: relative;
}

.media-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.media-card.selected {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px var(--accent-blue-soft);
}

.media-thumb {
    width: 100%;
    height: 220px;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: zoom-in;
    position: relative;
    border-bottom: 1px solid var(--border-subtle);
}

.media-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.media-select-wrap {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 3;
    background: rgba(15, 17, 23, 0.82);
    border-radius: 6px;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.media-select-checkbox {
    width: 17px;
    height: 17px;
    accent-color: var(--accent-blue);
    cursor: pointer;
}

.media-badges-stack {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
    pointer-events: none;
}

.cache-badge {
    font-size: 10px;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 999px;
    letter-spacing: 0.01em;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.cache-badge.optimized {
    background: #10b981;
    color: #052e1e;
}

.cache-badge.stale {
    background: #f59e0b;
    color: #1f1300;
}

.cache-badge.pending {
    background: rgba(15, 17, 23, 0.82);
    color: #e2e8f0;
    border: 1px solid rgba(255, 255, 255, 0.16);
}

.orphan-badge {
    background: var(--accent-amber);
    color: #000;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 999px;
}

.media-info {
    padding: 10px 12px 8px;
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
}

.media-filename {
    font-weight: 700;
    color: var(--text-primary);
    word-break: break-word;
    line-height: 1.3;
}

.media-size-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    font-size: 11px;
    color: var(--text-secondary);
    background: var(--bg-surface-2);
    padding: 5px 8px;
    border-radius: 6px;
}

.media-size-row .saved-tag {
    color: var(--accent-emerald);
    font-weight: 700;
}

.media-actions-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    padding: 8px 10px 10px;
    background: var(--bg-surface-2);
    border-top: 1px solid var(--border-subtle);
}

.media-actions-bar .btn {
    padding: 5px 6px;
    font-size: 11.5px;
    width: 100%;
}

/* Zonas Drag & Drop y Comparativas en Modales de Imagen */
.upload-dropzone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 22px 16px;
    text-align: center;
    background: var(--bg-surface-2);
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 14px;
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
    border-color: var(--accent-primary);
    background: var(--accent-primary-soft);
}

.compare-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin: 14px 0;
}

@media (max-width: 720px) {
    .compare-grid {
        grid-template-columns: 1fr;
    }
}

.compare-pane {
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.compare-pane-header {
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 700;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.compare-pane-img {
    height: 300px;
    background: #111;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
}

.compare-pane-img img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    background: #fff;
    border-radius: 4px;
}

.compare-pane-meta {
    padding: 8px 12px;
    font-size: 11.5px;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-subtle);
}

.alert-box {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    margin-bottom: 12px;
    border: 1px solid transparent;
}

.alert-box.warn {
    background: var(--accent-amber-soft);
    border-color: rgba(245, 158, 11, 0.35);
    color: var(--text-primary);
}

.alert-box.danger {
    background: rgba(239, 68, 68, 0.14);
    border-color: rgba(239, 68, 68, 0.35);
    color: var(--text-primary);
}

.alert-box.info {
    background: var(--accent-blue-soft);
    border-color: rgba(59, 130, 246, 0.35);
    color: var(--text-primary);
}

.alert-box.success {
    background: var(--accent-emerald-soft);
    border-color: rgba(16, 185, 129, 0.35);
    color: var(--text-primary);
}

.ref-json-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 10px 0;
    max-height: 220px;
    overflow-y: auto;
}

.ref-json-item {
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 12.5px;
}

.range-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.range-row input[type="range"] {
    flex: 1;
    accent-color: var(--accent-primary);
}

.options-card {
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-bottom: 14px;
}

/* ==========================================================================
   Modales y Visor Interactivo de Escenario / Simulador PDF
   ========================================================================== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(9, 11, 16, 0.78);
    backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-backdrop.open {
    display: flex;
}

.modal-dialog {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 680px;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal-dialog.modal-xl {
    max-width: 1180px;
}

.modal-dialog.modal-fullscreen {
    max-width: 96vw;
    height: 94vh;
}

.modal-header {
    padding: 16px 22px;
    background: var(--bg-surface-2);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 700;
}

.modal-body {
    padding: 22px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 14px 22px;
    background: var(--bg-surface-2);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

/* Simulador de Navegabilidad PDF / Modo Escenario */
.stage-simulator-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 20px;
    height: 100%;
    min-height: 0;
}

@media (max-width: 900px) {
    .stage-simulator-layout {
        grid-template-columns: 1fr;
    }
}

.stage-nav-sidebar {
    background: var(--bg-surface-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.stage-nav-list {
    overflow-y: auto;
    flex: 1;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stage-nav-item {
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 12.5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--text-secondary);
    transition: all var(--transition);
}

.stage-nav-item:hover {
    background: var(--bg-surface-3);
    color: var(--text-primary);
}

.stage-nav-item.active {
    background: var(--accent-primary-soft);
    color: var(--accent-primary);
    font-weight: 700;
}

.stage-tablet-viewport {
    background: #090b10;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
    position: relative;
    overflow: hidden;
}

.tablet-sheet-frame {
    height: 100%;
    max-height: 76vh;
    aspect-ratio: 1200 / 1920;
    background: #ffffff;
    color: #000000;
    border-radius: 10px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.65);
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

.tablet-sheet-frame img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    cursor: pointer;
}

.interactive-hint-banner {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 17, 23, 0.86);
    color: #fff;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 12px;
    pointer-events: none;
    white-space: nowrap;
    border: 1px solid rgba(255,255,255,0.15);
}

/* Barra de Progreso PDF */
.progress-bar-outer {
    width: 100%;
    height: 12px;
    background: var(--bg-surface-3);
    border-radius: 999px;
    overflow: hidden;
    margin: 14px 0;
}

.progress-bar-inner {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary) 0%, #f59e0b 100%);
    width: 0%;
    transition: width 0.15s ease;
}

/* Notificaciones Toast */
.toast-container {
    position: fixed;
    bottom: 22px;
    right: 22px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent-emerald);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 260px;
    animation: slideIn 0.2s ease;
}

.toast.error { border-left-color: #ef4444; }
.toast.warn { border-left-color: var(--accent-amber); }

@keyframes slideIn {
    from { transform: translateY(14px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.hidden {
    display: none !important;
}

