:root {
  --ink: #493328;
  --paper: #f7eedd;
  --clay: #ffdbac;
  --coral: #e8735a;
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --out: cubic-bezier(0.23, 1, 0.32, 1);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font:
    17px/1.5 system-ui,
    -apple-system,
    sans-serif;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 90;
  opacity: 0.16;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 .55 0 0 0 0 .45 0 0 0 0 .35 0 0 0 .06 0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}
header {
  max-width: 1600px;
  margin: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 32px;
  gap: 16px;
}
header a {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--ink);
  text-decoration: none;
}
header a span {
  color: var(--coral);
  margin-left: 8px;
}
button,
select,
summary {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  border: 2px solid #493328;
  border-radius: 17px;
  padding: 12px 18px;
  min-height: 48px;
  background: var(--clay);
  box-shadow: 3px 4px 0 #493328;
  transition:
    transform 120ms var(--spring),
    box-shadow 120ms var(--out),
    background 180ms var(--out);
  touch-action: manipulation;
}
button:hover {
  background: #ffe4c3;
}
button:active {
  transform: translate(2px, 3px) scale(0.97);
  box-shadow: 1px 1px 0 #493328;
}
button:disabled {
  opacity: 0.4;
  cursor: default;
  box-shadow: none;
}
button:focus-visible,
select:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 3px solid #2c6c91;
  outline-offset: 5px;
}
[hidden] {
  display: none !important;
}
#workshop {
  max-width: 1600px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(350px, 1fr);
  min-height: calc(100svh - 145px);
  padding: 0 32px;
  gap: clamp(24px, 4vw, 64px);
}
#model-stage {
  position: relative;
  min-width: 0;
  min-height: 520px;
  border-radius: 36px;
  background: #f3e6d0;
  overflow: hidden;
  align-self: stretch;
  touch-action: pan-y;
}
#engine {
  display: block;
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  touch-action: none;
}
#leaders {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: none;
}
#leaders.on {
  display: block;
}
#part-line {
  fill: none;
  stroke: #493328;
  stroke-width: 2;
  stroke-dasharray: 5 5;
}
#part-anchor {
  fill: #e8735a;
  stroke: #fffaf0;
  stroke-width: 3;
}
#part-tag {
  position: absolute;
  top: 20px;
  left: 20px;
  background: #fff7e8;
  border: 2px solid #493328;
  border-radius: 14px;
  padding: 7px 12px;
  max-width: calc(100% - 40px);
  font-weight: 650;
}
#view-tools {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
}
#view-tools button {
  width: 46px;
  min-height: 46px;
  padding: 0;
  font-size: 24px;
  background: #fff8ed;
  box-shadow: 2px 3px 0 #493328;
}
#guide {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 28px 4px;
  min-width: 0;
}
h1 {
  font-size: clamp(28px, 3vw, 46px);
  line-height: 1.14;
  letter-spacing: -0.035em;
  margin: 0 0 22px;
  font-weight: 780;
}
#step-copy {
  font-size: clamp(18px, 1.65vw, 23px);
  line-height: 1.5;
  margin: 0 0 22px;
}
#answers {
  display: grid;
  gap: 12px;
}
#answers button {
  text-align: left;
  font-size: 18px;
  line-height: 1.3;
  padding: 15px 17px;
}
#answers button[aria-pressed="true"] {
  background: #e8735a;
  color: #fff9ef;
}
#feedback {
  font-size: 20px;
  line-height: 1.5;
  margin: 20px 0 0;
}
#feedback:empty {
  display: none;
}
#part-picker {
  display: grid;
  gap: 10px;
  font-weight: 650;
}
select {
  width: 100%;
  min-height: 52px;
  border: 2px solid #493328;
  border-radius: 15px;
  background: #ffe2b9;
  padding: 10px;
  font-weight: 500;
}
details {
  margin-top: 22px;
}
summary {
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  text-decoration: underline;
  text-underline-offset: 4px;
  color: #6d5545;
}
details p {
  font-size: 18px;
  line-height: 1.55;
}
#journey-controls {
  margin-top: 32px;
}
#progress {
  display: flex;
  gap: 9px;
  align-items: center;
  margin-bottom: 20px;
  height: 12px;
}
#progress i {
  display: block;
  width: 9px;
  height: 9px;
  background: #cbbba4;
  border-radius: 50%;
}
#progress i.active {
  background: #a94a34;
  width: 26px;
  border-radius: 8px;
}
.actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
#next {
  background: var(--coral);
  color: #fffaf0;
  font-size: 20px;
  font-weight: 700;
  min-height: 58px;
  flex: 1;
  max-width: 290px;
}
#next:hover {
  background: #d8624a;
}
#next span {
  margin-left: 10px;
}
.icon {
  min-width: 45px;
  min-height: 45px;
  padding: 0;
  background: transparent;
  box-shadow: none;
  border-color: transparent;
  font-size: 22px;
}
.icon:hover {
  background: #ecdac0;
}
.quiet {
  background: none;
  border: 0;
  box-shadow: none;
  color: #765d4a;
  text-decoration: underline;
  text-underline-offset: 4px;
  display: block;
  margin: 16px 32px 24px;
  font-size: 16px;
}
#parts-toggle {
  background: transparent;
  box-shadow: none;
  border-color: #bba68d;
  font-size: 16px;
}
dialog {
  max-width: 550px;
  width: calc(100% - 32px);
  border: 2px solid #493328;
  border-radius: 26px;
  padding: 28px;
  background: #fff5e5;
  color: var(--ink);
}
dialog::backdrop {
  background: #49332888;
}
dialog h2 {
  line-height: 1.2;
}
.answer-enter {
  animation: answer-in 240ms var(--spring);
}
@keyframes answer-in {
  from {
    opacity: 0.4;
    transform: translateY(7px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
#workshop:fullscreen,
#workshop.fullscreen-fallback {
  max-width: none;
  background: var(--paper);
  padding: 24px;
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: auto;
}
#workshop.fullscreen-fallback {
  position: fixed;
  inset: 0;
  z-index: 80;
}
#workshop:fullscreen #model-stage,
#workshop.fullscreen-fallback #model-stage {
  min-height: 0;
}
body.focus-mode {
  overflow: hidden;
}
@media (max-width: 760px) {
  header {
    padding: 16px 18px;
    align-items: flex-start;
  }
  header a {
    font-size: 21px;
    white-space: nowrap;
  }
  #parts-toggle {
    font-size: 14px;
    line-height: 1.25;
    max-width: 155px;
    padding: 8px 12px;
    min-height: 44px;
  }
  #workshop {
    display: flex;
    flex-direction: column;
    min-height: 0;
    gap: 0;
    padding: 0 14px;
  }
  #model-stage {
    height: clamp(330px, 49svh, 490px);
    min-height: 0;
    flex: none;
    border-radius: 27px;
  }
  #guide {
    padding: 28px 10px 18px;
  }
  h1 {
    font-size: 30px;
    margin-bottom: 16px;
  }
  #step-copy {
    font-size: 19px;
    margin-bottom: 18px;
  }
  #journey-controls {
    margin-top: 25px;
  }
  .actions {
    gap: 7px;
  }
  #next {
    font-size: 18px;
    padding: 10px 12px;
  }
  .quiet {
    margin: 8px 24px 20px;
  }
  #feedback {
    font-size: 19px;
  }
  #workshop:fullscreen,
  #workshop.fullscreen-fallback {
    padding: 12px;
  }
  #workshop:fullscreen #model-stage,
  #workshop.fullscreen-fallback #model-stage {
    height: 54svh;
    min-height: 300px;
  }
  #workshop:fullscreen #guide,
  #workshop.fullscreen-fallback #guide {
    padding-top: 22px;
  }
  #part-tag {
    top: 14px;
    left: 14px;
    font-size: 15px;
  }
  #view-tools {
    gap: 10px;
    bottom: 12px;
  }
}
@media (min-width: 761px) and (max-height: 550px) {
  header {
    padding: 10px 22px;
  }
  #workshop {
    min-height: calc(100svh - 80px);
    grid-template-columns: minmax(0, 1.1fr) minmax(310px, 1fr);
    padding: 0 20px;
    gap: 24px;
  }
  #model-stage {
    min-height: 340px;
  }
  #guide {
    padding: 18px 0;
  }
  h1 {
    font-size: 28px;
  }
  #step-copy {
    font-size: 18px;
  }
  #journey-controls {
    margin-top: 18px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* On a phone the model stays in view while the current question scrolls. */
