/* 认知引擎 · 界面
   设计语言：冷纸底 + 深墨字 + 宋体标题；结构线代替装饰；
   树的形态是整套界面的结构母题（从第一性原理向上生长）。 */

:root {
  --paper: #EEF1F5;
  --surface: #FFFFFF;
  --ink: #16202B;
  --ink-2: #465565;
  --ink-3: #7B8A9A;
  --line: #D2DAE4;
  --line-2: #B4C0CF;
  --primary: #1F4A6E;
  --primary-2: #2F6B94;
  --primary-wash: #E4ECF3;
  --amber: #B9822A;
  --amber-wash: #F6EEDD;
  --ok: #2C6A4C;
  --ok-wash: #E3F0E8;
  --bad: #9E3A2C;
  --bad-wash: #F6E5E1;
  --radius: 8px;
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", SimSun, serif;
  --sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "JetBrains Mono", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

/* hidden 属性必须压过 .main 的 display:flex */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0;
}

a { color: var(--primary); }

/* ---------- 基础控件 ---------- */

.btn {
  appearance: none;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  padding: 9px 18px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--primary-2); border-color: var(--primary-2); }
.btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--primary);
}
.btn-ghost:hover { background: var(--primary-wash); }

.btn-quiet {
  background: transparent;
  border-color: var(--line-2);
  color: var(--ink-2);
}
.btn-quiet:hover { background: #fff; border-color: var(--ink-3); }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.field .hint {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 5px;
  line-height: 1.5;
}
.field input, .field select, .field textarea {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 9px 11px;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--primary-2);
  box-shadow: 0 0 0 3px var(--primary-wash);
}
.field input.mono { font-family: var(--mono); font-size: 13px; }

/* ---------- 状态 ---------- */

.dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 1px;
  background: var(--ink-3);
}
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--bad); }
.dot.warn { background: var(--amber); }

.tag {
  display: inline-block;
  font-size: 12px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  color: var(--ink-2);
}
.tag.ok { background: var(--ok-wash); border-color: transparent; color: var(--ok); }
.tag.bad { background: var(--bad-wash); border-color: transparent; color: var(--bad); }
.tag.warn { background: var(--amber-wash); border-color: transparent; color: var(--amber); }

.note {
  font-size: 13px;
  color: var(--ink-2);
  border-left: 2px solid var(--line-2);
  padding-left: 12px;
  margin: 14px 0;
}
.note.warn { border-left-color: var(--amber); color: var(--amber); }
.note.bad { border-left-color: var(--bad); color: var(--bad); }

.error {
  font-size: 13px;
  color: var(--bad);
  min-height: 20px;
}

/* ---------- 登录页 ---------- */

.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
}

.login-art {
  position: relative;
  background: linear-gradient(180deg, #E7ECF2 0%, #EEF1F5 100%);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px 56px;
  overflow: hidden;
}
.login-art svg {
  width: auto;
  height: auto;
  max-width: min(460px, 100%);
  max-height: calc(100vh - 190px);
  align-self: center;
}
.art-cap {
  font-family: var(--serif);
  font-size: 15px;
  color: var(--ink-2);
  letter-spacing: .06em;
}
.art-cap.bottom { text-align: right; }

.login-form {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.login-inner { width: 100%; max-width: 340px; }
.login-inner h1 { font-size: 30px; margin-bottom: 8px; }
.login-inner .lede {
  color: var(--ink-2);
  font-size: 14px;
  margin: 0 0 30px;
  line-height: 1.7;
}

.role-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 22px;
}
.role-tabs button {
  appearance: none;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink-2);
  padding: 10px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.role-tabs button + button { border-left: 1px solid var(--line-2); }
.role-tabs button[aria-selected="true"] {
  background: var(--ink);
  color: #fff;
}

.alt-link {
  margin-top: 16px;
  text-align: center;
  font-size: 13px;
}
.alt-link a { color: var(--ink-3); text-decoration: none; }
.alt-link a:hover { color: var(--primary); text-decoration: underline; }

/* ---------- 应用外壳 ---------- */

.shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand {
  font-family: var(--serif);
  font-size: 17px;
  letter-spacing: .04em;
}
.brand small {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ink-3);
  margin-left: 10px;
  letter-spacing: 0;
}
.topbar-right { display: flex; align-items: center; gap: 16px; font-size: 13px; color: var(--ink-2); }

