/* ==========================================================================
   商业知识树 — 视觉系统
   深色画布（沿用源文件 #0E1117），六支配色即分支色，刻度盘为签名元素
   ========================================================================== */

:root {
  /* 底色层 */
  --ink-0: #0B0E14;   /* 画布最底 */
  --ink-1: #111621;   /* 面板 */
  --ink-2: #171E2B;   /* 卡片 / 悬浮 */
  --ink-3: #212A3B;   /* 描边 */
  --ink-4: #2E3A4F;   /* 强描边 */

  /* 文字层 */
  --fg-0: #F2F5F9;    /* 主标题 */
  --fg-1: #C3CDDC;    /* 正文 */
  --fg-2: #8A96AB;    /* 次要 */
  --fg-3: #5E6A80;    /* 提示 */

  /* 六支分支色（源自源文件 markmap colorFreezeLevel 配色） */
  --m1: #7FB2C9;
  --m2: #8E9ED6;
  --m3: #B197CE;
  --m4: #87B67F;
  --m5: #D6A85E;
  --m6: #CE8B85;

  --accent: var(--m1);

  /* 字体：优先 Google Fonts，加载失败时用本机中文字体兜底（国内网络友好） */
  --font-display: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "SimSun", "STSong", serif;
  --font-num: "Barlow Condensed", "Bahnschrift", "DIN Alternate", "Segoe UI", sans-serif;
  --font-body: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", -apple-system, "Segoe UI", sans-serif;

  /* 三级宽度：桌面横向展开 */
  --col-0: 400px;
  --col-1: 392px;
  --col-2: 1fr;

  --ease: cubic-bezier(.22, .61, .36, 1);
  --dur: .46s;

  --topbar-h: 56px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ink-0);
  color: var(--fg-1);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  /* 极轻的网格，暗示"树/坐标系"而非装饰 */
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(122, 145, 180, .045) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(122, 145, 180, .045) 1px, transparent 1px);
  background-size: 56px 56px;
  pointer-events: none;
  z-index: 0;
}

button { font-family: inherit; color: inherit; cursor: pointer; border: 0; background: none; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

/* ===================== 顶栏 ===================== */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  background: linear-gradient(to bottom, rgba(11, 14, 20, .96) 55%, rgba(11, 14, 20, .72));
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--ink-3);
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 8px 5px 4px;
  border-radius: 6px;
  color: var(--fg-1);
  flex: none;
  transition: color .2s;
}
.brand:hover { color: var(--fg-0); }

.brand-mark { display: grid; place-items: center; color: var(--fg-2); transition: color .2s; }
.brand:hover .brand-mark { color: var(--accent); }

.brand-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .06em;
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
  font-size: 12.5px;
  color: var(--fg-3);
}
.crumb {
  white-space: nowrap;
  padding: 3px 7px;
  border-radius: 5px;
  color: var(--fg-2);
  transition: background .18s, color .18s;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 26ch;
}
.crumb:hover { background: var(--ink-2); color: var(--fg-0); }
.crumb.is-current { color: var(--fg-0); font-weight: 500; }
.crumb-sep { color: var(--ink-4); flex: none; }

.topbar-tools { display: flex; align-items: center; gap: 10px; flex: none; }

.counter {
  font-family: var(--font-num);
  font-size: 13px;
  letter-spacing: .1em;
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border-radius: 6px;
  color: var(--fg-2);
  border: 1px solid transparent;
  transition: all .2s;
}
.icon-btn:hover { color: var(--fg-0); background: var(--ink-2); border-color: var(--ink-3); }

/* ===================== 舞台三列 ===================== */

.stage {
  position: relative;
  z-index: 1;
  height: 100dvh;
  padding-top: var(--topbar-h);
  display: grid;
  grid-template-columns: var(--col-0) var(--col-1) var(--col-2);
  transition: grid-template-columns var(--dur) var(--ease);
}

/* 首页未选模块时：第一列铺满 */
.stage[data-step="0"] {
  grid-template-columns: 1fr 0px 0px;
}
/* 选了模块但未选知识点：列表列占剩余宽度，但限制最大宽度避免过散 */
.stage[data-step="1"] {
  grid-template-columns: var(--col-0) minmax(0, 1fr) 0px;
}
.stage[data-step="1"] .panel-l1 { max-width: 560px; }

.panel {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border-right: 1px solid var(--ink-3);
}
.panel:last-child { border-right: 0; }

/* 收起态的列整体淡出 */
.stage[data-step="0"] .panel-l1,
.stage[data-step="0"] .panel-l2,
.stage[data-step="1"] .panel-l2 {
  opacity: 0;
  pointer-events: none;
}

