/* =========================================================
   静读 · a zero-backend Markdown reader
   Palette: warm paper, cinnabar accent, quiet ink.
   ========================================================= */

:root {
  --bg: #f3efe5;
  --paper: #fbf8f1;
  --paper-raised: #fffdf8;
  --sidebar: #ece5d8;
  --ink: #292720;
  --ink-soft: #575247;
  --muted: #8b8171;
  --faint: #a79c89;
  --line: #ddd4c3;
  --line-strong: #c9bda9;
  --accent: #b1462f;
  --accent-hover: #943722;
  --accent-soft: rgba(177, 70, 47, 0.1);
  --accent-softer: rgba(177, 70, 47, 0.055);
  --gold: #9a7432;
  --code-bg: #24221d;
  --code-head: #302d26;
  --code-ink: #f0e9db;
  --code-muted: #a99f8d;
  --shadow-sm: 0 1px 2px rgba(45, 37, 25, 0.06);
  --shadow-lg: 0 24px 70px rgba(45, 37, 25, 0.18);
  --focus: 0 0 0 3px rgba(177, 70, 47, 0.22);
  --sidebar-width: 304px;
  --topbar-height: 64px;
  --font-ui: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", "Songti SC", "STSong", Georgia, serif;
  --font-mono: "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #131311;
  --paper: #1b1b18;
  --paper-raised: #22221e;
  --sidebar: #171714;
  --ink: #eae4d8;
  --ink-soft: #bcb3a3;
  --muted: #8e8576;
  --faint: #6e675b;
  --line: #302e28;
  --line-strong: #454137;
  --accent: #df8063;
  --accent-hover: #ee967a;
  --accent-soft: rgba(223, 128, 99, 0.12);
  --accent-softer: rgba(223, 128, 99, 0.06);
  --gold: #d0a75e;
  --code-bg: #0f0f0d;
  --code-head: #171714;
  --code-ink: #eee6d7;
  --code-muted: #938a7a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.5);
  --focus: 0 0 0 3px rgba(223, 128, 99, 0.25);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

::selection {
  background: var(--accent-soft);
  color: var(--ink);
}

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

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 1.15em;
  height: 1.15em;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 10px;
  left: 10px;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  font-size: 13px;
  transform: translateY(-160%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.reading-progress {
  position: fixed;
  z-index: 60;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  pointer-events: none;
}

.reading-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 80ms linear;
}

/* ---------------------------------------------------------
   Shell & sidebar
   --------------------------------------------------------- */

.app-shell {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.sidebar {
  position: relative;
  z-index: 40;
  display: flex;
  flex: 0 0 var(--sidebar-width);
  flex-direction: column;
  width: var(--sidebar-width);
  height: 100%;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background:
    radial-gradient(circle at 14% 12%, rgba(255, 255, 255, 0.24), transparent 38%),
    var(--sidebar);
}

html[data-theme="dark"] .sidebar {
  background:
    radial-gradient(circle at 14% 12%, rgba(255, 255, 255, 0.025), transparent 38%),
    var(--sidebar);
}

.sidebar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 27px 24px 0;
}

.brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  flex: 0 0 38px;
  width: 38px;
  height: 44px;
  place-items: center;
  border-radius: 3px 3px 9px 3px;
  background: var(--accent);
  color: #fbf3e8;
  font-family: var(--font-display);
  font-size: 24px;
  line-height: 1;
  box-shadow: 3px 3px 0 color-mix(in srgb, var(--accent) 20%, transparent);
  transform: rotate(-1.5deg);
}

.brand-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.brand-kicker {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.11em;
  line-height: 1.2;
  white-space: nowrap;
}

