:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-dark: #0f172a;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent-glow: rgba(99, 102, 241, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 0;
    overflow-y: auto;
}

.glass-container {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 40px;
    width: 100%;
    max-width: 600px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

header {
    text-align: center;
    margin-bottom: 24px;
}

header h1 {
    font-size: 3rem;
    font-weight: 600;
    letter-spacing: -1px;
}

header h1 span {
    color: var(--primary);
}

header p {
    color: var(--text-muted);
    font-size: 1rem;
}

/* Main Navigation (Tabs) */
.main-nav {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 32px;
    padding: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    border: 1px solid var(--glass-border);
}

.nav-tab {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.nav-tab:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.nav-tab.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px var(--accent-glow);
}

/* View Sections */
.view-section {
    display: block;
    animation: fadeInView 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.view-section.hidden {
    display: none;
}

@keyframes fadeInView {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Bass View Specials */
.bass-preview-container {
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed var(--glass-border);
    border-radius: 20px;
    padding: 60px 40px;
    text-align: center;
    margin-bottom: 40px;
}

.placeholder-text {
    color: var(--text-muted);
    font-style: italic;
    font-size: 1.1rem;
}

.controls {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    /* Key(Short) Scale(Long) BPM(Short) */
    gap: 16px 20px;
    /* Vertical gap 16, Horizontal 20 */
    margin-bottom: 24px;
    align-items: end;
}

/* Specific Placements */
.group-key {
    grid-column: 1;
    grid-row: 1;
}

.group-scale {
    grid-column: 2;
    grid-row: 1;
}

.group-bpm {
    grid-column: 3;
    grid-row: 1;
}

.group-sound {
    grid-column: 1 /span 2;
    grid-row: 2;
}

.group-oct {
    grid-column: 3;
    grid-row: 2;
}

/* Position Arp Toggle next to Octave? No, let's put it in the Sound row if there's space, or separate.
   Actually, let's make a 3rd row for Sound options if needed, but we wanted to declutter.
   Let's try a different grid: 
   Row 1: Key | Scale | BPM 
   Row 2: Sound | Octave | Arp
   Columns: 2fr 0.8fr 0.8fr ?
*/
.controls {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr 1fr 1fr;
    grid-template-areas:
        "key scale scale bpm oct"
        "sound sound div div arp";
    gap: 16px;
    margin-bottom: 24px;
    align-items: center;
    /* Center vertically for toggle alignment */
}

/* Reset individual placements to use areas */
.group-key {
    grid-area: key;
}

.group-scale {
    grid-area: scale;
}

.group-bpm {
    grid-area: bpm;
}

.group-sound {
    grid-area: sound;
}

.group-oct {
    grid-area: oct;
}

.group-div {
    grid-area: div;
}

.group-arp {
    grid-area: arp;
    margin-top: 6px;
    /* Visual adjustment for label alignment */
}

/* Place Generate button in the controls grid?
   No, it should probably be separate.
   But to fix spacing:
   1. Move effects toggler up to align with the controls better or make it less prominent.
   2. Add consistent margin between Generate and Chord Grid.
*/

.effects-toggle-container {
    display: flex;
    justify-content: flex-end;
    /* Align to right? or Center? */
    justify-content: center;
    margin-bottom: 24px;
    margin-top: -8px;
    /* Pull up closer to controls */
}

/* Adjust Generate Button spacing */
.group-gen {
    margin-bottom: 32px;
    /* MORE space before chord grid */
}

.chord-grid {
    margin-bottom: 40px;
}

.small-btn {
    padding: 8px 16px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: 1px dashed var(--glass-border);
}

.small-btn:hover {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.05);
}

.chevron {
    width: 16px;
    height: 16px;
    transition: transform 0.3s ease;
}

.effects-section {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 16px;
    margin-bottom: 24px;
    background: rgba(255, 255, 255, 0.03);
    padding: 16px;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1;
    max-height: 200px;
    /* Arbitrary enough height */
    overflow: hidden;
    transform: translateY(0);
}

.effects-section.hidden {
    opacity: 0;
    max-height: 0;
    margin-bottom: 0;
    padding: 0 16px;
    /* Keep horizontal padding to prevent width jank, remove vertical */
    padding-top: 0;
    padding-bottom: 0;
    transform: translateY(-10px);
    border: none;
}

.expanded .chevron {
    transform: rotate(180deg);
}

.effect-control {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.effect-control label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 700;
}

/* Range Slider Styling */
.fx-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    outline: none;
    padding: 0;
    border: none;
}

.fx-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--primary);
    cursor: pointer;
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent-glow);
    transition: all 0.2s ease;
}

