:root {
    /* Official Palette - Softer Theme for Visual Comfort */
    color-scheme: light;
    --bg: #EEF2F6;
    --surface: #FDFDFD;
    --card-dark: #252530;
    --border: #E2E8F0;
    --primary: #9333EA;
    --cyan: #06B6D4;
    --accent: #D946EF;
    --text-primary: #334155;
    --text-secondary: #64748B;
    --text-light: #FFFFFF;
    --text-muted: rgba(255, 255, 255, 0.7);

    --bpm: #FB923C;
    --key: #3B82F6;
    --success: #10B981;
    --chord-color: #d97706;

    --sidebar-width: 280px;
    --sidebar-right-width: 224px;
    --header-height: 50px;
    --footer-height: 88px;
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0A0A0A;
    --surface: #141414;
    --card-dark: #222222;
    --border: #2A2A2A;
    --primary: #A855F7;
    --cyan: #22D3EE;
    --accent: #E879F9;
    --text-primary: #F8FAFC;
    --text-secondary: #9CA3AF;
    --text-light: #FFFFFF;
    --text-muted: rgba(255, 255, 255, 0.5);
    --chord-color: #facc15;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    flex-direction: row;
    /* Sidebar on LEFT, Content on RIGHT */
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- MODERN SCROLLBARS --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    transition: all 0.3s;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* --- SIDEBAR --- */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    flex-shrink: 0;
    height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 200;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.05);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.search-container {
    padding: 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.search-input {
    width: 100%;
    padding: 10px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 13px;
    color: var(--text-primary);
    outline: none;
    transition: all 0.2s;
}

.sidebar-tabs {
    display: flex;
    gap: 8px;
    padding: 0 16px;
    margin-top: -4px;
    margin-bottom: 4px;
    background: var(--surface);
    z-index: 10;
}

.sidebar-tab {
    flex: 1;
    padding: 8px 0;
    border: none;
    background: transparent;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: 0.2s;
}

.sidebar-tab:hover {
    color: var(--primary);
}

.sidebar-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.maestro-slot.selected {
    border: 2px solid var(--primary);
    box-shadow: 0 0 15px rgba(168, 85, 247, 0.2);
    transform: translateY(-2px);
}

.maestro-slot.drag-over {
    border: 2px dashed var(--primary);
    background: rgba(168, 85, 247, 0.1);
    transform: scale(1.02);
}

.maestro-slot.dragging {
    opacity: 0.4;
    border: 2px dashed var(--primary);
    transform: scale(0.98);
}

.maestro-slot.dimmed {
    opacity: 0.2;
    filter: grayscale(0.8);
}

.search-input::placeholder {
    color: var(--text-secondary);
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.1);
    background: var(--surface);
}

.song-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    /* Space between cards like mobile */
}

/* --- SONG CARDS (MOBILE PARITY) --- */
.song-card {
    background: var(--card-dark);
    border-radius: 14px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 124px;
    /* Reduced ~20% */
    border: 2px solid transparent;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.song-card.in-setlist {
    opacity: 0.6;
    cursor: default;
    filter: grayscale(0.5);
}

.setlist-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-15deg);
    color: rgba(16, 185, 129, 0.25);
    /* Verde esmeralda com opacidade maior */
    z-index: 10;
    pointer-events: none;
    transition: all 0.3s;
}

.song-card.in-setlist:hover .setlist-watermark {
    color: rgba(16, 185, 129, 0.4);
}

.song-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--genre-gradient);
    opacity: 0.15;
    /* Gradient overlay like mobile */
    pointer-events: none;
}

.song-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px var(--genre-glow);
    border-color: rgba(147, 51, 234, 0.5);
}

.song-card.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary), 0 8px 24px var(--genre-glow);
}

.card-header {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    z-index: 1;
}

.genre-badge {
    background: var(--genre-color);
    color: white;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 8px;
    font-weight: 800;
    font-family: 'Outfit', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1;
    margin: 12px 0;
}

.card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    text-align: center;
    line-height: 1.1;
    margin-bottom: 2px;
}

.card-artist {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    text-align: center;
    letter-spacing: 0.5px;
}

.card-footer {
    display: flex;
    justify-content: flex-start;
    gap: 8px;
    z-index: 1;
}

