:root {
  --bg: #eef1f6;
  --surface: #ffffff;
  --surface-2: #f4f6fa;
  --line: #e2e6ee;
  --line-strong: #ccd3e0;
  --ink: #12161f;
  --ink-2: #5b6377;
  /* 4.6:1 on the app ground.  Was #8b93a5, which measured 2.9:1 — under
     the floor on every secondary label in the dock. */
  --ink-3: #6b7386;
  --accent: #1f4fd8;
  --accent-soft: #eaf0ff;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgb(16 22 36 / 6%), 0 2px 8px rgb(16 22 36 / 5%);
  --shadow: 0 8px 30px rgb(16 22 36 / 10%), 0 2px 8px rgb(16 22 36 / 6%);
  --dock-w: 372px;
  /* Abstract studio sweep: white overhead falling to grey at the floor. */
  --stage-0: #ffffff;
  --stage-1: #f2f3f5;
  --stage-2: #d2d5da;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  /* The family lives in the `font` shorthand, not beside it: the
     shorthand resets font-family, so a separate declaration above it is
     silently thrown away. This app had no face of its own and took
     whatever the OS gave it; Space Grotesk is the portfolio's, and a
     visitor arriving from there already has it cached. */
  font: 400 14px/1.45 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--ink);
  background:
    radial-gradient(130% 100% at 50% 2%, var(--stage-0) 0%, var(--stage-1) 42%, var(--stage-2) 100%);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app { position: fixed; inset: 0; }

#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#stage:active { cursor: grabbing; }

/* ------------------------------------------------------------------ header */

.brand {
  position: absolute;
  top: 20px;
  left: 22px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px 6px 6px;
  /* The stage behind this is a photo, so the wordmark carries its own scrim. */
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-sm);
  pointer-events: none;
  user-select: none;
}
/* The way out, first thing in the wordmark: this is a page inside a
   portfolio before it is an app, and somebody who opened it from there
   should not have to reach for the browser's own back button. */
.brand-back {
  display: grid;
  place-items: center;
  /* .brand is pointer-events:none so a drag that starts on the wordmark
     still orbits the avatar behind it. This is the one part of it that
     has to be clickable, so it takes the events back. */
  pointer-events: auto;
  width: 30px;
  height: 30px;
  margin-left: -2px;
  flex: none;
  border-radius: 999px;
  color: var(--ink-2);
  background: color-mix(in srgb, var(--ink-3) 10%, transparent);
  transition: color 0.2s linear, background 0.2s linear, transform 0.2s linear;
}
.brand-back:hover,
.brand-back:focus-visible {
  color: var(--ink);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  transform: translateX(-2px);
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(145deg, var(--accent), #6f4bff);
  box-shadow: var(--shadow-sm);
}
.brand-text strong {
  display: block;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.brand-text span {
  display: block;
  font-size: 11.5px;
  color: var(--ink-3);
  letter-spacing: 0.02em;
}
.brand-text .brand-by {
  margin-top: 1px;
  font-size: 12px;
  font-weight: 550;
  color: var(--ink-2);
}

/* ----------------------------------------------------------------- toolbar */

.toolbar {
  position: absolute;
  top: 20px;
  right: calc(var(--dock-w) + 26px);
  display: flex;
  gap: 8px;
}

.tool {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(8px);
  color: var(--ink-2);
  font: inherit;
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: color .15s, border-color .15s, transform .15s, background .15s;
}
.tool svg { width: 16px; height: 16px; }
.tool:hover { color: var(--ink); border-color: var(--line-strong); transform: translateY(-1px); }
.tool:active { transform: translateY(0); }

/* ------------------------------------------------- environment / camera bar */

.env-bar {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(calc(-50% - var(--dock-half, 0px)));
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-sm);
}
/* Shared caption for the three floating stage bars. */
.bar-label {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-3);
  white-space: nowrap;
  user-select: none;
}
.env-bar .bar-label { margin-right: 2px; }
.anim-bar .bar-label { margin: 0 4px 0 12px; }
.camera-rail .bar-label {
  padding: 4px 0 5px;
  text-align: center;
  font-size: 11px;
  letter-spacing: .07em;
  border-bottom: 1px solid var(--line);
  margin-bottom: 2px;
}

