:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-muted: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f1115;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --accent: #58c049;
  --accent-soft: #ecfdf3;
  --accent-text: #15803d;
  --radius: 14px;
}

body.theme-card {
  --accent: #1d4ed8;
  --accent-soft: #eff6ff;
  --accent-text: #1d4ed8;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
}

.page-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

body.is-embed .page-shell {
  padding: 16px 14px 36px;
}

.site-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px 24px;
  box-shadow: 0 1px 3px rgba(15, 17, 21, 0.04);
}

.header-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

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

.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  flex-shrink: 0;
  object-fit: contain;
}

.brand-eyebrow {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-text);
  background: var(--accent-soft);
  padding: 2px 9px;
  border-radius: 999px;
  margin-bottom: 6px;
}

h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.header-subtitle {
  margin: 6px 0 0;
  font-size: 13.5px;
  color: var(--text-secondary);
  max-width: 700px;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.pill-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}

.pill-link:hover {
  border-color: #94a3b8;
  background: var(--surface-muted);
}

body.is-embed .back-site-btn {
  display: none;
}

.controls-bar {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.control-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.control-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.seg-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 3px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.seg-btn {
  padding: 5px 11px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.seg-btn:hover {
  color: var(--text);
}

.seg-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(15, 17, 21, 0.08);
}

.usage-banner {
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.usage-banner strong {
  color: var(--text);
}

.usage-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12.5px;
  font-weight: 600;
}

.usage-links a {
  color: var(--accent-text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.sections-root {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

details.asset-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  transition: border-color 0.15s;
}

details.asset-section[open] {
  box-shadow: 0 1px 3px rgba(15, 17, 21, 0.03);
}

summary.section-summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  user-select: none;
  background: var(--surface);
}

summary.section-summary::-webkit-details-marker {
  display: none;
}

summary.section-summary:hover {
  background: #fbfdff;
}

.section-summary-left {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

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

.section-title {
  margin: 0;
  font-size: 16.5px;
  font-weight: 700;
}

.section-count {
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text-secondary);
}

.section-tag-primary {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.section-desc {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.section-chevron {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

details.asset-section[open] .section-chevron::before {
  content: attr(data-open-label);
}

details.asset-section:not([open]) .section-chevron::before {
  content: attr(data-closed-label);
}

.section-body {
  padding: 4px 20px 22px;
  border-top: 1px solid var(--border);
}

.cards-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(265px, 1fr));
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 6px 16px rgba(15, 17, 21, 0.05);
}

.preview-stage {
  position: relative;
  height: 184px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  border-bottom: 1px solid var(--border);
  cursor: zoom-in;
  overflow: hidden;
}

.bg-checker {
  background-color: #f8fafc;
  background-image:
    linear-gradient(45deg, #e2e8f0 25%, transparent 25%),
    linear-gradient(-45deg, #e2e8f0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e2e8f0 75%),
    linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

.bg-light {
  background: #ffffff;
}

.bg-dark {
  background: #0f1115;
}

.preview-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 6px;
  transition: transform 0.18s ease;
}

.preview-stage:hover img {
  transform: scale(1.03);
}

.id-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  font-size: 11.5px;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 2px 8px;
  border-radius: 7px;
  background: rgba(15, 17, 21, 0.82);
  color: #ffffff;
}

.dims-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 11px;
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 2px 7px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.92);
  color: #334155;
  border: 1px solid #cbd5e1;
}

.card-body {
  padding: 14px 15px 15px;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 8px;
}

.card-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}

.card-desc {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.dl-row {
  margin-top: auto;
  padding-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dl-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 9px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}

.dl-btn:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}

.dl-sub {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 10.5px;
}

.swatches-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.swatch {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  text-align: left;
  background: var(--surface);
  padding: 0;
  transition: transform 0.12s, border-color 0.15s;
}

.swatch:hover {
  transform: translateY(-2px);
  border-color: #94a3b8;
}

.swatch-color {
  height: 54px;
  width: 100%;
}

.swatch-info {
  padding: 8px 10px;
}

.swatch-hex {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  font-weight: 700;
  display: block;
}

.swatch-name {
  font-size: 12px;
  font-weight: 600;
  display: block;
  margin-top: 2px;
}

.swatch-role {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
}

.site-footer {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.footer-links a:hover {
  color: var(--text);
  text-decoration: underline;
}

/* Lightbox */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 17, 21, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-box {
  background: var(--surface);
  border-radius: 16px;
  max-width: 820px;
  width: 100%;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.modal-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modal-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
}

.modal-stage {
  height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.modal-foot {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 80;
  background: #0f1115;
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: all 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 640px) {
  .site-header {
    padding: 18px 16px;
  }
  .modal-stage {
    height: 300px;
  }
}
