/* 配色：旧纸白背景 / 钨钢灰文字 / 暖银表头与边框 / 皮革棕价格 */
:root {
  --paper: #f6f1e6;
  --paper-soft: #fbf8f1;
  --ink: #3d4348;
  --ink-soft: #767c81;
  --silver: #c6c0b4;
  --silver-bg: #ece7da;
  --leather: #8a5a33;
  --leather-tint: rgba(138, 90, 51, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --row-hover: #f3eee3;
  --shadow: 0 1px 2px rgba(61, 67, 72, 0.04), 0 8px 24px rgba(61, 67, 72, 0.06);
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background-color: var(--paper);
  /* 纸纹：细颗粒 + 大块斑驳两层噪点，去色避免彩色噪点 */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Cfilter id='c'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.12' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23c)' opacity='0.07'/%3E%3Crect width='200' height='200' filter='url(%23f)' opacity='0.11'/%3E%3C/svg%3E");
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: rgba(138, 90, 51, 0.18);
}

.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 0 20px 64px;
}

/* 页眉：毛玻璃吸顶，标题居左，导航居右 */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(246, 241, 230, 0.85);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--silver);
  margin-bottom: 28px;
}

.header-inner {
  max-width: 920px;
  margin: 0 auto;
  padding: 13px 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: baseline;
  gap: 6px 20px;
}

.site-title {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--ink);
  text-decoration: none;
}

.brand-word {
  white-space: nowrap;
}

.brand-not {
  color: var(--leather);
  font-weight: 700;
  font-style: italic;
  text-decoration: underline;
  text-decoration-thickness: 0.065em;
  text-underline-offset: 0.14em;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.language-switch {
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-size: 12px;
  white-space: nowrap;
  color: var(--silver);
}

.language-switch a {
  color: var(--ink-soft);
  text-decoration: none;
  padding-block: 4px;
}

.language-switch a:hover,
.language-switch a[aria-current] {
  color: var(--leather);
}

.language-switch a[aria-current] {
  text-decoration: underline;
  text-underline-offset: 4px;
}

@media (max-width: 680px) {
  .header-inner {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .site-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    gap: 4px;
  }

  .header-inner .site-nav a {
    padding-inline: 8px;
  }

  .language-switch {
    grid-column: 2;
    grid-row: 1;
  }
}

html:lang(en) .prose p {
  text-align: start;
}

html:lang(en) .cell-part {
  white-space: normal;
}

.currency-note {
  margin: 0 0 14px;
  color: var(--ink-soft);
  font-size: 12px;
}

.site-nav a {
  font-size: 13px;
  color: var(--ink-soft);
  text-decoration: none;
  padding: 4px 12px;
  border-radius: 999px;
  transition: color 0.15s ease, background 0.15s ease;
}

.site-nav a:hover {
  color: var(--ink);
  background: var(--silver-bg);
}

.site-nav a.is-active {
  color: var(--leather);
  background: var(--leather-tint);
}

/* 正文小节标题 */
.container h2 {
  margin: 36px 0 12px;
  padding-top: 16px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--ink);
  border-top: 1px solid var(--silver);
}

.container h3 {
  margin: 22px 0 6px;
  padding-left: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  border-left: 3px solid var(--leather);
}

.container h4 {
  margin: 16px 0 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}

/* 正文排版：主页简介与组车手记 */
.prose {
  max-width: 38rem;
  font-family: var(--font-serif);
  font-size: 16px;
  line-height: 1.9;
  hanging-punctuation: first allow-end;
}

.prose-title {
  margin: 4px 0 28px;
  font-size: 25px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.4;
  color: var(--ink);
}

.prose-title::after {
  content: "";
  display: block;
  width: 44px;
  height: 3px;
  margin-top: 14px;
  background: var(--leather);
  border-radius: 2px;
}

/* 开篇首段作为导语 */
.prose-title + p {
  font-size: 17px;
}

.prose p {
  margin: 0 0 1em;
  text-align: justify;
}

