:root {
  --paper: #f3efe7;
  --ink: #201e1b;
  --muted: #827b72;
  --line: #cfc7ba;
  --taupe: #b59b80;
  --bar-height: 64px;
  color-scheme: light;
}

* { box-sizing: border-box; }
/* 橡皮筋回弹要写在 html 上才管用（只写 body 时 iOS 不认）。
   全局 scroll-behavior:smooth 也去掉了 —— 它让每次点击后的页面移动都变成"滑一段"，
   手感发飘、像网页。需要动画的地方（分页、标签条、切换类型）都在 JS 里单独写 behavior:"smooth"。 */
html {
  background: var(--paper);
  overscroll-behavior: none;
}
body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button, a { color: inherit; font: inherit; -webkit-tap-highlight-color: transparent; }
button { border: 0; background: none; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--taupe); outline-offset: 3px; }
[hidden] { display: none !important; }
.loading { min-height: 100svh; display: grid; place-items: center; color: var(--muted); letter-spacing: .15em; }

/* 封面 */
.cover {
  position: relative;
  min-height: 100svh;
  overflow: hidden;
  isolation: isolate;
  background: var(--paper);
  padding: 40.1svh 7vw 12svh;
}
.cover-art { position: absolute; z-index: -1; inset: 0; width: 100%; height: 100%; object-fit: fill; pointer-events: none; }
.cover-logo { position: absolute; left: 7vw; top: 9.2svh; width: min(43vw, 420px); height: auto; }
/* 标题：细体黑 + 大字距，下面一条短线加一行英文小字，和 logo 的排法呼应。
   无衬线 500 + 负字距会把中文挤成一坨，宋体又太像文档标题，都试过了。 */
.cover h1 {
  position: relative;
  z-index: 1;
  margin: 0;
  width: min(62vw, 600px);
  font-size: clamp(40px, 8.8vw, 66px);
  line-height: 1.6;
  font-weight: 300;
  letter-spacing: .22em;
}
.cover h1.long-title { font-size: clamp(32px, 7vw, 52px); line-height: 1.58; letter-spacing: .18em; }
.cover-sub { position: relative; z-index: 1; margin: 22px 0 0; color: var(--muted); font-size: 11px; font-weight: 500; letter-spacing: .42em; }
.cover-sub::before { content: ""; display: block; width: 46px; height: 1px; margin-bottom: 22px; background: var(--ink); opacity: .55; }
.scroll-note { position: absolute; left: 7vw; bottom: 3.6svh; color: var(--muted); font-size: 15px; letter-spacing: .13em; }

/* 工艺目录：大类做成整块卡片，以后加"电动窗帘"这类也不用改结构 */
/* 撑满一屏，但页脚用 margin-top:auto 顶到底边，
   大类数量少时不会出现"页脚浮在中间、下面一大片空白" */
.category-menu { min-height: 100svh; display: flex; flex-direction: column; padding: 84px 7vw max(80px, env(safe-area-inset-bottom)); }
.eyebrow { margin: 0 0 38px; color: var(--muted); font-size: 13px; letter-spacing: .22em; }
.category-links { display: grid; gap: 16px; margin-bottom: 72px; }
.category-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: center;
  gap: 18px;
  padding: 32px 28px;
  border: 1px solid var(--ink);
  border-radius: 24px;
  background: rgba(255, 255, 255, .42);
  text-align: left;
  cursor: pointer;
}
.category-link:active { background: rgba(255, 255, 255, .8); }
.category-body { display: flex; flex-direction: column; min-width: 0; }
.category-number { color: var(--muted); font: italic 15px/1 Georgia, serif; }
.category-link strong { margin-top: 10px; font-size: clamp(32px, 7vw, 50px); line-height: 1.3; font-weight: 300; letter-spacing: .18em; }
.category-link small { margin-top: 9px; color: var(--muted); font: italic 16px/1.4 Georgia, serif; }
.category-arrow { font-size: 24px; }
.category-menu footer { margin-top: auto; padding-top: 20px; border-top: 1px solid var(--ink); color: var(--muted); text-align: right; font-size: 13px; letter-spacing: .12em; }