.wrap { width: min(1120px, 100%); margin: 0 auto; padding: 36px 28px 64px; }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin: 40px 0 18px;
}
.section-head:first-child { margin-top: 0; }
.section-head h2 { font-size: 19px; }
.section-head .sub { font-size: 13px; color: var(--ink-3); }

/* 双栏：靠一条结构线分隔，不用浮卡 */
.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.pair > section { padding: 24px 26px 20px; }
.pair > section + section { border-left: 1px solid var(--line); }

.slot-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.slot-title {
  font-family: var(--serif);
  font-size: 16px;
}
.slot-sub { font-size: 12px; color: var(--ink-3); }

.slot-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}
.slot-result { font-size: 12px; color: var(--ink-3); margin-left: auto; }

.plain {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 26px;
}

.rows { display: grid; gap: 12px; }
.row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  font-size: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: none; padding-bottom: 0; }
.row .k { color: var(--ink-2); }
.row .v { color: var(--ink); text-align: right; }

/* ---------- 学习页 ---------- */

.learn-shell {
  display: grid;
  grid-template-columns: 268px 1fr;
  height: 100vh;
}

.spine {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 22px 0 16px;
  overflow-y: auto;
}
.spine-brand {
  font-family: var(--serif);
  font-size: 17px;
  padding: 0 22px 18px;
  letter-spacing: .04em;
}
.spine-tabs { display: flex; padding: 0 18px 16px; gap: 6px; }
.spine-tabs button {
  flex: 1;
  appearance: none;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 13px;
  padding: 7px;
  border-radius: var(--radius);
  cursor: pointer;
}
.spine-tabs button[aria-selected="true"] {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.stages { list-style: none; margin: 0; padding: 0 0 8px; }
.stages li {
  position: relative;
  padding: 9px 22px 9px 46px;
  font-size: 13px;
  color: var(--ink-3);
}
.stages li::before {
  content: "";
  position: absolute;
  left: 26px; top: 15px;
  width: 7px; height: 7px;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  background: var(--surface);
}
.stages li::after {
  content: "";
  position: absolute;
  left: 29px; top: 22px; bottom: -9px;
  width: 1px;
  background: var(--line);
}
.stages li:last-child::after { display: none; }
.stages li.done { color: var(--ink-2); }
.stages li.done::before { background: var(--primary); border-color: var(--primary); }
.stages li.active { color: var(--ink); font-weight: 500; }
.stages li.active::before {
  background: var(--amber);
  border-color: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-wash);
}

.spine-foot {
  margin-top: auto;
  padding: 14px 22px 0;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-3);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.main { display: flex; flex-direction: column; height: 100vh; }

.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 32px 0;
}
.chat-inner { width: min(760px, 100%); margin: 0 auto; padding: 0 24px; }

.msg { margin-bottom: 26px; display: flex; flex-direction: column; }
.msg .who {
  font-size: 12px;
  color: var(--ink-3);
  margin-bottom: 6px;
  letter-spacing: .04em;
}
.msg .body {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.85;
}
.msg.user .body {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
}
.msg.engine .body { padding-left: 16px; border-left: 2px solid var(--primary); }

.alt {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.alt summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--ink-2);
  padding: 9px 16px;
  list-style: none;
}
.alt summary::-webkit-details-marker { display: none; }
.alt .alt-body { padding: 4px 16px 16px; font-size: 14px; color: var(--ink-2); white-space: pre-wrap; }

.composer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 14px 0 18px;
}
.composer-inner { width: min(760px, 100%); margin: 0 auto; padding: 0 24px; }
.composer textarea {
  width: 100%;
  resize: none;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.6;
  padding: 12px 14px;
  height: 76px;
  background: var(--paper);
}
.composer textarea:focus {
  outline: none;
  border-color: var(--primary-2);
  background: #fff;
  box-shadow: 0 0 0 3px var(--primary-wash);
}
.composer-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--ink-2);
}
.mini-select {
  font-family: inherit;
  font-size: 12.5px;
  color: var(--ink-2);
  background: var(--paper);
  border: 1px solid var(--line-2);
  border-radius: 6px;
  padding: 5px 8px;
  max-width: 190px;
}
.mini-select:focus { outline: none; border-color: var(--primary-2); }

.inline-input {
  font-family: inherit;
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  width: 140px;
}
.inline-input:focus { outline: none; border-color: var(--primary-2); }

