:root {
  --bg: #f7f8f5;
  --surface: #ffffff;
  --ink: #17201d;
  --muted: #6d766f;
  --line: #d9ded8;
  --brand: #0f766e;
  --brand-dark: #0b5f59;
  --accent: #0f766e;
  --soft: #e9f5f2;
  --warn-bg: #fff7ed;
  --warn: #b45309;
  --blue-soft: #eff6ff;
  --blue: #1d4ed8;
  --shadow: 0 10px 30px rgba(23, 32, 29, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

body {
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
}

body.preview-open {
  overflow: hidden;
  touch-action: none;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.product-shell {
  width: min(100%, 1080px);
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 18px max(34px, env(safe-area-inset-bottom));
}

.view,
.subview {
  display: none;
}

.view.active,
.subview.active {
  display: block;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0 14px;
  min-width: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.16;
}

h2 {
  font-size: 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 14px;
  font-weight: 850;
}

.ghost-link,
.primary-link,
.icon-button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  font-weight: 850;
}

.ghost-link,
.primary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  white-space: nowrap;
}

.primary-link {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.icon-button {
  width: 44px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  font-size: 24px;
  font-weight: 850;
}

.search-hero {
  margin: 4px 0 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

label {
  display: grid;
  gap: 8px;
}

label span {
  color: var(--brand-dark);
  font-size: 15px;
  font-weight: 900;
}

input {
  width: 100%;
  min-height: 64px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--ink);
  font-size: 22px;
  font-weight: 850;
  outline: none;
}

input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

.module-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
}

.module-tab,
.filter-chip,
.detail-tabs button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 900;
}

.module-tab {
  flex: 1 1 124px;
  padding: 0 12px;
}

.module-tab.active,
.filter-chip.active,
.detail-tabs button.active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric-grid article {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metric-grid strong {
  color: var(--brand-dark);
  font-size: 30px;
  font-weight: 950;
}

.metric-grid span,
.section-heading span,
.card-copy span,
.knowledge-card span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
  line-height: 1.35;
}

.section-block {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.model-grid,
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(238px, 1fr));
  gap: 10px;
}

.series-list,
.knowledge-list,
.ecommerce-list,
.search-results {
  display: grid;
  gap: 10px;
}

.series-list.small {
  margin-bottom: 10px;
}

.model-card,
.series-card,
.media-card,
.knowledge-card,
.empty-panel,
.source-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 6px 18px rgba(23, 32, 29, 0.05);
}

.model-card,
.media-card {
  overflow: hidden;
}

.media-card[data-preview-key] {
  cursor: zoom-in;
}

.model-card {
  cursor: pointer;
}

.series-card {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
}

.card-copy {
  min-width: 0;
  display: grid;
  gap: 6px;
  padding: 12px;
}

.series-card .card-copy {
  padding: 0;
}

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.card-title strong {
  min-width: 0;
  font-size: 20px;
  overflow-wrap: anywhere;
}

.card-meta-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.card-meta-line span:last-child {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-copy p,
.knowledge-card p,
.source-box p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.source-link {
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.source-link:hover {
  text-decoration: underline;
}

.inline-model-link {
  min-height: 34px;
  margin: 2px 4px 2px 0;
  padding: 0 10px;
  border: 1px solid var(--brand);
  border-radius: 8px;
  background: var(--soft);
  color: var(--brand-dark);
  font-weight: 900;
}

.inline-model-link:hover {
  background: var(--brand);
  color: #fff;
}

.image-box {
  width: 100%;
  aspect-ratio: 1.12;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: #eef2f1;
}

.series-card .image-box {
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.image-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-placeholder {
  height: 100%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  padding: 12px;
  color: var(--brand-dark);
  text-align: center;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.12), rgba(29, 78, 216, 0.1)),
    #f8faf9;
}

.identity-placeholder {
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), rgba(2, 132, 199, 0.06)),
    repeating-linear-gradient(45deg, rgba(15, 118, 110, 0.08) 0 1px, transparent 1px 12px),
    #f8faf9;
}

.image-placeholder strong {
  font-size: 18px;
  overflow-wrap: anywhere;
}

.image-placeholder span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.complete-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 950;
}

.complete-badge.level-100 {
  background: var(--soft);
  color: var(--brand-dark);
}

.complete-badge.level-70 {
  background: var(--blue-soft);
  color: var(--blue);
}

.complete-badge.level-50,
.complete-badge.level-30 {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 900;
}

