/* Reset and base styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-dark: #0d0d1a;
    --bg-medium: #1a1a2e;
    --bg-light: #252540;
    --accent-purple: #7c3aed;
    --accent-blue: #3b82f6;
    --accent-pink: #ec4899;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --glow-purple: rgba(124, 58, 237, 0.4);
    --glow-blue: rgba(59, 130, 246, 0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-medium) 50%, var(--bg-dark) 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

/* Container */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 3rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 300;
    letter-spacing: 0.1em;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue), var(--accent-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

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

/* Main content area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Recording section */
.recording-section {
    text-align: center;
    width: 100%;
}

/* Record button */
.record-button {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
    box-shadow: 0 0 40px var(--glow-purple);
}

.record-button:hover {
    transform: scale(1.05);
    box-shadow: 0 0 60px var(--glow-purple);
}

.record-button:active {
    transform: scale(0.98);
}

.record-button.recording {
    animation: pulse 1.5s ease-in-out infinite;
    background: linear-gradient(135deg, var(--accent-pink), var(--accent-purple));
}

.record-button .icon {
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 8px;
    margin: 0 auto;
    transition: all 0.3s ease;
}

.record-button.recording .icon {
    border-radius: 4px;
    width: 32px;
    height: 32px;
}

.record-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    animation: none;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 40px var(--glow-purple);
    }
    50% {
        box-shadow: 0 0 80px var(--glow-purple), 0 0 120px rgba(236, 72, 153, 0.3);
    }
}

/* Timer */
.timer {
    font-size: 2rem;
    font-weight: 200;
    letter-spacing: 0.1em;
    color: var(--text-primary);
    margin-top: 1.5rem;
    font-variant-numeric: tabular-nums;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.timer.visible {
    opacity: 1;
}

/* Audio visualizer */
.visualizer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 60px;
    margin-top: 1.5rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.visualizer.visible {
    opacity: 1;
}

.visualizer-bar {
    width: 4px;
    height: 10px;
    background: linear-gradient(to top, var(--accent-purple), var(--accent-blue));
    border-radius: 2px;
    transition: height 0.1s ease;
}

/* Status message */
.status-message {
    margin-top: 2rem;
    padding: 1rem 2rem;
    background: var(--bg-light);
    border-radius: 12px;
    color: var(--text-secondary);
    display: none;
    align-items: center;
    gap: 1rem;
}

.status-message.visible {
    display: flex;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--bg-medium);
    border-top-color: var(--accent-purple);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Result section */
.result-section {
    width: 100%;
    display: none;
    animation: fadeIn 0.5s ease;
}

.result-section.visible {
    display: block;
}

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

/* Video player */
.video-container {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 0 60px var(--glow-blue), 0 20px 60px rgba(0, 0, 0, 0.5);
    margin-bottom: 2rem;
}

.video-container video {
    width: 100%;
    display: block;
}

/* Transcription display */
.transcription-card {
    background: var(--bg-light);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.transcription-card h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.transcription-card p {
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1.8;
}

.transcription-card.prompt p {
    color: var(--text-secondary);
    font-style: italic;
}

/* Action buttons */
.action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

.btn {
    padding: 0.875rem 2rem;
    border-radius: 12px;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px var(--glow-purple);
}

.btn-secondary {
    background: var(--bg-light);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-medium);
}

/* Navigation */
nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--bg-light);
}

nav a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.3s ease;
}

nav a:hover {
    color: var(--text-primary);
}

/* Gallery grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.dream-card {
    background: var(--bg-light);
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
}

.dream-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.dream-card .thumbnail {
    aspect-ratio: 21/9;
    background: var(--bg-medium);
    position: relative;
}

.dream-card .thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.dream-card .thumbnail .placeholder-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-muted);
}

.dream-card .thumbnail .play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.dream-card:hover .play-icon {
    opacity: 1;
}

.dream-card .content {
    padding: 1rem;
}

.dream-card .content p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.dream-card .content .date {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 0.5rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 2rem;
}

.modal.visible {
    display: flex;
}

.modal-content {
    max-width: 900px;
    width: 100%;
    position: relative;
}

.modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
}

.modal video {
    width: 100%;
    border-radius: 16px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.empty-state h2 {
    font-weight: 400;
    margin-bottom: 1rem;
}

/* Instruction text */
.instruction {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 2rem;
}

/* Error state */
.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    padding: 1rem;
    border-radius: 12px;
    margin-top: 1rem;
    display: none;
}

.error-message.visible {
    display: block;
}

/* Responsive */
@media (max-width: 640px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 1.75rem;
    }

    .record-button {
        width: 120px;
        height: 120px;
    }

    .action-buttons {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }
}
