/* ==========================================================================
   Fabrix Materials — styles
   1. Tokens  2. Base  3. Layout  4. Header  5. Hero  6. Filters
   7. Results / cards  8. Compare  9. Modals  10. Processes / footer
   11. Responsive
   ========================================================================== */

/* ---------------------------------- 1. Tokens --------------------------- */
:root {
  --bg: #f7f7f5;
  --bg-elevated: #ffffff;
  --bg-sunken: #efefec;
  --bg-tint: #eef2fb;
  --text: #17181a;
  --text-muted: #5d6169;
  --text-faint: #8a8f98;
  --line: #e2e2de;
  --line-strong: #cfcfc9;
  --accent: #1d3d8f;
  --accent-strong: #16306e;
  --accent-soft: #e7ecfa;
  --accent-contrast: #ffffff;
  --ok: #1f7a4d;
  --warn: #b4600f;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgb(16 18 22 / 6%), 0 1px 3px rgb(16 18 22 / 4%);
  --shadow: 0 4px 12px -2px rgb(16 18 22 / 10%), 0 2px 6px -2px rgb(16 18 22 / 6%);
  --shadow-lg: 0 24px 60px -12px rgb(16 18 22 / 26%), 0 8px 24px -8px rgb(16 18 22 / 14%);

  --header-h: 68px;
  --wrap: 1220px;
  /* 底部安全区：先给 0px 回退，不支持 env() 的引擎整条计算不会失效 */
  --safe-b: 0px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: "Inter", "Segoe UI", "Hiragino Sans", "Noto Sans JP", "Microsoft YaHei",
          "PingFang SC", "Malgun Gothic", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", ui-monospace, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #101114;
  --bg-elevated: #181a1f;
  --bg-sunken: #0b0c0e;
  --bg-tint: #1b2233;
  --text: #f0f1f3;
  --text-muted: #a4a9b3;
  --text-faint: #7c828d;
  --line: #2a2d34;
  --line-strong: #3a3f48;
  --accent: #6f92f2;
  --accent-strong: #8aa6f6;
  --accent-soft: #1c2438;
  --accent-contrast: #0d1016;
  --ok: #4ec38a;
  --warn: #e0a35c;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 50%);
  --shadow: 0 6px 18px -4px rgb(0 0 0 / 60%);
  --shadow-lg: 0 28px 70px -20px rgb(0 0 0 / 80%);
}

/* ---------------------------------- 2. Base ---------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }

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

h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 650; letter-spacing: -0.015em; }
p { margin: 0; }
ul, ol, dl, dd { margin: 0; padding: 0; }
li { list-style: none; }
img, svg { display: block; max-width: 100%; }

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }

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

/* Safari < 15.4 不支持 :focus-visible，整条规则会被丢弃 → 键盘用户完全看不到焦点 */
@supports not selector(:focus-visible) {
  a:focus, button:focus, select:focus, input:focus, [tabindex]:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }
}

[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 50%;
  transform: translate(-50%, -120%);
  background: var(--accent); color: var(--accent-contrast);
  padding: 10px 18px; border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  z-index: 100; transition: transform .18s ease;
}
.skip-link:focus-visible { transform: translate(-50%, 0); }

.muted { color: var(--text-muted); font-size: .875rem; }

/* ---------------------------------- 3. Layout -------------------------- */
.wrap {
  width: calc(100% - 40px);
  max-width: var(--wrap);
  margin: 0 auto;              /* 逻辑属性的回退 */
  margin-inline: auto;
  width: min(100% - 40px, var(--wrap));
}

.section { padding-block: 56px; padding-block: clamp(48px, 6vw, 88px); }
.section--alt { background: var(--bg-sunken); border-block: 1px solid var(--line); }

.section__head { max-width: 640px; margin-bottom: 32px; }
.section__head h2 { font-size: clamp(1.5rem, 2.6vw, 2rem); }
.section__head p { margin-top: 8px; color: var(--text-muted); }

/* ---------------------------------- 4. Header -------------------------- */
.app-header {
  position: sticky; top: 0; z-index: 40;
  background: var(--bg-elevated); /* 旧浏览器回退：不支持 color-mix 时用实色 */
  background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.app-header__inner {
  display: flex; align-items: center; gap: 20px;
  min-height: var(--header-h);
}

.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand__mark {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--accent); color: var(--accent-contrast);
  font-size: .78rem; font-weight: 700; letter-spacing: .04em;
}
.brand__text { display: flex; flex-direction: column; line-height: 1.1; }
.brand__text strong { font-size: 1rem; letter-spacing: -0.01em; }
.brand__text small { font-size: .7rem; color: var(--text-muted); letter-spacing: .02em; }

