@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Playfair+Display:wght@400;500;600;700&family=JetBrains+Mono:wght@300;400;500&display=swap');

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --accent-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --dark-gradient: linear-gradient(145deg, #0f0f23 0%, #1a1a2e 50%, #16213e 100%);
    --card-bg: rgba(255, 255, 255, 0.03);
    --card-border: rgba(255, 255, 255, 0.08);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-accent: #64ffda;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--dark-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(120, 219, 255, 0.2) 0%, transparent 50%);
    z-index: -1;
    animation: floatBg 20s ease-in-out infinite;
}

@keyframes floatBg {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    33% { transform: translateY(-30px) rotate(2deg); }
    66% { transform: translateY(-20px) rotate(-1deg); }
}

.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(100, 255, 218, 0.6);
    border-radius: 50%;
    animation: float 15s infinite linear;
}

@keyframes float {
    0% {
        transform: translateY(100vh) translateX(0px);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-100px) translateX(100px);
        opacity: 0;
    }
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    display: grid;
    grid-template-columns: 280px 1fr 280px;
    grid-template-rows: auto 1fr;
    grid-template-areas: 
        "header header header"
        "sidebar-left main sidebar-right";
    gap: 2rem;
    min-height: 100vh;
}

header {
    grid-area: header;
    text-align: center;
    position: relative;
    padding: 3rem 2rem;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    margin-bottom: 1rem;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(from 0deg, transparent, rgba(100, 255, 218, 0.1), transparent);
    animation: rotate 10s linear infinite;
    z-index: -1;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

h1 {
    font-family: 'Playfair Display', serif;
    font-size: 3.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fff 0%, #64ffda 50%, #667eea 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    position: relative;
    z-index: 1;
    text-shadow: 0 0 30px rgba(100, 255, 218, 0.3);
    animation: glow 3s ease-in-out infinite alternate;
}

@keyframes glow {
    from { filter: drop-shadow(0 0 10px rgba(100, 255, 218, 0.3)); }
    to { filter: drop-shadow(0 0 30px rgba(100, 255, 218, 0.6)); }
}

.sidebar {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 2rem;
    height: fit-content;
    position: sticky;
    top: 2rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    border-color: rgba(100, 255, 218, 0.3);
}

.sidebar-left { grid-area: sidebar-left; }
.sidebar-right { grid-area: sidebar-right; }

.sidebar h3 {
    color: var(--text-accent);
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    position: relative;
    padding-bottom: 0.5rem;
}

.sidebar h3::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 50px;
    height: 2px;
    background: var(--accent-gradient);
    border-radius: 1px;
}

.sidebar input {
    width: 100%;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.sidebar input:focus {
    outline: none;
    border-color: var(--text-accent);
    box-shadow: 0 0 0 3px rgba(100, 255, 218, 0.1);
    transform: translateY(-1px);
}

.sidebar input::placeholder {
    color: var(--text-secondary);
}

.sidebar button {
    width: 100%;
    padding: 1rem;
    margin-bottom: 1rem;
    background: var(--primary-gradient);
    border: none;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.sidebar button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.6s;
}

.sidebar button:hover::before {
    left: 100%;
}

.sidebar button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

.sidebar .result {
    margin-top: 1rem;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.6;
    backdrop-filter: blur(10px);
    animation: slideIn 0.5s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.workspace-container {
    grid-area: main;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.workspace {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 2rem;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.workspace::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--accent-gradient);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.workspace:hover::before {
    transform: scaleX(1);
}

.workspace:hover {
    transform: translateY(-8px);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4);
    border-color: rgba(100, 255, 218, 0.2);
}

.editable-title {
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: 'Playfair Display', serif;
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    padding: 0.5rem;
    width: 100%;
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
    outline: none;
}

.editable-title:hover,
.editable-title:focus {
    border-bottom-color: var(--text-accent);
    color: var(--text-accent);
}

textarea {
    width: 100%;
    min-height: 300px;
    padding: 1.5rem;
    margin: 1rem 0;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    resize: vertical;
    font-family: 'JetBrains Mono', monospace;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    color: var(--text-primary);
    line-height: 1.8;
    font-size: 1rem;
    transition: all 0.3s ease;
}

textarea:focus {
    outline: none;
    border-color: var(--text-accent);
    box-shadow: 0 0 0 3px rgba(100, 255, 218, 0.1);
    background: rgba(0, 0, 0, 0.3);
}

textarea::placeholder {
    color: var(--text-secondary);
    font-style: italic;
}

.button-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

button {
    padding: 1rem 2rem;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    font-family: 'Inter', sans-serif;
}

.save-btn {
    background: var(--secondary-gradient);
    color: white;
}

.toggle-reference {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
}

button:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
}

.save-btn:hover {
    box-shadow: 0 15px 30px rgba(245, 87, 108, 0.4);
}

.delete-btn {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    color: white;
    font-size: 0.9rem;
}

.reference-section {
    margin-top: 2rem;
    padding: 2rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1;
    overflow: hidden;
    max-height: 800px;
    backdrop-filter: blur(10px);
}

.reference-section.hidden {
    max-height: 0;
    opacity: 0;
    margin: 0;
    padding: 0;
    pointer-events: none;
}

.reference-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.reference-header h3 {
    color: var(--text-accent);
    font-family: 'Playfair Display', serif;
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0;
}

.change-image-btn {
    background: var(--accent-gradient);
    color: white;
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    margin: 0;
}

.reference-image {
    width: 100%;
    min-height: 200px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.05);
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px dashed var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.reference-image:hover {
    border-color: var(--text-accent);
    background: rgba(100, 255, 218, 0.05);
}

.reference-image img,
.reference-image video {
    max-width: 100%;
    width: auto;
    height: auto;
    display: block;
    border-radius: 12px;
    margin: 0 auto;
    transform-origin: 50% 50%;
    transition: transform 0.1s ease;
}

.reference-image.panning {
    cursor: grab;
}

.reference-image.panning:active {
    cursor: grabbing;
}

.reference-image video {
    max-height: 500px;
    width: 100%;
    height: auto;
}

.reference-image.has-video {
    background: rgba(0, 0, 0, 0.8);
}

.video-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    padding: 1rem;
    opacity: 0;
    transition: opacity 0.3s;
    border-radius: 0 0 16px 16px;
}

.reference-image:hover .video-controls {
    opacity: 1;
}

.video-progress {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    cursor: pointer;
    margin-bottom: 0.5rem;
    border-radius: 3px;
    overflow: hidden;
}

.video-progress-bar {
    height: 100%;
    background: var(--accent-gradient);
    width: 0%;
    border-radius: 3px;
    transition: width 0.1s ease;
}

@media (max-width: 1200px) {
    .container {
        grid-template-columns: 250px 1fr 250px;
    }
}

@media (max-width: 768px) {
    .container {
        grid-template-columns: 1fr;
        grid-template-areas: 
            "header"
            "main";
        padding: 1rem;
        gap: 1rem;
    }
    
    .sidebar-left, 
    .sidebar-right {
        display: none;
    }
    
    h1 {
        font-size: 2.5rem;
    }
    
    .workspace {
        padding: 1.5rem;
    }
    
    .button-group {
        flex-direction: column;
    }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading {
    animation: pulse 2s ease-in-out infinite;
}

html {
    scroll-behavior: smooth;
}

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--accent-gradient);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #64ffda 0%, #4facfe 100%);
}