/* 大类详情：页面直接从工艺类型标签开始，不再重复一遍大类名 */
.detail { min-height: 100svh; padding-bottom: calc(var(--bar-height) + env(safe-area-inset-bottom)); }
#detail-content { width: min(100%, 1100px); margin: 0 auto; }

figure { margin: 0; }
.image-frame, .video-shell {
  position: relative;
  width: 100%;
  height: min(64svh, 680px);
  overflow: hidden;
  background: var(--paper);
}
.image-frame img, .video-shell video { display: block; width: 100%; height: 100%; object-fit: contain; background: transparent; }
.image-frame img { cursor: zoom-in; }
.media-caption { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 0 13px; }
/* 照片说明只有一个 span，尺寸和颜色与区块标题一致 */
.media-caption span { color: var(--ink); font-size: clamp(17px, 3.1vw, 23px); font-weight: 600; letter-spacing: .015em; }

/* 适配场景 / 安装要求：一个类型下的所有照片共用这一组 */
.type-specs { margin: 18px 0 24px; padding: 0 5vw; }
.type-specs > div { display: grid; grid-template-columns: 118px 1fr; gap: 18px; padding: 17px 4px; border-bottom: 1px solid var(--line); }
.type-specs > div:first-child { border-top: 1px solid var(--line); }
.type-specs dt { color: var(--muted); }
.type-specs dd { margin: 0; white-space: pre-wrap; line-height: 1.65; }

/* 视频：封面或页面底色先出现，不再显示“视频载入中”文字 */
.video-shell::before { content: "BU"; position: absolute; inset: 0; display: grid; place-items: center; color: rgba(80, 69, 57, .06); font: 600 clamp(56px, 13vw, 120px)/1 Georgia, serif; letter-spacing: -.1em; }
.video-shell video { position: relative; z-index: 1; opacity: 0; transition: opacity .25s ease; }
.video-shell.video-ready video, .video-shell.has-poster video { opacity: 1; }
.video-controls { position: absolute; z-index: 4; inset: 0; display: flex; align-items: center; justify-content: center; gap: 22px; background: rgba(18, 16, 14, .32); opacity: 0; pointer-events: none; transition: opacity .18s ease; }
.video-shell.controls-visible .video-controls { opacity: 1; pointer-events: auto; }
.video-controls button { width: 48px; height: 48px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.85); border-radius: 50%; color: #fff; background: rgba(20, 18, 16, .26); font-size: 19px; cursor: pointer; }
.video-controls small { font-size: 9px; }
.video-tap-hint { position: absolute; z-index: 3; right: 12px; bottom: 10px; padding: 5px 8px; border-radius: 999px; color: rgba(255,255,255,.9); background: rgba(20,18,16,.36); font-size: 10px; opacity: 0; transition: opacity .2s ease; }
.video-shell.video-ready:hover .video-tap-hint { opacity: 1; }

/* 类型选择：只有文字，选中的下面一条横线，类型多了自己横滑。整条分隔线不要。
   标签行现在是整页最上面那一行，所以自己让开刘海。 */
.type-browser { margin-top: 0; padding-top: 0; }
.type-tabs { position: sticky; z-index: 8; top: 0; display: flex; gap: 24px; overflow-x: auto; padding: max(18px, calc(env(safe-area-inset-top) + 10px)) 5vw 0; background: rgba(243, 239, 231, .97); scrollbar-width: none; overscroll-behavior: contain; }
.type-tabs::-webkit-scrollbar { display: none; }
.type-tabs button {
  flex: 0 0 auto;
  padding: 4px 2px 11px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 16px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}