.meta-badge {
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
    color: white;
}

.bg-bpm {
    background: var(--bpm);
}

.bg-key {
    background: var(--key);
}

.bg-capo {
    background: var(--cyan);
}

/* --- MAIN VIEW --- */
.main-view {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--bg);
}

header {
    height: var(--header-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 100;
}

.header-content-mode {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 100%;
}

.header-left,
.header-right {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-right {
    justify-content: flex-end;
}

.header-center {
    flex: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.logo {
    font-family: 'Outfit', sans-serif;
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    background: linear-gradient(135deg, var(--primary), var(--cyan));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    cursor: pointer;
    white-space: nowrap;
}

.logo svg {
    flex-shrink: 0;
    -webkit-text-fill-color: initial;
    /* Don't inherit transparent from text clip */
}


.draft-badge {
    display: none;
    background: var(--bpm);
    color: white;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    margin-left: 12px;
    animation: pulse-draft 2s infinite;
}

@keyframes pulse-draft {
    0% {
        opacity: 0.7;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.7;
    }
}

.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.sync-status {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 10px;
    border-radius: 8px;
    background: var(--bg);
    opacity: 0;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.sync-status.active {
    opacity: 1;
}

.sync-status.saving {
    color: var(--primary);
}

.sync-status.saved {
    color: var(--success);
}

.sync-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.btn {
    padding: 8px 16px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--text-secondary);
}

.btn-outline:hover {
    background: var(--bg);
    border-color: var(--primary);
    color: var(--primary);
}

/* --- AI STATUS BUTTONS --- */
.btn-ai-status {
    position: relative;
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    letter-spacing: 0.5px;
    padding: 8px 14px;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.ai-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    transition: all 0.3s ease;
    margin-right: 6px;
}

/* AI Connected/Active status (Green) */
.btn.btn-outline.btn-ai-status.connected {
    color: #10B981 !important;
    border-color: rgba(16, 185, 129, 0.4) !important;
    background: rgba(16, 185, 129, 0.06) !important;
}

.btn.btn-outline.btn-ai-status.connected .ai-status-dot {
    background-color: #10B981 !important;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.8) !important;
}

.btn.btn-outline.btn-ai-status.connected:hover {
    background: rgba(16, 185, 129, 0.12) !important;
    border-color: #10B981 !important;
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.2) !important;
}

/* AI Disconnected/Inactive status (Red) */
.btn.btn-outline.btn-ai-status.disconnected {
    color: #EF4444 !important;
    border-color: rgba(239, 68, 68, 0.4) !important;
    background: rgba(239, 68, 68, 0.06) !important;
}

.btn.btn-outline.btn-ai-status.disconnected .ai-status-dot {
    background-color: #EF4444 !important;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.8) !important;
}

.btn.btn-outline.btn-ai-status.disconnected:hover {
    background: rgba(239, 68, 68, 0.12) !important;
    border-color: #EF4444 !important;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.2) !important;
}

/* --- WORKSPACE --- */
.workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    position: relative;
    overflow: hidden;
}


/* EDITOR */
#editor {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.editor-meta {
    padding: 8px 2%;
    background: var(--surface);
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 16px;
    width: 100%;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 0;
    position: relative;
}

.field.key-field {
    flex: 0;
    min-width: 60px;
    max-width: 80px;
}

.field.capo-field {
    flex: 0;
    min-width: 60px;
    max-width: 80px;
}

.field.bpm-field {
    flex: 0;
    min-width: 70px;
    max-width: 90px;
}

.field.key-field input,
.field.capo-field input,
.field.bpm-field input {
    text-align: right;
}

.field.key-field label,
.field.capo-field label,
.field.bpm-field label {
    text-align: right;
}

.field.audio-field {
    flex: 0.8;
    max-width: 250px;
}

/* LARGURA FIXA PARA O ÁUDIO */
.field label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.field input {
    border: none;
    border-bottom: 1.5px solid var(--border);
    padding: 8px 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    background: transparent;
    outline: none;
    transition: 0.3s;
    caret-color: var(--primary);
    width: 100%;
}

.field input:focus {
    border-color: var(--primary);
}

.audio-container {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 12px;
    background: var(--bg);
    border-radius: 8px;
    border: 1.5px solid var(--border);
    cursor: pointer;
    transition: 0.2s;
    overflow: hidden;
    margin-top: 4px;
    position: relative;
}

