:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg: #f8f9fa;
    --border: #e2e8f0;
    --text: #1a202c;
    --text-secondary: #64748b;
    --error: #dc2626;
    --success: #16a34a;
    --code-bg: #ffffff;
    --key-color: #8a2be2;
    --string-color: #50a14f;
    --number-color: #986801;
    --boolean-color: #e45649;
    --null-color: #a626a4;
    --meta-color: #aaa;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
}

h1 {
    color: var(--primary);
    margin: 1rem 0 1.5rem;
    font-size: 1.8rem;
    font-weight: 600;
}

.security-alert {
    display: flex;
    gap: 8px;
    background: #fffbdd;
    border: 1px solid #f5d300;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    align-items: flex-start;
}

.alert-icon {
    flex-shrink: 0;
    font-size: 1.2rem;
    color: #d4b106;
}

.alert-text {
    color: #5e4d03;
    line-height: 1.5;
    font-size: 0.95rem;
}

.toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    align-items: center;
}

.toolbar button {
    padding: 0.7rem 1.2rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: white;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

.toolbar button:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #f0f4ff;
}

.toolbar button.primary {
    background: var(--primary);
    color: white;
    border: none;
}

.toolbar button.primary:hover {
    background: var(--primary-hover);
    color: white;
}

.toolbar button.danger {
    color: var(--error);
}

.toolbar button.danger:hover {
    background: #fef2f2;
    border-color: var(--error);
    color: var(--error);
}

.status-indicator {
    margin-left: auto;
    padding: 0.5rem 1rem;
    border-radius: 30px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
    background: #f1f5f9;
}

.status-indicator.valid {
    background: #e6f7e6;
    color: var(--success);
    border: 1px solid #b7eb8f;
}

.status-indicator.invalid {
    background: #fff1f0;
    color: var(--error);
    border: 1px solid #ffccc7;
}

.status-indicator .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.workspace {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    flex: 1;
    min-height: 500px;
}

.panel {
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 8px;
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,0.02);
}

.panel-header {
    padding: 0.8rem 1rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-content {
    flex: 1;
    position: relative;
    background: #fdfdfd;
}

textarea {
    width: 100%;
    height: 100%;
    min-height: 400px;
    padding: 1rem;
    border: none;
    resize: none;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    outline: none;
    background: transparent;
}

textarea:focus {
    background: #fbfdff;
}

.output-area {
    padding: 1rem;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    overflow: auto;
    min-height: 400px;
    max-height: 600px;
    background: #fafcff;
}

/* 树形预览样式 */
.tree-view-root {
    padding-left: 0.2rem;
}
.tree-item {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    line-height: 1.8;
    margin: 2px 0;
}
.tree-summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 4px;
    border-radius: 4px;
    padding: 2px 0;
}
.tree-summary:hover {
    background: #eef2f6;
}
.tree-summary::-webkit-details-marker {
    display: none;
}
.tree-summary::before {
    content: '▶';
    display: inline-block;
    width: 1.2rem;
    color: #94a3b8;
    font-size: 0.8rem;
    transition: transform 0.1s;
}
details[open] > .tree-summary::before {
    content: '▼';
}
.tree-children {
    padding-left: 1.2rem;
    border-left: 1px dashed #d1d9e6;
    margin-left: 0.5rem;
}
.key {
    color: var(--key-color);
    font-weight: 500;
    margin-right: 4px;
}
.string { color: var(--string-color); }
.number { color: var(--number-color); }
.boolean { color: var(--boolean-color); }
.null { color: var(--null-color); font-style: italic; }
.empty { color: #a0aec0; font-style: italic; }
.meta { color: var(--meta-color); font-size: 0.9em; margin: 0 4px; }
.brace { color: #4a5568; }

.error-message {
    color: var(--error);
    padding: 1rem;
    background: #fff2f0;
    border-left: 4px solid var(--error);
    border-radius: 4px;
}
.error-location {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.stats-row {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

footer {
    margin-top: 2rem;
    padding: 1.5rem 0 0.5rem;
    border-top: 1px solid var(--border);
    text-align: center;
}

.footer-content {
    color: #666;
    font-size: 0.9rem;
}

.footer-content a {
    color: var(--primary);
    text-decoration: none;
}

.footer-content a:hover {
    text-decoration: underline;
}

.footer-status {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border);
    display: flex;
    justify-content: center;
    gap: 24px;
    flex-wrap: wrap;
    font-size: 0.8rem;
    color: #94a3b8;
}

.footer-status span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.footer-status .dot {
    width: 8px;
    height: 8px;
    background: #52c41a;
    border-radius: 50%;
    display: inline-block;
}

.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-80px);
    background: #1e293b;
    color: white;
    padding: 12px 28px;
    border-radius: 40px;
    font-size: 14px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
    pointer-events: none;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

@media (max-width: 900px) {
    .workspace {
        grid-template-columns: 1fr;
    }

    .status-indicator {
        margin-left: 0;
        margin-top: 10px;
        width: 100%;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar button {
        width: 100%;
        justify-content: center;
    }
}