/* The gene creator is a tool, not a wiki page: it owns the whole window and
   never scrolls the body. It borrows the wiki's palette but not its layout. */

:root {
  --bg: #0b1120;
  --panel: #151d2c;
  --panel-2: #101725;
  --line: #26324a;
  --line-soft: #1c2536;
  --text: #e8eef8;
  --muted: #93a3bd;
  --accent: #4f9dff;
  --accent-dim: #2f6dbd;
  --good: #35c48a;
  --warn: #e8b13a;
  --bad: #ef5f5f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
}

/* ---- top bar ---- */

.topbar {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.topbar h1 { font-size: 1.05rem; margin: 0; letter-spacing: 0.01em; }
.topbar .tagline { margin: 0; color: var(--muted); font-size: 0.85rem; }
.topbar .back { color: var(--accent); text-decoration: none; font-size: 0.85rem; }
.topbar .back:hover { text-decoration: underline; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ---- workspace ---- */

.workspace {
  display: grid;
  grid-template-columns: 320px minmax(360px, 1fr) 400px;
  height: calc(100% - 52px);
}

.column { overflow-y: auto; padding: 14px 16px; }
.column.left { border-right: 1px solid var(--line); background: var(--panel-2); }
.column.right { border-left: 1px solid var(--line); background: var(--panel-2); }
.column.centre { display: flex; flex-direction: column; padding: 12px; overflow: hidden; }

h2 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 4px 0 10px;
}

h3 {
  font-size: 0.8rem;
  margin: 18px 0 6px;
  color: var(--text);
  border-top: 1px solid var(--line-soft);
  padding-top: 12px;
}

h4 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 14px 0 6px; }

.hint { color: var(--muted); font-size: 0.76rem; line-height: 1.4; display: block; }
.mini { color: var(--muted); font-size: 0.7rem; }
.warn { color: var(--warn); font-size: 0.75rem; }

/* ---- controls ---- */

input, select, textarea, button { font: inherit; color: var(--text); }

input[type="text"], input[type="number"], select, textarea {
  background: #0c1320;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 6px;
  min-width: 0;
}

input[type="text"]:focus, input[type="number"]:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-dim);
}

