@font-face {
  font-family: "Sen";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("assets/sen-regular.woff2") format("woff2");
}

@font-face {
  font-family: "Sen";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("assets/sen-bold.woff2") format("woff2");
}

@font-face {
  font-family: "Fragment Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("assets/fragment-mono-latin.woff2") format("woff2");
}

:root {
  color-scheme: dark;
  font-family: "Sen", ui-sans-serif, system-ui, sans-serif;
  font-synthesis: none;
  --ink: #ded8b8;
  --ink-strong: #ffffff;
  --muted: rgba(222, 216, 184, 0.64);
  --paper: #1f1e1c;
  --panel: #25251f;
  --panel: color-mix(in srgb, #1f1e1c 94%, #647855);
  --line: rgba(222, 216, 184, 0.2);
  --lichen: #647855;
  --pop: #e2ffb5;
  --pop-ink: #1f1e1c;
  --highlight: #ffffff;
  --dark: #1f1e1c;
  --stage-text: #ded8b8;
  --control: rgba(222, 216, 184, 0.08);
}

@supports (color: color(display-p3 1 1 1)) {
  :root {
    --pop: color(display-p3 0.91 1 0.74);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  width: 100%;
  height: 100%;
  margin: 0;
  overscroll-behavior: none;
  background: var(--paper);
  color: var(--ink);
}

html {
  overflow: clip;
}

body {
  position: fixed;
  inset: 0;
  overflow: clip;
  user-select: none;
  -webkit-user-select: none;
}

input[type="text"],
input[type="number"],
textarea,
[contenteditable="true"] {
  user-select: text;
  -webkit-user-select: text;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr);
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.app-header {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  padding: 0 16px 0 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(31, 30, 28, 0.97);
}

.brand-block,
.header-actions,
.stage-toolbar,
.stage-actions,
.zoom-controls,
.control-row,
.section-heading,
.color-control,
.stage-footer {
  display: flex;
  align-items: center;
}

.brand-block {
  min-width: 0;
  gap: 10px;
}

.brand-mark {
  display: block;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  overflow: visible;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  overflow: hidden;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-divider {
  color: var(--lichen);
  font-weight: 400;
}

.header-actions {
  gap: 6px;
}

.button,
.copy-button {
  height: 34px;
  border-radius: 6px;
  padding: 0 13px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.button:active,
.copy-button:active,
.preset:active,
.segment:active,
.zoom-controls button:active {
  transform: translateY(1px);
}

.button-quiet,
.copy-button {
  border-color: var(--line);
  background: var(--control);
}

.button-quiet:hover,
.copy-button:hover {
  border-color: rgba(222, 216, 184, 0.44);
  background: rgba(222, 216, 184, 0.13);
}

.stage-actions {
  gap: 6px;
}

.lightbox-button {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid rgba(222, 216, 184, 0.24);
  border-radius: 6px;
  background: rgba(222, 216, 184, 0.08);
  color: var(--stage-text);
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
}

.lightbox-button:hover {
  border-color: var(--stage-text);
  background: rgba(222, 216, 184, 0.16);
}

.button-primary {
  border-color: var(--pop);
  background: var(--pop);
  color: var(--pop-ink);
}

.button-primary:hover {
  border-color: var(--lichen);
  background: var(--highlight);
}

.workbench {
  display: grid;
  grid-template-columns: 326px minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.controls {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.controls,
.canvas-wrap {
  scrollbar-width: thin;
  scrollbar-color: rgba(222, 216, 184, 0.22) rgba(100, 120, 85, 0.12);
}

.controls::-webkit-scrollbar,
.canvas-wrap::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.controls::-webkit-scrollbar-track,
.canvas-wrap::-webkit-scrollbar-track,
.controls::-webkit-scrollbar-corner,
.canvas-wrap::-webkit-scrollbar-corner {
  background: rgba(100, 120, 85, 0.12);
}

.controls::-webkit-scrollbar-thumb,
.canvas-wrap::-webkit-scrollbar-thumb {
  border-radius: 3px;
  background: rgba(222, 216, 184, 0.2);
}

.controls::-webkit-scrollbar-thumb:hover,
.canvas-wrap::-webkit-scrollbar-thumb:hover {
  background: rgba(222, 216, 184, 0.34);
}

.control-section {
  padding: 20px 18px 22px;
  border-bottom: 1px solid var(--line);
}

.section-heading {
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-heading h2 {
  color: var(--ink-strong);
  font-family: "Fragment Mono", ui-monospace, monospace;
  font-size: 10px;
  font-weight: 400;
  text-transform: uppercase;
}

.section-heading span {
  color: var(--muted);
  font-family: "Fragment Mono", ui-monospace, monospace;
  font-size: 10px;
}

.section-stats {
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-stats .stat-divider {
  color: var(--line);
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.preset {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  min-width: 0;
  height: 42px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--control);
  cursor: pointer;
  text-align: left;
}

.preset strong {
  font-size: 14px;
}

.preset span {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preset.is-active {
  border-color: var(--lichen);
  background: var(--lichen);
  color: var(--highlight);
}

.preset.is-active span {
  color: rgba(255, 255, 255, 0.72);
}

.control-row {
  justify-content: space-between;
  margin-top: 16px;
  margin-bottom: 7px;
  gap: 12px;
}

.control-section > .control-row:first-child {
  margin-top: 0;
}

label,
.value-field {
  font-size: 12px;
}

.value-field {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 72px;
  height: 26px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--muted);
  background: var(--control);
  font-family: "Fragment Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

.value-field:focus-within {
  border-color: var(--lichen);
  color: var(--ink-strong);
}

.value-field-unitless {
  min-width: 54px;
}

.value-field input {
  width: 48px;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: 0;
  color: inherit;
  background: transparent;
  font: inherit;
  text-align: right;
}

.value-field input::-webkit-inner-spin-button,
.value-field input::-webkit-outer-spin-button {
  margin-left: 4px;
}

input[type="range"] {
  display: block;
  width: 100%;
  height: 18px;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
  accent-color: var(--lichen);
  background: transparent;
  cursor: ew-resize;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border: 0;
  border-radius: 3px;
  -webkit-appearance: none;
  appearance: none;
  background: linear-gradient(to right, var(--lichen) 0 var(--fill, 50%), rgba(100, 120, 85, 0.26) var(--fill, 50%) 100%);
  box-shadow: none;
}

input[type="range"]::-webkit-slider-thumb {
  width: 15px;
  height: 15px;
  margin-top: -6px;
  border: 2px solid var(--panel);
  border-radius: 50%;
  -webkit-appearance: none;
  appearance: none;
  background: var(--lichen);
  box-shadow: 0 0 0 1px var(--lichen);
}

input[type="range"]::-moz-range-track {
  height: 3px;
  border: 0;
  border-radius: 3px;
  background: rgba(100, 120, 85, 0.26);
}

input[type="range"]::-moz-range-progress {
  height: 3px;
  border-radius: 3px;
  background: var(--lichen);
}

input[type="range"]::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border: 2px solid var(--panel);
  border-radius: 50%;
  background: var(--lichen);
  box-shadow: 0 0 0 1px var(--lichen);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  height: 34px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(94, 93, 90, 0.1);
}

.segmented-two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.geometry-control {
  margin-bottom: 10px;
}

.palette-picker {
  margin-bottom: 8px;
  padding: 10px 0 14px;
  border-bottom: 1px solid var(--line);
}

.palette-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.palette-heading > span {
  color: var(--muted);
  font-family: "Fragment Mono", ui-monospace, monospace;
  font-size: 11px;
}

.palette-target {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 132px;
  height: 26px;
  padding: 2px;
  border-radius: 5px;
  background: rgba(94, 93, 90, 0.1);
}

.palette-target button {
  min-width: 0;
  padding: 0 6px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 9px;
  font-weight: 650;
}

.palette-target button.is-active {
  background: var(--lichen);
  color: var(--highlight);
  box-shadow: none;
}

.swatch-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}

.palette-swatch {
  position: relative;
  width: 100%;
  height: 26px;
  padding: 0;
  border: 1px solid rgba(31, 30, 28, 0.24);
  border-radius: 3px;
  background: var(--swatch-fallback);
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.palette-swatch.is-active::after {
  position: absolute;
  inset: -3px;
  border: 1.5px solid var(--ink-strong);
  border-radius: 5px;
  content: "";
}

@supports (color: color(display-p3 1 1 1)) {
  .palette-swatch {
    background: var(--swatch);
  }
}

.segment {
  min-width: 0;
  padding: 0 6px;
  overflow: hidden;
  border: 0;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  text-overflow: ellipsis;
}

.segment.is-active {
  background: var(--lichen);
  color: var(--highlight);
  box-shadow: none;
}

.color-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px 76px;
  min-height: 36px;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.color-control input[type="color"] {
  align-self: center;
  width: 24px;
  height: 24px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}

.color-control input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-control input[type="color"]::-webkit-color-swatch {
  border: 2px solid var(--panel);
  border-radius: 3px;
}

.hex-field {
  width: 76px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--muted);
  font-family: "Fragment Mono", ui-monospace, monospace;
  font-size: 11px;
  text-align: right;
  text-transform: uppercase;
}

.stage {
  position: relative;
  display: grid;
  grid-template-rows: 48px minmax(0, 1fr) 34px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--dark);
}

.stage-toolbar {
  position: relative;
  z-index: 2;
  justify-content: space-between;
  padding: 0 14px;
  border-bottom: 1px solid rgba(222, 216, 184, 0.14);
  color: var(--stage-text);
  background: var(--dark);
}

.zoom-controls {
  height: 30px;
  overflow: hidden;
  border: 1px solid rgba(222, 216, 184, 0.22);
  border-radius: 6px;
}

.zoom-controls button {
  width: 30px;
  height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--stage-text);
  cursor: pointer;
  font-size: 17px;
}

.zoom-controls button:hover {
  background: rgba(222, 216, 184, 0.12);
}

.zoom-controls .zoom-value {
  width: 50px;
  border-right: 1px solid rgba(222, 216, 184, 0.16);
  border-left: 1px solid rgba(222, 216, 184, 0.16);
  font-size: 10px;
  font-family: "Fragment Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.copy-button {
  height: 30px;
  border-color: rgba(222, 216, 184, 0.24);
  background: rgba(222, 216, 184, 0.08);
  color: var(--stage-text);
}

.copy-button:hover {
  border-color: var(--stage-text);
  background: rgba(222, 216, 184, 0.16);
}

.canvas-wrap {
  display: flex;
  container-type: size;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 44px;
  background-color: var(--dark);
  background-image: linear-gradient(rgba(222, 216, 184, 0.035) 1px, transparent 1px), linear-gradient(90deg, rgba(222, 216, 184, 0.035) 1px, transparent 1px);
  background-size: 24px 24px;
}

.canvas {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: min(100cqw, 100cqh, 720px);
  aspect-ratio: 1;
  margin: auto;
  padding: 0;
  overflow: hidden;
  zoom: var(--zoom, 1);
  border: 1px solid rgba(222, 216, 184, 0.2);
  border-radius: 2px;
  background: var(--canvas-bg, #1f1e1c);
  box-shadow: 0 22px 56px rgba(0, 0, 0, 0.28);
  cursor: zoom-in;
  transition: background 160ms ease;
}

#preview {
  display: block;
  width: 100%;
  height: 100%;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--lightbox-bg, #1f1e1c);
  cursor: ns-resize;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.lightbox[hidden] {
  display: none;
}

.lightbox:fullscreen {
  width: 100vw;
  height: 100vh;
}

.lightbox-preview {
  position: absolute;
  top: 50%;
  left: 50%;
  display: block;
  width: var(--lightbox-size, min(82vmin, 1200px));
  height: var(--lightbox-size, min(82vmin, 1200px));
  max-width: none;
  max-height: none;
  transform: translate(-50%, -50%);
  cursor: ns-resize;
  will-change: width, height;
}

.lightbox-preview:focus {
  outline: none;
}

.lightbox-scale {
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  width: 124px;
  height: 38px;
  padding: 0 12px;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: rgba(222, 216, 184, 0.1);
  color: rgba(222, 216, 184, 0.72);
  cursor: text;
  font-family: "Fragment Mono", ui-monospace, monospace;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.lightbox-scale:focus-within {
  border-color: rgba(222, 216, 184, 0.38);
  color: var(--ink);
}

.lightbox-scale input {
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: 0;
  appearance: textfield;
  background: transparent;
  color: inherit;
  cursor: text;
  font: inherit;
  text-align: right;
}

.lightbox-scale input:focus-visible {
  outline: none;
}

.lightbox-scale input::-webkit-inner-spin-button,
.lightbox-scale input::-webkit-outer-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.lightbox-close {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  z-index: 1;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: transparent;
  color: #ffffff;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
  opacity: 0.62;
  mix-blend-mode: difference;
}

.lightbox-close:hover,
.lightbox-close:focus-visible {
  opacity: 1;
}

.stage-footer {
  justify-content: space-between;
  padding: 0 14px;
  border-top: 1px solid rgba(222, 216, 184, 0.14);
  background: var(--dark);
  color: rgba(222, 216, 184, 0.62);
  font-family: "Fragment Mono", ui-monospace, monospace;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.toast {
  position: absolute;
  right: 16px;
  bottom: 48px;
  z-index: 4;
  max-width: calc(100% - 32px);
  padding: 9px 12px;
  border-radius: 6px;
  border: 1px solid var(--pop-ink);
  background: var(--pop);
  color: var(--pop-ink);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.24);
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(5px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--lichen);
  outline-offset: 2px;
}

@media (max-width: 760px) {
  .app-shell {
    display: grid;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  .app-header {
    height: 58px;
  }

  #reset-button {
    display: none;
  }

  .button {
    padding: 0 10px;
  }

  .workbench {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
  }

  .stage {
    order: 1;
    flex: 0 0 min(58dvh, 520px);
    height: auto;
    min-height: 0;
  }

  .controls {
    order: 2;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    border-top: 1px solid var(--line);
    border-right: 0;
  }

  .canvas-wrap {
    padding: 24px;
  }

  .canvas {
    width: min(100cqw, 100cqh, 520px);
  }
}

@media (max-width: 430px) {
  .brand-block {
    gap: 8px;
  }

  .brand-mark {
    display: none;
  }

  .header-actions {
    gap: 4px;
  }

  .button {
    height: 32px;
    padding: 0 8px;
    font-size: 11px;
  }

  .canvas-wrap {
    padding: 16px;
  }
}

@media (max-width: 370px) {
  #randomize-button {
    display: none;
  }
}

@supports (-webkit-touch-callout: none) {
  input[type="text"],
  input[type="number"],
  textarea {
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
