/* Pixel Dither: a dark tool UI. Tokens first; components use only these. */
:root {
  color-scheme: dark;
  --bg: #0b0b0d;
  --panel: #131316;
  --inset: #1b1b20;
  --line: #2a2a31;
  --line-strong: #3d3d46;
  --fg: #f4f4f5;
  --fg-2: #c9c9d0;
  --muted: #a1a1aa; /* 7.6:1 on --bg */
  --accent: #7dd3fc;
  --radius: 10px;
  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --fast: 120ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
/* Any display rule below would otherwise beat the hidden attribute. */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--fg-2); }
a:hover { color: var(--fg); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.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;
}
.skip { position: absolute; left: -999px; top: 8px; }
.skip:focus { left: 8px; background: var(--panel); padding: 6px 10px; border-radius: 6px; }

.bar {
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; padding: 0 20px; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 15px; font-weight: 600; }
/* The mark: a 2 by 2 checker, the tool's pattern at its smallest. */
.mark {
  width: 14px; height: 14px; border-radius: 2px;
  background: conic-gradient(var(--fg) 25%, var(--line-strong) 0 50%, var(--fg) 0 75%, var(--line-strong) 0);
}
.bar-links { display: flex; gap: 4px; }
.link {
  font: inherit; color: var(--muted); background: none; border: 0; cursor: pointer;
  padding: 6px 10px; border-radius: 6px; text-decoration: none;
}
.link:hover { color: var(--fg); }

.layout {
  display: grid; gap: 16px; padding: 16px;
  grid-template-columns: 1fr;
  min-height: calc(100% - 56px);
}
@media (min-width: 900px) {
  .layout { grid-template-columns: 1fr 320px; height: calc(100% - 56px); }
}

.stage {
  position: relative; min-height: 55vh;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.stage.dragging { border-color: var(--accent); }
.stage canvas {
  position: absolute; inset: 16px; width: calc(100% - 32px); height: calc(100% - 32px);
  object-fit: contain; image-rendering: pixelated;
}
.empty {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 4px;
  padding: 24px; pointer-events: none;
}
.empty-title { margin: 0; font-size: 16px; font-weight: 500; }
.empty-note { margin: 0; color: var(--muted); }
.badge {
  position: absolute; top: 12px; left: 12px; margin: 0;
  font: 11px/1 var(--mono); letter-spacing: 0.06em; text-transform: uppercase;
  background: rgb(0 0 0 / 0.7); color: var(--fg); padding: 6px 8px; border-radius: 4px;
}

.panel {
  display: grid; align-content: start; gap: 18px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; overflow: auto;
}
.row { display: flex; flex-wrap: wrap; gap: 8px; }
.button {
  display: inline-flex; align-items: center; justify-content: center; height: 36px; padding: 0 14px;
  font: 500 13px var(--font); color: var(--fg); background: var(--inset);
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
  transition: border-color var(--fast) var(--ease), background-color var(--fast) var(--ease);
}
.button:hover { border-color: var(--line-strong); }
.button:disabled { opacity: 0.45; cursor: default; }
.button.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.button[aria-pressed="true"] { border-color: var(--accent); }
label.button:has(:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.palette { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--inset); }
.palette span { flex: 1; }

.field { display: grid; gap: 8px; }
.field label {
  display: flex; justify-content: space-between;
  font: 11px/1.4 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.field output { font-variant-numeric: tabular-nums; color: var(--fg-2); }
input[type="range"] { width: 100%; accent-color: var(--fg); }
select {
  height: 36px; padding: 0 10px; font: inherit; color: var(--fg);
  background: var(--inset); border: 1px solid var(--line); border-radius: 8px;
}
.status { margin: 0; min-height: 1.5em; color: var(--muted); font-size: 13px; }
.foot { margin: 0; color: var(--muted); font-size: 12px; }

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