:root {
    --bg-color: #1a1a1a;
    --panel-color: #2c2c2c;
    --text-color: #f0f0f0;
    --primary-color: #00aaff;
    --border-color: #444;
    --input-bg: #333;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ==== Navigation ==== */
.main-navigation {
    background-color: var(--panel-color);
    border-bottom: 1px solid var(--border-color);
    padding: 0;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
}

.nav-brand a {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 1.2rem;
    font-weight: 600;
}

.nav-brand a:hover {
    color: #0088cc;
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.nav-links a {
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

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

.container {
    display: flex;
    flex: 1;
    min-height: 0;
}

/* ==== Controls Panel ==== */
.controls {
    width: 350px;
    background-color: var(--panel-color);
    padding: 2rem;
    overflow-y: auto;
    border-right: 1px solid var(--border-color);
}

.controls header {
    margin-bottom: 2rem;
    text-align: center;
}

.controls h2 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

#variant-counter {
    font-size: 0.9rem;
    color: #aaa;
}

.control-group {
    margin-bottom: 1.5rem;
}

.control-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    background: var(--input-bg);
    border-radius: 5px;
    outline: none;
    opacity: 0.7;
    transition: opacity .2s;
}

input[type="range"]:hover {
    opacity: 1;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    cursor: pointer;
    border-radius: 50%;
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    cursor: pointer;
    border-radius: 50%;
}

select, button {
    width: 100%;
    padding: 0.75rem;
    background-color: var(--input-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
}

button {
    background-color: var(--primary-color);
    color: #fff;
    font-weight: bold;
    border: none;
    transition: background-color 0.2s ease;
}

button:hover {
    background-color: #0088cc;
}

.navigation-buttons {
    display: flex;
    gap: 1rem;
}

.navigation-buttons button {
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.navigation-buttons button:active {
    transform: scale(0.95);
}

#animate-btn {
    position: relative;
}

#animate-btn.animating {
    background-color: #ff6b6b !important;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(255, 107, 107, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 107, 107, 0); }
}

/* ==== Export Panel ==== */
.export-panel {
    border-top: 2px solid var(--border-color);
    padding-top: 1.5rem;
    margin-top: 2rem;
}

.export-panel h3 {
    text-align: center;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

#add-watermark {
    vertical-align: middle;
    margin-right: 0.5rem;
}

#export-status {
    margin-top: 1rem;
    text-align: center;
    font-size: 0.9rem;
    min-height: 20px;
    color: #ccc;
}

/* ==== Preview Area ==== */
.preview-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 2rem;
}

#main-title {
    margin-bottom: 1rem;
    text-align: center;
    max-width: 80%;
    font-size: 1.8rem;
    font-weight: 500;
}

.canvas-container {
    width: 100%;
    height: 100%;
    max-width: 1280px;
    max-height: 720px;
    aspect-ratio: 16 / 9;
    background-color: #000;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    border-radius: 8px;
    overflow: hidden;
}

#bg-preview {
    width: 100%;
    height: 100%;
    display: block;
}

/* Responsive */
@media (max-width: 1024px) {
    .nav-container {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .nav-links {
        gap: 1.5rem;
    }
    
    .container {
        flex-direction: column;
    }
    
    .controls {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .preview-area {
        min-height: 60vh;
        padding: 1rem;
    }
    
    #main-title {
        font-size: 1.2rem;
    }
}

@media (max-width: 768px) {
    .nav-links {
        gap: 1rem;
    }
    
    .nav-links a {
        font-size: 0.9rem;
    }
}

/* ==== Matrix Layout ==== */
.matrix-container {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.canvas-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 1rem;
    width: 100%;
    height: 100%;
    max-width: 1200px;
    max-height: 600px;
}

.matrix-canvas {
    width: 100%;
    height: 100%;
    background-color: #000;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.matrix-canvas:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 20px rgba(0,0,0,0.5);
}

/* ==== Enlarged View ==== */
.enlarged-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.enlarged-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    align-items: center;
}

.enlarged-controls button {
    padding: 0.5rem 1rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s ease;
}

.enlarged-controls button:hover {
    background-color: #0088cc;
}

.enlarged-canvas-container {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #000;
    border-radius: 8px;
    overflow: hidden;
}

#enlarged-canvas {
    max-width: 100%;
    max-height: 100%;
    display: block;
}

/* ==== CSS Modal ==== */
.css-modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

.css-modal-content {
    background-color: var(--panel-color);
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

.css-close {
    float: right;
    font-size: 2rem;
    cursor: pointer;
    color: #aaa;
    line-height: 1;
}

.css-close:hover {
    color: #fff;
}

#css-output {
    width: 100%;
    height: 300px;
    background-color: var(--input-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1rem;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.9rem;
    margin: 1rem 0;
    resize: vertical;
}

#copy-css {
    padding: 0.5rem 1rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

/* ==== Footer ==== */
.site-footer {
    background-color: var(--panel-color);
    border-top: 1px solid var(--border-color);
    margin-top: auto;
    padding: 3rem 2rem 1rem;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.footer-section h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.footer-section h4 {
    color: var(--text-color);
    margin-bottom: 0.8rem;
    font-size: 1rem;
    font-weight: 500;
}

.footer-section p {
    color: #aaa;
    line-height: 1.6;
    font-size: 0.9rem;
}

.footer-section ul {
    list-style: none;
    padding: 0;
}

.footer-section ul li {
    margin-bottom: 0.5rem;
}

.footer-section ul li a {
    color: #ccc;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s ease;
}

.footer-section ul li a:hover {
    color: var(--primary-color);
}

.footer-bottom {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.footer-bottom p {
    color: #888;
    font-size: 0.8rem;
}

/* Responsive Footer */
@media (max-width: 768px) {
    .site-footer {
        padding: 2rem 1rem 1rem;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}
