/* ============================================================
   ZenithProxy 配置中心 · v5 层级树版
   按 config.json 原始层级递归渲染 · 父开关折叠 · 深/浅双主题
   ============================================================ */
:root {
  --mono: "Cascadia Mono", Consolas, "JetBrains Mono", monospace;
  --sans: "Segoe UI Variable Text", "HarmonyOS Sans SC", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
}
html[data-theme="dark"] {
  --bg: oklch(17% 0.015 285); --bg2: oklch(20% 0.015 285); --panel: oklch(22% 0.015 285); --panel2: oklch(25% 0.015 285);
  --text: oklch(93% 0.005 285); --text-dim: oklch(70% 0.01 285); --text-faint: oklch(52% 0.01 285);
  --border: oklch(32% 0.02 285); --border-soft: oklch(26% 0.02 285);
  --accent: oklch(70% 0.15 285); --accent-soft: oklch(70% 0.15 285 / 14%);
  --accent-dim: oklch(64% 0.13 285 / 78%);
  --warn: oklch(78% 0.13 80); --ok: oklch(72% 0.14 150); --err: oklch(65% 0.18 25);
  --input: oklch(15% 0.015 285);
}
html[data-theme="light"] {
  --bg: oklch(97.5% 0.005 285); --bg2: oklch(95% 0.005 285); --panel: oklch(99% 0.002 285); --panel2: oklch(94% 0.008 285);
  --text: oklch(25% 0.02 285); --text-dim: oklch(45% 0.02 285); --text-faint: oklch(58% 0.015 285);
  --border: oklch(86% 0.015 285); --border-soft: oklch(91% 0.01 285);
  --accent: oklch(55% 0.19 285); --accent-soft: oklch(55% 0.19 285 / 13%);
  --accent-dim: oklch(50% 0.17 285 / 80%);
  --warn: oklch(55% 0.12 80); --ok: oklch(48% 0.12 150); --err: oklch(50% 0.18 25);
  --input: oklch(100% 0 0);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg); color: var(--text);
  font-family: var(--sans); font-size: 14px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-soft); }
.mono, code, .fkey, .badge, .sec-no, .nav-no, .node-path, .json-bar, .statusbar, .st-num {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
}
button { font-family: inherit; cursor: pointer; }

/* ============ 顶栏 ============ */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 12px;
  padding: 9px 20px;
  background: color-mix(in oklab, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark {
  font-family: var(--mono); font-weight: 700; font-size: 14px;
  width: 36px; height: 36px; display: grid; place-items: center;
  background: var(--accent); color: oklch(96% 0.01 285);
  border-radius: 3px; letter-spacing: .5px;
}
.brand h1 { font-size: 15px; font-weight: 650; white-space: nowrap; }
.brand-sub { font-family: var(--mono); font-size: 10px; color: var(--accent-dim); letter-spacing: .14em; text-transform: uppercase; }
.top-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.btn {
  font-size: 13px; padding: 6px 12px; border-radius: 5px;
  background: var(--panel2); color: var(--text); border: 1px solid var(--border);
  transition: all .18s ease;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: oklch(96% 0.01 285); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); color: oklch(96% 0.01 285); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-dim); font-size: 16px; padding: 5px 8px; }
.btn.ghost:hover { color: var(--accent); border-color: var(--border); }
.btn:focus-visible, .btn.ghost:focus-visible, .nav-item:focus-visible, .node-head:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}