.main-nav { display: flex; align-items: center; gap: 22px; margin-inline-start: 12px; }
.main-nav a, .main-nav .linkish {
  font-size: .9rem; color: var(--text-muted); font-weight: 500;
  transition: color .15s ease;
}
.main-nav a:hover, .main-nav .linkish:hover { color: var(--text); }

.header-actions { display: flex; align-items: center; gap: 10px; margin-inline-start: auto; }

.field { display: inline-flex; align-items: center; }
.field--select select {
  -webkit-appearance: none;
  appearance: none;
  padding: 7px 30px 7px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--bg-elevated) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%23a0a6b0' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 11px center / 11px;
  font-size: .84rem; font-weight: 500; color: var(--text);
  cursor: pointer;
}
.field--select select:hover { border-color: var(--accent); }

.icon-btn {
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 999px;
  border: 1px solid var(--line-strong); color: var(--text-muted);
  transition: color .15s, border-color .15s, background .15s;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.ico-moon { display: none; }
[data-theme="dark"] .ico-sun { display: none; }
[data-theme="dark"] .ico-moon { display: block; }
[data-theme="dark"] .ico-moon { fill: none; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: 999px;
  font-size: .9rem; font-weight: 600; letter-spacing: .01em;
  border: 1px solid transparent;
  transition: transform .12s ease, background .16s ease, color .16s ease, border-color .16s ease;
}
.btn:active { transform: translateY(1px); }
.btn--sm { padding: 8px 14px; font-size: .82rem; }
.btn--primary { background: var(--accent); color: var(--accent-contrast); }
.btn--primary:hover { background: var(--accent-strong); }
.btn--ghost { border-color: var(--line-strong); color: var(--text); background: transparent; }
.btn--ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn--ghost[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.linkish { color: var(--accent); font-size: .84rem; font-weight: 600; }
.linkish:hover { text-decoration: underline; }

/* ---------------------------------- 5. Hero ---------------------------- */
.hero {
  padding-block: 48px 32px;                                  /* clamp() 的回退 */
  padding-block: clamp(40px, 6vw, 76px) clamp(28px, 4vw, 48px);
  background:
    radial-gradient(1000px 420px at 78% -10%, var(--accent-soft), transparent 70%),
    var(--bg);
  border-bottom: 1px solid var(--line);
}
.badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-size: .78rem; font-weight: 600; letter-spacing: .02em;
}
.hero__title {
  margin-top: 20px;
  font-size: 2.4rem;                        /* clamp() 的回退 */
  font-size: clamp(2rem, 5vw, 3.4rem);
  letter-spacing: -0.03em;
  max-width: 20ch;
}
.hero__title em { font-style: normal; color: var(--accent); }
[lang="ja"] .hero__title, [lang="zh-CN"] .hero__title, [lang="zh-TW"] .hero__title, [lang="ko"] .hero__title {
  letter-spacing: -0.01em;
}
.hero__sub { margin-top: 16px; max-width: 66ch; color: var(--text-muted); font-size: 1.03rem; }

.hero__search {
  position: relative; display: flex; align-items: center;
  margin-top: 28px; max-width: 560px;
  background: var(--bg-elevated);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 4px 6px 4px 44px;
  box-shadow: var(--shadow-sm);
  transition: border-color .16s, box-shadow .16s;
}
.hero__search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.ico-search {
  position: absolute; left: 16px; width: 20px; height: 20px;
  fill: none; stroke: var(--text-faint); stroke-width: 1.8; stroke-linecap: round;
}
.hero__search input {
  flex: 1; border: 0; background: none; padding: 10px 4px; font-size: .95rem; min-width: 0;
}
.hero__search input:focus { outline: none; }
.hero__search input::-webkit-search-cancel-button { display: none; }
.hero__search-clear {
  width: 30px; height: 30px; border-radius: 999px; color: var(--text-muted);
  display: grid; place-items: center; font-size: .8rem;
}
.hero__search-clear:hover { background: var(--bg-sunken); color: var(--text); }

.hero__stats {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px; margin-top: 36px; max-width: 720px;
}
.hero__stats > div { border-inline-start: 2px solid var(--accent); padding-inline-start: 14px; }
.hero__stats dt { font-size: .78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.hero__stats dd { font-size: 1.4rem; font-weight: 650; letter-spacing: -0.02em; }

/* ---------------------------------- 6. Filters ------------------------- */
.layout {
  display: grid;
  grid-template-columns: 258px minmax(0, 1fr);
  gap: 36px;
  align-items: start;
}

.filters {
  position: sticky; top: calc(var(--header-h) + 20px);
  display: flex; flex-direction: column; gap: 22px;
  padding: 22px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  max-height: calc(100vh - var(--header-h) - 40px);
  max-height: calc(100dvh - var(--header-h) - 40px);
  overflow-y: auto;
}
.filters__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.filters__head h2 { font-size: 1rem; }

.fgroup { display: flex; flex-direction: column; gap: 10px; }
.fgroup > h3 {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-faint); font-weight: 700;
}
.fgroup__list { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: transparent; color: var(--text-muted);
  font-size: .8rem; font-weight: 500;
  transition: all .14s ease;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip[aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent); color: var(--accent-contrast);
}
.chip__dot { width: 7px; height: 7px; border-radius: 999px; background: hsl(var(--h, 210) 62% 52%); }

.range { display: flex; flex-direction: column; gap: 8px; }
.range output { font-size: .82rem; font-weight: 600; color: var(--text); }
input[type="range"] {
  -webkit-appearance: none;
  appearance: none; width: 100%; height: 4px; border-radius: 999px;
  background: linear-gradient(to right, var(--accent) var(--pct, 50%), var(--line-strong) var(--pct, 50%));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none; width: 16px; height: 16px; border-radius: 999px;
  background: var(--bg-elevated); border: 2px solid var(--accent);
  box-shadow: var(--shadow-sm); cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 999px;
  background: var(--bg-elevated); border: 2px solid var(--accent); cursor: pointer;
}

/* ---------------------------------- 7. Results / cards ----------------- */
.results { min-width: 0; }
.results__bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 20px;
}
.results__count { font-size: .88rem; color: var(--text-muted); font-weight: 500; }
.results__tools { display: flex; align-items: center; gap: 10px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
  gap: 20px;
}

