/* ============================================
   Hear Me Out — AI Music Generator
   Aurora palette with glassmorphism
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
    --bg: #080c1a;
    --glass: rgba(255, 255, 255, 0.04);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-hover: rgba(255, 255, 255, 0.07);
    --text: #f0eef5;
    --text-dim: #8a8a9a;
    --rose: #f472b6;
    --rose-glow: rgba(244, 114, 182, 0.3);
    --amber: #fbbf24;
    --amber-glow: rgba(251, 191, 36, 0.25);
    --teal: #2dd4bf;
    --teal-glow: rgba(45, 212, 191, 0.25);
    --coral: #fb7185;
    --lavender: #a78bfa;
    --accent: var(--rose);
    --accent-glow: var(--rose-glow);
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ---- Three.js Background ---- */
#bgCanvas {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0;
    pointer-events: none;
}

#particleOverlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 1;
    pointer-events: none;
    background:
        radial-gradient(ellipse at 20% 10%, rgba(244, 114, 182, 0.07) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(251, 191, 36, 0.05) 0%, transparent 45%),
        radial-gradient(ellipse at 60% 90%, rgba(45, 212, 191, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 10% 80%, rgba(167, 139, 250, 0.04) 0%, transparent 40%);
}

/* ---- App Layout ---- */
.app {
    position: relative;
    z-index: 10;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.screen {
    display: none;
    width: 100%;
    max-width: 640px;
    animation: fadeSlideUp 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
.screen.active { display: block; }

@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(40px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---- Glass Card ---- */
.glass {
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
}

/* ============================================
   INPUT SCREEN
   ============================================ */
.hero { text-align: center; margin-bottom: 40px; }

.logo-glow {
    width: 100px; height: 100px;
    margin: 0 auto 24px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--rose) 0%, var(--amber) 40%, transparent 70%);
    opacity: 0.35;
    filter: blur(25px);
    animation: breathe 4s ease-in-out infinite;
}

@keyframes breathe {
    0%, 100% { transform: scale(1); opacity: 0.35; }
    50% { transform: scale(1.4); opacity: 0.55; }
}

.title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 64px;
    font-weight: 700;
    letter-spacing: -2px;
    background: linear-gradient(135deg, #fff 0%, var(--rose) 40%, var(--amber) 70%, var(--teal) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    position: relative;
}

/* Glitch effect on hover */
.title.glitch:hover::before,
.title.glitch:hover::after {
    content: attr(data-text);
    position: absolute;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background: var(--bg);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.title.glitch:hover::before {
    animation: glitch1 0.3s infinite;
    color: var(--rose);
    -webkit-text-fill-color: var(--rose);
    clip-path: inset(20% 0 40% 0);
}
.title.glitch:hover::after {
    animation: glitch2 0.3s infinite;
    color: var(--teal);
    -webkit-text-fill-color: var(--teal);
    clip-path: inset(60% 0 10% 0);
}

@keyframes glitch1 {
    0% { transform: translate(0); }
    20% { transform: translate(-3px, 2px); }
    40% { transform: translate(3px, -2px); }
    60% { transform: translate(-2px, 1px); }
    80% { transform: translate(2px, -1px); }
    100% { transform: translate(0); }
}
@keyframes glitch2 {
    0% { transform: translate(0); }
    20% { transform: translate(3px, -2px); }
    40% { transform: translate(-3px, 2px); }
    60% { transform: translate(2px, -1px); }
    80% { transform: translate(-2px, 1px); }
    100% { transform: translate(0); }
}

.tagline {
    font-size: 16px;
    color: var(--text-dim);
    margin-top: 12px;
    font-weight: 300;
    letter-spacing: 0.5px;
}

.input-card {
    padding: 28px;
}

textarea {
    width: 100%;
    height: 140px;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 14px;
    color: var(--text);
    padding: 18px;
    font-size: 15px;
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    resize: none;
    transition: border-color 0.3s, box-shadow 0.3s;
}
textarea:focus {
    outline: none;
    border-color: var(--rose);
    box-shadow: 0 0 0 3px var(--rose-glow);
}
textarea::placeholder { color: #444; }

button {
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    border: none;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#generateBtn {
    margin-top: 18px;
    width: 100%;
    padding: 16px 28px;
    background: linear-gradient(135deg, var(--rose), var(--amber), var(--teal));
    background-size: 200% 200%;
    animation: gradientShift 5s ease infinite;
    color: #fff;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

#generateBtn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 0%, rgba(255,255,255,0.15) 50%, transparent 100%);
    transform: translateX(-100%);
    transition: transform 0.6s;
}
#generateBtn:hover::before { transform: translateX(100%); }
#generateBtn:hover { transform: translateY(-2px); box-shadow: 0 8px 30px var(--rose-glow); }
#generateBtn:active { transform: translateY(0); }
#generateBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn-icon {
    font-size: 20px;
    transition: transform 0.3s;
}
#generateBtn:hover .btn-icon { transform: translateX(4px); }

/* ============================================
   LOADING SCREEN
   ============================================ */
#loadingScreen {
    text-align: center;
}

.loader-container {
    width: 120px; height: 120px;
    margin: 0 auto 36px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pulse-ring {
    position: absolute;
    width: 100%; height: 100%;
    border-radius: 50%;
    border: 2px solid var(--rose);
    opacity: 0;
    animation: pulseOut 2s ease-out infinite;
}
.pulse-ring:nth-child(2) {
    border-color: var(--amber);
}
.pulse-ring:nth-child(3) {
    border-color: var(--teal);
}
.delay-1 { animation-delay: 0.5s; }
.delay-2 { animation-delay: 1s; }

@keyframes pulseOut {
    0% { transform: scale(0.5); opacity: 0.6; }
    100% { transform: scale(1.8); opacity: 0; }
}

.loader-icon {
    font-size: 36px;
    animation: float 2s ease-in-out infinite;
    background: linear-gradient(135deg, var(--rose), var(--amber));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 20px var(--rose-glow));
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.loader-text {
    font-size: 15px;
    color: var(--text-dim);
    margin-bottom: 24px;
    animation: fadeInOut 3s ease-in-out infinite;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.progress-bar {
    width: 260px;
    height: 3px;
    background: rgba(255,255,255,0.06);
    border-radius: 3px;
    margin: 0 auto;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--rose), var(--amber), var(--teal));
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* ============================================
   PLAYER SCREEN
   ============================================ */
.player-card {
    padding: 36px;
    text-align: center;
}

/* Vinyl art */
.album-art {
    width: 180px; height: 180px;
    margin: 0 auto 28px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, #1a1028, #0f1a2e, #1a1028, #0d1520, #1a1028);
    position: relative;
    box-shadow:
        0 0 60px rgba(244, 114, 182, 0.12),
        0 0 120px rgba(251, 191, 36, 0.06),
        inset 0 0 30px rgba(0,0,0,0.5);
}
.album-art.spinning { animation: spin 4s linear infinite; }

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.vinyl-ring {
    position: absolute;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.05);
}
.vinyl-ring:nth-child(1) { inset: 15%; }
.vinyl-ring.r2 { inset: 30%; border-color: rgba(244, 114, 182, 0.08); }
.vinyl-ring.r3 { inset: 45%; border-color: rgba(251, 191, 36, 0.1); }

.vinyl-label {
    position: absolute;
    inset: 38%;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--rose), var(--amber), var(--teal));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.track-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #fff, var(--rose));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.track-tags {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-bottom: 28px;
}
.tag {
    padding: 5px 14px;
    background: rgba(244, 114, 182, 0.08);
    border: 1px solid rgba(244, 114, 182, 0.15);
    border-radius: 20px;
    font-size: 12px;
    color: var(--rose);
    font-weight: 500;
    transition: all 0.3s ease;
}
.tag:nth-child(even) {
    background: rgba(45, 212, 191, 0.08);
    border-color: rgba(45, 212, 191, 0.15);
    color: var(--teal);
}
.tag:nth-child(3n) {
    background: rgba(251, 191, 36, 0.08);
    border-color: rgba(251, 191, 36, 0.15);
    color: var(--amber);
}