/* ============ 布局 ============ */
.layout { display: flex; max-width: 1320px; margin: 0 auto; min-height: calc(100vh - 96px); }
.sidenav {
  width: 250px; flex-shrink: 0; padding: 16px 10px 24px;
  position: sticky; top: 55px; align-self: flex-start; max-height: calc(100vh - 55px); overflow-y: auto;
}
.nav-title { font-family: var(--mono); font-size: 10px; letter-spacing: .16em; color: var(--text-faint); padding: 0 8px 8px; }
.nav-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: none; border: none; color: var(--text-dim);
  padding: 6px 8px; border-radius: 4px; font-size: 13px;
  border-left: 2px solid transparent; transition: all .15s ease;
}
.nav-item:hover { color: var(--text); background: var(--panel); }
.nav-item.active { color: var(--text); background: var(--panel); border-left-color: var(--accent); }
.nav-item .nav-no { font-size: 10px; color: var(--text-faint); width: 18px; flex-shrink: 0; }
.nav-item.active .nav-no { color: var(--accent-dim); }
.nav-item .nav-count { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--text-faint); background: var(--panel2); padding: 0 6px; border-radius: 8px; }
.nav-item.active .nav-count { color: var(--accent-dim); }
.nav-item.nav-root { font-weight: 600; color: var(--text); margin-top: 2px; }
.nav-item.nav-child { padding-left: 24px; font-size: 12.5px; font-weight: 400; }
.nav-caret { font-size: 9px; color: var(--text-faint); width: 14px; flex-shrink: 0; transition: transform .25s ease; }
.nav-wrap.open > .nav-root .nav-caret { transform: rotate(90deg); color: var(--accent-dim); }
.nav-children { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .32s cubic-bezier(.4,0,.2,1); }
.nav-wrap.open > .nav-children { grid-template-rows: 1fr; }
.nav-inner { overflow: hidden; min-height: 0; }
.nav-sep { height: 1px; background: var(--border-soft); margin: 8px 6px; }
.content { flex: 1; min-width: 0; padding: 20px 24px 60px; }

/* ============ 引言 ============ */
.intro {
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  background: var(--panel); padding: 14px 16px; margin-bottom: 22px;
}
.intro .it { font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; color: var(--accent-dim); text-transform: uppercase; }
.intro p { color: var(--text-dim); font-size: 13px; margin-top: 3px; }
.intro b { color: var(--text); }

/* ============ 章节（大块） ============ */
.chapter { margin-bottom: 26px; scroll-margin-top: 68px; }
.chapter-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--border); border-left: 3px solid var(--accent);
  background: var(--panel); border-radius: 4px; cursor: pointer;
  user-select: none; transition: background .15s ease;
}
.chapter-head:hover { background: var(--panel2); }
.chapter-head .caret { color: var(--accent-dim); transition: transform .2s ease; font-size: 11px; }
.chapter.collapsed .caret { transform: rotate(-90deg); }
.chapter-head h2 { font-size: 15.5px; font-weight: 650; }
.chapter-head .sec-key { font-family: var(--mono); font-size: 11px; color: var(--text-faint); }
.chapter-desc {
  font-size: 11.5px; color: var(--text-faint); font-weight: 400;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1 1 auto; min-width: 0;
}
.chapter-head .sec-count { font-family: var(--mono); font-size: 11px; color: var(--accent-dim); margin-left: auto; }
.chapter-body { padding: 14px 4px 6px 14px; }
.chapter.collapsed > .chapter-body { display: none; }