.panel-l1, .panel-l2 {
  opacity: 1;
  transition: opacity .3s var(--ease);
}

.stage[data-step="0"] .panel-l1,
.stage[data-step="0"] .panel-l2 { display: none; }
.stage[data-step="1"] .panel-l2 { display: none; }

/* ===================== 封面（第一列） ===================== */

.panel-l0 { background: linear-gradient(170deg, #0D1119 0%, #0B0E14 60%); }

.cover {
  height: 100%;
  overflow-y: auto;
  padding: clamp(24px, 3.4vh, 40px) clamp(24px, 4vw, 48px) 32px;
  display: flex;
  flex-direction: column;
}

.cover-kicker {
  margin: 0 0 16px;
  font-family: var(--font-num);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .34em;
  text-transform: uppercase;
  color: var(--fg-3);
}

/* 标题与刻度盘并排：把纵向空间省给模块入口 */
.cover-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: clamp(16px, 3vw, 34px);
}
.cover-copy { min-width: 0; }

.cover-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(38px, 4.6vw, 56px);
  line-height: 1.06;
  letter-spacing: .03em;
  color: var(--fg-0);
}
.cover-title::after {
  content: "";
  display: block;
  width: 46px;
  height: 3px;
  margin-top: 18px;
  background: var(--accent);
  transition: background .5s;
}

.cover-sub {
  margin: 16px 0 0;
  font-size: 13px;
  line-height: 1.8;
  color: var(--fg-2);
}

/* --- 刻度盘：签名元素 --- */
.dial-wrap {
  flex: none;
  display: grid;
  place-items: center;
  padding-top: 4px;
}

.dial { width: clamp(124px, 11vw, 158px); height: auto; }

.dial .tick { transition: fill .3s, opacity .3s; }
.dial-num {
  font-family: var(--font-num);
  font-size: 40px;
  font-weight: 600;
  fill: var(--fg-0);
  letter-spacing: .02em;
}
.dial-cap {
  font-family: var(--font-body);
  font-size: 9px;
  fill: var(--fg-3);
  letter-spacing: .18em;
}

.cover-legend {
  display: grid;
  gap: 1px;
  margin-top: auto;
  padding-top: 18px;
}

/* ===================== 模块条目（可点击行） ===================== */

.mrow {
  position: relative;
  display: grid;
  grid-template-columns: 30px 1fr auto auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px 9px 6px;
  border-radius: 7px;
  text-align: left;
  color: var(--fg-1);
  transition: background .2s var(--ease), color .2s;
}
.mrow::before {
  content: "";
  position: absolute;
  left: -18px; top: 50%;
  width: 8px; height: 1px;
  background: var(--mrow-c, var(--ink-4));
  opacity: .8;
}
.mrow:hover { background: var(--ink-2); }
.mrow[aria-selected="true"] { background: var(--ink-2); }
.mrow[aria-selected="true"] .mrow-name { color: var(--fg-0); }

.mrow-num {
  font-family: var(--font-num);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--mrow-c);
  text-align: center;
  opacity: .9;
}

.mrow-name {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: .02em;
  color: var(--fg-1);
  transition: color .2s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mrow-count {
  font-family: var(--font-num);
  font-size: 12px;
  letter-spacing: .08em;
  color: var(--fg-3);
}
.mrow-arrow { color: var(--ink-4); transition: transform .2s, color .2s; display: grid; place-items: center; }
.mrow:hover .mrow-arrow { color: var(--mrow-c); transform: translateX(2px); }

.cover-hint {
  margin: 22px 0 0;
  font-size: 11.5px;
  letter-spacing: .04em;
  color: var(--fg-3);
}

/* ===================== 第二列：知识点列表 ===================== */

.panel-l1 { background: var(--ink-1); display: flex; flex-direction: column; }

.panel-head {
  padding: 22px 20px 14px;
  border-bottom: 1px solid var(--ink-3);
  flex: none;
}
.panel-eyebrow {
  font-family: var(--font-num);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--p1-c, var(--accent));
}
.panel-title {
  margin: 6px 0 0;
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--fg-0);
}
.panel-note {
  margin: 7px 0 0;
  font-size: 12px;
  color: var(--fg-3);
  line-height: 1.6;
}

.nodelist {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px 40px;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-4) transparent;
}

.nrow {
  position: relative;
  display: grid;
  grid-template-columns: 34px 1fr 16px;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  padding: 10px 8px;
  border-radius: 6px;
  text-align: left;
  transition: background .18s var(--ease);
  animation: rowIn .34s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 14ms);
}
@keyframes rowIn {
  from { opacity: 0; transform: translateX(-7px); }
  to { opacity: 1; transform: none; }
}

