:root {
    /* Dark Theme (Default) */
    --bg-dark: #0F1219;
    --bg-panel: #161A23;
    --bg-input: #0B0D12;
    --border: #2A2E39;

    --primary: #6366F1;
    --primary-hover: #4F46E5;
    --secondary: #8B5CF6;
    --accent: #22D3EE;

    --text-main: #F3F4F6;
    --text-muted: #9CA3AF;

    /* Diff Colors */
    --diff-add-bg: rgba(16, 185, 129, 0.15);
    --diff-add-text: #34D399;
    --diff-add-line: rgba(16, 185, 129, 0.3);

    --diff-rem-bg: rgba(239, 68, 68, 0.15);
    --diff-rem-text: #F87171;
    --diff-rem-line: rgba(239, 68, 68, 0.3);

    --diff-mod-bg: rgba(245, 158, 11, 0.15);
    --diff-mod-text: #FBBF24;
    --diff-mod-line: rgba(245, 158, 11, 0.3);

    --diff-unchanged: #9CA3AF;

    /* JSON syntax */
    --syn-key: #A78BFA;
    --syn-str: #34D399;
    --syn-num: #F87171;
    --syn-bool: #60A5FA;

    --radius: 12px;
    --radius-sm: 8px;
    --transition: 200ms ease;
    --glass-bg: rgba(22, 26, 35, 0.7);
}

.theme-light {
    --bg-dark: #F3F4F6;
    --bg-panel: #FFFFFF;
    --bg-input: #F9FAFB;
    --border: #E5E7EB;

    --text-main: #111827;
    --text-muted: #6B7280;

    --diff-add-bg: rgba(16, 185, 129, 0.1);
    --diff-add-text: #059669;
    --diff-add-line: rgba(16, 185, 129, 0.2);

    --diff-rem-bg: rgba(239, 68, 68, 0.1);
    --diff-rem-text: #DC2626;
    --diff-rem-line: rgba(239, 68, 68, 0.2);

    --diff-mod-bg: rgba(245, 158, 11, 0.1);
    --diff-mod-text: #D97706;
    --diff-mod-line: rgba(245, 158, 11, 0.2);

    --diff-unchanged: #6B7280;

    --syn-key: #7C3AED;
    --syn-str: #059669;
    --syn-num: #DC2626;
    --syn-bool: #2563EB;

    --glass-bg: rgba(255, 255, 255, 0.8);
}

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

body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.5;
    height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color var(--transition), color var(--transition);
}

.font-mono {
    font-family: 'JetBrains Mono', monospace;
}

.hidden {
    display: none !important;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 1rem;
    gap: 1rem;
    max-width: 1920px;
    margin: 0 auto;
    width: 100%;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-panel);
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    flex-shrink: 0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    backdrop-filter: blur(10px);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-main);
}

.logo svg {
    color: var(--primary);
}

h1 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.02em;
    background: linear-gradient(to right, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.app-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-right: auto;
    margin-left: 1rem;
    border-left: 1px solid var(--border);
    padding-left: 1rem;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    position: relative;
}

/* Dropdown Settings */
.settings-dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    right: 0;
    top: 120%;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    width: 220px;
    z-index: 100;
}

.setting-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
    color: var(--text-main);
}

.checkbox-label input {
    display: none;
}

.custom-cb {
    width: 16px;
    height: 16px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    border-radius: 4px;
    position: relative;
    transition: all var(--transition);
    flex-shrink: 0;
}

.checkbox-label input:checked+.custom-cb {
    background: var(--primary);
    border-color: var(--primary);
}

.checkbox-label input:checked+.custom-cb::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Workspace */
.workspace {
    display: flex;
    flex: 1;
    min-height: 0;
    gap: 1rem;
    position: relative;
}

.divider {
    width: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 50px;
    flex-shrink: 0;
    z-index: 10;
}

.diff-stats {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-badge {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-main);
    font-family: 'JetBrains Mono', monospace;
    transition: transform var(--transition);
}

.stat-badge:hover {
    transform: scale(1.1);
}

.stat-badge.added {
    background: var(--diff-add-bg);
    border: 1px solid var(--diff-add-text);
    color: var(--diff-add-text);
}

.stat-badge.removed {
    background: var(--diff-rem-bg);
    border: 1px solid var(--diff-rem-text);
    color: var(--diff-rem-text);
}

.stat-badge.changed {
    background: var(--diff-mod-bg);
    border: 1px solid var(--diff-mod-text);
    color: var(--diff-mod-text);
}

/* Panels */
.panel {
    flex: 1;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    position: relative;
}

.panel.drag-over {
    border-color: var(--primary);
    background: var(--bg-input);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--glass-bg);
    flex-shrink: 0;
    backdrop-filter: blur(10px);
}

.panel-header h2 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
}

.panel-actions {
    display: flex;
    gap: 0.5rem;
}

.input-container,
.diff-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    position: relative;
}

