:root {
    /* Telegram-inspired color palette */
    --bg-primary: #0F0F0F;
    --bg-secondary: #1C1C1E;
    --bg-tertiary: #2C2C2E;
    --bg-elevated: rgba(255, 255, 255, 0.05);
    --bg-glass: rgba(28, 28, 30, 0.8);
    
    --accent-blue: #3390EC;
    --accent-blue-light: #5BA0F0;
    --accent-gradient: linear-gradient(135deg, #3390EC 0%, #229ED9 100%);
    
    --text-primary: #FFFFFF;
    --text-secondary: rgba(255, 255, 255, 0.6);
    --text-tertiary: rgba(255, 255, 255, 0.35);
    
    --red: #FF3B30;
    --red-soft: rgba(255, 59, 48, 0.15);
    
    --border-subtle: rgba(255, 255, 255, 0.08);
    --shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 40px rgba(51, 144, 236, 0.15);
    
    --app-height: 100vh;
    --timing-smooth: cubic-bezier(0.25, 0.1, 0.25, 1);
    --timing-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   ROTATION WARNING
======================================== */
#rotation-warning {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    z-index: 99999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
}

@media screen and (orientation: landscape) {
    #rotation-warning { display: flex; }
    .main-container { display: none !important; }
}

.rotation-icon {
    font-size: 64px;
    margin-bottom: 24px;
    animation: gentle-rotate 2.5s ease-in-out infinite;
}

@keyframes gentle-rotate {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(-90deg); }
}

.rotation-text {
    font-size: 17px;
    font-weight: 500;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ========================================
   SELFIE LIGHT OVERLAY
======================================== */
#selfie-light-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    display: none;
    background: #FFFFFF;
    opacity: 0.95;
    -webkit-mask-image: radial-gradient(circle 160px at 50% 180px, transparent 0%, transparent 140px, black 160px);
    mask-image: radial-gradient(circle 160px at 50% 180px, transparent 0%, transparent 140px, black 160px);
}

/* ========================================
   MAIN CONTAINER
======================================== */
.main-container {
    width: 100%;
    height: var(--app-height);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 20px;
    padding-bottom: 100px;
    overflow: hidden;
    position: relative;
    background: var(--bg-primary);
}

/* ========================================
   CAMERA WITH PROGRESS RING
======================================== */
.camera-container {
    position: relative;
    width: 280px;
    height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 12px;
    margin-bottom: 24px;
    flex-shrink: 0;
}

.camera-wrapper {
    width: 256px;
    height: 256px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--bg-secondary);
    position: absolute;
    z-index: 10;
    box-shadow: var(--shadow-soft);
    border: 2px solid var(--border-subtle);
    transition: transform 0.3s var(--timing-bounce), box-shadow 0.3s ease;
}

.camera-wrapper.recording {
    box-shadow: var(--shadow-soft), 0 0 0 3px var(--red-soft);
}

video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}

video.front-camera {
    transform: scaleX(-1);
}

/* Progress Ring */
.progress-ring {
    position: absolute;
    width: 280px;
    height: 280px;
    transform: rotate(-90deg);
    z-index: 5;
    filter: drop-shadow(0 0 8px rgba(255, 59, 48, 0.3));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.progress-ring.active {
    opacity: 1;
}

.progress-ring-bg {
    fill: none;
    stroke: var(--border-subtle);
    stroke-width: 3;
}

.progress-ring-circle {
    fill: none;
    stroke: var(--red);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 879.6; /* 2 * PI * 140 */
    stroke-dashoffset: 879.6;
    transition: stroke-dashoffset 0.1s linear;
}

/* ========================================
   CAMERA CONTROLS
======================================== */
.camera-controls-row {
    display: flex;
    gap: 12px;
    margin-bottom: 32px;
    flex-shrink: 0;
}

.camera-control-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-elevated);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s var(--timing-smooth);
    color: var(--text-secondary);
}

.camera-control-btn:active {
    transform: scale(0.92);
    background: var(--bg-tertiary);
}

