/*
  现代、干净风格；浅/暗色主题；响应式布局；树形组件、tooltip、toast、高亮样式
*/

:root {
  --bg: #ffffff;
  --fg: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #2563eb;
  --accent-fg: #ffffff;
  --card: #f8fafc;
  --danger: #ef4444;
  --highlight: #fde68a;
}

html[data-theme="dark"] {
  --bg: #0b0f1a;
  --fg: #e5e7eb;
  --muted: #9ca3af;
  --border: #1f2937;
  --accent: #3b82f6;
  --accent-fg: #0b0f1a;
  --card: #111827;
  --danger: #f87171;
  --highlight: #3b82f6;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, "Microsoft Yahei", "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--fg);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; gap: 8px; align-items: baseline; }
.app-name { font-weight: 700; }
.app-desc { color: var(--muted); font-size: 0.9rem; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; border: 1px solid var(--border);
  background: var(--bg); color: var(--fg); border-radius: 8px;
  cursor: pointer; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--card); }
.btn:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.05); }
.btn-secondary { background: var(--card); }
.icon { font-size: 1rem; }

.input {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  border-radius: 8px;
  padding: 8px 10px;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 12px;
  padding: 12px;
}

.panel { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.panel-title { margin: 0 0 8px; font-size: 1rem; }
.panel-actions { display: flex; gap: 8px; margin-top: 8px; }
.hint { margin-top: 8px; color: var(--muted); font-size: .9rem; }
.page-title { margin: 12px; font-size: 1.1rem; color: var(--muted); }

.json-input {
  width: 100%; min-height: 220px; resize: vertical;
  border-radius: 12px; padding: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.error-box { margin-top: 10px; border: 1px solid var(--danger); background: #fff5f5; color: #7f1d1d; border-radius: 8px; }
html[data-theme="dark"] .error-box { background: #1f1515; color: #fecaca; }
.error-title { font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--danger); }
#errorText { margin: 0; padding: 8px; white-space: pre-wrap; }

.pathbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.path-text { font-family: ui-monospace, monospace; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }

.tree { border: 1px solid var(--border); border-radius: 12px; padding: 8px; background: var(--bg); max-height: calc(100vh - 280px); overflow: auto; }
.tree .node { padding-left: 16px; position: relative; }
.tree .node .row { display: flex; align-items: center; gap: 8px; padding: 4px 2px; border-radius: 6px; }
.tree .node .row:hover { background: var(--card); }
.tree .caret { cursor: pointer; width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; border-radius: 4px; }
.tree .caret:hover { background: var(--card); }
.tree .key { color: var(--fg); font-weight: 600; }
.tree .sep { color: var(--muted); }
.tree .type { color: var(--muted); font-size: .85rem; }
.tree .value { font-family: ui-monospace, monospace; }
.tree .value.preview { color: var(--muted); }
.tree .choose { margin-left: auto; }
.tree .children { margin-left: 22px; border-left: 1px dashed var(--border); padding-left: 8px; }
.tree .collapsed > .children { display: none; }
.tree .highlight { background: var(--highlight); color: #111; }

.progress-hint { padding: 8px; border: 1px dashed var(--border); border-radius: 12px; margin-bottom: 8px; color: var(--muted); }

.toast { position: fixed; right: 16px; bottom: 16px; background: var(--accent); color: var(--accent-fg); padding: 10px 12px; border-radius: 10px; box-shadow: 0 4px 12px rgba(0,0,0,.2); }
.seo-text { margin: 12px; color: var(--muted); font-size: .95rem; }
.site-footer { margin: 16px; padding: 12px; border-top: 1px solid var(--border); color: var(--muted); text-align: center; }

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .tree { max-height: none; }
}