/* Audio Controls */
.audio-controls {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 32px;
    padding: 14px 18px;
    background: rgba(0,0,0,0.3);
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.04);
}

audio { display: none; }

.play-btn {
    width: 48px; height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--rose), var(--coral));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 20px var(--rose-glow);
}
.play-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 30px var(--rose-glow);
}

.waveform-bar {
    flex: 1;
    height: 40px;
    position: relative;
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
}
.waveform-progress {
    position: absolute;
    top: 0; left: 0;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, rgba(244, 114, 182, 0.2), rgba(251, 191, 36, 0.15), rgba(45, 212, 191, 0.2));
    pointer-events: none;
    z-index: 1;
}
#waveformCanvas {
    width: 100%;
    height: 100%;
    opacity: 0.5;
}

.time-display {
    font-size: 13px;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
    min-width: 36px;
    text-align: right;
}

/* Lyrics in player */
.lyrics-section, .narrative-section {
    text-align: left;
    margin-bottom: 24px;
}
.lyrics-section h3, .narrative-section h3 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-dim);
    margin-bottom: 14px;
    font-weight: 600;
}

.lyrics-static {
    white-space: pre-wrap;
    font-size: 15px;
    line-height: 2;
    color: var(--text);
    padding: 16px;
    background: rgba(0,0,0,0.2);
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.04);
}