@media (max-width: 760px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }
  header {
    height: 88px;
    padding-block: 12px;
  }
  #workshop {
    height: calc(100svh - 88px);
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  #model-stage {
    height: 42%;
    min-height: 230px;
  }
  #guide {
    flex: 1;
    min-height: 0;
    padding: 18px 10px 10px;
    justify-content: flex-start;
  }
  #guide-content {
    overflow: auto;
    min-height: 0;
    overscroll-behavior: contain;
    padding: 0 7px 3px 0;
    scrollbar-width: thin;
  }
  #journey-controls {
    flex: none;
    margin-top: 15px;
  }
  #progress {
    margin-bottom: 12px;
  }
  h1 {
    font-size: 27px;
  }
  #step-copy {
    font-size: 18px;
  }
  #answers button {
    font-size: 17px;
    padding: 12px 14px;
  }
  #view-tools button {
    width: 44px;
    min-height: 44px;
  }
  #next {
    min-height: 52px;
  }
  .quiet {
    margin: 12px 0 0;
  }
  #workshop:fullscreen #model-stage,
  #workshop.fullscreen-fallback #model-stage {
    height: 45%;
    min-height: 220px;
  }
  #workshop:fullscreen #guide,
  #workshop.fullscreen-fallback #guide {
    padding-top: 15px;
  }
}

