:root {
    --bg-color: #0f172a;
    --panel-bg: rgba(30, 41, 59, 0.4);
    --panel-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #6366f1;
    --accent-hover: #4f46e5;
    --error-color: #ef4444;
    --tree-line: rgba(148, 163, 184, 0.3);

    --sidebar-bg: rgba(15, 23, 42, 0.5);
    --topbar-bg: rgba(30, 41, 59, 0.3);
    --input-bg: rgba(15, 23, 42, 0.6);
    --input-bg-hover: rgba(15, 23, 42, 0.8);
    --btn-secondary-bg: rgba(255, 255, 255, 0.1);
    --btn-secondary-hover: rgba(255, 255, 255, 0.2);
    --shadow-color: rgba(0, 0, 0, 0.5);
    --scroll-track: rgba(15, 23, 42, 0.4);
    --scroll-thumb: rgba(148, 163, 184, 0.4);

    /* Syntax Highlighting */
    --syntax-key: #38bdf8;
    --syntax-string: #a7f3d0;
    --syntax-number: #fdba74;
    --syntax-boolean: #f472b6;
    --syntax-null: #94a3b8;
}

body.light-mode {
    --bg-color: #f8fafc;
    --panel-bg: rgba(255, 255, 255, 0.7);
    --panel-border: rgba(0, 0, 0, 0.1);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --accent-color: #4f46e5;
    --accent-hover: #4338ca;
    --error-color: #dc2626;
    --tree-line: rgba(15, 23, 42, 0.2);

    --sidebar-bg: #e2e8f0;
    --topbar-bg: #ffffff;
    --input-bg: #ffffff;
    --input-bg-hover: #f1f5f9;
    --btn-secondary-bg: rgba(0, 0, 0, 0.05);
    --btn-secondary-hover: rgba(0, 0, 0, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.1);
    --scroll-track: rgba(0, 0, 0, 0.05);
    --scroll-thumb: rgba(0, 0, 0, 0.2);

    /* Syntax Highlighting Light */
    --syntax-key: #0284c7;
    --syntax-string: #16a34a;
    --syntax-number: #ea580c;
    --syntax-boolean: #c026d3;
    --syntax-null: #64748b;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    margin: 0;
    height: 100vh;
    overflow: hidden;
}

.app-dashboard {
    display: flex;
    height: 100vh;
    width: 100vw;
}

.sidebar {
    width: 340px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--panel-border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    gap: 1.5rem;
    flex-shrink: 0;
    overflow-y: auto;
}

.sidebar-header {
    text-align: left;
}

.sidebar-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    background: linear-gradient(to right, #818cf8, #38bdf8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    margin-bottom: 0.5rem;
}

.sidebar-header p {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.main-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background-image:
        radial-gradient(circle at 15% 50%, rgba(99, 102, 241, 0.1), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(56, 189, 248, 0.1), transparent 25%);
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--panel-border);
    background: var(--topbar-bg);
    flex-shrink: 0;
}

.viewer-section {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.glass-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.input-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex: 1;
}
.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.input-group label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

textarea {
    flex: 1;
    background: var(--input-bg);
    border: 1px solid var(--panel-border);
    border-radius: 0.5rem;
    padding: 1rem;
    color: var(--text-primary);
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    resize: none;
    transition: border-color 0.3s;
}

textarea:focus {
    outline: none;
    border-color: var(--accent-color);
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--panel-border);
}

.divider span {
    padding: 0 1rem;
}

input[type="file"] {
    display: none;
}

.file-upload-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: var(--input-bg);
    border: 1px dashed var(--panel-border);
    border-radius: 0.5rem;
    padding: 1rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s;
}

.file-upload-label:hover {
    border-color: var(--accent-color);
    background: var(--input-bg-hover);
}

.upload-icon {
    font-size: 1.2rem;
}

button {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    cursor: pointer;
    border: none;
    border-radius: 0.5rem;
    transition: all 0.3s;
}

.primary-btn {
    background: var(--accent-color);
    color: white;
    padding: 1rem;
    font-size: 1rem;
    margin-top: auto;
}

.primary-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.4);
}

.primary-btn:active {
    transform: translateY(0);
}

