/* Brand tokens (Value.tokens.json), matching the other tools */
:root {
  color-scheme: dark;
  --page: #111317;
  --layer: #21242c;
  --layer-hover: #292d36;
  --layer-secondary: #373c49;
  --border: #4e5566;
  --border-soft: #373c49;
  --heading: #f0f2f4;
  --body: #d5d9e0;
  --caption: #848fa4;
  --muted: #697388;
  --primary: #00ccaa;
  --primary-300: #007a66;
  --primary-400: #00a388;
  --primary-100: #002922;
  --secondary: #f57a3d;
  --secondary-400: #c46231;
  --px: 4px;
  --font-pixel: "Press Start 2P", ui-monospace, monospace;
  --font-heading: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { min-width: 320px; background: var(--page); }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 80% 8%, rgb(0 204 170 / 0.08), transparent 30rem),
    radial-gradient(circle at 8% 90%, rgb(245 122 61 / 0.05), transparent 26rem),
    var(--page);
  color: var(--heading);
  font-family: var(--font-body);
  line-height: 1.5;
}

/* Pixel grid backdrop, like the homepage */
body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: linear-gradient(rgb(255 255 255 / 0.025) 1px, transparent 1px), linear-gradient(90deg, rgb(255 255 255 / 0.025) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(to bottom, black, transparent 70%);
  content: "";
  pointer-events: none;
}

button, input { font: inherit; color: inherit; }

a { color: inherit; }

[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Stepped "pixel" corners */
.pixel-box,
.stage-card,
.panel,
.btn,
.tab,
.chip,
.swatch,
.segmented,
.hex-field,
.color-well,
.icon-button {
  clip-path: polygon(
    0 var(--px), var(--px) var(--px), var(--px) 0,
    calc(100% - var(--px)) 0, calc(100% - var(--px)) var(--px), 100% var(--px),
    100% calc(100% - var(--px)), calc(100% - var(--px)) calc(100% - var(--px)), calc(100% - var(--px)) 100%,
    var(--px) 100%, var(--px) calc(100% - var(--px)), 0 calc(100% - var(--px))
  );
}

/* Page */
.gb-app {
  width: min(1296px, calc(100% - 40px));
  margin: 0 auto;
  padding: 40px 0 48px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--caption);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: color 160ms ease;
}

.back-link .icon { width: 18px; height: 18px; }

.back-link:hover { color: var(--primary); }

.gb-hero {
  max-width: 780px;
  margin: clamp(32px, 8vh, 80px) 0 36px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 20px;
  color: var(--primary);
  font-family: var(--font-pixel);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow__mark {
  width: 10px;
  height: 10px;
  background: var(--primary);
  box-shadow: 4px 4px 0 var(--primary-300);
}

.gb-hero h1 {
  margin: 0;
  font-family: var(--font-pixel);
  font-size: clamp(22px, 4vw, 40px);
  font-weight: 400;
  line-height: 1.35;
  text-shadow: 4px 4px 0 #000;
}

.gb-hero h1 .nowrap { white-space: nowrap; }

.gb-hero h1 .accent {
  color: var(--primary);
  text-shadow: 4px 4px 0 var(--primary-100);
}

.cursor {
  display: inline-block;
  width: 0.55em;
  height: 0.9em;
  margin-left: 0.25em;
  vertical-align: -0.08em;
  background: var(--secondary);
  animation: blink 1.1s steps(1) infinite;
}

@keyframes blink { 50% { opacity: 0; } }

.gb-hero__copy {
  margin: 22px 0 0;
  max-width: 640px;
  color: var(--caption);
  font-size: 17px;
}

/* Layout */
.gb-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  align-items: start;
  gap: 24px;
}

/* 3D stage */
.stage-card {
  position: sticky;
  top: 20px;
  background: var(--layer);
  padding: var(--px);
}

.stage-card__bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--page);
  border-bottom: var(--px) solid var(--layer);
}

.stage-card__dots { display: flex; gap: 6px; }

.stage-card__dots i {
  width: 8px;
  height: 8px;
  background: var(--border);
}

.stage-card__dots i:first-child { background: var(--secondary); }
.stage-card__dots i:nth-child(2) { background: var(--primary); }

.stage-card__title {
  color: var(--muted);
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: 0.08em;
}