/* ============ 节点（模块组） ============ */
.node { margin-bottom: 2px; }
.node-head {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 4px; cursor: pointer; user-select: none;
  color: var(--text-dim); transition: background .15s ease;
}
.node-head:hover { background: var(--panel); }
.node-head .caret { color: var(--text-faint); font-size: 10px; width: 12px; flex-shrink: 0; transition: transform .2s ease; }
.node.collapsed .caret { transform: rotate(-90deg); }
.node-name { font-size: 13px; font-weight: 600; color: var(--text); }
.node-desc {
  flex: 1 1 auto; min-width: 0; font-size: 11px; color: var(--text-faint);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.node-path { font-size: 10.5px; color: var(--text-faint); flex-shrink: 0; }
.node-count { font-family: var(--mono); font-size: 10.5px; color: var(--text-faint); background: var(--panel2); padding: 0 7px; border-radius: 8px; flex-shrink: 0; }
.node-off-tag {
  font-family: var(--mono); font-size: 9px; letter-spacing: .08em; color: var(--err);
  border: 1px solid color-mix(in oklab, var(--err) 40%, transparent); padding: 0 5px; border-radius: 2px;
}
.node-body { padding: 2px 0 4px 18px; border-left: 1px solid var(--border-soft); margin-left: 6px; }
.node.collapsed > .node-body { display: none; }
.node-off > .node-head .node-name { color: var(--text-faint); }

/* ============ 字段行 ============ */
.frow {
  display: flex; align-items: flex-start; gap: 16px;
  padding: 7px 8px; border-radius: 4px; transition: background .15s ease;
}
.frow:hover { background: var(--panel); }
.fmeta { flex: 1; min-width: 0; }
.fname { font-size: 13px; font-weight: 550; display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; }
.fkey { font-size: 10px; color: var(--text-faint); font-weight: 400; }
.fdesc { font-size: 11.5px; color: var(--text-dim); margin-top: 0; }
.badge {
  display: inline-block; font-size: 9px; letter-spacing: .06em; padding: 0 5px;
  border-radius: 2px; border: 1px solid var(--border); color: var(--text-faint);
  vertical-align: 1px; text-transform: uppercase;
}
.badge.b-bool { color: var(--ok); border-color: color-mix(in oklab, var(--ok) 35%, transparent); }
.badge.b-num  { color: var(--accent); border-color: color-mix(in oklab, var(--accent) 35%, transparent); }
.badge.b-arr  { color: var(--warn); border-color: color-mix(in oklab, var(--warn) 35%, transparent); }
.fctrl { flex-shrink: 0; display: flex; align-items: center; min-height: 32px; }
.fctrl input[type="text"], .fctrl input[type="number"], .fctrl select {
  font-family: var(--mono); font-size: 12px; width: 240px;
  background: var(--input); color: var(--text); border: 1px solid var(--border);
  border-radius: 4px; padding: 6px 9px; transition: border-color .15s ease;
}
.fctrl input[type="text"]:focus, .fctrl input[type="number"]:focus, .fctrl select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.fctrl textarea {
  font-family: var(--mono); font-size: 11.5px; width: 300px; min-height: 54px; resize: vertical;
  background: var(--input); color: var(--text); border: 1px solid var(--border);
  border-radius: 4px; padding: 6px 9px; line-height: 1.5;
}
.fctrl textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.fctrl select { width: 240px; cursor: pointer; }
.fctrl select option { background: var(--panel); color: var(--text); }

/* 开关 */
.switch { position: relative; width: 40px; height: 22px; flex-shrink: 0; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; border-radius: 11px;
  background: var(--panel2); border: 1px solid var(--border); transition: all .22s ease;
}
.switch .track::before {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--text-faint); transition: all .22s cubic-bezier(.4,0,.2,1);
}
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::before { transform: translateX(18px); background: oklch(100% 0 0); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--accent-soft); }

/* ============ JSON ============ */
.json-shell { border: 1px solid var(--border); border-radius: 4px; overflow: hidden; background: var(--panel); }
.json-bar { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-bottom: 1px solid var(--border-soft); background: var(--panel2); }
.json-bar .dots { display: flex; gap: 5px; }
.json-bar .dots i { width: 9px; height: 9px; border-radius: 50%; display: block; }
.json-bar .dots i:nth-child(1) { background: var(--err); }
.json-bar .dots i:nth-child(2) { background: var(--warn); }
.json-bar .dots i:nth-child(3) { background: var(--ok); }
.json-bar .fname { font-size: 12px; color: var(--text-dim); }
#jsonEditor {
  width: 100%; min-height: 300px; border: none; resize: vertical;
  background: var(--input); color: var(--text); font-family: var(--mono); font-size: 12px; line-height: 1.55;
  padding: 12px 14px;
}
#jsonEditor:focus { outline: none; }
.json-actions { display: flex; gap: 8px; margin-bottom: 10px; }

/* ============ 状态栏 ============ */
.statusbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  background: color-mix(in oklab, var(--bg2) 92%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding: 5px 20px; font-size: 11px; color: var(--text-dim);
}
.statusbar .item { display: flex; align-items: center; gap: 5px; }
.statusbar b { color: var(--text); font-weight: 600; }
.statusbar .spacer { flex: 1; }
.statusbar .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; }

/* ============ Toast ============ */
#toast {
  position: fixed; top: 62px; left: 50%; transform: translateX(-50%) translateY(-8px);
  background: var(--panel); color: var(--text); border: 1px solid var(--accent);
  border-radius: 4px; padding: 9px 16px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 100;
  box-shadow: 0 6px 24px oklch(0% 0 0 / 25%);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { border-color: var(--err); }

