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;
}

.preview {
  min-height: 220px;
  aspect-ratio: 3 / 2;
  border-radius: var(--r-panel);
  box-shadow: var(--shadow-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 { aspect-ratio: auto; 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); }

/* Color stops */
.stops > li.stop {
  display: grid;
  grid-template-columns: 36px 8.5rem minmax(0, 1fr) 36px;
  grid-template-areas: "pick hex pos remove" "error error error error";
  align-items: end;
  column-gap: var(--s-3);
  row-gap: var(--s-1);
  padding: var(--s-3) 0;
}
.stop .pick { grid-area: pick; margin-bottom: 6px; }
.stop .stop-hex { grid-area: hex; }
.stop .stop-pos { grid-area: pos; padding-bottom: 14px; }
.stop .remove { grid-area: remove; margin-bottom: 6px; }
.stop .error { grid-area: error; }

@media (max-width: 30rem) {
  .stops > li.stop {
    grid-template-columns: 36px minmax(0, 1fr) 36px;
    grid-template-areas: "pick hex remove" "error error error" "pos pos pos";
    row-gap: var(--s-3);
  }
  .stop .stop-pos { padding-bottom: 0; }
}

.hex { font-family: var(--font-mono); font-size: var(--t-meta); letter-spacing: 0; }

/* The native color picker drawn as a round swatch. */
.pick {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  box-shadow: inset 0 0 0 1px var(--line-soft), var(--shadow-1);
  cursor: pointer;
  overflow: hidden;
  -webkit-appearance: none;
  appearance: none;
}
.pick::-webkit-color-swatch-wrapper { padding: 0; }
.pick::-webkit-color-swatch { border: 0; border-radius: 50%; }
.pick::-moz-color-swatch { border: 0; border-radius: 50%; }

.add {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) 0;
  border: 0;
  background: none;
  color: var(--text-2);
  text-align: left;
  transition: color var(--fast) ease;
}
.add:hover { color: var(--ink); }
.add .well {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  background: var(--glass-strong);
  box-shadow: var(--shadow-1);
  color: var(--ink);
}

/* 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); }
  .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)); }
}