.audio-container:hover {
    border-color: var(--primary);
    background: var(--surface);
}

.audio-container.pending {
    border-color: var(--bpm);
    background: rgba(244, 63, 94, 0.05);
}

.audio-info-wrapper {
    flex: 1;
    overflow: hidden;
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
}

.audio-info {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    display: inline-block;
}

/* EFEITO MARQUEE (LETREIRO) */
.marquee {
    display: inline-block;
    padding-left: 100%;
    animation: marquee 10s linear infinite;
}

@keyframes marquee {
    0% {
        transform: translate(0, 0);
    }

    100% {
        transform: translate(-100%, 0);
    }
}

.audio-info.has-audio {
    color: var(--primary);
}

.audio-info.is-pending {
    color: var(--bpm);
}

.textarea-container {
    flex: 1;
    position: relative;
    background: var(--surface);
    overflow: hidden;
    display: flex;
}

#songContent,
.highlights {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 8px 2%;
    font-family: 'Roboto Mono', monospace;
    font-size: 17px;
    line-height: 1.6;
    border: none;
    outline: none;
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-y: auto;
}

#songContent {
    background: transparent;
    color: var(--text-primary);
    -webkit-text-fill-color: transparent;
    caret-color: var(--primary);
    resize: none;
    z-index: 2;
}

.highlights {
    z-index: 1;
    color: var(--text-primary);
    pointer-events: none;
}

.hl-tag {
    color: #ef4444;
    font-weight: bold;
}

.hl-chord {
    color: #eab308;
    font-weight: bold;
}

#songContent::selection {
    background: rgba(147, 51, 234, 0.2);
    color: transparent;
}

/* FOOTER / PLAYER */
footer {
    height: var(--footer-height);
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 24px;
    z-index: 100;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.03);
}

.player-row-1 {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
}

.player-row-2 {
    display: flex;
    align-items: center;
    gap: 12px;
}

.play-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--success);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
    transition: transform 0.2s;
}

.play-btn:active {
    transform: scale(0.92);
}

.ctrl-btn {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
}

.ctrl-btn:hover {
    background: var(--border);
    color: var(--primary);
}

.timeline-container {
    flex: 1;
    display: flex;
    align-items: center;
    padding: 0 10px;
    position: relative;
    height: 48px;
}

.timeline-slider {
    width: 100%;
    height: 14px;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    border-radius: 4px;
    outline: none;
    cursor: pointer;
    z-index: 10;
    position: relative;
}

/* Esconder o slider original mas carregar os eventos */
.timeline-slider::-webkit-slider-runnable-track {
    background: transparent;
}

.timeline-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 0;
    height: 0;
    opacity: 0;
}

/* CUSTOM TIMELINE ELEMENTS */
.timeline-track-custom {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 14px;
    border-radius: 6px;
    background: var(--border);
    transform: translateY(-50%);
    overflow: hidden;
    display: flex;
    z-index: 1;
}

.timeline-segment {
    height: 100%;
    transition: width 0.1s;
}

.timeline-playhead {
    position: absolute;
    top: 50%;
    height: 24px;
    width: 2px;
    background: #FBBF24;
    /* Amber/Yellow */
    z-index: 20;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: translate(-50%, -50%);
}