.env-spin {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 2px;
  color: var(--ink-3);
  cursor: pointer;
}
.env-spin svg { width: 15px; height: 15px; flex: 0 0 auto; }
.env-spin output {
  min-width: 30px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.env-spin input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 82px;
  height: 16px;
  background: transparent;
  cursor: grab;
}
.env-spin input[type='range']:active { cursor: grabbing; }
.env-spin input[type='range']::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 999px;
  background: var(--line-strong);
}
.env-spin input[type='range']::-moz-range-track {
  height: 3px;
  border-radius: 999px;
  background: var(--line-strong);
}
.env-spin input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--accent);
  border: 2.5px solid var(--surface);
  box-shadow: 0 1px 3px rgb(16 22 36 / 25%);
}
.env-spin input[type='range']::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  border: 2.5px solid var(--surface);
  box-shadow: 0 1px 3px rgb(16 22 36 / 25%);
}

.camera-rail {
  position: absolute;
  left: 22px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  gap: 2px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-sm);
}

.camera-snap {
  display: grid;
  justify-items: center;
  gap: 2px;
  width: 54px;
  padding: 8px 2px 6px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--ink-3);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .03em;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.camera-snap svg { width: 20px; height: 20px; }
.camera-snap:hover { background: var(--surface-2); color: var(--ink-2); }
.camera-snap.is-selected { background: var(--accent-soft); color: var(--accent); }

/* ------------------------------------------------------------ animation bar */

.anim-bar {
  position: absolute;
  left: 22px;
  right: calc(var(--dock-w) + 26px);
  bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-sm);
}

.playback {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: var(--surface);
  cursor: pointer;
  transition: transform .15s, background .15s;
}
.playback svg { width: 14px; height: 14px; }
.playback:hover { transform: scale(1.06); }
.playback.is-paused { background: var(--accent); color: #fff; }

.anim-list {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 1px;
}
.anim-list::-webkit-scrollbar { display: none; }

.anim {
  flex: 0 0 auto;
  height: 32px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 12.5px;
  font-weight: 550;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.anim:hover { background: var(--surface-2); color: var(--ink); }
.anim.is-selected {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--accent);
}

/* -------------------------------------------------------------------- dock */

.dock {
  position: absolute;
  top: 16px;
  right: 16px;
  bottom: 16px;
  width: var(--dock-w);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.rail {
  display: grid;
  grid-template-columns: repeat(var(--rail-cols, 6), 1fr);
  gap: 2px;
  padding: 6px;
  scrollbar-width: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-sm);
}
.rail::-webkit-scrollbar { display: none; }

.rail-tab {
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 9px 2px 7px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-3);
  font: inherit;
  font-size: 12px;
  font-weight: 550;
  line-height: 1.15;
  text-align: center;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.rail-tab svg { width: 21px; height: 21px; }
.rail-tab:hover { background: var(--surface-2); color: var(--ink-2); }
.rail-tab.is-active { background: var(--accent-soft); color: var(--accent); }

.panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-title {
  margin: 0;
  padding: 16px 18px 12px;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
  border-bottom: 1px solid var(--line);
}

.panel-body {
  flex: 1;
  min-height: 0;
  padding: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.panel-body::-webkit-scrollbar { width: 8px; }
.panel-body::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border: 2px solid transparent;
  border-radius: 999px;
  background-clip: content-box;
}

.panel-note {
  margin: 0 2px 12px;
  font-size: 12px;
  color: var(--ink-3);
}

/* ------------------------------------------------------------------- grid */

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}