.user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 13.5px;
}
.user-row:last-child { border-bottom: none; }
.user-row .uname { font-family: var(--mono); font-size: 13px; min-width: 110px; }
.user-row .udisplay { color: var(--ink-2); flex: 1; min-width: 90px; }
.user-row .ustatus { font-size: 12px; }
.user-row .ustatus.on { color: var(--ok); }
.user-row .ustatus.off { color: var(--bad); }
.user-row .uacts { display: flex; gap: 8px; }
.user-row .uacts button {
  appearance: none;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.user-row .uacts button:hover { border-color: var(--primary-2); color: var(--primary); }

.icon-btn {
  appearance: none;
  border: 1px solid var(--line-2);
  background: var(--paper);
  color: var(--ink-2);
  border-radius: 6px;
  width: 30px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: none;
}
.icon-btn:hover { border-color: var(--primary-2); color: var(--primary); }
.icon-btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

.attach-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 0 2px;
}
.attach-thumb {
  position: relative;
  width: 66px;
  height: 66px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line-2);
  background: var(--paper);
}
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-thumb button {
  position: absolute;
  top: 2px; right: 2px;
  width: 18px; height: 18px;
  border: none;
  border-radius: 50%;
  background: rgba(22,32,43,.72);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.composer.dragover textarea {
  border-color: var(--primary-2);
  background: var(--primary-wash);
}
.switch { display: flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; white-space: nowrap; }
.switch input { accent-color: var(--primary); }

/* 开场 */
.empty {
  padding: 40px 0;
}
.empty h2 { font-size: 22px; margin-bottom: 10px; }
.empty p { color: var(--ink-2); font-size: 14px; max-width: 46em; margin: 0 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.chips button {
  appearance: none;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink-2);
  font-family: inherit;
  font-size: 13px;
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
}
.chips button:hover { border-color: var(--primary-2); color: var(--primary); }

/* 可行性面板 */
.feas { display: flex; flex-direction: column; height: 100%; }
.feas-body { flex: 1; overflow-y: auto; padding: 32px 0; }
.feas-inner { width: min(760px, 100%); margin: 0 auto; padding: 0 24px; }
.feas-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.verdict {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 22px 24px;
  margin-top: 24px;
}
.verdict h3 { font-size: 17px; margin-bottom: 6px; }
.verdict.feasible h3 { color: var(--ok); }
.verdict.infeasible h3 { color: var(--bad); }
.verdict .facts {
  display: flex;
  gap: 28px;
  margin: 16px 0 4px;
  flex-wrap: wrap;
}
.fact .n { font-family: var(--serif); font-size: 24px; }
.fact .l { font-size: 12px; color: var(--ink-3); }
.plans { margin: 16px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.plans li {
  font-size: 13px;
  padding: 10px 14px;
  border-left: 2px solid var(--amber);
  background: var(--amber-wash);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.plans .cost { color: var(--ink-3); }

/* ---------- 语义树 ---------- */

.spine-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.spine-tabs button { padding: 7px 4px; font-size: 12.5px; }

/* 三维权重 */
.weights { display: flex; gap: 22px; margin: 18px 0 6px; }
.weight { flex: 1; }
.weight .top { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-2); }
.weight .top b { font-weight: 600; color: var(--ink); }
.weight .bar { height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.weight .bar i { display: block; height: 100%; background: var(--primary); border-radius: 3px; }

/* 路径步骤 */
.steps { list-style: none; margin: 20px 0 0; padding: 0; }
.steps li {
  display: flex;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.steps li:last-child { border-bottom: none; }
.steps .idx { font-family: var(--serif); color: var(--ink-3); width: 26px; flex: none; font-size: 15px; }
.steps .sbody { flex: 1; min-width: 0; }
.steps .sname { font-size: 15px; }
.steps .smeta { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.steps .snote { font-size: 13px; color: var(--ink-2); margin-top: 6px; line-height: 1.6; }
.kind {
  display: inline-block;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 999px;
  margin-left: 8px;
  vertical-align: 1px;
  border: 1px solid var(--line-2);
  color: var(--ink-3);
}
.kind.safety { color: var(--bad); border-color: transparent; background: var(--bad-wash); }
.kind.action { color: var(--primary); border-color: transparent; background: var(--primary-wash); }
.kind.principle { color: var(--ok); border-color: transparent; background: var(--ok-wash); }

.profile-line { font-size: 13px; color: var(--ink-2); margin: 4px 0; }
.profile-line b { color: var(--ink); font-weight: 600; margin-right: 6px; }
/* 真值核查 */
/* 树根体检 */
.root-audit {
  margin-top: 26px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}
.root-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 14px;
}
.root-row:last-child { border-bottom: none; }
.root-row .deeper {
  flex-basis: 100%;
  font-size: 12.5px;
  color: var(--ink-2);
  margin: 4px 0 0 4px;
  padding-left: 10px;
  border-left: 2px solid var(--amber);
}

.truth-row {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.truth-row:last-child { border-bottom: none; }
.truth-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.truth-name { font-size: 15px; }
.truth-claim { font-size: 13px; color: var(--ink-2); margin-top: 5px; line-height: 1.6; }
.truth-models { margin-top: 8px; display: grid; gap: 6px; }
.truth-model {
  font-size: 12.5px;
  line-height: 1.6;
  padding: 7px 11px;
  border-radius: 0 var(--radius) var(--radius) 0;
  border-left: 2px solid var(--line-2);
  background: var(--paper);
  color: var(--ink-2);
}
.truth-model .m { color: var(--ink-3); margin-right: 6px; }
.truth-model.bad { border-left-color: var(--bad); background: var(--bad-wash); }
.truth-model.warn { border-left-color: var(--amber); background: var(--amber-wash); }

.status-pill {
  font-size: 11.5px;
  padding: 1px 9px;
  border-radius: 999px;
}
.status-pill.verified,
.status-pill.confirmed { background: var(--ok-wash); color: var(--ok); }
.status-pill.flagged { background: var(--bad-wash); color: var(--bad); }
.status-pill.disputed,
.status-pill.corrected { background: var(--amber-wash); color: var(--amber); }
.status-pill.unknown,
.status-pill.uncertain { background: var(--paper); color: var(--ink-3); }

.truth-conf { font-size: 11.5px; color: var(--ink-3); margin-left: auto; }
.truth-fix {
  margin-top: 8px;
  font-size: 13px;
  padding: 9px 13px;
  border-left: 2px solid var(--amber);
  background: var(--amber-wash);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--ink);
  line-height: 1.65;
}
.truth-fix b { color: var(--amber); font-weight: 600; margin-right: 6px; }
.truth-basis { font-size: 12.5px; color: var(--ink-3); margin-top: 7px; line-height: 1.6; }
.truth-evidence { font-size: 12px; color: var(--ink-3); margin-top: 6px; }
.truth-evidence a { color: var(--primary-2); text-decoration: none; }
.truth-evidence a:hover { text-decoration: underline; }

.truth-group { margin-top: 26px; }
.truth-group h3 { font-size: 15px; margin-bottom: 6px; }
.truth-group .gsub { font-size: 12.5px; color: var(--ink-3); margin-bottom: 8px; }

/* 六级校验 */
.gate-list {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  margin: 14px 0 0;
}
.gate-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background .12s;
}
.gate-row:last-child { border-bottom: none; }
.gate-row:hover { background: var(--primary-wash); }
.gate-row.sel { background: var(--primary-wash); }
.gate-num { font-family: var(--serif); color: var(--ink-3); width: 22px; }
.gate-name { flex: 1; font-size: 14.5px; }
.gate-name small { color: var(--ink-3); font-size: 12px; margin-left: 8px; }
.gate-state { font-size: 12px; color: var(--ink-3); }
.gate-state.ok { color: var(--ok); }
.gate-state.warn { color: var(--amber); }
.gate-state.bad { color: var(--bad); }

.gate-panel {
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 20px 22px;
}
.gate-prompt {
  font-size: 15px;
  line-height: 1.85;
  white-space: pre-wrap;
  margin-bottom: 16px;
}
.gate-panel textarea {
  width: 100%;
  min-height: 120px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.7;
  padding: 12px 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--paper);
  resize: vertical;
}
.gate-panel textarea:focus {
  outline: none;
  border-color: var(--primary-2);
  background: #fff;
  box-shadow: 0 0 0 3px var(--primary-wash);
}

.verdict-box {
  margin-top: 16px;
  padding: 14px 16px;
  border-left: 3px solid var(--line-2);
  background: var(--paper);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 14px;
  line-height: 1.75;
}
.verdict-box.understood { border-left-color: var(--ok); background: var(--ok-wash); }
.verdict-box.memorized,
.verdict-box.partial { border-left-color: var(--amber); background: var(--amber-wash); }
.verdict-box.wrong { border-left-color: var(--bad); background: var(--bad-wash); }
.verdict-box h4 { font-family: var(--serif); font-size: 15px; margin-bottom: 6px; }
.verdict-box .sub { color: var(--ink-2); font-size: 13px; margin-top: 6px; }

.progress-line {
  display: flex;
  gap: 12px;
  align-items: baseline;
  margin: 18px 0 0;
  font-size: 13px;
  color: var(--ink-2);
}
.progress-line b { font-family: var(--serif); font-size: 20px; color: var(--ink); }

.skipped-note {
  margin-top: 18px;
  font-size: 12.5px;
  color: var(--ink-3);
  border-top: 1px dashed var(--line-2);
  padding-top: 12px;
}

.tree-form {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 0 0 18px;
}
.tree-form input[type="text"] {
  flex: 1 1 260px;
  min-width: 200px;
  font-family: inherit;
  font-size: 14px;
  padding: 9px 11px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--surface);
}
.tree-form select {
  font-family: inherit;
  font-size: 13px;
  padding: 9px 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}
.tree-form input[type="text"]:focus, .tree-form select:focus {
  outline: none;
  border-color: var(--primary-2);
  box-shadow: 0 0 0 3px var(--primary-wash);
}
.tree-form label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-2);
  user-select: none;
}