@media (max-width: 760px) {
  #model-stage {
    height: 38%;
    min-height: 215px;
  }
  h1 {
    font-size: 25px;
  }
  #answers {
    gap: 10px;
  }
  #answers button {
    min-height: 48px;
    padding: 10px 12px;
  }
  #next {
    font-size: 17px;
    padding: 10px 8px;
  }
  details {
    margin-top: 16px;
  }
}
@media (min-width: 761px) and (max-height: 600px) {
  header {
    padding: 10px 24px;
  }
  #workshop {
    height: calc(100svh - 82px);
    min-height: 290px;
    padding: 0 24px 12px;
    gap: 24px;
    grid-template-columns: minmax(0, 1.1fr) minmax(330px, 1fr);
  }
  #model-stage {
    min-height: 0;
  }
  #guide {
    min-height: 0;
    padding: 8px 0 0;
    justify-content: flex-start;
  }
  #guide-content {
    min-height: 0;
    overflow: auto;
    padding: 0 7px 4px 0;
    scrollbar-width: thin;
  }
  h1 {
    font-size: 26px;
    margin-bottom: 12px;
  }
  #step-copy,
  #feedback {
    font-size: 18px;
  }
  #journey-controls {
    margin-top: 12px;
    flex: none;
  }
  #view-tools {
    bottom: 12px;
  }
  #progress {
    margin-bottom: 10px;
  }
  #next {
    padding: 10px;
    font-size: 17px;
  }
}

