:root {
  color-scheme: light;
  --ink: #182228;
  --muted: #66747a;
  --paper: #f5f7f7;
  --white: #ffffff;
  --line: #d9dfe1;
  --line-strong: #bbc6ca;
  --green: #17352d;
  --green-hover: #24483f;
  --gold: #b98e4c;
  --stage: #6f8c99;
  --selected: #e9eef0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
}

button,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(185, 142, 76, 0.5);
  outline-offset: 2px;
}

.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;
}

.library-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100%;
  height: 100%;
  min-height: 520px;
}

.library-header {
  position: relative;
  z-index: 6;
  display: grid;
  grid-template-columns: minmax(250px, 1fr) auto auto;
  align-items: center;
  gap: 22px;
  min-height: 72px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
}

.brand-block {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 11px;
}

.brand-logo {
  display: block;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.section-label {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 760;
  letter-spacing: 0;
  line-height: 1.2;
  text-transform: uppercase;
}

.brand-block h1 {
  margin: 0;
  overflow: hidden;
  font-size: 18px;
  font-weight: 680;
  letter-spacing: 0;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-link {
  display: inline-flex;
  height: 34px;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
}

.home-link:hover {
  border-color: var(--line-strong);
  background: #f5f7f7;
}

.family-switch {
  display: flex;
  align-items: center;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #eef2f3;
}

.family-switch button {
  min-width: 82px;
  height: 34px;
  padding: 0 15px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 740;
}

.family-switch button[aria-pressed="true"] {
  background: var(--green);
  color: #fff;
}

.browse-button,
.close-catalog {
  display: none;
}

.browse-label-short {
  display: none;
}

.library-workspace {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.catalog-panel {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--white);
}

.catalog-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
  min-height: 70px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.catalog-toolbar strong {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.2;
}

.catalog-toolbar select {
  height: 36px;
  max-width: 150px;
  padding: 0 30px 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 650;
}

.catalog-list {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.catalog-entry {
  border-bottom: 1px solid #e7ebec;
  background: #fff;
}

.catalog-item {
  position: relative;
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  width: 100%;
  min-height: 82px;
  gap: 12px;
  padding: 9px 14px;
  border: 0;
  border-bottom: 0;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.catalog-item:hover {
  background: #f7f9f9;
}

.catalog-item.is-selected {
  background: var(--selected);
  box-shadow: inset 3px 0 0 var(--gold);
}

.catalog-thumb {
  position: relative;
  display: block;
  width: 86px;
  height: 64px;
  overflow: hidden;
  border: 1px solid rgba(24, 34, 40, 0.14);
  border-radius: 3px;
  background: var(--stage);
}

.catalog-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.catalog-thumb.is-static {
  background: #fff;
}

.catalog-thumb.is-static img {
  object-fit: contain;
}

.catalog-thumb-badge {
  position: absolute;
  right: 4px;
  bottom: 4px;
  padding: 2px 4px;
  border-radius: 2px;
  background: rgba(23, 53, 45, 0.83);
  color: #fff;
  font-size: 8px;
  font-weight: 780;
}

.catalog-item-copy {
  align-self: center;
  min-width: 0;
}

.catalog-code {
  display: block;
  color: #52636a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  font-weight: 760;
  line-height: 1.2;
}

.catalog-name {
  display: -webkit-box;
  margin-top: 4px;
  overflow: hidden;
  font-size: 12px;
  font-weight: 690;
  line-height: 1.25;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.catalog-meta {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.2;
}

.variation-toggle {
  display: flex;
  width: calc(100% - 112px);
  min-height: 28px;
  align-items: center;
  justify-content: space-between;
  margin: -6px 14px 7px 98px;
  padding: 3px 7px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--green);
  font-size: 10px;
  font-weight: 760;
  text-align: left;
}

.variation-toggle:hover,
.variation-toggle[aria-expanded="true"] {
  background: #eef3f2;
}

.variation-toggle-arrow {
  font-size: 16px;
  line-height: 1;
  transition: transform 150ms ease;
}

.variation-toggle[aria-expanded="true"] .variation-toggle-arrow {
  transform: rotate(180deg);
}

.catalog-variations {
  margin: 0 10px 9px 24px;
  overflow: hidden;
  border-left: 2px solid #c8d2d5;
}

.catalog-variation-item {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  width: 100%;
  min-height: 62px;
  align-items: center;
  gap: 9px;
  padding: 6px 9px;
  border: 0;
  border-bottom: 1px solid #e7ebec;
  background: #f8fafa;
  color: var(--ink);
  text-align: left;
}

.catalog-variation-item:last-child {
  border-bottom: 0;
}

.catalog-variation-item:hover {
  background: #f0f4f4;
}

.catalog-variation-item.is-selected {
  background: #e4ecea;
  box-shadow: inset 3px 0 0 var(--green);
}

.catalog-variation-thumb {
  position: relative;
  display: block;
  width: 64px;
  height: 48px;
  overflow: hidden;
  border: 1px solid rgba(24, 34, 40, 0.14);
  border-radius: 2px;
  background: var(--stage);
}

.catalog-variation-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.catalog-empty {
  margin: 24px;
  color: var(--muted);
  font-size: 13px;
}

.model-area {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--stage);
}

.selection-bar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  min-height: 58px;
  gap: 16px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 247, 247, 0.98);
}

.selection-identity {
  min-width: 0;
}

.standard-code {
  display: block;
  color: var(--green);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  font-weight: 800;
}

.selection-name {
  display: block;
  max-width: 72vw;
  margin-top: 2px;
  overflow: hidden;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-page-link {
  display: inline-block;
  margin-top: 3px;
  color: var(--green);
  font-size: 10px;
  font-weight: 720;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.product-page-link[hidden] {
  display: none;
}

.viewer-frame-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--stage);
}

#viewer-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--stage);
}