/* ============ 视图切换 ============ */
.view-switch { display: flex; border: 1px solid var(--border); border-radius: 5px; overflow: hidden; flex-shrink: 0; }
.view-switch button { background: var(--panel2); color: var(--text-dim); border: none; padding: 6px 16px; font-size: 12.5px; transition: all .18s ease; }
.view-switch button:hover:not(.active) { color: var(--accent); }
.view-switch button.active { background: var(--accent); color: oklch(96% 0.01 285); font-weight: 600; }

/* 基础视图：登录模式提示 + 2b2t 定制区 */
.mode-tip {
  font-size: 12px; color: var(--accent-dim); background: var(--accent-soft);
  border: 1px solid color-mix(in oklab, var(--accent) 30%, transparent);
  border-radius: 5px; padding: 8px 12px; margin-bottom: 12px;
}
.b2-area {
  margin: 14px 0 4px; border: 1px dashed var(--border); border-radius: 6px;
  padding: 8px 12px 4px;
  background: color-mix(in oklab, var(--accent) 5%, var(--panel));
}
.b2-title { font-size: 12px; font-weight: 650; color: var(--accent-dim); margin-bottom: 6px; letter-spacing: .03em; }

/* ============ 响应式 ============ */
@media (max-width: 980px) {
  .layout { flex-direction: column; }
  .sidenav {
    width: 100%; position: static; max-height: none; overflow: visible;
    display: flex; flex-wrap: wrap; gap: 2px; padding: 10px 12px;
  }
  .nav-title { width: 100%; }
  .nav-item { width: auto; flex: 0 0 auto; border-left: none; border-bottom: 2px solid transparent; border-radius: 0; padding: 5px 8px; }
  .nav-item.nav-child { padding-left: 8px; }
  .nav-item.active { border-bottom-color: var(--accent); }
  .nav-sep { display: none; }
  .content { padding: 16px 12px 60px; }
  .fctrl input[type="text"], .fctrl input[type="number"], .fctrl select { width: 170px; }
  .fctrl textarea { width: 210px; }
}
@media (max-width: 560px) {
  .frow { flex-direction: column; gap: 5px; }
  .fctrl { width: 100%; }
  .fctrl input[type="text"], .fctrl input[type="number"], .fctrl select, .fctrl textarea { width: 100%; }
  .node-body { padding-left: 10px; }
  .view-switch button { padding: 5px 11px; font-size: 12px; }
  .scenario-row { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ============ 基础视图 v7：场景卡流程 ============ */
.scenario-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 4px; }
.scenario-card {
  border: 1px solid var(--border); border-radius: 8px; background: var(--panel);
  padding: 15px 16px; cursor: pointer; text-align: left;
  transition: all .18s ease; position: relative;
}
.scenario-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.scenario-card.active { border-color: var(--accent); background: var(--accent-soft); }
.scenario-card.active::after {
  content: "✓"; position: absolute; top: 10px; right: 12px;
  color: var(--accent); font-weight: 700; font-size: 14px;
}
.scenario-card .sc-icon { font-size: 22px; }
.scenario-card .sc-name { font-size: 14px; font-weight: 650; margin-top: 7px; }
.scenario-card .sc-desc { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; line-height: 1.5; }
.sc-hint { font-size: 11px; color: var(--text-faint); margin: 6px 2px 0; }

.more-group-title {
  font-size: 11px; font-weight: 650; color: var(--text-faint);
  letter-spacing: .06em; margin: 14px 0 2px; text-transform: uppercase;
}
.more-group-title:first-child { margin-top: 4px; }

.btn-download-big {
  display: block; width: 100%; max-width: 460px; margin: 26px auto 8px;
  padding: 15px 22px; font-size: 15px; font-weight: 700; border-radius: 9px;
  text-align: center;
}
.download-hint { text-align: center; font-size: 11.5px; color: var(--text-faint); margin-bottom: 10px; }

.dirty-dot {
  color: var(--warn); font-size: 12px; font-weight: 600; white-space: nowrap;
  animation: blink 1.3s ease-in-out infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