.narrative-text {
    font-size: 13px;
    line-height: 1.8;
    color: var(--text-dim);
    max-height: 120px;
    overflow-y: auto;
    padding: 14px;
    background: rgba(0,0,0,0.2);
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.04);
}
.narrative-text::-webkit-scrollbar { width: 4px; }
.narrative-text::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }

.new-btn {
    padding: 12px 28px;
    color: var(--text-dim);
    font-size: 14px;
    font-weight: 500;
    border-radius: 12px;
}
.new-btn:hover {
    color: var(--text);
    background: var(--glass-hover);
}

/* ============================================
   LYRICS OVERLAY (fullscreen animated)
   ============================================ */
.lyrics-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    transition: opacity 0.6s;
    background: rgba(8, 12, 26, 0.8);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
}
.lyrics-overlay.hidden { opacity: 0; pointer-events: none; }
.lyrics-overlay.visible { opacity: 1; pointer-events: auto; }

.lyrics-close {
    position: absolute;
    top: 30px;
    right: 30px;
    width: 40px; height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    color: #888;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    cursor: pointer;
    border: none;
    transition: all 0.3s;
    z-index: 51;
}
.lyrics-close:hover { background: rgba(255,255,255,0.15); color: #fff; }

.lyrics-mini-controls {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 16px;
    pointer-events: auto;
}
.lyrics-mini-controls .mini-play {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: rgba(244, 114, 182, 0.25);
    border: 1px solid rgba(244, 114, 182, 0.4);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.lyrics-mini-controls .mini-play:hover { background: rgba(244, 114, 182, 0.4); }
.lyrics-mini-time {
    font-size: 13px;
    color: #666;
    font-variant-numeric: tabular-nums;
}

.lyrics-lines {
    text-align: center;
    padding: 0 40px;
    max-height: 70vh;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-behavior: smooth;
}
.lyrics-lines::-webkit-scrollbar { display: none; }

/* ---- Lyrics Lines ---- */
.lyrics-line {
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(26px, 4.5vw, 48px);
    font-weight: 700;
    color: rgba(255,255,255,0.85);
    line-height: 1.5;
    margin-bottom: 12px;
    transition: all 0.5s ease;
}

/* ---- Section Labels ---- */
.lyrics-section-label {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 6px;
    background: linear-gradient(90deg, var(--rose), var(--amber));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 20px;
    transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0.7;
    transform: translateY(0);
}

/* ============================================
   ITERATE PANEL
   ============================================ */
.iterate-section {
    margin-top: 24px;
    width: 100%;
}

.iterate-toggle {
    width: 100%;
    padding: 14px 24px;
    border: 1px solid rgba(45, 212, 191, 0.3);
    border-radius: 12px;
    background: rgba(45, 212, 191, 0.08);
    color: var(--teal);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
}
.iterate-toggle:hover {
    background: rgba(45, 212, 191, 0.15);
    border-color: var(--teal);
    box-shadow: 0 0 20px var(--teal-glow);
}
.iterate-icon {
    font-size: 18px;
}

.iterate-panel {
    margin-top: 16px;
    padding: 24px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.iterate-controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.iterate-row label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 10px;
}

.iterate-input-group {
    display: flex;
    align-items: center;
    gap: 14px;
}

.iterate-input-group input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
}
.iterate-input-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--rose), var(--amber));
    cursor: pointer;
    box-shadow: 0 0 10px var(--rose-glow);
}
.iter-val {
    font-size: 16px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--rose), var(--amber));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    min-width: 40px;
    text-align: right;
}