.fx-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: white;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.control-group.toggle-group {
    /* Align toggle switch better in grid */
    justify-content: flex-end;
    padding-bottom: 11px;
    align-items: flex-end;
}

/* Make Generate button span full width if it's on a new row alone,
   or just make it prominent in the grid */
.primary-btn {
    grid-column: 1 / -1;
    margin-top: 0;
    width: 100%;
    height: 48px;
    font-size: 1rem;
    font-weight: 600;
}

/* On larger screens, maybe let the button sit in the flow if there is space? 
   Actually, a full width 'Generate' bar usually looks premium. 
   Let's try that first as per 'premium' directive. */

.control-group label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
}

select,
input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 12px;
    border-radius: 12px;
    outline: none;
    transition: all 0.3s ease;
}

select:focus,
input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--accent-glow);
}

.primary-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px var(--accent-glow);
}

#save-btn,
#export-btn {
    display: none;
    /* Hidden by default */
    min-width: 80px;
    /* Prevent width changes */
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid var(--glass-border);
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.secondary-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

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

.btn-group {
    display: flex;
    gap: 16px;
    align-items: center;
}

/* Icon Button Standardization */
.icon-only-btn {
    width: 52px;
    height: 52px;
    border-radius: 50% !important;
    padding: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.icon-only-btn svg {
    width: 24px;
    height: 24px;
}

/* Legacy Action Deck styles removed - now handled in mobile-base.css */

.main-action {
    position: relative;
    flex: 0 0 auto;
    /* Keep play button size fixed */
}

/* FAB Play Button Enhancement */
.fab-btn {
    width: 68px !important;
    height: 68px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, var(--primary) 0%, #4438ca 100%) !important;
    box-shadow: 0 10px 30px var(--accent-glow) !important;
    border: 2px solid rgba(255, 255, 255, 0.15) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

.fab-btn:hover {
    transform: scale(1.1) translateY(-4px) !important;
    box-shadow: 0 15px 35px var(--accent-glow), 0 0 20px var(--primary) !important;
    background: linear-gradient(135deg, #818cf8 0%, var(--primary) 100%) !important;
}

.fab-btn svg {
    width: 36px;
    height: 36px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.fab-btn:active {
    transform: scale(0.95) !important;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border: 1px solid var(--glass-border);
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked+.slider {
    background-color: var(--primary);
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--primary);
}

input:checked+.slider:before {
    transform: translateX(22px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

.chord-bank-container {
    margin-bottom: 32px;
    padding: 24px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 20px;
    border: 1px solid var(--glass-border);
}

.chord-bank-container label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 700;
    display: block;
    margin-bottom: 20px;
    text-align: center;
}

.chord-bank {
    display: flex;
    flex-wrap: nowrap;
    gap: 16px;
    overflow-x: auto;
    padding: 10px 10px 24px 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) rgba(255, 255, 255, 0.05);
}

/* Custom scrollbar for webkit */
.chord-bank::-webkit-scrollbar {
    height: 6px;
}

.chord-bank::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.chord-bank::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

.bank-chord {
    flex: 0 0 140px;
    height: 140px;
    cursor: grab;
}

.bank-chord:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-4px);
}

.bank-placeholder {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.9rem;
    opacity: 0.7;
}

.chord-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 40px;
}

.chord-slot {
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 600;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    cursor: grab;
    /* Enable grab cursor */
    user-select: none;
}

.chord-slot:active {
    cursor: grabbing;
}

.chord-slot.dragging {
    opacity: 0.5;
    border-style: dashed;
    transform: scale(0.95);
}

.chord-slot.drag-over {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.2);
    /* Tint with primary color */
    transform: scale(1.05);
}

