/* ============================================================
   DeepSeek Harness 费曼教程 · 站点样式
   纯本地资源，无外部 CDN，可直接 file:// 打开
   ============================================================ */

:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef1f8;
  --ink: #1f2430;
  --ink-soft: #4a5266;
  --ink-faint: #7a8296;
  --line: #dde2ee;
  --line-strong: #c6cddd;
  --brand: #2f4bd6;
  --brand-deep: #2438a8;
  --brand-ink: #1c2c8a;
  --accent: #e8590c;
  --accent-soft: #fdf0e6;
  --ok: #1f8a4c;
  --ok-soft: #e9f7ef;
  --note: #0e7490;
  --note-soft: #e5f6fa;
  --warn: #b45309;
  --warn-soft: #fdf3e0;
  --code-bg: #232a3b;
  --code-ink: #dce4f3;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(31, 36, 48, .06), 0 8px 24px -12px rgba(31, 36, 48, .18);
  --shadow-lg: 0 2px 4px rgba(31, 36, 48, .08), 0 18px 40px -16px rgba(31, 36, 48, .28);
  --sidebar-w: 272px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16.5px;
  line-height: 1.75;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- 布局骨架 ---------- */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* ---------- 侧边栏 ---------- */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 22px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  padding: 4px 8px 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
}

.brand .logo {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), #7c5cff);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: .5px;
  box-shadow: 0 4px 10px -3px rgba(47, 75, 214, .5);
}

.brand .title { font-weight: 700; font-size: 15.5px; line-height: 1.3; }
.brand .subtitle { font-size: 12px; color: var(--ink-faint); font-weight: 500; }

.nav-label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--ink-faint);
  text-transform: uppercase;
  padding: 14px 8px 6px;
}

.nav a.nav-link {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.45;
  transition: background .12s ease, color .12s ease;
}

.nav a.nav-link:hover { background: var(--surface-2); color: var(--ink); }

.nav a.nav-link .no {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-faint);
  flex: none;
  width: 22px;
  text-align: right;
}

.nav a.nav-link.active {
  background: var(--brand);
  color: #fff;
  font-weight: 600;
}

.nav a.nav-link.active .no { color: #c9d4ff; }

.sidebar .side-foot {
  margin-top: auto;
  padding: 14px 8px 0;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-faint);
  line-height: 1.6;
}

/* ---------- 主内容 ---------- */

.main { min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 54px;
  padding: 0 28px;
  background: rgba(246, 247, 251, .86);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.topbar .menu-btn {
  display: none;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  font-size: 18px;
  cursor: pointer;
  color: var(--ink);
}

.topbar .crumbs { font-size: 13.5px; color: var(--ink-faint); }
.topbar .crumbs b { color: var(--ink); font-weight: 600; }

.progress {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--ink-faint);
  font-family: var(--mono);
}

.progress .bar {
  width: 120px;
  height: 6px;
  border-radius: 3px;
  background: var(--surface-2);
  overflow: hidden;
}

.progress .bar i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--brand), #7c5cff);
  border-radius: 3px;
  transition: width .3s ease;
}

article.content {
  max-width: 860px;
  margin: 0 auto;
  padding: 40px 40px 90px;
}

/* ---------- 章节头部 ---------- */

.ch-head { margin-bottom: 34px; }

.ch-head .kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--brand);
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 16px;
}

.ch-head h1 {
  font-size: 36px;
  line-height: 1.25;
  margin: 0 0 12px;
  letter-spacing: -.01em;
}

.ch-head .lede {
  font-size: 18px;
  color: var(--ink-soft);
  margin: 0;
  max-width: 640px;
}

/* ---------- 正文排版 ---------- */

h2 {
  font-size: 25px;
  margin: 44px 0 14px;
  padding-top: 8px;
  letter-spacing: -.01em;
  line-height: 1.35;
}

h2::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 22px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--brand), #7c5cff);
  margin-right: 10px;
  vertical-align: -3px;
}

