* {
    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: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    width: 100%;
    max-width: none;
    align-items: flex-start;
}

.container {
    background: #122b1c;
    padding: 28px 32px;
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    border: 1px solid #1e452c;
    min-width: 0;
}

.sidebar {
    position: sticky;
    top: 20px;
    padding: 0;
    background-color: transparent;
    min-width: 0;
    border: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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: #1a2540;
    border: 1px solid #2d4070;
    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: #93c5fd;
}

.seo-panel {
    display: none;
    flex-direction: column;
    gap: 10px;
    margin-top: 4px;
    border-top: 1px solid #2d4070;
    padding-top: 10px;
}

.seo-panel.open {
    display: flex;
}

.seo-file-block {
    background: #0d1526;
    border: 1px solid #2d4070;
    border-radius: 6px;
    padding: 10px 12px;
}

.seo-file-label {
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.seo-file-content {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 11px;
    color: #94a3b8;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 120px;
    overflow-y: auto;
    line-height: 1.5;
}

.text-check-panel {
    margin-top: 16px;
    background: #0d1526;
    border: 1px solid #2d4070;
    border-radius: 8px;
    padding: 14px;
}

.text-check-title {
    font-size: 13px;
    font-weight: 700;
    color: #93c5fd;
    margin-bottom: 10px;
}

.text-check-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 12px;
    color: #94a3b8;
    padding: 3px 0;
}

.text-check-ok { color: #4ade80; }
.text-check-warn { color: #fbbf24; }
.text-check-err { color: #f87171; }

.text-check-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    font-size: 12px;
    color: #cbd5e1;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px dashed #2d4070;
}

.text-check-pages-title {
    font-size: 12px;
    color: #93c5fd;
    margin: 12px 0 6px;
    font-weight: 600;
}

.text-check-pages {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.text-check-page-row {
    background: #07111f;
    border: 1px solid #2d4070;
    border-radius: 6px;
    overflow: hidden;
}

.text-check-page-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    cursor: pointer;
    font-size: 12px;
    user-select: none;
}

.text-check-page-header:hover {
    background: #0d1a2e;
}

.text-check-page-status {
    flex: 0 0 auto;
    font-weight: 700;
    font-size: 13px;
    width: 16px;
    text-align: center;
}

.text-check-page-name {
    flex: 1 1 auto;
    color: #e2e8f0;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    word-break: break-all;
}

.text-check-page-meta {
    flex: 0 0 auto;
    color: #64748b;
    font-size: 11px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.text-check-page-details {
    display: none;
    padding: 10px 12px;
    border-top: 1px solid #2d4070;
    background: #050b14;
    font-size: 12px;
    color: #cbd5e1;
    line-height: 1.6;
    word-break: break-word;
}

.text-check-page-details > div {
    padding: 2px 0;
}

.text-check-page-row.open .text-check-page-details {
    display: block;
}

.text-check-page-row.open .text-check-page-header {
    background: #0d1a2e;
}

@media (max-width: 600px) {
    .text-check-page-meta {
        display: none;
    }
}

.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-seo {
    background-color: #334155;
    color: #93c5fd;
    border: 1px solid #2d4070;
}

.btn-seo:hover {
    background-color: #1e3a5f;
}

.btn-seo.active {
    background-color: #1e3a5f;
    border-color: #60a5fa;
}

.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: 1024px) {
    .main-wrapper {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        width: 100%;
    }
}

@media (max-width: 768px) {
    body {
        padding: 16px 12px;
    }

    .container {
        padding: 20px 18px;
        border-radius: 12px;
    }

    #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%;
    }
}

.log-panel {
    background: #0a0f0d;
    border: 1px solid #1e452c;
    border-radius: 8px;
    padding: 0;
    margin-top: 0;
    display: flex;
    flex-direction: column;
    max-height: 600px;
    min-height: 400px;
}

.log-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid #1e452c;
    background: #07120a;
    border-radius: 8px 8px 0 0;
}

.log-header h3 {
    margin: 0;
    font-size: 14px;
    color: #86efac;
}

.log-header .log-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.log-badge.connected {
    background: #064e3b;
    color: #6ee7b7;
}

.log-badge.disconnected {
    background: #7f1d1d;
    color: #fca5a5;
}

.log-badge.idle {
    background: #1c2a1e;
    color: #4b7a5e;
}

.log-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 12px;
    line-height: 1.6;
}

.log-body::-webkit-scrollbar {
    width: 6px;
}

.log-body::-webkit-scrollbar-track {
    background: #0a0f0d;
}

.log-body::-webkit-scrollbar-thumb {
    background: #1e452c;
    border-radius: 3px;
}

.log-line {
    padding: 1px 0;
    word-break: break-all;
}

.log-line .log-ts {
    color: #4b5563;
    margin-right: 6px;
}

.log-line.level-info .log-msg {
    color: #d1d5db;
}

.log-line.level-ok .log-msg {
    color: #86efac;
}

.log-line.level-warn .log-msg {
    color: #fbbf24;
}

.log-line.level-error .log-msg {
    color: #f87171;
}

.log-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    gap: 10px;
    border-top: 1px solid #1e452c;
    font-size: 11px;
    color: #6b7280;
}

.log-footer button {
    background: none;
    border: 1px solid #374151;
    color: #9ca3af;
    padding: 3px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
}

.log-footer button:hover {
    border-color: #86efac;
    color: #86efac;
}

.build-info {
    font-size: 11px;
    color: #4b5563;
    padding: 6px 14px;
    text-align: right;
    background: #07120a;
    border: 1px solid #1e452c;
    border-radius: 8px;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #07120a; }
::-webkit-scrollbar-thumb { background: #1e452c; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #2d5a3d; }

@media (max-width: 480px) {
    .sidebar > div { padding: 16px; }

#logCount {
    flex: 0 0 auto;
}