:root {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --accent: #10b981;
    --accent-hover: #059669;
    --accent-light: #d1fae5;
    --border: #e2e8f0;
    --success: #10b981;
    --error: #ef4444;
    --error-light: #fee2e2;
    --warning: #f59e0b;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    
    /* Syntax highlighting */
    --json-key: #0369a1;
    --json-string: #059669;
    --json-number: #d97706;
    --json-boolean: #7c3aed;
    --json-null: #64748b;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #34d399;
    --accent-hover: #10b981;
    --accent-light: #064e3b;
    --border: #334155;
    --error-light: #450a0a;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    
    --json-key: #7dd3fc;
    --json-string: #6ee7b7;
    --json-number: #fcd34d;
    --json-boolean: #c4b5fd;
    --json-null: #94a3b8;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

header { text-align: center; margin-bottom: 2rem; }

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--accent), #06b6d4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

/* Trust Badges */
.trust-badges {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.trust-badges .badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.35rem 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.builder-card {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    border: 1px solid var(--border);
}

/* Status Banner */
.status-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    transition: all 0.3s;
}

.status-banner.valid {
    background: var(--accent-light);
    border-color: var(--success);
}

.status-banner.invalid {
    background: var(--error-light);
    border-color: var(--error);
}

.status-icon { font-size: 1.25rem; }
.status-text { font-weight: 500; color: var(--text-primary); }

/* Editor Section */
.editor-section { margin-bottom: 1.5rem; }

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.editor-header label {
    font-weight: 600;
    color: var(--text-primary);
}

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

.small-btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.small-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.editor-wrapper {
    position: relative;
    display: flex;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-tertiary);
    transition: border-color 0.2s;
}

.editor-wrapper:focus-within { border-color: var(--accent); }
.editor-wrapper.error { border-color: var(--error); }
.editor-wrapper.drag-over { border-color: var(--accent); border-style: dashed; }

.line-numbers {
    padding: 1rem 0.75rem;
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    text-align: right;
    user-select: none;
    border-right: 1px solid var(--border);
    min-width: 3rem;
}

textarea {
    flex: 1;
    padding: 1rem;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    border: none;
    background: transparent;
    color: var(--text-primary);
    resize: vertical;
    min-height: 300px;
    outline: none;
}

textarea::placeholder { color: var(--text-muted); }

/* Drop Overlay */
.drop-overlay {
    position: absolute;
    inset: 0;
    background: rgba(16, 185, 129, 0.1);
    border: 2px dashed var(--accent);
    border-radius: var(--radius-sm);
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: var(--accent);
    font-weight: 600;
    z-index: 10;
}

.editor-wrapper.drag-over .drop-overlay { display: flex; }

.editor-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

.editor-stats {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.error-display {
    margin-top: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--error-light);
    border: 1px solid var(--error);
    border-radius: var(--radius-sm);
    color: var(--error);
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.85rem;
    display: none;
}

.error-display.visible { display: block; }

/* Actions */
.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.action-btn {
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 600;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.action-btn:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.action-btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.action-btn.primary:hover:not(:disabled) {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: white;
}

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

/* Tree Section */
.tree-section {
    display: none;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.tree-section.visible { display: block; }

.tree-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tree-header h3 { font-size: 1rem; }

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

.collapse-btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.collapse-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.tree-container {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    max-height: 400px;
    overflow: auto;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.85rem;
}

/* Tree nodes */
.tree-node {
    padding-left: 1.25rem;
    position: relative;
}

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

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

.tree-key:hover { text-decoration: underline; }

.tree-toggle {
    display: inline-block;
    width: 1rem;
    cursor: pointer;
    user-select: none;
    color: var(--text-muted);
}

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

.tree-value { margin-left: 0.25rem; }
.tree-value.string { color: var(--json-string); }
.tree-value.number { color: var(--json-number); }
.tree-value.boolean { color: var(--json-boolean); }
.tree-value.null { color: var(--json-null); }

.tree-collapsed > .tree-node { display: none; }
.tree-bracket { color: var(--text-muted); }
.tree-count { color: var(--text-muted); font-size: 0.8em; }

/* Info Section */
.info-section {
    margin-top: 2.5rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.info-section h2 {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

.info-section > p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.info-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
}

.info-card h3 {
    font-size: 1rem;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

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

/* FAQ Section */
.faq-section { margin-top: 2.5rem; }

.faq-section h2 {
    font-size: 1.5rem;
    margin-bottom: 1.25rem;
    text-align: center;
}

.faq-item { margin-bottom: 0.75rem; }

.faq-item details {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.faq-item summary {
    padding: 1rem 1.25rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    list-style: none;
    transition: background-color 0.2s;
}

.faq-item summary::-webkit-details-marker { display: none; }

.faq-item summary::after {
    content: '+';
    font-size: 1.25rem;
    font-weight: 400;
    color: var(--text-muted);
}

.faq-item details[open] summary::after { content: '−'; }
.faq-item summary:hover { background: var(--bg-tertiary); }

.faq-content {
    padding: 0 1.25rem 1.25rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.7;
}

.faq-content p { margin-bottom: 0.75rem; }
.faq-content ul, .faq-content ol { margin: 0.75rem 0; padding-left: 1.5rem; }
.faq-content li { margin-bottom: 0.5rem; }

.faq-content code {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.85em;
    padding: 0.2rem 0.4rem;
    background: var(--bg-tertiary);
    border-radius: 4px;
    color: var(--accent);
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal.visible { display: flex; }

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 500px;
    width: 100%;
    box-shadow: var(--shadow-lg);
}

.modal-content h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.modal-content input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.modal-content input:focus {
    outline: none;
    border-color: var(--accent);
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.modal-note {
    margin-top: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Footer */
footer {
    text-align: center;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.footer-content p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.footer-links { font-size: 0.8rem; }

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
}

.footer-links a:hover { color: var(--accent); }
footer a { color: var(--accent); text-decoration: none; }

.theme-toggle {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--bg-secondary);
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    font-size: 1.25rem;
    transition: transform 0.2s;
    z-index: 100;
}

.theme-toggle:hover { transform: scale(1.1); }

/* Mobile */
@media (max-width: 640px) {
    .container { padding: 1rem; }
    h1 { font-size: 2rem; }
    .builder-card { padding: 1.25rem; }
    .actions { flex-direction: column; }
    .action-btn { justify-content: center; }
    .info-grid { grid-template-columns: 1fr; }
    textarea { min-height: 200px; }
    .editor-header { flex-direction: column; align-items: flex-start; }
    .editor-actions { width: 100%; justify-content: flex-start; }
}
