:root {
  --bg1: #f5f7f9; --bg2: #e4e9ee;
  --ink: #1d2733; --muted: #687482; --faint: #98a2ae;
  --line: #e1e6eb; --panel: rgba(255,255,255,.94);
  --brand: #2f9e44; --brand-ink: #1f7a33; --accent: #1c7ed6;
  --ok: #2f9e44; --warn: #e8590c;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(31,45,61,.10), 0 2px 6px rgba(31,45,61,.06);
  --font: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: "JetBrains Mono", Consolas, "Courier New", monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); color: var(--ink); font-size: 14px; line-height: 1.6;
  background: radial-gradient(120% 90% at 50% 30%, var(--bg1), var(--bg2));
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; }

#stage { position: fixed; inset: 0; }
#stage canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: fixed; top: 14px; left: 16px; right: 16px; z-index: 10;
  display: flex; align-items: center; gap: 14px; pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: var(--brand); color: #fff; font-weight: 700;
}
.brand-text b { display: block; font-size: 15px; }
.brand-text small { color: var(--muted); font-size: 12px; }
.topic {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
  background: var(--panel); border-radius: 999px; padding: 5px 8px 5px 14px; box-shadow: var(--shadow);
}
.topic span { color: var(--muted); font-size: 12px; }
.topic select {
  border: 0; background: #f1f4f7; border-radius: 999px; padding: 4px 8px; font: inherit; font-weight: 600; color: var(--ink);
}
.topic em { font-style: normal; color: var(--muted); font-size: 12px; padding-right: 6px; }
.mode { display: flex; background: var(--panel); border-radius: 999px; padding: 4px; box-shadow: var(--shadow); }
.mode button { border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; color: var(--muted); font-weight: 600; }
.mode button.on { background: var(--ink); color: #fff; }

/* ---------- 设计路线（目录） ---------- */
.route {
  position: fixed; left: 16px; top: 76px; bottom: 84px; z-index: 9; width: 188px;
  display: flex; flex-direction: column; gap: 4px; overflow-y: auto; padding-right: 4px;
  scrollbar-width: thin;
}
.layer { background: var(--panel); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.layer-h {
  display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: transparent;
  padding: 8px 10px; text-align: left; font-weight: 600; color: var(--ink);
}
.layer-h i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.layer-h small { margin-left: auto; color: var(--faint); font-weight: 500; font-size: 12px; }
.layer ul { list-style: none; margin: 0; padding: 0 6px 6px; display: none; }
.layer.open ul { display: block; }
.layer li button {
  width: 100%; border: 0; background: transparent; text-align: left; padding: 4px 8px 4px 22px;
  border-radius: 8px; color: var(--muted); font-size: 13px; position: relative;
}
.layer li button:hover { background: #f1f4f7; color: var(--ink); }
.layer li button.on { background: #e7f5ea; color: var(--brand-ink); font-weight: 600; }
.layer li button::before {
  content: ""; position: absolute; left: 9px; top: 50%; width: 6px; height: 6px; margin-top: -3px;
  border-radius: 50%; background: #cfd6dd;
}
.layer li button.done::before { background: var(--ok); }
.layer li button.locked { color: var(--faint); }
.layer li button.locked::after { content: "🔒"; font-size: 10px; margin-left: 4px; opacity: .6; }

/* ---------- 首页引导 ---------- */
.intro {
  position: fixed; left: 228px; bottom: 96px; z-index: 8; max-width: 440px;
  transition: opacity .35s, transform .35s;
}
.intro.hide { opacity: 0; transform: translateY(12px); pointer-events: none; }
.intro h1 { font-size: 30px; line-height: 1.25; margin: 0 0 8px; letter-spacing: .5px; }
.intro p { margin: 0 0 16px; color: var(--muted); }
.intro-btns { display: flex; gap: 10px; margin-bottom: 16px; }
.hero-strip { display: flex; gap: 8px; }
.hero-strip figure { margin: 0; width: 132px; cursor: zoom-in; }
.hero-strip img { width: 100%; aspect-ratio: 16/10; object-fit: cover; border-radius: 10px; box-shadow: var(--shadow); display: block; }
.hero-strip figcaption { font-size: 11px; color: var(--muted); margin-top: 4px; line-height: 1.35; }

.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 9px 18px;
  border-radius: 999px; font-weight: 600; font-size: 14px;
}
.btn:hover { border-color: #c5ced7; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-ink); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); padding: 6px 10px; }
.btn.ghost:hover { color: var(--ink); background: #f1f4f7; }
.btn:disabled { opacity: .4; cursor: default; }

/* ---------- 底部工具 ---------- */
.dock {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 9;
  display: flex; align-items: center; gap: 8px; background: var(--panel); padding: 6px 8px 6px 16px;
  border-radius: 999px; box-shadow: var(--shadow);
}
.explode { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.explode input { width: 180px; accent-color: var(--brand); }
.chip-btn { border: 0; background: #f1f4f7; color: var(--ink); padding: 6px 12px; border-radius: 999px; font-size: 13px; }
.chip-btn.on { background: var(--ink); color: #fff; }

.progress {
  position: fixed; right: 16px; bottom: 18px; z-index: 9; background: var(--panel); box-shadow: var(--shadow);
  padding: 6px 14px; border-radius: 999px; color: var(--muted); font-size: 13px;
}
.progress b { color: var(--brand-ink); font-size: 16px; }

/* ---------- 节点卡片 ---------- */
.card {
  position: fixed; right: 16px; top: 76px; bottom: 76px; width: 392px; z-index: 11;
  background: var(--panel); backdrop-filter: blur(8px); border-radius: 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; padding: 16px 18px 10px; animation: slideIn .28s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
.card-head { display: flex; align-items: center; }
.layer-chip { font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px; color: #fff; }
.icon-btn { margin-left: auto; border: 0; background: #f1f4f7; width: 30px; height: 30px; border-radius: 50%; color: var(--muted); }
.icon-btn:hover { color: var(--ink); }
.card h2 { font-size: 21px; margin: 10px 0 4px; }
.why { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.card-hero { margin: 0 0 12px; cursor: zoom-in; }
.card-hero img { width: 100%; border-radius: 10px; display: block; height: 96px; object-fit: cover; object-position: 50% 40%; }
.card-hero figcaption { font-size: 11px; color: var(--faint); margin-top: 4px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs button {
  border: 0; background: transparent; padding: 8px 10px; color: var(--muted); font-weight: 600; font-size: 13px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.on { color: var(--ink); border-bottom-color: var(--ink); }
.tabs button sup { color: var(--faint); font-weight: 500; margin-left: 2px; }
.tab-body { flex: 1; overflow-y: auto; padding: 12px 2px 8px; scrollbar-width: thin; }
.card-foot { display: flex; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 6px; }
.empty { color: var(--faint); font-size: 13px; padding: 20px 4px; text-align: center; }

/* 计算步骤 */
.step { padding: 9px 0 10px; border-bottom: 1px dashed var(--line); }
.step:last-child { border-bottom: 0; }
.step-t { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.step-t .st { margin-left: auto; font-size: 12px; font-weight: 600; }
.st.ok { color: var(--ok); }
.formula {
  font-family: var(--mono); font-size: 12.5px; background: #f4f6f8; border-radius: 8px; padding: 6px 9px; margin-top: 6px;
  color: #33404d; white-space: pre-wrap; word-break: break-word;
}
.result { margin-top: 4px; font-weight: 600; color: var(--brand-ink); }
.proc summary { cursor: pointer; color: var(--faint); font-size: 12px; margin-top: 4px; list-style: none; display: inline-block; }
.proc summary::-webkit-details-marker { display: none; }
.proc summary::after { content: " ▾"; }
.proc[open] summary::after { content: " ▴"; }
.proc summary:hover { color: var(--ink); }
.table-chip { max-width: 100%; text-align: left; }
.step .table-chip + .table-chip { margin-left: 4px; }
.answer { display: flex; gap: 6px; margin-top: 8px; align-items: center; }
.answer label { font-size: 13px; color: var(--muted); white-space: nowrap; }
.answer input {
  width: 110px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-family: var(--mono);
}
.answer input:focus { outline: 2px solid #b2f2bb; border-color: var(--brand); }
.answer .unit { color: var(--muted); font-size: 13px; }
.answer .btn { padding: 5px 12px; font-size: 13px; }
.fb { font-size: 12.5px; margin-top: 6px; }
.fb.bad { color: var(--warn); }
.fb.good { color: var(--ok); }
.hint-row { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.hint-row button { border: 1px solid var(--line); background: #fff; border-radius: 999px; font-size: 12px; padding: 2px 10px; color: var(--muted); }
.hint-row button:hover { color: var(--ink); }
.hint { font-size: 13px; color: #44505c; background: #fff8e6; border-radius: 8px; padding: 6px 9px; margin-top: 6px; }
.table-chip {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; border: 0; background: #edf4ff; color: #1864ab;
  border-radius: 8px; padding: 4px 10px; font-size: 12.5px;
}
.table-chip:hover { background: #dbe9ff; }
.points { margin: 0; padding-left: 18px; color: #3c4855; }
.points li { margin-bottom: 6px; }
.lock-note { background: #f1f4f7; border-radius: 10px; padding: 12px; color: var(--muted); font-size: 13px; }

/* 视频 / 资料缩略图 */
.media-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.media-item { border: 0; padding: 0; background: transparent; text-align: left; cursor: pointer; }
.media-item .thumb { position: relative; }
.media-item img { width: 100%; display: block; border-radius: 10px; border: 1px solid var(--line); background: #fff; }
.media-item .time {
  position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.72); color: #fff; font-size: 12px;
  border-radius: 6px; padding: 1px 7px; font-family: var(--mono);
}
.media-item .play {
  position: absolute; inset: 0; margin: auto; width: 46px; height: 46px; border-radius: 50%;
  background: rgba(255,255,255,.9); display: grid; place-items: center; font-size: 16px; color: var(--ink);
  box-shadow: 0 2px 10px rgba(0,0,0,.2);
}
.media-item p { margin: 5px 2px 0; font-size: 13px; color: #3c4855; }
.media-item small { color: var(--faint); font-size: 11.5px; display: block; margin: 0 2px; }
.docs-grid { grid-template-columns: 1fr 1fr; }
.docs-grid img { aspect-ratio: 3/4; object-fit: cover; object-position: top; }

/* 问 AI */
.tab-body.ask-mode { display: flex; overflow: hidden; padding-bottom: 0; }
.ask { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.ask-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 2px 2px 8px; scrollbar-width: thin; }
.msg { max-width: 92%; padding: 8px 12px; border-radius: 14px; font-size: 14px; line-height: 1.65; word-break: break-word; }
.msg.user { align-self: flex-end; background: var(--ink); color: #fff; border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: #f1f4f7; color: #26313c; border-bottom-left-radius: 4px; }
.msg.hello { background: #e7f5ea; color: var(--brand-ink); }
.msg.warn { background: #fff4e6; color: #9a4a0a; }
.cite {
  border: 0; background: #d0ebff; color: #1864ab; font-size: 11px; font-weight: 700; min-width: 17px; height: 17px;
  border-radius: 9px; padding: 0 4px; margin: 0 1px; vertical-align: 2px; line-height: 17px;
}
.cite:hover { background: #a5d8ff; }
.srcs { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; padding-top: 8px; border-top: 1px solid #dfe5ea; }
.src { border: 0; background: #fff; border-radius: 8px; padding: 4px 8px; text-align: left; font-size: 12.5px; color: #1864ab; display: flex; gap: 6px; align-items: baseline; }
.src:hover { background: #edf4ff; }
.src i { font-style: normal; font-weight: 700; color: #fff; background: #4dabf7; border-radius: 6px; padding: 0 5px; font-size: 11px; }
.thinking { color: var(--muted); }
.thinking i { font-style: normal; animation: blink 1.2s infinite; }
.thinking i:nth-child(2) { animation-delay: .2s; } .thinking i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 100% { opacity: .2; } 50% { opacity: 1; } }
.ask-sugg { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 0 8px; }
.ask-sugg button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 3px 10px; font-size: 12.5px; color: #3c4855; }
.ask-sugg button:hover { border-color: var(--brand); color: var(--brand-ink); }
.ask-input { display: flex; gap: 8px; align-items: flex-end; border-top: 1px solid var(--line); padding-top: 8px; }
.ask-input textarea {
  flex: 1; resize: none; border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; font: inherit; max-height: 120px;
}
.ask-input textarea:focus { outline: 2px solid #b2f2bb; border-color: var(--brand); }
.ask-input .btn { padding: 8px 16px; }
.ask-note { margin: 6px 0 4px; font-size: 11.5px; color: var(--faint); }
.hint-row .ask-link { border-color: #a5d8ff; color: #1864ab; }
.ask-fab {
  position: fixed; right: 16px; bottom: 64px; z-index: 12; border: 0; background: var(--ink); color: #fff; font-weight: 700;
  padding: 10px 16px; border-radius: 999px; box-shadow: var(--shadow); font-size: 14px;
}
.ask-fab:hover { background: #000; }
.ask-fab::before { content: "✦ "; color: #b2f2bb; }

/* 悬停提示 / 消息 */
.tip {
  position: fixed; z-index: 20; pointer-events: none; background: var(--ink); color: #fff; font-size: 12.5px;
  padding: 5px 10px; border-radius: 8px; white-space: nowrap; transform: translate(12px, 12px);
}
.tip b { color: #b2f2bb; font-weight: 600; }
.toast {
  position: fixed; left: 50%; top: 76px; transform: translateX(-50%); z-index: 30; background: var(--ink); color: #fff;
  padding: 9px 18px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow); animation: pop .25s ease;
}
@keyframes pop { from { opacity: 0; transform: translate(-50%, -6px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* 弹窗 */
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(16,22,30,.72); display: grid; place-items: center; padding: 24px; }
.modal-box { position: relative; max-width: min(1100px, 96vw); max-height: 92vh; display: flex; flex-direction: column; }
.modal-close { position: absolute; right: -8px; top: -8px; z-index: 2; background: #fff; }
.modal-body { overflow: auto; max-height: 84vh; border-radius: 12px; background: #fff; }
.modal-body img { display: block; max-width: 100%; height: auto; cursor: zoom-in; }
.modal-body img.zoom { max-width: none; cursor: zoom-out; }
.modal-body video { display: block; width: min(1000px, 92vw); max-height: 80vh; background: #000; }
.modal-cap { color: #e9edf1; margin: 10px 2px 0; font-size: 13px; }

/* ---------- 窄屏 / 手机 ---------- */
.chip-btn, .explode span { white-space: nowrap; }
@media (max-width: 820px) {
  body { overflow: auto; display: flex; flex-direction: column; min-height: 100%; height: auto; }
  #stage { position: relative; height: 58vh; flex: none; order: 0; }
  .dock { order: 1; } .route { order: 2; } .intro { order: 3; } .card { order: 4; }
  .topbar { position: absolute; top: 10px; left: 10px; right: 10px; flex-wrap: wrap; gap: 8px; }
  .brand-text small { display: none; }
  .topic { margin-left: auto; padding: 3px 6px 3px 10px; }
  .topic em { display: none; }
  .mode { order: 3; }
  .route {
    position: static; width: auto; flex-direction: row; overflow-x: auto; padding: 8px 12px; gap: 6px;
  }
  .layer { flex: none; }
  .layer ul { display: none !important; }
  .intro { position: static; margin: 4px 14px 24px; max-width: none; }
  .intro.hide { display: none; }
  .intro h1 { font-size: 22px; }
  .hero-strip figure { flex: 1; width: auto; }
  .dock { position: static; transform: none; align-self: center; margin: -26px 0 4px; padding: 4px 6px 4px 12px; }
  .explode input { width: 120px; }
  .progress { position: absolute; top: 52px; right: 10px; bottom: auto; }
  .card { position: static; width: auto; margin: 4px 10px 20px; max-height: none; }
  .tab-body { overflow: visible; }
  .tab-body.ask-mode { height: 70vh; }
  .ask-fab { bottom: 16px; }
  .modal { padding: 8px; }
}