#viewer-frame[hidden] {
  display: none;
}

.viewer-poster {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  width: 100%;
  height: 100%;
  padding: 0;
  overflow: hidden;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: var(--stage);
  color: #fff;
  cursor: pointer;
}

.viewer-poster[hidden] {
  display: none;
}

.viewer-poster img {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  box-sizing: border-box;
  padding: clamp(18px, 4vw, 56px);
  object-fit: contain;
}

.viewer-poster-prompt {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  grid-template-columns: auto auto auto;
  grid-template-rows: auto auto;
  align-items: center;
  min-width: 250px;
  column-gap: 10px;
  row-gap: 2px;
  border: 0;
  background: transparent;
  color: #fff;
  text-align: center;
  text-shadow: 0 2px 8px rgba(24, 34, 40, 0.78), 0 1px 2px rgba(24, 34, 40, 0.92);
  transform: translate(-50%, -50%);
}

.viewer-poster-prompt::before,
.viewer-poster-prompt::after {
  grid-row: 1 / -1;
  font-size: 30px;
  font-weight: 400;
  line-height: 1;
  opacity: 0.88;
  animation: poster-arrow-left 1.8s ease-in-out infinite;
  content: "↶";
}

.viewer-poster-prompt::after {
  grid-column: 3;
  animation-name: poster-arrow-right;
  content: "↷";
}

.viewer-poster-prompt strong {
  display: block;
  grid-column: 2;
  grid-row: 1;
  font-size: 13px;
}

.viewer-poster-prompt span {
  display: block;
  grid-column: 2;
  grid-row: 2;
  color: rgba(255, 255, 255, 0.78);
  font-size: 10px;
}

.viewer-poster:hover .viewer-poster-prompt {
  transform: translate(-50%, -50%) scale(1.03);
}

@keyframes poster-arrow-left {
  50% { transform: translateX(-4px) rotate(-8deg); }
}