.card {
  display: flex; flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.card.is-compared { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

.card__media {
  position: relative;
  height: 116px;
  background:
    repeating-linear-gradient(115deg, rgb(255 255 255 / 16%) 0 2px, transparent 2px 9px),
    radial-gradient(120% 140% at 26% 18%, hsl(var(--h, 210) 72% 82%), transparent 62%),
    linear-gradient(135deg, hsl(var(--h, 210) 58% 88%), hsl(calc(var(--h, 210) + 38) 52% 76%));
}
[data-theme="dark"] .card__media {
  background:
    repeating-linear-gradient(115deg, rgb(255 255 255 / 7%) 0 2px, transparent 2px 9px),
    radial-gradient(120% 140% at 26% 18%, hsl(var(--h, 210) 62% 46%), transparent 64%),
    linear-gradient(135deg, hsl(var(--h, 210) 44% 30%), hsl(calc(var(--h, 210) + 38) 40% 20%));
}
.card__media::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgb(0 0 0 / 12%), transparent 55%);
}
.pill {
  position: absolute; z-index: 1; top: 12px; left: 12px; inset-inline-start: 12px;
  display: inline-flex; align-items: center;
  padding: 4px 10px; border-radius: 999px;
  background: rgb(255 255 255 / 88%); color: #1b1d21;
  font-size: .68rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.pill--family {
  left: auto; right: 12px;
  inset-inline-start: auto; inset-inline-end: 12px;
  background: rgb(23 24 26 / 72%); color: #fff;
}

.card__body { display: flex; flex-direction: column; gap: 12px; padding: 16px 18px 18px; flex: 1; }
.card__title { font-size: 1.06rem; }
.card__title button { text-align: start; }
.card__title button:hover { color: var(--accent); }

.card__traits { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: .7rem; padding: 3px 8px; border-radius: 6px;
  background: var(--bg-sunken); color: var(--text-muted); font-weight: 500;
}
[data-theme="dark"] .tag { background: #23262c; }

.card__specs {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  padding-block: 10px; border-block: 1px solid var(--line);
}
.card__specs dt { font-size: .68rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: .05em; }
.card__specs dd { font-size: .86rem; font-weight: 600; margin-top: 2px; }

.card__colors { display: flex; align-items: center; gap: 5px; }
.swatch {
  width: 15px; height: 15px; border-radius: 999px;
  border: 1px solid rgb(0 0 0 / 14%);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 45%);
}
.swatch--more { font-size: .66rem; color: var(--text-faint); width: auto; height: auto; border: 0; box-shadow: none; }

.card__foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin-top: auto; }
.card__foot > .btn { margin-inline-start: auto; }
.card__price { font-size: .78rem; color: var(--text-muted); }
.card__price b { display: block; font-size: 1.14rem; color: var(--text); letter-spacing: -0.02em; }
.card__price small { font-weight: 500; }