.type-tabs button.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); }
.type-stage { scroll-margin-top: 56px; }
.type { padding: 0 0 72px; }
/* 类型名已经在标签行里，这里只剩英文名和张数，压成一行 */
.type-meta { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 5vw 0; }
.type-meta-text { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.type-meta-text em { flex: 0 0 auto; color: var(--muted); font-style: normal; font-size: 13px; }
.type-meta-text span { overflow: hidden; color: var(--muted); font: italic 16px/1.4 Georgia, serif; text-overflow: ellipsis; white-space: nowrap; }
.type-pager { flex: 0 0 auto; display: flex; align-items: center; gap: 12px; padding: 6px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); }
.type-pager button { width: 31px; height: 31px; display: grid; place-items: center; cursor: pointer; font-size: 25px; }
.type-pager span { min-width: 38px; text-align: center; font-size: 13px; }
/* 横滑轨道：原生 scroll-snap，跟手、回弹、惯性全部交给系统。
   overscroll-behavior: contain 保证滑到头不会把外面的页面一起带着晃。 */
.swipe-track { display: flex; gap: 26px; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: 5vw; padding: 0 5vw; overscroll-behavior: contain; scrollbar-width: none; }
.swipe-track::-webkit-scrollbar { display: none; }
.slide { flex: 0 0 calc(100% - 10vw); scroll-snap-align: start; scroll-snap-stop: always; }
.slide .image-frame, .slide .video-shell { scroll-margin-top: 60px; }
.empty { margin: 0 5vw; padding: 60px 20px; border: 1px dashed var(--line); color: var(--muted); text-align: center; }

/* 微信内置浏览器防误退：固定大类切换栏（矮条） */
.category-switcher { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; height: calc(var(--bar-height) + env(safe-area-inset-bottom)); display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; padding: 0 4vw env(safe-area-inset-bottom); border-top: 1px solid var(--line); background: rgba(243, 239, 231, .98); }
.category-switcher button { min-width: 0; height: var(--bar-height); display: flex; align-items: center; gap: 5px; cursor: pointer; }
.category-switcher .nav-label { flex: 0 0 auto; color: var(--muted); font-size: 13px; }
.category-switcher .nav-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.category-switcher .nav-arrow { flex: 0 0 auto; font-style: normal; font-size: 19px; line-height: 1; color: var(--muted); }
.category-switcher #category-prev, .category-switcher #category-next { gap: 0; }
#category-prev .nav-arrow { margin-right: 6px; }
#category-next .nav-arrow { margin-left: 6px; }
#category-prev { justify-content: flex-start; }
#category-next { justify-content: flex-end; }
.category-switcher .category-home { justify-content: center; padding: 0 18px; font-size: 15px; font-weight: 600; letter-spacing: .04em; }
.category-switcher button:disabled { cursor: default; }
/* 到头了整个按钮留空，箭头也不留 */
.category-switcher button.is-empty { visibility: hidden; }

