/* =============================================
   CHORD EDITOR - Ultra Precise Chordly-style
   Professional chord positioning system
   ============================================= */

/* ===== MAIN CONTAINER ===== */
.minimal-editor {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    background: var(--bg-card);
    height: 100%;
    min-height: 400px;
    position: relative;
}

/* ===== STICKY TOOLBAR WRAPPER ===== */
.minimal-toolbar-sticky {
    position: sticky;
    top: 60px; /* Offset for main topbar */
    z-index: 50;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
}

/* Editor content area with scroll */
.minimal-editor-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    position: relative;
    padding-left: 8px; /* Space for delete button */
}

/* ===== FORMAT PANEL ===== */
.minimal-format-panel {
    padding: var(--space-3) var(--space-4);
    background: var(--bg-body);
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    animation: slideDown 0.2s ease-out;
}

.minimal-format-panel.hidden {
    display: none;
}

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

.format-panel-group {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 180px;
}

.format-panel-group label {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 80px;
}

.format-panel-group input[type="range"] {
    flex: 1;
    height: 4px;
    appearance: none;
    background: var(--border-color);
    border-radius: 2px;
    cursor: pointer;
    min-width: 80px;
}

.format-panel-group input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--color-primary);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.format-panel-group input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.format-panel-group input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--color-primary);
    border-radius: 50%;
    border: none;
    cursor: pointer;
}

.format-panel-value {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    min-width: 32px;
    text-align: right;
    font-family: 'Fira Code', monospace;
}

