/* JSON 可视化编辑器 - 借鉴 YouMind 的内容库式产品工具风格 */

:root {
    --navy: #17213a;
    --blue: #446ee7;
    --blue-hover: #365ed1;
    --light-blue: #edf3ff;
    --green: #18a66a;
    --light-green: #eaf8f1;
    --purple: #8a5cf6;
    --light-purple: #f2efff;
    --orange: #d99021;
    --light-orange: #fff4df;
    --red: #e85d56;
    --light-red: #fff0ef;
    --teal: #159a9c;
    --light-teal: #e7f7f7;
    --card: #ffffff;
    --card-soft: #f8fafc;
    --border: #e2e6ef;
    --background: #f4f7fb;
    --text-primary: #18202d;
    --text-secondary: #566172;
    --text-muted: #8d97a8;
    --shadow-card: 0 1px 2px rgba(23,33,58,0.05), 0 8px 24px rgba(23,33,58,0.05);
    --shadow-card-hover: 0 2px 8px rgba(23,33,58,0.08), 0 14px 34px rgba(23,33,58,0.07);
    --shadow-modal: 0 18px 50px rgba(23,33,58,0.18);
    --shadow-btn: 0 1px 2px rgba(23,33,58,0.06);
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 8px;
    --radius-xl: 8px;
    --radius-full: 9999px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --font-sans: 'Avenir Next', 'Noto Sans SC', 'PingFang SC', 'Helvetica Neue', sans-serif;
    --font-mono: 'SF Mono', 'Menlo', 'Cascadia Code', 'Courier New', monospace;
}

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

body {
    font-family: var(--font-sans);
    background: var(--background);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== 背景纹理 - YouMind风格的微妙几何点阵 ===== */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.45), rgba(255,255,255,0.15)),
        radial-gradient(circle, rgba(23,33,58,0.045) 1px, transparent 1px);
    background-size: auto, 22px 22px;
    pointer-events: none;
    z-index: 0;
}

/* ===== Navbar - YouMind风格顶栏 ===== */
.navbar {
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-inner {
    max-width: 1320px;
    margin: 0 auto;
    padding: 0 32px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--blue) 0%, var(--purple) 100%);
    color: white;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0;
    box-shadow: 0 2px 8px rgba(68,110,231,0.28);
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--navy);
    line-height: 1.2;
    letter-spacing: 0;
}

.brand-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.2px;
}

.nav-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 8px;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ===== Buttons - YouMind风格按钮 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 14px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-sans);
    transition: var(--transition);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn svg { flex-shrink: 0; }

.btn-primary {
    background: var(--blue);
    color: white;
    box-shadow: var(--shadow-btn), 0 2px 6px rgba(91,143,249,0.2);
}
.btn-primary:hover {
    background: var(--blue-hover);
    box-shadow: var(--shadow-btn), 0 4px 12px rgba(91,143,249,0.3);
    transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

.btn-outline {
    background: var(--card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-btn);
}
.btn-outline:hover {
    background: var(--light-blue);
    border-color: var(--blue);
    color: var(--blue);
}

.btn-danger-outline {
    background: var(--card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-btn);
}
.btn-danger-outline:hover {
    background: var(--light-red);
    border-color: var(--red);
    color: var(--red);
}

.btn-sm { padding: 5px 10px; font-size: 12px; }

.btn-icon {
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-xs);
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-btn);
}
.btn-icon:hover {
    color: var(--red);
    background: var(--light-red);
    border-color: var(--red);
    transform: translateY(-1px);
}
.btn-icon.btn-icon-blue:hover {
    color: var(--blue);
    background: var(--light-blue);
    border-color: var(--blue);
}

/* ===== Main Layout ===== */
.main-layout {
    max-width: 1440px;
    margin: 0 auto;
    padding: 24px 32px;
    display: grid;
    grid-template-columns: 260px 1fr 360px;
    gap: 20px;
    min-height: calc(100vh - 60px);
    position: relative;
    z-index: 1;
}

@media (max-width: 1200px) {
    .main-layout {
        grid-template-columns: 220px 1fr;
    }
    .preview-section {
        grid-column: 1 / -1;
        position: static;
        max-height: none;
    }
    .json-preview { max-height: 320px; }
    .version-list { max-height: 240px; }
}

