:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --accent-primary: #6366f1;
    --accent-secondary: #a855f7;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass-border: rgba(255, 255, 255, 0.1);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: 'Inter', -apple-system, sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at top right, #1e1b4b, #0f172a);
    overflow-x: hidden;
}

/* Main App Structure */
#app {
    width: 100%;
    max-width: 1400px;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 0;
}

/* SETUP VIEW - Centered Dashboard */
.setup-container {
    width: 100%;
    max-width: 800px;
    padding: 1rem;
    animation: fadeIn 0.5s ease-out;
}

.settings-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.settings-card h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.8rem;
    margin-bottom: 0.5rem;
}

/* STUDY VIEW - Full Screen */
.active-session-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: slideUp 0.5s ease-out;
    padding: 1rem;
}

.session-header {
    width: 100%;
    max-width: 1200px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    margin-bottom: 1rem;
}

.main-content {
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Card Container tweaks for study view */
.card-container {
    perspective: 1000px;
    cursor: pointer;
    margin-bottom: 2rem;
    /* Responsive sizing handled via max-width */
    width: 90vw;
    max-width: 600px;
    height: 60vh;
    max-height: 400px;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

.flashcard {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-container.flipped .flashcard {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.card-face.back {
    transform: rotateY(180deg);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(168, 85, 247, 0.1));
}

.audio-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.play-button {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--accent-primary);
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-glow);
}

.visualizer {
    display: flex;
    gap: 4px;
    height: 40px;
    align-items: center;
}

.bar {
    width: 4px;
    background: var(--accent-primary);
    border-radius: 2px;
    animation: bounce 1.2s ease-in-out infinite;
}

@keyframes bounce {

    0%,
    100% {
        height: 10px;
        opacity: 0.5;
    }

    50% {
        height: 30px;
        opacity: 1;
    }
}

.species-name {
    font-family: 'Playfair Display', serif;
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.vocalization-type {
    font-size: 1.2rem;
    color: var(--text-muted);
}

.species-image-container {
    width: 100%;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#speciesImage {
    max-width: 100%;
    max-height: 200px;
    border-radius: 12px;
    object-fit: contain;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.attribution {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
    text-align: center;
    max-width: 90%;
}

.location-tag {
    margin-top: 1rem;
    padding: 0.4rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    font-size: 0.9rem;
}

.controls {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.rating-group {
    display: flex;
    gap: 0.5rem;
}

.rating-btn {
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    border: none;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.rating-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.rating-btn.again {
    background: #ef4444;
}

.rating-btn.hard {
    background: #f59e0b;
}

.rating-btn.good {
    background: #10b981;
}

.rating-btn.easy {
    background: #3b82f6;
}

button.primary,
button.secondary {
    padding: 0.8rem 2.5rem;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
}

button.primary {
    background: var(--accent-primary);
    color: white;
}

button.secondary {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-main);
}

button:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.hidden {
    display: none !important;
}

.hidden-card {
    display: none !important;
}

.dropdown-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #1e293b;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    margin-top: 4px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 50;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.dropdown-item {
    padding: 0.8rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    font-size: 0.9rem;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background: var(--accent-primary);
    color: white;
}

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

/* New Session Creation UI */
.create-session-btn {
    width: 100%;
    margin-top: auto;
    padding: 1rem;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    border: none;
    border-radius: 16px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    box-shadow: var(--shadow-glow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.create-session-btn:hover:not(:disabled) {
    transform: translateY(-4px) scale(1.02);
    filter: brightness(1.2);
}

.create-session-btn:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
}

.create-session-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--text-muted);
    box-shadow: none;
}

.progress-banner {
    width: 100%;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid var(--accent-primary);
    border-radius: 12px;
    padding: 0.5rem 1rem;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.progress-bar-bg {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    width: 0%;
    height: 100%;
    background: var(--accent-primary);
    transition: width 0.3s ease;
}

.settings-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.settings-group h4 {
    font-size: 0.75rem;
    color: var(--accent-primary);
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

#keyStatus {
    font-weight: 600;
    letter-spacing: 0.02em;
}

.advanced-toggle {
    margin-top: auto;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
    cursor: pointer;
    text-decoration: underline;
    opacity: 0.5;
}

.advanced-toggle:hover {
    opacity: 1;
}

/* Species List Summary Area */
#speciesListSummary {
    animation: fadeIn 0.3s ease-in-out;
    max-height: 200px;
    display: flex;
    flex-direction: column;
}

#speciesListPreview {
    font-family: 'Inter', sans-serif;
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    max-height: 120px;
    overflow-y: auto;
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--text-muted);
}

#speciesListPreview::-webkit-scrollbar {
    width: 4px;
}

#speciesListPreview::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
    border-radius: 2px;
}

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

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