/* === Reset & Base === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0d0d1a;
    --bg-secondary: #1a1a2e;
    --bg-controls: rgba(26, 26, 46, 0.95);
    --text-primary: #f0f0f0;
    --text-secondary: #a0a0b0;
    --accent: #4a9eff;
    --accent-hover: #6bb3ff;
    --btn-bg: rgba(255, 255, 255, 0.1);
    --btn-hover: rgba(255, 255, 255, 0.2);
    --sidebar-bg: #16163a;
    --border-color: rgba(255, 255, 255, 0.1);
    --song-hover: rgba(74, 158, 255, 0.15);
    --font-lyrics: 'Georgia', serif;
    --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --lyrics-size: 30px;
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: var(--font-ui);
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

/* === Control Bar (Top) === */
.controls-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    padding-top: calc(env(safe-area-inset-top, 0px) + 8px);
    background: var(--bg-controls);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    height: auto;
    min-height: 52px;
}

.controls-center {
    display: flex;
    align-items: center;
    gap: 8px;
}

.controls-left {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-home {
    padding: 2px;
    border-radius: 50%;
    overflow: hidden;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
}

.header-logo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.btn-speed-toggle {
    font-size: 13px;
    padding: 4px 10px;
    border-radius: 12px;
    background: var(--btn-bg);
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.btn-speed-toggle.active {
    background: var(--accent);
    color: #fff;
}

.speed-slider-container {
    display: none;
    position: fixed;
    top: 52px;
    left: 0;
    right: 0;
    z-index: 150;
    background: var(--bg-controls);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    padding: 20px 16px;
    align-items: center;
    gap: 14px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.speed-slider-container.visible {
    display: flex;
}

.speed-slider-container label {
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.speed-slider-container input[type="range"] {
    flex: 1;
    height: 50px;
    cursor: pointer;
    accent-color: var(--accent);
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
}

.speed-slider-container input[type="range"]::-webkit-slider-runnable-track {
    height: 14px;
    background: var(--btn-bg);
    border-radius: 7px;
}

.speed-slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: 50%;
    margin-top: -11px;
    cursor: pointer;
}

.speed-slider-container #speedSliderValue {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 50px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    border: none;
    border-radius: 8px;
    background: var(--btn-bg);
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
    transition: background 0.15s ease;
    -webkit-user-select: none;
    user-select: none;
}

.btn:hover {
    background: var(--btn-hover);
}

.btn:active {
    background: rgba(255, 255, 255, 0.25);
}

.btn-play {
    background: var(--accent);
    color: white;
    font-size: 16px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

.btn-play:hover {
    background: var(--accent-hover);
}

.btn-play.playing {
    background: #ff6b6b;
}

.btn-play.playing:hover {
    background: #ff8787;
}

.btn-nav {
    font-size: 14px;
    min-width: 36px;
    min-height: 36px;
    border-radius: 6px;
}

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

.btn-close {
    font-size: 20px;
}

.btn-menu {
    font-size: 22px;
    min-width: 72px;
    min-height: 44px;
}

.controls-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-font {
    font-size: 16px;
    font-weight: 600;
    padding: 0 8px;
}

/* === Sidebar (Songs) === */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 370px;
    max-width: 85vw;
    z-index: 200;
    background: var(--sidebar-bg);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar-right {
    left: auto;
    right: 0;
    transform: translateX(100%);
}

.sidebar-right.open {
    transform: translateX(0);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    padding-top: calc(env(safe-area-inset-top, 0px) + 16px);
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 600;
}

/* === Song List === */
.song-search-container {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.song-search-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 16px;
    font-family: var(--font-ui);
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.15s ease;
}

.song-search-input:focus {
    border-color: var(--accent);
}

.song-search-input::placeholder {
    color: var(--text-secondary);
}

.song-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

.song-list li {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.1s ease;
}

.song-list li:hover {
    background: var(--song-hover);
}

.song-list li.active {
    background: var(--song-hover);
    border-left: 3px solid var(--accent);
}

.song-list li .song-item-title {
    font-size: 35px;
    font-weight: 500;
}

.song-list li .song-item-artist {
    display: none;
}

.song-list li.song-list-divider {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 12px 16px 6px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    cursor: default;
    position: sticky;
    top: 0;
    z-index: 1;
}

.song-list li.song-list-divider:hover {
    background: var(--bg-secondary);
}

/* === Setlist Content === */
.setlist-content {
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
    padding: 8px 0;
}

.setlist-item {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.1s ease;
}

.setlist-item:hover {
    background: var(--song-hover);
}

.setlist-item.active {
    background: var(--song-hover);
    border-left: 3px solid var(--accent);
}

.setlist-item-name {
    font-size: 15px;
    font-weight: 500;
}

.setlist-item-count {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.setlist-songs {
    list-style: none;
    padding: 0;
}

.setlist-songs li {
    padding: 10px 16px 10px 28px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    font-size: 14px;
    transition: background 0.1s ease;
}

.setlist-songs li:hover {
    background: var(--song-hover);
}

.setlist-songs li.active {
    color: var(--accent);
    font-weight: 500;
}

.setlist-songs li .song-number {
    color: var(--text-secondary);
    margin-right: 8px;
    font-size: 12px;
}

/* === Overlay === */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 150;
    background: rgba(0, 0, 0, 0.6);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

/* === Lyrics Container === */
.lyrics-container {
    position: fixed;
    top: 52px;
    bottom: 48px;
    left: 0;
    right: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 24px 20px;
    scroll-behavior: auto;
    background: #000000;
}

.lyrics-content {
    font-family: var(--font-lyrics);
    font-size: var(--lyrics-size);
    line-height: 1.8;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    max-width: 100%;
    padding-bottom: 60vh;
    min-height: 100%;
}

.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 220px);
    text-align: center;
    color: var(--text-secondary);
    font-family: var(--font-ui);
    font-size: 18px;
    gap: 12px;
}

.welcome-image {
    max-width: 90%;
    max-height: 70vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
}

.welcome-message p:first-child {
    font-size: 48px;
}

.lyrics-content.is-home {
    padding-bottom: 0;
}

/* Remove top padding only on the home/welcome screen */
.lyrics-container:has(.lyrics-content.is-home) {
    padding-top: 0;
}

/* Song separator within continuous scroll */
.song-separator {
    padding: 40px 0 20px 0;
    border-top: 2px solid var(--border-color);
    margin-top: 60px;
}

.song-separator:first-child {
    border-top: none;
    margin-top: 0;
    padding-top: 0;
}

.song-separator-title {
    font-family: var(--font-ui);
    font-size: var(--lyrics-size);
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    margin-bottom: 4px;
    overflow-wrap: anywhere;
}

.song-separator-artist {
    font-family: var(--font-ui);
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* === Song Info Footer === */
.song-info {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
    background: var(--bg-controls);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-color);
    min-height: 48px;
}

.song-title {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    margin-right: 8px;
}

.song-nav {
    display: flex;
    gap: 4px;
}

/* === Responsive === */
@media (max-width: 600px) {
    .lyrics-content {
        line-height: 1.7;
    }

    .controls-bar {
        padding: 6px 8px;
        padding-top: calc(env(safe-area-inset-top, 0px) + 6px);
    }
}

@media (min-width: 1024px) {
    .lyrics-content {
        max-width: 800px;
        margin: 0 auto;
    }

    .sidebar {
        width: 420px;
    }
}

/* === Scrollbar (subtle) === */
.lyrics-container::-webkit-scrollbar {
    width: 4px;
}

.lyrics-container::-webkit-scrollbar-track {
    background: transparent;
}

.lyrics-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

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