.prose a {
  color: var(--leather);
  text-decoration: underline;
  text-decoration-color: rgba(138, 90, 51, 0.35);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.15s ease;
}

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

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

.prose ul,
.prose ol {
  margin: 0 0 1em;
  padding-left: 1.4em;
}

.prose li {
  margin: 0.3em 0;
}

.prose li::marker {
  color: var(--leather);
}

.prose blockquote {
  margin: 1.4em 0;
  padding: 2px 0 2px 14px;
  border-left: 3px solid var(--silver);
  color: var(--ink-soft);
}

.prose blockquote p {
  margin: 0;
}

.prose code {
  background: var(--silver-bg);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-size: 0.88em;
}

.prose hr {
  border: none;
  margin: 2.4em 0;
  text-align: center;
}

.prose hr::before {
  content: "· · ·";
  color: var(--silver);
  font-size: 16px;
  letter-spacing: 0.2em;
}

.prose img {
  max-width: 100%;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* 锚点跳转时避开吸顶页眉 */
.prose h2,
.prose h3 {
  scroll-margin-top: 72px;
}

/* 文章 minimap 目录：固定在右侧，窄屏隐藏 */
.toc {
  display: none;
}

@media (min-width: 960px) {
  .toc {
    display: block;
    position: fixed;
    right: 28px;
    top: 50%;
    transform: translateY(-50%);
    width: 176px;
    max-height: 72vh;
    overflow-y: auto;
    font-size: 12px;
    line-height: 1.5;
  }
}

.toc a {
  display: block;
  padding: 3px 0 3px 12px;
  color: var(--ink-soft);
  text-decoration: none;
  border-left: 1px solid var(--silver);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.toc a.toc-h3 {
  padding-left: 24px;
  opacity: 0.85;
}

.toc a:hover {
  color: var(--ink);
}

.toc a.is-active {
  color: var(--leather);
  border-left-color: var(--leather);
  font-weight: 600;
}

/* 工具栏：筛选按钮居左，搜索框居右 */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.system-filter {
  flex: 1 1 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.search-input {
  width: 260px;
  margin-left: auto;
  padding: 8px 16px;
  font-size: 14px;
  color: var(--ink);
  background: var(--paper-soft);
  border: 1px solid var(--silver);
  border-radius: 999px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--leather);
  box-shadow: 0 0 0 3px var(--leather-tint);
}

.filter-btn {
  padding: 5px 14px;
  font-size: 13px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--silver);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.filter-btn:hover {
  border-color: var(--ink-soft);
}

.filter-btn.is-active {
  color: var(--leather);
  border-color: var(--leather);
  background: var(--leather-tint);
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid rgba(138, 90, 51, 0.45);
  outline-offset: 2px;
}

.no-result {
  margin: 32px 0;
  text-align: center;
  color: var(--ink-soft);
}

.price-strong {
  color: var(--leather);
}

.empty-hint {
  color: var(--ink-soft);
}

.empty-hint code {
  background: var(--silver-bg);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

/* 账本表格：圆角容器 + 横向细线 + 行悬停 */
.table-wrap {
  border: 1px solid var(--silver);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper-soft);
  box-shadow: var(--shadow);
}

.parts-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-serif);
  font-size: 14px;
}

.parts-table th,
.parts-table td {
  padding: 12px 16px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--silver);
}

.parts-table thead th {
  background: var(--silver-bg);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

/* 系统分类标题行 */
.system-row th {
  background: var(--silver-bg);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  padding: 8px 16px;
}

.parts-table tbody tr:not(.system-row) {
  transition: background 0.15s ease;
}

.parts-table tbody tr:not(.system-row):hover {
  background: var(--row-hover);
}

.parts-table tbody tr:last-child td {
  border-bottom: none;
}

.col-image {
  width: 72px;
}

.cell-part {
  font-weight: 600;
  white-space: nowrap;
}


.spec-primary,
.spec-secondary {
  display: block;
}

.spec-primary {
  color: var(--ink);
}

.spec-secondary {
  margin-top: 2px;
  color: var(--ink-soft);
  font-size: 12px;
}

/* 缩略图 */
.thumb-link {
  display: inline-block;
  line-height: 0;
}

.thumb {
  width: 56px;
  height: 56px;
  object-fit: contain;
  background: var(--silver-bg);
  border: 1px solid var(--silver);
  border-radius: var(--radius-sm);
  transition: transform 0.15s ease;
}

.thumb-link:hover .thumb {
  transform: scale(1.05);
}

.no-image {
  color: var(--ink-soft);
  font-size: 13px;
  white-space: nowrap;
}

/* 状态小标签 */
.status-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  font-size: 12px;
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px solid var(--silver);
  border-radius: 999px;
  white-space: nowrap;
}

