:root {
  --brand: #94070a;
  --brand-700: #7d0608;
  --brand-50: #fdf3f3;
  --gray-50: #f8f6f4;
  --gray-100: #f1eeeb;
  --gray-200: #e6e1dd;
  --gray-500: #7d736c;
  --gray-700: #453e39;
  --gray-900: #1c1917;
  --sidebar-w: 248px;
  --topbar-h: 56px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --r: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  color: var(--gray-900);
  background: var(--gray-50);
  line-height: 1.65;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--brand-50);
  padding: 0.08em 0.32em;
  border-radius: 4px;
}
pre {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--gray-900);
  color: #f5f6f8;
  padding: 14px 16px;
  border-radius: 10px;
  overflow-x: auto;
  margin: 12px 0 0;
}
pre code { background: none; color: inherit; padding: 0; }

/* login */
.login-page {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  background:
    radial-gradient(1200px 400px at 50% -10%, rgba(148, 7, 10, 0.12), transparent 60%),
    var(--gray-50);
}
.login-card {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 20px;
  padding: 32px 28px 24px;
  box-shadow: 0 16px 40px rgba(28, 25, 23, 0.06);
}
.login-brand { font-size: 22px; font-weight: 800; color: var(--brand); }
.login-brand em { font-style: normal; color: var(--gray-900); }
.login-card h1 { font-size: 22px; margin: 16px 0 8px; }
.login-card .sub { color: var(--gray-500); font-size: 14px; margin-bottom: 20px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; font-weight: 700; color: var(--gray-500); margin-bottom: 4px; }
.field input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 0 12px;
  font: inherit;
  background: var(--gray-50);
  color: var(--gray-700);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  padding: 0 18px;
  border-radius: 10px;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  border: none;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand); color: #fff; width: 100%; margin-top: 8px; }
.btn-primary:hover { background: var(--brand-700); }
.btn-ghost { background: transparent; color: var(--gray-700); border: 1px solid var(--gray-200); }
.login-hint { margin-top: 16px; font-size: 12px; color: var(--gray-500); }

/* app shell */
.app { display: flex; min-height: 100%; }
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  padding: 16px 12px 20px;
  overflow-y: auto;
}
.brand {
  display: block;
  font-weight: 800;
  font-size: 18px;
  color: var(--brand);
  padding: 8px 10px 16px;
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand span { display: block; font-size: 12px; font-weight: 600; color: var(--gray-500); margin-top: 2px; }
.nav-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--gray-500);
  padding: 12px 10px 6px;
  text-transform: uppercase;
}
.sidebar nav a {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--gray-700);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.sidebar nav a:hover { background: var(--gray-100); }
.sidebar nav a.active { background: var(--brand-50); color: var(--brand); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--gray-200);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 12px;
}
.crumb { font-size: 13px; font-weight: 700; color: var(--gray-700); }
.badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-700);
  background: var(--gray-100);
  border-radius: 999px;
  padding: 6px 12px;
}
.content {
  flex: 1;
  padding: 28px 32px 40px;
  max-width: 920px;
}
.content h1 { font-size: 26px; margin-bottom: 8px; }
.content h2 { font-size: 18px; margin: 22px 0 8px; color: var(--brand); }
.content h3 { font-size: 15px; margin: 0 0 6px; color: var(--brand); }
.content p, .content li { font-size: 15px; }
.content p { margin: 8px 0; }
.content ul, .content ol { padding-left: 20px; margin: 8px 0; }
.content li { margin: 4px 0; }
.lead { color: var(--gray-500); margin-bottom: 16px; }
table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--r);
  overflow: hidden;
  font-size: 14px;
  margin: 12px 0 8px;
}
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--gray-200); vertical-align: top; }
th { background: var(--brand); color: #fff; font-size: 13px; }
tr:last-child td { border-bottom: none; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.tile {
  display: block;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--r);
  padding: 16px;
  color: inherit;
  text-decoration: none;
}
.tile:hover { border-color: var(--brand); text-decoration: none; }
.tile strong { display: block; color: var(--brand); margin-bottom: 6px; }
.tile span { font-size: 13px; color: var(--gray-500); }
.pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-200);
}
.note {
  background: var(--brand-50);
  border-left: 3px solid var(--brand);
  padding: 10px 14px;
  border-radius: 0 10px 10px 0;
  margin: 14px 0;
  font-size: 14px;
}
.kp { margin: 8px 0 4px; }
.kp-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--r);
  padding: 14px 16px;
  margin: 10px 0;
}
.kp-card p { color: var(--gray-700); }
.think {
  background: #fff;
  border: 1px dashed var(--brand);
  border-radius: var(--r);
  padding: 12px 16px;
  margin: 18px 0 8px;
}
.alts { margin: 18px 0 8px; }

/* 核对清单（每个部分的实现方案核对表） */
.check { margin: 20px 0 8px; }
.check-intro { color: var(--gray-500); font-size: 14px; margin: 8px 0 10px; }
.check-table th:nth-child(1), .check-table td:nth-child(1) { width: 26%; }
.check-table th:nth-child(2), .check-table td:nth-child(2) { width: 26%; }
.check-table th:last-child, .check-table td:last-child { width: 46px; text-align: center; }
.check-table td:first-child { font-weight: 600; color: var(--gray-900); }
.check-table td.tick { text-align: center; }
.check-table td.tick .cb {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--brand);
  border-radius: 3px;
  vertical-align: -2px;
}
.check-table b { color: var(--brand); font-weight: 700; }
.sub-h { font-size: 13px; font-weight: 600; color: var(--gray-500); }

