:root {
  color-scheme: dark;
  --bg: #09090b;
  --bg-2: #111113;
  --bg-3: #18181b;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --accent: #d6fb51;
  --accent-ink: #141807;
  --danger: #fb7185;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --radius: 16px;
  font-family: "Segoe UI Variable", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(214, 251, 81, 0.08), transparent 55%),
    var(--bg);
  color: var(--text);
}

body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

button, input, select { font: inherit; color: inherit; }

button { cursor: pointer; }

a { color: var(--accent); }

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 9, 11, 0.8);
  backdrop-filter: blur(16px);
}

.brand { display: flex; align-items: center; gap: 12px; }

.logo { width: 28px; height: 28px; color: var(--accent); }

.mark {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.04em;
  line-height: 1;
}

.sub { color: var(--muted); font-size: 12px; margin-top: 4px; }

.hw {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
}

main {
  display: grid;
  grid-template-columns: 400px minmax(0, 1fr);
  min-height: 0;
}

.panel {
  overflow: auto;
  border-right: 1px solid var(--line);
  padding: 18px 18px 32px;
}

.drop {
  position: relative;
  height: 188px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(214, 251, 81, 0.06), transparent 46%),
    var(--bg-3);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.drop:hover { border-color: rgba(214, 251, 81, 0.45); }

.drop:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.drop img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #050506;
}

.drop p {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  margin: 0;
  text-align: center;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.drop p span { color: var(--muted); font-size: 13px; font-weight: 400; }

.drop.has-image p { display: none; }

.seg {
  display: flex;
  gap: 4px;
  margin-top: 10px;
  padding: 4px;
  width: fit-content;
  border-radius: 999px;
  background: var(--bg-3);
  border: 1px solid var(--line);
}

.seg button, .tool, .downloads a, .quiet, #seed-random, #weights-button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 7px 12px;
  border-radius: 999px;
}

.seg button { border: 0; border-radius: 999px; }

.seg button.on, .tool.on {
  background: var(--text);
  color: #09090b;
}

.examples {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-top: 12px;
  padding-bottom: 4px;
}

.examples button {
  padding: 0;
  border: 1px solid var(--line);
  background: #050506;
  width: 68px;
  height: 68px;
  flex: 0 0 auto;
  border-radius: 14px;
  overflow: hidden;
}

.examples button:hover { border-color: rgba(214, 251, 81, 0.5); }

.examples img { width: 100%; height: 100%; object-fit: cover; display: block; }

fieldset {
  border: 1px solid var(--line);
  margin: 16px 0 0;
  padding: 14px 14px 6px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.02);
}

legend {
  padding: 0 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.field { display: block; margin: 0 0 14px; }

.field-name {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
}

.help {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

output { color: var(--accent); font-variant-numeric: tabular-nums; font-weight: 650; }

input[type="range"] { width: 100%; accent-color: var(--accent); margin: 0; }

select, input[type="number"] {
  width: 100%;
  background: #0c0c0e;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 9px 12px;
}

.seed-row { display: flex; gap: 8px; }

.seed-row input { flex: 1; }

#seed-random { white-space: nowrap; }

details {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px 4px;
  background: rgba(255, 255, 255, 0.02);
}

summary {
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
  margin-bottom: 12px;
}

.hint, .credit, .job, .stats, .stage-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.hint { margin: 10px 2px; }

.primary {
  width: 100%;
  margin-top: 16px;
  padding: 13px 14px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.primary:hover:not(:disabled) { filter: brightness(1.05); }

.primary:disabled, button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.quiet {
  width: 100%;
  margin-top: 8px;
  border-color: transparent;
  color: var(--muted);
}

.gpu-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.gpu-actions a {
  display: inline-block;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  text-decoration: none;
}

.banner, .warn, .error {
  margin-top: 12px;
  padding: 12px 14px;
  background: #1c1912;
  border: 1px solid rgba(214, 251, 81, 0.25);
  border-radius: 14px;
}

.warn { background: #231418; border-color: rgba(251, 113, 133, 0.35); color: #fecdd3; }

.error {
  white-space: pre-wrap;
  color: #fecdd3;
  background: #231418;
  border-color: rgba(251, 113, 133, 0.35);
  max-height: 160px;
  overflow: auto;
}

.meter { height: 4px; background: rgba(255, 255, 255, 0.08); margin: 8px 0; border-radius: 999px; overflow: hidden; }

.meter > div { height: 100%; width: 0; background: var(--accent); }

.stage-meter {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  margin: 0;
  z-index: 2;
  background: transparent;
  border-radius: 0;
}

.credit { margin-top: 22px; }

.gate {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(9, 9, 11, 0.78);
  backdrop-filter: blur(10px);
}

.gate form {
  width: min(420px, 100%);
  padding: 28px 24px 22px;
  background: var(--bg-2);
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.gate h1 {
  margin: 0 0 8px;
  font-weight: 650;
  letter-spacing: -0.04em;
  font-size: 28px;
}

.gate p { color: var(--muted); }

.gate label { display: grid; gap: 8px; margin: 18px 0; color: var(--text); font-weight: 600; }

.gate input {
  width: 100%;
  padding: 11px 12px;
  background: #0c0c0e;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  font-weight: 400;
}

.gate button {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  border-radius: 12px;
  font-weight: 700;
}

.gate-error { min-height: 1.2em; color: var(--danger); }

.stage { position: relative; min-width: 0; min-height: 0; background: #070708; }

canvas { width: 100%; height: 100%; display: block; touch-action: none; }

.steps {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  list-style: none;
  margin: 0;
  padding: 8px;
  border-radius: 16px;
  background: rgba(12, 12, 14, 0.78);
  border: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.steps li {
  color: var(--muted);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 999px;
}

.steps li.on { color: #09090b; background: var(--accent); font-weight: 700; }

.steps li.done { color: var(--text); }

.toolbar, .stage-note, .stage-foot { position: absolute; z-index: 2; }

.toolbar {
  top: 16px;
  left: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(12, 12, 14, 0.72);
  border: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.tool { background: transparent; border-color: transparent; }

.stage-note {
  top: 72px;
  left: 20px;
  right: 20px;
  margin: 0;
  pointer-events: none;
}

.stage-foot {
  left: 16px;
  right: 16px;
  bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;
}

.stage-foot > * { pointer-events: auto; }

.stats { margin: 0; max-width: 46%; }

.downloads { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }

.downloads a {
  text-decoration: none;
  background: rgba(12, 12, 14, 0.82);
  color: var(--text);
  backdrop-filter: blur(12px);
}

.downloads a:hover, .tool:hover, #weights-button:hover, #seed-random:hover, .quiet:hover {
  border-color: rgba(214, 251, 81, 0.45);
  color: var(--text);
}

@media (max-width: 980px) {
  body { overflow: auto; height: auto; }
  main { grid-template-columns: 1fr; }
  .stage { height: 72vh; }
  .panel { border-right: 0; border-bottom: 1px solid var(--line); }
}