.camera-control-btn.active {
    background: rgba(255, 214, 10, 0.15);
    border-color: rgba(255, 214, 10, 0.3);
    color: #FFD60A;
}

.camera-control-btn svg {
    width: 22px;
    height: 22px;
}

.camera-control-btn svg path {
    fill: currentColor;
}

/* ========================================
   TRACK CARDS - Swiper Cards Effect
======================================== */
.track-swiper-container {
    width: 100%;
    max-width: 340px;
    position: relative;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.track-swiper {
    width: 280px;
    height: 180px;
    overflow: visible !important;
}

.track-swiper .swiper-wrapper {
    width: 100%;
    height: 100%;
}

.track-swiper .swiper-slide {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    background: var(--bg-glass);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-soft);
    overflow: hidden;
}

.track-swiper .swiper-slide-active {
    border-color: var(--accent-blue);
    box-shadow: var(--shadow-glow), var(--shadow-soft);
}

/* Track Card Content */
.track-card {
    width: 100%;
    height: 100%;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.track-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    letter-spacing: -0.3px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
}

/* Swipe Hint */
.swipe-hint-container {
    display: flex;
    justify-content: center;
    margin-top: 8px;
}

.swipe-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-tertiary);
    animation: hint-pulse 2s ease-in-out infinite;
}

.swipe-hint.hidden {
    display: none;
}

@keyframes hint-pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.swipe-hint::before,
.swipe-hint::after {
    content: '';
    width: 20px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--text-tertiary));
    border-radius: 1px;
}

.swipe-hint::after {
    background: linear-gradient(90deg, var(--text-tertiary), transparent);
}

/* Track Card Index Badge */
.track-index {
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    background: var(--bg-elevated);
    padding: 4px 8px;
    border-radius: 10px;
}

/* ========================================
   EQUALIZER - Smooth Pulsing Waves
======================================== */
.equalizer {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 3px;
    height: 48px;
    width: 100%;
    padding: 0 16px;
}

.eq-bar {
    width: 4px;
    height: 6px;
    background: var(--accent-blue);
    border-radius: 2px;
    transition: height 0.1s ease-out, opacity 0.1s ease-out;
    will-change: height, opacity;
}

/* Idle state - elegant wave animation */
.equalizer:not(.active) .eq-bar {
    animation: eq-wave 1.2s ease-in-out infinite;
}

/* Staggered delays for wave effect - center-out pattern */
.equalizer:not(.active) .eq-bar:nth-child(1) { animation-delay: 0.40s; }
.equalizer:not(.active) .eq-bar:nth-child(2) { animation-delay: 0.35s; }
.equalizer:not(.active) .eq-bar:nth-child(3) { animation-delay: 0.30s; }
.equalizer:not(.active) .eq-bar:nth-child(4) { animation-delay: 0.25s; }
.equalizer:not(.active) .eq-bar:nth-child(5) { animation-delay: 0.20s; }
.equalizer:not(.active) .eq-bar:nth-child(6) { animation-delay: 0.15s; }
.equalizer:not(.active) .eq-bar:nth-child(7) { animation-delay: 0.10s; }
.equalizer:not(.active) .eq-bar:nth-child(8) { animation-delay: 0.05s; }
.equalizer:not(.active) .eq-bar:nth-child(9) { animation-delay: 0.05s; }
.equalizer:not(.active) .eq-bar:nth-child(10) { animation-delay: 0.10s; }
.equalizer:not(.active) .eq-bar:nth-child(11) { animation-delay: 0.15s; }
.equalizer:not(.active) .eq-bar:nth-child(12) { animation-delay: 0.20s; }
.equalizer:not(.active) .eq-bar:nth-child(13) { animation-delay: 0.25s; }
.equalizer:not(.active) .eq-bar:nth-child(14) { animation-delay: 0.30s; }
.equalizer:not(.active) .eq-bar:nth-child(15) { animation-delay: 0.35s; }
.equalizer:not(.active) .eq-bar:nth-child(16) { animation-delay: 0.40s; }

