:root {
    --bg-main: #f8fafc;
    --panel-bg: #ffffff;
    --border-color: #e2e8f0;
    --border-focus: #3b82f6;
    
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-code: #1e293b;
    
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --accent-bg: #eff6ff;
    
    --warning-color: #d97706;
    --warning-bg: #fffbeb;
    --warning-border: #fde68a;
    
    --error-color: #ef4444;
    --error-bg: #fef2f2;
    --error-border: #fca5a5;
    
    --success-color: #10b981;
    --success-bg: #ecfdf5;
    
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'Fira Code', Monaco, Consolas, "Courier New", monospace;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Header */
.app-header {
    height: 56px;
    background: var(--panel-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 10;
    box-shadow: var(--shadow-sm);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.logo span {
    color: var(--accent-color);
}

.tagline {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-main);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.status-indicator {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-main);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

/* Main Area */
.app-main {
    flex: 1;
    display: flex;
    overflow: hidden;
    padding: 16px;
    gap: 16px;
    background-color: var(--bg-main);
}

.panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--panel-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.panel:hover {
    box-shadow: var(--shadow-lg);
}

.panel-header {
    height: 42px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    background: #fafbfc;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
}

.panel-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.panel-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.panel-btn:hover {
    background: #f1f5f9;
    color: var(--text-main);
    border-color: var(--text-muted);
}

/* Textareas & Inputs */
textarea {
    flex: 1;
    width: 100%;
    border: none;
    resize: none;
    padding: 20px;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-code);
    outline: none;
    line-height: 1.6;
    background: transparent;
}

textarea::placeholder {
    color: #cbd5e1;
}

/* Output Area */
.output-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #fafbfc;
    position: relative;
}

pre {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-code);
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.6;
}

/* Custom Scrollbars */
.output-container::-webkit-scrollbar,
textarea::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.output-container::-webkit-scrollbar-track,
textarea::-webkit-scrollbar-track {
    background: transparent;
}

.output-container::-webkit-scrollbar-thumb,
textarea::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.output-container::-webkit-scrollbar-thumb:hover,
textarea::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* States */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #94a3b8;
    gap: 12px;
}

.empty-icon {
    font-size: 32px;
}

.empty-state p {
    font-size: 14px;
    font-weight: 500;
}

/* AI Warning Panel */
.ai-warning-box {
    border: 1px solid var(--warning-border);
    background: var(--warning-bg);
    border-radius: var(--radius-md);
    padding: 24px;
    text-align: center;
    margin-top: 10px;
    box-shadow: var(--shadow-sm);
    animation: fadeIn 0.3s ease;
}

.ai-warning-box p {
    font-size: 14px;
    font-weight: 500;
    color: var(--warning-color);
    margin-bottom: 18px;
}

.ai-btn {
    background: linear-gradient(135deg, #4f46e5, #3b82f6);
    color: #ffffff;
    border: none;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.ai-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.3);
}

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

/* Loading Spinner */
.loading-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    gap: 16px;
    animation: fadeIn 0.2s ease;
}

.spinner {
    width: 42px;
    height: 42px;
    border: 3px solid rgba(59, 130, 246, 0.1);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Error States */
.error-box {
    border: 1px solid var(--error-border);
    background: var(--error-bg);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-top: 10px;
    animation: fadeIn 0.3s ease;
}

.error-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--error-color);
    margin-bottom: 8px;
}

.error-msg {
    font-family: var(--font-mono);
    font-size: 12px;
    color: #991b1b;
    background: rgba(255, 255, 255, 0.7);
    padding: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(239, 68, 68, 0.1);
    margin-bottom: 16px;
    overflow-x: auto;
    max-height: 120px;
}

.retry-btn {
    background: #64748b;
    box-shadow: none;
}

.retry-btn:hover {
    background: #475569;
    box-shadow: none;
}

/* Animations */
.fade-in {
    animation: fadeIn 0.25s ease-out forwards;
}

/* 容器相对定位 */
.output-container {
    position: relative;
}

/* AI 转换半透明遮罩层 */
.converting-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(1px);
    -webkit-backdrop-filter: blur(1px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    z-index: 100;
    pointer-events: none;
    transition: all 0.3s ease;
}

.converting-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-color);
}

.panel-btn.success {
    background: var(--success-bg);
    color: var(--success-color);
    border-color: rgba(16, 185, 129, 0.2);
}

.panel-btn.warning {
    background: var(--warning-bg);
    color: var(--warning-color);
    border-color: var(--warning-border);
}

/* JSON 树形渲染样式 */
.json-tree-container {
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-code);
}

.json-nested-content {
    padding-left: 2ch;
}

.json-line {
    display: block;
}

.json-key {
    color: #881391;
}

.json-val-string {
    color: #22863a;
}

.json-val-number,
.json-val-boolean,
.json-val-null {
    color: #e36209;
    font-weight: 500;
}

/* 折叠切换按钮（精致圆角矩形） */
.json-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border: 1px solid #ef5350;
    border-radius: 4px;
    color: #ef5350;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    user-select: none;
    margin-right: 6px;
    vertical-align: middle;
    line-height: 1;
    background: #fff5f5;
    transition: all 0.2s ease;
}

.json-toggle-btn::before {
    content: "-";
}

/* 折叠状态样式 */
.json-toggle-btn.collapsed {
    border-color: #00bdcf;
    color: #00bdcf;
    background: #f0fdfa;
}

.json-toggle-btn.collapsed::before {
    content: "+";
}

/* 折叠隐藏逻辑 */
.json-item.collapsed > .json-nested-content {
    display: none;
}

/* 折叠时隐藏外层括号 */
.json-item.collapsed > .json-bracket {
    display: none;
}

.json-item.collapsed > .json-collapsed-placeholder {
    display: inline;
    color: #6b7280;
    font-size: 13px;
    padding: 0 4px;
    vertical-align: middle;
}

.json-item > .json-collapsed-placeholder {
    display: none;
}