@media (max-width: 1024px) {
    .main-layout {
        grid-template-columns: 1fr;
        padding: 16px;
    }
    .tree-section { display: none; }
}

/* ===== Section Header ===== */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    gap: 12px;
}

.section-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--navy);
    letter-spacing: 0;
    white-space: nowrap;
}

.file-pill {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    max-width: 320px;
    padding: 4px 9px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: rgba(255,255,255,0.72);
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== View Toggle - YouMind风格切换 ===== */
.view-toggle {
    display: inline-flex;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px;
    box-shadow: var(--shadow-btn);
}

.toggle-btn {
    padding: 5px 10px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
    display: flex;
    align-items: center;
    border-radius: var(--radius-xs);
}
.toggle-btn:hover { color: var(--blue); }
.toggle-btn.active {
    background: var(--light-blue);
    color: var(--blue);
    box-shadow: var(--shadow-btn);
}

/* ===== Cards - YouMind风格卡片 ===== */
.editor-card, .preview-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    transition: var(--transition);
}

.editor-card {
    min-height: 500px;
}

/* ===== Editor ===== */
.json-editor {
    padding: 20px;
    min-height: 500px;
}

.code-editor {
    display: flex;
    flex-direction: column;
    min-height: 500px;
}

.code-textarea {
    flex: 1;
    width: 100%;
    padding: 20px;
    border: none;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.7;
    resize: none;
    outline: none;
    color: var(--text-primary);
    background: #fafbfc;
}

.code-actions {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: var(--card);
    justify-content: flex-end;
}

/* ===== Empty State - YouMind风格空状态 ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    text-align: center;
    padding: 48px 24px;
}

.empty-icon {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, var(--light-blue) 0%, #f0eeff 100%);
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    box-shadow: 0 4px 16px rgba(91,143,249,0.1);
}

.empty-state h3 {
    font-size: 17px;
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 6px;
    letter-spacing: 0;
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 13px;
    max-width: 280px;
    margin-bottom: 24px;
    line-height: 1.5;
}

.empty-actions {
    display: flex;
    gap: 10px;
}

/* ===== Inline JSON Editor - 内联树编辑样式 ===== */
.inline-editor {
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.7;
    padding: 16px 20px;
    color: var(--text-primary);
    min-height: 500px;
}

.inline-row {
    display: flex;
    align-items: baseline;
    padding: 2px 4px;
    border-radius: var(--radius-xs);
    transition: background 0.15s ease;
    position: relative;
    min-height: 24px;
}

.inline-row:hover {
    background: rgba(91, 143, 249, 0.04);
}

.inline-row:hover .inline-actions {
    opacity: 1;
}

.inline-arrow {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: transform 0.15s ease, color 0.15s ease;
    margin-right: 2px;
    user-select: none;
}

.inline-arrow:hover {
    color: var(--blue);
}

.inline-arrow.expanded {
    transform: rotate(90deg);
}

.inline-arrow-placeholder {
    width: 16px;
    flex-shrink: 0;
    margin-right: 2px;
}

.inline-key {
    color: var(--purple);
    font-weight: 500;
    white-space: nowrap;
    cursor: default;
    flex-shrink: 0;
}

.inline-key .key-text {
    cursor: text;
    padding: 0 2px;
    border-radius: 2px;
    transition: background 0.15s ease;
}

.inline-key .key-text:hover {
    background: rgba(140, 124, 243, 0.1);
}

.inline-key .key-input {
    background: white;
    border: 1px solid var(--blue);
    border-radius: 3px;
    padding: 0 4px;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--purple);
    font-weight: 500;
    outline: none;
    box-shadow: 0 0 0 3px rgba(91, 143, 249, 0.1);
    min-width: 40px;
}

.inline-colon {
    color: var(--text-muted);
    margin-right: 6px;
    flex-shrink: 0;
}

.inline-value {
    cursor: pointer;
    padding: 0 3px;
    border-radius: 2px;
    transition: background 0.15s ease;
    flex: 1;
    min-width: 0;
    word-break: break-all;
}

.inline-value:hover {
    background: rgba(91, 143, 249, 0.08);
}