/* 全屏照片/视频查看 */
.viewer-open { overflow: hidden; }
.media-viewer { position: fixed; z-index: 100; inset: 0; color: #fff; background: rgba(13, 12, 11, .98); }
.viewer-toolbar { position: absolute; z-index: 3; left: 0; right: 0; top: 0; height: calc(62px + env(safe-area-inset-top)); display: flex; align-items: flex-end; justify-content: space-between; padding: 0 18px 14px; background: linear-gradient(rgba(0,0,0,.55), transparent); }
.viewer-toolbar button, .viewer-toolbar a { padding: 8px 0; color: #fff; text-decoration: none; }
.viewer-stage { position: absolute; inset: 0; display: flex; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scroll-snap-stop: always; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-x; scrollbar-width: none; }
.viewer-stage::-webkit-scrollbar { display: none; }
/* 放大后手指用来平移，这时必须把横滑关掉，否则一边拖一边翻页 */
.viewer-stage.zoom-active { touch-action: none; }
.viewer-slide { flex: 0 0 100%; scroll-snap-align: center; scroll-snap-stop: always; display: grid; place-items: center; height: 100%; overflow: hidden; }
.viewer-media { max-width: 100%; max-height: 100%; object-fit: contain; transform-origin: center; will-change: transform; user-select: none; -webkit-user-drag: none; }
img.viewer-media { cursor: zoom-in; }
.viewer-nav { position: absolute; z-index: 3; top: 50%; width: 52px; height: 76px; transform: translateY(-50%); color: #fff; background: rgba(0,0,0,.28); font-size: 44px; }
.viewer-prev { left: 0; }
.viewer-next { right: 0; }
.viewer-help { position: absolute; z-index: 3; left: 0; right: 0; bottom: calc(16px + env(safe-area-inset-bottom)); margin: 0; color: rgba(255,255,255,.65); text-align: center; font-size: 11px; }

@media (min-width: 900px) {
  .cover { max-width: 760px; margin: 0 auto; box-shadow: 0 0 0 1px rgba(80, 65, 50, .08); }
  .category-menu { width: min(100%, 960px); margin: 0 auto; }
  .category-links { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  :root { --bar-height: 56px; }
  .cover { padding-top: 40.3svh; }
  .cover-logo { width: 44vw; }
  .cover h1 { width: 72vw; font-size: 8.8vw; }
  .cover h1.long-title { font-size: 7vw; }
  .cover-sub { margin-top: 18px; font-size: 10px; letter-spacing: .38em; }
  .cover-sub::before { width: 38px; margin-bottom: 18px; }
  .category-menu { padding-top: 52px; }
  .category-links { gap: 13px; margin-bottom: 56px; }
  .category-link { padding: 26px 22px; border-radius: 20px; grid-template-columns: minmax(0, 1fr) 24px; gap: 12px; }
  .category-link strong { margin-top: 8px; font-size: 30px; }
  .category-link small { margin-top: 7px; font-size: 14px; }
  .category-arrow { font-size: 20px; }
  .image-frame, .video-shell { height: 58svh; }
  .media-caption { min-height: 40px; padding: 9px 0 8px; }
  .type-specs { margin-bottom: 22px; }
  .type-specs > div { grid-template-columns: 70px 1fr; gap: 10px; padding: 12px 2px; font-size: 13px; }
  .type-specs dd { line-height: 1.45; }
  .type-browser { padding-top: 6px; }
  .type-tabs { gap: 20px; padding-top: 10px; }
  .type-tabs button { padding: 3px 2px 10px; font-size: 14px; }
  .type { padding-top: 0; padding-bottom: 40px; }
  .type-meta { padding-top: 14px; }
  .type-meta-text em { font-size: 11px; }
  .type-meta-text span { font-size: 13px; }
  .type-pager { gap: 3px; padding: 4px 6px; }
  .type-pager button { width: 24px; height: 24px; font-size: 19px; }
  .type-pager span { min-width: 30px; font-size: 10px; }
  .swipe-track { gap: 12px; }
  .slide { flex-basis: calc(100% - 10vw); }
  .slide .image-frame,
  .slide .video-shell { height: auto; aspect-ratio: 4 / 5; background: var(--paper); }
  .slide .image-frame img,
  .slide .video-shell video { object-fit: cover; object-position: center; }
  .category-switcher { padding: 0 3vw env(safe-area-inset-bottom); }
  .category-switcher .nav-label { font-size: 11.5px; }
  .category-switcher .nav-name { font-size: 12.5px; }
  .category-switcher .nav-arrow { font-size: 17px; }
  .category-switcher .category-home { padding: 0 10px; font-size: 13.5px; }
}

@media print {
  .cover { min-height: 100vh; break-after: page; }
  .category-menu, .category-switcher, .media-viewer, .type-tabs { display: none !important; }
  .detail { padding-bottom: 0; }
  .swipe-track { display: block; overflow: visible; }
  .slide { break-inside: avoid; margin-bottom: 30px; }
  .video-shell video { opacity: 1; }
}