.empty { text-align: center; padding: 64px 20px; display: grid; gap: 10px; justify-items: center; }
.empty__title { font-size: 1.1rem; font-weight: 650; }
.empty__hint { color: var(--text-muted); font-size: .9rem; max-width: 34ch; }

/* ---------------------------------- 8. Compare ------------------------- */
.compare-bar {
  position: fixed; left: 0; right: 0; inset-inline: 0; bottom: 0; z-index: 45;
  background: var(--bg-elevated);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 30px -12px rgb(16 18 22 / 24%);
  animation: rise .22s ease;
  /* 安全区只在这里留一次（原来 __inner 与 @supports 各留一次，iPhone 上叠成 68px） */
  padding-bottom: var(--safe-b);
}
@keyframes rise { from { transform: translateY(100%); } to { transform: translateY(0); } }
.compare-bar__inner { display: flex; align-items: center; gap: 16px; padding-block: 12px; }
.compare-bar__items { display: flex; gap: 8px; flex: 1; overflow-x: auto; scrollbar-width: thin; }
.compare-bar__actions { display: flex; align-items: center; gap: 10px; }

.mini {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 8px 6px 6px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--bg);
  white-space: nowrap; font-size: .8rem; font-weight: 500;
}
.mini__dot { width: 22px; height: 22px; border-radius: 999px; background: hsl(var(--h, 210) 60% 62%); }
.mini__x { color: var(--text-faint); padding: 0 2px; font-size: .8rem; }
.mini__x:hover { color: var(--warn); }

.compare-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.compare-table th, .compare-table td {
  padding: 12px 14px; text-align: start; vertical-align: top;
  border-bottom: 1px solid var(--line);
}
.compare-table thead th { position: sticky; top: 0; background: var(--bg-elevated); z-index: 1; }
.compare-table tbody th { color: var(--text-muted); font-weight: 500; width: 180px; }
.compare-table td.is-best { color: var(--ok); font-weight: 650; }
.compare-table td.is-best::after { content: " ★"; }
.compare-table .col-head { display: flex; flex-direction: column; gap: 2px; }
.compare-table .col-head b { font-size: .98rem; }
.compare-table .col-head span { font-size: .72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }

/* ---------------------------------- 9. Modals -------------------------- */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 24px; }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgb(12 13 16 / 55%); backdrop-filter: blur(3px); }
.modal__panel {
  position: relative;
  width: min(100%, 860px);
  max-height: min(88vh, 900px);
  display: flex; flex-direction: column;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: pop .2s ease;
}
.modal__panel--wide { width: min(100%, 920px); }
.modal__panel--full { width: min(100%, 1040px); }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.99); } to { opacity: 1; transform: none; } }

.modal__head {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 22px; border-bottom: 1px solid var(--line);
}
.modal__head h2 { font-size: 1.1rem; }
.modal__body { overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.modal__close {
  position: absolute; top: 14px; right: 14px; inset-inline-end: 14px; z-index: 2;
  width: 34px; height: 34px; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--bg-elevated); border: 1px solid var(--line);
  color: var(--text-muted);
}
.modal__close--inline { position: static; margin-inline-start: auto; }
.modal__close:hover { color: var(--text); border-color: var(--line-strong); }

/* detail */
.detail__hero {
  padding: 26px 26px 22px;
  background:
    radial-gradient(600px 220px at 88% -30%, hsl(var(--h, 210) 70% 84% / 62%), transparent 70%),
    var(--bg-elevated);
  border-bottom: 1px solid var(--line);
}
.detail__kicker { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.detail__hero h2 { font-size: clamp(1.35rem, 2.6vw, 1.9rem); }
.detail__lead { margin-top: 10px; color: var(--text-muted); font-size: .94rem; max-width: 66ch; }
.detail__cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

.detail__grid { display: grid; gap: 26px; padding: 24px 26px 30px; }
.detail__block h3 {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-faint); margin-bottom: 12px;
}
.spec-table { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.spec-table > div { background: var(--bg-elevated); padding: 12px 14px; }
.spec-table dt { font-size: .74rem; color: var(--text-muted); }
.spec-table dd { font-size: .95rem; font-weight: 600; margin-top: 2px; }

.color-list { display: flex; flex-wrap: wrap; gap: 10px; }
.color-item { display: flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--text-muted); }
.color-item .swatch { width: 18px; height: 18px; }