.inline-value.type-string { color: #3da65c; }
.inline-value.type-number { color: #c8860d; }
.inline-value.type-boolean { color: var(--purple); }
.inline-value.type-null { color: #9ba7b4; font-style: italic; }
.inline-value.type-object { color: var(--blue); }
.inline-value.type-array { color: var(--blue); }

.inline-value-edit {
    font-family: var(--font-mono);
    font-size: 13px;
    border: 1px solid var(--blue);
    border-radius: 3px;
    padding: 1px 6px;
    outline: none;
    background: white;
    color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(91, 143, 249, 0.1);
    min-width: 60px;
    max-width: 100%;
}

.inline-value-edit[type="number"] {
    width: 100px;
}

.inline-bracket {
    color: var(--text-muted);
    font-weight: 500;
}

.inline-actions {
    display: flex;
    gap: 2px;
    margin-left: auto;
    opacity: 0.54;
    transition: opacity 0.15s ease;
    flex-shrink: 0;
}

.inline-action-btn {
    width: 22px;
    height: 22px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-xs);
    transition: var(--transition);
}

.inline-action-btn:hover {
    color: var(--red);
    background: var(--light-red);
}

.inline-action-btn.btn-add:hover {
    color: var(--green);
    background: var(--light-green);
}

.inline-children {
    padding-left: 24px;
    border-left: 2px solid var(--border);
    margin-left: 8px;
}

/* 层级颜色区分 - 6色循环 */
.inline-children[data-depth="0"] { border-left-color: #e8ebf2; }
.inline-children[data-depth="1"] { border-left-color: var(--blue); }
.inline-children[data-depth="2"] { border-left-color: var(--green); }
.inline-children[data-depth="3"] { border-left-color: var(--purple); }
.inline-children[data-depth="4"] { border-left-color: var(--orange); }
.inline-children[data-depth="5"] { border-left-color: var(--red); }
.inline-children[data-depth="6"] { border-left-color: #3da65c; }
.inline-children[data-depth="7"] { border-left-color: #c8860d; }

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

.inline-closing {
    color: var(--text-muted);
    font-weight: 500;
    padding-left: 24px;
    padding: 2px 4px;
    border-radius: var(--radius-xs);
}

.inline-add-row {
    padding: 2px 4px;
    margin-top: 2px;
}

.inline-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border: 1px dashed transparent;
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-family: var(--font-mono);
    cursor: pointer;
    transition: var(--transition);
}

.inline-add-btn:hover {
    color: var(--blue);
    border-color: var(--blue);
    background: var(--light-blue);
}

.inline-count {
    color: var(--text-muted);
    font-size: 11px;
    margin-left: 4px;
}

/* ===== Preview - YouMind风格预览 ===== */
.preview-section {
    position: sticky;
    top: 72px;
    align-self: start;
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-height: calc(100vh - 96px);
}

.preview-card {
    min-height: 0;
}

.preview-card-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
}

.preview-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.json-preview {
    padding: 16px;
    margin: 0;
    font-family: var(--font-mono);
    font-size: 11.5px;
    line-height: 1.7;
    color: var(--text-primary);
    background: #fcfbf8;
    max-height: 42vh;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

.json-preview code {
    font-family: inherit;
}

/* JSON 语法着色 */
.json-key { color: var(--blue); font-weight: 500; }
.json-string { color: #3da65c; }
.json-number { color: #c8860d; }
.json-boolean { color: var(--purple); }
.json-null { color: #9ba7b4; font-style: italic; }

/* ===== Version History ===== */
.version-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.version-card-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: white;
}

.storage-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    background: var(--light-orange);
    color: var(--orange);
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.storage-badge[data-mode="directory"] {
    background: var(--light-green);
    color: var(--green);
}

.storage-badge[data-mode="warning"] {
    background: var(--light-red);
    color: var(--red);
}

.version-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 12px 14px 10px;
}

.version-filter {
    display: flex;
    gap: 6px;
    padding: 0 14px 10px;
}

.filter-chip {
    height: 28px;
    padding: 0 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: #fff;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.filter-chip:hover {
    border-color: var(--blue);
    color: var(--blue);
    background: var(--light-blue);
}

.filter-chip.active {
    border-color: rgba(68,110,231,0.22);
    background: var(--light-blue);
    color: var(--blue);
}

.version-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 14px 14px;
    max-height: 280px;
    overflow-y: auto;
}

.version-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 86px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
    background: var(--card-soft);
    color: var(--text-muted);
    font-size: 12px;
}

.version-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: #fff;
    transition: var(--transition);
}

.version-item:hover {
    border-color: rgba(68,110,231,0.28);
    box-shadow: var(--shadow-card-hover);
}

.version-item-body {
    min-width: 0;
}

.version-item-title {
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.version-item-file {
    margin-top: 2px;
    color: var(--text-secondary);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.version-item-meta {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.35;
}

.version-restore-btn {
    height: 30px;
    padding: 0 10px;
    border: 1px solid rgba(68,110,231,0.22);
    border-radius: var(--radius-sm);
    background: var(--light-blue);
    color: var(--blue);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.version-restore-btn:hover {
    background: var(--blue);
    color: #fff;
}

/* ===== Toast - YouMind风格通知 ===== */
.toast-container {
    position: fixed;
    top: 72px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    background: var(--card);
    box-shadow: var(--shadow-modal);
    border: 1px solid var(--border);
    font-size: 13px;
    animation: toastSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 340px;
}

.toast.toast-success { border-left: 3px solid var(--green); }
.toast.toast-error { border-left: 3px solid var(--red); }
.toast.toast-info { border-left: 3px solid var(--blue); }

.toast-icon {
    width: 22px;
    height: 22px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

.toast-success .toast-icon { background: var(--light-green); color: var(--green); }
.toast-error .toast-icon { background: var(--light-red); color: var(--red); }
.toast-info .toast-icon { background: var(--light-blue); color: var(--blue); }

.toast.leaving { animation: toastSlideOut 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards; }

@keyframes toastSlideIn {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes toastSlideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(120%); opacity: 0; }
}

/* ===== Modal - YouMind风格模态框 ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20,38,74,0.3);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.15s ease;
}

.modal-card {
    background: var(--card);
    border-radius: var(--radius-xl);
    padding: 28px;
    width: 90%;
    max-width: 400px;
    box-shadow: var(--shadow-modal);
    animation: modalPop 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid var(--border);
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 20px;
    letter-spacing: 0;
}

.modal-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    letter-spacing: 0.2px;
}

.modal-input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: var(--font-sans);
    color: var(--text-primary);
    outline: none;
    margin-bottom: 16px;
    transition: var(--transition);
    background: #fafbfc;
}

.modal-input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(91,143,249,0.1);
    background: white;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 4px;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalPop {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* ===== Utility ===== */
.hidden { display: none !important; }

/* ===== Scrollbar - YouMind风格滚动条 ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d5dae6; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #bcc3d0; }

/* ===== Tree Panel - 结构树 ===== */
.tree-section {
    position: relative;
}

.tree-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    position: sticky;
    top: 72px;
    max-height: calc(100vh - 96px);
    display: flex;
    flex-direction: column;
}

.tree-header {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
    flex-shrink: 0;
}

.tree-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.tree-header-actions {
    display: flex;
    gap: 2px;
}

.tree-header-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-xs);
    transition: var(--transition);
}

.tree-header-btn:hover {
    color: var(--blue);
    background: var(--light-blue);
}

.json-tree {
    padding: 8px 6px;
    overflow-y: auto;
    flex: 1;
    min-height: 200px;
}

.tree-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    text-align: center;
    gap: 10px;
}

.tree-empty p {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Tree node */
.tree-node {
    user-select: none;
}

.tree-node-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 6px;
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-node-row:hover {
    background: var(--light-blue);
}

.tree-node-row.active {
    background: var(--light-blue);
    color: var(--blue);
}

.tree-arrow {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s ease;
    color: var(--text-muted);
}

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

.tree-arrow-placeholder {
    width: 16px;
    flex-shrink: 0;
}

.tree-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tree-key-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-type-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-left: auto;
}

.tree-type-dot.type-string { background: var(--blue); }
.tree-type-dot.type-number { background: var(--orange); }
.tree-type-dot.type-boolean { background: var(--purple); }
.tree-type-dot.type-object { background: var(--green); }
.tree-type-dot.type-array { background: var(--red); }
.tree-type-dot.type-null { background: var(--text-muted); }

.tree-value-preview {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: 2px;
    max-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--font-mono);
}