h3 { font-size: 19.5px; margin: 32px 0 10px; line-height: 1.4; }

p { margin: 14px 0; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

strong { color: var(--ink); font-weight: 650; }

ul, ol { padding-left: 24px; margin: 14px 0; }
li { margin: 6px 0; }
li::marker { color: var(--brand); }

hr { border: 0; border-top: 1px solid var(--line); margin: 36px 0; }

/* 行内代码 */
code {
  font-family: var(--mono);
  font-size: .86em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: .12em .38em;
  color: var(--brand-deep);
}

/* 术语 */
.term {
  font-family: var(--mono);
  font-size: .9em;
  color: var(--brand-deep);
  font-weight: 600;
  white-space: nowrap;
}

/* ---------- 卡片 ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin: 20px 0;
  box-shadow: var(--shadow);
}

.card.analogy { border-left: 4px solid var(--accent); background: var(--accent-soft); }
.card.termbox { border-left: 4px solid var(--brand); background: #f1f4ff; }
.card.notebox { border-left: 4px solid var(--note); background: var(--note-soft); }
.card.warnbox { border-left: 4px solid var(--warn); background: var(--warn-soft); }
.card.checkbox { border-left: 4px solid var(--ok); background: var(--ok-soft); }

.card .card-title {
  font-weight: 700;
  font-size: 15px;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card .card-title .ic { font-size: 17px; }

/* 一句话讲清楚 */
.oneliner {
  font-size: 19px;
  font-weight: 650;
  color: var(--brand-deep);
  background: linear-gradient(135deg, #eef1ff, #f7f4ff);
  border: 1px solid #dbe2ff;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 22px 0;
  line-height: 1.6;
}

/* ---------- 图 ---------- */

figure.fig {
  margin: 26px 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

figure.fig svg, figure.fig img { display: block; width: 100%; height: auto; }

figure.fig figcaption {
  margin-top: 12px;
  font-size: 13.5px;
  color: var(--ink-faint);
  text-align: center;
  line-height: 1.6;
}

figure.fig figcaption b { color: var(--ink-soft); }

/* ---------- 代码块 ---------- */

.codeblock {
  position: relative;
  margin: 20px 0;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--code-bg);
}

.codeblock .cb-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, .05);
  border-bottom: 1px solid rgba(255, 255, 255, .09);
}

.codeblock .cb-lang {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .08em;
  color: #93a3c4;
  text-transform: uppercase;
}