.iterate-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.6);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.25s ease;
}
.chip:hover {
    border-color: rgba(244, 114, 182, 0.4);
    color: rgba(255, 255, 255, 0.9);
    background: rgba(244, 114, 182, 0.1);
}
.chip.active {
    background: linear-gradient(135deg, rgba(244, 114, 182, 0.2), rgba(251, 191, 36, 0.15));
    border-color: var(--rose);
    color: #fff;
    box-shadow: 0 0 12px var(--rose-glow);
}

.iterate-notes {
    width: 100%;
    min-height: 60px;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    outline: none;
    transition: border-color 0.3s ease;
}
.iterate-notes:focus {
    border-color: rgba(244, 114, 182, 0.4);
}
.iterate-notes::placeholder {
    color: rgba(255, 255, 255, 0.25);
}

.iterate-btn {
    margin-top: 20px;
    width: 100%;
    padding: 14px 24px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, var(--coral), var(--rose), var(--amber));
    background-size: 200% 200%;
    animation: gradientShift 4s ease infinite;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px var(--rose-glow);
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.iterate-btn:hover {
    box-shadow: 0 6px 30px var(--rose-glow);
    transform: translateY(-1px);
}
.iterate-btn:active {
    transform: translateY(0);
}

/* ============================================
   COMPUTER VISION UI
   ============================================ */

/* Webcam overlay */
.webcam-overlay {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 240px;
    height: 180px;
    border-radius: 16px;
    overflow: hidden;
    z-index: 40;
    border: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 0;
    transform: scale(0.8) translateY(20px);
    transition: opacity 0.4s ease, transform 0.4s ease;
    pointer-events: none;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}
.webcam-overlay.visible {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}
.cv-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

.emotion-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    font-size: 24px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
}

/* Effect indicator bar */
.effect-indicators {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    display: flex;
    gap: 8px;
    z-index: 40;
    opacity: 0;
    transition: opacity 0.4s ease, transform 0.4s ease;
    pointer-events: none;
}
.effect-indicators.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.fx-pill {
    padding: 6px 12px;
    border-radius: 20px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-dim);
    transition: all 0.3s ease;
    white-space: nowrap;
}
.fx-pill.active {
    border-color: var(--rose);
    color: var(--rose);
    background: rgba(244, 114, 182, 0.1);
    box-shadow: 0 0 12px var(--rose-glow);
}
.fx-label {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 9px;
}
.fx-val {
    font-variant-numeric: tabular-nums;
    font-size: 11px;
}

/* Gesture guide */
.gesture-guide {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 340px;
    max-height: 80vh;
    z-index: 55;
    background: rgba(8, 12, 26, 0.95);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 24px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.gesture-guide.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}
.gesture-guide-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.gesture-guide-header h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 16px;
    background: linear-gradient(135deg, var(--rose), var(--amber));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.gesture-guide-close {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: #888;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
}
.gesture-guide-close:hover { background: rgba(255, 255, 255, 0.15); color: #fff; }

.gesture-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.gesture-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 13px;
    color: var(--text-dim);
}
.gesture-icon {
    font-size: 18px;
    width: 32px;
    text-align: center;
    flex-shrink: 0;
}