.tree-children {
    padding-left: 14px;
    border-left: 1px solid var(--border);
    margin-left: 13px;
}

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

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .navbar-inner { padding: 0 16px; height: 52px; }
    .brand-title { font-size: 14px; }
    .brand-subtitle { display: none; }
    .nav-divider { display: none; }
    .nav-actions { gap: 4px; }
    .btn { padding: 6px 10px; font-size: 12px; }
    .btn span.btn-text { display: none; }
    .main-layout { padding: 12px; gap: 12px; }
    .json-editor { padding: 12px; }
    .json-preview { padding: 12px; font-size: 10.5px; }
    .inline-editor { padding: 12px; }
    .inline-row { font-size: 12px; }
    .inline-children { padding-left: 16px; }
    .section-header { align-items: flex-start; flex-direction: column; }
    .file-pill { max-width: 100%; }
    .version-actions { grid-template-columns: 1fr; }
}

/* ===== YouMind Neo-Brutalist Visual Pass ===== */
:root {
    --navy: #000000;
    --blue: #10A37F;
    --blue-hover: #0C8C6D;
    --light-blue: #DDF7EF;
    --green: #10A37F;
    --light-green: #DDF7EF;
    --purple: #7D4DFF;
    --light-purple: #EFE8FF;
    --orange: #B47A00;
    --light-orange: #FFE66D;
    --red: #E43D30;
    --light-red: #FFE5E1;
    --teal: #0A7F70;
    --light-teal: #DDF7EF;
    --yellow: #FFE66D;
    --card: #FFFFFF;
    --card-soft: #F8F9FA;
    --border: #000000;
    --background: #F0F0F0;
    --text-primary: #000000;
    --text-secondary: #1F1F1F;
    --text-muted: #5B5B5B;
    --shadow-card: 6px 6px 0 #000000;
    --shadow-card-hover: 8px 8px 0 #000000;
    --shadow-modal: 8px 8px 0 #000000;
    --shadow-btn: 3px 3px 0 #000000;
    --radius-xs: 0;
    --radius-sm: 0;
    --radius-md: 0;
    --radius-lg: 0;
    --radius-xl: 0;
    --radius-full: 9999px;
    --transition: all 0.16s ease;
}