.brand-title {
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-close.icon-button {
  display: none;
}

.library-description {
  display: -webkit-box;
  overflow: hidden;
  margin: 19px 24px 0;
  color: var(--ink-soft);
  font-family: var(--font-display);
  font-size: 13.5px;
  font-style: italic;
  line-height: 1.65;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.search-box {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  margin: 22px 18px 0;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--paper) 64%, transparent);
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.search-box:focus-within {
  border-color: var(--line-strong);
  background: var(--paper);
  box-shadow: var(--focus);
}

.search-icon {
  color: var(--muted);
  font-size: 14px;
}

.search-box input {
  width: 100%;
  min-width: 0;
  height: 38px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
}

.search-box input::placeholder {
  color: var(--faint);
}

.search-box input::-webkit-search-cancel-button {
  display: none;
}

.search-key {
  display: grid;
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1;
}

.search-spinner {
  flex: 0 0 13px;
  width: 13px;
  height: 13px;
  border: 1.5px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.tree-region {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
  margin-top: 22px;
}

.tree-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px 8px 24px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.tree-scroll {
  min-height: 0;
  flex: 1 1 auto;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0 12px 24px;
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
}

.tree-scroll::-webkit-scrollbar {
  width: 8px;
}

.tree-scroll::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 8px;
  background: var(--line-strong);
  background-clip: padding-box;
}

.tree {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.tree-empty {
  margin: 18px 12px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.tree-empty.nested {
  margin: 6px 10px 10px calc(21px + var(--depth, 1) * 15px);
  font-size: 10px;
  text-align: left;
  opacity: 0.75;
}

.icon-button:disabled {
  cursor: default;
  opacity: 0.4;
}

.tree-skeleton {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 11px 12px;
}

.tree-skeleton span {
  display: block;
  width: 76%;
  height: 11px;
  border-radius: 20px;
  background: var(--line);
  animation: pulse 1.3s ease-in-out infinite;
}

.tree-skeleton span:nth-child(2) {
  width: 58%;
  animation-delay: 100ms;
}

.tree-skeleton span:nth-child(3) {
  width: 68%;
  margin-left: 16px;
  animation-delay: 200ms;
}

.tree-skeleton span:nth-child(4) {
  width: 46%;
  margin-left: 16px;
  animation-delay: 300ms;
}

.tree-branch {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.tree-row {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 34px;
  align-items: center;
  gap: 8px;
  padding: 7px 9px 7px calc(9px + var(--depth, 0) * 15px);
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.35;
  text-align: left;
  text-decoration: none;
}

.tree-row:hover {
  background: color-mix(in srgb, var(--ink) 5%, transparent);
  color: var(--ink);
}

.tree-row.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.tree-row.active::before {
  position: absolute;
  top: 9px;
  bottom: 9px;
  left: 0;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
  content: "";
}

.tree-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.tree-chevron {
  width: 13px;
  height: 13px;
  color: var(--faint);
  transition: transform 140ms ease;
}

.tree-folder.open > .tree-row .tree-chevron {
  transform: rotate(90deg);
}

.tree-icon {
  width: 15px;
  height: 15px;
  color: var(--faint);
}

.tree-row.active .tree-icon {
  color: var(--accent);
}

.tree-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-badge {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 17px;
  margin-left: auto;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
}

.tree-children {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.tree-children[hidden] {
  display: none;
}

.tree-loader {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 9px 7px calc(18px + var(--depth, 1) * 15px);
  color: var(--muted);
  font-size: 11px;
}

.tree-loader .mini-spinner {
  width: 11px;
  height: 11px;
  border: 1.5px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.tree-error {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 3px 8px 5px calc(18px + var(--depth, 1) * 15px);
  padding: 8px 9px;
  border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--line));
  border-radius: 5px;
  background: var(--accent-softer);
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.5;
}

.tree-error .icon {
  width: 13px;
  height: 13px;
  margin-top: 1px;
  color: var(--accent);
}

.tree-error button {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  cursor: pointer;
  font-size: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.sidebar-foot {
  flex: 0 0 auto;
  padding: 14px 24px 19px;
  border-top: 1px solid var(--line);
}

.source-line {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
}

.source-dot {
  flex: 0 0 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #69916d;
  box-shadow: 0 0 0 3px rgba(105, 145, 109, 0.12);
}

.source-path {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-note {
  margin: 7px 0 0 13px;
  color: var(--faint);
  font-size: 10px;
  letter-spacing: 0.02em;
}

/* ---------------------------------------------------------
   Workspace, topbar, layout
   --------------------------------------------------------- */

.workspace {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 70% -10%, color-mix(in srgb, var(--paper) 80%, transparent), transparent 45%),
    var(--paper);
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
}

.workspace::-webkit-scrollbar {
  width: 10px;
}

.workspace::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 10px;
  background: var(--line-strong);
  background-clip: padding-box;
}

.topbar {
  position: sticky;
  z-index: 25;
  top: 0;
  display: flex;
  flex: 0 0 auto;
  height: var(--topbar-height);
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 clamp(20px, 3.4vw, 42px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
}

.topbar-lead {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.menu-button.icon-button {
  display: none;
}

.topbar-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 4px;
}

.icon-button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}

.icon-button:hover {
  border-color: var(--line);
  background: var(--paper-raised);
  color: var(--ink);
}

.icon-button:active {
  transform: translateY(1px);
}

.icon-button.compact {
  width: 24px;
  height: 24px;
  flex-basis: 24px;
  border-radius: 5px;
}

.icon-button.compact .icon {
  width: 14px;
  height: 14px;
}

.theme-icon-moon {
  display: none;
}

html[data-theme="dark"] .theme-icon-sun {
  display: none;
}

html[data-theme="dark"] .theme-icon-moon {
  display: block;
}

.breadcrumb {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.breadcrumb-placeholder {
  color: var(--faint);
}

.breadcrumb-item {
  overflow: hidden;
  max-width: 220px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.breadcrumb-separator {
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 10px;
}

.breadcrumb-current {
  overflow: hidden;
  max-width: 300px;
  color: var(--ink);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content-layout {
  display: flex;
  width: 100%;
  max-width: 1220px;
  flex: 1 0 auto;
  align-items: flex-start;
  justify-content: center;
  gap: clamp(34px, 5vw, 76px);
  margin: 0 auto;
  padding: 0 clamp(24px, 4.5vw, 58px);
}

.main {
  width: 100%;
  max-width: 790px;
  min-width: 0;
  padding: clamp(38px, 5vw, 58px) 0 0;
  outline: none;
}

.article {
  min-height: 50vh;
}

.article.is-loading {
  opacity: 0.5;
}

.article-skeleton {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding-top: 10px;
}

.article-skeleton span {
  display: block;
  border-radius: 30px;
  background: var(--line);
  animation: pulse 1.25s ease-in-out infinite;
}

.skeleton-kicker {
  width: 120px;
  height: 9px;
}

.skeleton-title {
  width: min(78%, 510px);
  height: 45px;
  margin: 4px 0 14px;
}

.skeleton-line {
  width: 100%;
  height: 12px;
}

.skeleton-line.short {
  width: 62%;
}

/* ---------------------------------------------------------
   Article header
   --------------------------------------------------------- */

.article-header {
  margin-bottom: 44px;
  padding-bottom: 31px;
  border-bottom: 1px solid var(--line);
  animation: rise-in 380ms cubic-bezier(0.22, 0.8, 0.3, 1) both;
}

.article-eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 18px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  line-height: 1.4;
  text-transform: uppercase;
}

.article-eyebrow::before {
  width: 22px;
  height: 1px;
  background: currentColor;
  content: "";
}

.article-title {
  max-width: 740px;
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(36px, 5.1vw, 54px);
  font-weight: 600;
  letter-spacing: -0.028em;
  line-height: 1.16;
  text-wrap: balance;
}

.article-description {
  max-width: 650px;
  margin: 17px 0 0;
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 1.75;
  text-wrap: pretty;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px 18px;
  margin-top: 23px;
  color: var(--muted);
  font-size: 11.5px;
}

.article-meta-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.article-meta .meta-divider {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--line-strong);
}

.meta-mono {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.02em;
}

.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.article-tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--ink-soft);
  font-size: 10.5px;
}

/* ---------------------------------------------------------
   Prose / markdown
   --------------------------------------------------------- */

.prose {
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.9;
  overflow-wrap: break-word;
  animation: rise-in 420ms 60ms cubic-bezier(0.22, 0.8, 0.3, 1) both;
}

.prose > :first-child {
  margin-top: 0;
}

.prose > :last-child {
  margin-bottom: 0;
}

.prose p {
  margin: 0 0 1.15em;
  text-wrap: pretty;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
  position: relative;
  scroll-margin-top: calc(var(--topbar-height) + 24px);
  color: var(--ink);
  font-weight: 650;
  letter-spacing: -0.018em;
  line-height: 1.38;
  text-wrap: balance;
}

.prose h1 {
  margin: 2.1em 0 0.7em;
  font-family: var(--font-display);
  font-size: 2.05em;
  font-weight: 600;
}

.prose h2 {
  margin: 2.35em 0 0.7em;
  padding-top: 0.16em;
  font-size: 1.52em;
}

.prose h2::before {
  display: block;
  width: 28px;
  height: 2px;
  margin-bottom: 15px;
  border-radius: 2px;
  background: var(--accent);
  content: "";
}

.prose h3 {
  margin: 1.95em 0 0.55em;
  font-size: 1.2em;
}

.prose h4 {
  margin: 1.7em 0 0.45em;
  font-size: 1.03em;
}

.prose h5,
.prose h6 {
  margin: 1.5em 0 0.4em;
  color: var(--ink-soft);
  font-size: 0.96em;
}

.heading-anchor {
  display: inline-flex;
  width: 1.2em;
  height: 1.2em;
  align-items: center;
  justify-content: center;
  margin-left: 0.28em;
  border-radius: 4px;
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 0.65em;
  font-weight: 400;
  opacity: 0;
  text-decoration: none;
  vertical-align: 0.15em;
  transition: opacity 130ms ease, background 130ms ease;
}

.heading-anchor:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.prose h1:hover .heading-anchor,
.prose h2:hover .heading-anchor,
.prose h3:hover .heading-anchor,
.prose h4:hover .heading-anchor,
.heading-anchor:focus-visible {
  opacity: 1;
}

.prose strong {
  color: var(--ink);
  font-weight: 700;
}

.prose em {
  font-style: italic;
}

.prose del {
  color: var(--muted);
}

.prose a {
  color: var(--accent);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 38%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: text-decoration-color 130ms ease, color 130ms ease;
}

.prose a:hover {
  color: var(--accent-hover);
  text-decoration-color: currentColor;
}

.prose a[target="_blank"]::after {
  display: inline-block;
  margin-left: 0.28em;
  color: var(--faint);
  content: "↗";
  font-size: 0.8em;
  text-decoration: none;
}

.prose ul,
.prose ol {
  margin: 0 0 1.2em;
  padding-left: 1.5em;
}

.prose li {
  margin: 0.32em 0;
  padding-left: 0.22em;
}

.prose li > p {
  margin: 0.35em 0;
}

.prose li::marker {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.85em;
}

.prose ul ul,
.prose ol ol,
.prose ul ol,
.prose ol ul {
  margin-top: 0.35em;
  margin-bottom: 0.35em;
}

.prose .task-list-item {
  list-style: none;
}

.prose .task-list-item input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0 7px 0 -1.45em;
  accent-color: var(--accent);
  vertical-align: -1px;
}

.prose blockquote {
  position: relative;
  margin: 1.8em 0;
  padding: 4px 0 4px 22px;
  border-left: 2px solid var(--accent);
  color: var(--ink-soft);
  font-family: var(--font-display);
  font-size: 1.05em;
  font-style: italic;
}

.prose blockquote p:last-child {
  margin-bottom: 0;
}

.prose blockquote strong {
  color: var(--ink);
}

.prose hr {
  width: 100%;
  height: 1px;
  margin: 2.7em 0;
  border: 0;
  background: linear-gradient(90deg, var(--line-strong), transparent);
}

.prose img,
.prose video {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.8em auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper-raised);
  box-shadow: var(--shadow-sm);
}

.prose figure {
  margin: 1.8em 0;
}

.prose figure img {
  margin-bottom: 0.6em;
}

.prose figcaption {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.prose code {
  padding: 0.16em 0.38em;
  border: 1px solid color-mix(in srgb, var(--line) 75%, transparent);
  border-radius: 4px;
  background: color-mix(in srgb, var(--ink) 5%, transparent);
  color: color-mix(in srgb, var(--ink) 88%, var(--accent));
  font-family: var(--font-mono);
  font-size: 0.845em;
  word-break: break-word;
}

.code-block {
  position: relative;
  overflow: hidden;
  margin: 1.9em 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--code-bg);
  box-shadow: var(--shadow-sm);
}

.code-head {
  display: flex;
  height: 37px;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 0 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: var(--code-head);
}

.code-language {
  color: var(--code-muted);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.copy-code {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 7px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--code-muted);
  cursor: pointer;
  font-size: 10px;
  transition: background 130ms ease, color 130ms ease;
}

.copy-code:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--code-ink);
}