@keyframes poster-arrow-right {
  50% { transform: translateX(4px) rotate(8deg); }
}

body.is-product-embed .library-shell {
  grid-template-rows: minmax(0, 1fr);
  min-height: 360px;
}

body.is-product-embed .library-header,
body.is-product-embed .catalog-panel {
  display: none;
}

body.is-product-embed .library-workspace {
  grid-template-columns: minmax(0, 1fr);
}

.viewer-loading,
.viewer-empty {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  padding: 28px;
  background: var(--stage);
  color: rgba(255, 255, 255, 0.94);
  text-align: center;
}

.viewer-loading span:first-child {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

.viewer-empty span {
  max-width: 520px;
  color: rgba(255, 255, 255, 0.76);
  font-size: 13px;
  line-height: 1.5;
}

.static-reference-switch {
  display: flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 5px;
  background: rgba(24, 34, 40, 0.7);
}

.static-reference-switch button {
  height: 31px;
  padding: 0 12px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: rgba(255, 255, 255, 0.74);
  font-size: 10px;
  font-weight: 720;
}

.static-reference-switch button[aria-pressed="true"] {
  background: #fff;
  color: var(--ink);
}

.static-reference-switch button[hidden] {
  display: none;
}

.static-reference-image {
  display: none;
  width: min(72vw, 760px);
  height: min(62vh, 560px);
  padding: 22px;
  border: 1px solid rgba(24, 34, 40, 0.16);
  border-radius: 3px;
  background: #fff;
}

.viewer-empty.has-image .static-reference-image {
  display: grid;
  place-items: center;
}

.static-reference-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.viewer-loading[hidden],
.viewer-empty[hidden] {
  display: none;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 920px) {
  .library-header {
    grid-template-columns: minmax(190px, 1fr) auto auto;
    gap: 10px;
  }

  .library-workspace {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .catalog-item {
    grid-template-columns: 74px minmax(0, 1fr);
  }

  .catalog-thumb {
    width: 74px;
    height: 56px;
  }
}

@media (max-width: 720px) {
  .library-shell {
    min-height: 420px;
  }

  .library-header {
    grid-template-columns: minmax(0, 1fr) auto auto;
    min-height: 64px;
    padding: 8px 10px;
  }

  .brand-logo {
    width: 32px;
    height: 32px;
  }

  .brand-block {
    grid-column: 1;
    grid-row: 1;
  }

  .home-link {
    grid-column: 2;
    grid-row: 1;
  }

  .family-switch {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
  }

  .family-switch button {
    flex: 1;
    min-width: 0;
  }

  .brand-block h1 {
    font-size: 15px;
  }

  .browse-button {
    display: block;
    grid-column: 3;
    grid-row: 1;
    height: 36px;
    padding: 0 11px;
    border: 0;
    border-radius: 4px;
    background: var(--green);
    color: #fff;
    font-size: 11px;
    font-weight: 720;
  }

  .browse-label-full {
    display: none;
  }

  .browse-label-short {
    display: inline;
  }

  .library-workspace {
    display: block;
    position: relative;
  }

  .catalog-panel {
    position: absolute;
    inset: 0 auto 0 0;
    width: min(90vw, 360px);
    box-shadow: 10px 0 30px rgba(24, 34, 40, 0.24);
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  .library-shell.is-browsing .catalog-panel {
    transform: translateX(0);
  }

  .catalog-toolbar {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .close-catalog {
    display: block;
    height: 34px;
    padding: 0 9px;
    border: 1px solid var(--line-strong);
    border-radius: 4px;
    background: #fff;
    color: var(--ink);
    font-size: 10px;
    font-weight: 700;
  }

  .model-area {
    width: 100%;
    height: 100%;
  }

  .selection-bar {
    min-height: 54px;
  }

  .selection-name {
    max-width: 58vw;
    font-size: 12px;
  }

  .viewer-poster-prompt {
    min-width: 220px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