@keyframes eq-wave {
    0%, 100% { 
        height: 6px; 
        opacity: 0.3;
        background: var(--accent-blue);
    }
    25% { 
        height: 20px; 
        opacity: 0.6;
    }
    50% { 
        height: 36px; 
        opacity: 1;
        background: var(--accent-blue-light);
    }
    75% { 
        height: 20px; 
        opacity: 0.6;
    }
}

/* Active playing - controlled by JS */
.equalizer.active .eq-bar {
    animation: none;
}

/* ========================================
   RECORDING BAR - Telegram Style
======================================== */
.record-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-glass);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    z-index: 1000;
    transform: translateY(100%);
    opacity: 0;
    transition: transform 0.35s var(--timing-smooth), opacity 0.35s ease;
}

.record-bar.visible {
    transform: translateY(0);
    opacity: 1;
}

.record-bar.hidden {
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
}

.record-bar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.record-bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Blinking Record Dot */
.record-dot {
    width: 10px;
    height: 10px;
    background: var(--red);
    border-radius: 50%;
    animation: dot-blink 1s ease-in-out infinite;
    box-shadow: 0 0 8px var(--red);
}

@keyframes dot-blink {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}

/* Timer */
.record-timer {
    font-size: 17px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    min-width: 72px;
    letter-spacing: 0.5px;
}

/* Cancel Button */
.cancel-btn {
    background: none;
    border: none;
    color: var(--accent-blue);
    font-size: 17px;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 12px;
    margin-left: 4px;
    border-radius: 8px;
    transition: all 0.15s ease;
}

.cancel-btn:active {
    background: var(--bg-elevated);
    transform: scale(0.96);
}

/* Pause Button */
.pause-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s var(--timing-smooth);
}

.pause-btn:active {
    transform: scale(0.92);
    background: var(--bg-tertiary);
}

.pause-btn svg {
    width: 20px;
    height: 20px;
}

/* Send Button - Premium Look */
.send-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--accent-gradient);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s var(--timing-smooth);
    box-shadow: 0 4px 20px rgba(51, 144, 236, 0.4);
}

.send-btn:active {
    transform: scale(0.92);
    box-shadow: 0 2px 12px rgba(51, 144, 236, 0.3);
}

.send-btn:disabled,
.send-btn.sending {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.send-btn.sending {
    animation: send-pulse 1s ease-in-out infinite;
}

@keyframes send-pulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(51, 144, 236, 0.4); }
    50% { box-shadow: 0 4px 30px rgba(51, 144, 236, 0.6); }
}

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

/* ========================================
   MICRO-INTERACTIONS
======================================== */

/* Haptic-like feedback on swipe */
.track-card-container::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 20px;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: -1;
}

.track-card-container.swiping::before {
    opacity: 0.1;
}

/* Subtle scale on drag */
.track-card.dragging {
    transform: scale(0.98);
}

/* ========================================
   LOADING STATE
======================================== */
.loading-shimmer {
    background: linear-gradient(
        90deg,
        var(--bg-elevated) 0%,
        rgba(255, 255, 255, 0.08) 50%,
        var(--bg-elevated) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* ========================================
   RESPONSIVE
======================================== */
@media (max-height: 680px) {
    .camera-container {
        width: 240px;
        height: 240px;
        margin-bottom: 16px;
    }
    
    .camera-wrapper {
        width: 216px;
        height: 216px;
    }
    
    .progress-ring {
        width: 240px;
        height: 240px;
    }
    
    .progress-ring-bg,
    .progress-ring-circle {
        r: 117;
        cx: 120;
        cy: 120;
    }
    
    .track-card {
        padding: 16px;
        gap: 14px;
    }
    
    .track-name {
        font-size: 18px;
    }
    
    .equalizer {
        height: 40px;
    }
}

/* ========================================
   SAFE AREA
======================================== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .main-container {
        padding-bottom: calc(100px + env(safe-area-inset-bottom));
    }
}

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

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
