/* ========================================
    Global Layout Constants & Transitions
    ======================================== */
:root {
    --header-height: 64px;
    --tab-button-height: 52px;
    --padding-base: 1.5rem;
    --border-radius-base: 1rem;
    --transition-speed: 0.3s ease-in-out;
}

/* ========================================
    Theme Definitions
    ======================================== */
/* ========================================
   RED DARK THEME
   ======================================== */
:root,
[data-theme="dark"],
[data-theme="amoled-dark"] {
    /* Background Colors */
    --bg-primary: #0d0004;
    --bg-secondary: #1a0c0e;
    --bg-tertiary: #5e0010;
    --bg-hover: #7a0212;
    --bg-active: #9e001c;

    /* Text Colors */
    --text-primary: #fdfbfa;
    --text-secondary: #b89a9f;
    --text-muted: #885e66;

    /* Accent Colors */
    --accent-primary: #c1001f;
    --accent-secondary: #e52e3b;
    --accent-hover: #ff475a;
    --accent-active: #7a0212;
    --accent-glow: rgba(255, 71, 90, 0.3);

    /* Borders */
    --border: #9e001c;
    --border-light: #b89a9f;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(255, 71, 90, 0.05), 0 1px 2px rgba(255, 71, 90, 0.1);
    --shadow-md: 0 4px 6px rgba(255, 71, 90, 0.1), 0 1px 3px rgba(255, 71, 90, 0.05);
    --shadow-lg: 0 10px 25px rgba(255, 71, 90, 0.1), 0 5px 10px rgba(255, 71, 90, 0.05);

    /* Status Colors */
    --success: #00e600;
    --warning: #e6e600;
    --danger: #e60000;
    --info: #00cccc;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #0d0004 0%, #1a0c0e 100%);
    --gradient-accent: linear-gradient(135deg, #c1001f 0%, #e52e3b 100%);
}

/* ========================================
   RED LIGHT THEME
   ======================================== */
[data-theme="light"] {
    /* Background Colors */
    --bg-primary: #fdfbfa;
    --bg-secondary: #f0dada;
    --bg-tertiary: #f7d0d0;
    --bg-hover: #ffc0c0;
    --bg-active: #ffaaaa;

    /* Text Colors */
    --text-primary: #0d0004;
    --text-secondary: #5e0010;
    --text-muted: #9e001c;

    /* Accent Colors */
    --accent-primary: #c1001f;
    --accent-secondary: #9e001c;
    --accent-hover: #7a0212;
    --accent-active: #e52e3b;
    --accent-glow: rgba(193, 0, 31, 0.3);

    /* Borders */
    --border: #b89a9f;
    --border-light: #dcafb0;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(193, 0, 31, 0.12), 0 1px 2px rgba(193, 0, 31, 0.24);
    --shadow-md: 0 4px 6px rgba(193, 0, 31, 0.1), 0 1px 3px rgba(193, 0, 31, 0.08);
    --shadow-lg: 0 10px 25px rgba(193, 0, 31, 0.1), 0 5px 10px rgba(193, 0, 31, 0.05);

    /* Status Colors */
    --success: #008000;
    --warning: #cc9900;
    --danger: #cc0000;
    --info: #006666;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #fdfbfa 0%, #f0dada 100%);
    --gradient-accent: linear-gradient(135deg, #c1001f 0%, #9e001c 100%);
}



/* ========================================
    Base & Global Styles
    ======================================== */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    margin: 0;
    font-size: 1rem;
    transition: background-color var(--transition-speed), color var(--transition-speed);
    overflow-x: hidden; /* Prevent horizontal scrolling */
    box-sizing: border-box; /* Include padding and border in the element's total width and height */
}

/* Ensure images and other media don't overflow their containers */
img, video, iframe {
    max-width: 100%;
    height: auto;
    display: block;
}

/* General responsive utility to prevent elements from breaking layout */
* {
    box-sizing: border-box;
}

mark {
    background-color: var(--accent-glow, yellow);
    padding: 0 2px;
    border-radius: 3px;
}

/* Specific adjustments for elements that might cause overflow */
.page-content,
.toolbar {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* ========================================
    Header & Navigation
    ======================================== */
.app-header {
    background-color: var(--bg-secondary);
    padding: 0em 0 0em 0; /* Top/bottom padding for header content */
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: background-color var(--transition-speed), border-color var(--transition-speed), box-shadow var(--transition-speed);
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.5rem 1rem;
    gap: 1rem;
    flex-wrap: wrap;
    position: relative;
}

.app-logo-img {
    max-height: 40px;
}


.theme-toggle-wrapper {
    min-width: 120px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-left: 1.3rem;
}

.theme-select {
    font-size: 0.95rem;
    padding: 0.3rem 1.2rem;
    border-radius: var(--border-radius-base);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    opacity: 0.85;
    margin-right: 0.1rem;
    max-width: 170px;
    transition: background var(--transition-speed), border-color var(--transition-speed), color var(--transition-speed);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg fill="%23CCC" 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 0.7em top 50%, 0 0;
    background-size: 0.65em auto, 100%;
}

.theme-select option {
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
}

.sort-select {
    font-size: 0.8rem;
    padding: 0.3rem 0.6rem;
    border-radius: var(--border-radius-base);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    margin-left: 0;
}

.page-content, .tab {
  overflow: visible !important;
}

.tab-toolbar {
  width: 100%;
  margin-top: 0.3em;
  margin-bottom: 0.1em;
  display: flex;
  gap: 1em;
  align-items: center;
  background: transparent; /* inherits header background */
  /* Optional: soft divider line */
  border-bottom: 1px solid var(--border, #222);
  padding-bottom: 0.32em;
  min-height: 2.5em;
}


.app-nav {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 2.1rem;
    padding: 0.29rem 0 0.03rem 0;
    background: none;
    box-shadow: none;
    margin-bottom: 1em;
    border: none;
}


.nav-button {
    font-size: 1.11rem;
    padding: 0.6rem 1.19rem 0.6rem 1.19rem;
    border-radius: var(--border-radius-base);
    background: none;
    border: none;
    color: var(--text-secondary);
    transition: background var(--transition-speed), color var(--transition-speed), box-shadow var(--transition-speed);
    box-shadow: none;
    margin-bottom: 0;
    position: relative;
    cursor: pointer;
}

.nav-button:hover {
    background: var(--bg-hover);
    color: var(--accent-hover);
    box-shadow: 0 0 6px var(--accent-glow);
}

.nav-button.active {
    color: var(--accent-primary);
    background: var(--bg-active);
    border-bottom: 2px solid var(--accent-primary);
    font-weight: bold;
    box-shadow: 0 0 7px var(--accent-glow), 0 0 0 var(--accent-glow);
    z-index: 2;
    font-size: 1rem;
    transition: box-shadow var(--transition-speed), color var(--transition-speed), background var(--transition-speed), border-color var(--transition-speed);
}

.icon-btn {
  background: none;
  border: none;
  color: var(--accent-secondary, #aaa);
  font-size: 1.2em;
  cursor: pointer;
  opacity: 0.85;
  transition: color 0.22s, opacity 0.15s;
}
.icon-btn:hover, .icon-btn:focus {
  color: var(--accent-primary, #fff);
  opacity: 1;
}

.theme-icon-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: none;
  border: none;
  color: var(--accent-secondary, #888);
  font-size: 1rem;
  cursor: pointer;
  opacity: 0.82;
  z-index: 100;
  transition: color 0.22s, opacity 0.14s;
}
.theme-icon-btn:hover, .theme-icon-btn:focus {
  color: var(--accent-primary, #fff);
  opacity: 1;
}
/* ========================================
    Media Queries (already structured, just apply new variables)
    ======================================== */
@media (max-width: 800px) {
    .app-header {
        padding: 0 0 0.5rem 0;
    }
    .header-top {
        flex-direction: row;
        align-items: center;
        justify-content: center;
        padding: 0.5rem;
    }
    .app-logo-img {
        max-height: 32px;
    }
    .app-title {
        font-size: 1.08rem;
        padding-left: 0.2rem;
    }
    .app-nav {
        gap: 1.1rem;
        padding: 0.5rem 0 0 0;
    }
    .app-header {
        flex-direction: column;
        align-items: stretch;
        padding: 0.75rem 0.5rem 0.5rem 0.5rem;
    }
    .app-nav {
        gap: 1rem;
    }
    .app-title {
        margin: 0.25rem 0;
        font-size: 1.15rem;
    }
    .theme-toggle-wrapper {
        margin-top: 0.4rem;
        margin-bottom: 0.4rem;
        justify-content: flex-end;
    }
}

/* Tablet specific adjustments (768px - 1024px roughly) */
@media (min-width: 768px) and (max-width: 1024px) {
    .app-logo-text {
        font-size: 1.8rem; /* Slightly smaller logo on tablets */
    }
    .app-nav {
        gap: 1.5rem; /* Reduced gap for nav buttons */
    }

    .nav-button {
        font-size: 1rem; /* Slightly smaller nav buttons */
        padding: 0.5rem 1rem;
    }

    #tab-toolbar {
        gap: 0.8rem; /* Reduced gap in toolbar */
        padding: 0.6rem 1rem; /* Reduced padding in toolbar */
    }

    .column {
        padding: 1rem; /* Reduced padding in columns */
    }

    .song-item {
        padding: 0.8rem; /* Reduced padding for song items */
        font-size: 0.95rem; /* Slightly smaller font for song items */
    }


    #song-title-input, #song-lyrics-input {
        padding: 0.5rem; /* Smaller input padding in modals */
        font-size: 0.95rem;
    }

    .editor-header {
        padding: 0.3em 0.5em; /* Reduced padding in editor header */
        font-size: 0.8em;
    }

    .editor-header h2,
    .editor-header .song-info h2 {
        font-size: 1.1em; /* Smaller song title in editor */
    }

    .lyrics-container {
        font-size: 1rem; /* Base font size for lyrics on mobile */
        padding: 1em 0.8em 1.5em 0.8em !important; /* Adjusted padding for lyrics */
        line-height: 1.4 !important; /* Slightly more relaxed line-height for readability */
    }

    .nav-arrow {
        font-size: 1.8rem; /* Slightly smaller nav arrows */
        padding: 0.6rem 0.9rem;
    }

    .scroll-to-top-btn,
    .auto-scroll-btn {
        width: 48px; /* Smaller floating buttons */
        height: 48px;
        font-size: 1.4rem;
        right: 2em; /* Adjust position */
    }

    .scroll-to-top-btn {
        bottom: 100px; /* Adjust position */
    }

    .auto-scroll-btn {
        bottom: 40px; /* Adjust position */
    }

    #font-size-slider.font-slider {
        width: 250px !important; /* Smaller slider */
        margin: 0 1em;
    }

    .theme-btn {
        min-width: 8em;
        max-width: 8em;
        font-size: 1.05em;
        padding: 0.6em 0;
    }
}



/* ========================================
    Animations and Tab Content
    ======================================== */
.neon-pulse {
    animation: neon-pulse 1.5s infinite alternate;
}

@keyframes neon-pulse {
    from {
        text-shadow: 0 0 10px var(--accent-primary); /* Uses accent primary */
    }
    to {
        text-shadow: 0 0 20px var(--accent-primary), 0 0 30px var(--accent-primary);
    }
}

.tab {
    display: none;
}

.tab.active {
    display: block;
}

.page-content {
    padding: var(--padding-base); /* Using base padding */
}

/* ========================================
    Toolbar and Buttons
    ======================================== */
/* Toolbar layout */
.toolbar {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: var(--padding-base);
    align-items: stretch;
    padding: 0 0.5rem;
}

/* Group wrapper for toolbar buttons */
.toolbar-buttons-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.toolbar-buttons-group > .sort-select {
    height: 2.5rem;
    padding: 0 0.5rem;
    border-radius: var(--border-radius-base);
    min-width: 6rem;
}

.search-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    margin: 0;
    background-color: var(--bg-hover); /* Inputs use tertiary background */
    color: var(--text-primary);
    border: 1px solid var(--border); /* Input borders use main border */
    border-radius: var(--border-radius-base); /* Using base border radius */
    transition: background-color var(--transition-speed), color var(--transition-speed), border-color var(--transition-speed);
}

.search-input::placeholder {
    color: var(--text-secondary); /* Placeholder text uses muted text color */
}

.btn {
    background-color: var(--accent-primary); /* Buttons use accent primary */
    color: var(--bg-primary); /* Text on buttons should contrast, using bg-primary for dark themes */
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--border-radius-base); /* Using base border radius */
    cursor: pointer;
    transition: background-color var(--transition-speed), color var(--transition-speed), box-shadow var(--transition-speed);
    box-shadow: var(--shadow-sm); /* Adding a subtle shadow to buttons */
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn:hover {
    background-color: var(--accent-hover);
    box-shadow: var(--shadow-md);
}

.btn.icon-btn {
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border-radius: 50%;
}

.btn:active {
    background-color: var(--accent-active);
}

.btn.danger {
    background-color: var(--danger); /* Danger button uses danger color */
    color: var(--text-primary); /* Ensure contrast on danger button */
}
.btn.danger:hover {
    filter: brightness(0.9);
}

.hidden-file {
    /* Modified to work better on mobile devices */
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    opacity: 0.01; /* Not completely invisible to ensure it's clickable */
    pointer-events: auto; /* Ensure it can receive clicks */
}

/* ========================================
    Song List and Setlist Editor
    ======================================== */
.song-list {
    list-style: none;
    padding: 0;
}

.song-item {
    background-color: var(--bg-tertiary); /* Song items use tertiary background */
    padding: 0.7rem 1rem; /* Reduced vertical padding */
    margin-bottom: 0.3rem; /* Reduced margin between items */
    border-radius: var(--border-radius-base); /* Using base border radius */
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border-light); /* Lighter border for song items */
    box-shadow: var(--shadow-sm);
    transition: background-color var(--transition-speed), border-color var(--transition-speed), box-shadow var(--transition-speed);
}

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

.column {
    flex: 1;
    background-color: var(--bg-secondary); /* Columns use secondary background */
    padding: 0.8rem; /* Reduced padding */
    border-radius: var(--border-radius-base); /* Using base border radius */
    min-height: 250px; /* Slightly reduced min-height */
    border: 1px solid var(--border); /* Column borders use main border */
    box-shadow: var(--shadow-md); /* Adding shadow to columns */
    transition: background-color var(--transition-speed), border-color var(--transition-speed), box-shadow var(--transition-speed);
}


/* ========================================
    Editor Mode
    ======================================== */
.editor-mode-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-primary); /* Overlay uses primary background */
    z-index: 1000;
    display: none;
    flex-direction: column;
    transition: background-color var(--transition-speed);
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background-color: var(--bg-secondary); /* Editor header uses secondary background */
    border-bottom: 1px solid var(--border);
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

