:root {
    --bg-color: #f4f4f9;
    /* Softer light gray background */
    --surface-color: #ffffff;
    /* White cards */
    --primary-color: #6200ee;
    --text-color: #333333;
    /* Softer black */
    --input-bg: #f9f9f9;
    --input-border: #ddd;
    --sheet-bg: #ffffff;
    /* White sheet music */
    --btn-text: #ffffff;
    --danger-bg: #dc3545;
}

body.dark-mode {
    --bg-color: #121212;
    --surface-color: #1e1e1e;
    --primary-color: #bb86fc;
    --text-color: #e0e0e0;
    --input-bg: #333;
    --input-border: #444;
    --sheet-bg: #222;
    --btn-text: #000;
    --danger-bg: #cf6679;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: sans-serif;
    margin: 0;
    padding: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Auth Forms */
.auth-box {
    background: var(--surface-color);
    padding: 2rem;
    border-radius: 8px;
    max-width: 400px;
    margin: 50px auto;
    text-align: center;
}

/* =========================================
   11. Song Detail View
   ========================================= */
.song-meta-container {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-size: 0.95rem;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--input-border);
}

.meta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 15px;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
}

.meta-item.artist {
    color: var(--text-color);
    font-weight: bold;
    font-size: 1.1em;
}

.meta-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    text-decoration: none;
    font-weight: 500;
    transition: transform 0.1s;
    cursor: pointer;
}

.meta-link:hover {
    text-decoration: none;
    transform: translateY(-1px);
}

.meta-link.pdf {
    background-color: rgba(220, 53, 69, 0.1);
    color: #dc3545;
    border: 1px solid rgba(220, 53, 69, 0.2);
}

.meta-link.youtube {
    background-color: rgba(255, 0, 0, 0.1);
    color: #ff0000;
    border: 1px solid rgba(255, 0, 0, 0.2);
}

.meta-link.youtube-search {
    background-color: var(--surface-color);
    color: var(--text-secondary);
    border: 1px solid var(--input-border);
}

.scripture-chip {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    background-color: var(--surface-color);
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    font-size: 0.85em;
    cursor: pointer;
    transition: background-color 0.2s;
}

.scripture-chip:hover {
    background-color: var(--primary-color);
    color: var(--btn-text);
}

.song-insights {
    background-color: var(--surface-color);
    border-radius: 8px;
    padding: 15px;
    border-left: 4px solid var(--secondary-color);
    margin-top: 10px;
}

.insight-box {
    margin-bottom: 8px;
    font-size: 0.9em;
    line-height: 1.5;
}

.insight-box:last-child {
    margin-bottom: 0;
}

.insight-box strong {
    color: var(--secondary-color);
    display: block;
    margin-bottom: 2px;
}

input,
select,
textarea {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-color);
    box-sizing: border-box;
    font-family: inherit;
}

button {
    background-color: var(--primary-color);
    color: var(--btn-text);
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    font-weight: bold;
    width: 100%;
}

.hidden {
    display: none !important;
}

.link-btn {
    background: none;
    color: var(--primary-color);
    text-decoration: underline;
    margin-top: 10px;
    display: inline-block;
}

/* ChordPro Rendering */
.chord-sheet {
    font-family: monospace;
    font-size: 18px;
    line-height: 1.2;
    white-space: pre-wrap;
    background: var(--sheet-bg);
    padding: 15px;
    border-radius: 8px;
}

.chordpro-multi-column {
    column-width: 22em;
    column-fill: auto;
    height: 100%;
    width: 100%;
    box-sizing: border-box;
}

.song-header {
    column-span: all;
    -webkit-column-span: all;
}

.cp-line {
    display: block;
    margin-bottom: 0.2em;
    position: relative; /* Anchor for the canvas */
    /* Space between lines */
}

.cp-chunk {
    display: inline-flex;
    flex-direction: column;
    vertical-align: bottom;
    white-space: nowrap; /* Prevent internal wrapping to ensure stable bounding box for drawings */
}