#fullscreen {
  display: grid;
  place-items: center;
}
#part-picker label {
  display: block;
}
@media (max-width: 360px) {
  header {
    padding: 10px 14px;
    gap: 10px;
  }
  header a {
    font-size: 20px;
    white-space: nowrap;
  }
  #parts-toggle {
    font-size: 14px;
    padding: 7px 10px;
    min-height: 44px;
  }
  h1 {
    font-size: 22px;
    line-height: 1.15;
    margin-bottom: 14px;
  }
  .actions {
    gap: 6px;
  }
  .icon {
    width: 44px;
    min-width: 44px;
    padding: 0;
  }
  #next {
    font-size: 16px;
    line-height: 1.2;
    padding: 8px 6px;
  }
  #next span {
    display: none;
  }
  #guide {
    padding-top: 12px;
  }
  #journey-controls {
    margin-top: 10px;
  }
  #progress {
    margin-bottom: 8px;
  }
  #answers {
    gap: 8px;
  }
  #answers button {
    font-size: 16px;
    padding: 8px 10px;
  }
}
@media (max-width: 760px) and (max-height: 650px) {
  #model-stage {
    height: 32%;
    min-height: 190px;
  }
  #workshop {
    padding-bottom: 10px;
  }
  #guide-content {
    scrollbar-color: #a78567 #eee0c8;
    scrollbar-width: thin;
  }
}
#guide-content::-webkit-scrollbar {
  width: 6px;
}
#guide-content::-webkit-scrollbar-thumb {
  background: #a78567;
  border-radius: 6px;
}
#guide-content::-webkit-scrollbar-track {
  background: #eee0c8;
}

#scroll-hint {
  font-size: 14px;
  color: #775a46;
  text-align: right;
  margin-top: 4px;
  flex: none;
}

/* The reference's clay accent stays warm; dark ink keeps the action readable. */
#next,
#answers button[aria-pressed="true"] {
  color: #35251e;
  background: #ed9576;
}
#next:hover {
  background: #efa98f;
}
#scene-readout {
  position: absolute;
  left: 16px;
  right: 16px;
  top: 68px;
  text-align: center;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.35;
  color: #493328;
  background: #fff5e5;
  border: 1px solid #baa083;
  border-radius: 10px;
  padding: 7px 10px;
  pointer-events: none;
}
#part-tag {
  font-size: 15px;
  max-width: calc(100% - 32px);
}
#model-stage:has(#part-tag[hidden]) #scene-readout {
  top: 18px;
}
#view-tools {
  gap: 8px;
}
#theme-toggle {
  font-size: 23px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #211d1a;
  --ink: #f3e4cf;
  --clay: #574434;
  --coral: #ed9576;
}
[data-theme="dark"] #model-stage {
  background: #211d1a;
}
[data-theme="dark"] button {
  border-color: #d8baa0;
  box-shadow: 3px 4px 0 #0d0b09;
}
[data-theme="dark"] button:hover {
  background: #6c5240;
}
[data-theme="dark"] #next,
[data-theme="dark"] #next:hover {
  background: #ed9576;
  color: #35251e;
  border-color: #f2c1a4;
}
[data-theme="dark"] #view-tools button,
[data-theme="dark"] #part-tag,
[data-theme="dark"] #scene-readout {
  background: #33291f;
  color: #f3e4cf;
  border-color: #b59c80;
}
[data-theme="dark"] #parts-toggle {
  color: #f3e4cf;
  border-color: #a88a70;
  box-shadow: none;
}
[data-theme="dark"] summary,
[data-theme="dark"] .quiet,
[data-theme="dark"] #scroll-hint {
  color: #dec4a8;
}
[data-theme="dark"] select,
[data-theme="dark"] dialog {
  background: #33291f;
  color: #f3e4cf;
  border-color: #b59c80;
}
[data-theme="dark"] #part-line {
  stroke: #ead7bc;
}
[data-theme="dark"] #part-anchor {
  stroke: #211d1a;
}
[data-theme="dark"] .icon {
  box-shadow: none;
  border-color: transparent;
}
[data-theme="dark"] button:focus-visible,
[data-theme="dark"] select:focus-visible,
[data-theme="dark"] summary:focus-visible,
[data-theme="dark"] a:focus-visible {
  outline-color: #9bd5ed;
}
@media (max-width: 760px) {
  #model-stage {
    height: 42%;
    min-height: 265px;
  }
  #scene-readout {
    font-size: 14px;
    top: 60px;
    left: 12px;
    right: 12px;
    padding: 6px;
  }
  #part-tag {
    top: 12px;
    left: 12px;
    padding: 6px 10px;
    font-size: 14px;
  }
  #view-tools {
    bottom: 10px;
  }
  #view-tools button {
    width: 42px;
    min-height: 42px;
  }
  header a {
    font-size: 20px;
    letter-spacing: -0.8px;
  }
}
@media (max-width: 760px) and (max-height: 680px) {
  #model-stage {
    min-height: 230px;
    height: 39%;
  }
  #scene-readout {
    top: 55px;
    padding: 4px;
    font-size: 14px;
  }
}

