*, *::before, *::after { box-sizing: border-box; }
[x-cloak] { display: none !important; }

body {
  font: 16px/1.5 system-ui, sans-serif;
  max-width: 48em;
  margin: 2em auto;
  padding: 0 1em;
  color: #1a1a1a;
}

h1 { font-size: 1.6em; margin: 0 0 .3em; cursor: pointer; }
h1 .version {
  font-size: .55em;
  font-weight: 400;
  color: #777;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  margin-left: .5em;
  vertical-align: middle;
}
h2 { margin-top: 2em; font-size: 1.2em; }

p.hint {
  color: #555;
  font-size: .9em;
  margin: 0 0 1em;
}

form { margin-bottom: 1.5em; }

input, select {
  font: inherit;
  padding: .5em .6em;
  min-height: 2.5em;
  width: 100%;
}

/* Each form is a stack of grouped <fieldset class="grp"> blocks
   (Geometry / Placement / Material) plus a collapsible Advanced
   <details>. Each group is its own two-column grid so labels stay
   aligned within the group without cross-group bleed. The .grid
   variant skips the fieldset chrome (used inside <details>). */
.grp {
  display: grid;
  grid-template-columns: 9em 1fr;
  gap: .5em .8em;
  align-items: center;
  border: 1px solid #e3e3e8;
  border-radius: 6px;
  padding: .9em 1em 1em;
  margin: 0 0 .8em;
}
.grp.grid {
  border: none;
  padding: 0;
  margin: 0;
}
.grp > legend {
  font-size: .8em;
  font-weight: 600;
  color: #555;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 0 .4em;
}

/* .field stacks a control above its hint so they share column 2 of
   the parent .grp grid. Sliders nest cleanly inside it. */
.field {
  display: flex;
  flex-direction: column;
  gap: .25em;
}

small.hint {
  display: block;
  color: #666;
  font-size: .8em;
  line-height: 1.4;
}

/* Advanced material: rarely-touched knobs, collapsed by default. The
   <summary> click is itself the "tap to learn more" gesture, so
   inline hints inside the open section don't clutter normal use. */
details.advanced { margin: 0 0 .8em; }
details.advanced > summary {
  font: inherit;
  font-size: .9em;
  font-weight: 600;
  color: #555;
  cursor: pointer;
  padding: .5em .4em;
  user-select: none;
  letter-spacing: .03em;
}
details.advanced[open] > summary { margin-bottom: .6em; }

/* 0..1 slider rows: range fills the cell, the <output> shows the
   current value next to it. Output is fixed-width so the slider's
   right edge doesn't jitter as the value scrubs. */
.slider {
  display: grid;
  grid-template-columns: 1fr 3em;
  align-items: center;
  gap: .6em;
}
.slider input[type="range"] {
  padding: 0;
  min-height: 0;
}
.slider output {
  font: inherit;
  font-variant-numeric: tabular-nums;
  font-size: .9em;
  color: #555;
  text-align: right;
}

form button {
  font: inherit;
  display: block;
  padding: .6em 1.2em;
  margin-top: .6em;
  min-height: 2.5em;
  cursor: pointer;
}

code {
  background: #f3f3f3;
  padding: 0 .3em;
  border-radius: 3px;
}

pre {
  background: #f3f3f3;
  padding: .8em;
  border-radius: 4px;
  overflow-x: auto;
  font-size: .9em;
}
pre code { background: none; padding: 0; }

/* --- Preview / AR launcher --- */

/* <model> is iOS Safari 17+'s native USDZ viewer: renders the model
   inline and launches AR Quick Look on tap. Non-supporting browsers
   render the fallback child <a rel="ar"> instead.
   No border-radius: iOS composites the native model surface above the
   element's CSS background, so the corners don't clip and show as a
   dark fringe. Square corners avoid that. */
model.preview {
  display: block;
  width: 100%;
  height: 18em;
  margin: 1em 0;
  background: linear-gradient(180deg, #f6f6f8 0%, #e9e9ee 100%);
}

a.ar-launch {
  display: inline-block;
  font: inherit;
  background: #1a1a1a;
  color: #fff;
  text-decoration: none;
  padding: .6em 1.2em;
  border-radius: 4px;
  margin: 1em 0 .5em;
}
a.ar-launch:hover { background: #333; }

/* --- Tab bar --- */

nav.tabs {
  display: flex;
  gap: .25em;
  overflow-x: auto;
  overflow-y: hidden;
  /* Only handle horizontal panning inside the tab bar; vertical swipes
     fall through to page scroll instead of trying to scroll this element. */
  touch-action: pan-x;
  overscroll-behavior: contain;
  /* Divider as inset shadow rather than border-bottom: doesn't take
     layout space, so children can have their own border-bottom flush
     against the same line without negative margin (which was causing
     1px of vertical-scroll content on iOS). */
  box-shadow: inset 0 -1px 0 #ddd;
  margin: 1em 0 1.5em;
  /* hide scrollbar visually; tabs still scrollable */
  scrollbar-width: none;
}
nav.tabs::-webkit-scrollbar { display: none; }

nav.tabs button {
  font: inherit;
  flex: 0 0 auto;
  border: none;
  background: none;
  padding: .6em 1em;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: #666;
  cursor: pointer;
  white-space: nowrap;
}
nav.tabs button:hover { color: #1a1a1a; }
nav.tabs button.active {
  color: #1a1a1a;
  border-bottom-color: #1a1a1a;
  font-weight: 600;
}

/* --- Mobile --- */

@media (max-width: 40em) {
  body { margin: 1em auto; padding: 0 .8em; }

  .grp {
    grid-template-columns: 1fr;
    gap: .2em;
    padding: .7em .8em .8em;
  }
  .grp label {
    margin-top: .5em;
    font-size: .85em;
    color: #555;
  }
  form button {
    width: 100%;
    text-align: center;
    margin-top: 1em;
  }
}