input.narrow { width: 62px; }
input[type="range"] { flex: 1; min-width: 60px; accent-color: var(--accent); }
input[type="color"] { width: 46px; height: 26px; padding: 1px; background: #0c1320; border: 1px solid var(--line); border-radius: 4px; }

.field { display: block; margin-bottom: 9px; }
.field-label { display: block; font-size: 0.74rem; color: var(--muted); margin-bottom: 3px; }
.field > input, .field > select { width: 100%; }
.field .hint { margin-top: 3px; }

.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.row > input[type="text"] { flex: 1; }

/* A ramp stop or a palette entry: the well and its delete button, kept together
   so a wrapped row breaks between stops rather than through one. */
.swatch-cell { display: inline-flex; align-items: center; gap: 2px; }

.btn {
  background: var(--accent-dim);
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 5px 11px;
  cursor: pointer;
  font-weight: 600;
}
.btn:hover { background: var(--accent); }
.btn.small { padding: 3px 8px; font-size: 0.78rem; font-weight: 500; }
.btn.tiny { padding: 1px 7px; font-size: 0.8rem; background: #23304a; }
.btn.tiny:hover { background: #31456b; }
/* The PATH canvas's full / minimal tabs: which shape the handles are on. */
.btn.tiny.on { background: var(--accent-dim); color: #fff; }
.btn.tiny:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.danger { background: #5d2530; }
.btn.danger:hover { background: var(--bad); }

.tag {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1px 7px;
}

/* ---- value editor ---- */

.value-editor {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
  background: #0c1320;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  padding: 5px 6px;
}
.value-editor > select { font-size: 0.75rem; padding: 2px 4px; }

/* ---- parts picker ---- */

.parts-summary {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 4px;
  word-break: break-word;
}

.parts-grid { display: flex; flex-wrap: wrap; gap: 3px; }

.chip {
  background: #0c1320;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 3px;
  padding: 2px 6px;
  font-size: 0.68rem;
  cursor: pointer;
}
.chip.group { border-style: dashed; }
.chip:hover { border-color: var(--accent-dim); }
.chip.on { background: var(--accent-dim); color: #fff; border-color: var(--accent); }

/* ---- knobs ---- */

.knob {
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  padding: 8px;
  margin-bottom: 7px;
  background: var(--panel);
}

/* ---- layers ---- */

.layer {
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 8px;
  background: var(--panel);
}
.layer.open { border-color: var(--accent-dim); }

.layer-head { display: flex; align-items: center; gap: 5px; padding: 6px 8px; }

.layer-title {
  flex: 1;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.84rem;
  padding: 0;
}

.cover-toggle {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 0.68rem;
  color: var(--muted);
  cursor: pointer;
}

.layer-body { padding: 4px 10px 12px; border-top: 1px solid var(--line-soft); }

.mask {
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--accent-dim);
  border-radius: 4px;
  padding: 8px;
  margin-bottom: 8px;
  background: var(--panel-2);
}
.mask-head { margin-bottom: 2px; }
.mask-head select { font-size: 0.78rem; }

/* ---- centre column ---- */

.controls { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.controls .field { margin-bottom: 0; min-width: 130px; }

.viewport {
  flex: 1;
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  background: #11161f;
}
.viewport canvas { display: block; width: 100%; height: 100%; cursor: crosshair; }

.no-3d { padding: 20px; color: var(--muted); font-size: 0.82rem; }

.under-viewport { display: flex; gap: 14px; margin-top: 10px; align-items: flex-start; }

.sheet-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; }

#sheet-canvas {
  width: 192px;
  height: 192px;
  image-rendering: pixelated;
  background: #0c1320;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.caption { font-size: 0.68rem; color: var(--muted); }

.readouts { flex: 1; min-width: 0; }
.readout-block { margin-top: 8px; }
.readout-block h4 { margin: 0 0 3px; }
.pick div { font-size: 0.76rem; color: var(--text); }
.pick .hint { color: var(--muted); }

.drawn { display: flex; gap: 8px; font-size: 0.76rem; align-items: center; }
.drawn-name { color: var(--muted); min-width: 96px; }
.drawn-value { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* The dial slider: pins the knob a gene nominated as "how much of itself this
   horse is showing", so a marking can be looked at at its least and its most
   without rolling horses until one lands near an end. */
.dial { gap: 3px; margin-top: 6px; font-size: 0.76rem; }
.dial .row { align-items: center; gap: 6px; }
.dial-slider { flex: 1; min-width: 90px; accent-color: var(--accent); }

.status { font-size: 0.75rem; color: var(--muted); }
.status.warnish { color: var(--warn); }
.status.bad { color: var(--bad); }
.status.ok { color: var(--good); }

/* The parity self-check: quiet one line when the port agrees with the game,
   and impossible to miss when it does not - a preview that lies is the one
   failure this tool must never look calm about. */
#parity-status.bad {
  border: 1px solid var(--bad);
  border-radius: 4px;
  padding: 6px 8px;
  margin-top: 4px;
}
#parity-status.bad strong { display: block; margin-bottom: 4px; }

/* A vertical list of text rows - the carrot's flavour ingredients. */
.stack { display: flex; flex-direction: column; gap: 4px; width: 100%; }
.stack .row { margin-bottom: 0; }

/* The blurb field wants room to be a paragraph. */
.field textarea {
  width: 100%;
  resize: vertical;
  font: inherit;
  font-size: 0.8rem;
}

/* ---- export ---- */

#json-output {
  width: 100%;
  height: 240px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  resize: vertical;
  white-space: pre;
  color: #9fd4ff;
}

#problems { margin-bottom: 8px; }
.problem { color: var(--bad); font-size: 0.76rem; margin-bottom: 3px; }
.ok { color: var(--good); font-size: 0.76rem; }

#export-filename { color: var(--muted); font-size: 0.74rem; }

.install { margin-top: 12px; font-size: 0.78rem; color: var(--muted); }
.install summary { cursor: pointer; color: var(--accent); }
.install p { margin: 8px 0; }
.install code { color: var(--text); background: #0c1320; padding: 1px 4px; border-radius: 3px; }

/* Narrow windows: stack the columns rather than crushing them. */
@media (max-width: 1100px) {
  html, body { overflow: auto; }
  .workspace { grid-template-columns: 1fr; height: auto; }
  .column { overflow: visible; border: none; border-bottom: 1px solid var(--line); }
  .column.centre { height: 70vh; }
}

/* An effect's negate toggle, sitting beside its flag picker. */
.inline { display: inline-flex; align-items: center; gap: 4px; font-size: 0.76rem; }

/* A condition the simple form cannot edit: shown as-is, never rewritten. */
.frozen {
  display: block;
  background: rgba(0, 0, 0, 0.25);
  padding: 4px 6px;
  border-radius: 3px;
  font-size: 0.72rem;
  word-break: break-all;
  margin-bottom: 3px;
}

/* ---- the PATH drawing canvas ---- */

.path-editor { gap: 6px; }

.path-canvas {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #0d1422;
  cursor: crosshair;
  touch-action: none;
}
.path-canvas:focus { outline: none; border-color: var(--accent-dim); }

.path-bar { gap: 4px; }

.path-note { line-height: 1.35; }

.path-numbers summary { cursor: pointer; color: var(--muted); font-size: 0.72rem; }
.path-numbers textarea { margin-top: 4px; }
