@font-face {
  font-family: "VT323";
  src: url("../../../assets/fonts/VT323-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  --bg: #0a0a0a;
  --panel: #141414;
  --line: #262626;
  --text: #f3f4f6;
  --muted: #71717a;
  --ink: #f3f3f3;
  --mass: #000013;
}

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 12px/1.4 Inter, Geist, "Segoe UI", system-ui, sans-serif;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.relative { position: relative; }
.absolute { position: absolute; }
.inset { inset: 0; }
.clip { overflow: hidden; }
.no-pointer { pointer-events: none; }

.shell { display: flex; flex-direction: column; height: 100%; }
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 56px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  z-index: 3;
}
.brand-block {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand-mark {
  width: 16px;
  height: 16px;
  flex: none;
  display: block;
}
.brand {
  font-size: 13px;
  letter-spacing: 0.08em;
  white-space: nowrap;
}
.tagline {
  margin: 0;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.recipe-foot button,
.recipe-head button {
  width: auto;
  margin: 0;
}

button, select {
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
}
button.ghost { color: var(--text); }
button.ghost:hover,
select:hover { background: #1a1a1a; }
button.primary {
  background: #f3f3f3;
  color: #111;
  border-color: #f3f3f3;
}
button.primary:hover { background: #e5e5e5; }

.workspace { flex: 1; min-height: 0; display: flex; }
.stage-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  padding: 24px 24px 72px;
  background-color: #000;
  background-image: radial-gradient(#1c1c1c 0.7px, transparent 0.8px);
  background-size: 16px 16px;
}
.stage {
  flex: 1;
  width: 100%;
  min-height: 0;
  background: var(--mass);
  border: 1px solid var(--line);
  box-shadow: inset 0 0 0 1px #00000080;
}
.stage canvas, .preview canvas { width: 100%; height: 100%; display: block; }
#gray { image-rendering: pixelated; }

.transport {
  position: absolute;
  left: 50%;
  bottom: 16px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  width: min(600px, calc(100% - 40px));
  padding: 8px 10px;
  transform: translateX(-50%);
  background: #141414d9;
  border: 1px solid var(--line);
  backdrop-filter: blur(12px);
  overflow: visible;
}
.icon-btn {
  position: relative;
  width: 32px;
  height: 32px;
  padding: 0;
  display: grid;
  place-items: center;
  flex: none;
  color: var(--text);
  background: transparent;
  border-color: var(--line);
}
.icon-btn svg {
  width: 16px;
  height: 16px;
}
.icon-btn:hover { background: #1a1a1a; }
.icon-btn.primary {
  background: #f3f3f3;
  color: #111;
  border-color: #f3f3f3;
}
.icon-btn.primary:hover { background: #e5e5e5; }
.icon-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  padding: 4px 8px;
  background: #111;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%);
}
.icon-btn:hover::after,
.icon-btn:focus-visible::after { opacity: 1; }
#pause .icon-play { display: none; }
#pause.is-paused .icon-pause { display: none; }
#pause.is-paused .icon-play { display: block; }
.transport-split {
  width: 1px;
  height: 18px;
  margin: 0 4px;
  background: var(--line);
  flex: none;
}
.transport #frame { width: auto; flex: 1; min-width: 72px; margin: 0; }
#frame-value {
  min-width: 3.5em;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.inspector {
  width: 320px;
  overflow: auto;
  background: var(--panel);
  border-left: 1px solid var(--line);
}
.group { padding: 18px 16px 16px; border-bottom: 1px solid var(--line); }
h2 {
  margin: 0 0 14px;
  color: var(--muted);
  font: 10px/1 Inter, Geist, "Segoe UI", system-ui, sans-serif;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.field { display: block; margin: 0 0 14px; }
.field:last-child { margin-bottom: 0; }
.field-label {
  display: flex;
  justify-content: space-between;
  margin: 0 0 8px;
  color: var(--text);
  font-size: 11px;
}
.sources {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}
.inspector select { width: 100%; background: #0a0a0a; }

.color-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  background: #0a0a0a;
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
}
input[type="color"] {
  width: 22px;
  height: 22px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 3px;
}
#color-hex {
  color: var(--muted);
  font: 11px/1 ui-monospace, Consolas, monospace;
  letter-spacing: 0.04em;
}

.mass-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 3px;
  background: #0a0a0a;
  border: 1px solid var(--line);
}
.mass-toggle button {
  margin: 0;
  border: 0;
  background: transparent;
  border-radius: 3px;
}
.mass-toggle button.is-on {
  background: #ececec;
  color: #111;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  margin: 0;
  background: transparent;
  border: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: #3f3f46;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  margin-top: -4px;
  background: #f3f3f3;
  border: 0;
  border-radius: 50%;
}
input[type="range"]::-moz-range-track {
  height: 2px;
  background: #3f3f46;
  border: 0;
}
input[type="range"]::-moz-range-thumb {
  width: 10px;
  height: 10px;
  background: #f3f3f3;
  border: 0;
  border-radius: 50%;
}

.preview {
  aspect-ratio: 1;
  width: min(100%, 220px);
  max-height: 220px;
  margin: 0 auto;
  background: repeating-conic-gradient(#2a2a2a 0% 25%, #171717 0% 50%) 0 0 / 12px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.source-meta {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}
.source-meta b {
  color: var(--text);
  font-weight: 600;
}

.recipe-panel {
  width: min(920px, calc(100vw - 24px));
  height: min(82vh, 860px);
  max-height: calc(100vh - 24px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--bg);
  color: inherit;
  color-scheme: dark;
}
.recipe-panel[open] {
  display: flex;
  flex-direction: column;
}
.recipe-panel::backdrop { background: #000000c4; }
.recipe-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.recipe-head h2 { margin: 0 0 4px; }
#recipe-file-label {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}
.recipe-head button { margin-left: auto; }
#recipe-json {
  flex: 1;
  min-height: 0;
  width: 100%;
  margin: 0;
  padding: 16px;
  border: 0;
  border-radius: 0;
  background: #111;
  color: var(--text);
  font: 12px/1.45 ui-monospace, Consolas, monospace;
  tab-size: 2;
  resize: none;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow: auto;
}
.recipe-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}
#recipe-note {
  margin: 0 auto 0 0;
  min-width: 0;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 800px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 12px; }
  .workspace { flex-direction: column; overflow: auto; }
  .stage-wrap { height: 58vh; flex: none; padding: 12px 12px 64px; }
  .inspector { width: auto; border-left: 0; border-top: 1px solid var(--line); }
  .recipe-panel { height: min(90vh, 860px); }
  .transport { width: calc(100% - 24px); }
}
