:root {
  --bg: #f3f4f6;
  --fg: #1f2328;
  --muted: #5b6470;
  --accent: #19b394;
  --card: #ffffff;
  --viewer-bg: #1c1d22;
  --splat-height: 440px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 16px;
}

.site-header {
  background: var(--card);
  border-bottom: 1px solid #e3e6ea;
  padding: 20px 0 16px;
}
.site-header h1 { margin: 6px 0 4px; font-size: 1.5rem; }
.site-header p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.site-header .notice-inline {
  margin-top: 8px;
  font-size: 0.85rem;
  color: #8a5a00;
  background: #fff6e0;
  border-left: 3px solid #e3a008;
  padding: 6px 10px;
  border-radius: 4px;
}
.badge {
  display: inline-block;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--accent);
  color: #fff;
  padding: 2px 8px;
  border-radius: 999px;
}

main { padding: 8px 16px 40px; }

/* ---- Splat viewer --------------------------------------------------- */

.splat-viewer {
  position: relative;
  width: 100%;
  height: var(--splat-height);
  max-height: 70vh;
  background: var(--viewer-bg);
  border-radius: 8px;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}
.splat-viewer canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  cursor: grab;
}
.splat-viewer canvas:active { cursor: grabbing; }

.splat-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(28, 29, 34, 0.92);
  color: #e6e8ec;
  font-size: 0.95rem;
  text-align: center;
  padding: 24px;
  transition: opacity 0.4s ease;
}
.splat-overlay.hidden { opacity: 0; pointer-events: none; }
.splat-overlay.error { color: #ffb4a8; }
.splat-progress {
  width: min(320px, 70%);
  height: 6px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  overflow: hidden;
}
.splat-progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.2s linear;
}

.splat-hud {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
  color: #e6e8ec;
  font-size: 0.8rem;
  pointer-events: none;
}
.splat-hud .splat-buttons { display: flex; gap: 6px; }
.splat-hud button {
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  padding: 4px 10px;
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.splat-hud button:hover { background: rgba(255, 255, 255, 0.25); }

/* Full screen: native Fullscreen API where available, CSS fallback otherwise. */
.splat-viewer:fullscreen,
.splat-viewer.splat-fs {
  height: 100vh;
  max-height: none;
  border-radius: 0;
}
.splat-viewer.splat-fs {
  position: fixed;
  inset: 0;
  width: 100vw;
  z-index: 10000;
}

.splat-credit {
  position: absolute;
  top: 6px;
  right: 10px;
  font-size: 0.65rem;
  color: rgba(230, 232, 236, 0.6);
  pointer-events: none;
}

.splat-attrib {
  margin: 8px 0 0;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--muted);
}
.splat-attrib a { color: inherit; text-decoration: underline; }
.splat-attrib a:hover { color: var(--fg); }

@media (max-width: 600px) {
  .splat-viewer { height: auto; aspect-ratio: 4 / 3; }
  .splat-hud .splat-hint { display: none; }
  .splat-credit { display: none; }
}

/* ---- Results -------------------------------------------------------- */

#results {
  background: var(--card);
  border-radius: 8px;
  padding: 20px 24px 24px;
  margin-top: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
#results h2 { font-size: 1.1rem; margin: 8px 0 12px; }
.metrics {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin-bottom: 20px;
}
.metrics th, .metrics td {
  text-align: right;
  padding: 6px 8px;
  border-bottom: 1px solid #e3e6ea;
}
.metrics th:first-child, .metrics td:first-child { text-align: left; }
.metrics th { color: var(--muted); font-weight: 600; }
.actions { display: flex; gap: 8px; margin-bottom: 12px; }
.actions button {
  font: inherit;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.actions button.secondary { background: transparent; color: var(--accent); }
#resultsJson {
  background: #0f172a;
  color: #e2e8f0;
  padding: 16px;
  border-radius: 6px;
  overflow: auto;
  max-height: 60vh;
  font-size: 0.8rem;
}

.site-footer { color: var(--muted); font-size: 0.8rem; padding-bottom: 32px; }
.site-footer h2 { font-size: 0.9rem; margin: 0 0 6px; color: var(--fg); }
.site-footer ul { margin: 0 0 8px; padding-left: 18px; }
.site-footer li { margin-bottom: 6px; line-height: 1.45; }
.site-footer a { color: inherit; }
.notice { background: #fff3cd; padding: 12px; border-radius: 6px; }