.nrow::after {
  /* 分支连接线：从左侧竖直延伸出的短线 */
  content: "";
  position: absolute;
  left: 2px; top: 50%;
  width: 6px; height: 1px;
  background: var(--nrow-c, var(--ink-4));
  opacity: .55;
}

.nrow:hover { background: var(--ink-2); }
.nrow[aria-current="true"] { background: var(--ink-2); }
.nrow[aria-current="true"]::after { opacity: 1; width: 16px; }
.nrow[aria-current="true"] .nrow-name { color: var(--fg-0); font-weight: 600; }

.nrow-code {
  font-family: var(--font-num);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: .06em;
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
}
.nrow[aria-current="true"] .nrow-code { color: var(--nrow-c); }

.nrow-name {
  font-size: 13.5px;
  color: var(--fg-1);
  letter-spacing: .01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nrow-name small {
  display: block;
  margin-top: 3px;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--fg-3);
  white-space: normal;
  line-height: 1.5;
}

.nrow-arrow {
  align-self: center;
  color: var(--ink-4);
  display: grid;
  place-items: center;
  transition: transform .2s, color .2s;
}
.nrow:hover .nrow-arrow,
.nrow[aria-current="true"] .nrow-arrow {
  color: var(--nrow-c);
  transform: translateX(2px);
}

/* ===================== 第三列：图文详解 ===================== */

.panel-l2 { background: linear-gradient(160deg, #0E1320 0%, #0B0E14 55%); }

.detail {
  height: 100%;
  overflow-y: auto;
  padding: clamp(26px, 4vh, 44px) clamp(22px, 3.4vw, 52px) 72px;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-4) transparent;
}

.detail-inner {
  max-width: 620px;
  margin: 0 auto;
  animation: detailIn .44s var(--ease) both;
}
@keyframes detailIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.d-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 11.5px;
  letter-spacing: .12em;
  color: var(--fg-3);
  font-family: var(--font-num);
  text-transform: uppercase;
}
.d-module {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--d-c, var(--accent));
}
.d-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.d-sep { color: var(--ink-4); }

.d-code {
  font-family: var(--font-num);
  font-size: clamp(58px, 8vw, 92px);
  font-weight: 600;
  line-height: .92;
  letter-spacing: -.01em;
  color: transparent;
  -webkit-text-stroke: 1.4px var(--d-c, var(--accent));
  margin: 18px 0 2px;
  opacity: .92;
}

.d-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(26px, 3.4vw, 36px);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: .02em;
  color: var(--fg-0);
}

.d-lede {
  margin: 18px 0 0;
  padding-left: 16px;
  border-left: 2px solid var(--d-c, var(--accent));
  font-size: clamp(15px, 1.5vw, 17px);
  line-height: 1.95;
  color: var(--fg-1);
  letter-spacing: .01em;
}

/* --- 图文卡片：刻度位置图 --- */
.d-viz {
  margin: 34px 0 0;
  padding: 22px 20px 18px;
  border: 1px solid var(--ink-3);
  border-radius: 10px;
  background: linear-gradient(165deg, rgba(255,255,255,.022), rgba(255,255,255,0));
}
.d-viz-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 0 16px;
  font-family: var(--font-num);
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--fg-3);
}
.d-viz-label b { color: var(--d-c); font-weight: 600; }

.viz-dial { display: block; width: 100%; max-width: 300px; margin: 0 auto; }

/* --- 相关知识点 --- */
.d-related { margin: 40px 0 0; }
.d-related-h {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  font-size: 11px;
  font-family: var(--font-num);
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--fg-3);
}
.d-related-h::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--ink-3);
}
.rel-list { display: grid; gap: 2px; }

.rel {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 6px;
  text-align: left;
  transition: background .18s;
}
.rel:hover { background: var(--ink-2); }
.rel-code {
  font-family: var(--font-num);
  font-size: 12px;
  color: var(--fg-3);
  letter-spacing: .06em;
}
.rel-name { font-size: 13px; color: var(--fg-1); }
.rel:hover .rel-name { color: var(--fg-0); }
.rel-arrow { color: var(--ink-4); display: grid; place-items: center; }
.rel:hover .rel-arrow { color: var(--rel-c, var(--accent)); }