* {
    letter-spacing: 0;
}

body {
    background: var(--background);
    color: #000;
}

body::before {
    display: none;
}

.navbar {
    background: #10A37F;
    border-bottom: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.navbar-inner {
    max-width: 1200px;
    height: auto;
    min-height: 64px;
    padding: 12px 24px;
}

.brand {
    min-height: 36px;
    padding: 7px 11px;
    background: #fff;
    border: 2px solid #000;
    box-shadow: 3px 3px 0 #000;
    color: #000;
    transition: var(--transition);
}

.brand:hover {
    transform: translate(1px, 1px);
    box-shadow: 2px 2px 0 #000;
}

.brand-icon {
    width: auto;
    height: auto;
    min-width: 32px;
    padding: 2px 5px;
    background: #000;
    color: #fff;
    border: 2px solid #000;
    border-radius: 0;
    box-shadow: none;
    font-weight: 900;
}

.brand-title {
    color: #000;
    font-size: 15px;
    font-weight: 900;
    text-transform: uppercase;
}

.brand-subtitle {
    color: #000;
    font-size: 10px;
    font-weight: 800;
}

.nav-divider {
    display: none;
}

.nav-actions {
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.btn,
.btn-icon,
.tree-header-btn,
.inline-action-btn,
.inline-add-btn,
.toggle-btn,
.filter-chip,
.version-restore-btn {
    border-radius: 0;
}

.btn {
    min-height: 34px;
    padding: 7px 12px;
    border: 2px solid #000;
    background: #fff;
    color: #000;
    box-shadow: 3px 3px 0 #000;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    overflow: visible;
}

.btn:hover {
    transform: translate(1px, 1px);
    box-shadow: 2px 2px 0 #000;
}

.btn:active {
    transform: translate(3px, 3px);
    box-shadow: none;
}

.btn-primary {
    background: #10A37F;
    color: #fff;
    border-color: #000;
    box-shadow: 3px 3px 0 #000;
}

.btn-primary:hover {
    background: #000;
    color: #fff;
    box-shadow: 2px 2px 0 #000;
}

.btn-outline,
.btn-danger-outline {
    background: #fff;
    color: #000;
    border-color: #000;
    box-shadow: 3px 3px 0 #000;
}

.btn-outline:hover {
    background: #FFE66D;
    color: #000;
    border-color: #000;
}

.btn-danger-outline:hover {
    background: #E43D30;
    color: #fff;
    border-color: #000;
}

.btn-sm {
    min-height: 30px;
    padding: 5px 9px;
    font-size: 11px;
}

.hero-section {
    position: relative;
    z-index: 1;
    background: #10A37F;
    border-bottom: 4px solid #000;
}

.hero-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 34px 24px 40px;
    text-align: center;
}

.hero-kicker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 6px 12px;
    background: #fff;
    border: 2px solid #000;
    box-shadow: 3px 3px 0 #000;
    color: #000;
    font-size: 12px;
    font-weight: 900;
}