/* Emotion heatmap */
.emotion-heatmap {
    margin-top: 12px;
    border-radius: 8px;
    overflow: hidden;
}
.emotion-heatmap canvas {
    width: 100%;
    height: 20px;
    border-radius: 6px;
}
.heatmap-legend {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 8px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.legend-warm { color: var(--rose); }
.legend-cool { color: var(--teal); }
.legend-gray { color: var(--text-dim); }

/* Refinement modal */
.refinement-modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(8, 12, 26, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}
.refinement-modal.visible {
    opacity: 1;
    pointer-events: auto;
}
.refinement-content {
    max-width: 440px;
    width: 90%;
    padding: 32px;
    text-align: center;
}
.refinement-content h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 20px;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--rose), var(--amber), var(--teal));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.refinement-desc {
    font-size: 14px;
    color: var(--text-dim);
    line-height: 1.7;
    margin-bottom: 20px;
}
.refinement-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}
.refinement-accept {
    width: 100%;
    padding: 14px 24px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--rose), var(--amber), var(--teal));
    background-size: 200% 200%;
    animation: gradientShift 4s ease infinite;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    box-shadow: 0 4px 20px var(--rose-glow);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.refinement-accept:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px var(--rose-glow);
}
.refinement-decline {
    padding: 10px;
    background: transparent;
    color: var(--text-dim);
    font-size: 13px;
    border-radius: 8px;
}
.refinement-decline:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
}

/* CV control buttons on player */
.cv-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 16px;
    margin-bottom: 12px;
}
.cv-btn {
    padding: 10px 18px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 8px;
}
.cv-btn:hover {
    color: var(--text);
    background: var(--glass-hover);
}
.cv-btn.active {
    border-color: var(--teal);
    color: var(--teal);
    background: rgba(45, 212, 191, 0.1);
}
.cv-icon {
    font-size: 16px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 500px) {
    .title { font-size: 48px; }
    .player-card { padding: 24px; }
    .album-art { width: 140px; height: 140px; }
    .webcam-overlay { width: 160px; height: 120px; bottom: 10px; right: 10px; }
    .effect-indicators { flex-wrap: wrap; max-width: 90vw; bottom: 140px; }
    .fx-pill { padding: 4px 8px; font-size: 10px; }
    .gesture-guide { width: 90vw; }
    .history-panel { max-height: 300px; }
    .meditation-card { padding: 24px; }
    .player-actions { flex-direction: column; gap: 8px; }
    .chatbot-panel { width: 100%; right: -100%; }
    .chatbot-panel.open { right: 0; }
    .q-card { padding: 20px; }
    .q-options { flex-direction: column; }
}

/* === MANIK: History, Download, Meditation === */

/* ---- Player Action Buttons (Download, Meditate) ---- */
.player-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
    margin-bottom: 8px;
}
.action-btn {
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 8px;
}
.action-btn:hover {
    color: var(--text);
    background: var(--glass-hover);
    border-color: var(--amber);
    box-shadow: 0 0 15px var(--amber-glow);
}
.action-icon {
    font-size: 16px;
}

/* ---- History Panel ---- */
.history-section {
    margin-top: 24px;
    width: 100%;
}
.history-toggle {
    width: 100%;
    padding: 12px 20px;
    border: 1px solid rgba(167, 139, 250, 0.3);
    border-radius: 12px;
    background: rgba(167, 139, 250, 0.08);
    color: var(--lavender);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
}
.history-toggle:hover {
    background: rgba(167, 139, 250, 0.15);
    border-color: var(--lavender);
    box-shadow: 0 0 20px rgba(167, 139, 250, 0.25);
}
.history-icon {
    font-size: 16px;
}
.history-panel {
    margin-top: 12px;
    max-height: 400px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #333 transparent;
}
.history-panel::-webkit-scrollbar { width: 4px; }
.history-panel::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }

.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.history-item {
    padding: 16px;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}
.history-item:hover {
    background: var(--glass-hover);
    border-color: var(--lavender);
    box-shadow: 0 0 15px rgba(167, 139, 250, 0.15);
}
.history-date {
    font-size: 11px;
    color: var(--text-dim);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.history-snippet {
    font-size: 14px;
    color: var(--text);
    line-height: 1.5;
    margin-bottom: 8px;
}
.history-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}
.history-tag {
    padding: 3px 10px;
    background: rgba(244, 114, 182, 0.08);
    border: 1px solid rgba(244, 114, 182, 0.15);
    border-radius: 12px;
    font-size: 11px;
    color: var(--rose);
}
.history-tag:nth-child(even) {
    background: rgba(45, 212, 191, 0.08);
    border-color: rgba(45, 212, 191, 0.15);
    color: var(--teal);
}
.history-replay-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    padding: 5px 14px;
    border-radius: 8px;
    background: rgba(167, 139, 250, 0.15);
    border: 1px solid rgba(167, 139, 250, 0.3);
    color: var(--lavender);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.history-replay-btn:hover {
    background: rgba(167, 139, 250, 0.3);
}
.history-loading, .history-empty {
    text-align: center;
    color: var(--text-dim);
    font-size: 13px;
    padding: 24px;
}

