* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Trebuchet MS", system-ui, sans-serif;
  background: #1d2b3a;
  color: #fff;
}
.bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1rem;
  background: #14202c;
}
.bar h1 { font-size: 1.3rem; margin: 0; }
.home { color: #ffd76a; text-decoration: none; font-weight: bold; }
.tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.2rem;
  align-items: center;
  justify-content: center;
  padding: 0.7rem;
  background: #26394d;
  position: sticky;
  top: 0;
  z-index: 5;
}
.group { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
button.tool, button.page {
  font: inherit;
  padding: 0.5rem 0.8rem;
  border: 2px solid transparent;
  border-radius: 10px;
  background: #3b556f;
  color: #fff;
  cursor: pointer;
}
button.tool.active, button.page.active { border-color: #ffd76a; background: #4d7094; }
.swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid #fff;
  cursor: pointer;
  padding: 0;
}
.swatch.active { outline: 3px solid #ffd76a; outline-offset: 2px; }
.custom input { vertical-align: middle; width: 40px; height: 32px; border: 0; padding: 0; background: none; }
.stage {
  position: relative;
  --z: 1;
  width: calc(min(96vw, 640px) * var(--z));
  flex: none;
  aspect-ratio: 1024 / 1536;
  margin: 1rem auto 2rem;
  background: #fff;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  touch-action: none;
}
.stage canvas, .stage img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.viewport { max-height: 82vh; overflow: auto; margin: 1rem auto 2rem; width: fit-content; max-width: 100%; touch-action: none; }
.viewport .stage { margin: 0; }
.viewport.hand .stage canvas { cursor: grab; }
.stage canvas { touch-action: none; cursor: none; }
.stage .ring {
  position: absolute;
  inset: auto;
  width: 18px;
  height: 18px;
  border: 2px solid #000;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #fff, inset 0 0 0 1px #fff;
  transform: translate(-50%, -50%);
  pointer-events: none;
  display: none;
  box-sizing: border-box;
}
.stage img { mix-blend-mode: multiply; pointer-events: none; user-select: none; }