.hero-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 16px 0 0;
    color: #fff;
    font-size: clamp(46px, 9vw, 112px);
    font-weight: 900;
    line-height: 0.92;
    text-transform: uppercase;
    text-shadow: 5px 5px 0 #000;
}

.hero-title-label {
    display: inline-block;
    margin-top: 10px;
    padding: 8px 18px 12px;
    background: #fff;
    border: 4px solid #000;
    color: #000;
    box-shadow: 5px 5px 0 #000;
    text-shadow: none;
}

.hero-copy {
    margin: 18px auto 0;
    max-width: 620px;
    color: #fff;
    font-size: 15px;
    font-weight: 900;
    line-height: 1.6;
    text-shadow: 2px 2px 0 #000;
}

.hero-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 22px;
}

.hero-chip {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 5px 12px;
    background: rgba(255,255,255,0.92);
    border: 1px solid #000;
    border-radius: 9999px;
    box-shadow: 2px 2px 0 #000;
    color: #000;
    font-size: 12px;
    font-weight: 900;
}

.hero-chip.active {
    background: #FFE66D;
    border-width: 2px;
}

.main-layout {
    width: min(100% - 48px, 1560px);
    max-width: none;
    padding: 28px 0 40px;
    grid-template-columns: 230px minmax(560px, 1fr) minmax(380px, 440px);
    gap: 28px;
    min-height: auto;
}

.editor-section,
.preview-section {
    min-width: 0;
}

.section-header {
    margin-bottom: 12px;
}

.section-title {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 5px 11px;
    background: #fff;
    border: 2px solid #000;
    box-shadow: 3px 3px 0 #000;
    color: #000;
    font-size: 18px;
    font-weight: 900;
    text-transform: uppercase;
}

.file-pill,
.storage-badge {
    border: 2px solid #000;
    border-radius: 9999px;
    background: #FFE66D;
    color: #000;
    font-weight: 900;
}

.storage-badge[data-mode="directory"] {
    background: #10A37F;
    color: #fff;
}

.storage-badge[data-mode="warning"] {
    background: #E43D30;
    color: #fff;
}

.view-toggle {
    gap: 4px;
    padding: 4px;
    background: #fff;
    border: 2px solid #000;
    border-radius: 0;
    box-shadow: 3px 3px 0 #000;
}

.toggle-btn {
    border: 2px solid transparent;
    color: #000;
}

.toggle-btn:hover {
    background: #FFE66D;
    color: #000;
}

.toggle-btn.active {
    background: #000;
    color: #fff;
    border-color: #000;
    box-shadow: none;
}

.editor-card,
.preview-card,
.version-card,
.tree-card {
    position: relative;
    overflow: visible;
    background: #fff;
    border: 4px solid #000;
    border-radius: 0;
    box-shadow: 6px 6px 0 #000;
    transition: var(--transition);
}

.editor-card:hover,
.preview-card:hover,
.version-card:hover,
.tree-card:hover {
    transform: translate(-1px, -1px);
    box-shadow: 7px 7px 0 #000;
}

.editor-card::before,
.version-card::before,
.preview-card::before {
    position: absolute;
    z-index: 3;
    top: -15px;
    right: 14px;
    padding: 4px 9px;
    background: #FFE66D;
    border: 2px solid #000;
    color: #000;
    box-shadow: 2px 2px 0 #000;
    font-size: 11px;
    font-weight: 900;
    transform: rotate(2deg);
}

