* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: #0a1710;
    color: #e5e7eb;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: 40px 20px;
    margin: 0;
    overflow-x: hidden;
}

.main-wrapper {
    display: flex;
    gap: 24px;
    width: 100%;
    max-width: 1200px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.container {
    background: #122b1c;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
    border: 1px solid #1e452c;
    flex: 2;
    min-width: 0;
    width: 100%;
}

.sidebar {
    flex: 1;
    min-width: 0;
    width: 100%;
}

h1,
h2 {
    margin-top: 0;
    margin-bottom: 24px;
    color: #f3f4f6;
}

h1 {
    font-size: 26px;
    text-align: center;
}

h2 {
    font-size: 20px;
    border-bottom: 1px solid #1e452c;
    padding-bottom: 10px;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #9ca3af;
}

.input-group input:not([type="checkbox"]):not([type="color"]),
.input-group select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #2d5a3d;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s ease;
    background-color: #07120a;
    color: #e5e7eb;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

button {
    width: 100%;
    background-color: #10b981;
    color: #022c22;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

button:hover {
    background-color: #059669;
}

button:active {
    transform: scale(0.98);
}

button:disabled {
    background-color: #4b5563;
    color: #9ca3af;
    cursor: not-allowed;
    transform: none;
}

#resultBox {
    margin-top: 24px;
    padding: 16px;
    border-radius: 8px;
    font-size: 15px;
    line-height: 1.5;
    display: none;
    font-weight: 500;
}

.success {
    background-color: #064e3b;
    color: #34d399;
    border: 1px solid #059669;
    display: block !important;
}

.error {
    background-color: #450a0a;
    color: #fca5a5;
    border: 1px solid #dc2626;
    display: block !important;
}

.site-item {
    background: #183824;
    border: 1px solid #2d5a3d;
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.site-item-title {
    font-weight: bold;
    font-size: 15px;
    word-break: break-all;
    color: #10b981;
}

.site-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-sm {
    padding: 8px 10px;
    font-size: 13px;
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    flex: 1;
    border: none;
    font-weight: 600;
    transition: 0.2s;
    margin-top: 0;
    min-width: 80px;
}

.btn-preview {
    background-color: #3b82f6;
    color: white;
}

.btn-preview:hover {
    background-color: #2563eb;
}

.btn-download {
    background-color: #f59e0b;
    color: #451a03;
}

.btn-download:hover {
    background-color: #d97706;
}

.btn-delete {
    background-color: #ef4444;
    color: white;
}

.btn-delete:hover {
    background-color: #dc2626;
}

.modal-overlay {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(3px);
}

.modal-content.preview-mode {
    background-color: #fff;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
}

.device-toolbar {
    background: #333;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    color: #fff;
}

.page-selector-container,
.resize-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: bold;
    flex-wrap: wrap;
}

#pageSelector {
    padding: 6px 10px;
    border-radius: 4px;
    border: 1px solid #555;
    background: #222;
    color: white;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    max-width: 100%;
}

#widthSlider {
    cursor: ew-resize;
    width: 150px;
    max-width: 100%;
}

.device-btn {
    background: #555;
    border: 1px solid #777;
    color: white;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.device-btn:hover {
    background: #666;
}

.close-btn {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

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

.iframe-wrapper {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background: #e0e0e0;
    overflow: auto;
}

#liveIframe {
    background: #fff;
    border: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transition: width 0.1s linear;
    width: 100%;
    height: 100%;
}

@media (max-width: 992px) {
    .main-wrapper {
        flex-direction: column;
    }
    
    .container, 
    .sidebar {
        flex: none;
        width: 100%;
    }
}

@media (max-width: 768px) {
    body {
        padding: 20px 10px;
    }
    
    .container {
        padding: 20px;
    }

    #palette_grid > div {
        width: 100% !important;
    }

    .device-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .page-selector-container,
    .resize-controls {
        width: 100%;
    }

    .close-btn {
        position: absolute;
        top: 10px;
        right: 15px;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 22px;
    }

    h2 {
        font-size: 18px;
    }

    .site-actions {
        flex-direction: column;
    }
    
    .btn-sm {
        width: 100%;
        padding: 10px;
    }

    .resize-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    #widthSlider {
        width: 100%;
    }
    
    .device-btn {
        width: 100%;
    }
}