:root {
  --bg: #0d1117;
  --bg-soft: #161b22;
  --card: #1c2333;
  --border: #2d3648;
  --text: #e6edf3;
  --muted: #9aa7b8;
  --accent: #f2a33c;
  --accent-2: #58a6ff;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --sans: "Inter", system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.6;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

code, .mono {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}

/* ---------- Hero ---------- */
.hero {
  background:
    radial-gradient(1200px 500px at 15% -10%, rgba(242, 163, 60, 0.14), transparent 60%),
    radial-gradient(900px 400px at 90% 0%, rgba(88, 166, 255, 0.10), transparent 60%),
    var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 72px 24px 56px;
  text-align: center;
}

.hero-inner { max-width: 860px; margin: 0 auto; }

.kicker {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 14px;
}

h1 {
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}

h1 .accent { color: var(--accent); }

.sub {
  margin: 18px auto 26px;
  max-width: 680px;
  color: var(--muted);
  font-size: 1.05rem;
}

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

.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.btn {
  display: inline-block;
  padding: 11px 22px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid transparent;
  transition: transform 0.12s ease, background 0.15s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }

.btn.primary { background: var(--accent); color: #1a1206; }
.btn.primary:hover { background: #f5b256; }

.btn.ghost { border-color: var(--border); color: var(--text); }
.btn.ghost:hover { background: var(--bg-soft); }

.hero .muted { margin-top: 22px; }

/* ---------- Sections ---------- */
.section {
  max-width: 1080px;
  margin: 0 auto;
  padding: 56px 24px;
  scroll-margin-top: 20px;
}

.section h2 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}

.section > .muted { margin-bottom: 26px; }

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }

/* ---------- Viewer ---------- */
.viewer-wrap {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg-soft);
}

#canvas-host { width: 100%; height: 560px; display: block; }
#canvas-host canvas { display: block; width: 100%; height: 100%; }

.viewer-overlay {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
  pointer-events: none;
}
.viewer-overlay > * { pointer-events: auto; }

.viewer-controls-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  background: rgba(13, 17, 23, 0.85);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--sans);
  transition: all 0.15s ease;
  backdrop-filter: blur(8px);
}
.chip:hover { color: var(--text); border-color: #3d4a63; }
.chip.active { color: #1a1206; background: var(--accent); border-color: var(--accent); }
.chip.highlight { color: #58a6ff; border-color: rgba(88, 166, 255, 0.4); background: rgba(88, 166, 255, 0.1); }
.chip.highlight:hover { background: rgba(88, 166, 255, 0.25); color: #ffffff; }

.viewer-nav-panel {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.category-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.cat-btn {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--sans);
  transition: all 0.15s ease;
}
.cat-btn:hover {
  color: var(--text);
  border-color: #3d4a63;
  background: #222b3d;
}
.cat-btn.active {
  color: #1a1206;
  background: var(--accent);
  border-color: var(--accent);
}

.piece-selector-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }

.piece-meta {
  margin-top: 12px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  font-size: 0.92rem;
  min-height: 62px;
}
.piece-meta .name { font-weight: 700; color: var(--accent); }
.piece-meta .desc { color: var(--muted); margin-top: 4px; }

.badge-loading { color: var(--accent-2); font-weight: 600; }
.badge-error { color: #f85149; font-weight: 600; }

/* ---------- Gallery ---------- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
}

.gallery-item {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-soft);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.gallery-item:hover {
  transform: translateY(-3px);
  border-color: #3d4a63;
}

.gallery-item img {
  width: 100%;
  display: block;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}

.gallery-item figcaption {
  padding: 10px 14px;
  font-size: 0.85rem;
  color: var(--muted);
}

.center { text-align: center; }
.margin-top { margin-top: 18px; }

/* ---------- Cards grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

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

.card:hover {
  transform: translateY(-3px);
  border-color: #3d4a63;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.preview-wrap {
  position: relative;
  cursor: zoom-in;
  overflow: hidden;
}

.preview-wrap:hover .zoom-hint {
  opacity: 1;
}

.zoom-hint {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(13, 17, 23, 0.85);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
  backdrop-filter: blur(6px);
}

.card .preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  display: block;
}

/* Lightbox Modal */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(13, 17, 23, 0.92);
  backdrop-filter: blur(12px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 24px;
}

.lightbox.active {
  opacity: 1;
  pointer-events: auto;
}

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.lightbox-content img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  background: #161b22;
}

.lightbox-close {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.lightbox-close:hover {
  background: var(--accent);
  color: #1a1206;
  border-color: var(--accent);
}


.preview-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  aspect-ratio: 16 / 9;
  background:
    radial-gradient(400px 200px at 30% 20%, rgba(242, 163, 60, 0.08), transparent 60%),
    var(--bg-soft);
}

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

.card h3 { font-size: 1.05rem; margin: 0; }
.card p { color: var(--muted); font-size: 0.94rem; margin: 0; }
.card .hint { font-size: 0.82rem; color: #b8c4d4; }

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 10px;
}

.card-actions .chip { pointer-events: auto; }
.chip.download { border-color: var(--border); color: var(--text); }
.chip.download:hover { background: var(--bg-soft); color: var(--text); }

ul.plain { list-style: none; }
ul.plain li { padding: 4px 0; color: var(--muted); font-size: 0.94rem; }
ul.plain li::before { content: "▸ "; color: var(--accent); }

.note {
  margin-top: 22px;
  padding: 14px 18px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--border);
  padding: 28px 24px 40px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 640px) {
  #canvas-host { height: 420px; }
  .hero { padding: 52px 18px 42px; }
  .section { padding: 40px 18px; }
}