.playhead-circle {
    width: 10px;
    height: 10px;
    background: #FBBF24;
    border: 1.5px solid white;
    border-radius: 50%;
    margin-top: -6px;
    /* Ajuste fino para o topo */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.timeline-marker-line {
    position: absolute;
    top: 50%;
    height: 14px;
    width: 2px;
    background: #FBBF24;
    z-index: 15;
    pointer-events: none;
    transform: translate(-50%, -50%);
}

.timer-display {
    font-family: 'Roboto Mono', monospace;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    min-width: 50px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.section-nav {
    flex: 1;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    align-items: center;
    scroll-behavior: smooth;
}

.section-nav::-webkit-scrollbar {
    display: none;
}

/* Botão de Controle - Modo de Edição Ativo */
.ctrl-btn.edit-mode {
    background: rgba(239, 68, 68, 0.1) !important;
    border: 1px solid rgba(239, 68, 68, 0.3) !important;
    color: #ef4444 !important;
    animation: pulse-edit 2s infinite;
}

@keyframes pulse-edit {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* Setas do Carrossel */
.nav-scroll-btn {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 50%;
    background: var(--bg);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
    padding: 0;
}

.nav-scroll-btn:hover {
    background: var(--border);
    color: var(--primary);
    transform: scale(1.05);
}

.nav-scroll-btn:active {
    transform: scale(0.95);
}

.section-btn {
    padding: 6px 14px;
    border-radius: 8px;
    background: rgba(var(--btn-rgb, 147, 51, 234), 0.1);
    border: 1px solid rgba(var(--btn-rgb, 147, 51, 234), 0.3);
    font-size: 11px;
    font-weight: 700;
    color: var(--btn-color, var(--primary));
    cursor: pointer;
    white-space: nowrap;
    transition: 0.2s;
    text-transform: lowercase;
}

.section-btn:hover {
    background: rgba(var(--btn-rgb, 147, 51, 234), 0.2);
}

.section-btn.active {
    background: var(--btn-color) !important;
    color: white !important;
    box-shadow: 0 4px 12px var(--btn-glow);
    transform: translateY(-1px);
}

/* --- RIGHT SIDEBAR (TOOLKIT) --- */
.sidebar-right {
    width: var(--sidebar-right-width);
    min-width: var(--sidebar-right-width);
    flex-shrink: 0;
    height: 100vh;
    background: var(--surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 200;
}

.sidebar-right-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.toolkit-container {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tool-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tool-section-label {
    font-size: 10px;
    font-weight: 800;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.tool-btn {
    width: 100%;
    height: 38px;
    background: var(--bg);
    border: 1px solid var(--border);
    font-size: 11px;
    font-weight: 800;
    color: var(--text-secondary);
    border-radius: 10px;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool-btn:hover {
    background: var(--surface);
    color: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(168, 85, 247, 0.1);
}

.tool-btn.primary-tool {
    background: rgba(147, 51, 234, 0.1);
    color: var(--primary);
    border-color: rgba(147, 51, 234, 0.3);
}

.tool-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 0;
}

/* UPLOAD PROGRESS OVERLAY */
.upload-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.upload-card {
    background: white;
    padding: 32px;
    border-radius: 24px;
    width: 320px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.upload-title {
    font-family: 'Outfit', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.progress-container {
    width: 100%;
    height: 10px;
    background: var(--bg);
    border-radius: 5px;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border);
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--cyan));
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary);
    font-family: 'Roboto Mono', monospace;
    letter-spacing: -1px;
}

/* CUSTOM MODALS */
.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.2s;
}

.custom-modal-overlay.active {
    display: flex;
    opacity: 1;
}

.custom-modal-card {
    background: var(--surface);
    padding: 24px;
    border-radius: 20px;
    width: 340px;
    max-width: 90%;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border);
    transform: scale(0.95);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.custom-modal-overlay.active .custom-modal-card {
    transform: scale(1);
}

.custom-modal-title {
    font-family: 'Outfit', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.custom-modal-message {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 24px;
}

.custom-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.custom-modal-actions .btn {
    padding: 8px 16px;
    font-size: 13px;
}

/* --- SETLIST MAESTRO EDITOR --- */
.setlist-toolbar {
    height: 70px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
}

.setlist-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}

.setlist-title-input {
    background: transparent;
    border: none;
    font-family: 'Outfit', sans-serif;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    outline: none;
    width: 300px;
}

.maestro-badge {
    padding: 4px 10px;
    background: linear-gradient(135deg, var(--primary), var(--cyan));
    color: white;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.setlist-pagination {
    display: flex;
    background: var(--bg);
    padding: 4px;
    border-radius: 12px;
    gap: 4px;
}

.page-link {
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    background: transparent;
    font-weight: 700;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: 0.2s;
    white-space: nowrap;
    /* Impede quebra vertical */
    display: flex;
    align-items: center;
    gap: 4px;
}

.page-link.active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.maestro-grid-container {
    flex: 1;
    padding: 12px 4px;
    /* Mantém vertical, reduz lateral ao mínimo */
    overflow-x: auto;
    overflow-y: hidden;
    display: flex;
    justify-content: flex-start;
    align-items: stretch;
    background: var(--bg);
}

.maestro-viewport {
    display: flex;
    gap: 16px;
    padding: 6px 2px;
    /* Lateral quase zerada */
    width: 100%;
    height: 100%;
    justify-content: center;
    background: var(--bg);
    overflow: hidden;
    /* Proíbe rolagem */
}

.maestro-page {
    flex: 1;
    max-width: 480px;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    /* Reduzido de 12px */
    background: var(--surface);
    padding: 8px;
    /* Reduzido de 12px */
    border-radius: 20px;
    border: 1px solid var(--border);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 8px 4px 8px;
    border-bottom: 1px solid var(--border);
}

.page-header-title {
    font-size: 11px;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-clear-page {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 6px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-clear-page:hover {
    color: var(--danger, #ef4444);
    background: rgba(239, 68, 68, 0.1);
}

/* --- MAESTRO AI MODAL --- */
.maestro-modal {
    max-width: 500px;
}

.maestro-options-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
}

.maestro-option {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.maestro-option:hover {
    background: var(--surface);
    border-color: var(--primary);
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.maestro-option-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.maestro-option-info {
    flex: 1;
}

.maestro-option-title {
    font-weight: 700;
    font-size: 15px;
    color: var(--text-primary);
}

.maestro-option-desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
    line-height: 1.4;
}

.maestro-block {
    flex: 1;
    /* Faz os blocos dividirem o espaço vertical */
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 4px;
    background: rgba(0, 0, 0, 0.03);
    padding: 4px;
    border-radius: 16px;
    border: 1px solid var(--border);
    min-height: 0;
}

.maestro-slot {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    text-align: center;
    min-height: 0;
}

.maestro-slot:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(168, 85, 247, 0.1);
}

.maestro-slot.selected {
    border-color: var(--primary);
    background: rgba(168, 85, 247, 0.05);
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.2);
}

.maestro-slot.has-song {
    background: var(--card-dark);
    border-color: transparent;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
    align-items: stretch;
    /* Permite que header/footer alinhem à esquerda */
    justify-content: space-between;
    /* Distribui topo, meio e fundo */
}

.maestro-slot.has-song::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--genre-gradient);
    opacity: 0.3;
    /* Increased from 0.15 for better visibility in small slots */
    pointer-events: none;
}

.maestro-slot.has-song .slot-title {
    color: var(--text-light);
    font-size: 14px;
    /* Increased from 11px */
    font-weight: 800;
    text-transform: uppercase;
    line-height: 1.1;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.maestro-slot.has-song .slot-artist {
    color: var(--text-muted);
    font-size: 10px;
    /* Increased from 8px */
    font-weight: 600;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

/* Reuse existing badge structures but scale down for slot */
.maestro-slot .genre-badge {
    font-size: 9px;
    /* Increased from 6px */
    padding: 3px 7px;
    border-radius: 5px;
}

.maestro-slot .meta-badge {
    font-size: 10px;
    /* Increased from 8px */
    padding: 2px 8px;
    border-radius: 5px;
}

.maestro-slot .card-body {
    margin: 4px 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    /* Mantém título e artista centralizados */
}

.maestro-slot .card-header {
    width: 100%;
    margin-bottom: 2px;
    display: flex;
    justify-content: flex-start;
    /* Alinha badge à esquerda como no card original */
}

.maestro-slot .card-footer {
    width: 100%;
    margin-top: auto;
    display: flex;
    justify-content: flex-start;
    /* Alinha metadados à esquerda como no card original */
    gap: 4px;
}

.btn-clear-slot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
    backdrop-filter: blur(4px);
    z-index: 2;
}

.maestro-slot:hover .btn-clear-slot {
    opacity: 1;
}

.btn-clear-slot:hover {
    background: var(--danger, #ef4444);
    transform: scale(1.1);
}

.slot-number {
    position: absolute;
    top: 6px;
    left: 8px;
    font-size: 11px;
    /* Increased from 9px */
    font-weight: 800;
    color: var(--text-secondary);
    opacity: 0.5;
}

.slot-empty-icon {
    color: var(--border);
    margin-bottom: 4px;
}

.maestro-slot.selected .slot-empty-icon {
    color: var(--primary);
}

/* --- ANIMATIONS --- */
@keyframes flash-update {
    0% {
        background-color: rgba(168, 85, 247, 0.4);
        box-shadow: 0 0 15px rgba(168, 85, 247, 0.6);
    }

    100% {
        background-color: transparent;
        box-shadow: none;
    }
}

.flash-update {
    animation: flash-update 1.5s ease-out;
}

/* --- INFO AI MODAL & SPINNER STYLES --- */
.metric-progress-bg {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border);
    margin-top: 4px;
}

.metric-progress-fill {
    height: 100%;
    width: 0%;
    border-radius: 4px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.bg-popularity {
    background: linear-gradient(90deg, #a855f7, #c084fc);
    box-shadow: 0 0 8px rgba(168, 85, 247, 0.5);
}

.bg-energy {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
}

.bg-danceability {
    background: linear-gradient(90deg, #06b6d4, #22d3ee);
    box-shadow: 0 0 8px rgba(6, 182, 212, 0.5);
}

.info-ai-field {
    display: flex;
    flex-direction: column;
}

.info-ai-input {
    height: 38px;
    border-radius: 8px;
    border: 1px solid var(--border);
    padding: 0 10px;
    background: var(--surface-card);
    color: var(--text);
    outline: none;
    font-size: 13px;
    transition: all 0.2s;
}

.info-ai-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.2);
}

@keyframes spin-glow {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.spinner-glow {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(168, 85, 247, 0.1);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin-glow 1s linear infinite;
    box-shadow: 0 0 12px rgba(168, 85, 247, 0.3);
}

select.info-ai-input {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg fill='gray' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/><path d='M0 0h24v24H0z' fill='none'/></svg>");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 30px;
    cursor: pointer;
}

/* --- SONG VIEWER MODE --- */
#viewer {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow-y: auto;
    background: var(--bg);
    padding: 40px 60px;
    font-family: 'Inter', sans-serif;
    scroll-behavior: smooth;
}

.viewer-song-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 2px solid var(--border);
    padding-bottom: 24px;
    margin-bottom: 32px;
}

.viewer-title {
    font-family: 'Outfit', sans-serif;
    font-size: 32px;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.2;
    margin-bottom: 6px;
}

.viewer-artist {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-secondary);
}

.viewer-meta-row {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 8px;
}

.viewer-meta-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    min-width: 60px;
}

.viewer-meta-badge span {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.viewer-meta-badge strong {
    font-size: 14px;
    font-weight: 800;
    color: var(--text-primary);
}

.viewer-meta-badge.bg-key strong {
    color: var(--key);
}

.viewer-meta-badge.bg-bpm strong {
    color: var(--bpm);
}

.viewer-meta-badge.bg-capo strong {
    color: var(--primary);
}

.viewer-body {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.viewer-section-header {
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    font-weight: 700;
    padding: 10px 16px;
    margin-top: 36px;
    margin-bottom: 16px;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: inline-block;
    scroll-margin-top: 20px;
}

.viewer-line-wrapper {
    margin-bottom: 6px;
    scroll-margin-top: 100px;
}

.viewer-line {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    line-height: 1.8;
}

.viewer-line.no-chords {
    line-height: 1.4;
    margin-top: 4px;
}

.viewer-line.no-chords .viewer-chord {
    display: none;
}

.viewer-segment {
    display: flex;
    flex-direction: column;
    min-width: 4px;
}

.viewer-chord {
    font-family: 'Roboto Mono', monospace;
    font-size: 15px;
    font-weight: 800;
    color: var(--chord-color);
    height: 22px;
    line-height: 22px;
    user-select: none;
    margin-right: 12px;
}

.viewer-text {
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    color: var(--text-primary);
    white-space: pre;
    line-height: 24px;
}

#btn-toggle-viewer.active {
    background: var(--primary);
    color: var(--text-light) !important;
    border-color: var(--primary);
}

/* --- STRUMMING VISUALIZER --- */
.viewer-strumming-container {
    display: flex;
    flex-direction: column;
    background: transparent;
    border: none;
    padding: 0;
    margin: 12px 0;
    box-shadow: none;
    gap: 6px;
}

.viewer-strumming-label {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 400;
    font-style: italic;
    color: var(--text-secondary);
    text-transform: none;
    letter-spacing: normal;
}

.viewer-strumming-pattern {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
}

.viewer-strum-arrow {
    display: none; /* replaced by SVG stems/note heads */
}

/* --- SECTION HEADERS --- */
.viewer-section-row {
    display: flex;
    align-items: center;
    margin-top: 36px;
    margin-bottom: 16px;
    gap: 12px;
    scroll-margin-top: 20px;
}

.viewer-section-pill {
    font-family: 'Outfit', sans-serif;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: white;
    padding: 4px 12px;
    border-radius: 6px;
    letter-spacing: 0.5px;
}

.viewer-section-ts {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}

/* --- RITORNELLOS & CHORDS ONLY ROW --- */
.chords-only-row {
    margin-bottom: 6px;
    scroll-margin-top: 100px;
}

.viewer-chord.ritornello {
    color: var(--cyan);
    font-weight: 800;
}

.viewer-segment-spacer {
    white-space: pre;
    font-family: 'Roboto Mono', monospace;
    font-size: 15px;
    color: transparent;
    user-select: none;
}

/* Active Section Glow & Highlights in Viewer */
.viewer-section-row {
    transition: background-color 0.3s ease, padding 0.3s ease, border-radius 0.3s ease;
}

.viewer-section-row.active {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    padding: 8px 12px;
    margin-left: -12px;
    margin-right: -12px;
    box-shadow: inset 0 0 12px rgba(255, 255, 255, 0.02);
}

.viewer-section-row.active .viewer-section-pill {
    transform: scale(1.04);
    box-shadow: 0 0 15px var(--primary);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* --- TIMING EDITOR MODAL (PC) --- */
.timing-modal {
    max-width: 680px;
    width: 95%;
    padding: 28px 32px;
}

.timing-modal .custom-modal-title {
    font-size: 20px;
}

.timing-modal .custom-modal-message {
    font-size: 14px;
    margin-bottom: 16px;
}

#timingChordList {
    max-height: 360px;
    gap: 8px;
    margin-bottom: 16px;
}

.timing-chord-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    transition: 0.15s;
    gap: 10px;
}

.timing-chord-row:hover {
    border-color: var(--primary);
}

.timing-chord-name {
    font-family: 'Roboto Mono', monospace;
    font-weight: 800;
    font-size: 16px;
    color: var(--primary);
    min-width: 56px;
}

.timing-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.timing-stepper-btn {
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: 8px;
    cursor: pointer;
    font-size: 17px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.15s;
}

.timing-stepper-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.timing-stepper-input {
    width: 52px;
    height: 34px;
    text-align: center;
    font-family: 'Roboto Mono', monospace;
    font-weight: 800;
    font-size: 15px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    outline: none;
    transition: 0.15s;
    -moz-appearance: textfield;
}

.timing-stepper-input::-webkit-inner-spin-button,
.timing-stepper-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.timing-stepper-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(147, 51, 234, 0.15);
}

.timing-apply-all-btn {
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.15s;
    flex-shrink: 0;
}

.timing-apply-all-btn:hover {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    border-color: #3b82f6;
}

.timing-actions-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.timing-chip {
    flex: 1;
    min-width: 56px;
    height: 38px;
    font-size: 13px;
    font-weight: 800;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: 0.15s;
    color: var(--text-secondary);
}

.timing-chip:hover {
    background: rgba(147, 51, 234, 0.1);
    color: var(--primary);
    border-color: var(--primary);
}

.timing-bar-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    transition: 0.15s;
    user-select: none;
}

.timing-bar-toggle:hover {
    border-color: var(--primary);
}

.timing-bar-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

.timing-bar-toggle span {
    display: flex;
    align-items: center;
    gap: 4px;
}

#timingBarInfo {
    font-weight: 800;
    color: var(--primary);
    font-family: 'Roboto Mono', monospace;
}

.timing-preview-area {
    margin-top: 16px;
}

.timing-preview-label {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.timing-preview-text {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    font-family: 'Roboto Mono', monospace;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 130px;
    overflow-y: auto;
}

.timing-rest-row {
    border-color: rgba(234, 179, 8, 0.25);
    background: rgba(234, 179, 8, 0.04);
}

.timing-rest-row:hover {
    border-color: #eab308;
}

.timing-rest-name {
    color: #eab308;
    font-size: 20px;
    line-height: 1;
}