.copy-code .icon {
  width: 12px;
  height: 12px;
}

.copy-code.copied {
  color: #9bc3a1;
}

.code-block pre {
  overflow-x: auto;
  margin: 0;
  padding: 18px 19px 20px;
  color: var(--code-ink);
  scrollbar-color: #4a463c transparent;
  scrollbar-width: thin;
}

.code-block pre code {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: inherit;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.78;
  word-break: normal;
  white-space: pre;
}

.prose :not(pre) > code {
  white-space: break-spaces;
}

.table-wrap {
  overflow-x: auto;
  margin: 1.8em 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  scrollbar-color: var(--line-strong) transparent;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  line-height: 1.65;
}

.prose th,
.prose td {
  min-width: 100px;
  padding: 11px 14px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.prose th:last-child,
.prose td:last-child {
  border-right: 0;
}

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

.prose th {
  background: color-mix(in srgb, var(--ink) 4%, transparent);
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.prose tbody tr:hover {
  background: var(--accent-softer);
}

.prose kbd {
  display: inline-block;
  padding: 0.08em 0.42em;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--paper-raised);
  font-family: var(--font-mono);
  font-size: 0.78em;
  line-height: 1.5;
}

.prose .footnotes {
  margin-top: 3em;
  padding-top: 1.2em;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.84em;
}

.prose mark {
  padding: 0.08em 0.2em;
  background: color-mix(in srgb, var(--gold) 25%, transparent);
  color: inherit;
}

/* Article-level state screens */

.state-screen {
  padding: clamp(45px, 8vh, 100px) 0 70px;
  animation: rise-in 350ms ease both;
}

.state-mark {
  display: inline-flex;
  width: 46px;
  height: 46px;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--accent);
  background: var(--paper-raised);
}