.secondary-btn {
    background: var(--btn-secondary-bg);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.secondary-btn:hover {
    background: var(--btn-secondary-hover);
}

.error-message {
    color: var(--error-color);
    font-size: 0.85rem;
    padding: 0.75rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 0.5rem;
    text-align: center;
}

.hidden {
    display: none !important;
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.output-header h2 {
    font-size: 1.2rem;
    font-weight: 500;
}

.tree-controls {
    display: flex;
    gap: 0.5rem;
}

.tree-container {
    height: 100%;
    width: 100%;
    overflow: auto;
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
}

.empty-state {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-style: italic;
}

/* Tree Styles */
.tree-node {
    margin-left: 1.5rem;
    position: relative;
}

.tree-node::before {
    content: '';
    position: absolute;
    left: -1rem;
    top: 0;
    bottom: 0;
    width: 1px;
    background-color: var(--tree-line);
}

.tree-node:last-child::before {
    bottom: auto;
    height: 1.2rem;
}

.tree-node::after {
    content: '';
    position: absolute;
    left: -1rem;
    top: 1.2rem;
    width: 0.8rem;
    height: 1px;
    background-color: var(--tree-line);
}

.tree-root {
    margin-left: 0;
}

.tree-item {
    display: flex;
    align-items: flex-start;
    padding: 0.2rem 0;
}

.tree-caret {
    cursor: pointer;
    user-select: none;
    width: 1.5rem;
    height: 1.5rem;
    line-height: 1.5rem;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.7rem;
    transition: transform 0.3s ease, color 0.3s;
    margin-right: 0.2rem;
}

.tree-caret:hover {
    color: var(--text-primary);
}

.tree-caret.expanded {
    transform: rotate(90deg);
}

.tree-caret.hidden {
    visibility: hidden;
    pointer-events: none;
}

.tree-key {
    color: var(--syntax-key);
    margin-right: 0.5rem;
    line-height: 1.5rem;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: normal;
}

.tree-value-string,
.tree-value-number,
.tree-value-boolean,
.tree-value-null {
    line-height: 1.5rem;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: normal;
}

.tree-value-string {
    color: var(--syntax-string);
}

.tree-value-number {
    color: var(--syntax-number);
}

.tree-value-boolean {
    color: var(--syntax-boolean);
}

.tree-value-null {
    color: var(--syntax-null);
    font-style: italic;
}

.tree-bracket {
    color: var(--text-secondary);
    line-height: 1.5rem;
}

.tree-children {
    display: block;
    overflow: hidden;
}

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

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

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

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

::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.6);
}

/* Responsive */
@media (max-width: 900px) {
    .main-content {
        flex-direction: column;
        height: auto;
    }

    .input-section {
        max-width: 100%;
        min-height: 450px;
    }

    .output-section {
        min-height: 500px;
    }
}

/* View Toggle */
.view-toggle {
    display: flex;
    background: var(--input-bg);
    border-radius: 0.5rem;
    overflow: hidden;
    border: 1px solid var(--panel-border);
}

.toggle-btn {
    background: transparent;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    border-radius: 0;
    flex: 1;
}

.toggle-btn:hover {
    background: var(--btn-secondary-bg);
}

.toggle-btn.active {
    background: var(--accent-color);
    color: white;
}

.icon-btn {
    font-size: 1.2rem;
    padding: 0.2rem 0.6rem;
    line-height: 1;
}

/* Graph Container */
#graph-container {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    background:
        radial-gradient(circle at 34% 42%, rgba(112, 10, 64, 0.26), transparent 36%),
        radial-gradient(circle at 75% 55%, rgba(49, 9, 46, 0.24), transparent 32%);
    touch-action: none;
}

#graph-container.grabbing {
    cursor: grabbing;
}

.graph-wrapper {
    transform-origin: 0 0;
    min-width: max-content;
    min-height: max-content;
    position: relative;
}

.mindmap-surface,
.mindmap-nodes,
.mindmap-connectors {
    position: absolute;
    inset: 0;
}

.mindmap-surface {
    font-family: 'Fira Code', monospace;
    transform-origin: 0 0;
}

.mindmap-connectors {
    overflow: visible;
    pointer-events: none;
}

.mindmap-link {
    fill: none;
    stroke: rgba(214, 203, 177, 0.9);
    stroke-width: 3;
    stroke-linecap: round;
}

.mindmap-source-dot {
    fill: #c9b8ff;
    stroke: var(--bg-color);
    stroke-width: 2;
}

.mindmap-node {
    position: absolute;
    border: 3px solid #a997d8;
    border-radius: 8px;
    color: #e8ddff;
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.42);
    overflow: hidden;
}

.mindmap-container {
<<<<<<< Updated upstream
    width: 340px;
=======
    width: max-content;
    min-width: 360px;
    max-width: 760px;
>>>>>>> Stashed changes
    background:
        linear-gradient(135deg, rgba(35, 21, 58, 0.98), rgba(21, 27, 51, 0.98));
}

.mindmap-root {
<<<<<<< Updated upstream
    width: 420px;
}

.mindmap-value {
    min-width: 190px;
    max-width: 320px;
    min-height: 78px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 1rem 1.5rem;
    background:
        linear-gradient(135deg, rgba(58, 13, 58, 0.96), rgba(42, 21, 72, 0.96));
    text-align: center;
=======
    min-width: 460px;
    max-width: 820px;
}

.mindmap-value {
    min-width: 240px;
    max-width: 620px;
    min-height: 78px;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    padding: 1rem 1.5rem;
    background:
        linear-gradient(135deg, rgba(58, 13, 58, 0.96), rgba(42, 21, 72, 0.96));
    text-align: left;
>>>>>>> Stashed changes
    gap: 0.65rem;
}