.view-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 12px;
  border: 0;
  background: var(--layer);
  color: var(--body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.chip .icon { width: 16px; height: 16px; }

.chip:hover { background: var(--layer-secondary); }

.chip.is-active {
  background: var(--primary);
  color: var(--page);
}

.stage {
  position: relative;
  height: min(72vh, 720px);
  min-height: 420px;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 40%, rgb(0 204 170 / 0.12), transparent 60%),
    linear-gradient(180deg, #1a1d23, #121418);
}

/* Faint LCD scanlines over the preview */
.stage::after {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, rgb(0 0 0 / 0.12) 0 1px, transparent 1px 3px);
  content: "";
  pointer-events: none;
}

.stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

.stage canvas:active { cursor: grabbing; }

.stage__hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  margin: 0;
  transform: translateX(-50%);
  color: var(--muted);
  font-family: var(--font-pixel);
  font-size: 8px;
  letter-spacing: 0.06em;
  white-space: nowrap;
  pointer-events: none;
}

.stage__error {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 32px;
  color: var(--body);
  text-align: center;
}

/* Control panel */
.panel {
  background: var(--layer);
  padding: 20px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 20px;
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 4px 10px;
  border: 0;
  background: var(--page);
  color: var(--caption);
  font-family: var(--font-pixel);
  font-size: 8px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.tab:hover { color: var(--heading); background: #181a1f; }

.tab.is-active {
  background: var(--primary);
  color: var(--page);
}

.halves {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 2px dashed var(--border-soft);
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.switch input { position: absolute; opacity: 0; pointer-events: none; }

.switch__track {
  position: relative;
  width: 40px;
  height: 20px;
  background: var(--page);
  box-shadow: inset 0 0 0 2px var(--border);
}

.switch__track::after {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 12px;
  height: 12px;
  background: var(--caption);
  content: "";
  transition: transform 140ms steps(3), background 140ms ease;
}

.switch input:checked + .switch__track { box-shadow: inset 0 0 0 2px var(--primary); }

.switch input:checked + .switch__track::after {
  transform: translateX(20px);
  background: var(--primary);
}

.switch input:focus-visible + .switch__track { outline: 2px solid var(--primary); outline-offset: 2px; }

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--page);
}

.segmented button {
  min-height: 36px;
  border: 0;
  background: transparent;
  color: var(--caption);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.segmented button:hover { color: var(--heading); }

.segmented button.is-active {
  background: var(--layer-secondary);
  color: var(--heading);
  box-shadow: inset 0 -3px 0 var(--primary);
}

.current {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.current__swatch,
.swatch {
  --swatch: #c4bfb8;
  background: var(--swatch);
}

.current__swatch {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  box-shadow: inset 0 0 0 2px rgb(255 255 255 / 0.14), 4px 4px 0 #000;
}

.current__swatch.is-clear,
.swatches.is-clear .swatch {
  background:
    linear-gradient(135deg, rgb(255 255 255 / 0.55) 0 22%, transparent 22% 48%, rgb(255 255 255 / 0.3) 48% 56%, transparent 56%),
    linear-gradient(color-mix(in srgb, var(--swatch) 60%, transparent), color-mix(in srgb, var(--swatch) 60%, transparent)),
    repeating-conic-gradient(#373c49 0 25%, #21242c 0 50%) 0 0 / 10px 10px;
}

.current > div { min-width: 0; flex: 1; }

.current .label { margin: 0 0 4px; }

.current__name {
  margin: 0;
  overflow: hidden;
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  background: var(--page);
  color: var(--primary);
  cursor: pointer;
  transition: background 120ms ease, transform 120ms ease;
}

.icon-button:hover { background: var(--layer-secondary); }

.icon-button:active { transform: rotate(-20deg) scale(0.94); }

.label {
  margin: 0 0 10px;
  color: var(--caption);
  font-family: var(--font-pixel);
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-bottom: 22px;
}

.swatch {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 0;
  box-shadow: inset 0 0 0 2px rgb(255 255 255 / 0.12);
  cursor: pointer;
  transition: transform 100ms steps(2);
}

.swatch:hover { transform: translateY(-2px); }

.swatch__check {
  width: 18px;
  height: 18px;
  color: #fff;
  opacity: 0;
  filter: drop-shadow(1px 1px 0 #000);
}

.swatch.is-active {
  box-shadow: inset 0 0 0 3px var(--primary), inset 0 0 0 5px var(--page);
}

.swatch.is-active .swatch__check { opacity: 1; }

.custom-color {
  display: flex;
  gap: 8px;
}

.color-well {
  position: relative;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  background: var(--page);
  color: var(--primary);
  cursor: pointer;
}

.color-well:hover { background: var(--layer-secondary); }

.color-well input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.hex-field {
  display: flex;
  align-items: center;
  flex: 1;
  gap: 4px;
  padding: 0 14px;
  background: var(--page);
  font-family: var(--font-pixel);
  font-size: 13px;
  color: var(--muted);
}

.hex-field:focus-within { box-shadow: inset 0 0 0 2px var(--primary); }

.hex-field input {
  width: 100%;
  min-width: 0;
  height: 48px;
  border: 0;
  background: transparent;
  color: var(--heading);
  font-family: var(--font-pixel);
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  outline: none;
}

.field-error {
  min-height: 20px;
  margin: 6px 0 8px;
  color: var(--secondary);
  font-size: 13px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 2px dashed var(--border-soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 14px;
  border: 0;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 80ms steps(2), filter 120ms ease;
}

.btn:active { transform: translate(2px, 2px); }

.btn--primary {
  grid-column: 1 / -1;
  background: var(--primary);
  color: var(--page);
  box-shadow: inset -4px -4px 0 var(--primary-300), inset 4px 4px 0 #5fe3cc;
}

.btn--primary:hover { filter: brightness(1.08); }

.btn--secondary {
  background: var(--layer-secondary);
  color: var(--heading);
  box-shadow: inset -4px -4px 0 #2a2e38, inset 4px 4px 0 #474d5c;
}

.btn--secondary:hover { filter: brightness(1.12); }

.btn--ghost {
  grid-column: 1 / -1;
  min-height: 40px;
  background: transparent;
  color: var(--caption);
  font-weight: 500;
}

.btn--ghost:hover { color: var(--heading); }

.feedback {
  min-height: 22px;
  margin: 10px 0 0;
  color: var(--primary);
  font-size: 14px;
  text-align: center;
}

/* Button chooser */
.chooser {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  padding: 4px;
  background: var(--page);
  clip-path: polygon(
    0 var(--px), var(--px) var(--px), var(--px) 0,
    calc(100% - var(--px)) 0, calc(100% - var(--px)) var(--px), 100% var(--px),
    100% calc(100% - var(--px)), calc(100% - var(--px)) calc(100% - var(--px)), calc(100% - var(--px)) 100%,
    var(--px) 100%, var(--px) calc(100% - var(--px)), 0 calc(100% - var(--px))
  );
}

.chooser button {
  min-height: 36px;
  padding: 0 2px;
  border: 0;
  background: transparent;
  color: var(--caption);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.chooser button:hover { color: var(--heading); }

.chooser button.is-active {
  background: var(--layer-secondary);
  color: var(--heading);
  box-shadow: inset 0 -3px 0 var(--primary);
}

.current__swatch.is-mixed {
  background: conic-gradient(#9b1b4a 0 25%, #1e1e22 0 50%, #8e8e96 0 75%, #00ccaa 0);
}

/* Saved colors */
.swatch-wrap { position: relative; }

.swatch-wrap .swatch { width: 100%; }

.swatch-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  background: var(--page);
  color: var(--heading);
  box-shadow: 0 0 0 2px var(--border);
  cursor: pointer;
  opacity: 0;
  transition: opacity 120ms ease;
}

.swatch-remove .icon { width: 14px; height: 14px; }

.swatch-wrap:hover .swatch-remove,
.swatch-remove:focus-visible { opacity: 1; }

.swatch-remove:hover { color: var(--secondary); }

@media (hover: none) {
  .swatch-remove { opacity: 1; }
}

.icon-button--save {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
}

/* Footer */
.gb-footer {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 2px dashed var(--border-soft);
  color: var(--muted);
  font-size: 13px;
}

.gb-footer p { margin: 0 0 8px; }

.gb-footer a { color: var(--caption); }

.gb-footer a:hover { color: var(--primary); }

.legal { display: flex; gap: 16px; }

/* Responsive */
@media (max-width: 1000px) {
  .gb-layout { grid-template-columns: 1fr; }

  .stage-card { position: relative; top: 0; }

  .stage { height: 62vh; min-height: 360px; }
}

@media (max-width: 560px) {
  .gb-app { width: calc(100% - 32px); padding-top: 24px; }

  .stage-card__title { display: none; }

  .view-buttons { margin-left: 0; }

  .stage-card__dots { display: none; }

  .stage { height: 56vh; min-height: 320px; }

  .panel { padding: 16px; }

  .swatches { gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .cursor { animation: none; }
  * { transition: none !important; }
}