.state-mark .icon {
  width: 21px;
  height: 21px;
}

.state-kicker {
  margin: 0 0 12px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.state-screen h1 {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-size: clamp(29px, 4vw, 42px);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.22;
}

.state-screen > p {
  max-width: 570px;
  margin: 0 0 24px;
  color: var(--ink-soft);
  font-size: 14.5px;
  line-height: 1.8;
}

.state-screen code {
  padding: 0.13em 0.35em;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--accent-softer);
  font-family: var(--font-mono);
  font-size: 0.85em;
}

.state-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 25px;
}

.button {
  display: inline-flex;
  height: 37px;
  align-items: center;
  gap: 7px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--paper-raised);
  color: var(--ink);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: border-color 130ms ease, background 130ms ease, transform 130ms ease;
}

.button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.button:active {
  transform: translateY(1px);
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff9f1;
}

.button.primary:hover {
  background: var(--accent-hover);
  color: #fff9f1;
}

.button .icon {
  width: 14px;
  height: 14px;
}

.setup-code {
  overflow-x: auto;
  max-width: 640px;
  margin: 25px 0 0;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--code-bg);
  color: var(--code-ink);
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.7;
  white-space: pre;
}

.error-detail {
  margin: 18px 0 0;
  padding: 10px 13px;
  border-left: 2px solid var(--accent);
  background: var(--accent-softer);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
  overflow-wrap: anywhere;
}

