:root {
  --bg: #12140e;
  --panel: #1a1e14;
  --panel-2: #22281a;
  --ink: #f4f0e4;
  --muted: #a8a28f;
  --line: #343b2c;
  --brass: #e4a33a;
  --brass-ink: #24180a;
  --green: #c6ef9a;
  --coral: #e36d4e;
  --ground: #3c4432;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  --sans: "Outfit", "Segoe UI Variable", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", "Cascadia Mono", Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(900px 420px at 0% -10%, rgba(228, 163, 58, 0.08), transparent 55%),
    radial-gradient(800px 480px at 100% 100%, rgba(47, 143, 123, 0.07), transparent 50%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
}

button, input, select { font: inherit; color: inherit; }

button { cursor: pointer; }

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

.app {
  height: 100dvh;
  display: grid;
  grid-template-columns: 332px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
}

header {
  grid-column: 1 / -1;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.brand svg { flex: none; color: var(--ink); }

h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.brand p {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.copyright {
  font-size: 12px;
}

.copyright a {
  color: inherit;
  text-decoration: none;
}

.copyright a:hover { color: var(--ink); }

.header-meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }

aside {
  grid-column: 1;
  grid-row: 2 / span 2;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: rgba(26, 30, 20, 0.92);
  border-right: 1px solid var(--line);
}

.aside-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px 12px 8px;
  scrollbar-color: #3d4434 transparent;
}

.section-label {
  margin: 12px 4px 6px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.algo-list { display: flex; flex-direction: column; gap: 2px; }

.algo {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 8px;
  padding: 8px 10px 8px 12px;
}

.algo:hover { background: rgba(255, 248, 230, 0.04); }

.algo[aria-pressed="true"] {
  background: #262c1c;
  box-shadow: inset 3px 0 0 var(--brass);
}

.algo-tag {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  white-space: nowrap;
}

.params { display: flex; flex-direction: column; gap: 10px; padding: 0 4px; }

.field { display: flex; flex-direction: column; gap: 6px; }

.field-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.field-value { font-family: var(--mono); color: var(--ink); font-size: 12px; }

select, .seed-label input {
  background: #12150e;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 8px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--brass);
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 14px;
}

.check input { accent-color: var(--brass); }

.blurb {
  margin: 4px 4px 8px;
  color: #ddd6c4;
  font-size: 13.5px;
}

.compare { margin: 4px 0 8px; }

.compare table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.compare th, .compare td {
  text-align: left;
  padding: 6px 6px;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

.compare th {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.compare td.num, .compare th.num { text-align: right; }

.compare tr.current td { color: var(--brass); }

.compare .tag {
  font-family: var(--mono);
  font-size: 11px;
}

.compare .tag.path { color: var(--green); }
.compare .tag.stuck { color: #e6b15a; }
.compare .tag.fail { color: #e7a090; }

.compare caption {
  caption-side: bottom;
  text-align: left;
  color: var(--muted);
  font-size: 11px;
  padding-top: 6px;
}

.transport {
  border-top: 1px solid var(--line);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #161b11;
}

.row { display: flex; gap: 8px; }

.row button, .ghost, .tool, .brush-btn, #reseed {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

.row button { flex: 1; }

.row button:hover, .ghost:hover, .tool:hover, .brush-btn:hover, #reseed:hover {
  background: rgba(255, 248, 230, 0.05);
}

.run {
  height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--brass);
  color: var(--brass-ink);
  font-weight: 600;
}

.run:hover { background: #f0b44e; }

.run:disabled, button:disabled { opacity: 0.45; cursor: default; }

.ghost { width: 100%; }

.keys {
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

main {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 12px 14px 0;
  gap: 8px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.tools, .brush { display: flex; gap: 4px; }

.tool[aria-pressed="true"], .brush-btn[aria-pressed="true"] {
  background: #262c1c;
  border-color: #6d6244;
  box-shadow: inset 0 -2px 0 var(--brass);
}

.toolbar label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.seed-label input {
  width: 76px;
  padding: 6px 8px;
}

.hint {
  margin: 0;
  min-height: 1.2em;
  color: var(--muted);
  font-size: 13px;
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 244, 220, 0.025), transparent 80px),
    var(--ground);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

canvas {
  display: block;
  touch-action: none;
  cursor: crosshair;
  background: #3c4432;
}

canvas[data-tool="start"], canvas[data-tool="goal"] { cursor: grab; }
canvas[data-tool="erase"] { cursor: cell; }

.tip {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  width: max-content;
  max-width: 340px;
  padding: 8px 10px 9px;
  background: rgba(18, 20, 14, 0.96);
  border: 1px solid var(--line);
  border-left: 3px solid #ffb703;
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: 12.5px;
  line-height: 1.35;
}

.tip-title {
  margin-bottom: 4px;
  font-family: var(--mono);
  font-size: 12px;
  color: #ffb703;
}

.tip-row { display: flex; gap: 8px; align-items: baseline; }

.tip-k {
  width: 1.1em;
  font-family: var(--mono);
  color: var(--brass);
}

.tip-v {
  width: 4.4em;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.tip-note { color: var(--muted); }

.tip-calc {
  margin: 2px 0 6px;
  color: #ddd6c4;
  font-size: 12px;
  line-height: 1.4;
}

.tip-why {
  margin: 2px 0 0;
  color: #f4f0e4;
}

.legend {
  position: absolute;
  left: 10px;
  bottom: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  max-width: calc(100% - 20px);
  padding: 6px 8px;
  background: rgba(14, 16, 10, 0.82);
  border: 1px solid rgba(244, 240, 228, 0.08);
  border-radius: 8px;
  pointer-events: none;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #ddd6c4;
  font-family: var(--mono);
  font-size: 11px;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.status {
  grid-column: 2;
  grid-row: 3;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 16px 12px;
}

.pill {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}

.pill.running { background: var(--brass); color: var(--brass-ink); border-color: transparent; }
.pill.success { background: var(--green); color: #17210f; border-color: transparent; }
.pill.fail { background: #e7a090; color: #2a1210; border-color: transparent; }
.pill.stuck { background: #e6b15a; color: #2a1c08; border-color: transparent; }

.status-copy { min-width: 0; }

.status-text {
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.caption {
  margin: 2px 0 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats {
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.step-card {
  grid-column: 1 / -1;
  margin: 0;
  padding: 8px 12px 10px;
  background: #1c2216;
  border: 1px solid var(--line);
  border-left: 3px solid var(--brass);
  border-radius: 10px;
  max-height: 11.5rem;
  overflow: auto;
}

.step-card .section-label { margin: 0 0 6px; }

.step-mark {
  margin-left: 8px;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--brass);
}

.step-card p {
  margin: 0 0 6px;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--ink);
}

.step-card p:last-child { margin: 0; }

@media (max-width: 980px) {
  .app { display: block; height: auto; min-height: 100dvh; }
  aside { border-right: 0; border-bottom: 1px solid var(--line); }
  .aside-scroll { max-height: none; overflow: visible; }
  main { height: 78vh; min-height: 520px; }
  .status { grid-template-columns: 1fr; }
  .stats { text-align: left; }
}
