/* ── Claude Code 学习站 ── */
:root {
  --bg: #fafaf8;
  --bg-elev: #ffffff;
  --bg-soft: #f3f2ef;
  --border: #e9e6e0;
  --border-strong: #d8d3ca;
  --fg: #1a1a1a;
  --fg-muted: #5c5a55;
  --fg-dim: #8a877f;
  --brand: #d97757;
  --brand-soft: #f7ede4;
  --brand-fg: #9c4a2f;
  --accent: #2f6f5e;
  --code-bg: #1f1d1a;
  --code-fg: #f5f1ea;
  --code-inline-bg: #efebe3;
  --code-inline-fg: #5c2912;
  --shadow-sm: 0 1px 2px rgba(30, 25, 20, 0.05);
  --shadow-md: 0 8px 24px -12px rgba(30, 25, 20, 0.15);
  --radius: 12px;
  --sidebar-w: 300px;
}

[data-theme="dark"] {
  --bg: #17161a;
  --bg-elev: #1f1d22;
  --bg-soft: #252329;
  --border: #2e2b32;
  --border-strong: #3b3740;
  --fg: #f3f1ee;
  --fg-muted: #b6b2ac;
  --fg-dim: #7f7a73;
  --brand: #e89073;
  --brand-soft: #3a2420;
  --brand-fg: #f0a387;
  --accent: #6ac0a4;
  --code-bg: #0f0e10;
  --code-fg: #ececec;
  --code-inline-bg: #2c272e;
  --code-inline-fg: #f0a387;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px -10px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Source Han Sans CN", Inter, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.75;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

button { font-family: inherit; cursor: pointer; }

kbd {
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.85em;
}

/* ── Layout ── */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding-bottom: 8px;
}
.brand-logo {
  width: 34px; height: 34px;
  background: var(--brand);
  color: #fff;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 16px;
  box-shadow: var(--shadow-sm);
}
.brand-text { line-height: 1.2; }
.brand-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--fg);
}
.brand-sub {
  font-size: 12px;
  color: var(--fg-dim);
}

.progress-block {
  background: var(--bg-soft);
  border-radius: var(--radius);
  padding: 14px 14px 16px;
}
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--fg-muted);
  margin-bottom: 8px;
}
.progress-label strong { color: var(--fg); font-weight: 600; }
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), #e8a889);
  transition: width 0.4s ease;
}

.search-box {
  position: relative;
}
.search-box input {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid transparent;
  color: var(--fg);
  font-size: 13px;
  padding: 9px 12px 9px 32px;
  border-radius: 8px;
  outline: none;
  transition: all 0.15s;
}
.search-box input:focus {
  background: var(--bg-elev);
  border-color: var(--brand);
}
.search-box::before {
  content: "⌕";
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--fg-dim);
  font-size: 16px;
}

.nav-heading {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg-dim);
  margin: 4px 4px 4px;
  font-weight: 600;
}

.nav-chapter {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--fg-muted);
  cursor: pointer;
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
  transition: all 0.15s;
  margin-bottom: 2px;
}
.nav-chapter:hover { background: var(--bg-soft); color: var(--fg); }
.nav-chapter.active {
  background: var(--brand-soft);
  color: var(--brand-fg);
  font-weight: 600;
}
.nav-chapter-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.nav-chapter-code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  color: var(--fg-dim);
}
.nav-chapter.active .nav-chapter-code { color: var(--brand-fg); opacity: 0.7; }
.nav-chapter-title { flex: 1; line-height: 1.3; }
.nav-chapter-progress {
  font-size: 11px;
  color: var(--fg-dim);
}
.nav-chapter.active .nav-chapter-progress { color: var(--brand-fg); }

.nav-sections {
  margin: 4px 0 4px 8px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
  display: none;
}
.nav-chapter.active + .nav-sections { display: block; }

.nav-section {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  font-size: 12.5px;
  color: var(--fg-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.12s;
}
.nav-section:hover { color: var(--fg); background: var(--bg-soft); }
.nav-section.done { color: var(--fg-dim); }
.nav-section.active { color: var(--brand-fg); font-weight: 500; }
.nav-section-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--border-strong);
  flex-shrink: 0;
}
.nav-section.done .nav-section-dot { background: var(--accent); }
.nav-section.active .nav-section-dot { background: var(--brand); }

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--fg-dim);
}
.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-muted);
  width: 32px; height: 32px;
  border-radius: 8px;
  display: grid; place-items: center;
  transition: all 0.15s;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--fg); border-color: var(--border-strong); }

