* {
    box-sizing: border-box;
}
:root {
    --bg: #0b1220;
    --panel: #111827;
    --panel2: #0f172a;
    --line: #22304a;
    --line2: #2d3d5d;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --blue: #2563eb;
    --blue2: #1d4ed8;
    --green: #10b981;
    --green2: #059669;
    --orange: #f59e0b;
    --purple: #7c3aed;
    --editor-width: 48%;
}

html,
body {
    margin: 0;
    height: 100%;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    user-select: none;
}

.app {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.workspace {
    flex: 1;
    min-height: 0;
    display: flex;
    overflow: hidden;
}

.left {
    width: var(--editor-width);
    min-width: 320px;
    max-width: 80%;
    display: flex;
    flex-direction: column;
    background: #020617;
    border-right: 1px solid var(--line);
    min-height: 0;
    overflow: hidden;
}

.right {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: #0a1020;
}

.resizer {
    width: 8px;
    background: linear-gradient(180deg, #0f172a, #111827);
    border-right: 1px solid var(--line);
    border-left: 1px solid #101827;
    cursor: col-resize;
    position: relative;
    flex-shrink: 0;
}

.resizer:before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 64px;
    border-radius: 20px;
    background: linear-gradient(180deg, #334155, #64748b);
    opacity: .85;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 10px 12px;
    border-bottom: 1px solid #1e293b;
    background: #0f172a;
    min-height: 58px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.head-left,
.head-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.tab-btn,
.toolbar-btn,
.file-label {
    padding: 9px 12px;
    border-radius: 10px;
    border: 1px solid var(--line2);
    background: #132039;
    color: #dbeafe;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    transition: .18s ease;
    appearance: none;
    -webkit-appearance: none;
}

.tab-btn:hover,
.toolbar-btn:hover,
.file-label:hover {
    background: #1a2b47;
}

.tab-btn.active {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff;
    box-shadow: 0 0 18px rgba(37, 99, 235, .25);
}

.btn-run {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff;
}

.btn-run:hover {
    background: var(--blue2);
}

.btn-open {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
}

.btn-open:hover {
    background: var(--green2);
}

.btn-download {
    background: var(--orange);
    border-color: var(--orange);
    color: #111827;
}

.btn-beautify {
    background: var(--purple);
    border-color: var(--purple);
    color: #fff;
}

.btn-beautify:hover {
    background: #6d28d9;
}

.btn-clear {
    background: #1f2937;
    color: #fff;
}

.toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--line2);
    border-radius: 10px;
    background: #152033;
    font-size: 13px;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.toggle input {
    accent-color: var(--blue);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.editor-wrap {
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
    background: #020617;
}

.editor-pane,
.color-panel {
    position: absolute;
    inset: 0;
    display: none;
    width: 100%;
    height: 100%;
}

.editor-pane.active,
.color-panel.active {
    display: block;
}

.monaco-host {
    width: 100%;
    height: 100%;
}

.monaco-editor,
.monaco-editor .overflow-guard {
    border-radius: 0;
}

.monaco-editor,
.monaco-editor-background,
.monaco-editor .margin {
    background: #020617 !important;
}

.monaco-editor {
    overflow: hidden !important;
}

.monaco-editor .overflow-guard {
    overflow: hidden !important;
}

.monaco-editor .find-widget {
    z-index: 9999 !important;
    position: absolute !important;
    top: 10px !important;
    right: 10px !important;
    left: auto !important;
    width: min(760px, calc(100% - 20px)) !important;
    min-width: 560px !important;
    max-width: calc(100% - 20px) !important;
    border: 1px solid #2d3d5d !important;
    border-radius: 12px !important;
    background: #111827 !important;
    box-shadow: 0 14px 38px rgba(0, 0, 0, .42) !important;
    overflow: hidden !important;
    padding: 8px !important;
}

.monaco-editor .find-widget:not(.visible) {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.monaco-editor .find-widget.visible {
    display: block !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

.monaco-editor .find-widget:not(.visible) .find-part,
.monaco-editor .find-widget:not(.visible) .replace-part {
    display: none !important;
}

.monaco-editor .find-widget.visible .find-part,
.monaco-editor .find-widget.visible .replace-part {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto auto !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 6px 4px !important;
    background: transparent !important;
    min-height: 42px !important;
    overflow: hidden !important;
}

.monaco-editor .find-widget.visible .replace-part {
    border-top: 1px solid rgba(255, 255, 255, .08) !important;
    margin-top: 4px !important;
    padding-top: 10px !important;
}

.monaco-editor .find-widget .monaco-inputbox {
    width: 100% !important;
    min-width: 0 !important;
    height: 34px !important;
    border: 1px solid #3b4c70 !important;
    border-radius: 8px !important;
    background: #0b1220 !important;
    box-shadow: none !important;
    overflow: hidden !important;
}

.monaco-editor .find-widget .input,
.monaco-editor .find-widget input {
    min-width: 0 !important;
}

.monaco-editor .find-widget .monaco-inputbox input {
    height: 32px !important;
    padding: 0 10px !important;
    color: #e5e7eb !important;
    background: transparent !important;
    font-size: 12px !important;
    width: 100% !important;
}

.monaco-editor .find-widget .monaco-inputbox.synthetic-focus {
    border-color: #2563eb !important;
    box-shadow: 0 0 0 1px #2563eb inset !important;
}

.monaco-editor .find-widget .matchesCount {
    min-width: 78px !important;
    text-align: center !important;
    font-size: 12px !important;
    color: #cbd5e1 !important;
    opacity: 1 !important;
    white-space: nowrap !important;
    margin: 0 !important;
}

.monaco-editor .find-widget .controls,
.monaco-editor .find-widget .toggles,
.monaco-editor .find-widget .actions {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 4px !important;
    flex-wrap: nowrap !important;
    overflow: visible !important;
    min-width: fit-content !important;
}

.monaco-editor .find-widget .button,
.monaco-editor .find-widget button,
.monaco-editor .find-widget .monaco-button {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    min-height: 28px !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 8px !important;
    background: transparent !important;
    color: #dbeafe !important;
    cursor: pointer !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transition: background .15s ease, color .15s ease !important;
    position: relative !important;
}

.monaco-editor .find-widget .button:hover,
.monaco-editor .find-widget button:hover,
.monaco-editor .find-widget .monaco-button:hover {
    background: rgba(255, 255, 255, .08) !important;
    color: #ffffff !important;
}

.monaco-editor .find-widget .button.checked,
.monaco-editor .find-widget button.checked,
.monaco-editor .find-widget .monaco-button.checked {
    background: rgba(37, 99, 235, .18) !important;
    color: #93c5fd !important;
}

.monaco-editor .find-widget .button.disabled,
.monaco-editor .find-widget button:disabled,
.monaco-editor .find-widget .monaco-button:disabled {
    opacity: .45 !important;
    cursor: not-allowed !important;
}

.monaco-editor .find-widget .codicon {
    font-size: 15px !important;
    line-height: 1 !important;
    color: inherit !important;
}

.monaco-editor .find-widget .replace,
.monaco-editor .find-widget .replaceAll {
    opacity: 1 !important;
    visibility: visible !important;
}

.monaco-editor .find-widget .button[aria-label]:hover::after,
.monaco-editor .find-widget button[aria-label]:hover::after,
.monaco-editor .find-widget .monaco-button[aria-label]:hover::after {
    content: attr(aria-label);
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: #0b1220;
    color: #e5e7eb;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 6px 8px;
    font-size: 11px;
    white-space: nowrap;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
    z-index: 10000;
    pointer-events: none;
}

.color-panel {
    overflow: auto;
    background: #020617;
    padding: 18px;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.color-card {
    background: #0f172a;
    border: 1px solid var(--line2);
    border-radius: 14px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.color-card h4 {
    margin: 0;
    font-size: 14px;
    color: #fff;
}

.color-card p {
    margin: 0;
    font-size: 12px;
    color: var(--muted);
}

.color-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-row input[type="color"] {
    width: 54px;
    height: 42px;
    border: 0;
    padding: 0;
    border-radius: 10px;
    background: none;
    cursor: pointer;
}

.color-row input[type="text"] {
    flex: 1;
    min-width: 0;
    height: 42px;
    border-radius: 10px;
    border: 1px solid var(--line2);
    background: #111827;
    color: #fff;
    padding: 0 12px;
    outline: none;
    font-weight: 700;
    text-transform: uppercase;
}

.color-preview {
    height: 52px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, .08);
    background: var(--swatch, #000000);
}

.color-tools {
    margin-top: 18px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.mini-btn {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--line2);
    background: #111827;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.preview-top {
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid var(--line);
    background: #0f172a;
    flex-shrink: 0;
}

.fake-browser {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    min-height: 58px;
    border-bottom: 1px solid rgba(255, 255, 255, .03);
}

.browser-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    overflow: hidden;
}

.browser-dots {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.dot.red {
    background: #ef4444;
}

.dot.yellow {
    background: #f59e0b;
}

.dot.green {
    background: #10b981;
}

.page-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #111b2f;
    border: 1px solid var(--line2);
    border-radius: 12px;
    padding: 8px 12px;
    min-width: 0;
    max-width: 100%;
}

.page-favicon {
    width: 18px;
    height: 18px;
    object-fit: contain;
    border-radius: 4px;
    background: #fff;
    flex-shrink: 0;
}

.page-meta {
    min-width: 0;
    overflow: hidden;
}

.page-title,
.page-url {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.page-title {
    font-size: 13px;
    font-weight: 700;
    color: #fff;
}

.page-url {
    font-size: 11px;
    color: var(--muted);
}

.device-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 12px;
}

.device-btn {
    padding: 8px 12px;
    font-size: 12px;
    border-radius: 10px;
    border: 1px solid var(--line2);
    background: #132039;
    color: #dbeafe;
    cursor: pointer;
    font-weight: 700;
}

.device-btn.active {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
}

.preview-area {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background:
        linear-gradient(45deg, rgba(255, 255, 255, .03) 25%, transparent 25%) -12px 0/24px 24px,
        linear-gradient(-45deg, rgba(255, 255, 255, .03) 25%, transparent 25%) -12px 0/24px 24px,
        linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, .03) 75%) -12px 0/24px 24px,
        linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, .03) 75%) -12px 0/24px 24px,
        #0b1220;
}

.frame-shell {
    width: 100%;
    height: 100%;
    max-width: 100%;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
    transition: .2s ease;
    border-left: 1px solid rgba(255, 255, 255, .04);
}

.frame-shell.desktop {
    width: 100%;
    height: 100%;
}

.frame-shell.tablet {
    width: 820px;
    max-width: 100%;
    min-height: 100%;
    margin: 18px auto;
    border-radius: 18px;
    border: 1px solid var(--line2);
}

.frame-shell.mobile {
    width: 390px;
    max-width: 100%;
    min-height: 100%;
    margin: 18px auto;
    border-radius: 18px;
    border: 1px solid var(--line2);
}

iframe {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 100%;
    border: 0;
    background: #fff;
}

.statusbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    border-top: 1px solid var(--line);
    background: #0d1528;
    color: var(--muted);
    font-size: 12px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.status-left,
.status-right {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    align-items: center;
}

input[type="file"] {
    display: none;
}

textarea[hidden] {
    display: none !important;
}

@media (max-width: 980px) {
    .workspace {
        flex-direction: column;
    }

    .left {
        width: 100%;
        max-width: none;
        min-width: 0;
        height: 48%;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .resizer {
        width: 100%;
        height: 8px;
        cursor: row-resize;
    }

    .resizer:before {
        width: 64px;
        height: 4px;
    }

    .right {
        flex: 1;
    }

    .color-grid {
        grid-template-columns: 1fr;
    }

    .monaco-editor .find-widget {
        min-width: unset !important;
        width: calc(100% - 12px) !important;
        max-width: calc(100% - 12px) !important;
        right: 6px !important;
        top: 6px !important;
    }

    .monaco-editor .find-widget.visible .find-part,
    .monaco-editor .find-widget.visible .replace-part {
        grid-template-columns: minmax(0, 1fr) auto !important;
    }

    .monaco-editor .find-widget .matchesCount {min-width: 0 !important;
        text-align: left !important;
    }

    .monaco-editor .find-widget .controls,
    .monaco-editor .find-widget .toggles,
    .monaco-editor .find-widget .actions {
        flex-wrap: wrap !important;
    }
}

@media (max-width: 640px) {
    .panel-head {
        padding: 10px;
    }

    .head-left,
    .head-right {
        width: 100%;
    }

    .monaco-editor .find-widget.visible .find-part,
    .monaco-editor .find-widget.visible .replace-part {
        grid-template-columns: 1fr !important;
        gap: 4px !important;
        padding: 5px !important;
    }

    .monaco-editor .find-widget .matchesCount {
        font-size: 11px !important;
    }

    .monaco-editor .find-widget .button,
    .monaco-editor .find-widget button,.monaco-editor .find-widget .monaco-button {
        width: 26px !important;
        height: 26px !important;
        min-width: 26px !important;
        min-height: 26px !important;
    }
}

.detected-colors-wrap {
    margin-top: 18px;
    padding: 16px;
    border-radius: 16px;
    background: rgba(15, 23, 42, .55);
    border: 1px solid rgba(148, 163, 184, .14);
}

.detected-colors-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.detected-colors-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.detected-colors-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
}

.detected-color-item {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    border-radius: 14px;
    background: rgba(2, 6, 23, .78);
    border: 1px solid rgba(148, 163, 184, .14);
    box-shadow: 0 10px 25px rgba(0, 0, 0, .18);
}

.detected-color-top {
    display: flex;
    align-items: center;
    gap: 12px;
}

.detected-color-swatch {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, .14);
    background: var(--detected-color, #ffffff);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06);
}

.detected-color-meta {
    min-width: 0;
    flex: 1;
}

.detected-color-code {
    font-size: 14px;
    font-weight: 700;
    color: #e2e8f0;
    word-break: break-all;
}

.detected-color-info {
    margin-top: 4px;
    font-size: 12px;
    color: #94a3b8;
    line-height: 1.5;
}

.detected-color-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.detected-color-row input[type="color"] {
    width: 44px;
    height: 42px;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
}

.detected-color-row input[type="text"] {
    flex: 1;
    min-width: 130px;
    height: 42px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, .18);
    background: #0f172a;
    color: #e2e8f0;
    padding: 0 12px;
    outline: none;
}

.detected-color-row input[type="text"]:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .15);
}

.detected-color-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.detected-empty {
    padding: 16px;
    border-radius: 12px;
    background: rgba(2, 6, 23, .72);
    border: 1px dashed rgba(148, 163, 184, .18);
    color: #94a3b8;
    font-size: 13px;
}