.chord-slot.active-slot {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.15);
    box-shadow: 0 0 20px var(--accent-glow);
    transform: scale(1.05);
}

.chord-slot.active {
    border-color: var(--primary);
    background: var(--accent-glow);
    transform: scale(1.05);
}

.chord-slot.empty {
    color: var(--glass-border);
    font-size: 2rem;
}

.chord-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* Lists Layout */
.list-toggle-nav {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
    padding: 4px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.nav-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.nav-btn:hover {
    color: var(--text-main);
}

.nav-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.lists-container {
    margin-top: 12px;
}

.list-section {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.list-section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#favorite-btn {
    display: none;
    min-width: 50px;
    color: var(--text-muted);
}

#favorite-btn svg {
    width: 20px;
    height: 20px;
}

#favorite-btn.is-favorite,
.heart-btn.is-favorite {
    color: #ef4444;
    /* Heart Red */
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.4);
}

.icon-only-btn {
    padding: 12px !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-list {
    max-height: 220px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-right: 6px;
}

/* Scrollbar polish */
.history-list::-webkit-scrollbar {
    width: 4px;
}

.history-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
}

.history-list::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 4px;
}

.history-item {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    /* Slightly slower for noticeability */
    position: relative;
    overflow: visible;
}

.history-item.deleting {
    transform: translateX(100px);
    opacity: 0;
    pointer-events: none;
}

/* ... existing hover styles ... */

.history-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--primary);
    opacity: 0.5;
    transition: opacity 0.2s;
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
}

/* ... existing hover::before ... */

.history-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    /* Increased gap */
}

.history-meta {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.history-title {
    font-weight: 700;
    color: white;
    font-size: 1rem;
    letter-spacing: -0.02em;
    line-height: 1.4;
    /* Ensure line height */
}

.history-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: monospace;
}

.history-chords {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
    font-family: 'Outfit', sans-serif;
    opacity: 0.9;
    line-height: 1.4;
    /* Ensure line height */
}

.history-settings-preview {
    font-size: 0.7rem;
    color: var(--primary);
    opacity: 0.8;
    margin-top: 2px;
    font-weight: 500;
}

.history-actions {
    display: flex;
    gap: 8px;
    margin-left: 16px;
}

.icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid transparent;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.05);
}

.icon-btn[title="Delete"]:hover {
    background: #ef4444;
    /* Red for delete */
}

.icon-btn.active {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--primary);
    color: white;
}

.icon-btn.active:hover {
    background: rgba(99, 102, 241, 0.3);
}

.history-placeholder {
    padding: 30px;
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    border: 1px dashed var(--glass-border);
}

.playback-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    margin-bottom: 40px;
    position: relative;
    background: rgba(255, 255, 255, 0.03);
    padding: 20px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
}

.action-bar .btn-group {
    flex: 0 0 auto;
    display: flex;
    gap: 8px;
}

.play-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--primary);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.play-btn svg {
    width: 32px;
    height: 32px;
}

.play-btn:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 10px 15px -3px var(--accent-glow);
}

.play-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.tempo-control {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tempo-control label {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.tempo-control input {
    width: 80px;
    text-align: center;
}

@media (max-width: 600px) {
    .controls {
        grid-template-areas:
            "key scale"
            "bpm oct"
            "sound sound"
            "arp gen";
        grid-template-columns: 1fr 1fr;
    }
}