:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f7;
    --text-primary: #1d1d1f;
    --text-secondary: #86868b;
    --accent: #0071e3;
    --border: #d2d2d7;
    --editor-bg: #ffffff;
    --editor-text: #000000;
}

.dark-mode {
    --bg-primary: #000000;
    --bg-secondary: #1d1d1f;
    --text-primary: #f5f5f7;
    --text-secondary: #86868b;
    --accent: #2997ff;
    --border: #424245;
    --editor-bg: #1d1d1f;
    --editor-text: #ffffff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.3s, color 0.3s;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

/* Add these styles after your existing root variables */

@keyframes gradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-20px); }
    100% { transform: translateY(0px); }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

header {
    background: linear-gradient(-45deg, #12508f, #114562, #0b3444, #17191a);
    background-size: 400% 400%;
    animation: gradient 15s ease infinite;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid var(--border);
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1440 320"><path fill="%23ffffff" fill-opacity="0.1" d="M0,96L48,112C96,128,192,160,288,165.3C384,171,480,149,576,128C672,107,768,85,864,90.7C960,96,1056,128,1152,133.3C1248,139,1344,117,1392,106.7L1440,96L1440,0L1392,0C1344,0,1248,0,1152,0C1056,0,960,0,864,0C768,0,672,0,576,0C480,0,384,0,288,0C192,0,96,0,48,0L0,0Z"></path></svg>');
    background-repeat: repeat-x;
    background-position: center;
    animation: float 6s ease-in-out infinite;
    pointer-events: none;
}

header::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1440 320"><circle cx="100" cy="100" r="3" fill="%23ffffff" fill-opacity="0.2"/><circle cx="400" cy="200" r="4" fill="%23ffffff" fill-opacity="0.2"/><circle cx="700" cy="150" r="3" fill="%23ffffff" fill-opacity="0.2"/><circle cx="1000" cy="100" r="4" fill="%23ffffff" fill-opacity="0.2"/><circle cx="1300" cy="200" r="3" fill="%23ffffff" fill-opacity="0.2"/></svg>');
    animation: pulse 4s ease-in-out infinite;
    pointer-events: none;
}

h1 {
    font-size: 2rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: relative;
    z-index: 1;
}

.theme-toggle {
    position: relative;
    width: 60px;
    height: 30px;
    z-index: 1;
}

.switch {
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    cursor: pointer;
    backdrop-filter: blur(8px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.switch:hover {
    background-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.slider {
    position: absolute;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: white;
    top: 2px;
    left: 2px;
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55), background 0.3s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.slider::before {
    content: '🌞';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 14px;
}

#theme-switch:checked + .switch .slider {
    transform: translateX(30px);
}

#theme-switch:checked + .switch .slider::before {
    content: '🌙';
}

#theme-switch:checked + .switch {
    background-color: rgba(0, 0, 0, 0.4);
}

/* Add smooth transitions for dark mode switch */
body {
    transition: background-color 0.3s ease, color 0.3s ease;
}

.dark-mode header {
    background: linear-gradient(-45deg, #1a1a1a, #2d2d2d, #404040, #525252);
    background-size: 400% 400%;
}

.dark-mode .switch {
    background-color: rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.1);
}

.dark-mode .slider {
    background: #2997ff;
}

h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(45deg, var(--accent), #6b47ff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    position: relative;
    padding-left: 2.5rem;
}

h1::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 2rem;
    height: 2rem;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="%230071e3" d="M19.9 12.66a1 1 0 0 1 0-1.32l1.28-1.44a1 1 0 0 0 .12-1.17l-2-3.46a1 1 0 0 0-1.07-.48l-1.88.38a1 1 0 0 1-1.15-.66l-.61-1.83a1 1 0 0 0-.95-.68h-4a1 1 0 0 0-1 .68l-.56 1.83a1 1 0 0 1-1.15.66L5 4.79a1 1 0 0 0-1 .48L2 8.73a1 1 0 0 0 .1 1.17l1.27 1.44a1 1 0 0 1 0 1.32L2.1 14.1a1 1 0 0 0-.1 1.17l2 3.46a1 1 0 0 0 1.07.48l1.88-.38a1 1 0 0 1 1.15.66l.61 1.83a1 1 0 0 0 1 .68h4a1 1 0 0 0 .95-.68l.61-1.83a1 1 0 0 1 1.15-.66l1.88.38a1 1 0 0 0 1.07-.48l2-3.46a1 1 0 0 0-.12-1.17l-1.28-1.44zM12 15.5a3.5 3.5 0 1 1 0-7 3.5 3.5 0 0 1 0 7z"/></svg>');
    background-repeat: no-repeat;
    background-size: contain;
}

main {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: calc(100vh - 4rem);
    overflow-y: auto;
    position: relative;
}

.editor-container {
    display: flex;
    gap: 1rem;
    position: relative;
    z-index: 1;
}

.editor-container.top {
    min-height: 400px;
    height: auto;
    flex-shrink: 0;
}

.editor-container.bottom {
    min-height: 300px;
    height: auto;
    margin-top: 1rem;
}

.editor-box {
    flex: 1;
    background-color: var(--bg-secondary);
    border-radius: 1rem;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
    resize: both;
    overflow: auto;
    min-width: 400px;
    min-height: 300px;
    height: 100%;
}

.editor-box.full-width {
    width: 100%;
}

.CodeMirror {
    height: 100% !important;
    min-height: 250px;
    border-radius: 0.5rem;
    background-color: var(--editor-bg);
    color: var(--editor-text);
    font-size: 14px;
    line-height: 1.6;
}

@media (max-width: 1200px) {
    .editor-box {
        min-width: 350px;
        min-height: 250px;
    }
    
    .editor-container.top {
        min-height: 350px;
    }
    
    .editor-container.bottom {
        min-height: 250px;
    }
}

@media (max-width: 768px) {
    .editor-container.top,
    .editor-container.bottom {
        flex-direction: column;
        height: auto;
    }
    
    .editor-box {
        min-width: 100%;
        height: 300px;
    }
}
.editor-box::after {
    content: '';
    position: absolute;
    right: 0;
    bottom: 0;
    width: 15px;
    height: 15px;
    cursor: se-resize;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 15 15"><path fill="%230071e3" d="M11 11v4h4v-4h-4zm-4-4v4h4V7H7zm-4-4v4h4V3H3z"/></svg>');
    background-repeat: no-repeat;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.editor-box:hover::after {
    opacity: 1;
}

.CodeMirror {
    height: 100%;
    border-radius: 0.5rem;
    background-color: var(--editor-bg);
    color: var(--editor-text);
}

.button-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

button, select {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: none;
    background-color: var(--accent);
    color: white;
    cursor: pointer;
    font-size: 0.9rem;
    transition: opacity 0.2s;
}

button:hover {
    opacity: 0.9;
}

.theme-toggle {
    position: relative;
    width: 60px;
    height: 30px;
}

.switch {
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: var(--bg-secondary);
    border-radius: 15px;
    cursor: pointer;
    border: 1px solid var(--border);
}

.slider {
    position: absolute;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: var(--accent);
    top: 0;
    left: 0;
    transition: transform 0.3s;
}

#theme-switch {
    display: none;
}

#theme-switch:checked + .switch .slider {
    transform: translateX(30px);
}

.version-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

@media (max-width: 768px) {
    .editor-container {
        flex-direction: column;
    }
    
    main {
        height: auto;
    }
}