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

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
}

header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
}

.main-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 20px;
    align-items: start;
}

.controls-panel {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    position: sticky;
    top: 20px;
}

.controls-panel h2 {
    color: #1f2937;
    margin-bottom: 20px;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f3f4f6;
}

.control-section:last-child {
    border-bottom: none;
}

.control-section h3 {
    color: #4b5563;
    margin-bottom: 15px;
    font-size: 1rem;
    font-weight: 600;
}

.control-group {
    margin-bottom: 15px;
}

.control-group label {
    display: block;
    margin-bottom: 8px;
    color: #374151;
    font-size: 0.9rem;
    font-weight: 500;
}

input[type="number"],
input[type="text"],
select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

input:focus,
select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.button-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
}

button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.preset-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.preset-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.reset-btn {
    background: #e5e7eb;
    color: #374151;
}

.reset-btn:hover {
    background: #d1d5db;
}

.copy-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    grid-column: 1 / -1;
}

.copy-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.preview-panel {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    min-height: 600px;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.preview-header h2 {
    color: #1f2937;
    font-size: 1.3rem;
}

.toggle-group {
    display: flex;
    gap: 10px;
}

.toggle-btn {
    padding: 8px 16px;
    background: #f3f4f6;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.toggle-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.grid-container {
    border: 3px dashed #cbd5e1;
    border-radius: 12px;
    padding: 20px;
    background: #f8fafc;
    min-height: 500px;
    position: relative;
}

.grid-wrapper {
    display: grid;
    gap: 15px;
    height: 100%;
}

.grid-item {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 1.2rem;
    min-height: 100px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
    cursor: pointer;
}

.grid-item:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.grid-item:nth-child(2) {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    box-shadow: 0 4px 15px rgba(245, 87, 108, 0.3);
}

.grid-item:nth-child(3) {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    box-shadow: 0 4px 15px rgba(0, 242, 254, 0.3);
}

.grid-item:nth-child(4) {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    box-shadow: 0 4px 15px rgba(56, 249, 215, 0.3);
}

.grid-item:nth-child(5) {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    box-shadow: 0 4px 15px rgba(254, 225, 64, 0.3);
}

.grid-item:nth-child(6) {
    background: linear-gradient(135deg, #30cfd0 0%, #330867 100%);
    box-shadow: 0 4px 15px rgba(48, 207, 208, 0.3);
}

.code-output {
    background: #1f2937;
    color: #10b981;
    padding: 20px;
    border-radius: 10px;
    margin-top: 20px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    overflow-x: auto;
    position: relative;
}

.code-output pre {
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.code-copy-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 6px 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 0.8rem;
    cursor: pointer;
}

.code-copy-btn:hover {
    background: #5568d3;
}

.info-box {
    background: #eff6ff;
    border-left: 4px solid #3b82f6;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.info-box h4 {
    color: #1e40af;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.info-box p {
    color: #1e3a8a;
    font-size: 0.85rem;
    line-height: 1.5;
}

.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: #10b981;
    color: white;
    padding: 15px 25px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 1000;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.grid-lines {
    display: none;
}

.grid-lines.active .grid-container {
    background-image: 
        repeating-linear-gradient(0deg, transparent, transparent 19px, rgba(102, 126, 234, 0.2) 19px, rgba(102, 126, 234, 0.2) 20px),
        repeating-linear-gradient(90deg, transparent, transparent 19px, rgba(102, 126, 234, 0.2) 19px, rgba(102, 126, 234, 0.2) 20px);
    background-size: 20px 20px;
}

@media (max-width: 1200px) {
    .main-layout {
        grid-template-columns: 1fr;
    }

    .controls-panel {
        position: static;
        max-height: none;
    }
}

@media (max-width: 768px) {
    h1 {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 0.95rem;
    }

    .button-group {
        grid-template-columns: 1fr;
    }

    .preview-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
}