.codeblock .cb-dot { width: 9px; height: 9px; border-radius: 50%; background: #ff5f57; }
.codeblock .cb-dot:nth-child(2) { background: #febc2e; }
.codeblock .cb-dot:nth-child(3) { background: #28c840; }

.codeblock .cb-copy {
  margin-left: auto;
  font-size: 12px;
  color: #b9c6e4;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 6px;
  padding: 3px 10px;
  cursor: pointer;
  font-family: var(--font);
  transition: background .12s ease;
}

.codeblock .cb-copy:hover { background: rgba(255, 255, 255, .16); color: #fff; }
.codeblock .cb-copy.copied { background: #1f8a4c; color: #fff; border-color: #1f8a4c; }

.codeblock pre {
  margin: 0;
  padding: 16px 18px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--code-ink);
}

.codeblock code { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; }

/* 轻量语法着色 */
.tok-k { color: #ff9ec7; }        /* 关键字 */
.tok-s { color: #a5e3a5; }        /* 字符串 */
.tok-c { color: #8a97b8; font-style: italic; } /* 注释 */
.tok-n { color: #ffd479; }        /* 数字 */
.tok-f { color: #82c8ff; }        /* 函数/方法 */
.tok-p { color: #c9d1e6; }        /* 属性/路径 */

/* ---------- 表格 ---------- */

.table-wrap { overflow-x: auto; margin: 20px 0; box-shadow: var(--shadow); border-radius: var(--radius); border: 1px solid var(--line); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
  background: var(--surface);
}

th, td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  background: var(--surface-2);
  font-weight: 650;
  color: var(--ink);
  white-space: nowrap;
}

tr:last-child td { border-bottom: 0; }

tbody tr:hover { background: #fafbfe; }

/* ---------- 费曼自查 ---------- */

.quiz-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  margin: 14px 0;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.quiz-item .q {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 18px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.quiz-item .q .qn {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--ok);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  margin-top: 2px;
}

.quiz-item .q .q-arrow {
  margin-left: auto;
  color: var(--ink-faint);
  transition: transform .15s ease;
  font-size: 13px;
}

.quiz-item.open .q .q-arrow { transform: rotate(90deg); }

.quiz-item .a {
  display: none;
  padding: 4px 18px 16px 56px;
  border-top: 1px dashed var(--line);
  color: var(--ink-soft);
  font-size: 15px;
}

.quiz-item.open .a { display: block; }

/* ---------- 章末导航 ---------- */

.ch-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 54px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}

.ch-nav a {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--ink);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}

.ch-nav a:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--brand);
  text-decoration: none;
}

.ch-nav a.next { text-align: right; }
.ch-nav .dir { font-size: 12px; color: var(--ink-faint); font-weight: 700; letter-spacing: .08em; }
.ch-nav .ttl { font-weight: 650; margin-top: 3px; }
.ch-nav a:hover .ttl { color: var(--brand); }

/* ---------- 首页 ---------- */

.hero {
  text-align: center;
  padding: 60px 24px 30px;
}

.hero .logo-big {
  width: 76px;
  height: 76px;
  margin: 0 auto 22px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--brand), #7c5cff);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 34px;
  font-weight: 800;
  box-shadow: 0 16px 40px -10px rgba(47, 75, 214, .55);
}

.hero h1 { font-size: 42px; margin: 0 0 14px; letter-spacing: -.02em; line-height: 1.2; }

.hero .lede {
  font-size: 19px;
  color: var(--ink-soft);
  max-width: 640px;
  margin: 0 auto;
  line-height: 1.7;
}

.hero .tags { margin-top: 22px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.tag {
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-soft);
}

.tag.hot { border-color: #ffd0b8; background: var(--accent-soft); color: var(--accent); }

.method-strip {
  max-width: 760px;
  margin: 40px auto 10px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.method-strip .m {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  box-shadow: var(--shadow);
}

.method-strip .m .ic { font-size: 24px; }
.method-strip .m .t { font-weight: 700; font-size: 14px; margin-top: 6px; }
.method-strip .m .d { font-size: 12.5px; color: var(--ink-faint); margin-top: 2px; line-height: 1.5; }

.chapter-grid {
  max-width: 860px;
  margin: 34px auto 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 0 24px 40px;
}

.chapter-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--ink);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}

.chapter-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--brand);
  text-decoration: none;
}

.chapter-card .cno {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: .08em;
}

.chapter-card h3 { margin: 8px 0 6px; font-size: 18px; }
.chapter-card p { margin: 0; font-size: 14px; color: var(--ink-soft); line-height: 1.6; }

/* ---------- 滚动偏移（锚点） ---------- */
[id] { scroll-margin-top: 70px; }

/* ---------- 移动端 ---------- */

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 50;
    transform: translateX(-102%);
    transition: transform .22s ease;
    width: min(320px, 86vw);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .topbar .menu-btn { display: grid; place-items: center; }
  article.content { padding: 28px 20px 70px; }
  .hero h1 { font-size: 32px; }
  .method-strip { grid-template-columns: repeat(2, 1fr); }
  .chapter-grid { grid-template-columns: 1fr; padding: 0 16px 30px; }
  .ch-nav { grid-template-columns: 1fr; }
  .ch-nav a.next { text-align: left; }
  .topbar .progress .bar { width: 70px; }
}

@media (max-width: 560px) {
  .quiz-item .a { padding-left: 18px; }
  .method-strip { grid-template-columns: 1fr 1fr; }
}