.lyrics-container {
    flex-grow: 1;
    overflow-y: auto;
    font-size: 1rem; /* Base size, slider still works */
    padding: 1rem;
    text-align: center;
    line-height: 1.33;
    color: var(--text-primary); /* Lyrics use primary text color */
    transition: color var(--transition-speed);
    word-break: break-word;
    white-space: pre-wrap;
    max-width: 900px;
    margin: 0 auto;
}

.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-secondary, #222); /* Subtle background */
    color: var(--accent-secondary, #888);   /* From theme, less “clowny” */
    border: none;
    font-size: 2.1rem;
    cursor: pointer;
    padding: 0.7rem 1rem;
    border-radius: var(--border-radius-base, 10px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    opacity: 0.75;
    transition: background 0.22s, color 0.15s, opacity 0.22s;
    z-index: 1010;
}

.nav-arrow:hover, .nav-arrow:focus {
    background: var(--bg-hover, #333);
    color: var(--accent-primary, #fff);   /* Highlight only on hover */
    opacity: 1;
}

.nav-arrow.left { left: 0.5em; }
.nav-arrow.right { right: 0.5em; }

#song-title-input, #song-lyrics-input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.6rem;
    border-radius: 10px;
    border: 1.5px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: 0.5rem;
    transition: border-color 0.2s;
}

#song-title-input:focus, #song-lyrics-input:focus {
    border-color: var(--accent-primary);
    outline: none;
    box-shadow: 0 0 8px var(--accent-glow);
}

#song-lyrics-input {
    min-height: 6rem;
    max-height: 60vh;
    resize: vertical;
    font-family: inherit;
    font-size: 1rem;
}

