.reference-card {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 16px;
  align-items: center;
  margin: 18px 0 8px;
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 14px;
}

.reference-card img {
  width: 150px;
  height: 112px;
  object-fit: cover;
  border-radius: 10px;
  background: #dde1da;
}

.reference-card div { display: grid; gap: 4px; }
.reference-card strong { font: 700 16px Georgia, serif; }
.reference-card small { color: var(--muted); }
.reference-card a { width: max-content; color: var(--ink); font-size: 10px; font-weight: 750; }
.reference-card code {
  width: max-content;
  margin-top: 4px;
  padding: 4px 7px;
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 9px;
}
.reference-card.missing { grid-template-columns: 1fr; border-color: #e6b7bb; background: var(--red); }

#productDialog { width: min(1500px, 96vw); max-height: 94vh; }
#productDialog .dialog-close { position: fixed; right: max(3vw, 22px); top: 4vh; }
.product-detail-page { padding: 34px; }
.product-detail-page .detail-header { grid-template-columns: 132px minmax(0, 1fr) auto; }
.product-detail-page .detail-header > img,
.detail-hero-empty { width: 132px; height: 132px; border-radius: 12px; object-fit: contain; background: #e5e9e3; }
.detail-hero-empty { display: grid; place-items: center; font-size: 34px; }
.detail-header-actions { display: grid; justify-items: end; gap: 10px; }
.detail-action { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; width: max-content; padding: 9px 14px; border: 1px solid var(--ink); border-radius: 8px; color: var(--ink); background: #fff; font-size: 10px; font-weight: 800; text-decoration: none; }
.detail-action.dark { color: #fff; background: var(--ink); }
.detail-action.disabled { color: var(--muted); border-color: var(--line); cursor: not-allowed; }
.detail-jump { position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; gap: 7px; padding: 12px 0; background: linear-gradient(var(--surface) 80%, transparent); }
.detail-jump a { padding: 7px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink); background: #fff; font-size: 9px; font-weight: 750; text-decoration: none; }
.reference-card.rich { grid-template-columns: minmax(0, 360px) minmax(0, 1fr); align-items: stretch; border-radius: 12px; }
.reference-card.rich img { width: 100%; height: auto; aspect-ratio: 1; object-fit: contain; border-radius: 8px; background: #fff; }
.reference-card.rich > div { min-width: 0; align-content: center; padding: 10px; }
.competitor-reference-gallery { display: grid; width: 100%; min-width: 0; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; align-content: start !important; }
.competitor-reference-gallery a { width: 100%; min-width: 0; max-width: 100%; position: relative; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.competitor-reference-gallery a:first-child { grid-column: 1/-1; }
.competitor-reference-gallery a img { display: block; width: 100%; max-width: 100%; height: auto; aspect-ratio: 1; object-fit: contain; }
.competitor-reference-gallery a span { position: absolute; left: 8px; bottom: 8px; padding: 3px 7px; border-radius: 99px; background: rgba(23,25,22,.85); color: #fff; font-size: 11px; font-weight: 750; }
.reference-facts { display: grid !important; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px !important; margin: 8px 0 12px; }
.reference-facts div { padding: 8px; border: 1px solid var(--line); background: #fff; }
.reference-facts span,.detail-kv span { color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: 8px; }
.reference-facts strong,.detail-kv strong { display: block; overflow-wrap: anywhere; font-size: 10px; }
.reference-card.rich code { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-section { scroll-margin-top: 54px; margin-top: 16px; padding: 22px; border: 1px solid var(--line); background: #fff; border-radius: 12px; }
.detail-section-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.detail-section-head h3 { margin: 3px 0 0; font: 750 22px/1.05 Georgia,serif; }
.detail-section-head > strong,.detail-section-head > small { color: var(--muted); font-size: 10px; }
.detail-gallery { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 10px; }
.gallery-image { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--ink); text-decoration: none; }
.gallery-image:hover { border-color: var(--ink); }
.gallery-image img { width: 100%; aspect-ratio: 1; display: block; object-fit: contain; background: #e5e9e3; }
.workflow-first { margin-top: 4px; }
.gallery-image span,.gallery-image small { display: block; padding: 7px 8px 0; font-size: 9px; font-weight: 750; }
.gallery-image small { min-height: 34px; padding-top: 2px; color: var(--muted); font-size: 8px; font-weight: 500; }
.factory-gallery { grid-template-columns: repeat(3,minmax(0,220px)); }
.subheading { margin: 20px 0 9px; font-size: 11px; }
.detail-columns { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; margin-top: 14px; }
.detail-columns > div,.copy-block { padding: 16px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; }
.detail-columns h4,.copy-block h4 { margin: 0 0 11px; font-size: 11px; }
.detail-kv { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.detail-kv > div { min-width: 0; padding-bottom: 7px; border-bottom: 1px solid var(--line); }
.copy-block { margin-top: 14px; }
.copy-block p { margin: 0; color: #4e554e; font-size: 11px; white-space: pre-line; }
.long-copy p { max-height: 230px; overflow: auto; }
.raw-detail { margin-top: 10px; border: 1px solid var(--line); border-radius: 8px; background: #f8faf7; }
.raw-detail summary { padding: 11px 13px; cursor: pointer; font-size: 10px; font-weight: 750; }
.raw-detail pre { max-height: 360px; overflow: auto; margin: 0; padding: 14px; border-top: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 9px; }
.table-scroll { overflow: auto; }
.detail-table { width: 100%; border-collapse: collapse; font-size: 9px; }
.detail-table th { position: sticky; top: 0; padding: 9px; text-align: left; background: var(--ink); color: #fff; }
.detail-table td { padding: 9px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.product-detail-page .timeline-step { grid-template-columns: 34px minmax(180px,1fr) 110px minmax(250px,auto); align-items: start; }
.timeline-actions { display: flex; flex-wrap: wrap; gap: 7px; justify-content: flex-end; }
.regen-btn { min-height: 34px; padding: 7px 10px; border: 1px solid var(--ink); border-radius: 8px; background: #fff; font-size: 9px; font-weight: 750; cursor: pointer; }
.regen-btn:hover { background: var(--lime); }
.regen-btn:disabled { cursor: not-allowed; opacity: .45; }
.regen-update-btn:not(:disabled) { background: var(--lime); }
.job-list,.artifact-list { display: grid; margin-top: 12px; }
.job-row { display: grid; grid-template-columns: minmax(220px,1fr) 110px 110px 130px; gap: 12px; align-items: center; padding: 10px 2px; border-bottom: 1px solid var(--line); font-size: 9px; }
.job-row div { min-width: 0; }
.job-row strong,.job-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-row small,.artifact-row small { color: var(--muted); }
.artifact-list { margin-top: 18px; }
.artifact-row { display: grid; grid-template-columns: 190px minmax(0,1fr) 160px; gap: 12px; padding: 9px 2px; border-bottom: 1px solid var(--line); font-size: 9px; }
.artifact-row span { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 650px) {
  .reference-card { grid-template-columns: 1fr; }
  .reference-card img { width: 100%; height: 180px; }
  .product-detail-page { padding: 18px; }
  .product-detail-page .detail-header { grid-template-columns: 72px 1fr; }
  .product-detail-page .detail-header > img,.detail-hero-empty { width:72px;height:72px; }
  .detail-header-actions { grid-column: 1/-1; justify-items: start; }
  .reference-card.rich,.detail-columns { grid-template-columns: 1fr; }
  .competitor-reference-gallery { max-width: 360px; }
  .reference-facts { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .detail-gallery { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .product-detail-page .timeline-step { grid-template-columns: 32px 1fr; }
  .product-detail-page .step-times,.timeline-actions { grid-column: 2; text-align: left; }
  .timeline-actions { justify-content: flex-start; }
  .job-row,.artifact-row { grid-template-columns: 1fr; }
}
