.dw-json-wrapper {
    max-width: 1400px;
    margin: 40px auto;
    padding: 30px 20px;
    font-family: 'Inter', system-ui, sans-serif;
    color: #1e293b;
    border-radius: 24px;
    transition: background 0.3s, color 0.3s;
}

/* Typography */
.dw-title { font-size: 36px; font-weight: 800; text-align: center; margin-bottom: 10px; color: #0f172a; transition: 0.3s; }
.dw-sub { text-align: center; color: #64748b; margin-bottom: 35px; font-size: 16px; transition: 0.3s; }

/* Box Design */
.dw-box {
    background: #ffffff;
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.06);
    border: 1px solid #f1f5f9;
    transition: all 0.3s ease;
}
.dw-box-title { font-weight: 700; margin-bottom: 15px; font-size: 16px; color: #3b82f6; }

/* Toolbar Layout */
.dw-toolbar {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    padding: 20px 24px;
}
.toolbar-left, .toolbar-right {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

/* Buttons */
.dw-toolbar button, .upload-label {
    padding: 10px 18px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    display: inline-block;
}
.btn-primary { background: #2563eb; color: #ffffff; box-shadow: 0 4px 12px rgba(37,99,235,0.2); }
.btn-primary:hover { background: #1d4ed8; transform: translateY(-2px); box-shadow: 0 6px 16px rgba(37,99,235,0.3); }
.btn-secondary, .upload-label { background: #f1f5f9; color: #334155; border: 1px solid #e2e8f0; }
.btn-secondary:hover, .upload-label:hover { background: #e2e8f0; transform: translateY(-2px); }

/* Search Input */
#dw-search {
    padding: 10px 16px;
    border-radius: 12px;
    border: 1px solid #cbd5e1;
    min-width: 200px;
    font-size: 14px;
    outline: none;
    background: #f8fafc;
}
#dw-search:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }

/* =====================================
   GRID & EDITOR FIX (Core Solution)
===================================== */
.dw-grid { 
    display: grid; 
    /* minmax(0, 1fr) ensures the box NEVER expands beyond 50% width */
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); 
    gap: 25px; 
}
.editor-box {
    min-width: 0; /* Prevents flex/grid blowouts */
    width: 100%;
}

.CodeMirror {
    height: 550px !important;
    max-width: 100%; /* Force it to stay inside the box */
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    font-family: 'Fira Code', monospace;
    font-size: 14px;
    background: #f8fafc;
}
.CodeMirror-scroll {
    overflow: auto !important; /* Enables both H & V scrollbars natively */
}

/* Custom Scrollbars for Editors */
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar { outline: none; }
.CodeMirror-scroll::-webkit-scrollbar { width: 10px; height: 12px; }
.CodeMirror-scroll::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 10px; }
.CodeMirror-scroll::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 10px; border: 2px solid #f1f5f9; }
.CodeMirror-scroll::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* Stats Footer */
.dw-stats { display: flex; justify-content: space-between; font-weight: 600; font-size: 14px; }
#dw-message { color: #10b981; }

/* Dark Mode Switch */
.dw-dark-toggle-wrap { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.dw-switch { position: relative; display: inline-block; width: 48px; height: 24px; }
.dw-switch input { opacity: 0; width: 0; height: 0; }
.dw-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: #cbd5e1; border-radius: 34px; transition: .3s; }
.dw-slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: .3s; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
.dw-switch input:checked + .dw-slider { background: #3b82f6; }
.dw-switch input:checked + .dw-slider:before { transform: translateX(24px); }

/* =====================================
   DARK MODE & VIBRANT SYNTAX HIGHLIGHTING
===================================== */
.dw-json-wrapper.dw-dark { 
    background: #0f172a; 
    color: #f8fafc; 
    padding: 30px; 
}
.dw-json-wrapper.dw-dark .dw-title { color: #ffffff !important; }
.dw-json-wrapper.dw-dark .dw-sub { color: #94a3b8 !important; }
.dw-json-wrapper.dw-dark .dw-box { background: #1e293b; border: 1px solid #334155; box-shadow: 0 10px 30px rgba(0,0,0,0.3); }

.dw-json-wrapper.dw-dark .btn-secondary, 
.dw-json-wrapper.dw-dark .upload-label { background: #334155; color: #f8fafc; border: 1px solid #475569; }
.dw-json-wrapper.dw-dark .btn-secondary:hover, 
.dw-json-wrapper.dw-dark .upload-label:hover { background: #475569; }

.dw-json-wrapper.dw-dark #dw-search { background: #0f172a; border-color: #334155; color: #f8fafc; }

/* Dark CodeMirror Editor */
.dw-json-wrapper.dw-dark .CodeMirror { background: #0f172a; color: #e2e8f0; border-color: #334155; }
.dw-json-wrapper.dw-dark .CodeMirror-scroll::-webkit-scrollbar-track { background: #0f172a; }
.dw-json-wrapper.dw-dark .CodeMirror-scroll::-webkit-scrollbar-thumb { background: #475569; border: 2px solid #0f172a; }
.dw-json-wrapper.dw-dark .CodeMirror-scroll::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* Syntax Highlighting for Dark Mode (Making it readable and beautiful) */
.dw-json-wrapper.dw-dark .cm-string { color: #86efac !important; } /* Light Green */
.dw-json-wrapper.dw-dark .cm-number { color: #fca5a5 !important; } /* Light Red/Orange */
.dw-json-wrapper.dw-dark .cm-property { color: #93c5fd !important; } /* Light Blue (Keys) */
.dw-json-wrapper.dw-dark .cm-atom { color: #c4b5fd !important; } /* Light Purple (Boolean/Null) */

/* Tree View Colors */
#dw-tree-view ul { list-style: none; border-left: 1px dashed #cbd5e1; padding-left: 20px; }
#dw-tree-view li { margin: 8px 0; font-family: monospace; }
.tree-key { font-weight: bold; color: #2563eb; }
.tree-string { color: #16a34a; }
.dw-json-wrapper.dw-dark #dw-tree-view ul { border-color: #475569; }
.dw-json-wrapper.dw-dark .tree-key { color: #93c5fd; }
.dw-json-wrapper.dw-dark .tree-string { color: #86efac; }

/* Responsive */
@media(max-width: 1024px) {
    .dw-grid { grid-template-columns: 1fr; }
    .dw-toolbar { justify-content: center; }
    .toolbar-left, .toolbar-right { justify-content: center; }
}