/* Empty state messages */
.empty-message {
    color: var(--text-secondary);
    font-style: italic;
    text-align: center;
    padding: 40px 20px;
    margin: 0;
}

/* Disabled button states */
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}


.drag-handle {
    cursor: grab;
    font-size: 1.3em;
    opacity: 0.6;
    margin-right: 10px;
    user-select: none;
    transition: opacity 0.15s;
}
.song-item:active .drag-handle,
.song-item .drag-handle:active {
    opacity: 1;
}
.drag-ghost {
    opacity: 0.7 !important;
    background: var(--accent-glow) !important;
}

.editor-header {
    padding: 0.45em 0.65em;
    font-size: 0.88em;
    min-height: unset;
}

.editor-header h2,
.editor-header .song-info h2 {
    margin: 0;
    font-size: 1.25em;
    line-height: 1.1;
    font-weight: bold;
}

.editor-controls {
    gap: 0.4em;
}

#editor-song-info h2 {
    font-size: 1.13em;
    margin-bottom: 0.15em;
}

#font-size-slider.font-slider {
    width: 350px !important;    /* Make it nice and long */
    accent-color: var(--accent-primary, #00bcd4);
    height: 20px;
    margin: 0 1.5em;
    background: var(--bg-tertiary, #222);
    border-radius: 8px;
}
.editor-header label[for="font-size-slider"] {
    display: none;
}

#exit-editor-btn,
#toggle-theme-btn {
    padding: 0.1em 0.45em;
    font-size: 1em;
    min-width: 24px;
    min-height: 24px;
}