.mindmap-row {
    display: grid;
<<<<<<< Updated upstream
    grid-template-columns: minmax(5.4rem, auto) minmax(0, auto) minmax(0, 1fr) auto;
=======
    grid-template-columns: max-content max-content minmax(14rem, 1fr) auto;
>>>>>>> Stashed changes
    gap: 0.65rem;
    align-items: center;
    min-height: 46px;
    padding: 0.65rem 1.55rem 0.65rem 1.2rem;
    border-bottom: 1px solid rgba(201, 184, 255, 0.16);
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.25;
}

.mindmap-row:last-child {
    border-bottom: 0;
}

.mindmap-row.is-branch {
    cursor: pointer;
}

.mindmap-row.is-branch:hover,
.mindmap-row.is-branch:focus {
    background: rgba(201, 184, 255, 0.08);
    outline: none;
}

.mindmap-key {
    color: #f1e6c8;
    min-width: 0;
<<<<<<< Updated upstream
    overflow-wrap: anywhere;
=======
    max-width: 16rem;
    overflow-wrap: break-word;
    word-break: normal;
>>>>>>> Stashed changes
}

.mindmap-summary,
.mindmap-value-text {
    min-width: 0;
<<<<<<< Updated upstream
    overflow-wrap: anywhere;
=======
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: auto;
>>>>>>> Stashed changes
}

.mindmap-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.18rem;
    min-width: 0;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    line-height: 1;
    text-transform: uppercase;
}

.mindmap-type-badge .mindmap-type-icon {
    flex: 0 0 1rem;
    width: 1rem;
    height: 1rem;
    line-height: 1rem;
    margin-right: 0;
}

.mindmap-type-badge .mindmap-type-icon svg {
    display: block;
}

.mindmap-type-label {
    overflow-wrap: normal;
    white-space: nowrap;
}

.mindmap-value-text {
    font-size: 1.1rem;
    font-weight: 800;
    line-height: 1.35;
}

.mindmap-branch-state {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.15rem;
    height: 1.15rem;
    border: 1px solid rgba(201, 184, 255, 0.5);
    border-radius: 999px;
    font-size: 0.8rem;
    line-height: 1;
    color: #e8ddff;
}

.mindmap-row.is-collapsed .mindmap-branch-state {
    background: rgba(201, 184, 255, 0.14);
}

.mindmap-empty-row {
    color: var(--text-secondary);
    font-style: italic;
}

.mindmap-row.type-string .mindmap-summary,
.mindmap-value.type-string .mindmap-value-text {
    color: var(--syntax-string);
}

.mindmap-row.type-number .mindmap-summary,
.mindmap-value.type-number .mindmap-value-text {
    color: var(--syntax-number);
}

.mindmap-row.type-boolean .mindmap-summary,
.mindmap-value.type-boolean .mindmap-value-text {
    color: var(--syntax-boolean);
}

.mindmap-row.type-null .mindmap-summary,
.mindmap-value.type-null .mindmap-value-text {
    color: var(--syntax-null);
    font-style: italic;
}

body.light-mode #graph-container {
    background:
        radial-gradient(circle at 34% 42%, rgba(99, 102, 241, 0.12), transparent 36%),
        radial-gradient(circle at 75% 55%, rgba(14, 165, 233, 0.1), transparent 32%);
}

body.light-mode .mindmap-node {
    border-color: #64748b;
    color: #0f172a;
    box-shadow: 0 18px 42px rgba(15, 23, 42, 0.12);
}

body.light-mode .mindmap-container {
    background: rgba(255, 255, 255, 0.94);
}

body.light-mode .mindmap-value {
    background: rgba(238, 242, 255, 0.96);
}

body.light-mode .mindmap-link {
    stroke: rgba(71, 85, 105, 0.72);
}

body.light-mode .mindmap-source-dot {
    fill: #64748b;
    stroke: #f8fafc;
}

body.light-mode .mindmap-row {
    border-bottom-color: rgba(100, 116, 139, 0.18);
}

body.light-mode .mindmap-key,
body.light-mode .mindmap-branch-state {
    color: #0f172a;
}

/* Type Icons and Pills for List View */
.type-icon {
    font-size: 0.85rem;
    font-weight: 700;
    margin-right: 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1.5rem;
    height: 1.5rem;
}

.toggle-icon {
    margin-top: 2px;
}

.type-icon-object { color: #facc15; } /* Yellow */
.type-icon-array { color: #f87171; } /* Red */
.type-icon-string { color: #4ade80; } /* Green */
.type-icon-number { color: #60a5fa; } /* Blue */
.type-icon-boolean { color: #c084fc; } /* Purple */
.type-icon-null { color: #94a3b8; } /* Gray */
