:root {
    --primary: #4f6ef7;
    --primary-dark: #3c58d8;
    --bg: #f4f6fb;
    --card-bg: #ffffff;
    --text: #24292f;
    --text-muted: #6b7280;
    --border: #e3e7f0;
    --green: #22a06b;
    --red: #dc2626;
    --radius: 10px;
}

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

body {
    font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.hidden { display: none !important; }

/* ── 头部 ───────────────────────────────────────────── */
.app-header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.app-header h1 { font-size: 18px; font-weight: 600; }
.subtitle { font-size: 13px; color: var(--text-muted); font-weight: 400; margin-left: 6px; }

.header-right { display: flex; align-items: center; gap: 14px; }

.health { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #9ca3af; display: inline-block; }
.dot.ok { background: var(--green); box-shadow: 0 0 0 3px rgba(34, 160, 107, .15); }
.dot.bad { background: var(--red); box-shadow: 0 0 0 3px rgba(220, 38, 38, .12); }

.settings-panel {
    max-width: 960px;
    margin: 0 auto;
    padding: 12px 20px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 13px;
}
.settings-panel label { color: var(--text-muted); }
.settings-panel input {
    flex: 1;
    min-width: 260px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-family: Consolas, monospace;
}
.settings-tip { color: var(--text-muted); width: 100%; }

/* ── 主体 ───────────────────────────────────────────── */
.app-main {
    max-width: 960px;
    width: 100%;
    margin: 24px auto;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px;
}

.card h2 { font-size: 15px; margin-bottom: 14px; }

/* ── 上传区 ─────────────────────────────────────────── */
.dropzone {
    border: 2px dashed #c8d2ea;
    border-radius: var(--radius);
    padding: 28px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag-over {
    border-color: var(--primary);
    background: #f6f8ff;
}

.upload-icon { font-size: 30px; color: var(--primary); margin-bottom: 8px; }
.dropzone-hint p { font-size: 14px; color: var(--text); }
.dropzone-hint .supported { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

.file-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f6f8ff;
    border: 1px solid #d5ddfb;
    border-radius: 8px;
    padding: 12px 16px;
    text-align: left;
}
.file-icon { font-size: 24px; }
.file-meta { flex: 1; min-width: 0; }
.file-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.action-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.select-label { font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 8px; }
.select-label select {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
}

.status-bar { margin-top: 14px; font-size: 13px; padding: 9px 12px; border-radius: 6px; }
.status-bar.info { background: #eef2ff; color: #3730a3; }
.status-bar.success { background: #ecfdf5; color: var(--green); }
.status-bar.error { background: #fef2f2; color: var(--red); }

/* ── 按钮 ───────────────────────────────────────────── */
.btn {
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 13px;
    cursor: pointer;
    transition: background .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-ghost { background: transparent; color: var(--primary); border: 1px solid var(--border); }
.btn-ghost:hover { background: #f6f8ff; }
.btn-lg { padding: 9px 26px; font-size: 14px; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon {
    border: none; background: transparent; color: var(--text-muted);
    font-size: 14px; cursor: pointer; padding: 4px 6px; border-radius: 4px;
}
.btn-icon:hover { background: #e8ecf7; color: var(--red); }

/* ── 结果区 ─────────────────────────────────────────── */
.result-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.result-header h2 { margin-bottom: 0; }
.summary { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
    font-size: 12px;
    background: #f0f3fc;
    color: #43537a;
    border-radius: 999px;
    padding: 3px 10px;
}
.chip strong { font-weight: 600; }

.tabs {
    display: flex;
    align-items: center;
    gap: 6px;
    border-bottom: 1px solid var(--border);
    margin: 16px 0 14px;
    flex-wrap: wrap;
}
.tab {
    border: none;
    background: transparent;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.spacer { flex: 1; }
.tab-tools { display: flex; gap: 6px; }

.tree-panel { max-height: 560px; overflow: auto; }

/* ── 层级树 ─────────────────────────────────────────── */
.tree-item .node-children { margin-left: 18px; border-left: 1px solid var(--border); padding-left: 8px; }

.node-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 14px;
}
.node-row.clickable { cursor: pointer; }
.node-row.clickable:hover { background: #f4f6fd; }

.chevron { width: 14px; flex: none; color: var(--text-muted); font-size: 11px; }
.level-badge {
    flex: none;
    font-size: 11px;
    color: var(--primary);
    background: #eef1fe;
    border-radius: 4px;
    padding: 1px 6px;
}
.node-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-title.untitled { color: var(--text-muted); font-style: italic; }
.node-meta { flex: none; font-size: 11px; color: var(--text-muted); }

.node-detail { display: none; }
.tree-item.open > .node-detail { display: block; }

.node-content {
    margin: 4px 0 8px 30px;
    padding: 10px 12px;
    background: #fafbfe;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
    color: #374151;
    max-height: 260px;
    overflow: auto;
}

/* ── JSON 视图 ──────────────────────────────────────── */
#jsonView {
    background: #1e2430;
    color: #d7e0f0;
    border-radius: 8px;
    padding: 16px;
    font-size: 12px;
    line-height: 1.6;
    max-height: 560px;
    overflow: auto;
    white-space: pre;
}

/* ── 页脚 ───────────────────────────────────────────── */
.app-footer {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    padding: 18px 0 26px;
}

@media (max-width: 640px) {
    .card { padding: 16px; }
    .action-row { flex-direction: column; align-items: stretch; }
    .btn-lg { width: 100%; }
}