/* ── Main ── */
.main {
  min-width: 0;
  padding: 40px 48px 80px;
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
}

/* Home */
.home-hero {
  padding: 48px 0 32px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 36px;
}
.home-title {
  font-size: 30px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 12px;
}
.home-subtitle {
  font-size: 15.5px;
  color: var(--fg-muted);
  max-width: 620px;
  line-height: 1.7;
  margin: 0;
}
.home-cta {
  margin-top: 28px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: all 0.15s;
  cursor: pointer;
  text-decoration: none;
}
.btn-primary {
  background: var(--brand);
  color: #fff;
}
.btn-primary:hover { background: #c96443; text-decoration: none; }
.btn-ghost {
  background: transparent;
  color: var(--fg);
  border-color: var(--border-strong);
}
.btn-ghost:hover { background: var(--bg-soft); text-decoration: none; }

.home-meta {
  display: flex;
  gap: 24px;
  margin-top: 28px;
  font-size: 13px;
  color: var(--fg-dim);
}
.home-meta span strong { color: var(--fg); font-weight: 600; }

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.chapter-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  cursor: pointer;
  transition: all 0.18s;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
}
.chapter-card:hover {
  border-color: var(--brand);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.chapter-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chapter-code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  color: var(--fg-dim);
  letter-spacing: 0.05em;
}
.chapter-title {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
  margin: 0;
}
.chapter-subtitle {
  font-size: 13px;
  color: var(--fg-muted);
  line-height: 1.55;
}
.chapter-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  font-size: 12px;
  color: var(--fg-dim);
}
.mini-progress {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-right: 12px;
  overflow: hidden;
}
.mini-progress > div {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s;
}

/* Chapter view */
.chapter-header {
  padding: 36px 0 28px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 36px;
}
.chapter-header h1 {
  font-size: 34px;
  line-height: 1.2;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
  font-weight: 700;
}
.chapter-header .chapter-header-sub {
  font-size: 16px;
  color: var(--fg-muted);
  margin-bottom: 24px;
}
.chapter-hero {
  margin: 0;
  font-size: 15.5px;
  line-height: 1.7;
  color: var(--fg-muted);
}
.goals {
  margin-top: 24px;
}
.goals-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg-dim);
  font-weight: 600;
  margin-bottom: 10px;
}
.goals ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
}
.goals li {
  padding-left: 18px;
  position: relative;
  color: var(--fg-muted);
  font-size: 14px;
  line-height: 1.65;
}
.goals li::before {
  content: "·";
  position: absolute;
  left: 6px;
  top: 0;
  color: var(--fg-dim);
}

/* Sections */
.section {
  margin-bottom: 40px;
  scroll-margin-top: 20px;
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 18px 0 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.section-head h2 {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}
.section-head-left { flex: 1; min-width: 0; }

.read-toggle {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--fg-muted);
  padding: 7px 12px;
  border-radius: 7px;
  font-size: 12.5px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  transition: all 0.15s;
}
.read-toggle:hover { background: var(--bg-soft); color: var(--fg); }
.read-toggle.done {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Markdown body */
.md h3 { font-size: 17px; margin: 1.6em 0 0.6em; font-weight: 600; }
.md p { margin: 0.9em 0; color: var(--fg); }
.md strong { color: var(--fg); font-weight: 600; }
.md ul, .md ol { padding-left: 24px; margin: 0.9em 0; }
.md li { margin: 0.3em 0; }
.md li::marker { color: var(--fg-dim); }
.md blockquote {
  border-left: 2px solid var(--border-strong);
  color: var(--fg-muted);
  padding: 2px 16px;
  margin: 1.2em 0;
  font-size: 14.5px;
  line-height: 1.7;
}
.md blockquote p { margin: 0.3em 0; }
.md blockquote strong { color: var(--fg); }

.md code {
  background: var(--code-inline-bg);
  color: var(--code-inline-fg);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.88em;
  font-weight: 500;
}
.md pre {
  background: var(--code-bg);
  color: var(--code-fg);
  padding: 16px 18px;
  border-radius: 10px;
  overflow-x: auto;
  margin: 1.2em 0;
  font-size: 13px;
  line-height: 1.65;
  position: relative;
}
.md pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: inherit;
  font-weight: normal;
}
.md pre::-webkit-scrollbar { height: 6px; }
.md pre::-webkit-scrollbar-thumb { background: #3a3633; border-radius: 3px; }

.md table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.2em 0;
  font-size: 14px;
}
.md table th, .md table td {
  border: 1px solid var(--border);
  padding: 9px 14px;
  text-align: left;
}
.md table th {
  background: var(--bg-soft);
  font-weight: 600;
  color: var(--fg);
  font-size: 13px;
}
.md table code {
  font-size: 0.85em;
}