.tree-status {
  font-size: 13px;
  color: var(--ink-2);
  min-height: 22px;
  margin-bottom: 14px;
}

/* 生成进度：动态效果，让人看得出系统在工作 */
.progress-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 15px 18px;
  margin-bottom: 16px;
}
.progress-top {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--ink);
}
.pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  flex: none;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: .25; transform: scale(.8); }
  50% { opacity: 1; transform: scale(1.15); }
}
.progress-bar {
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 12px;
  position: relative;
}
.progress-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  border-radius: 2px;
  position: relative;
  transition: width .6s ease;
}
.progress-bar i::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .5), transparent);
  animation: shimmer 1.6s linear infinite;
}
@keyframes shimmer {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}
.progress-sub {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 10px;
}

@media (prefers-reduced-motion: reduce) {
  .pulse, .progress-bar i::after { animation: none; }
}

.meta-row { display: flex; gap: 30px; flex-wrap: wrap; margin: 4px 0 24px; }
.meta-row .n { font-family: var(--serif); font-size: 22px; line-height: 1.2; }
.meta-row .l { font-size: 12px; color: var(--ink-3); }

.tree-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 28px;
  align-items: start;
}

.tree-outline { font-size: 14px; }
.tree-children {
  margin-left: 11px;
  padding-left: 20px;
  border-left: 1px solid var(--line);
}
.tree-item { position: relative; padding: 3px 0; }
.tree-item::before {
  content: "";
  position: absolute;
  left: -21px;
  top: 15px;
  width: 11px;
  height: 1px;
  background: var(--line);
}
.tree-item > button {
  appearance: none;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  text-align: left;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  width: 100%;
}
.tree-item > button:hover { background: var(--primary-wash); }
.tree-item.sel > button { background: var(--primary-wash); color: var(--primary); }
.tree-node-min { color: var(--ink-3); font-size: 12px; margin-left: 8px; }
.tree-node-extra { color: var(--ink-3); font-size: 11px; margin-left: 8px; }
.tree-node-flag { color: var(--amber); font-size: 11px; margin-left: 6px; }