.status-icon {
  width: 13px;
  height: 13px;
  flex: none;
}

.status-icon-new {
  color: var(--leather);
}

.status-icon-used {
  color: var(--ink-soft);
}

/* 价格格 */
.cell-price {
  color: var(--leather);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 90px;
}

.price-paid {
  display: block;
}

.price-provided {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 500;
}

.cell-note {
  color: var(--ink);
  min-width: 120px;
}

.source-line,
.note-line {
  display: block;
}

/* 图片灯箱：零件图是透明底 PNG，垫纸色卡片舞台，深色零件也看得清 */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 32, 34, 0.55);
  cursor: zoom-out;
}

.lightbox[hidden] {
  display: none;
}

.lightbox-card {
  margin: 0;
  padding: 32px;
  background: var(--paper-soft);
  border-radius: var(--radius);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
  cursor: default;
  animation: lightbox-in 0.18s ease;
}

.lightbox-card img {
  display: block;
  max-width: min(72vw, 640px);
  max-height: 68vh;
  margin: 0 auto;
}

.lightbox-caption {
  margin-top: 16px;
  font-family: var(--font-serif);
  font-size: 14px;
  color: var(--ink);
  text-align: center;
}

.lightbox-caption:empty {
  display: none;
}

.lightbox-close {
  position: absolute;
  top: 18px;
  right: 20px;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(246, 241, 230, 0.92);
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.lightbox-close:hover {
  transform: scale(1.08);
}

@keyframes lightbox-in {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
}

/* 移动端：表格转为纵向信息块，无横向滚动 */
@media (max-width: 680px) {
  .table-wrap {
    border: none;
    background: transparent;
    box-shadow: none;
    overflow: visible;
  }

  .parts-table,
  .parts-table tbody,
  .parts-table tr,
  .parts-table td,
  .parts-table tbody th {
    display: block;
    width: 100%;
  }

  .parts-table thead {
    display: none;
  }

  .parts-table tbody tr {
    margin-bottom: 14px;
    border: 1px solid var(--silver);
    border-radius: var(--radius);
    background: var(--paper-soft);
    box-shadow: var(--shadow);
    overflow: hidden;
  }

  /* 分类行在移动端是贴在下一张信息块上方的分类条 */
  .parts-table tbody tr.system-row {
    margin-bottom: 8px;
    border: none;
    background: transparent;
    box-shadow: none;
    overflow: visible;
  }

  .parts-table tbody tr.system-row th {
    padding: 6px 12px;
    border: 1px solid var(--silver);
    border-radius: var(--radius-sm);
  }

  .parts-table td {
    border-left: none;
    border-bottom: 1px dashed var(--silver);
  }

  .parts-table td:last-child {
    border-bottom: none;
  }

  .parts-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    font-size: 12px;
    color: var(--ink-soft);
  }

  .thumb {
    width: 72px;
    height: 72px;
  }

  /* 移动端工具栏堆叠：搜索框整行在上，筛选按钮在下 */
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-input {
    order: -1;
    width: 100%;
    margin-left: 0;
  }

}

/* 圆环与下方总重小字 */
.donut-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex: none;
}