.cp-chord {
    font-weight: bold;
    color: var(--primary-color);
    font-size: 0.9em;
    min-height: 1.2em;
    /* Keeps alignment even if chord is empty */
}

.cp-lyric {
    white-space: pre;
    /* Preserves spaces within the chunk */
}

.cp-chorus {
    border-left: 4px solid var(--primary-color);
    padding-left: 15px;
    margin: 10px 0;
    background: rgba(255, 255, 255, 0.05);
}

.cp-chorus,
.cp-section {
    break-inside: avoid;
    page-break-inside: avoid;
}

.cp-comment {
    font-weight: bold;
    color: var(--text-color);
    background: var(--input-bg);
    padding: 0px 10px;
    border-radius: 4px;
    margin: 15px 0 5px 0;
    display: inline-block;
    border: 1px solid var(--input-border);
}

#live-mode-view {
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: var(--bg-color);
    z-index: 1000;
    touch-action: manipulation; /* Disables browser double-tap zoom to allow custom gestures */
}

.app-header {
    background: var(--surface-color);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header h3 {
    margin: 0;
    font-size: 1.1em; /* Prevent text from being too large on mobile */
}

.toolbar {
    background: var(--surface-color);
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--input-border);
}

/* Performance Mode (Hides Toolbar) */
.performance-mode .toolbar {
    display: none !important;
}

.toolbar button {
    background-color: var(--input-bg);
    color: var(--text-color);
    border: 1px solid var(--input-border);
    width: auto !important;
    display: inline-block;
}

.btn-secondary {
    background-color: var(--input-bg);
    color: var(--text-color);
    border: 1px solid var(--input-border);
    border-radius: 4px;
}

.btn-danger {
    background-color: var(--danger-bg);
    color: var(--btn-text);
    border-radius: 4px;
}

/* Dashboard & Cards */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.card {
    background: var(--surface-color);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--input-border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
    border-color: var(--primary-color);
}

/* Modern List Items */
.list-item {
    background: var(--surface-color);
    border: 1px solid var(--input-border);
    color: var(--text-color);
    margin: 10px 0;
    padding: 15px 20px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.list-item:hover {
    transform: translateX(4px);
    border-left: 4px solid var(--primary-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.list-item.dragging {
    opacity: 0.5;
    border: 2px dashed var(--primary-color);
    background: var(--bg-color);
}

/* Live Mode PDF & Pagination */
.pdf-canvas {
    display: block;
    margin: 0 auto;
}

.paginated {
    height: calc(100vh - 60px);
    /* Subtract toolbar height */
    column-width: calc(100vw - 40px);
    /* Screen width minus padding (20px left + 20px right) */
    column-gap: 40px;
    /* 20px right margin for Page 1 + 20px left margin for Page 2 */
    padding: 20px !important;
    /* Ensure consistent padding */
    column-fill: auto;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 20px;
    max-width: none !important;
    /* Override container limit for full-screen book mode */
}

.song-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
    background-color: var(--bg-color); /* Ensure background is opaque for sliding */
}

.song-slide.paginated {
    max-width: none !important;
    height: 100%;
    column-width: calc(100vw - 40px);
    column-gap: 40px;
    padding: 20px !important;
    column-fill: auto;
    overflow-x: auto;
    overflow-y: hidden;
}

/* Slide Animations */
.slide-in-right { animation: slideInRight 0.3s forwards; }
.slide-out-left { animation: slideOutLeft 0.3s forwards; }
.slide-in-left { animation: slideInLeft 0.3s forwards; }
.slide-out-right { animation: slideOutRight 0.3s forwards; }

@keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes slideOutLeft { from { transform: translateX(0); } to { transform: translateX(-100%); } }
@keyframes slideInLeft { from { transform: translateX(-100%); } to { transform: translateX(0); } }
@keyframes slideOutRight { from { transform: translateX(0); } to { transform: translateX(100%); } }

.form-container {
    background: var(--sheet-bg);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

/* Lyrics Only Mode */
.lyrics-only .cp-chord {
    display: none !important;
}

.lyrics-only .chord-sheet {
    line-height: 1.8; /* Increase spacing for lyrics-only readability */
}

/* Editor Split View */
.editor-split-view {
    display: block;
}
.editor-preview-col {
    display: none;
    margin-top: 20px;
}
@media (min-width: 900px) {
    .editor-split-view {
        display: flex;
        gap: 20px;
        align-items: stretch;
        height: 85vh;
    }
    .editor-main-col { 
        flex: 1; 
        display: flex;
        flex-direction: column;
    }
    .editor-preview-col {
        display: block;
        flex: 1;
        margin-top: 0;
        position: static;
        max-height: none;
        overflow-y: auto;
        background: var(--sheet-bg);
        padding: 15px;
        border-radius: 8px;
        border: 1px solid var(--input-border);
    }
    #song-content {
        flex-grow: 1;
        height: auto !important;
        resize: none;
    }
}

/* Scripture Modal (Replaces Tooltip) */
#scripture-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

#scripture-modal.visible {
    opacity: 1;
    pointer-events: auto;
}

.scripture-modal-content {
    background: var(--surface-color);
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--input-border);
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

#scripture-modal.visible .scripture-modal-content {
    transform: scale(1);
}