/* ===== DELETE LINE BUTTON ===== */
.ce-delete-line {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-left: 8px;
    background: var(--color-danger-light, rgba(239, 68, 68, 0.1));
    border: none;
    border-radius: var(--border-radius-sm);
    color: var(--color-danger, #ef4444);
    cursor: pointer;
    opacity: 0;
    transition: all 0.15s ease;
    font-size: 12px;
    font-weight: bold;
    flex-shrink: 0;
}

.ce-line-wrapper:hover .ce-delete-line,
.ce-section-wrapper:hover .ce-delete-line,
.ce-tab-wrapper:hover .ce-delete-line,
.ce-tab-block-wrapper:hover .ce-delete-line {
    opacity: 1;
}

.ce-delete-line:hover {
    background: var(--color-danger, #ef4444);
    color: white;
    transform: scale(1.1);
}

/* ===== DRAG OVER STATE ===== */
.ce-line-wrapper.drag-over,
.ce-section-wrapper.drag-over,
.ce-tab-wrapper.drag-over,
.ce-tab-block-wrapper.drag-over {
    background: var(--color-primary-light);
    border-radius: var(--border-radius-md);
    box-shadow: inset 0 0 0 2px var(--color-primary);
}

/* ===== FORM TEXTAREA (for import) ===== */
.ce-form-textarea {
    width: 100%;
    min-height: 200px;
    padding: var(--space-3);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    font-family: 'Fira Code', monospace;
    font-size: var(--font-size-sm);
    background: var(--bg-body);
    resize: vertical;
    line-height: 1.5;
}

.ce-form-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* ===== IMPORT/EXPORT BUTTONS ===== */
.ce-import-export-group {
    display: flex;
    gap: var(--space-1);
}

/* ===== TAB LINE EDITABLE ===== */
.ce-tab-line[contenteditable="true"] {
    outline: none;
    cursor: text;
}

.ce-tab-line[contenteditable="true"]:focus {
    background: var(--color-primary-light);
    border-radius: var(--border-radius-sm);
}

/* ===== DRAGGABLE LINE HANDLE ===== */
.ce-drag-handle {
    left: -24px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: grab;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.ce-line-wrapper:hover .ce-drag-handle,
.ce-section-wrapper:hover .ce-drag-handle,
.ce-tab-wrapper:hover .ce-drag-handle {
    opacity: 0.5;
}

.ce-drag-handle:hover {
    opacity: 1 !important;
    color: var(--color-primary);
}

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

/* ===== TOOLBAR ===== */
.minimal-toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-tertiary);
    flex-wrap: wrap;
}

.minimal-toolbar-group {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.minimal-toolbar-divider {
    width: 1px;
    height: 20px;
    background: var(--border-color);
    margin: 0 var(--space-1);
}

.minimal-toolbar-spacer {
    flex: 1;
}

.minimal-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    border: none;
    background: transparent;
    border-radius: var(--border-radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: var(--font-size-sm);
    height: 32px;
}

.minimal-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.minimal-btn.active,
.minimal-btn-accent.active {
    background: var(--color-primary);
    color: white;
}

.minimal-btn-accent {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.minimal-btn-accent:hover {
    background: var(--color-primary);
    color: white;
}

.minimal-btn svg {
    flex-shrink: 0;
}

/* ===== COLOR PICKER FOR TEXT FORMATTING ===== */
.minimal-color-picker-wrapper {
    display: flex;
    align-items: center;
    position: relative;
}

.minimal-color-picker {
    width: 0 !important;
    height: 0 !important;
    min-width: 0 !important;
    min-height: 0 !important;
    opacity: 0 !important;
    position: absolute !important;
    pointer-events: none !important;
}


.minimal-color-btn {
    position: relative;
    padding-right: var(--space-3) !important;
}

.color-indicator {
    /* position: absolute; REMOVED - breaks CSS Grid */
    bottom: 0.5em;
    
    
    width: 16px;
    height: 3px;
    border-radius: 2px;
    pointer-events: none;
}

.minimal-color-btn:hover .color-indicator {
    
    height: 4px;
}

/* ===== FONT FAMILY SELECT ===== */
.minimal-select {
    padding: var(--space-1) var(--space-2);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    background: var(--bg-card);
    font-size: var(--font-size-xs);
    color: var(--text-primary);
    cursor: pointer;
    height: 32px;
    min-width: 100px;
}

.minimal-select:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* ===== COLOR PALETTE DROPDOWN ===== */
.color-palette-dropdown {
    /* position: absolute; REMOVED - breaks CSS Grid */
    top: 100%;
    left: 0;
    margin-top: var(--space-1);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    padding: var(--space-3);
    min-width: 200px;
}

.color-palette-dropdown.hidden {
    display: none;
}

.color-palette-presets {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.color-preset {
    width: 28px;
    height: 28px;
    border: 2px solid transparent;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    transition: all 0.15s ease;
}

.color-preset:hover {
    transform: scale(1.15);
    border-color: var(--text-primary);
}

.color-preset.active {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-primary-light);
}

.color-palette-custom {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding-top: var(--space-2);
    border-top: 1px solid var(--border-color);
}

.color-palette-custom label {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    white-space: nowrap;
}

.color-palette-custom input[type="color"] {
    width: 32px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
}

.minimal-font-size {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    min-width: 36px;
    text-align: center;
}

/* ===== DROPDOWN ===== */
.minimal-dropdown {
    position: relative;
}

.minimal-dropdown-trigger {
    padding-right: var(--space-2);
}

.minimal-dropdown-menu {
    /* position: absolute; REMOVED - breaks CSS Grid */
    top: 100%;
    left: 0;
    margin-top: var(--space-1);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    min-width: 140px;
    padding: var(--space-1);
    display: none;
}

.minimal-dropdown-menu.show {
    display: block;
}

.minimal-dropdown-item {
    display: block;
    width: 100%;
    padding: var(--space-2) var(--space-3);
    border: none;
    background: transparent;
    text-align: left;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    cursor: pointer;
    border-radius: var(--border-radius-md);
    transition: background var(--transition-fast);
}

.minimal-dropdown-item:hover {
    background: var(--bg-card-hover);
}

.minimal-dropdown-item svg {
    margin-right: var(--space-2);
    flex-shrink: 0;
}

/* ===== CHORD BAR ===== */
.minimal-chord-bar {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-body);
    border-bottom: 1px solid var(--border-color);
    overflow: hidden;
}

.minimal-chord-bar.hidden {
    display: none;
}

.minimal-chord-search {
    flex-shrink: 0;
}

.minimal-chord-search input {
    width: 140px;
    padding: var(--space-1) var(--space-2);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    font-size: var(--font-size-sm);
    background: var(--bg-card);
}

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

.minimal-chord-list {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    overflow-x: auto;
    padding: var(--space-1) 0;
    flex: 1;
    scrollbar-width: thin;
}

.minimal-chord-list::-webkit-scrollbar {
    height: 4px;
}

.minimal-chord-list::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

.minimal-chord-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

.minimal-chord-btn {
    flex-shrink: 0;
    padding: var(--space-1) var(--space-2);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    cursor: grab;
    transition: all var(--transition-fast);
    white-space: nowrap;
    user-select: none;
}

.minimal-chord-btn:hover {
    background: var(--color-primary-light);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.minimal-chord-btn:active,
.minimal-chord-btn.dragging {
    cursor: grabbing;
    opacity: 0.6;
    transform: scale(0.95);
}

.minimal-chord-empty {
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    padding: var(--space-2);
}

/* ===== SECTION BUTTONS ===== */
.minimal-section-btn {
    flex-shrink: 0;
    padding: var(--space-1) var(--space-2);
    background: var(--color-primary-light);
    border: 1px solid var(--color-primary);
    border-radius: var(--border-radius-md);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-primary);
    cursor: grab;
    transition: all var(--transition-fast);
    white-space: nowrap;
    user-select: none;
}

.minimal-section-btn:hover {
    background: var(--color-primary);
    color: white;
}

.minimal-section-btn:active,
.minimal-section-btn.dragging {
    cursor: grabbing;
    opacity: 0.6;
    transform: scale(0.95);
}

/* ===== UNIFIED EDITOR AREA ===== */
.ce-unified-editor {
    padding: var(--space-4);
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 13px; /* Reducido 20% desde 16px */
    line-height: 1.6;
    position: relative;
    min-height: 300px;
}

/* ===== LINE WRAPPER ===== */
.ce-line-wrapper,
.ce-section-wrapper,
.ce-tab-wrapper,
.ce-tab-block-wrapper {
    position: relative;
    margin-bottom: var(--space-2);
    display: flex;
    align-items: flex-start;
    margin-left: 8px;
    margin-right: 8px;
}

/* ===== LINE NUMBERS ===== */
.ce-line-number {
    flex-shrink: 0;
    width: 28px;
    text-align: right;
    padding-right: var(--space-2);
    font-size: 0.7em;
    color: var(--text-muted);
    opacity: 0.4;
    user-select: none;
    line-height: 1.6;
    font-family: 'Fira Code', 'Consolas', monospace;
    margin-top: 26px; /* Align with lyric row (chord row height) */
}

.ce-section-wrapper .ce-line-number {
    visibility: hidden;
    margin-top: 0;
}

.ce-tab-wrapper .ce-line-number {
    margin-top: 0;
}

.ce-line-wrapper:hover .ce-line-number {
    opacity: 0.7;
}

/* ===== LINE CONTENT ===== */
.ce-line-content {
    flex: 1;
    min-width: 0;
    position: relative;
    overflow: visible;
}

/* ===== CHORD ROW - Precise positioning ===== */
.ce-chord-row {
    display: grid; /* Required for grid-column positioning */
    position: relative;
    min-height: 24px;
    margin-bottom: 2px;
    /* Allow vertical overflow for stacked chords */
    overflow: visible;
}

/* Individual chord with absolute positioning */
.ce-chord {
    /* NO position absolute - CSS Grid handles positioning via grid-column */
    /* position: absolute; REMOVED - breaks CSS Grid */
    /* top: 0; NOT needed without position absolute */

    background: transparent;
    color: #1f2937;
    padding: 0;
    border-radius: 0;
    font-size: 13px;
    font-weight: 900;
    cursor: grab;
    user-select: none;
    white-space: nowrap;
    z-index: 2;
    transition: opacity 0.15s ease, transform 0.15s ease;
    line-height: 1.2;
}

.ce-chord:hover {
    opacity: 0.7;
    z-index: 10;
}

.ce-chord:active {
    cursor: grabbing;
    opacity: 0.5;
}

.ce-chord.dragging {
    opacity: 0.3;
}

/* Selected chord - red color to indicate delete on second click */
.ce-chord.selected {
    color: var(--color-danger, #ef4444) !important;
    text-decoration: none;
    
    animation: pulse-selected-text 1.5s ease-in-out infinite;
}

@keyframes pulse-selected-text {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

/* ===== LYRIC ROW - Editable ===== */
.ce-lyric-row {
    outline: none;
    min-height: 1.4em;
    white-space: pre-wrap;
    word-wrap: break-word;
    border-radius: var(--border-radius-sm);
    padding: 0;
    transition: background-color 0.15s ease;
}

/* Subtle background for lyric rows to differentiate from sections */
.ce-line-wrapper {
    background: rgba(var(--color-primary-rgb, 99, 102, 241), 0.02);
    border-radius: var(--border-radius-sm);
    padding: 0;
}

.ce-line-wrapper:nth-child(even) {
    background: rgba(var(--color-primary-rgb, 99, 102, 241), 0.04);
}

.ce-lyric-row:focus {
    background-color: var(--color-primary-light);
}

.ce-lyric-row:empty::before {
    content: '\00a0';
}

/* ===== SECTION BAR - Color-coded bars for sections ===== */
.ce-section-bar {
    position: relative;
    display: block;
    padding-left: 20px;
    margin: var(--space-3) 0 var(--space-2) 0;
    border-left: 4px solid var(--section-bar-color, var(--color-primary));
    border-radius: 0;
}

.ce-section-bar .ce-section-wrapper {
    margin: 0 0 var(--space-2) 0;
    width: 100%;
}

.ce-section-bar .ce-section {
    border-left: none;
    background: color-mix(in srgb, var(--section-bar-color) 15%, transparent);
}

.ce-section-bar .ce-line-wrapper {
    margin-left: 0;
    width: 100%;
}

.ce-section-bar .ce-tab-block-wrapper,
.ce-section-bar .ce-tab-wrapper {
    margin-left: 0;
}

/* ===== SECTION HEADERS ===== */
.ce-section-wrapper {
    margin: var(--space-3) 0 var(--space-2) 0;
    align-items: center;
    width: calc(100% - 32px); /* Full width minus left margin */
}

.ce-section-wrapper:first-child {
    margin-top: 0;
}

.ce-section {
    font-weight: var(--font-weight-bold);
    color: var(--color-primary);
    padding: var(--space-2) var(--space-3);
    background: var(--color-primary-light);
    border-radius: var(--border-radius-md);
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: block;
    width: fit-content;
    border-left: 3px solid var(--color-primary);
}

.ce-section-clickable {
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.ce-section-clickable:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Section Preview in Modal */
.ce-section-preview {
    display: inline-block;
    padding: 8px 20px;
    background: #4f46e5;
    color: white;
    border-radius: var(--border-radius-md);
    font-size: 16px;
    font-weight: bold;
    font-family: 'Fira Code', monospace;
    margin-bottom: var(--space-4);
    text-align: center;
    min-width: 100px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-left: 3px solid rgba(255, 255, 255, 0.3);
}

/* ===== TAB BLOCK ===== */
.ce-tab-block-wrapper {
    margin: var(--space-3) 0;
    align-items: flex-start;
}

.ce-tab-block-wrapper .ce-line-number {
    visibility: hidden;
    margin-top: 0;
}

.ce-tab-block {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    overflow: hidden;
}

.ce-tab-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) var(--space-3);
    background: var(--bg-body);
    border-bottom: 1px solid var(--border-color);
}

.ce-tab-block-label {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.ce-tab-edit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
}

.ce-tab-edit-btn:hover {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.ce-tab-block-content {
    padding: var(--space-3);
}

/* ===== TAB LINES ===== */
.ce-tab-line {
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.85em;
    color: var(--text-secondary);
    line-height: 1.3;
    white-space: pre;
}

/* ===== DROP INDICATOR ===== */
/* Character highlight style - width is set dynamically in JS */
.ce-drop-indicator {
    position: absolute;
    display: none;
    /* width is now set dynamically based on character width */
    height: 24px;
    background: rgba(var(--color-primary-rgb, 99, 102, 241), 0.15);
    border: 1px solid rgba(var(--color-primary-rgb, 99, 102, 241), 0.4);
    border-radius: 2px;
    pointer-events: none;
    z-index: 100;
    animation: pulse-indicator-subtle 1s ease-in-out infinite;
}

@keyframes pulse-indicator-subtle {
    0%, 100% {
        opacity: 1;
        background: rgba(var(--color-primary-rgb, 99, 102, 241), 0.15);
    }
    50% {
        opacity: 0.8;
        background: rgba(var(--color-primary-rgb, 99, 102, 241), 0.2);
    }
}

/* ===== TOUCH PREVIEW ===== */
/* Floating chord preview for touch devices */
.ce-touch-preview {
    position: absolute;
    display: none;
    background: var(--color-primary);
    color: white;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--border-radius-md);
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    z-index: 1000;
    transform: translateX(-50%);
    white-space: nowrap;
}

.ce-touch-preview::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--color-primary);
}

/* ===== CHORD OPTIONS POPUP ===== */
.ce-chord-popup {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 4px;
    display: flex;
    gap: 4px;
}

.ce-chord-popup-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.ce-chord-popup-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.ce-chord-popup-edit:hover {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

/* ===== CHORD EDIT MODAL ===== */
.ce-chord-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1200;
    padding: var(--space-4);
    animation: modal-bg-appear 0.2s ease-out;
}

.ce-chord-modal.hidden {
    display: none;
}

@keyframes modal-bg-appear {
    from { opacity: 0; }
    to { opacity: 1; }
}

.ce-chord-modal-content {
    background: var(--bg-card);
    border-radius: var(--border-radius-xl);
    box-shadow: var(--shadow-xl);
    max-width: 420px;
    width: 100%;
    animation: modal-appear 0.25s ease-out;
}

@keyframes modal-appear {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.ce-chord-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-color);
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-lg);
}