.pill-list { display: flex; flex-wrap: wrap; gap: 8px; }
.pill-list .tag { font-size: .78rem; padding: 5px 10px; border-radius: 999px; }

/* ---------------------------------- 10. Processes / footer ------------- */
.process-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.process-card {
  padding: 22px; border-radius: var(--radius);
  background: var(--bg-elevated); border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 8px;
  transition: border-color .16s, transform .16s;
}
.process-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.process-card__top { display: flex; align-items: center; gap: 10px; }
.process-card__icon { width: 28px; height: 28px; flex: 0 0 auto; }
.process-card h3 { font-size: 1rem; }
.process-card__count { font-size: .74rem; color: var(--text-faint); margin-inline-start: auto; }
.process-card p { font-size: .86rem; color: var(--text-muted); }
.process-card__bar { height: 3px; border-radius: 999px; background: hsl(var(--h, 210) 60% 62%); margin-top: auto; }

.app-footer { padding-block: 40px; border-top: 1px solid var(--line); background: var(--bg-elevated); }
.app-footer__inner { display: grid; grid-template-columns: 1.1fr 1fr; gap: 32px; align-items: start; }
.app-footer__meta { display: grid; gap: 6px; }

/* 公司动态 */
.news-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.news-card {
  display: grid; gap: 8px; padding: 18px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--bg-elevated);
  text-decoration: none; color: inherit; transition: border-color .15s ease, transform .15s ease;
}
.news-card:hover { border-color: var(--accent); transform: translateY(-2px); }
/* 页脚联系方式 */
.footer-contact { display: grid; gap: 6px; margin-bottom: 12px; font-size: .86rem; }
.footer-contact a { color: var(--text); text-decoration: none; border-bottom: 1px solid var(--line); padding-bottom: 1px; }
.footer-contact a:hover { color: var(--accent); border-color: var(--accent); }
.footer-contact span { color: var(--text-muted); }

/* 首页主视觉图（后台上传指定） */
.hero__art {
  display: block; width: 100%; max-width: 620px; margin: 22px auto 0;
  border-radius: var(--radius); object-fit: cover; max-height: 320px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .12);
}

