:root {
    --bg-color: #121212;
    --panel-color: #1e1e1e;
    --text-color: #e0e0e0;
    --accent-color: #3b82f6;
    /* Blue */
    --chord-color: #fbbf24;
    /* Amber/Yellow */
    --border-color: #333;
    --font-ui: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-song: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-chord: 'Consolas', 'Monaco', monospace;
}

body {
    margin: 0;
    font-family: var(--font-ui);
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden;
    /* Prevent body scroll, handle in main */
    height: 100vh;
    /* Fallback */
    height: 100dvh;
    /* Dynamic viewport height */
    display: flex;
    flex-direction: column;
}

/* --- Layout --- */
.app-header {
    height: 60px;
    background-color: var(--panel-color);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    padding-top: env(safe-area-inset-top);
    /* Safe area for notch */
    z-index: 10;
    flex-shrink: 0;
}

.app-main {
    flex-grow: 1;
    position: relative;
    overflow: hidden;
    display: flex;
}

.app-footer {
    height: 80px;
    background-color: var(--panel-color);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 10px;
    padding-bottom: env(safe-area-inset-bottom);
    height: calc(90px + env(safe-area-inset-bottom));
    z-index: 10;
    flex-shrink: 0;
}

/* --- Header Elements --- */
.header-title {
    font-size: 1.2rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 50%;
}

.header-controls {
    display: flex;
    gap: 12px;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.icon-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.icon-btn.active {
    color: var(--accent-color);
    background-color: rgba(59, 130, 246, 0.1);
}

/* --- Main Content Areas --- */
.editor-panel {
    width: 50%;
    /* Default split */
    height: 100%;
    border-right: 1px solid var(--border-color);
    background-color: #181818;
    transition: width 0.3s ease, transform 0.3s ease;
    position: absolute;
    left: 0;
    top: 0;
    z-index: 5;
}

.editor-panel.hidden {
    transform: translateX(-100%);
}

.editor-textarea {
    width: 100%;
    height: 100%;
    background: transparent;
    color: #ccc;
    border: none;
    padding: 20px;
    box-sizing: border-box;
    font-family: monospace;
    font-size: 16px;
    resize: none;
    outline: none;
}

.song-view {
    flex-grow: 1;
    height: 100%;
    overflow-y: auto;
    padding: 20px 40px 100px 40px;
    /* Extra bottom padding for scroll */
    box-sizing: border-box;
    text-align: center;
    /* Default center alignment */
    transition: margin-left 0.3s ease;
    width: 100%;
    /* Occupy full width, pushed by editor */
    margin-left: 0;
}

.app-main.split-view .song-view {
    margin-left: 50%;
    width: 50%;
}

/* --- Song Rendering --- */
.song-title-render {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: #fff;
}

.section-header {
    font-size: 1.5em;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 0.5rem;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.song-line {
    margin-bottom: 1.5rem;
    position: relative;
    line-height: 1.5;
}

.song-line.chord-only {
    margin-bottom: 0;
}

.chord-line {
    height: 1.5em;
    color: var(--chord-color);
    font-family: var(--font-chord);
    font-weight: 700;
    font-size: 1.2em;
    margin-bottom: 0.2em;
    white-space: pre;
}

.lyric-line {
    font-family: var(--font-chord);
    font-size: 1.2em;
    color: var(--text-color);
    white-space: pre-wrap;
}

.chord-wrapper {
    display: inline-block;
    position: relative;
}

.chord {
    position: absolute;
    bottom: 100%;
    left: 0;
    color: var(--chord-color);
    font-weight: bold;
    font-family: var(--font-chord);
    white-space: nowrap;
}

/* --- Footer Controls --- */
.control-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 100px;
}

.control-label {
    font-size: 0.75rem;
    color: #888;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.control-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: #2a2a2a;
    padding: 4px;
    border-radius: 20px;
}

.control-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background-color: #383838;
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    background-color: #484848;
}

.control-btn:active {
    background-color: #222;
}

.control-value {
    min-width: 30px;
    text-align: center;
    font-weight: bold;
    font-family: monospace;
}

.play-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: var(--accent-color);
    color: white;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s;
}

.play-btn:hover {
    transform: scale(1.05);
    background-color: #2563eb;
}

.play-btn:active {
    transform: scale(0.95);
}

.play-btn.playing {
    background-color: #dc2626;
}

/* --- Modals --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--panel-color);
    padding: 24px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: bold;
}

.close-btn {
    background: none;
    border: none;
    color: #888;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.song-list-item {
    padding: 12px;
    border-bottom: 1px solid #333;
    cursor: pointer;
    transition: background 0.2s;
}

.song-list-item:hover {
    background-color: #333;
}

.menu-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #333;
}

.menu-item:last-child {
    border-bottom: none;
}

/* Utility */
.hidden {
    display: none !important;
}

/* Pulse Animation */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(220, 38, 38, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0);
    }
}

.play-btn.pulsing {
    animation: pulse var(--pulse-duration, 1s) infinite;
}