.ce-chord-modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 24px;
    border-radius: var(--border-radius-md);
    transition: all var(--transition-fast);
}

.ce-chord-modal-close:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.ce-chord-modal-body {
    padding: var(--space-4);
}

/* Chord Preview */
.ce-chord-preview {
    display: inline-block;
    padding: 8px 20px;
    background: transparent;
    color: #1f2937;
    border-radius: var(--border-radius-md);
    font-size: 18px;
    font-weight: bold;
    font-family: 'Fira Code', monospace;
    margin-bottom: var(--space-4);
    text-align: center;
    min-width: 80px;
    border: 1px dashed var(--border-color);
}

/* Form Styles */
.ce-chord-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.ce-form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.ce-form-group label {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--text-secondary);
}

.ce-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
}

.ce-form-input {
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    font-size: var(--font-size-base);
    font-family: 'Fira Code', monospace;
    background: var(--bg-body);
    transition: border-color var(--transition-fast);
}

.ce-form-input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.ce-form-select {
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    font-size: var(--font-size-sm);
    background: var(--bg-body);
    cursor: pointer;
}

.ce-form-select:focus {
    outline: none;
    border-color: var(--color-primary);
}

.ce-form-color {
    width: 100%;
    height: 40px;
    padding: 2px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    cursor: pointer;
    background: var(--bg-body);
}