/* ---- Meditation Screen ---- */
.meditation-card {
    padding: 40px;
    text-align: center;
    min-height: 60vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.meditation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
}
.meditation-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 22px;
    font-weight: 600;
    background: linear-gradient(135deg, var(--teal), var(--lavender));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.meditation-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: #888;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: all 0.3s;
}
.meditation-close:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}
.meditation-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 40px;
}
.meditation-breath-ring {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 2px solid var(--teal);
    opacity: 0.4;
    animation: meditationBreathe 6s ease-in-out infinite;
}
@keyframes meditationBreathe {
    0%, 100% { transform: scale(0.8); opacity: 0.3; border-color: var(--teal); }
    50% { transform: scale(1.3); opacity: 0.6; border-color: var(--lavender); }
}
.meditation-text {
    font-size: 20px;
    line-height: 1.8;
    color: var(--text);
    max-width: 480px;
    transition: opacity 0.5s ease;
    font-weight: 300;
    letter-spacing: 0.3px;
}
.meditation-progress-bar {
    width: 200px;
    height: 2px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 2px;
    margin: 30px auto;
    overflow: hidden;
}
.meditation-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--teal), var(--lavender));
    border-radius: 2px;
    transition: width 0.8s ease;
}
.meditation-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
}
.meditation-btn {
    padding: 10px 24px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-dim);
    cursor: pointer;
}
.meditation-btn:hover {
    color: var(--text);
    background: var(--glass-hover);
}

/* === SYED: Ethics Disclaimer, Questionnaire, Chatbot === */

/* ---- Ethics Modal ---- */
.ethics-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(8, 12, 26, 0.95);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}
.ethics-modal.visible {
    opacity: 1;
    pointer-events: auto;
}
.ethics-content {
    max-width: 520px;
    width: 90%;
    padding: 36px;
    text-align: center;
}
.ethics-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 28px;
    background: linear-gradient(135deg, #fff, var(--rose), var(--amber));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.ethics-body {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 24px;
}
.ethics-item {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}
.ethics-icon {
    font-size: 24px;
    flex-shrink: 0;
    width: 36px;
    text-align: center;
}
.ethics-item strong {
    display: block;
    font-size: 14px;
    color: var(--text);
    margin-bottom: 4px;
}
.ethics-item p {
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.6;
}
.ethics-optout {
    margin-bottom: 24px;
    padding: 14px 18px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}
.ethics-toggle-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-dim);
}
.ethics-toggle-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--rose);
    cursor: pointer;
}
.ethics-accept-btn {
    width: 100%;
    padding: 16px 28px;
    background: linear-gradient(135deg, var(--rose), var(--amber), var(--teal));
    background-size: 200% 200%;
    animation: gradientShift 5s ease infinite;
    color: #fff;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 600;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.ethics-accept-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px var(--rose-glow);
}

/* ---- Questionnaire ---- */
.q-card {
    padding: 32px;
    max-height: 85vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #333 transparent;
}
.q-card::-webkit-scrollbar { width: 4px; }
.q-card::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }
.q-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #fff, var(--rose), var(--amber));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.q-subtitle {
    font-size: 14px;
    color: var(--text-dim);
    margin-bottom: 28px;
    line-height: 1.5;
}
.q-questions {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 24px;
}
.q-item {
    text-align: left;
}
.q-text {
    font-size: 14px;
    color: var(--text);
    margin-bottom: 10px;
    line-height: 1.5;
}
.q-options {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.q-option {
    flex: 1;
    min-width: 80px;
    padding: 10px 8px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-dim);
    font-size: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    transition: all 0.25s ease;
}
.q-option:hover {
    border-color: rgba(244, 114, 182, 0.3);
    background: rgba(244, 114, 182, 0.05);
    color: var(--text);
}
.q-option.selected {
    border-color: var(--rose);
    background: rgba(244, 114, 182, 0.15);
    color: #fff;
    box-shadow: 0 0 12px var(--rose-glow);
}
.q-score-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    transition: all 0.25s ease;
}
.q-option.selected .q-score-dot {
    background: var(--rose);
    box-shadow: 0 0 8px var(--rose-glow);
}
.q-label {
    font-size: 11px;
    text-align: center;
}
.q-warning {
    color: var(--coral);
    font-size: 13px;
    margin-bottom: 16px;
    text-align: center;
}
.q-submit-btn {
    width: 100%;
    padding: 16px 28px;
    background: linear-gradient(135deg, var(--rose), var(--amber), var(--teal));
    background-size: 200% 200%;
    animation: gradientShift 5s ease infinite;
    color: #fff;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.q-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px var(--rose-glow);
}