.tree-detail {
  position: sticky;
  top: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px 20px;
  font-size: 13px;
  color: var(--ink-2);
}
.tree-detail .empty-hint { color: var(--ink-3); }
.tree-detail h3 { font-size: 16px; color: var(--ink); margin-bottom: 4px; }
.tree-detail .sub { color: var(--ink-3); font-size: 12px; margin-bottom: 12px; }
.tree-detail dt { color: var(--ink-3); font-size: 12px; margin-top: 12px; }
.tree-detail dd { margin: 3px 0 0; line-height: 1.65; color: var(--ink-2); }

.issues { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.issues li {
  font-size: 12.5px;
  padding: 8px 12px;
  border-left: 2px solid var(--line-2);
  background: var(--paper);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.issues li.high { border-left-color: var(--bad); background: var(--bad-wash); }
.issues li.medium { border-left-color: var(--amber); background: var(--amber-wash); }
.issues .where { color: var(--ink-3); margin-left: 6px; }

/* ---------- 响应式 ---------- */

.mobile-tabs { display: none; }

@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login-art { min-height: 200px; padding: 28px; }
  .login-art svg { max-width: 220px; }
  .learn-shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .spine { display: none; }

  .top-tabs { display: none; }

  .mobile-tabs {
    display: flex;
    gap: 6px;
    padding: 10px 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
  }
  .mobile-tabs button {
    flex: 1;
    appearance: none;
    border: 1px solid var(--line-2);
    background: transparent;
    color: var(--ink-2);
    font-family: inherit;
    font-size: 13px;
    padding: 7px 4px;
    border-radius: var(--radius);
  }
  .mobile-tabs button[aria-selected="true"] {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
  }
  .main { height: auto; min-height: 0; }

  .pair { grid-template-columns: 1fr; }
  .pair > section + section { border-left: none; border-top: 1px solid var(--line); }
  .feas-grid { grid-template-columns: 1fr; }
  .tree-layout { grid-template-columns: 1fr; }
  .tree-detail { position: static; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}


/* ---------- 工作台与顶部选项卡 ---------- */

.work { display: flex; flex-direction: column; height: 100vh; min-width: 0; }
.main { height: auto; flex: 1; min-height: 0; }

.top-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 18px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex: none;
}
.top-tabs button {
  appearance: none;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink-2);
  padding: 10px 16px 12px;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}
