/* Dunkles Labor-/Terminal-Design. Keine externen Dateien, keine Web-Fonts. */

:root {
  color-scheme: dark;
  --bg: #05070a;
  --panel: #0b1016;
  --panel-2: #10171f;
  --line: #1d2a36;
  --text: #c9d7e3;
  --muted: #6c8193;
  --accent: #7ee787;
  --focus: #79c0ff;
  --warn: #f2cc60;
  --radius: 6px;
  --gutter: 16px;
  --touch: 44px;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, Menlo, Consolas, "Liberation Mono", "DejaVu Sans Mono", monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.4;
}

main {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--gutter);
}

h1,
h2 {
  margin: 0;
  font-weight: 600;
}

h1 {
  font-size: 1.4rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ---------- Kopfzeile ---------- */

.app-header {
  display: grid;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.global-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.defaults {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 18px;
  margin: 0;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.defaults legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ---------- Felder und Buttons ---------- */

.field {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.field-range {
  min-width: 220px;
}

.field-range input[type="range"] {
  flex: 1 1 120px;
  min-height: var(--touch);
  accent-color: var(--accent);
}

output {
  min-width: 4.5em;
  color: var(--text);
}

input[type="number"] {
  width: 6.5em;
  min-height: var(--touch);
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

.btn {
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  touch-action: manipulation;
}

.btn:hover:not(:disabled) {
  border-color: var(--muted);
}

.btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn-primary {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-icon {
  padding: 4px 12px;
  line-height: 1;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ---------- Statistik und Hinweise ---------- */

.stats {
  margin: 16px 0 8px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin: 0;
}

.stats-grid > div,
.tile-stats > div {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.stats-grid dt,
.tile-stats dt {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stats-grid dd,
.tile-stats dd {
  margin: 2px 0 0;
  font-size: 1.25rem;
  color: var(--text);
}

.note {
  margin: 10px 0 0;
  padding: 8px 12px;
  border: 1px solid var(--warn);
  border-radius: var(--radius);
  color: var(--warn);
  font-size: 0.9rem;
}

.note[hidden] {
  display: none;
}

.hint {
  min-height: 1.4em;
  margin: 8px 0;
  color: var(--warn);
  font-size: 0.9rem;
}

/* ---------- Kachelraster ---------- */

.boards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  min-width: 0;
}

.tile.is-running {
  border-color: var(--accent);
  box-shadow: 0 0 14px -4px var(--accent);
}

.tile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tile-title {
  font-size: 1rem;
  color: var(--accent);
}

.tile-canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: 50vh;
  object-fit: contain;
  image-rendering: pixelated;
  background: #0a0d10;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.tile-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
}

.tile-stats dd {
  font-family: var(--font-mono);
  font-size: 1.1rem;
}

.tile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tile-actions .btn {
  flex: 1 1 auto;
}

.tile-settings {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.tile-settings summary {
  min-height: var(--touch);
  display: flex;
  align-items: center;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
}

.tile-settings-body {
  display: grid;
  gap: 10px;
  padding-top: 6px;
}

.size-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.tile-settings .field-range {
  min-width: 0;
}

.palette {
  margin: 0;
  padding: 0;
  border: 0;
}

.palette legend {
  padding: 0 0 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.palette-options {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.swatch {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--touch);
  height: var(--touch);
  cursor: pointer;
}

.swatch::before {
  content: "";
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 0 8px -2px var(--swatch);
}

.swatch input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.swatch:has(input:checked)::before {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.swatch:has(input:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 50%;
}

/* ---------- Schmale Bildschirme ---------- */

@media (max-width: 600px) {
  .boards {
    grid-template-columns: 1fr;
  }

  .field-range {
    min-width: 0;
    width: 100%;
  }

  .global-controls .btn,
  .title-row .btn {
    flex: 1 1 auto;
  }

  .defaults {
    width: 100%;
  }
}