/* Editor */
.code-editor {
    flex: 1;
    background: var(--bg-input);
    border: none;
    color: var(--text-main);
    padding: 1rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    resize: none;
    outline: none;
    white-space: pre;
    overflow: auto;
}

.status-bar {
    padding: 0.4rem 1rem;
    font-size: 0.75rem;
    background: var(--glass-bg);
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.status-bar.error {
    color: var(--diff-rem-text);
    background: rgba(239, 68, 68, 0.05);
    border-top-color: rgba(239, 68, 68, 0.2);
}

/* Tree Diff View */
.diff-container {
    background: var(--bg-input);
    overflow: auto;
    padding: 1rem 0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
}

.tree-node {
    display: flex;
    flex-direction: column;
}

.tree-line {
    display: flex;
    padding: 0.2rem 1rem;
    cursor: pointer;
    position: relative;
    border-left: 2px solid transparent;
}

.tree-line:hover {
    background: rgba(128, 128, 128, 0.1);
}

/* Line type coloring */
.tree-line.added {
    background: var(--diff-add-bg);
    color: var(--diff-add-text);
    border-left-color: var(--diff-add-line);
}

.tree-line.removed {
    background: var(--diff-rem-bg);
    color: var(--diff-rem-text);
    border-left-color: var(--diff-rem-line);
}

.tree-line.changed {
    background: var(--diff-mod-bg);
    color: var(--diff-mod-text);
    border-left-color: var(--diff-mod-line);
}

.tree-line.unchanged {
    color: var(--diff-unchanged);
}

.tree-indent {
    display: inline-block;
}

.tree-toggle {
    width: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    user-select: none;
}

.tree-toggle:hover {
    color: var(--text-main);
}

.tree-key {
    color: var(--syn-key);
}

.tree-val.string {
    color: var(--syn-str);
}

.tree-val.number {
    color: var(--syn-num);
}

.tree-val.boolean {
    color: var(--syn-bool);
}

.tree-val.null {
    color: var(--text-muted);
    font-style: italic;
}

.tree-line.changed .tree-val {
    color: var(--diff-mod-text);
    font-weight: 700;
    text-decoration: underline;
    text-decoration-color: rgba(245, 158, 11, 0.5);
}

.tree-children {
    display: flex;
    flex-direction: column;
}

.tree-children.collapsed {
    display: none;
}

/* Connecting hover logic */
.tree-line.hover-sync {
    background: rgba(128, 128, 128, 0.15);
}

/* Line View (Flat list of changes) */
.line-view-mode {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    padding: 1rem;
}

.line-diff-entry {
    margin-bottom: 1rem;
    border-left: 2px solid var(--border);
    padding-left: 1rem;
}

.line-diff-path {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.line-diff-val {
    display: block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.line-diff-val.red {
    background: var(--diff-rem-bg);
    color: var(--diff-rem-text);
    text-decoration: line-through;
}

.line-diff-val.green {
    background: var(--diff-add-bg);
    color: var(--diff-add-text);
}

/* Footer */
.app-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    flex-shrink: 0;
    backdrop-filter: blur(10px);
}

.view-toggles,
.footer-actions {
    display: flex;
    gap: 0.5rem;
}

/* Buttons */
.btn {
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.btn.primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
}

.btn.primary:hover {
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
}

.btn.secondary {
    background: rgba(128, 128, 128, 0.1);
    color: var(--text-main);
}

.btn.secondary:hover {
    background: rgba(128, 128, 128, 0.2);
}

.btn.outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.btn.outline:hover {
    border-color: var(--text-muted);
    color: var(--text-main);
}

.btn.outline.active {
    background: rgba(128, 128, 128, 0.15);
    color: var(--text-main);
    border-color: transparent;
}

.btn.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    height: 32px;
}

.icon-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
}

.icon-btn:hover {
    background: rgba(128, 128, 128, 0.1);
    color: var(--text-main);
}

.icon-text-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: color var(--transition);
}

.icon-text-btn:hover {
    color: var(--primary);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    background: var(--text-main);
    color: var(--bg-dark);
    padding: 0.75rem 1.5rem;
    border-radius: 99px;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.toast.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(30px);
    pointer-events: none;
}

.toast.error {
    background: var(--diff-rem-text);
    color: white;
}

/* Drag Overlay */
.drag-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(99, 102, 241, 0.1);
    border: 2px dashed var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    pointer-events: none;
    backdrop-filter: blur(2px);
}

.drag-msg {
    background: var(--primary);
    color: white;
    padding: 1rem 2rem;
    border-radius: var(--radius);
    font-weight: 600;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Responsive */
@media (max-width: 1024px) {
    .workspace {
        flex-direction: column;
    }

    .divider {
        width: 100%;
        flex-direction: row;
        padding-top: 0;
        justify-content: center;
        padding: 0.5rem;
    }

    .diff-stats {
        flex-direction: row;
    }
}