.ce-form-color::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.ce-form-color::-webkit-color-swatch {
    border-radius: var(--border-radius-sm);
    border: none;
}

/* Tip text */
.ce-chord-tip {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    margin-top: var(--space-4);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-md);
    line-height: 1.5;
}

.ce-chord-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

/* ===== TAB MODAL ===== */
.minimal-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    padding: var(--space-4);
}

.minimal-modal.hidden {
    display: none;
}

.minimal-modal-content {
    background: var(--bg-card);
    border-radius: var(--border-radius-xl);
    box-shadow: var(--shadow-xl);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
}

.minimal-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-color);
    font-weight: var(--font-weight-semibold);
}

.minimal-modal-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: var(--font-size-xl);
    border-radius: var(--border-radius-md);
}

.minimal-modal-close:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.minimal-tab-editor {
    padding: var(--space-4);
}

.minimal-tab-help {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    margin-bottom: var(--space-3);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-md);
}

.minimal-tab-controls {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
    flex-wrap: wrap;
}

.minimal-tab-grid-wrapper {
    display: flex;
    gap: var(--space-2);
    overflow-x: auto;
    padding: var(--space-3);
    background: var(--bg-body);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
}

.minimal-tab-strings {
    display: flex;
    flex-direction: column;
    gap: 0;
    flex-shrink: 0;
}