.top-tabs button[aria-selected="true"] {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}
.top-tabs button:hover { color: var(--ink); }

.sub-tabs {
  display: flex;
  gap: 18px;
  padding: 12px 24px 0;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.sub-tabs button {
  appearance: none;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink-3);
  padding: 4px 0 10px;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}
.sub-tabs button[aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--amber);
}

.ws-block { padding: 0 18px 18px; }
.ws-label {
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: .04em;
  margin-bottom: 8px;
}
.ws-select {
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  padding: 7px 8px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}
.ws-todo { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ws-todo li {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.5;
  padding-left: 14px;
  position: relative;
}
.ws-todo li::before {
  content: "";
  position: absolute;
  left: 0; top: 8px;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--line-2);
}
.ws-todo li.due { color: var(--bad); }
.ws-todo li.due::before { background: var(--bad); }
.ws-empty { color: var(--ink-3); font-size: 12.5px; }

.ws-stats { display: flex; gap: 16px; }
.ws-stat .n { font-family: var(--serif); font-size: 19px; }
.ws-stat .l { font-size: 11.5px; color: var(--ink-3); }

.ws-creds { display: grid; gap: 6px; }
.ws-cred {
  font-size: 12.5px;
  color: var(--ok);
  background: var(--ok-wash);
  border-radius: 6px;
  padding: 6px 9px;
  line-height: 1.45;
}
.ws-cred.revoked { color: var(--ink-3); background: var(--paper); }
.admin-only { display: none; }
body.is-admin .admin-only { display: inline-flex; }


/* ---------- 右侧方法论面板 ---------- */
.insight {
  display: none;
  background: var(--surface);
  border-left: 1px solid var(--line);
  padding: 22px 18px 40px;
  overflow-y: auto;
}
@media (min-width: 1201px) {
  .learn-shell { grid-template-columns: 260px 1fr 300px; }
  .insight { display: block; }
}
.insight h3 {
  font-family: var(--serif);
  font-size: 15px;
  margin: 0 0 14px;
}
.insight .block { margin-bottom: 22px; }
.insight .kv { display: flex; justify-content: space-between; font-size: 13px; padding: 5px 0; }
.insight .kv .k { color: var(--ink-3); }
.insight .advice {
  font-size: 13px;
  line-height: 1.65;
  color: var(--ink-2);
  border-left: 2px solid var(--amber);
  padding: 8px 10px;
  background: var(--amber-wash);
  border-radius: 0 6px 6px 0;
  margin-bottom: 8px;
}
.insight .advice .ev { display: block; color: var(--ink-3); font-size: 12px; margin-top: 4px; }

.msg-body.collapsed .more { display: none; }
.msg-body .toggle-more {
  display: inline-block;
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--primary);
  cursor: pointer;
}
.badge {
  display: inline-block;
  min-width: 16px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--bad);
  color: #fff;
  font-size: 11px;
  line-height: 16px;
  text-align: center;
  margin-left: 6px;
}


/* 树全貌图 */
.tree-svg {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px 8px 4px;
  margin-bottom: 22px;
}
.tree-svg svg { display: block; }

.node-art {
  display: block;
  width: 100%;
  max-width: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 4px 0 14px;
  background: var(--surface);
}


/* 窄屏：只保留一排页签（必须放在文件末尾，否则被前面的 .top-tabs 覆盖） */
@media (max-width: 860px) {
  .top-tabs { display: none; }
}


/* 未审节点 */
.tree-item[data-status="pending"] > button { color: var(--ink-3); }
.tree-item[data-status="issue"] > button { color: var(--amber); }