/* 上一个 / 下一个 */
.d-pager {
  display: flex;
  gap: 10px;
  margin: 34px 0 0;
  padding-top: 22px;
  border-top: 1px solid var(--ink-3);
}
.pager-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--ink-3);
  border-radius: 8px;
  text-align: left;
  transition: border-color .2s, background .2s;
  min-width: 0;
}
.pager-btn:hover { border-color: var(--ink-4); background: var(--ink-2); }
.pager-btn[disabled] { opacity: .35; pointer-events: none; }
.pager-btn.next { text-align: right; align-items: flex-end; }
.pager-cap {
  font-family: var(--font-num);
  font-size: 10.5px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--fg-3);
}
.pager-name {
  font-size: 13px;
  line-height: 1.45;
  color: var(--fg-1);
  max-width: 100%;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

/* 空态 */
.empty {
  height: 100%;
  display: grid;
  place-content: center;
  gap: 12px;
  text-align: center;
  padding: 40px;
}
.empty-title {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--fg-2);
}
.empty-note { font-size: 13px; color: var(--fg-3); line-height: 1.8; }

/* ===================== 移动端返回 / 抽屉 ===================== */

.back-btn {
  position: fixed;
  left: 12px;
  bottom: calc(14px + env(safe-area-inset-bottom));
  display: none;
  align-items: center;
  gap: 4px;
  padding: 9px 14px 9px 10px;
  border-radius: 999px;
  background: rgba(23, 30, 43, .92);
  border: 1px solid var(--ink-4);
  backdrop-filter: blur(12px);
  color: var(--fg-1);
  font-size: 12.5px;
  z-index: 45;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .45);
}

.sheet-scrim {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 11, .62);
  backdrop-filter: blur(2px);
  z-index: 50;
  animation: fadeIn .22s ease both;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 51;
  max-height: 76dvh;
  overflow-y: auto;
  padding: 10px 14px calc(24px + env(safe-area-inset-bottom));
  background: var(--ink-1);
  border-top: 1px solid var(--ink-4);
  border-radius: 14px 14px 0 0;
  animation: sheetUp .28s var(--ease) both;
}
@keyframes sheetUp { from { transform: translateY(100%) } to { transform: none } }

.sheet-handle {
  width: 34px; height: 3px;
  margin: 2px auto 12px;
  border-radius: 2px;
  background: var(--ink-4);
}
.sheet-title {
  margin: 0 0 8px;
  font-size: 11px;
  font-family: var(--font-num);
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--fg-3);
  text-align: center;
}
.sheet-list { display: grid; gap: 2px; }

/* ===================== 响应式 ===================== */

/* 中等宽度：三列压缩 */
@media (max-width: 1180px) {
  :root { --col-0: 330px; --col-1: 330px; }
  .cover-title { font-size: clamp(34px, 5vw, 46px); }
}

/* 窄屏 / 平板竖屏：改为逐层替换的栈式导航 */
@media (max-width: 860px) {
  :root { --topbar-h: 52px; }

  .stage,
  .stage[data-step="0"],
  .stage[data-step="1"] {
    display: block;
    position: relative;
    transition: none;
  }

  .panel {
    position: absolute;
    inset: 0;
    width: 100%;
    border-right: 0;
    border-left: 0;
    opacity: 1;
    display: none;
    transform: none;
  }

  /* 只有当前层显示 */
  .stage[data-step="0"] .panel-l0,
  .stage[data-step="1"] .panel-l1,
  .stage[data-step="2"] .panel-l2 { display: flex; animation: slideIn .34s var(--ease) both; }

  .stage[data-step="0"] .panel-l1,
  .stage[data-step="0"] .panel-l2,
  .stage[data-step="1"] .panel-l2 { display: none; opacity: 1; }

  @keyframes slideIn {
    from { opacity: 0; transform: translateX(22px); }
    to { opacity: 1; transform: none; }
  }

  .back-btn { display: inline-flex; }
  .stage[data-step="0"] ~ .back-btn,
  body[data-step="0"] .back-btn { display: none; }

  .detail { padding-bottom: 104px; }
  .nodelist { padding-bottom: 96px; }
  .cover { padding-bottom: 104px; }

  .cover-title { font-size: 44px; }
  .dial { width: 156px; }
  .d-code { font-size: 64px; }
  .crumbs { display: none; }
  .counter { display: none; }

  .mrow { grid-template-columns: 26px 1fr auto; padding: 12px 8px; }
  .mrow::before { display: none; }
  .nrow { padding: 12px 8px; grid-template-columns: 34px 1fr 16px; }
  .nrow::after { display: none; }
}

@media (max-width: 420px) {
  .cover-title { font-size: 38px; }
  .d-title { font-size: 25px; }
  .pager-btn { padding: 10px 11px; }
}

/* 极矮横屏（手机横放） */
@media (max-height: 520px) and (min-width: 700px) {
  .dial-wrap { display: none; }
}

/* ===================== 无障碍 ===================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-delay: 0ms !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
