:root {
  --primary: #8a2be2;
  --primary-dark: #6a1b9a;
  --bg: #1a0033;
  --card: #2d0052;
  --input: #4d0099;
  --text: #ffffff;
  --muted: #c8b6e2;
  --ok: #4caf50;
  --bad: #f44336;
  --warn: #ff9800;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

header {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--primary);
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

h1 { margin: 0; font-size: 1.25rem; }
h2 { margin: 0 0 12px; font-size: 1.1rem; }

.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .8rem;
  background: rgba(0, 0, 0, .25);
}
.pill.ok { background: var(--ok); }
.pill.bad { background: var(--bad); }
.pill.warn { background: var(--warn); }

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.card {
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.card.quick { grid-column: 1 / -1; border: 2px solid var(--primary); }

label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
output { color: var(--text); font-weight: bold; }

input, select, button {
  font: inherit;
  color: var(--text);
  border: none;
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
}
input, select { background: var(--input); width: 100%; }
input[type="checkbox"] { width: 22px; min-height: 22px; accent-color: var(--primary); }
input[type="range"] { padding: 0; accent-color: var(--primary); background: transparent; }

button {
  background: var(--primary);
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}
button:hover { filter: brightness(1.15); }
button.secondary { background: var(--input); }
button.active { outline: 2px solid #fff; }

.row { display: flex; gap: 8px; }
.row > input, .row > label { flex: 1; min-width: 0; }

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

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches button {
  width: 40px;
  min-height: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  border: 3px solid transparent;
}
.swatches button.active { border-color: #fff; outline: none; }

.hint { margin: 0; color: var(--muted); font-size: .85rem; }

pre#log {
  margin: 0;
  background: #120022;
  border-radius: 10px;
  padding: 10px;
  max-height: 220px;
  overflow: auto;
  font-size: .8rem;
  white-space: pre-wrap;
  word-break: break-word;
}

dialog {
  border: none;
  border-radius: 14px;
  background: var(--card);
  color: var(--text);
  width: min(420px, calc(100% - 32px));
  padding: 20px;
}
dialog::backdrop { background: rgba(0, 0, 0, .7); }
dialog form { display: flex; flex-direction: column; gap: 12px; }
dialog h2 { margin: 0; }
.error { color: var(--bad); margin: 0; min-height: 1.2em; }

code { background: var(--input); padding: 1px 5px; border-radius: 4px; }

@media (max-width: 480px) {
  main { padding: 12px; gap: 12px; }
  .row { flex-wrap: wrap; }
  .row > button { flex: 1; }
}
