:root {
  color-scheme: light;
  --navy: #0a3b86;
  --navy-strong: #072c65;
  --orange: #ec7307;
  --green: #247359;
  --ink: #17232d;
  --muted: #5d6872;
  --line: #d5dde2;
  --soft: #eef2f3;
  --blue-soft: #eaf1fa;
  --white: #ffffff;
  --page: #f7f8f8;
  --shadow: 0 14px 38px rgba(18, 35, 52, 0.14);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Noto Sans Arabic", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  min-width: 320px;
  letter-spacing: 0;
}

button, input, select { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  height: 68px;
  padding: 0 max(18px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand img { width: 208px; height: 39px; object-fit: contain; object-position: left center; }
.top-actions { display: flex; align-items: center; gap: 10px; }

.language-switch {
  height: 34px;
  padding: 3px;
  display: grid;
  grid-template-columns: repeat(3, 42px);
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.language-switch button {
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.language-switch button.is-active { background: var(--white); color: var(--navy); box-shadow: 0 1px 4px rgba(23, 35, 45, 0.12); }

.icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  color: var(--navy);
  font-size: 23px;
  line-height: 1;
}

.icon-button:hover { border-color: var(--navy); background: var(--blue-soft); }

main { width: min(1280px, calc(100% - 40px)); margin: 0 auto; padding-bottom: 96px; }

.catalog-intro {
  min-height: 178px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  padding: 42px 0 26px;
  border-bottom: 1px solid var(--line);
}

.eyebrow { margin: 0 0 9px; color: var(--orange); font-size: 13px; font-weight: 800; text-transform: uppercase; }
h1, h2, p { overflow-wrap: anywhere; }
h1 { margin: 0; color: var(--navy); font-size: clamp(30px, 4vw, 48px); line-height: 1.12; }
.intro-copy { max-width: 720px; margin: 12px 0 0; color: var(--muted); font-size: 15px; line-height: 1.7; }

.catalog-count { flex: 0 0 auto; display: grid; justify-items: end; padding-bottom: 4px; }
.catalog-count strong { color: var(--navy); font-size: 38px; line-height: 1; }
.catalog-count span { margin-top: 6px; color: var(--muted); font-size: 12px; }

.catalog-tools { padding: 20px 0 4px; }
.search-field {
  height: 50px;
  display: grid;
  grid-template-columns: 34px 1fr 36px;
  align-items: center;
  max-width: 760px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.search-field:focus-within { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(10, 59, 134, 0.09); }
.search-field > span { justify-self: center; color: var(--navy); font-size: 23px; transform: rotate(-20deg); }
.search-field input { min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); }
.search-field button { width: 32px; height: 32px; border: 0; background: transparent; color: var(--muted); font-size: 20px; visibility: hidden; }
.search-field.has-value button { visibility: visible; }

.major-section, .results-section { padding: 30px 0 4px; }
.section-heading, .results-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.section-heading h2, .results-toolbar h2 { margin: 0; color: var(--ink); font-size: 20px; line-height: 1.3; }
.text-button { border: 0; background: transparent; color: var(--navy); font-size: 13px; font-weight: 800; }

.major-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.major-card {
  position: relative;
  min-height: 190px;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  padding: 18px;
  border: 0;
  border-radius: 6px;
  background: #1d2d38;
  color: var(--white);
  text-align: left;
}
.major-card::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0.04) 20%, rgba(7,22,34,0.88) 100%); }
.major-card::before { content: "RUIJIANG METAL"; position: absolute; z-index: 2; top: 10px; left: 10px; padding: 4px 7px; background: rgba(7, 25, 39, 0.58); color: rgba(255,255,255,0.92); font-size: 9px; font-weight: 850; }
.major-card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform 220ms ease; }
.major-card:hover img { transform: scale(1.025); }
.major-card.is-active { outline: 3px solid var(--orange); outline-offset: -3px; }
.major-copy { position: relative; z-index: 3; width: 100%; }
.major-copy strong { display: block; font-size: 19px; line-height: 1.3; }
.major-copy span { display: block; margin-top: 5px; color: #e5ebee; font-size: 12px; }

.results-section { scroll-margin-top: 82px; }
.breadcrumb { margin: 0 0 5px; color: var(--navy); font-size: 13px; font-weight: 800; }
.sort-control { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.sort-control select { height: 36px; padding: 0 28px 0 10px; border: 1px solid var(--line); border-radius: 5px; background: var(--white); color: var(--ink); }

.subcategory-row { min-height: 40px; display: flex; gap: 8px; overflow-x: auto; padding: 0 0 14px; scrollbar-width: thin; }
.subcategory-chip { flex: 0 0 auto; min-height: 36px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 5px; background: var(--white); color: var(--ink); font-size: 12px; }
.subcategory-chip.is-active { border-color: var(--navy); background: var(--navy); color: var(--white); }

.product-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.product-card { overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: var(--white); }
.product-card button { width: 100%; padding: 0; border: 0; background: transparent; text-align: inherit; }
.product-image { position: relative; aspect-ratio: 4 / 3; overflow: hidden; background: var(--soft); }
.product-image img { width: 100%; height: 100%; object-fit: cover; transition: transform 180ms ease; }
.product-image::before { content: "RUIJIANG METAL"; position: absolute; z-index: 2; left: 8px; bottom: 8px; padding: 4px 7px; background: rgba(7, 25, 39, 0.56); color: rgba(255,255,255,0.94); font-size: 9px; font-weight: 850; pointer-events: none; }
.product-image.image-error::after { content: "Image unavailable"; position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; color: var(--muted); font-size: 12px; text-align: center; }
.product-card:hover .product-image img { transform: scale(1.025); }
.image-count { position: absolute; z-index: 3; right: 8px; bottom: 8px; min-width: 28px; padding: 4px 7px; border-radius: 4px; background: rgba(8, 24, 36, 0.78); color: var(--white); font-size: 11px; text-align: center; }
.product-copy { min-height: 112px; padding: 12px; }
.product-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 10px; }
.product-copy h3 { margin: 8px 0 0; color: var(--navy); font-size: 14px; line-height: 1.4; font-weight: 750; }

.empty-state { min-height: 220px; align-content: center; justify-items: center; color: var(--muted); text-align: center; }
.empty-state strong { display: block; color: var(--ink); font-size: 18px; }
.empty-state span { display: block; margin-top: 8px; }
.empty-state:not([hidden]) { display: grid; }
.load-more { min-width: 180px; height: 44px; margin: 24px auto 0; display: block; border: 1px solid var(--navy); border-radius: 5px; background: var(--white); color: var(--navy); font-weight: 800; }
.load-more:hover { background: var(--blue-soft); }

.mobile-actions { position: fixed; z-index: 25; left: 50%; bottom: 16px; transform: translateX(-50%); width: min(560px, calc(100% - 28px)); display: grid; grid-template-columns: 0.8fr 1.2fr; gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,0.96); box-shadow: var(--shadow); backdrop-filter: blur(12px); }
.primary-action, .secondary-action { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 10px 16px; border-radius: 5px; font-weight: 800; text-align: center; }
.primary-action { background: var(--orange); color: var(--white); }
.primary-action:hover { background: #cf6000; }
.secondary-action { border: 1px solid var(--line); background: var(--white); color: var(--navy); }

.modal[hidden], .lightbox[hidden] { display: none; }
.modal { position: fixed; z-index: 60; inset: 0; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(5, 15, 23, 0.72); }
.product-dialog { position: absolute; left: 50%; bottom: 0; width: min(1100px, 100%); max-height: min(900px, 94dvh); overflow: auto; transform: translateX(-50%); border-radius: 8px 8px 0 0; background: var(--white); box-shadow: var(--shadow); }
.dialog-header { position: sticky; z-index: 3; top: 0; height: 56px; display: flex; align-items: center; justify-content: space-between; padding: 8px 14px; background: rgba(255,255,255,0.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); }
.dialog-body { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(320px, 0.92fr); gap: 28px; padding: 24px; }
.gallery-main { position: relative; width: 100%; aspect-ratio: 4 / 3; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: var(--soft); }
.gallery-main::after { content: "RUIJIANG METAL  ·  rujiangmetal.com"; position: absolute; right: 12px; bottom: 12px; padding: 6px 9px; background: rgba(7, 25, 39, 0.54); color: rgba(255,255,255,0.94); font-size: 10px; font-weight: 850; pointer-events: none; }
.gallery-main img { width: 100%; height: 100%; object-fit: contain; }
.thumbnail-row { display: grid; grid-template-columns: repeat(4, 66px); gap: 8px; margin-top: 10px; }
.thumbnail-button { position: relative; width: 66px; height: 54px; padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 4px; background: var(--soft); }
.thumbnail-button::after { content: "RJ"; position: absolute; right: 3px; bottom: 3px; padding: 2px 3px; background: rgba(7, 25, 39, 0.58); color: rgba(255,255,255,0.94); font-size: 7px; font-weight: 900; pointer-events: none; }
.thumbnail-button.is-active { border: 2px solid var(--orange); }
.thumbnail-button img { width: 100%; height: 100%; object-fit: cover; }
.product-code { margin: 0; color: var(--orange); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.product-detail h2 { margin: 7px 0 0; color: var(--navy); font-size: 26px; line-height: 1.25; }
.product-category { margin: 10px 0 0; color: var(--green); font-size: 12px; font-weight: 800; }
.product-summary { margin: 20px 0 0; color: var(--muted); font-size: 14px; line-height: 1.65; }
.spec-list { margin: 20px 0 0; border-top: 1px solid var(--line); }
.spec-row { display: grid; grid-template-columns: minmax(100px, 0.38fr) 1fr; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 12px; line-height: 1.5; }
.spec-row dt { color: var(--muted); }
.spec-row dd { margin: 0; color: var(--ink); font-weight: 650; }
.rfq-note { margin-top: 18px; padding: 13px; border-left: 4px solid var(--orange); background: #fff1e5; }
.rfq-note strong, .rfq-note span { display: block; }
.rfq-note strong { color: var(--navy); font-size: 12px; }
.rfq-note span { margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.dialog-actions { position: sticky; bottom: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px 24px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(255,255,255,0.98); }

.lightbox { position: fixed; z-index: 90; inset: 0; display: grid; place-items: center; padding: 54px 16px 16px; background: rgba(2, 8, 12, 0.94); }
.lightbox::after { content: "RUIJIANG METAL  ·  rujiangmetal.com"; position: absolute; right: 24px; bottom: 24px; padding: 7px 10px; background: rgba(7, 25, 39, 0.62); color: rgba(255,255,255,0.95); font-size: 11px; font-weight: 850; pointer-events: none; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox-close { position: absolute; top: 12px; right: 14px; border-color: #65727b; background: rgba(255,255,255,0.1); color: var(--white); }

.toast { position: fixed; z-index: 120; left: 50%; bottom: 92px; max-width: calc(100% - 32px); transform: translate(-50%, 14px); padding: 10px 14px; border-radius: 5px; background: var(--ink); color: var(--white); font-size: 12px; opacity: 0; pointer-events: none; transition: 160ms ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.skeleton { position: relative; overflow: hidden; min-height: 280px; background: var(--soft); border-radius: 6px; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,0.72), transparent); animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }

[dir="rtl"] .major-card { text-align: right; }
[dir="rtl"] .major-card::before, [dir="rtl"] .product-image::before { right: 8px; left: auto; }
[dir="rtl"] .catalog-count { justify-items: start; }
[dir="rtl"] .rfq-note { border-left: 0; border-right: 4px solid var(--orange); }
[dir="rtl"] .brand img { object-position: right center; }

@media (min-width: 1020px) {
  .mobile-actions { left: auto; right: 22px; transform: none; width: 380px; }
  .product-dialog { bottom: 50%; transform: translate(-50%, 50%); border-radius: 8px; }
}

@media (max-width: 900px) {
  .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dialog-body { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .topbar { height: 60px; padding-right: 12px; padding-left: 12px; }
  .brand img { width: 142px; height: 31px; }
  .top-actions { gap: 6px; }
  .language-switch { grid-template-columns: repeat(3, 30px); }
  #shareCatalogButton { width: 34px; height: 34px; display: inline-grid; }
  main { width: min(100% - 24px, 680px); }
  .catalog-intro { min-height: 148px; align-items: flex-start; padding: 28px 0 20px; }
  .catalog-intro h1 { font-size: 30px; }
  .catalog-count { padding-top: 7px; }
  .catalog-count strong { font-size: 28px; }
  .intro-copy { font-size: 13px; }
  .major-section, .results-section { padding-top: 24px; }
  .major-grid { grid-template-columns: 1fr; gap: 10px; }
  .major-card { min-height: 126px; }
  .major-copy strong { font-size: 17px; }
  .results-toolbar { align-items: flex-start; }
  .sort-control > span { display: none; }
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .product-copy { min-height: 104px; padding: 10px; }
  .product-copy h3 { font-size: 12px; }
  .product-meta { font-size: 9px; }
  .dialog-body { gap: 18px; padding: 14px; }
  .product-detail h2 { font-size: 21px; }
  .dialog-actions { padding-right: 14px; padding-left: 14px; }
  .gallery-main { aspect-ratio: 1 / 1; }
}

@media (max-width: 390px) {
  .brand img { width: 126px; }
  .language-switch { grid-template-columns: repeat(3, 28px); }
  .catalog-intro { gap: 14px; }
  .catalog-count strong { font-size: 24px; }
  .dialog-actions { grid-template-columns: 0.9fr 1.1fr; }
  .primary-action, .secondary-action { padding-right: 9px; padding-left: 9px; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