/* Inline content and end matter */

.page-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: clamp(52px, 8vw, 90px);
  padding: 24px 0 35px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 10.5px;
}

.back-to-top {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
}

.back-to-top:hover {
  color: var(--accent);
}

.back-to-top .icon {
  width: 13px;
  height: 13px;
}

/* ---------------------------------------------------------
   Page outline
   --------------------------------------------------------- */

.outline {
  --outline-offset: clamp(55px, 6vw, 80px);

  position: sticky;
  top: calc(var(--topbar-height) + 24px);
  display: none;
  flex: 0 0 190px;
  width: 190px;
  max-height: calc(100vh - var(--topbar-height) - var(--outline-offset) - 24px);
  max-height: calc(100dvh - var(--topbar-height) - var(--outline-offset) - 24px);
  align-self: flex-start;
  margin-top: var(--outline-offset);
}

.outline-inner {
  display: flex;
  max-height: inherit;
  min-height: 0;
  flex-direction: column;
  padding-left: 19px;
  border-left: 1px solid var(--line);
}

.outline-heading {
  flex: 0 0 auto;
  margin: 0 0 13px;
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.outline-nav {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
  padding-right: 4px;
  padding-bottom: 12px;
  overscroll-behavior: contain;
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
}

.outline-nav::-webkit-scrollbar {
  width: 7px;
}

.outline-nav::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 7px;
  background: var(--line-strong);
  background-clip: padding-box;
}

.outline-link {
  display: block;
  padding: 3px 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
  text-decoration: none;
  transition: color 120ms ease;
}

.outline-link:hover {
  color: var(--ink);
}