.tile {
  position: relative;
  display: grid;
  gap: 6px;
  padding: 7px 7px 9px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color .15s, transform .15s, box-shadow .15s, color .15s;
}
.tile:hover { border-color: var(--line-strong); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.tile.is-selected {
  border-color: var(--accent);
  color: var(--ink);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.tile-art {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 8px;
  background: linear-gradient(180deg, var(--surface-2), color-mix(in srgb, var(--line) 60%, var(--surface-2)));
  overflow: hidden;
  color: var(--ink-3);
}
.tile-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-art svg { width: 26px; height: 26px; }
.tile-initial { font-size: 15px; font-weight: 600; letter-spacing: .02em; }

.tile-label {
  font-size: 12px;
  font-weight: 550;
  line-height: 1.2;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile.is-loading .tile-art::after {
  content: '';
  position: absolute;
  inset: 7px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 66%, transparent);
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .45; } }

/* --------------------------------------------------------------- swatches */

.swatches { margin-top: 18px; }
.swatches-title,
.slider-group-title {
  margin: 0 0 9px 2px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.picker {
  margin-bottom: 16px;
}
.picker + .picker {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.picker-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.picker-chip {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border-radius: 7px;
  background: var(--chip);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 18%);
}
.picker-label {
  font-size: 12px;
  font-weight: 550;
  color: var(--ink-2);
}
.picker-hex {
  margin-left: auto;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
  color: var(--ink-3);
}
.picker-reset {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--ink-3);
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.picker-reset svg { width: 13px; height: 13px; }
.picker-reset:hover { color: var(--ink); border-color: var(--line-strong); }

.hsb {
  display: grid;
  grid-template-columns: 14px 1fr;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
}
.hsb > span {
  font-size: 11.5px;
  font-weight: 650;
  color: var(--ink-3);
}

.hsb input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 16px;
  background: transparent;
  cursor: pointer;
}
/* Each track is painted with the colours that slider travels through, so the
   control reads as a picker rather than three grey bars. */
.hsb input[type='range']::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--from, #000), var(--to, #fff));
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 10%);
}
.hsb input[type='range']::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--from, #000), var(--to, #fff));
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 10%);
}
.hsb:first-of-type input[type='range']::-webkit-slider-runnable-track {
  background: linear-gradient(90deg, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
}
.hsb:first-of-type input[type='range']::-moz-range-track {
  background: linear-gradient(90deg, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
}
.hsb input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -3px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--ink);
  box-shadow: 0 1px 3px rgb(16 22 36 / 30%);
}
.hsb input[type='range']::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--ink);
  box-shadow: 0 1px 3px rgb(16 22 36 / 30%);
}

/* ---------------------------------------------------------------- sliders */

.slider-group { margin-bottom: 18px; }

.slider {
  display: grid;
  gap: 3px;
  padding: 5px 2px 7px;
}
.slider-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.slider-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}
.slider output {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
}

.slider input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  background: transparent;
  cursor: pointer;
}
.slider input[type='range']::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: var(--line);
}
.slider input[type='range']::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: var(--line);
}
.slider input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  margin-top: -5.5px;
  border-radius: 50%;
  background: var(--accent);
  border: 2.5px solid var(--surface);
  box-shadow: 0 1px 3px rgb(16 22 36 / 25%);
}
.slider input[type='range']::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--accent);
  border: 2.5px solid var(--surface);
  box-shadow: 0 1px 3px rgb(16 22 36 / 25%);
}

.ghost-button {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink-2);
  font: inherit;
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.ghost-button:hover { border-color: var(--line-strong); color: var(--ink); }

/* ------------------------------------------------------------------ loader */

#loader {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  background: var(--bg);
  transition: opacity .45s ease;
}
#loader.is-done { opacity: 0; pointer-events: none; }
#loader p {
  margin: 0;
  font-size: 12.5px;
  font-weight: 550;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.loader-track {
  width: 190px;
  height: 3px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
#loader-bar {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #6f4bff);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .25s ease;
}

/* ------------------------------------------------------------- responsive */

@media (max-width: 900px) {
  :root { --dock-w: auto; }

  .dock {
    top: auto;
    left: 10px;
    right: 10px;
    bottom: 10px;
    height: min(52vh, 430px);
  }
  .toolbar { right: 14px; top: 14px; }
  .tool span { display: none; }
  .tool { padding: 0 10px; }
  .brand { top: 14px; left: 14px; }
  .grid { grid-template-columns: repeat(4, 1fr); }
  .rail { grid-template-columns: repeat(6, 1fr); }

  .env-bar {
    top: auto;
    bottom: calc(min(52vh, 430px) + 74px);
    left: 14px;
    transform: none;
    padding: 5px 8px 5px 11px;
  }
  .env-spin input[type='range'] { width: 56px; }
  .env-spin output { display: none; }
  .camera-rail {
    left: auto;
    right: 14px;
    top: 68px;
    transform: none;
    grid-auto-flow: column;
  }
  .camera-rail .bar-label { display: none; }
  .anim-bar .bar-label { display: none; }
  .camera-snap { width: 46px; }
  .anim-bar {
    left: 10px;
    right: 10px;
    bottom: calc(min(52vh, 430px) + 20px);
  }
}

@media (max-width: 520px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
  .brand-text { display: none; }
}

@media (max-width: 900px) {
  .brand-text .brand-by { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