/* Optional: Only show auto-scroll button in editor mode */
#editor-mode[style*="display: flex"] .auto-scroll-btn {
    display: flex !important;
}
#editor-mode:not([style*="display: flex"]) .auto-scroll-btn,
#editor-mode[style*="display: none"] .auto-scroll-btn {
    display: none !important;
}

.song-progress {
  font-size: 1.02em;
  color: var(--accent-secondary, #aaa);
  margin-top: 0.1em;
  margin-bottom: 0.4em;
  letter-spacing: 0.06em;
  opacity: 0.75;
  text-align: left;
  font-family: inherit;
}

.main-logo-img {
    display: block;
    max-width: 95vw;
    max-height: 110px;
    margin: 0.7em auto 0.6em auto;
    border-radius: 11px;
    box-shadow: 0 4px 24px 1px rgba(0,0,0,0.27), 0 0 13px 1px var(--accent-glow, #fff4);
    background: transparent;
    filter: drop-shadow(0 0 8px var(--accent-glow, #fff6)) brightness(1.06) contrast(1.04);
    transition: filter 0.28s, box-shadow 0.22s;
}



/* For smaller screens, go even smaller */
@media (max-width: 700px) {
  .main-logo-img {
      max-height: 55px;
      margin-top: 0.25em;
      margin-bottom: 0.22em;
  }
}

/* If you ever want to tweak even further on the tiniest phones */
@media (max-width: 500px) {
  .main-logo-img {
      max-height: 38px;
  }
}

@media (max-width: 800px) {
  .header-top {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100% !important;
    padding: 0 !important;
  }
}

/* Ensure tab content also stretches to fill, if necessary */
.tab.active {
    display: flex; /* Change from block to flex to ensure content stretches */
    flex-direction: column;
    flex-grow: 1; /* Allow active tab to grow and fill space */
}

.page-content {
    flex-grow: 1; /* Allow page content to grow */
    display: flex;
    flex-direction: column;
    /* Ensure padding doesn't cause overflow */
    box-sizing: border-box;
    padding: var(--padding-base); /* Keep your padding */
}

/* ========================================
    Media Queries (Corrected)
    ======================================== */

/* Tablet and Phone Adjustments (max-width: 800px) */
@media (max-width: 800px) {
    .app-header {
        padding: 0 0 0.5rem 0;
    }
    
    /* === LOGO CENTERING FIX === */
    /* We must set .header-top to 100% width on mobile/tablet 
       to allow the logo to center correctly across the full screen. 
       The existing 70% rule was the root cause. */
    .header-top {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 100% !important; 
        padding: 0 !important;
    }

    .app-title {
        font-size: 1.08rem;
        padding-left: 0.2rem;
    }
    /* ... (rest of the existing 800px media query styles) ... */
    
    /* Remove any redundant @media (max-width: 800px) block that might be at the end of the file */
}


/* === BACKGROUND VOID FIX === */
/* Ensure the main content containers fill the available height */
.tab.active {
    /* Change display from 'block' to 'flex' and allow it to stretch */
    display: flex;
    flex-direction: column;
    flex-grow: 1; 
}

.page-content {
    /* Ensure the page content also fills its container */
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: var(--padding-base); 
}

html, body {
  height: 100%;
  min-height: 100vh;
  background: var(--bg-primary, #000) !important;
  overflow-x: hidden;
  box-sizing: border-box;
}

.main-box { /* Add this new rule for .main-box */
    display: flex;
    flex-direction: column;
    min-height: 100vh; /* Ensure it's at least viewport height */
    flex-grow: 1; /* Allow it to grow and fill space */
}

main { /* Add this new rule for main */
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Allow main content area to grow */
}

.tab.active {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.page-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: var(--padding-base);
}
html, body {
  height: 100%;
  min-height: 100vh;
  background: var(--bg-primary, #000) !important;
}

#bg-filler {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--bg-primary, #000); /* Or use any color you want */
  z-index: 0;
  pointer-events: none;
}

.main-box {
  position: relative;
  z-index: 1;
}
html, body {
  background: var(--bg-primary, #000) !important;
  min-height: 100vh;
  height: 100%;
  margin: 0;
  padding: 0;
}




/* === MOBILE FIX PATCH v2 === */
@media (max-width: 480px) {
  /* Buttons (Play, Add, Delete, etc) */
  .btn,
  .icon-btn,
  .perform-song-btn{
    font-size: 0.75rem !important;
    padding: 0.32rem 0.5rem !important;
    min-width: 2.2em !important;
    min-height: 2.2em !important;
  }
  
  .song-btn{
    font-size: 0.75rem !important;
    padding: 0.32rem 0.5rem !important;
    min-width: 2.2em !important;
    min-height: 2.2em !important;
  }
  
  .delete-song-btn {
    font-size: 0.75rem !important;
    padding: 0.32rem 0.5rem !important;
    min-width: 2.2em !important;
    min-height: 2.2em !important;
  }
  
  .app-header {
    flex-direction: column;
    align-items: center;
  }
  
  .header-top {
    display: flex;
    align-items: center;
    width: 50% !important;
    justify-content: space-between;
    padding: 0.29rem 1.2rem 0.11rem 1.27rem;
  }
  
  .header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 70% !important;
    margin-bottom: 1rem !important;
    margin-top: 1rem !important;
  }
  
  .app-image-logo {
    width: 100rem;
  }
    
  .edit-song-btn {
    font-size: 0.75rem !important;
    padding: 0.32rem 0.5rem !important;
    min-width: 2.2em !important;
    min-height: 2.2em !important;
  }
  
  /* Song items */
  .song-item {
    padding: 0.3rem 0.4rem !important;
    font-size: 0.6rem !important;
  }

  .song-title,
  .song-item span {
    max-width: 70vw !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    display: inline-block !important;
    vertical-align: middle;
  }

  .song-item {
    font-size: 0.75rem !important;
    background-color: var(--bg-tertiary); /* Song items use tertiary background */
    padding: 0.3rem 0.5rem !important;
    margin-bottom: 0.3rem; /* Reduced margin between items */
    border-radius: var(--border-radius-base); /* Using base border radius */
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border-light); /* Lighter border for song items */
    box-shadow: var(--shadow-sm);
    transition: background-color var(--transition-speed), border-color var(--transition-speed), box-shadow var(--transition-speed);
  }
  }
  

  /* Reduce lyric container padding for tighter view */
  .lyrics-container {
    padding: 0.6em 0.3em 1em 0.3em !important;
    font-size: 1rem !important;
  }
}



/* ========================================
    Enhanced Song List Styles
    ======================================== */
.song-item {
    background-color: var(--bg-tertiary);
    padding: 1rem;
    margin-bottom: 0.5rem;
    border-radius: var(--border-radius-base);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-speed);
    cursor: pointer;
}

.song-item:hover {
    background-color: var(--bg-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.song-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.song-title {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.song-metadata {
    display: flex;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--accent-primary);
    font-weight: 500;
}

.song-details {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.song-tags {
    color: var(--accent-secondary);
    font-style: italic;
}

.song-edited {
    color: var(--text-muted);
}


.song-actions {
    display: flex;
    gap: 0.25rem;
    align-items: flex-start;
    flex-shrink: 0;
}

.song-actions .icon-btn {
    background: var(--bg-secondary);
    color: var(--accent-secondary);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.song-actions .icon-btn:hover {
    background: var(--accent-primary);
    color: var(--bg-primary);
    transform: scale(1.05);
}

/* ========================================
    Metadata Editor Styles
    ======================================== */
.metadata-editor {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-base);
    padding: 1.5rem;
    margin: 1rem 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.metadata-row {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.metadata-row label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.metadata-row input,
.metadata-row select,
.metadata-row textarea {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--border-radius-base);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: border-color 0.2s ease;
}

.metadata-row input:focus,
.metadata-row select:focus,
.metadata-row textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.metadata-row textarea {
    min-height: 80px;
    resize: vertical;
    font-family: inherit;
}

.metadata-row small {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 0.25rem;
}



/* ========================================
    Toast Notification Styles
    ======================================== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 10000;
}

.toast {
    position: relative;
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius-base);
    color: white;
    font-weight: 500;
    font-size: 0.9rem;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 300px;
    box-shadow: var(--shadow-lg);
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-success {
    background: linear-gradient(135deg, #10b981, #059669);
}

.toast-error {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.toast-info {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
}

/* ========================================
    Mobile Optimizations
    ======================================== */
@media (max-width: 600px) {
    .song-item {
        padding: 0.75rem;
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .song-info {
        width: 100%;
    }
    
    .song-actions {
        width: 100%;
        justify-content: flex-end;
        gap: 0.5rem;
    }

    .song-actions .icon-btn {
        width: 2.25rem;
        height: 2.25rem;
        font-size: 0.9rem;
    }
    
    .metadata-editor {
        padding: 1rem;
        margin: 0.5rem 0;
    }
    
    .metadata-row {
        gap: 0.5rem;
    }
    

    .toast-container {
        top: auto;
        bottom: 20px;
        right: 20px;
        left: 20px;
    }

    .toast {
        transform: translateY(100%);
        max-width: none;
    }

    .toast.show {
        transform: translateY(0);
    }
}

/* ========================================
    Improved Mobile Song List
    ======================================== */
@media (max-width: 480px) {
    .song-item {
        padding: 0.5rem;
        margin-bottom: 0.4rem;
    }
    
    .song-title {
        font-size: 1rem;
    }
    
    .song-metadata {
        font-size: 0.8rem;
        flex-wrap: wrap;
    }
    
    .song-details {
        font-size: 0.75rem;
    }
    
    .song-actions {
        gap: 0.3rem;
    }

    .song-actions .icon-btn {
        width: 2rem;
        height: 2rem;
        font-size: 0.8rem;
    }
    
    .metadata-row input,
    .metadata-row select,
    .metadata-row textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* === HEADER LAYOUT REWRITE (safe drop-in) === */
.app-header { position: sticky; top: 0; z-index: 100; }
.header-top { 
  position: relative;
  display: flex; 
  align-items: center; 
  justify-content: flex-start; 
  gap: 0.75rem;
  width: 100%;
  padding: 0.6rem 0.9rem;
}

/* Logo sizing (scales across breakpoints) */
.app-logo { display: flex; align-items: center; }
.app-logo-img {
  height: auto;
  max-height: clamp(56px, 6vh + 2vw, 88px); /* bigger everywhere */
  width: auto;
}


/* ===== Tablet tune-up ===== */
@media (min-width: 700px) and (max-width: 1024px) {
  .app-logo-img { max-height: 80px; }
}