.outline-link.depth-3 {
  padding-left: 12px;
  font-size: 11px;
}

.outline-link.active {
  color: var(--accent);
  font-weight: 600;
}

.outline-empty {
  color: var(--faint);
  font-size: 11px;
}

/* ---------------------------------------------------------
   Mobile, overlay, toast
   --------------------------------------------------------- */

.sidebar-overlay {
  position: fixed;
  z-index: 35;
  inset: 0;
  border: 0;
  background: rgba(27, 23, 17, 0.42);
  backdrop-filter: blur(2px);
  cursor: pointer;
}

.sidebar-overlay[hidden] {
  display: none;
}

.toast {
  position: fixed;
  z-index: 100;
  bottom: 24px;
  left: 50%;
  max-width: calc(100vw - 40px);
  padding: 9px 15px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--ink);
  color: var(--paper);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------------------------------------------------------
   Motion & responsive
   --------------------------------------------------------- */

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (min-width: 1200px) {
  .outline:not([hidden]) {
    display: block;
  }
}

@media (max-width: 1180px) {
  .content-layout {
    max-width: 860px;
  }
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(324px, calc(100vw - 48px));
    flex-basis: auto;
    transform: translateX(-102%);
    transition: transform 220ms cubic-bezier(0.22, 0.8, 0.3, 1);
    box-shadow: var(--shadow-lg);
  }

  .sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-close.icon-button {
    display: inline-grid;
    margin-top: 2px;
  }

  .menu-button.icon-button {
    display: inline-grid;
  }

  .topbar {
    padding: 0 20px;
  }

  .content-layout {
    padding: 0 clamp(20px, 5vw, 44px);
  }

  .main {
    padding-top: clamp(33px, 6vw, 48px);
  }
}

@media (max-width: 640px) {
  :root {
    --topbar-height: 58px;
  }

  .topbar {
    gap: 8px;
    padding: 0 13px;
  }

  .topbar-lead {
    gap: 5px;
  }

  .topbar-actions {
    gap: 1px;
  }

  .icon-button {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
  }

  .breadcrumb {
    gap: 5px;
    font-size: 10.5px;
  }

  .breadcrumb-item {
    max-width: 74px;
  }

  .breadcrumb-current {
    max-width: 125px;
  }

  .content-layout {
    padding: 0 19px;
  }

  .main {
    padding-top: 35px;
  }

  .article-header {
    margin-bottom: 32px;
    padding-bottom: 24px;
  }

  .article-title {
    font-size: clamp(32px, 10vw, 41px);
  }

  .article-description {
    font-size: 14.5px;
  }

  .article-meta {
    margin-top: 18px;
    gap: 7px 12px;
  }

  .prose {
    font-size: 15.5px;
    line-height: 1.85;
  }

  .prose h2 {
    font-size: 1.38em;
  }

  .prose h3 {
    font-size: 1.14em;
  }

  .code-block {
    margin-right: -3px;
    margin-left: -3px;
  }

  .code-block pre {
    padding: 15px;
  }

  .code-block pre code {
    font-size: 11.5px;
  }

  .page-foot {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding-bottom: 25px;
  }

  .back-to-top {
    align-self: flex-end;
  }

  .sidebar-head {
    padding-top: 22px;
  }

  .toast {
    bottom: 16px;
  }
}

@media (max-height: 620px) {
  .library-description {
    display: none;
  }

  .search-box {
    margin-top: 16px;
  }

  .tree-region {
    margin-top: 15px;
  }

  .sidebar-foot {
    padding-top: 10px;
    padding-bottom: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  body {
    overflow: visible;
    background: #fff;
    color: #111;
  }

  .sidebar,
  .topbar,
  .outline,
  .page-foot,
  .reading-progress,
  .sidebar-overlay,
  .heading-anchor,
  .copy-code {
    display: none !important;
  }

  .workspace {
    display: block;
    height: auto;
    overflow: visible;
    background: #fff;
  }

  .content-layout {
    display: block;
    max-width: none;
    padding: 0;
  }

  .main {
    max-width: none;
    padding: 0;
  }

  .article-header,
  .prose {
    animation: none;
  }

  .code-block {
    border-color: #ddd;
    background: #f6f6f4;
  }

  .code-head {
    background: #eee;
  }

  .code-block pre {
    color: #222;
  }

  .code-language {
    color: #555;
  }

  a {
    color: inherit;
  }
}
