:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #64748b;
  --line: #d6dce8;
  --accent: #1f5fbf;
  --soft: #eef4ff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 18px 22px;
  background: #111827;
  color: white;
}

header h1 {
  margin: 0 0 4px 0;
  font-size: 22px;
}

header p {
  margin: 0;
  color: #dbe4f0;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 650;
}

main {
  display: grid;
  grid-template-columns: minmax(560px, 1fr) 430px;
  gap: 14px;
  padding: 14px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
  overflow: hidden;
}

#viewportPanel {
  min-height: 780px;
  position: relative;
}

#viewport {
  height: 780px;
  width: 100%;
}

.hint {
  position: absolute;
  left: 12px;
  bottom: 12px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--muted);
  font-size: 13px;
}

.controls {
  padding: 16px;
  overflow-y: auto;
  max-height: 780px;
}

h2 {
  font-size: 17px;
  margin: 0 0 10px 0;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 14px;
  margin: 0 0 14px 0;
  padding: 12px;
}

legend {
  padding: 0 6px;
  color: var(--muted);
  font-weight: 700;
}

label {
  display: grid;
  grid-template-columns: 86px 1fr 48px;
  align-items: center;
  gap: 8px;
  margin: 9px 0;
  font-size: 14px;
}

label.check {
  display: flex;
  align-items: center;
  gap: 8px;
}

input[type="range"] {
  width: 100%;
}

.mathBox {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--soft);
  padding: 12px;
}

#formulas {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.statusHit {
  display: inline-block;
  margin: 6px 0 8px 0;
  padding: 3px 8px;
  border-radius: 999px;
  background: #d1fae5;
}

.statusMiss {
  display: inline-block;
  margin: 6px 0 8px 0;
  padding: 3px 8px;
  border-radius: 999px;
  background: #fee2e2;
}

.tasks {
  margin: 0 14px 14px 14px;
  padding: 16px 20px;
}

.tasks ol {
  margin: 8px 0 0 20px;
  line-height: 1.55;
}

code {
  background: #e5e7eb;
  padding: 1px 5px;
  border-radius: 5px;
}

@media (max-width: 1050px) {
  main { grid-template-columns: 1fr; }
  .controls { max-height: none; }
  #viewportPanel, #viewport { min-height: 620px; height: 620px; }
}

.pixelBox {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  padding: 12px;
  margin-bottom: 14px;
}

#pixelSwatch {
  min-height: 58px;
  border: 1px solid #94a3b8;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

#pixelInfo {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}


/* --- v8 Pixel-Scan Layout Overrides --- */

main {
  display: grid;
  grid-template-columns: minmax(660px, 1fr) 520px;
  gap: 14px;
  padding: 14px;
}

#viewportPanel {
  min-height: 820px;
  position: relative;
}

#viewport {
  height: 820px;
  width: 100%;
}

.hint {
  position: absolute;
  left: 12px;
  bottom: 12px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--muted);
  font-size: 13px;
}

.controls {
  max-height: 820px;
  padding: 18px;
  overflow-y: auto;
}

h2 {
  font-size: 18px;
  margin: 0 0 10px 0;
}

#formulas {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 15px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.mathBox {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--soft);
  padding: 16px;
}

.pixelBox,
.fixedSceneBox {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  padding: 16px;
  margin-bottom: 14px;
}

.fixedSceneBox p {
  margin: 6px 0;
  color: var(--muted);
  font-size: 14px;
}

#pixelSwatch {
  min-height: 82px;
  border: 1px solid #94a3b8;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
  font-size: 22px;
}

#pixelInfo {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.statusHit {
  display: inline-block;
  margin: 6px 0 8px 0;
  padding: 3px 8px;
  border-radius: 999px;
  background: #d1fae5;
}

.statusMiss {
  display: inline-block;
  margin: 6px 0 8px 0;
  padding: 3px 8px;
  border-radius: 999px;
  background: #fee2e2;
}

.tasks {
  margin: 0 14px 14px 14px;
  padding: 16px 20px;
}

.tasks ol {
  margin: 8px 0 0 20px;
  line-height: 1.55;
}

code {
  background: #e5e7eb;
  padding: 1px 5px;
  border-radius: 5px;
}

@media (max-width: 1050px) {
  main { grid-template-columns: 1fr; }
  .controls { max-height: none; }
  #viewportPanel, #viewport { min-height: 640px; height: 640px; }
}


/* --- v9 strict backtracing status --- */
.traceStatusBox {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  padding: 16px;
  margin-bottom: 14px;
}
#traceStatus {
  display: grid;
  gap: 8px;
  font-size: 14px;
  line-height: 1.45;
}
#traceStatus div {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 8px;
  align-items: start;
  padding: 8px 10px;
  border-radius: 10px;
}
#traceStatus .ok { background: #dcfce7; color: #14532d; }
#traceStatus .warn { background: #fef9c3; color: #713f12; }
#traceStatus .fail { background: #fee2e2; color: #7f1d1d; }


/* --- v9d: Pixel-Farbe direkt unter den Parametern --- */

.pixelBoxPrimary {
  margin-top: -2px;
  margin-bottom: 18px;
  border: 2px solid #bfdbfe;
  background: #f8fbff;
}

.pixelBoxPrimary h2 {
  margin-bottom: 8px;
}

.pixelBoxPrimary #pixelSwatch {
  min-height: 92px;
  font-size: 24px;
}