/* Questionnaire Result */
.q-result {
    text-align: center;
}
.q-result-card {
    padding: 40px 32px;
    text-align: center;
}
.q-result-icon {
    font-size: 48px;
    margin-bottom: 20px;
    background: linear-gradient(135deg, var(--rose), var(--amber));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 20px var(--rose-glow));
}
.q-result-text {
    font-size: 16px;
    color: var(--text);
    line-height: 1.7;
    margin-bottom: 28px;
}
.q-result-btn {
    padding: 14px 32px;
    background: linear-gradient(135deg, var(--teal), var(--lavender));
    color: #fff;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
}
.q-result-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px var(--teal-glow);
}

/* ---- Chatbot Panel ---- */
.chatbot-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 380px;
    height: 100vh;
    z-index: 80;
    background: rgba(8, 12, 26, 0.97);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-left: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.5);
}
.chatbot-panel.open {
    right: 0;
}
.chatbot-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.chatbot-header h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 16px;
    background: linear-gradient(135deg, var(--rose), var(--amber));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.chatbot-close {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: #888;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
}
.chatbot-close:hover { background: rgba(255, 255, 255, 0.15); color: #fff; }

.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: #333 transparent;
}
.chatbot-messages::-webkit-scrollbar { width: 4px; }
.chatbot-messages::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }

.chat-welcome {
    text-align: center;
    padding: 40px 20px;
}
.chat-welcome p {
    font-size: 14px;
    color: var(--text-dim);
    line-height: 1.7;
}

.chat-msg {
    display: flex;
    max-width: 85%;
}
.chat-msg.user {
    align-self: flex-end;
}
.chat-msg.assistant {
    align-self: flex-start;
}
.chat-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
}
.chat-msg.user .chat-bubble {
    background: linear-gradient(135deg, rgba(244, 114, 182, 0.2), rgba(251, 191, 36, 0.15));
    border: 1px solid rgba(244, 114, 182, 0.3);
    color: var(--text);
    border-bottom-right-radius: 4px;
}
.chat-msg.assistant .chat-bubble {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text);
    border-bottom-left-radius: 4px;
}
.chat-bubble.typing {
    color: var(--text-dim);
    animation: fadeInOut 1.5s ease-in-out infinite;
}

.chatbot-use-song {
    padding: 12px 20px;
    margin: 0 20px;
    background: rgba(45, 212, 191, 0.1);
    border: 1px solid rgba(45, 212, 191, 0.3);
    border-radius: 12px;
    color: var(--teal);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.chatbot-use-song:hover {
    background: rgba(45, 212, 191, 0.2);
    border-color: var(--teal);
}

.chatbot-input-row {
    padding: 16px 20px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-shrink: 0;
}
.chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.3);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    min-height: 42px;
    line-height: 1.4;
}
.chatbot-input:focus {
    outline: none;
    border-color: rgba(244, 114, 182, 0.4);
}
.chatbot-input::placeholder {
    color: rgba(255, 255, 255, 0.25);
}
.chatbot-send {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--rose), var(--amber));
    color: #fff;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 15px var(--rose-glow);
}
.chatbot-send:hover {
    transform: scale(1.08);
}

/* Chatbot trigger button on input screen */
.chatbot-trigger {
    width: 100%;
    padding: 12px 18px;
    margin-top: 12px;
    border-radius: 12px;
    font-size: 13px;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.chatbot-trigger:hover {
    color: var(--text);
    background: var(--glass-hover);
    border-color: rgba(244, 114, 182, 0.3);
}