/* 报价方式切换 */
.qmode {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px;
  background: var(--bg-sunken); border-radius: 12px; margin-bottom: 16px;
}
.qmode__btn {
  border: 0; background: transparent; padding: 10px 8px; border-radius: 9px;
  font: inherit; font-size: .9rem; font-weight: 600; color: var(--text-muted); cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.qmode__btn.is-active { background: var(--bg-elevated); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.news-card__cover { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: var(--radius-sm); }

/* 媒体库选图缩略图按钮 */
.media-pick {
  border: 1px solid var(--line); background: var(--bg-elevated); padding: 0;
  border-radius: 10px; overflow: hidden; cursor: pointer; line-height: 0;
}
.media-pick:hover { border-color: var(--accent); }
.media-pick img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.news-card__date { font-size: .74rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.news-card__title { font-size: 1rem; margin: 0; line-height: 1.4; }
.news-card__sum { margin: 0; font-size: .86rem; color: var(--text-muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.news-more-row { margin-top: 18px; }

/* 案例卡片上的信息标签 */
.case-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.case-chip {
  font-size: .7rem; padding: 2px 8px; border-radius: 999px;
  background: var(--bg-sunken); color: var(--text-muted); border: 1px solid var(--line);
}

/* 关于我们 / 联系方式 */
.about__text { max-width: 720px; color: var(--text-muted); margin-bottom: 28px; white-space: pre-line; }
.contact-list {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px;
}
.contact-item {
  display: grid; gap: 4px; padding: 14px 16px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-elevated);
}
.contact-item__label { font-size: .74rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); }
.contact-item__value { font-size: .95rem; font-weight: 600; color: var(--text); overflow-wrap: anywhere; text-decoration: none; }
a.contact-item__value { color: var(--accent); }
a.contact-item__value:hover { text-decoration: underline; }
.contact-item__value--btn {
  background: none; border: 0; padding: 0; text-align: left; cursor: pointer;
  color: var(--accent); font: inherit; font-weight: 600;
}
.brand--footer { margin-bottom: 10px; }

/* ---------------------------------- 11. Responsive -------------------- */
.mobile-only { display: none; }

@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; }
  .filters {
    position: fixed; inset: 0; z-index: 55; margin: 0; border-radius: 0;
    max-height: none; border: 0; padding: 20px;
    /* 用 transform 而不是独立的 translate 属性：老 WebView（微信 X5 / Chromium<104）
       不认识 translate，整条会丢弃 —— 抽屉就永远盖在屏幕上 */
    transform: translateY(100%);
    transition: transform .24s ease;
    will-change: transform;
  }
  .filters.is-open { transform: translateY(0); }
  .mobile-only { display: inline-flex; }
  .filters__foot {
    position: sticky; bottom: 0;
    display: flex; padding-top: 12px;
    background: linear-gradient(to top, var(--bg-elevated) 68%, transparent);
  }
  .filters__foot .btn { width: 100%; }
  .filters__head { position: sticky; top: 0; background: var(--bg-elevated); padding-bottom: 12px; z-index: 1; }
}

@media (max-width: 860px) {
  /* 手机端保留导航：变成可横向滑动的胶囊条（之前是 display:none，手机上完全没导航） */
  .app-header__inner { flex-wrap: wrap; row-gap: 0; }
  .main-nav {
    display: flex; order: 3; width: 100%; margin: 8px 0 0; gap: 8px;
    overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; padding-bottom: 4px;
  }
  .main-nav::-webkit-scrollbar { display: none; }
  .main-nav a, .main-nav .linkish {
    flex: 0 0 auto; padding: 7px 13px; border-radius: 999px;
    background: var(--bg-sunken); font-size: .85rem; white-space: nowrap;
  }
  .main-nav a:hover, .main-nav .linkish:hover { background: var(--line); }
  .hero__stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-footer__inner { grid-template-columns: 1fr; }
}

/* 锚点跳转时给吸顶头部留出空间 */
#materials, #processes, #cases, #news, #about { scroll-margin-top: calc(var(--header-h) + 12px); }

@media (max-width: 620px) {
  :root { --header-h: 60px; }
  .wrap { width: calc(100% - 28px); }
  .brand__text small { display: none; }
  .header-actions .btn--primary { display: none; }
  .grid { grid-template-columns: 1fr; }
  .modal { padding: 0; }
  .modal__panel { max-height: 100vh; border-radius: 0; height: 100%; }
  .compare-bar__actions .btn--ghost { display: none; }
  .detail__grid, .detail__hero { padding-inline: 18px; }
  .results__bar { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  html { scroll-behavior: auto; }
}

@media print {
  .app-header, .filters, .compare-bar, .hero__search, .results__tools, .modal { display: none !important; }
  body { background: #fff; }
  .card { break-inside: avoid; }
}

/* ------------------------- 12. 上传图片 / 素材位 ------------------------- */
.card__img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  z-index: 0;
}
.detail__img {
  margin-top: 14px;
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

/* 手机端常驻筛选浮钮（默认隐藏，只在窄屏显示） */
.fab {
  display: none;
  position: fixed;
  right: 16px; inset-inline-end: 16px;
  bottom: 16px;
  bottom: calc(16px + var(--safe-b));
  z-index: 46;                 /* 高于对比栏(45)，避免被盖住 */
  align-items: center; gap: 8px;
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--accent); color: var(--accent-contrast);
  font-size: .9rem; font-weight: 650;
  box-shadow: var(--shadow-lg);
  touch-action: manipulation;
}
.fab svg { width: 18px; height: 18px; }
.fab:active { transform: translateY(1px); }
body.has-compare .fab { bottom: calc(100px + var(--safe-b)); }

/* 与 .mobile-only 保持同一个断点，避免两套显隐规则互相压制 */
@media (max-width: 1080px) {
  .fab { display: inline-flex; }
}

/* ------------------------- 13. 布局自检浮层 (?probe=1) ------------------- */
.probe-box {
  position: fixed; z-index: 47;      /* 低于弹窗(60)与抽屉(55)，避免挡住关闭按钮 */
  right: 16px; inset-inline-end: 16px;
  top: calc(var(--header-h) + 12px);
  max-width: 380px;
  max-width: min(92vw, 380px);
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  border: 1px solid var(--accent);
  box-shadow: var(--shadow-lg);
  font-size: .82rem;
  color: var(--text);
}
.probe-box strong { display: block; margin-bottom: 6px; letter-spacing: -0.01em; }
.probe-box ul { margin: 0; padding-inline-start: 16px; display: grid; gap: 4px; }
.probe-box li { list-style: disc; color: var(--text-muted); overflow-wrap: anywhere; }
.probe-box__close {
  margin-top: 10px; font-size: .78rem; font-weight: 600;
  color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer;
}

/* ---------------------- 15. 自助报价 / 在线客服 ---------------------- */
.qfield { display: grid; gap: 6px; min-width: 0; }
.qfield > span { font-size: .8rem; font-weight: 600; color: var(--text-muted); }
.qinput, .qselect {
  width: 100%; min-width: 0;             /* 默认 min-width:auto 会在 grid 里撑破容器 */
  padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--bg-elevated); color: var(--text);
  font: inherit; font-size: .94rem;
}
.quote-body { padding: 16px 20px 26px; }

/* STL 上传区 */
.stl-drop {
  border: 1px dashed var(--line-strong, var(--line)); border-radius: var(--radius);
  padding: 14px; text-align: center; background: var(--bg-sunken);
  display: grid; gap: 8px; justify-items: center;
}
.stl-drop.is-over { border-color: var(--accent); background: var(--bg-elevated); }
.stl-drop p { margin: 0; font-size: .8rem; }
.stl-info {
  margin-top: 10px; padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--bg-elevated);
}
.stl-info__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.stl-info__head strong { font-size: .86rem; overflow-wrap: anywhere; }
.stl-info__clear {
  background: none; border: 0; color: var(--accent); font-size: .78rem;
  font-weight: 600; cursor: pointer; padding: 0;
}
.stl-info__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin: 0; }
.stl-info__grid div { display: flex; justify-content: space-between; gap: 8px; font-size: .8rem; }
.stl-info__grid dt { color: var(--text-muted); }
.stl-info__grid dd { margin: 0; font-variant-numeric: tabular-nums; }

