*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0f0f13;
  --surface: #1a1a24;
  --text: #e4e4ef;
  --accent: #7c5cfc;
  --accent-hover: #9b82fd;
  --radius: 12px;
}

html, body {
  height: 100%;
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ---- Header ---- */
header {
  text-align: center;
  padding: 1.5rem 1rem 0.5rem;
}

header h1 {
  font-size: 1.6rem;
  letter-spacing: 0.04em;
}

.subtitle {
  font-size: 0.85rem;
  opacity: 0.6;
  margin-top: 0.25rem;
}

/* ---- Main / Viewer ---- */
main {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 720px;
  padding: 0.75rem 1rem;
}

#viewer-container {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: 60vh;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

#viewer-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Loading overlay */
#loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: var(--surface);
  z-index: 10;
}

.spinner {
  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;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---- Animation Picker ---- */
#animation-section {
  width: 100%;
  max-width: 720px;
  padding: 0.5rem 1rem 0.5rem;
}

#animation-section h2 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
  opacity: 0.8;
}

#animation-picker {
  display: flex;
  gap: 0.6rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}

#animation-picker::-webkit-scrollbar {
  height: 6px;
}

#animation-picker::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 3px;
}

.anim-card {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  background: var(--surface);
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 0.65rem 0.9rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  color: var(--text);
  font-family: inherit;
  min-width: 100px;
}

.anim-card:hover {
  background: rgba(255,255,255,0.05);
}

.anim-card.selected {
  border-color: var(--accent);
  background: rgba(124, 92, 252, 0.1);
}

.anim-card.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.anim-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.anim-label {
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.anim-desc {
  font-size: 0.65rem;
  opacity: 0.55;
  white-space: nowrap;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Notice ---- */
.notice {
  text-align: center;
  padding: 2rem;
  opacity: 0.7;
  font-size: 0.95rem;
  line-height: 1.5;
}

/* ---- Footer ---- */
footer {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  padding: 0.75rem 1rem 1.5rem;
}

#ar-button,
#ar-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.5rem 1.2rem;
  font-size: 0.85rem;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s;
  text-decoration: none;
}

#ar-button:hover,
#ar-link:hover {
  background: var(--accent-hover);
}

#custom-ar-button {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.5rem 1.2rem;
  font-size: 0.85rem;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  text-decoration: none;
}

#custom-ar-button:hover {
  background: var(--accent-hover);
}

#custom-ar-button.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#custom-ar-button.disabled:hover {
  background: var(--accent);
}

/* ---- WebXR AR Overlay ---- */
#ar-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  pointer-events: none;
}

#ar-hint {
  position: absolute;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  padding: 0.5rem 1.2rem;
  border-radius: 999px;
  font-size: 0.9rem;
  pointer-events: none;
  white-space: nowrap;
}

#ar-exit-btn {
  position: absolute;
  top: env(safe-area-inset-top, 16px);
  right: 16px;
  margin-top: 16px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  cursor: pointer;
  pointer-events: auto;
}

#ar-exit-btn:hover {
  background: rgba(0, 0, 0, 0.8);
}

#reset-camera {
  padding: 0.5rem 1.2rem;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s;
}

#reset-camera:hover {
  background: rgba(255, 255, 255, 0.08);
}