.donut-weight {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 12px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

/* 分类投入占比：表格下方的附注，环形图随筛选联动 */
.spend-chart {
  margin: 20px 0 0;
  padding: 18px 4px 0;
  border-top: 1px solid var(--silver);
  display: flex;
  align-items: center;
  gap: 20px;
}

.donut {
  width: 220px;
  flex: none;
}

.donut-track {
  fill: none;
  stroke: var(--silver-bg);
  stroke-width: 16;
}

.donut-seg {
  fill: none;
  stroke-width: 16;
  transition: stroke-dasharray 0.3s ease, stroke-dashoffset 0.3s ease;
}

.donut-label {
  font-size: 9px;
  fill: var(--ink-soft);
  letter-spacing: 0.05em;
}

.donut-num {
  font-family: var(--font-serif);
  font-size: 11px;
  font-weight: 600;
  fill: var(--leather);
}

.legend {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px 20px;
  font-size: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.legend-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
}

.legend-name {
  color: var(--ink-soft);
}

.legend-amount {
  margin-left: auto;
  font-family: var(--font-serif);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.legend-pct {
  min-width: 3.6em;
  text-align: right;
  color: var(--ink-soft);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 680px) {
  .spend-chart {
    flex-direction: column;
    align-items: flex-start;
  }

  .donut-wrap {
    align-self: center;
  }

  .legend {
    grid-template-columns: 1fr;
    width: 100%;
  }
}

/* 照片页网格 */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.photo-item {
  margin: 0;
}

.photo-item a {
  display: block;
  line-height: 0;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease;
}

.photo-item a:hover {
  transform: scale(1.02);
}

.photo-item img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.photo-item figcaption {
  margin-top: 8px;
  font-family: var(--font-serif);
  font-size: 13px;
  color: var(--ink-soft);
  text-align: center;
}

@media (max-width: 680px) {
  .photo-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* 打印：配件页输出为干净账本 */
@media print {
  .site-nav,
  .toolbar,
  .toc,
  .lightbox,
  .no-result {
    display: none;
  }

  .site-header {
    position: static;
    background: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  body {
    background: #fff;
    font-size: 12px;
  }

  .container {
    max-width: none;
    padding-bottom: 24px;
  }

  .table-wrap,
  .spend-chart {
    box-shadow: none;
  }

  .parts-table thead th,
  .system-row th,
  .status-tag,
  .legend-dot {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .parts-table tr {
    page-break-inside: avoid;
  }

  .parts-table th,
  .parts-table td {
    padding: 8px 10px;
  }

  .thumb {
    width: 40px;
    height: 40px;
  }
}

/* 可排序表头：默认双向箭头提示，激活后显示方向 */
.parts-table th.sortable {
  cursor: pointer;
  user-select: none;
}

.parts-table th.sortable:hover {
  color: var(--leather);
}

.parts-table th.sortable::after {
  content: "↕";
  margin-left: 4px;
  font-size: 10px;
  opacity: 0.35;
}

.parts-table th.sortable[aria-sort="ascending"]::after {
  content: "↑";
  color: var(--leather);
  opacity: 1;
}

.parts-table th.sortable[aria-sort="descending"]::after {
  content: "↓";
  color: var(--leather);
  opacity: 1;
}

/* 环形图交互：悬停分段或图例时高亮对应分类，点击只显示该系统 */
.legend-item {
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  margin: -2px -6px;
  transition: background 0.15s ease;
}

.legend-item:hover,
.legend-item.is-hover {
  background: var(--silver-bg);
}

.donut-seg {
  cursor: pointer;
  transition: stroke-dasharray 0.3s ease, stroke-dashoffset 0.3s ease,
    opacity 0.15s ease, stroke-width 0.15s ease;
}

.donut-seg:hover {
  stroke-width: 20;
}

/* 404 页 */
.not-found {
  margin: 64px 0;
  text-align: center;
  font-family: var(--font-serif);
}

.not-found-code {
  margin: 0 0 8px;
  font-size: 56px;
  font-weight: 600;
  color: var(--silver);
  letter-spacing: 0.08em;
}

.not-found p {
  margin: 0.4em 0;
  color: var(--ink-soft);
}

.not-found-links a {
  color: var(--leather);
}