/* 学习节奏 */
.flow {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 14px 0 10px;
}
.flow-step {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 12px 14px;
}
.flow-step b { display: block; color: var(--brand); font-size: 14px; }
.flow-step span { font-size: 13px; color: var(--gray-500); }
.flow-step code { overflow-wrap: anywhere; }

/* 总表页的步骤小节 */
.step-h {
  font-size: 15px;
  margin: 20px 0 6px;
  padding-top: 12px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.step-h .jump { margin-left: auto; font-size: 12px; font-weight: 600; }

/* 步骤单元：把知识点、方案取舍、核对与动手聚合在一处 */
.note.howto {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-left: 3px solid var(--brand);
  color: var(--gray-700);
}
.steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 18px;
}
.steps-h {
  width: 100%;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--gray-500);
  margin: 0;
}
.steps a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 999px;
  padding: 5px 14px 5px 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  text-decoration: none;
}
.steps a:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.steps-n {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--brand-50);
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
}
.unit {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 16px;
  padding: 18px 22px 16px;
  margin: 18px 0;
}
.content .unit-h {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 19px;
  color: var(--gray-900);
  margin: 0 0 6px;
}
.unit-n {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
}
.unit-lead { color: var(--gray-500); font-size: 14px; margin: 0 0 10px; }
.content .unit-sub {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--brand);
  margin: 16px 0 8px;
  padding-left: 9px;
  border-left: 3px solid var(--brand);
  display: block;
}
.unit .kp-card { background: var(--gray-50); margin: 8px 0; }
.unit table { margin: 10px 0 6px; }
.unit ul, .unit ol { margin: 6px 0 4px; }
.unit .note { margin: 10px 0; }
@media print {
  .steps { display: none; }
  .unit { break-inside: avoid; page-break-inside: avoid; }
}
.menu-btn {
  display: none;
  border: 1px solid var(--gray-200);
  background: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  font: inherit;
  font-weight: 700;
}
@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    z-index: 30;
    inset: 0 auto 0 0;
    transform: translateX(-100%);
    transition: transform 0.2s;
  }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .content { padding: 20px 16px 32px; }
}

/* 右侧小节索引（本页目录），宽屏常驻并随滚动高亮 */
.doc { display: flex; align-items: flex-start; flex: 1; min-width: 0; }
.doc > .content { flex: 1 1 auto; min-width: 0; }
.toc { display: none; }
.toc-h {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--gray-500);
  margin: 0 0 6px;
  padding-left: 11px;
  text-transform: uppercase;
}
.toc-list { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--gray-200); }
.toc-l1 > a {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 10px;
  margin-left: -1px;
  border-left: 2px solid transparent;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--gray-500);
  text-decoration: none;
}
.toc-l1 > a:hover { color: var(--brand); text-decoration: none; }
.toc-n { flex: 0 0 auto; font-size: 11px; font-weight: 800; }
.toc-t { min-width: 0; }
.toc-l1.current > a {
  color: var(--brand);
  border-left-color: var(--brand);
  background: var(--brand-50);
  border-radius: 0 6px 6px 0;
}
.toc-sub { list-style: none; margin: 2px 0 8px; padding: 0 0 0 12px; display: none; }
.toc-l1.current > .toc-sub { display: block; }
.toc-sub a {
  display: block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
  color: var(--gray-500);
  text-decoration: none;
}
.toc-sub a:hover { color: var(--brand); background: var(--gray-100); text-decoration: none; }
.toc-sub a.on { color: var(--brand); font-weight: 700; }
@media (min-width: 1200px) {
  .toc {
    display: block;
    flex: 0 0 224px;
    position: sticky;
    top: calc(var(--topbar-h) + 20px);
    margin: 28px 24px 40px 0;
    max-height: calc(100vh - var(--topbar-h) - 48px);
    overflow-y: auto;
  }
  /* 宽屏下右侧目录已承担小节索引，顶部胶囊隐藏，避免重复 */
  .steps { display: none; }
}
/* 示意图 */
.fig { margin: 14px 0 6px; }
.fig svg {
  width: 100%; height: auto; display: block;
  background: #fff; border: 1px solid var(--gray-200); border-radius: var(--r);
}
.fig figcaption { font-size: 12px; color: var(--gray-500); margin-top: 6px; }
@media print { .fig svg { border-color: #999; } }

/* 向 Harness 核对的参考提问 */
.ask {
  background: #fff;
  border: 1px dashed var(--gray-200);
  border-radius: var(--r);
  padding: 12px 16px;
  margin: 10px 0;
  font-size: 14px;
}
.ask .ask-h { color: var(--gray-500); font-size: 13px; margin: 0 0 8px; }
.ask ol { margin: 0; padding-left: 22px; }
.ask li { margin: 6px 0; color: var(--gray-700); }
.ask li::marker { color: var(--brand); font-weight: 600; }

@media print {
  .toc { display: none !important; }
}
