:root {
  color-scheme: light;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #181c25;
  background: #f8fafc;
  font-synthesis: none;
  --blue: #4f46e5;
  --blue-dark: #4338ca;
  --line: #e5e7eb;
  --muted: #6b7280;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; padding-bottom: env(safe-area-inset-bottom); }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button, a, summary, select { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .6; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid #a5b4fc; outline-offset: 2px; }
[hidden] { display: none !important; }

.topbar {
  height: calc(56px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(24px, calc((100vw - 1080px) / 2)) 0;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.brand { display: flex; align-items: center; gap: 9px; color: inherit; text-decoration: none; white-space: nowrap; }
.brand strong { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.brand > span { color: var(--muted); font-size: 12px; }
.topbar-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.install-app {
  border: 1px solid #c7d2fe;
  background: #eef2ff;
  color: var(--blue);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.health { font-size: 12px; color: var(--muted); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.health.online { color: #15803d; }

.search-band {
  background: #fff;
  padding: 20px max(24px, calc((100vw - 1080px) / 2)) 16px;
  border-bottom: 1px solid var(--line);
}
.search-form label { display: block; font-size: 20px; font-weight: 700; margin-bottom: 12px; }
.search-row { display: grid; grid-template-columns: minmax(0, 1fr) 104px; gap: 8px; }
.input-wrap { position: relative; min-width: 0; }
.search-row input {
  min-width: 0;
  width: 100%;
  height: 48px;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  padding: 0 36px 0 14px;
  font-size: 16px;
  background: #fff;
  outline: none;
}
.search-row input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); }
.clear-keyword {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 999px;
  background: #f3f4f6;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  display: grid;
  place-items: center;
}
.search-row button[type="submit"] {
  border: 0;
  background: var(--blue);
  color: #fff;
  border-radius: 10px;
  font-weight: 600;
  font-size: 15px;
  min-height: 48px;
}
.search-row button[type="submit"]:hover { background: var(--blue-dark); }

.quick-strip { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.quick-search, .recent-searches {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 0;
}
.quick-search::-webkit-scrollbar, .recent-searches::-webkit-scrollbar { display: none; }
.quick-search button {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 5px 12px;
  color: #4b5563;
  font-size: 12.5px;
  min-height: 34px;
  white-space: nowrap;
}
.quick-search button:hover { border-color: var(--blue); color: var(--blue); }
.recent-label { flex: 0 0 auto; font-size: 11.5px; color: var(--muted); }
.recent-chip {
  flex: 0 0 auto;
  border: 0;
  background: #f1f5f9;
  color: #475569;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11.5px;
  white-space: nowrap;
}
.recent-clear {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  padding: 4px 6px;
}
.connection-note { font-size: 12px; color: var(--muted); margin: 10px 0 0; line-height: 1.5; }

.result-band { width: min(1080px, calc(100% - 48px)); margin: 0 auto; padding: 18px 0 36px; }
.result-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.result-header h1 { font-size: 19px; line-height: 1.4; margin: 0 0 3px; overflow-wrap: anywhere; }
.result-header p { font-size: 12.5px; color: var(--muted); margin: 0; line-height: 1.5; }
#cancel { flex-shrink: 0; min-height: 38px; color: #b91c1c; background: #fff; border: 1px solid #fecaca; border-radius: 8px; padding: 0 12px; font-size: 13px; }

#coverage { border: 1px solid var(--line); background: #fff; border-radius: 10px; margin-bottom: 10px; }
#coverage > summary { padding: 10px 14px; font-size: 12.5px; line-height: 1.5; cursor: pointer; color: #374151; font-weight: 500; }
.channel-status { display: grid; grid-template-columns: 1fr 1fr; padding: 0 14px 10px; gap: 6px; }
.channel-status > div { border-top: 1px solid #f1f5f9; padding: 8px 6px; border-radius: 6px; font-size: 12px; line-height: 1.5; cursor: pointer; }
.channel-status > div:hover { background: #f8fafc; }
.channel-status > div.is-selected { background: #eef2ff; }
.channel-status strong { display: block; font-size: 12.5px; }
.channel-status p { margin: 2px 0 0; color: var(--muted); font-size: 11.5px; }
.channel-status a { color: var(--blue); display: inline-flex; padding: 4px 0; font-size: 11.5px; }
.channel-status .channel-error strong { color: #b45309; }
.channel-status .channel-ok strong { color: #15803d; }

.channel-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 0 8px;
}
.channel-pills::-webkit-scrollbar { display: none; }
.channel-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #4b5563;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.channel-pill:hover { border-color: #c7d2fe; color: var(--blue); background: #f5f7ff; }
.channel-pill.is-active { border-color: var(--blue); background: var(--blue); color: #fff; }
.pill-count { font-size: 11px; opacity: .8; font-variant-numeric: tabular-nums; }
.pill-dot { width: 6px; height: 6px; border-radius: 999px; background: #ef4444; }
.channel-pill.is-active .pill-dot { background: rgba(255, 255, 255, .85); }

.channel-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  padding: 8px 12px;
  border: 1px solid #e0e7ff;
  border-radius: 10px;
  background: #f5f7ff;
  font-size: 12px;
}
.channel-banner-info { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; min-width: 0; }
.channel-banner-title { color: #312e81; font-weight: 600; }
.channel-banner-meta { color: #4b5563; }
.channel-banner-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 6px; }
.channel-open {
  padding: 4px 10px;
  border-radius: 7px;
  color: var(--blue);
  background: #fff;
  border: 1px solid #c7d2fe;
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
}
.channel-reset { padding: 4px 10px; border: 1px solid #d1d5db; border-radius: 7px; color: #374151; background: #fff; font-size: 12px; }

.filters {
  display: grid;
  grid-template-columns: 1.2fr .8fr 1.2fr auto;
  gap: 8px;
  align-items: end;
  background: #f8fafc;
  padding: 4px 0 10px;
  position: sticky;
  top: 0;
  z-index: 5;
}
.filters label, .more-filters label { min-width: 0; display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: var(--muted); }
select, .more-filters input:not([type=checkbox]) {
  width: 100%;
  height: 40px;
  min-width: 0;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  color: #181c25;
  padding: 0 9px;
  font-size: 13.5px;
}
.filters button, .more-filters button {
  height: 40px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  color: #374151;
  padding: 0 13px;
  font-size: 13px;
  white-space: nowrap;
}
.filters button[aria-expanded=true] { background: #eef2ff; border-color: var(--blue); color: var(--blue); }

.sheet-head { display: none; }
.more-filters {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 12px 10px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 10px;
}
.more-filters .check { flex-direction: row; align-items: center; gap: 7px; min-height: 40px; font-size: 13px; color: #374151; }
.check input { width: 18px; height: 18px; accent-color: var(--blue); margin: 0; }

.price-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.strip-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid #d1fae5;
  background: #f0fdf4;
}
.strip-item.is-ref { border-color: #fde68a; background: #fffbeb; }
.strip-label { font-size: 11px; color: #4b5563; }
.strip-item strong { font-size: 16px; color: #15803d; font-variant-numeric: tabular-nums; }
.strip-item.is-ref strong { color: #b45309; }
.strip-item small { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.result-count { font-size: 12px; color: var(--muted); line-height: 1.5; margin: 0 0 10px; }
.results { display: grid; gap: 8px; }
.product {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 176px;
  align-items: stretch;
  gap: 16px;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.product-main { min-width: 0; }
.product-labels { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; min-height: 28px; }
.source { font-size: 11px; font-weight: 600; color: #3730a3; background: #eef2ff; padding: 2px 7px; border-radius: 5px; }
.price-kind { font-size: 11px; color: var(--muted); }
.favorite { margin-left: auto; background: transparent; color: #9ca3af; border: 0; padding: 0 4px; min-height: 36px; min-width: 36px; font-size: 21px; }
.favorite[aria-pressed=true] { color: #f59e0b; }
.product-body { display: flex; gap: 10px; align-items: flex-start; }
.product-thumb { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; flex-shrink: 0; background: #f3f4f6; }
.product-text { min-width: 0; flex: 1; }
.product h2 { margin: 0; font-size: 15px; line-height: 1.45; font-weight: 600; overflow-wrap: anywhere; }
.description { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--muted); font-size: 12px; line-height: 1.55; margin: 5px 0; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11.5px; color: var(--muted); margin-top: 4px; overflow-wrap: anywhere; }
.reference-note { font-size: 11px; color: #92400e; margin: 5px 0 0; line-height: 1.5; }
.offer {
  border-left: 1px solid #f1f5f9;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  padding-left: 16px;
  gap: 10px;
}
.offer-price { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.price { color: #dc2626; font-size: 22px; font-weight: 700; letter-spacing: -.4px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stock { color: #15803d; font-size: 12px; }
.product.is-reference .stock { color: #b45309; }
.offer-actions { display: flex; align-items: center; gap: 6px; }
.copy-link {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid #d1d5db;
  border-radius: 7px;
  background: #fff;
  color: #4b5563;
  font-size: 12px;
}
.offer a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--blue);
  border-radius: 7px;
  background: var(--blue);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.offer a:hover { background: var(--blue-dark); }
.product.is-reference { border-color: #eadfc8; border-style: dashed; }

.empty {
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  min-height: 220px;
  padding: 28px 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}
.empty img { opacity: .8; margin-bottom: 12px; }
.empty strong { font-size: 16px; color: #181c25; }
.empty p { margin: 8px 0; }
.empty.error { color: #b91c1c; }
.loading::before { content: ""; width: 24px; height: 24px; border: 3px solid #e0e7ff; border-top-color: var(--blue); border-radius: 50%; margin-bottom: 14px; animation: spin .85s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#load-more { width: 100%; min-height: 44px; border: 1px solid #c7d2fe; border-radius: 9px; color: var(--blue); background: #fff; margin-top: 12px; font-weight: 600; }
.footnote { font-size: 11px; color: #9ca3af; line-height: 1.7; margin: 18px 0 0; }

.back-top {
  position: fixed;
  right: 16px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 15;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .94);
  color: var(--blue);
  box-shadow: 0 6px 18px rgba(15, 23, 42, .14);
  font-size: 18px;
  font-weight: 700;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 40;
  max-width: min(360px, calc(100vw - 32px));
  padding: 9px 14px;
  border-radius: 999px;
  background: rgba(24, 28, 37, .92);
  color: #fff;
  font-size: 12.5px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
}

@media (max-width: 640px) {
  .topbar { height: calc(50px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 14px 0; }
  .brand > span { display: none; }
  .brand strong { font-size: 17px; }
  .health { max-width: 132px; font-size: 11px; }
  .search-band { padding: 14px 14px 12px; }
  .search-form label { font-size: 18px; margin-bottom: 9px; }
  body.has-results .search-form label,
  body.has-results .connection-note { display: none; }
  .search-row { grid-template-columns: minmax(0, 1fr) 76px; gap: 7px; }
  .search-row input { height: 46px; padding: 0 34px 0 12px; }
  .search-row button[type="submit"] { min-height: 46px; font-size: 14.5px; }
  .quick-search button { min-height: 36px; font-size: 12px; padding: 5px 11px; }
  .connection-note { font-size: 11px; }
  .result-band { width: calc(100% - 24px); padding-top: 12px; }
  .result-header { margin-bottom: 8px; }
  .result-header h1 { font-size: 16.5px; }
  .result-header p { font-size: 11.5px; }
  .channel-status { grid-template-columns: 1fr; }
  .channel-pill { height: 34px; padding: 0 11px; font-size: 12px; }
  .channel-banner { padding: 7px 10px; font-size: 11.5px; }
  .filters { grid-template-columns: minmax(0, 1fr) 72px minmax(0, 1.1fr) auto; gap: 5px; padding: 4px 0 8px; }
  .filters select { height: 38px; padding: 0 4px; font-size: 12px; }
  .filters button { height: 38px; padding: 0 10px; font-size: 12px; }
  .filter-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .4); z-index: 25; }
  .more-filters {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    margin: 0;
    max-height: 78dvh;
    overflow-y: auto;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 14px 16px calc(18px + env(safe-area-inset-bottom));
    border: 0;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -10px 32px rgba(15, 23, 42, .18);
  }
  .sheet-head {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--line);
  }
  .sheet-head strong { font-size: 15px; }
  .close-filters { border: 0 !important; background: #eef2ff !important; color: var(--blue) !important; height: 32px !important; padding: 0 12px !important; font-weight: 600; }
  .spec-label { grid-column: 1 / -1; }
  #reset-filters { grid-column: 1 / -1; }
  body.sheet-open { overflow: hidden; }
  .price-strip { grid-template-columns: 1fr; gap: 6px; }
  .product { grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 11px 12px; }
  .product h2 { font-size: 14.5px; }
  .offer { flex-direction: row; justify-content: space-between; align-items: center; border-left: 0; border-top: 1px solid #f1f5f9; padding: 10px 0 0; gap: 8px; }
  .offer-price { min-width: 0; flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
  .price { font-size: 21px; }
  .offer-actions { flex-shrink: 0; }
  .copy-link { min-height: 38px; padding: 0 10px; }
  .offer a { min-height: 38px; min-width: 84px; padding: 0 12px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; scroll-behavior: auto !important; } }