/* The caption and control dock are outside the canvas. Nothing floats over
   the phone model, and camera fitting uses only the actual drawing area. */
#model-panel {
  min-width: 0;
  min-height: 520px;
  display: flex;
  flex-direction: column;
  align-self: stretch;
  gap: 8px;
}
#model-stage {
  flex: 1;
  min-height: 0;
  border-radius: 20px;
  background: transparent;
}
#scene-caption {
  flex: none;
  margin: 8px 8px 0;
  padding: 7px 10px;
  border: 1px solid #baa083;
  border-radius: 12px;
  background: #fff5e5;
  text-align: center;
  min-height: 36px;
}
#part-tag,
#scene-readout {
  position: static;
  display: block;
  border: 0;
  border-radius: 0;
  background: none;
  padding: 0;
  max-width: none;
  line-height: 1.3;
  color: #493328;
}
#part-tag {
  font-size: 14px;
  font-weight: 650;
}
#scene-readout {
  font-size: 15px;
  font-weight: 550;
}
#view-tools {
  position: static;
  transform: none;
  justify-content: center;
  flex: none;
  padding: 4px 0 10px;
  gap: 10px;
}
#view-tools button {
  width: 44px;
  min-height: 44px;
}
[data-theme="dark"] #scene-caption {
  background: #33291f;
  border-color: #b59c80;
}
[data-theme="dark"] #part-tag,
[data-theme="dark"] #scene-readout {
  background: none;
  color: #f3e4cf;
  border: 0;
}
#scroll-hint {
  font-weight: 600;
  background: var(--paper);
  padding-top: 3px;
}
#workshop:fullscreen #model-panel,
#workshop.fullscreen-fallback #model-panel {
  min-height: 0;
}
@media (max-width: 760px) {
  #model-panel {
    height: 44%;
    min-height: 260px;
    gap: 3px;
  }
  #model-stage {
    height: auto;
    min-height: 0;
  }
  #scene-caption {
    margin: 0 8px;
    padding: 5px 8px;
    min-height: 30px;
  }
  #part-tag,
  #scene-readout {
    font-size: 14px;
  }
  #view-tools {
    padding: 3px 0 4px;
    gap: 10px;
  }
  #view-tools button {
    width: 44px;
    min-height: 44px;
  }
  #workshop:fullscreen #model-panel,
  #workshop.fullscreen-fallback #model-panel {
    height: 46%;
    min-height: 260px;
  }
  #workshop:fullscreen #model-stage,
  #workshop.fullscreen-fallback #model-stage {
    height: auto;
    min-height: 0;
  }
}
@media (max-width: 760px) and (max-height: 680px) {
  #model-panel {
    height: 43%;
    min-height: 275px;
  }
  #scene-caption {
    padding: 4px 6px;
  }
}
@media (min-width: 761px) and (max-height: 600px) {
  #model-panel {
    min-height: 0;
  }
}

dialog {
  max-height: calc(100svh - 36px);
  overflow: auto;
}
dialog a {
  color: inherit;
  text-underline-offset: 3px;
}
dialog li {
  margin-block: 10px;
}
dialog #limits-close {
  margin-top: 20px;
}
