html, .twh { height: 100%; }
.app {
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
  min-height: 100%;
  padding-top: var(--s-6);
  padding-bottom: var(--s-6);
}
.title { font-size: calc(var(--t-title) + var(--s-2)); font-weight: 400; letter-spacing: -0.02em; line-height: 1.1; }

.head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-6);
  flex: none;
}
.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--s-2);
  flex: none;
  text-decoration: none;
}
.brand .logo { display: block; color: var(--ink); }
.brand:hover .hint { text-decoration: underline; text-underline-offset: 3px; }

.layout {
  flex: 1;
  display: grid;
  gap: var(--s-5);
  min-height: 0;
  align-items: stretch;
}

/* The canvas is sized by app.js to fit inside this box at the frame's aspect ratio. */
.preview {
  position: relative;
  display: grid;
  place-items: center;
  padding: var(--s-5);
  border-radius: var(--r-panel);
  background: var(--fill);
  overflow: hidden;
}
.art {
  display: block;
  border-radius: var(--r-small);
  box-shadow: var(--shadow-2);
}
.art { touch-action: none; }
.play {
  position: absolute;
  right: var(--s-4);
  bottom: var(--s-4);
}
.shape-box { padding: var(--s-1) 0; }
.shape-box .spread { flex-wrap: wrap; row-gap: var(--s-2); }

@media (min-width: 60rem) {
  .app {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
  }
  .layout { grid-template-columns: minmax(0, 1fr) minmax(20rem, 24rem); gap: var(--s-6); }
  .preview { height: 100%; min-height: 0; }
  .controls { min-height: 0; height: 100%; overflow-y: auto; scrollbar-width: thin; }
}

.controls { display: flex; flex-direction: column; gap: var(--s-5); }
.knobs { column-gap: var(--s-5); padding-top: var(--s-1); }
.knobs[hidden] { display: none; }

.toggle { gap: var(--s-3); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); }

/* Sliders */
.range {
  width: 100%;
  height: 20px;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.range::-webkit-slider-runnable-track { height: 4px; border-radius: var(--r-pill); background: var(--fill-hover); }
.range::-moz-range-track { height: 4px; border-radius: var(--r-pill); background: var(--fill-hover); }
.range::-webkit-slider-thumb {
  width: 20px;
  height: 20px;
  margin-top: -8px;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line), var(--shadow-1);
  -webkit-appearance: none;
  appearance: none;
}
.range::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line), var(--shadow-1);
}
.range:focus-visible { outline: 0; }
.range:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--ink); outline-offset: 2px; }
.range:focus-visible::-moz-range-thumb { outline: 2px solid var(--ink); outline-offset: 2px; }

@media (max-width: 40rem) {
  .head { flex-wrap: wrap; }
  .brand { align-items: flex-start; }
  .page { padding-top: var(--s-6); }
  .controls { padding: var(--s-5); }
  .preview { padding: var(--s-3); border-radius: var(--r-card); }
  .settings .spread { flex-wrap: wrap; }
}

/* The one-time sign-up offer after a first save (app.js, showSignup). */
.signup {
  position: fixed;
  left: var(--s-5);
  bottom: var(--s-5);
  z-index: 10;
  width: min(24rem, calc(100% - 2 * var(--s-5)));
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: var(--s-5);
  border-radius: var(--r-card);
  opacity: 0;
  transform: translateY(var(--s-2));
  transition: opacity var(--slow) var(--ease), transform var(--slow) var(--ease);
}
.signup.is-in { opacity: 1; transform: none; }
.signup-text { padding-right: var(--s-8); }
.signup-form { display: flex; gap: var(--s-2); }
.signup-form .input { flex: 1; min-width: 0; }
.signup-close { position: absolute; top: var(--s-3); right: var(--s-3); }
@media (max-width: 40rem) {
  .signup { left: var(--s-3); bottom: var(--s-3); width: calc(100% - 2 * var(--s-3)); }
  /* Room to scroll the last controls out from under it. */
  body:has(.signup) .app { padding-bottom: calc(2 * var(--s-11) + var(--s-6)); }
}