/* Copy code button — always visible, brightens on hover */
.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.85);
  border: 1px solid rgba(255,255,255,0.18);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 5px;
  opacity: 0.75;
  transition: all 0.15s;
  font-family: inherit;
  cursor: pointer;
  z-index: 1;
}
.md pre:hover .copy-btn,
.exercise-cmd:hover .copy-btn { opacity: 1; }
.copy-btn:hover { background: rgba(255,255,255,0.22); color: #fff; opacity: 1; }
.copy-btn.copied { background: var(--accent); color: #fff; border-color: var(--accent); opacity: 1; }

/* Exercises */
.exercises {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.exercises h2 {
  margin: 0 0 14px;
  font-size: 20px;
  font-weight: 700;
}
.exercise {
  display: flex;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  align-items: flex-start;
}
.exercise:first-of-type { border-top: none; }
.exercise-check {
  width: 22px; height: 22px;
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 1px;
  transition: all 0.15s;
  display: grid;
  place-items: center;
  background: var(--bg-elev);
}
.exercise-check:hover { border-color: var(--brand); }
.exercise.done .exercise-check {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.exercise.done .exercise-check::after { content: "✓"; font-size: 12px; }
.exercise-body { flex: 1; min-width: 0; }
.exercise-title {
  font-size: 14.5px;
  color: var(--fg);
  line-height: 1.55;
}
.exercise.done .exercise-title {
  text-decoration: line-through;
  color: var(--fg-dim);
}
.exercise-cmd {
  background: var(--code-bg);
  color: var(--code-fg);
  padding: 12px 14px;
  border-radius: 8px;
  margin: 6px 0 0;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.65;
  white-space: pre;
  overflow-x: auto;
  position: relative;
}
.exercise-cmd code { font-family: inherit; color: inherit; background: transparent; padding: 0; }
.exercise-cmd::-webkit-scrollbar { height: 6px; }
.exercise-cmd::-webkit-scrollbar-thumb { background: #3a3633; border-radius: 3px; }

.install {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.install-desc {
  color: var(--fg-muted);
  font-size: 13.5px;
  margin: 0;
  line-height: 1.6;
}
.install-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.install-label {
  font-size: 12px;
  color: var(--fg-muted);
  font-weight: 600;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.install-files {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
}
.install-files li {
  font-size: 13px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--fg-muted);
  line-height: 1.5;
}
.install-files code {
  background: var(--code-inline-bg);
  color: var(--code-inline-fg);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.88em;
}
.dl-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--brand-soft);
  color: var(--brand-fg) !important;
  padding: 3px 10px;
  border-radius: 5px;
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: none !important;
  border: 1px solid transparent;
  transition: all 0.15s;
}
.dl-link:hover {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff !important;
}
.dl-arrow { color: var(--fg-dim); font-size: 12px; }
.install-manual {
  margin: 0;
  padding-left: 22px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px 12px 34px;
  color: var(--fg-muted);
  font-size: 13.5px;
  line-height: 1.65;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.install-manual li::marker { color: var(--fg-dim); font-variant-numeric: tabular-nums; }
.install-manual li { padding-left: 2px; }

/* Key takeaway — plain, no accent card */
.takeaway {
  margin: 40px 0 0;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.takeaway-label {
  font-size: 13px;
  color: var(--fg-dim);
  font-weight: 500;
  margin-bottom: 6px;
}
.takeaway-text {
  font-size: 15px;
  line-height: 1.75;
  color: var(--fg);
}

/* Notes */
.notes-block {
  margin-top: 36px;
  padding: 20px;
  background: var(--bg-elev);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}
.notes-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg-dim);
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
}
.notes-saved { color: var(--accent); font-weight: 500; letter-spacing: 0; text-transform: none; font-size: 11px; }
.notes-block textarea {
  width: 100%;
  min-height: 110px;
  border: none;
  background: transparent;
  resize: vertical;
  font-family: inherit;
  font-size: 14px;
  color: var(--fg);
  line-height: 1.6;
  outline: none;
}
.notes-block textarea::placeholder { color: var(--fg-dim); }

/* Chapter nav buttons */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.chapter-nav-btn {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 20px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 180px;
  max-width: 48%;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}
.chapter-nav-btn:hover { border-color: var(--brand); background: var(--brand-soft); }
.chapter-nav-btn.next { margin-left: auto; text-align: right; }
.chapter-nav-btn .nav-dir {
  font-size: 11px;
  color: var(--fg-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.chapter-nav-btn .nav-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
}

/* Search results */
.search-results {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 6px;
  max-height: 60vh;
  overflow-y: auto;
  z-index: 30;
  padding: 6px;
  display: none;
}
.search-results.show { display: block; }
.search-result {
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
}
.search-result:hover { background: var(--bg-soft); }
.search-result-title {
  font-size: 13px;
  color: var(--fg);
  font-weight: 500;
}
.search-result-ctx {
  font-size: 12px;
  color: var(--fg-dim);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-result mark {
  background: var(--brand-soft);
  color: var(--brand-fg);
  padding: 0 2px;
  border-radius: 2px;
}

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--fg-dim);
  font-size: 13px;
}

/* ── Live learners badge ── */
.learners-badge {
  position: fixed;
  top: 18px;
  right: 22px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px 6px 12px;
  font-size: 12.5px;
  color: var(--fg-muted);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 7px;
  box-shadow: var(--shadow-sm);
  user-select: none;
}
.learners-badge strong {
  color: var(--fg);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.learners-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3fa05a;
  box-shadow: 0 0 0 0 rgba(63, 160, 90, 0.5);
  animation: learners-pulse 2s infinite;
  flex-shrink: 0;
}
@keyframes learners-pulse {
  0% { box-shadow: 0 0 0 0 rgba(63, 160, 90, 0.45); }
  70% { box-shadow: 0 0 0 8px rgba(63, 160, 90, 0); }
  100% { box-shadow: 0 0 0 0 rgba(63, 160, 90, 0); }
}
@media (max-width: 900px) {
  .learners-badge {
    top: 12px;
    right: 12px;
    font-size: 11.5px;
    padding: 5px 11px 5px 10px;
  }
}

/* ── Floating notebook ── */
.book-btn {
  position: fixed;
  right: 22px;
  bottom: 28px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--fg);
  color: var(--bg);
  border: none;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 18px -4px rgba(30, 25, 20, 0.35);
  z-index: 45;
  transition: transform 0.15s, background 0.15s;
}
.book-btn:hover { transform: translateY(-2px); }
.book-btn.has-draft::after {
  content: "";
  position: absolute;
  top: 8px; right: 8px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid var(--bg);
}

.notebook-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 48;
}
.notebook-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.notebook-drawer {
  position: fixed;
  right: 0; top: 0; bottom: 0;
  width: 440px;
  max-width: 92vw;
  background: var(--bg-elev);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 32px -12px rgba(30, 25, 20, 0.18);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 49;
  display: flex;
  flex-direction: column;
}
.notebook-drawer.open { transform: translateX(0); }

.nb-head {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.nb-head-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.nb-title {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.nb-close {
  background: transparent;
  border: none;
  color: var(--fg-muted);
  font-size: 20px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 6px;
}
.nb-close:hover { background: var(--bg-soft); color: var(--fg); }
.nb-context {
  font-size: 12.5px;
  color: var(--fg-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.nb-context-chip {
  background: var(--bg-soft);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11.5px;
  color: var(--fg);
}

.nb-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.nb-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.nb-editor textarea {
  width: 100%;
  min-height: 140px;
  resize: vertical;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
  border-radius: 8px;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.65;
  outline: none;
  transition: border-color 0.15s;
}
.nb-editor textarea:focus { border-color: var(--brand); }
.nb-editor-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--fg-dim);
}
.nb-save {
  background: var(--fg);
  color: var(--bg);
  border: none;
  padding: 7px 16px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  transition: opacity 0.15s;
}
.nb-save:disabled { opacity: 0.4; cursor: not-allowed; }
.nb-saved-flash {
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.2s;
}
.nb-saved-flash.show { opacity: 1; }

.nb-list-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-dim);
  font-weight: 600;
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.nb-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.nb-note {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}
.nb-note-meta {
  font-size: 11.5px;
  color: var(--fg-dim);
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.nb-note-text {
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--fg);
}
.nb-note-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  font-size: 11.5px;
}
.nb-note-actions button {
  background: transparent;
  border: none;
  color: var(--fg-dim);
  padding: 0;
  font-size: inherit;
}
.nb-note-actions button:hover { color: var(--fg); text-decoration: underline; }
.nb-empty {
  color: var(--fg-dim);
  font-size: 13px;
  text-align: center;
  padding: 20px 0;
}

/* ── Notes page ── */
.notes-page-hero {
  padding: 40px 0 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}
.notes-page-hero h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
}
.notes-page-hero p {
  color: var(--fg-muted);
  font-size: 14.5px;
  margin: 0;
}

.heatmap-card {
  margin-bottom: 36px;
}
.heatmap-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
}
.heatmap-head h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}
.heatmap-summary {
  font-size: 12.5px;
  color: var(--fg-muted);
}
.heatmap-summary strong { color: var(--fg); font-weight: 600; }