/* 查询结果卡片 */
#track-result { margin-top: 16px; }
.track-card { display: grid; gap: 10px; }
.track-card__head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.track-card__head strong { font-size: 1rem; letter-spacing: -0.01em; }
.track-badge {
  padding: 3px 10px; border-radius: 999px; font-size: .72rem; font-weight: 700;
  background: var(--bg-sunken); color: var(--text-muted); border: 1px solid var(--line);
}
.track-badge--in_production, .track-badge--pending { color: var(--accent); border-color: var(--accent); }
.track-badge--shipped, .track-badge--done { color: #1a7f4b; border-color: #1a7f4b; }
.track-badge--cancelled { color: #b3382c; border-color: #b3382c; }
.track-ok { color: #1a7f4b; font-weight: 600; font-size: .9rem; margin: 0 0 8px; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.timeline li { display: grid; grid-template-columns: 12px auto 1fr; align-items: center; gap: 8px; font-size: .84rem; }
.timeline__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.timeline li:not(:last-child) .timeline__dot { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.timeline__label { font-weight: 600; }
textarea.qinput { resize: vertical; min-height: 62px; }
.qinput:focus, .qselect:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.quote-grid { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; margin-top: 14px; min-width: 0; }
.quote-size { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; min-width: 0; }
.quote-summary {
  margin: 16px 0; padding: 14px 16px; border-radius: var(--radius);
  background: var(--bg-sunken); border: 1px solid var(--line); display: grid; gap: 7px;
}
.quote-summary div { display: flex; justify-content: space-between; gap: 12px; font-size: .88rem; }
.quote-summary dt { color: var(--text-muted); }
.quote-summary dd { margin: 0; font-variant-numeric: tabular-nums; }
.quote-summary .is-total {
  border-top: 1px dashed var(--line); margin-top: 4px; padding-top: 8px;
  font-weight: 700; font-size: 1rem;
}
.qerror { color: var(--danger, #c0362c); font-size: .84rem; margin: 10px 0 0; }
.btn--block { width: 100%; justify-content: center; margin-top: 12px; }
.quote-done { text-align: center; padding: 22px 0; }
.quote-done__no { font-size: 1.05rem; font-weight: 700; color: var(--accent); margin: 0 0 6px; }

.chat { position: fixed; left: 16px; bottom: 16px; z-index: 48; }
.chat__fab {
  width: 52px; height: 52px; border-radius: 50%; border: 0;
  background: var(--accent); color: var(--accent-contrast);
  box-shadow: var(--shadow-lg); display: grid; place-items: center; cursor: pointer;
  touch-action: manipulation;
}
.chat__fab svg { width: 24px; height: 24px; }
.chat__panel {
  position: fixed; left: 12px; right: 12px; bottom: 80px; max-height: 62vh; z-index: 49;
  display: grid; grid-template-rows: auto 1fr auto;
  background: var(--bg-elevated); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden;
}
.chat__head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.chat__tools { display: flex; align-items: center; gap: 8px; }
.chat__lang {
  max-width: 130px; min-height: 30px; padding: 2px 6px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg-sunken); color: var(--text); font-size: .76rem;
}
.chat__orig {
  justify-self: start; margin-top: 2px; padding: 0;
  background: none; border: 0; cursor: pointer;
  font-size: .7rem; color: var(--text-muted); text-decoration: underline;
}
.chat__close { background: none; border: 0; color: var(--text-muted); font-size: 1rem; padding: 4px 6px; cursor: pointer; }
.chat__log { overflow-y: auto; padding: 10px 12px; display: grid; gap: 8px; min-height: 140px; -webkit-overflow-scrolling: touch; }
.chat__msg { display: grid; gap: 2px; max-width: 86%; }
.chat__who { font-size: .68rem; color: var(--text-muted); }
.chat__msg p { margin: 0; padding: 8px 10px; border-radius: 12px; font-size: .86rem; line-height: 1.5; overflow-wrap: anywhere; }
.chat__msg--staff p { background: var(--bg-sunken); }
.chat__msg--you { justify-self: end; text-align: right; }
.chat__msg--you p { background: var(--accent); color: var(--accent-contrast); }
.chat__form { display: grid; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
.chat__row { display: flex; gap: 8px; }
.chat__row .qinput { flex: 1; }

@media (min-width: 720px) {
  .chat { left: 24px; bottom: 24px; }
  .chat__panel { width: 340px; right: auto; left: 24px; bottom: 88px; }
}
@media (max-width: 860px) {
  .chat__panel { bottom: calc(80px + var(--safe-b)); }
  .chat__fab { width: 48px; height: 48px; }
  /* 输入框 16px：iOS 聚焦不放大 */
  .qinput, .qselect { font-size: 16px; }
  .quote-grid { grid-template-columns: 1fr; }
}

/* --------------------------- 14. 手机 H5 适配 --------------------------- */

/* iOS 输入框放大、触控目标、安全区 */
body.has-compare { padding-bottom: 88px; padding-bottom: calc(88px + var(--safe-b)); }

@media (max-width: 860px) {
  html { -webkit-tap-highlight-color: transparent; }
  /* 防止横向溢出导致整页左右晃动（对比表等宽表格在自身容器内滚动） */
  body { overflow-x: clip; }
  /* 去掉移动端 300ms 点击延迟与双击缩放 */
  button, a, .chip, .btn, select, label.file-btn { touch-action: manipulation; }
  .hero__search input,
  .field--select select,
  .filters input, .filters select { font-size: 16px; } /* 防 iOS 聚焦自动缩放 */

  .btn { min-height: 44px; }
  .btn--sm { min-height: 38px; }
  .icon-btn { width: 40px; height: 40px; }
  .chip { padding: 9px 14px; min-height: 40px; }
  /* 下拉在手机上也要够高（原来 33px，低于 38px 门槛） */
  select { min-height: 40px; }
  .main-nav a { padding-block: 8px; }

  /* 底部对比栏：安全区已由 .compare-bar 的 padding-bottom 统一处理 */
  .compare-bar__inner { padding-block: 10px; }
  .filters { padding-bottom: calc(24px + var(--safe-b)); }
  .app-footer { padding-bottom: calc(32px + var(--safe-b)); }
}

@media (max-width: 620px) {
  .card__media { height: 148px; }
  .grid { gap: 14px; }
  .hero__stats { gap: 12px; }
  .hero__stats dd { font-size: 1.2rem; }
  .results__tools { width: 100%; justify-content: space-between; }
  /* 高度沿用 620 块（第 584 行）的 height:100%：.modal 已是 fixed inset:0，
     这里再写 100vh 会在不支持 dvh 的引擎上把弹窗顶部推出可视区、关不掉 */
  .modal__panel { max-height: 100%; }
  .modal__body { -webkit-overflow-scrolling: touch; }
  .compare-table { font-size: .82rem; min-width: 540px; }
  .compare-table th, .compare-table td { padding: 10px 10px; }
  .compare-table tbody th { width: 120px; }
  /* 横向溢出交给容器滚动，避免整页横滚 */
  #compare-body { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* 超窄屏（320–420px）：压缩顶栏，避免主题按钮被挤出视口
   —— 只收窄 select 与品牌字号，图标按钮保持 40px 触控尺寸 */
@media (max-width: 420px) {
  .app-header__inner { gap: 6px; }
  .header-actions { gap: 6px; }
  .field--select select { padding: 6px 22px 6px 8px; font-size: .76rem; }
  .brand__text strong { font-size: .92rem; }
  .hero__stats dd { font-size: 1.05rem; }
}

/* 暗色主题下让原生控件（滚动条、select 下拉、range、checkbox）也跟着变暗 */
html[data-theme="dark"] { color-scheme: dark; }
html:not([data-theme="dark"]) { color-scheme: light; }