.editor-card::before {
    content: "编辑";
}

.preview-card::before {
    content: "预览";
}

.version-card::before {
    content: "本地";
}

.tree-card {
    top: 88px;
    max-height: calc(100vh - 112px);
}

.preview-section {
    top: 88px;
    gap: 22px;
    min-width: 380px;
    max-height: calc(100vh - 112px);
}

.tree-header,
.preview-card-header,
.version-card-header {
    padding: 12px 14px;
    background: #000;
    border-bottom: 4px solid #000;
}

.tree-label,
.preview-label {
    color: #fff;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.preview-card-header .btn,
.version-card-header .storage-badge {
    box-shadow: 2px 2px 0 #000;
}

.tree-header-btn {
    width: 28px;
    height: 28px;
    background: #fff;
    border: 2px solid #000;
    color: #000;
    box-shadow: 2px 2px 0 #000;
}

.tree-header-btn:hover {
    background: #FFE66D;
    color: #000;
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0 #000;
}

.json-editor,
.inline-editor {
    background: #fff;
}

.code-textarea,
.json-preview {
    background: #F8F9FA;
    color: #000;
}

.code-actions {
    background: #fff;
    border-top: 4px solid #000;
}

.empty-state {
    min-height: 420px;
}

.empty-icon {
    background: #FFE66D;
    border: 4px solid #000;
    border-radius: 0;
    box-shadow: 5px 5px 0 #000;
}

.empty-state h3 {
    color: #000;
    font-size: 24px;
    font-weight: 900;
    text-transform: uppercase;
}

.empty-state p {
    color: #1F1F1F;
    font-weight: 800;
}

.inline-row {
    border-radius: 0;
    border: 1px solid transparent;
}

.inline-row:hover {
    background: #FFF7B3;
    border-color: #000;
}

.inline-key {
    color: #000;
    font-weight: 900;
}

.inline-key .key-text:hover,
.inline-value:hover {
    background: #FFE66D;
}

.inline-key .key-input,
.inline-value-edit,
.modal-input {
    border: 2px solid #000;
    border-radius: 0;
    box-shadow: 3px 3px 0 #000;
}

.inline-key .key-input:focus,
.inline-value-edit:focus,
.modal-input:focus {
    border-color: #000;
    box-shadow: 3px 3px 0 #10A37F;
}

.inline-actions {
    opacity: 0.64;
}

.inline-action-btn {
    width: 24px;
    height: 24px;
    border: 1px solid #000;
    background: #fff;
    color: #000;
}

.inline-action-btn:hover,
.inline-action-btn.btn-add:hover {
    background: #FFE66D;
    color: #000;
}

.inline-children {
    border-left: 3px solid #000;
}

.inline-children[data-depth="1"] { border-left-color: #10A37F; }
.inline-children[data-depth="2"] { border-left-color: #FFE66D; }
.inline-children[data-depth="3"] { border-left-color: #7D4DFF; }
.inline-children[data-depth="4"] { border-left-color: #E43D30; }
.inline-children[data-depth="5"] { border-left-color: #000000; }
.inline-children[data-depth="6"] { border-left-color: #10A37F; }
.inline-children[data-depth="7"] { border-left-color: #FFE66D; }

.inline-add-btn {
    border: 2px dashed #000;
    background: #fff;
    color: #000;
    font-weight: 900;
}

.inline-add-btn:hover {
    background: #FFE66D;
    color: #000;
    border-color: #000;
}

.json-key { color: #000; font-weight: 900; }
.json-string { color: #0A7F70; font-weight: 700; }
.json-number { color: #B47A00; font-weight: 700; }
.json-boolean { color: #7D4DFF; font-weight: 700; }
.json-null { color: #5B5B5B; font-weight: 700; }

.version-actions {
    padding: 14px 14px 12px;
}

.version-filter {
    padding: 0 14px 12px;
}

.filter-chip {
    height: 30px;
    border: 2px solid #000;
    background: #fff;
    color: #000;
    box-shadow: 2px 2px 0 #000;
    font-weight: 900;
}

.filter-chip:hover,
.filter-chip.active {
    background: #FFE66D;
    color: #000;
    border-color: #000;
}

.version-empty {
    min-height: 90px;
    border: 2px dashed #000;
    border-radius: 0;
    background: #F8F9FA;
    color: #000;
    font-weight: 900;
}

.version-item {
    border: 2px solid #000;
    border-radius: 0;
    background: #fff;
    box-shadow: 3px 3px 0 #000;
}

.version-item:hover {
    border-color: #000;
    background: #FFFDF0;
    box-shadow: 4px 4px 0 #000;
}

.version-item-title {
    color: #000;
    font-weight: 900;
}

.version-item-file,
.version-item-meta {
    color: #333;
    font-weight: 700;
}

.version-restore-btn {
    border: 2px solid #000;
    background: #10A37F;
    color: #fff;
    box-shadow: 2px 2px 0 #000;
    font-weight: 900;
}

.version-restore-btn:hover {
    background: #000;
    color: #fff;
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0 #000;
}

.tree-node-row {
    border-radius: 0;
    border: 1px solid transparent;
}

.tree-node-row:hover,
.tree-node-row.active {
    background: #FFE66D;
    color: #000;
    border-color: #000;
}

.tree-key-name {
    color: #000;
    font-weight: 800;
}

.tree-value-preview {
    color: #333;
}

.tree-children {
    border-left: 2px solid #000;
}

.tree-type-dot {
    width: 8px;
    height: 8px;
    border: 1px solid #000;
}

.toast {
    border: 3px solid #000;
    border-radius: 0;
    box-shadow: 5px 5px 0 #000;
    color: #000;
    font-weight: 800;
}

.toast.toast-success,
.toast.toast-error,
.toast.toast-info {
    border-left-width: 8px;
}

.toast-success .toast-icon,
.toast-error .toast-icon,
.toast-info .toast-icon {
    background: #FFE66D;
    color: #000;
    border: 2px solid #000;
}

.modal-overlay {
    background: rgba(0, 0, 0, 0.46);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.modal-card {
    border: 4px solid #000;
    border-radius: 0;
    box-shadow: 8px 8px 0 #000;
}

.modal-title {
    display: inline-flex;
    padding: 4px 10px;
    background: #FFE66D;
    border: 2px solid #000;
    color: #000;
    box-shadow: 3px 3px 0 #000;
    font-size: 18px;
    font-weight: 900;
}

.modal-label {
    color: #000;
    font-weight: 900;
}

::-webkit-scrollbar {
    width: 9px;
    height: 9px;
}

::-webkit-scrollbar-thumb {
    background: #000;
    border: 2px solid #F0F0F0;
    border-radius: 0;
}

@media (max-width: 1320px) {
    .main-layout {
        grid-template-columns: 220px minmax(0, 1fr);
    }

    .preview-section {
        grid-column: 1 / -1;
        position: static;
        min-width: 0;
        max-height: none;
    }
}

@media (max-width: 1024px) {
    .main-layout {
        width: min(100% - 36px, 1560px);
        grid-template-columns: 1fr;
        padding: 22px 0 34px;
    }

    .tree-section {
        display: none;
    }
}

@media (max-width: 768px) {
    .navbar-inner {
        min-height: 58px;
        padding: 10px 12px;
        align-items: flex-start;
    }

    .brand {
        padding: 6px 8px;
    }

    .brand-icon {
        min-width: 28px;
        font-size: 12px;
    }

    .nav-actions {
        gap: 6px;
    }

    .btn {
        min-height: 32px;
        padding: 6px 9px;
        font-size: 11px;
    }

    .hero-inner {
        padding: 26px 16px 32px;
    }

    .hero-title {
        font-size: clamp(42px, 15vw, 72px);
        text-shadow: 4px 4px 0 #000;
    }

    .hero-title-label {
        padding: 7px 12px 10px;
        border-width: 3px;
        box-shadow: 4px 4px 0 #000;
    }

    .hero-copy {
        font-size: 13px;
    }

    .main-layout {
        width: min(100% - 24px, 1560px);
        padding: 18px 0 28px;
        gap: 18px;
    }

    .section-header {
        align-items: stretch;
    }

    .section-title-group {
        flex-direction: column;
        align-items: flex-start;
    }

    .editor-card,
    .preview-card,
    .version-card {
        box-shadow: 5px 5px 0 #000;
    }

    .editor-card::before,
    .preview-card::before,
    .version-card::before {
        right: 10px;
    }
}