.heatmap-wrap {
  overflow-x: auto;
  padding-bottom: 6px;
}
.heatmap {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 11px);
  grid-auto-columns: 11px;
  gap: 3px;
  width: max-content;
}
.heat-cell {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  cursor: default;
  transition: outline 0.1s;
}
.heat-cell:hover { outline: 1px solid var(--fg-muted); }
.heat-cell.empty { visibility: hidden; }
.heat-cell[data-l="1"] { background: #d7ecd5; border-color: #c0dcbc; }
.heat-cell[data-l="2"] { background: #8fcf90; border-color: #7ac17b; }
.heat-cell[data-l="3"] { background: #46a257; border-color: #3e9150; }
.heat-cell[data-l="4"] { background: #1d6b33; border-color: #17582a; }
[data-theme="dark"] .heat-cell { background: #1e1c21; border-color: #2b282f; }
[data-theme="dark"] .heat-cell[data-l="1"] { background: #1d3b2a; border-color: #264c36; }
[data-theme="dark"] .heat-cell[data-l="2"] { background: #286d3b; border-color: #2f7e45; }
[data-theme="dark"] .heat-cell[data-l="3"] { background: #3fa05a; border-color: #45b065; }
[data-theme="dark"] .heat-cell[data-l="4"] { background: #60d37e; border-color: #6cdd88; }

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  justify-content: flex-end;
  font-size: 11px;
  color: var(--fg-dim);
}
.heatmap-legend .heat-cell { cursor: default; }

.notes-page-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.notes-group {
  margin-bottom: 24px;
}
.notes-group-head {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg-dim);
  font-weight: 600;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.notes-page-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--fg-dim);
  font-size: 14px;
}

.nav-link {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--fg-muted);
  cursor: pointer;
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
  transition: all 0.15s;
  margin-bottom: 2px;
  text-decoration: none;
}
.nav-link:hover { background: var(--bg-soft); color: var(--fg); text-decoration: none; }
.nav-link.active { background: var(--brand-soft); color: var(--brand-fg); font-weight: 600; }

/* Mobile */
.menu-btn { display: none; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: 88%;
    max-width: 320px;
    box-shadow: var(--shadow-md);
  }
  .sidebar.open { transform: translateX(0); }
  .main {
    padding: 24px 20px 60px;
  }
  .menu-btn {
    display: inline-flex;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 50;
    background: var(--brand);
    color: #fff;
    border: none;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    font-size: 22px;
    box-shadow: var(--shadow-md);
    align-items: center;
    justify-content: center;
  }
  .backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 35;
  }
  .backdrop.show { display: block; }
  .home-title { font-size: 32px; }
  .chapter-header h1 { font-size: 26px; }
  .section-head h2 { font-size: 19px; }
  .chapter-nav-btn { max-width: 47%; }
  .book-btn { right: 82px; bottom: 22px; width: 44px; height: 44px; }
  .notebook-drawer { width: 100vw; max-width: none; }
}
