:root {
    /* Beige / Apricot Theme */
    --bg-color: #faf6f0;       /* Light beige background */
    --panel-bg: #ffffff;       /* Pure white panels */
    --border-color: #e8dfd8;   /* Warm border */
    --text-primary: #4a3f35;   /* Dark warm brown text */
    --text-secondary: #8c7d70; /* Muted brown */
    --accent-color: #d98850;   /* Apricot accent */
    --accent-hover: #c2723c;
    --error-color: #e05252;
    --success-color: #5cb87a;
    
    /* JSON Syntax Colors - Warm Theme */
    --json-key: #a05a2c;      /* Deep Apricot */
    --json-string: #4f8a65;   /* Muted Green */
    --json-number: #c2723c;   /* Orange */
    --json-boolean: #d95050;  /* Soft Red */
    --json-null: #8c7d70;     /* Muted */
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Layout */
.app-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
.mac-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(138, 120, 105, 0.05);
}

h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

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

/* Buttons */
button {
    font-family: inherit;
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.1s ease;
}

.primary-btn {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    box-shadow: 0 2px 6px rgba(217, 136, 80, 0.3);
}

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

.secondary-btn {
    background: #ffffff;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

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

.icon-btn {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
    padding: 0.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

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

.text-btn {
    background: transparent;
    color: var(--accent-color);
    border: none;
    font-size: 0.8rem;
    padding: 0.4rem 0.6rem;
}

.text-btn:hover {
    text-decoration: underline;
}

/* Grid Area */
.editor-grid {
    display: flex;
    gap: 1.5rem;
    flex-grow: 1;
    min-height: 0;
}

/* Panels */
.panel {
    flex: 1;
    width: 50%;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 12px rgba(138, 120, 105, 0.05);
    overflow: hidden;
}

/* Force headers to be exact same height to fix alignment issues */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 56px;
    padding: 0 1.2rem;
    border-bottom: 1px solid var(--border-color);
    background: #fdfcfb;
}

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

.output-actions {
    display: flex;
    align-items: center;
    gap: 0.2rem;
}

/* Input Area */
textarea {
    flex-grow: 1;
    background: transparent;
    border: none;
    padding: 1.2rem;
    color: var(--text-primary);
    font-family: 'SF Mono', Menlo, Monaco, Consolas, 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: none;
    outline: none;
}

textarea::placeholder {
    color: #c4b9b0;
}

/* Output Area (Tree View) */
.output-area {
    flex-grow: 1;
    padding: 1.2rem;
    overflow-y: auto;
    font-family: 'SF Mono', Menlo, Monaco, Consolas, 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Tree View Styles */
.json-tree, .json-tree ul {
    list-style: none;
}

.json-tree ul {
    padding-left: 1.5rem;
    border-left: 1px solid #e8dfd8;
    margin-left: 0.5rem;
}

.json-node {
    margin: 2px 0;
    position: relative;
    /* Auto wrap long lines */
    word-break: break-all;
    white-space: pre-wrap;
    overflow-wrap: break-word;
}

.json-key { 
    color: var(--json-key); 
}

.json-val.string { color: var(--json-string); }
.json-val.number { color: var(--json-number); }
.json-val.boolean { color: var(--json-boolean); }
.json-val.null { color: var(--json-null); font-style: italic; }

.toggle {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    color: #8c7d70;
    font-size: 11px;
    margin-right: 6px;
    user-select: none;
    position: absolute;
    left: -20px;
    top: 3px;
}

.toggle:hover {
    color: var(--accent-color);
}

/* FIXED: Target the inner ul and toggle inside the node-wrapper */
.collapsed > .node-wrapper > ul {
    display: none;
}

.collapsed > .node-wrapper > .toggle::after {
    content: '▶';
}

.toggle::after {
    content: '▼';
}

.node-wrapper {
    position: relative;
    padding-left: 20px;
}

.item-count {
    color: #8c7d70;
    font-size: 0.8em;
    margin-left: 5px;
    cursor: pointer;
    background: var(--bg-color);
    padding: 1px 6px;
    border-radius: 10px;
}
.item-count:hover {
    background: #e8dfd8;
}

/* Plain pre rendering fallback (Minify mode) */
.plain-pre {
    word-break: break-all;
    white-space: pre-wrap;
    color: var(--text-primary);
}

/* Status Badges */
.status-badge {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.3rem 0.6rem;
    border-radius: 10px;
    background: var(--bg-color);
    color: var(--text-secondary);
}

.status-badge.error {
    background: #fce8e8;
    color: var(--error-color);
}

.status-badge.success {
    background: #eaf5ee;
    color: var(--success-color);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #dcd3cb;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #c4b9b0;
}

@media (max-width: 900px) {
    .editor-grid {
        flex-direction: column;
    }
    .panel {
        width: 100%;
        /* Force panels to split height equally */
        flex: 1;
    }
    .app-container { padding: 1rem; }
}