.badge.pending {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge.verified {
  background: var(--soft);
  color: var(--brand-dark);
}

.badge.draft {
  background: var(--blue-soft);
  color: var(--blue);
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.model-filter-row {
  margin-bottom: 8px;
}

.filter-chip {
  padding: 0 14px;
}

.filter-summary {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 850;
}

.completeness-panel {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.completeness-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.completeness-head strong {
  font-size: 18px;
}

.completeness-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 8px;
}

.completeness-grid span {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 850;
}

.completeness-grid .ok {
  background: var(--soft);
  color: var(--brand-dark);
}

.completeness-grid .missing {
  background: var(--warn-bg);
  color: var(--warn);
}

.knowledge-card,
.empty-panel,
.source-box {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.empty-panel.compact {
  box-shadow: none;
}

.empty-panel strong {
  font-size: 18px;
}

.empty-panel span {
  color: var(--muted);
  line-height: 1.45;
}

.detail-drawer {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: end center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.38);
}

.image-preview {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: rgba(6, 10, 9, 0.96);
  color: #fff;
  overflow: hidden;
  touch-action: none;
}

.image-preview[hidden] {
  display: none;
}

.preview-bar {
  min-width: 0;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left));
  background: rgba(6, 10, 9, 0.72);
}

.preview-bar strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
}

.preview-button,
.preview-nav {
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-weight: 900;
  touch-action: manipulation;
}

.preview-button {
  min-width: 52px;
  min-height: 52px;
  padding: 0 14px;
  font-size: 30px;
}

.preview-button.text {
  min-width: 92px;
  font-size: 15px;
}

.preview-stage {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.preview-stage:active {
  cursor: grabbing;
}

.preview-stage img {
  max-width: 96vw;
  max-height: calc(100svh - 84px);
  width: auto;
  height: auto;
  object-fit: contain;
  transform-origin: center center;
  transition: transform 0.05s linear;
  image-rendering: auto;
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
}

@media (max-width: 640px) {
  .preview-bar {
    grid-template-columns: 58px minmax(0, 1fr) auto;
    gap: 8px;
  }

  .preview-button {
    min-width: 56px;
    min-height: 56px;
  }

  .preview-button.text {
    min-width: 104px;
    padding: 0 12px;
  }

  .preview-nav {
    top: auto;
    bottom: max(16px, env(safe-area-inset-bottom));
    width: 64px;
    height: 64px;
    transform: none;
    background: rgba(255, 255, 255, 0.18);
  }

  .preview-stage img {
    max-width: 100vw;
    max-height: calc(100svh - 86px);
  }
}

.preview-nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 58px;
  height: 72px;
  display: grid;
  place-items: center;
  transform: translateY(-50%);
  font-size: 46px;
  line-height: 1;
}

.preview-nav.previous {
  left: max(10px, env(safe-area-inset-left));
}

.preview-nav.next {
  right: max(10px, env(safe-area-inset-right));
}

.detail-drawer[hidden] {
  display: none;
}

.detail-card {
  width: min(100%, 820px);
  max-height: calc(100svh - 36px);
  overflow: auto;
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 8px;
  background: var(--bg);
  box-shadow: var(--shadow);
}

.detail-topbar {
  display: flex;
  justify-content: flex-end;
}

.detail-hero {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.detail-hero .image-box {
  border: 1px solid var(--line);
  border-radius: 8px;
}

.detail-hero > div:last-child {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.detail-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.detail-title-line h2 {
  font-size: 28px;
}

.detail-hero strong {
  font-size: 18px;
  overflow-wrap: anywhere;
}

.detail-hero span,
.detail-hero p {
  color: var(--muted);
  line-height: 1.42;
}

.detail-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.detail-tabs::-webkit-scrollbar {
  display: none;
}

.detail-tabs button {
  flex: 0 0 auto;
  padding: 0 12px;
  white-space: nowrap;
}

.detail-body {
  display: grid;
  gap: 10px;
}

.info-table {
  display: grid;
  gap: 8px;
}

.info-table div {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.info-table span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 850;
}

.info-table strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 60;
  transform: translate(-50%, 18px);
  opacity: 0;
  pointer-events: none;
  max-width: min(92vw, 420px);
  padding: 12px 14px;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  font-weight: 850;
  transition: 0.18s ease;
}

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

@media (max-width: 720px) {
  .product-shell {
    padding-inline: 14px;
  }

  h1 {
    font-size: 26px;
  }

  .topbar {
    align-items: flex-start;
  }

  .ghost-link {
    min-width: 72px;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .model-grid,
  .media-grid {
    grid-template-columns: 1fr;
  }

  .series-card {
    grid-template-columns: 104px minmax(0, 1fr);
  }

  .detail-drawer {
    padding: 0;
  }

  .detail-card {
    width: 100%;
    max-height: 100svh;
    border-radius: 8px 8px 0 0;
  }

  .detail-hero {
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 10px;
  }

  .detail-title-line h2 {
    font-size: 24px;
  }

  .info-table div {
    grid-template-columns: 88px minmax(0, 1fr);
  }
}

@media (max-width: 420px) {
  input {
    font-size: 19px;
  }

  .module-tab {
    flex-basis: 108px;
  }

  .series-card {
    grid-template-columns: 1fr;
  }
}
