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

:root {
  --bg: #0e0e10;
  --surface: #1a1a1f;
  --surface-hover: #222228;
  --border: #2a2a32;
  --text: #e4e4e7;
  --text-muted: #8b8b95;
  --accent: #6d5dfc;
  --accent-hover: #8577ff;
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* Header */
header {
  text-align: center;
  padding: 3rem 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
}

header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

header p {
  color: var(--text-muted);
  margin-top: 0.5rem;
  font-size: 1.05rem;
}

header a {
  color: var(--accent);
  text-decoration: none;
}

header a:hover {
  text-decoration: underline;
}

/* Grid */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
}

.card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

/* Image carousel */
.carousel {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #111113;
  overflow: hidden;
}

.carousel img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.carousel img.active {
  opacity: 1;
}

.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 2;
}

.carousel:hover .carousel-btn {
  opacity: 1;
}

.carousel-btn:hover {
  background: rgba(0, 0, 0, 0.8);
}

.carousel-btn.prev { left: 8px; }
.carousel-btn.next { right: 8px; }

.carousel-dots {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 2;
}

.carousel-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  transition: background 0.2s;
}

.carousel-dots span.active {
  background: #fff;
}

/* No-image placeholder */
.no-image {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #111113;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 2.5rem;
}

/* Card body */
.card-body {
  padding: 1.25rem;
}

.card-body h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.card-body p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.2s;
}

.download-btn:hover {
  background: var(--accent-hover);
}

.download-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 4rem 1.5rem;
  color: var(--text-muted);
}

.empty-state p {
  font-size: 1.1rem;
}

/* Footer */
footer {
  text-align: center;
  padding: 2rem 1.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

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

.lightbox img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 8px;
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
}

/* Spinner */
.spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  z-index: 1;
}

@keyframes spin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* 3D Viewer modal */
.viewer-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.viewer-modal.open {
  opacity: 1;
  pointer-events: auto;
}

.viewer-modal canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.viewer-close {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
  z-index: 201;
}

.viewer-hint {
  position: absolute;
  bottom: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.8rem;
  z-index: 201;
  pointer-events: none;
}

.viewer-progress {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  z-index: 201;
}

.viewer-progress.active {
  display: flex;
}

.viewer-progress-bar {
  width: 200px;
  height: 4px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.viewer-progress-bar::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: var(--progress, 0%);
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.15s ease;
}

.viewer-progress-text {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.download-btn.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.download-btn.secondary:hover {
  background: var(--accent);
  color: #fff;
}

.view3d-btn {
  cursor: pointer;
}

.card-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

footer a {
  color: var(--accent);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

@media (max-width: 480px) {
  header h1 { font-size: 1.5rem; }
  .projects-grid { grid-template-columns: 1fr; gap: 1rem; padding: 0 1rem; }
}
