/* Layout: workbench — big live GIF on a checkerboard bench (left), tool rack of controls + export (right), stacks on phones. */
:root {
  --bg: #E6EAEE;
  --surface: #F8F9FA;
  --ink: #17212B;
  --muted: #586674;
  --line: #C9D1D8;
  --accent: #F2B705;
  --accent-ink: #17212B;
  --warn: #B4471B;
  --ok: #1E7A4C;
  --check-a: #FFFFFF;
  --check-b: #DCE1E6;
  --font-display: "Bowlby One", "Arial Black", Impact, sans-serif;
  --font-body: "Chivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Chivo Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11161C; --surface: #1A2129; --ink: #E7EBEF; --muted: #92A0AE; --line: #2B3540;
    --accent: #F5C02E; --accent-ink: #11161C; --warn: #F08A5D; --ok: #5CC98F;
    --check-a: #2A323B; --check-b: #222931; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11161C; --surface: #1A2129; --ink: #E7EBEF; --muted: #92A0AE; --line: #2B3540;
  --accent: #F5C02E; --accent-ink: #11161C; --warn: #F08A5D; --ok: #5CC98F;
  --check-a: #2A323B; --check-b: #222931; color-scheme: dark;
}

body { background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.5; }
.wrap { max-width: 1040px; margin: 0 auto; padding-inline: 20px; padding-block: 28px 48px; display: grid; gap: 24px; }

header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 18px; }
h1 { font-family: var(--font-display); font-weight: 400; font-size: clamp(34px, 6vw, 56px); line-height: 1; margin: 0; letter-spacing: -0.01em; text-wrap: balance; }
h1 span { display: inline-block; transform: rotate(-4deg); background: var(--accent); color: var(--accent-ink); padding: 0 10px; margin-left: 4px; }
header p { margin: 0; color: var(--muted); max-width: 46ch; }

main { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 760px) { main { grid-template-columns: minmax(0, 1fr); } }

.bench { display: grid; gap: 14px; }
.stage {
  position: relative; border: 2px dashed var(--line); border-radius: 6px; padding: 24px;
  display: grid; place-items: center; background: var(--surface); transition: border-color .15s;
}
.stage.drag, .stage:focus { border-color: var(--accent); outline: none; }
.stage:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.stage-hint kbd { font: 600 11px var(--font-mono); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 3px; padding: 0 5px; color: var(--ink); background: var(--bg); }
.stage .frame {
  width: min(100%, 384px); aspect-ratio: 1; max-width: 100%;
  background-color: var(--check-a);
  background-image: linear-gradient(45deg, var(--check-b) 25%, transparent 25%, transparent 75%, var(--check-b) 75%),
                    linear-gradient(45deg, var(--check-b) 25%, transparent 25%, transparent 75%, var(--check-b) 75%);
  background-size: 24px 24px; background-position: 0 0, 12px 12px;
}
.stage .frame.white { background: #FFFFFF; }
.stage img#big { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.stage-hint { font-family: var(--font-mono); font-size: 12px; color: var(--muted); text-align: center; margin: 0; }
.sample-tag {
  position: absolute; top: 12px; left: 12px; font-family: var(--font-mono); font-size: 11px; letter-spacing: .08em;
  text-transform: uppercase; background: var(--ink); color: var(--surface); padding: 2px 8px; border-radius: 3px;
}

.chat { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 14px 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.chat .who { font-weight: 800; font-size: 14px; }
.chat .who time { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 6px; font-family: var(--font-mono); }
.chat .msg { margin: 0; }
.chat .msg img { width: 22px; height: 22px; vertical-align: -5px; }
.reactions { display: flex; gap: 6px; flex-wrap: wrap; }
.reaction { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--accent); border-radius: 999px; padding: 1px 8px 1px 5px; font-family: var(--font-mono); font-size: 12px; }
.reaction img { width: 16px; height: 16px; }
.reaction.plain { border-color: var(--line); color: var(--muted); min-width: 0; overflow-wrap: anywhere; }

.rack { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 20px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.field { display: grid; gap: 6px; }
.label { font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; }
.label output { color: var(--ink); }

.btn {
  font: 800 15px var(--font-body); border-radius: 4px; padding: 10px 16px; cursor: pointer;
  border: 2px solid var(--ink); background: var(--surface); color: var(--ink); transition: transform .08s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent-ink); box-shadow: 3px 3px 0 var(--ink); }
.btn:focus-visible, input:focus-visible, .seg label:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }

.name { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); font-family: var(--font-mono); }
.name span { padding-left: 10px; color: var(--muted); }
.name span:last-child { padding: 0 10px 0 0; }
.name input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); font: inherit; padding: 9px 2px; }
.name input:focus-visible { outline: none; }
.link { display: flex; gap: 8px; }
.link .name { flex: 1; min-width: 0; }
.link input { padding-left: 10px; }
.link .btn { padding-block: 6px; }
.name:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }

input[type=range] { width: 100%; accent-color: var(--accent); }

.seg { display: flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.seg label { flex: 1; text-align: center; cursor: pointer; padding: 7px 4px; font-size: 13px; font-weight: 600; border-left: 1px solid var(--line); }
.seg label:first-child { border-left: 0; }
.seg label:has(input:checked) { background: var(--ink); color: var(--surface); }

.styles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.styles label {
  display: grid; justify-items: center; gap: 2px; padding: 6px 2px 8px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 4px; font-size: 12px; font-weight: 600; text-align: center;
}
.styles canvas { width: 56px; height: 56px; max-width: 100%; }
.seg input, .styles input, .swatches input { position: absolute; opacity: 0; pointer-events: none; }
.styles label:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); background: var(--bg); }
.styles label:has(input:focus-visible), .swatches label:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches label { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); cursor: pointer; }
.swatches label:has(input:checked) { border-color: var(--ink); box-shadow: 0 0 0 2px var(--accent); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.export { border-top: 1px solid var(--line); padding-top: 18px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
#download { overflow-wrap: anywhere; }
.stats { font-family: var(--font-mono); font-size: 13px; font-variant-numeric: tabular-nums; color: var(--muted); }
.chip { justify-self: start; font-family: var(--font-mono); font-size: 12px; padding: 2px 8px; border-radius: 3px; border: 1px solid currentColor; }
.chip.ok { color: var(--ok); }
.chip.warn { color: var(--warn); }
.note { font-size: 13px; color: var(--muted); margin: 0; }
.toast { font-size: 13px; font-weight: 600; min-height: 1.5em; margin: 0; }

[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { .btn, .stage { transition: none; } }
