:root {
  font: 16px/1.35 Arial, sans-serif;
  color: #111d37;
  background: #e6e5e1;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input { font: inherit; }
button { color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 5px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.app {
  --ink: #111d37;
  --accent: #ff5436;
  --track: #a9adb6;
  --ground: #e6e5e1;
  --viewer-fill: #d1d0cd;
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  height: 100dvh;
  min-height: 650px;
  overflow: hidden;
  color: var(--ink);
  background: var(--viewer-fill);
}
.viewer { position: relative; min-width: 0; min-height: 0; }
.scene { position: absolute; inset: 0; }
.scene canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; }
header {
  position: absolute;
  z-index: 4;
  inset: 12px 2.1% auto 2.85%;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
  pointer-events: none;
}
header button { pointer-events: auto; }
.wordmark { width: max-content; padding-left: 9px; border-left: 3px solid var(--accent); }
.wordmark strong, .wordmark span { display: block; }
.wordmark strong { font-size: clamp(13px, 1.27vw, 20px); line-height: 1.05; letter-spacing: .025em; }
.wordmark span { margin-top: 3px; font-size: clamp(7px, .7vw, 11px); font-weight: 700; letter-spacing: .34em; }
.types { display: flex; align-items: center; gap: clamp(8px, 1.85vw, 34px); }
.types button { border: 0; padding: 2px 5px 4px; background: transparent; font-size: clamp(11px, 1.18vw, 18px); white-space: nowrap; }
.types button.active { box-shadow: inset 0 -2px var(--accent); font-weight: 700; }
.types button:hover { color: var(--accent); }
.view-tools { display: flex; align-items: center; justify-self: end; gap: clamp(7px, 1vw, 18px); }
.theme-switch { display: flex; border: 1px solid var(--track); border-radius: 999px; }
.theme-switch button, .icon {
  display: grid;
  place-items: center;
  width: 31px;
  height: 28px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 999px;
  background: none;
}
.theme-switch button.active { border-color: var(--accent); background: #ffffff45; }
.theme-switch button:hover, .icon:hover { color: var(--accent); }
.view-tools svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#detail {
  position: absolute;
  z-index: 3;
  top: 17%;
  right: 3.8%;
  width: min(26%, 410px);
  display: grid;
  grid-template-columns: 30% minmax(0, 1fr);
  gap: 4%;
  align-items: start;
  pointer-events: none;
}
#detail[data-side="left"] { left: 3.8%; right: auto; grid-template-columns: minmax(0, 1fr) 30%; }
#detail[data-side="left"] .detail-preview { grid-column: 2; grid-row: 1; }
#detail[data-side="left"] .detail-text { grid-column: 1; grid-row: 1; text-align: right; }
.detail-preview { aspect-ratio: 1; overflow: hidden; border: 2px solid var(--accent); border-radius: 50%; background: #5d5954; }
.detail-preview canvas { display: block; width: 100% !important; height: 100% !important; object-fit: cover; }
.detail-kicker { color: var(--accent); font-size: clamp(11px, 1.3vw, 21px); font-weight: 800; }
.detail-text h2 { margin: 1px 0 8px; font-size: clamp(15px, 1.65vw, 26px); line-height: 1.08; letter-spacing: -.025em; }
.detail-copy { margin: 0; font-size: clamp(10px, 1.04vw, 16px); line-height: 1.4; }
.markers, .layer-pointer { position: absolute; inset: 0; pointer-events: none; overflow: visible; z-index: 2; }
.layer-pointer { fill: none; stroke: var(--accent); stroke-width: 2; }
.target-dot { fill: var(--accent); stroke: #fff3e7; stroke-width: 1; }
.target-ring { fill: #ff543633; }
/* The cards are projected from the stage rim into the viewer. */
.layer-arc { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.layer-step {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--card-width, 64px);
  container-type: inline-size;
  padding: 3px 2px 6px;
  border: 1px solid rgb(35 40 46 / 22%);
  border-radius: 9px;
  background: rgb(248 247 243 / 38%);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
  pointer-events: auto;
  transform: translate3d(var(--card-x, 0px), var(--card-y, 0px), 0) translateX(-50%);
}
body.night .layer-step {
  border-color: rgb(255 255 255 / 25%);
  background: rgb(31 31 31 / 42%);
}
.layer-step:nth-child(1) { --tilt: -8deg; }
.layer-step:nth-child(2) { --tilt: -6deg; }
.layer-step:nth-child(3) { --tilt: -3deg; }
.layer-step:nth-child(6) { --tilt: 3deg; }
.layer-step:nth-child(7) { --tilt: 6deg; }
.layer-step:nth-child(8) { --tilt: 8deg; }
.layer-swatch {
  position: relative;
  display: block;
  aspect-ratio: 1.4;
  max-height: 13vh;
  overflow: hidden;
  border: 1px solid transparent;
  background: transparent;
  transform: rotate(var(--tilt, 0deg));
}
.layer-swatch canvas { display: block; width: 100%; height: 100%; object-fit: fill; filter: grayscale(1); }
.layer-step-caption {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: clamp(2px, 4cqi, 4px);
  margin-top: 8px;
  font-size: clamp(8px, 12cqi, 12px);
  white-space: nowrap;
  line-height: 1.15;
  font-weight: 700;
}
.layer-step-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.layer-step-number { flex: none; font-variant-numeric: tabular-nums; }
.layer-step.active .layer-step-number { color: var(--accent); }
body .layer-step:is(:hover, .active) { border-color: var(--accent); }
.layer-step.active canvas { filter: none; }
.assembly { position: absolute; z-index: 4; bottom: clamp(16px, 4vh, 41px); inset-inline: 0; pointer-events: none; display: flex; align-items: center; justify-content: center; gap: clamp(12px, 2vw, 32px); margin-top: 10px; }
.assembly :is(button, input, label) { pointer-events: auto; }
.play { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; background: transparent; }
.play svg { width: 28px; height: 28px; }
.assembly label { font-size: clamp(13px, 1.4vw, 22px); font-weight: 700; }
#assembly { appearance: none; width: min(24vw, 360px); height: 4px; margin: 0; border-radius: 4px; cursor: pointer; background: linear-gradient(to right, var(--accent) var(--progress, 88%), var(--track) 0); }
#assembly::-webkit-slider-thumb { appearance: none; width: 19px; height: 19px; border: 4px solid white; border-radius: 50%; background: var(--accent); box-shadow: 0 2px 5px #0005; }
#assembly::-moz-range-thumb { width: 11px; height: 11px; border: 4px solid white; border-radius: 50%; background: var(--accent); box-shadow: 0 2px 5px #0005; }
body.night .app { --ink: #f0f0ee; --track: #777d8a; --ground: #000; --viewer-fill: #000; }
@media (max-width: 900px) {
  header { grid-template-columns: 1fr auto; }
  .types { position: absolute; top: 37px; left: 50%; transform: translateX(-50%); }
  #detail { top: 17%; right: 2.5%; width: 29%; }
}
@media (max-width: 759px) {
  .app { min-height: 690px; }
  #detail { top: 99px; width: min(68%, 330px); right: 4%; grid-template-columns: 40px minmax(0, 1fr); }
  #detail[data-side="left"] { left: 4%; grid-template-columns: minmax(0, 1fr) 40px; }
  .detail-text h2 { font-size: 14px; margin-bottom: 3px; }
  .detail-copy { font-size: 10px; }
  .layer-pointer { display: none; }
  .layer-swatch { aspect-ratio: 1.4; transform: none; }
  .layer-step-caption { margin-top: 4px; }
  #assembly { width: 43vw; }
}

@media (max-width: 520px) {
  #detail { top: 86px; }
}