.scripture-modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--input-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0,0,0,0.02);
    border-radius: 12px 12px 0 0;
}

.scripture-modal-body {
    padding: 25px;
    overflow-y: auto;
    font-size: 1em;
    line-height: 1.6;
    color: var(--text-color);
    font-family: 'Georgia', serif; /* Better for reading scripture */
}

.scripture-modal-body b {
    color: var(--primary-color);
    font-size: 0.8em;
    vertical-align: super;
    margin-right: 2px;
}

/* Spinner for loading */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0,0,0,0.1);
    border-left-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { 100% { transform: rotate(360deg); } }

/* Drawing Mode */
.drawing-canvas {
    touch-action: none; /* Prevent scrolling while drawing */
    cursor: crosshair;
}

.draw-toolbar {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 2100;
    background: var(--surface-color);
    padding: 10px;
    border-radius: 50px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    border: 1px solid var(--primary-color);
}

.drawing-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 50;
    pointer-events: none; /* Pass-through by default */
    overflow: visible;
}
.drawing-layer path {
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: visibleStroke; /* Allow clicking/touching the stroke lines */
}

/* =========================================
   12. Billing & Pricing
   ========================================= */
.pricing-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    margin-top: 30px;
}

.pricing-card {
    background: var(--surface-color);
    border: 1px solid var(--input-border);
    border-radius: 12px;
    padding: 30px;
    width: 100%;
    max-width: 350px;
    text-align: center;
    transition: transform 0.2s;
    position: relative;
}

.pricing-card.featured {
    border: 2px solid var(--primary-color);
    transform: scale(1.02);
}

.pricing-price {
    font-size: 2.5em;
    font-weight: bold;
    margin: 15px 0;
    color: var(--text-color);
}

.pricing-features {
    list-style: none;
    padding: 0;
    margin: 20px 0;
    text-align: left;
    opacity: 0.8;
}

/* =========================================
   13. Modern Form Elements
   ========================================= */
.modern-form-card {
    background: var(--surface-color);
    padding: 30px;
    border-radius: 16px;
    border: 1px solid var(--input-border);
    max-width: 450px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
}
.modern-input-group {
    margin-bottom: 20px;
}
.modern-input-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.95em;
}
.modern-input {
    width: 100%;
    padding: 12px 16px;
    padding-right: 45px;
    border-radius: 10px;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--text-color);
    font-size: 1em;
    transition: all 0.2s ease;
}
.modern-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(98, 0, 238, 0.1);
    outline: none;
}
.password-toggle-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    opacity: 0.4;
    font-size: 1.2em;
    transition: opacity 0.2s;
    user-select: none;
}
.password-toggle-icon:hover {
    opacity: 1;
    color: var(--primary-color);
}