.minimal-tab-strings span {
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-weight: var(--font-weight-bold);
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    width: 20px;
}

.minimal-tab-grid {
    display: grid;
    gap: 0;
}

.minimal-tab-cell {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    text-align: center;
    color: var(--text-muted);
    padding: 0;
    outline: none;
}

.minimal-tab-cell:focus {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
    color: var(--color-primary);
    font-weight: var(--font-weight-bold);
    z-index: 1;
    position: relative;
}

.minimal-tab-cell:not([value="-"]):not(:placeholder-shown) {
    color: var(--color-primary);
    font-weight: var(--font-weight-bold);
}

.minimal-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
    margin-top: var(--space-4);
    padding-top: var(--space-3);
    border-top: 1px solid var(--border-color);
}

/* ===== DRAWING PANEL ===== */
.minimal-draw-panel {
    padding: var(--space-3) var(--space-4);
    background: var(--bg-body);
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    align-items: center;
    animation: slideDown 0.2s ease-out;
}

.minimal-draw-panel.hidden {
    display: none;
}

.draw-panel-group {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.draw-panel-group label {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    white-space: nowrap;
}

.draw-colors {
    display: flex;
    gap: var(--space-1);
}

.draw-color-btn {
    width: 24px;
    height: 24px;
    border: 2px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.15s ease;
}

.draw-color-btn:hover {
    transform: scale(1.15);
}

.draw-color-btn.active {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 2px var(--bg-card);
}

/* ===== DRAWING CANVAS ===== */
.ce-draw-canvas {
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
    cursor: crosshair;
    touch-action: none;
}

.ce-draw-canvas.hidden {
    display: none;
}

/* When drawing mode is active, show visual indicator */
.minimal-editor.draw-mode .minimal-editor-content {
    outline: 2px dashed var(--color-primary);
    outline-offset: -2px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 820px) {
    .minimal-toolbar {
        padding: var(--space-2);
    }

    .minimal-toolbar-divider {
        display: none;
    }

    .minimal-btn span:not(:only-child) {
        display: none;
    }

    .minimal-chord-search input {
        width: 100px;
    }

    .ce-unified-editor {
        padding: var(--space-3);
    }

    .ce-chord-modal-content {
        margin: var(--space-2);
    }

    .ce-form-row {
        grid-template-columns: 1fr;
    }

    .minimal-modal-content {
        margin: var(--space-2);
        max-height: calc(100vh - var(--space-4));
        max-height: calc(100dvh - var(--space-4));
    }

    .minimal-tab-grid-wrapper {
        padding: var(--space-2);
    }

    .minimal-tab-cell {
        width: 28px;
        height: 28px;
    }
}

/* ===== CHORD SELECTOR POPUP ===== */
.ce-chord-selector {
    position: absolute !important;
    z-index: 1000;
    background: var(--bg-primary, #ffffff);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    width: 260px;
    max-height: 300px;
    overflow: hidden;
}

.ce-chord-selector.hidden {
    display: none;
}

.ce-chord-selector-search {
    padding: var(--space-2);
    border-bottom: 1px solid var(--border-color);
}

.ce-chord-selector-search input {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    font-size: var(--font-size-sm);
    font-family: 'Fira Code', monospace;
    background: var(--bg-body);
    outline: none;
}

.ce-chord-selector-search input:focus {
    border-color: var(--color-primary);
}

.ce-chord-selector-list {
    padding: var(--space-2);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    max-height: 220px;
    overflow-y: auto;
}

.ce-chord-selector-btn {
    padding: var(--space-1) var(--space-2);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-family: 'Fira Code', monospace;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.ce-chord-selector-btn:hover,
.ce-chord-selector-btn:focus {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
    outline: none;
}

/* ===== SECTION SELECTOR POPUP ===== */
.ce-section-selector {
    position: fixed !important;
    z-index: 1000;
    background: var(--bg-primary, #ffffff);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    width: 280px;
    max-height: 400px;
    overflow: hidden;
}

.ce-section-selector.hidden {
    display: none;
}

.ce-section-selector-header {
    padding: var(--space-3);
    border-bottom: 1px solid var(--border-color);
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    text-align: center;
}

.ce-section-selector-search {
    padding: var(--space-2);
    border-bottom: 1px solid var(--border-color);
}

.ce-section-selector-search input {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    font-size: var(--font-size-sm);
    background: var(--bg-body);
    outline: none;
}

.ce-section-selector-search input:focus {
    border-color: var(--color-primary);
}

.ce-section-selector-list {
    padding: var(--space-3);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
    max-height: 280px;
    overflow-y: auto;
}

.ce-section-selector-btn {
    padding: var(--space-2) var(--space-3);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
}

.ce-section-selector-btn:hover,
.ce-section-selector-btn:focus {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
    outline: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Make line numbers clickable visual hint */
.ce-line-number {
    cursor: pointer;
    transition: all var(--transition-fast);
    opacity: 0.4;
}

.ce-line-number:hover {
    opacity: 1;
    color: var(--color-primary);
    transform: scale(1.1);
}

/* ===== SECTION REPEAT SELECTOR ===== */
.ce-repeat-selector {
    display: flex;
    gap: var(--space-1);
}

.ce-repeat-btn {
    flex: 1;
    padding: var(--space-2);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.ce-repeat-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.ce-repeat-btn.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

/* Section repeat indicator (inline badge) */
.ce-section-repeat {
    display: inline;
    margin-left: 0.5em;
    font-size: 0.85em;
    font-weight: 600;
    color: inherit;
    opacity: 0.7;
}

/* Repeat group - wraps section and all lines until next section */
.ce-repeat-group {
    position: relative;
    padding-left: 16px;
    margin: var(--space-2) 0;
    border-left: 3px solid var(--color-primary);
    border-radius: 0;
}

/* Different bar styles for different repeat counts */
.ce-repeat-group[data-repeat="2"] {
    border-left-width: 4px;
}

.ce-repeat-group[data-repeat="3"] {
    border-left-width: 5px;
}

.ce-repeat-group[data-repeat="4"] {
    border-left-width: 6px;
}


/* =============================================================================
   INSTRUMENT MODE - Read-only lyrics
   ============================================================================= */

/* Container indicator */
.ce-instrument-mode {
    position: relative;
}

.ce-instrument-mode::before {
    content: '';
    /* position: absolute; REMOVED - breaks CSS Grid */
    /* top: 0; NOT needed without position absolute */
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary, #8b5cf6));
    z-index: 10;
}

/* Read-only lyric rows */
.ce-lyric-row.ce-readonly {
    background: rgba(0, 0, 0, 0.02);
    cursor: default;
    user-select: none;
}

.ce-lyric-row.ce-readonly:focus {
    outline: none;
}

/* Dark mode */
[data-theme="dark"] .ce-lyric-row.ce-readonly {
    background: rgba(255, 255, 255, 0.02);
}

/* Chords remain fully interactive in instrument mode */
.ce-instrument-mode .ce-chord {
    /* NO position absolute - CSS Grid handles positioning via grid-column */
    cursor: pointer;
    pointer-events: auto;
}

/* Visual hint that lyrics are locked */
.ce-instrument-mode .ce-lyric-row::after {
    content: '';
    /* position: absolute; REMOVED - breaks CSS Grid */
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Crect x='3' y='11' width='18' height='11' rx='2' ry='2'%3E%3C/rect%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4'%3E%3C/path%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0.3;
    pointer-events: none;
}

/* Instrument active indicator on select */
.song-field-instrument-select.instrument-active {
    background: var(--color-primary) !important;
    color: white !important;
    border-color: var(--color-primary) !important;
    font-weight: 600;
}

/* Section readonly in instrument mode */
.ce-section-clickable.ce-readonly {
    cursor: default;
    pointer-events: none;
}

.ce-section-clickable.ce-readonly:hover {
    filter: none;
}

/* No drag indicator */
.ce-no-drag {
    cursor: default !important;
}

.ce-no-drag:hover {
    opacity: 1 !important;
}

/* Hide lock icon on sections in instrument mode */
.ce-instrument-mode .ce-section-wrapper::after {
    display: none;
}

/* ===== RESPONSIVE - MOBILE & TABLET ===== */
@media (max-width: 768px) {
    /* Touch preview larger on mobile */
    .ce-touch-preview {
        font-size: 1.25rem;
        padding: var(--space-3) var(--space-4);
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
    }

    /* Drop indicator slightly wider on mobile for better visibility */
    .ce-drop-indicator {
        border-width: 2px;
    }

    /* Increase touch target size for chords */
    .ce-chord {
        min-width: 36px;
        min-height: 36px;
        padding: var(--space-2) var(--space-3);
    }
}


/* ═══════════════════════════════════════════════════════════════
   SECTION COPY/PASTE BUTTONS - SIMPLE VERSION
   ═══════════════════════════════════════════════════════════════ */

/* Wrapper must be relative for absolute positioning */
.ce-section-wrapper {
    position: relative !important;
}

/* Actions container - hidden by default, shown on hover */
.ce-section-actions {
    position: absolute !important;
    right: 10px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.2s ease !important;
    z-index: 50 !important;
}

/* Show on hover */
.ce-section-wrapper:hover .ce-section-actions {
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Copy button - blue */
.ce-copy-section {
    width: 26px !important;
    height: 26px !important;
    padding: 0 !important;
    background: #3b82f6 !important;
    border: none !important;
    border-radius: 5px !important;
    color: white !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15) !important;
    transition: all 0.15s ease !important;
}

.ce-copy-section:hover {
    background: #2563eb !important;
    transform: scale(1.1) !important;
}

/* Paste button - green, hidden until copy */
.ce-paste-section {
    width: 26px !important;
    height: 26px !important;
    padding: 0 !important;
    background: #22c55e !important;
    border: none !important;
    border-radius: 5px !important;
    color: white !important;
    cursor: pointer !important;
    display: none !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15) !important;
    transition: all 0.15s ease !important;
}

.ce-paste-section:hover {
    background: #16a34a !important;
    transform: scale(1.1) !important;
}

.ce-paste-section.visible {
    display: flex !important;
}

/* SVG icons inside buttons */
.ce-copy-section svg,
.ce-paste-section svg {
    width: 14px !important;
    height: 14px !important;
    stroke: currentColor !important;
}

/* Delete button inside actions - override default styles */
.ce-section-actions .ce-delete-line {
    opacity: 1 !important;
    position: relative !important;
    margin-left: 0 !important;
    width: 26px !important;
    height: 26px !important;
    font-size: 16px !important;
}

/* Chord copy/paste buttons in popup */
.ce-chord-popup-copy:hover {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

.ce-chord-popup-paste:hover {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

/* Paste chord button in chord selector */
.ce-chord-paste-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: rgba(34, 197, 94, 0.1);
    border: 1px dashed #22c55e;
    border-radius: var(--border-radius-md);
    color: #22c55e;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.ce-chord-paste-btn:hover {
    background: rgba(34, 197, 94, 0.2);
    border-style: solid;
}

.ce-chord-paste-btn.hidden {
    display: none;
}
