:root {
  --bg: #0e1424;
  --panel: rgba(14, 20, 36, 0.82);
  --text: #eef1f7;
  --muted: #9aa4ba;
  --accent: #ff3b30;
  --warn: #ffcc00;
  --button: #26304a;
  color-scheme: dark;
}

[hidden] { display: none !important; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

button {
  font: inherit;
  color: var(--text);
  background: var(--button);
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  min-height: 44px;
}

button[aria-pressed="true"] { background: #3d4a6e; }

.primary {
  background: var(--accent);
  font-weight: 600;
  width: 100%;
  max-width: 360px;
  padding: 16px;
}

/* Ekran startowy */
.start {
  min-height: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: calc(32px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
}

.logo { border-radius: 20px; }
h1 { margin: 4px 0 0; font-size: 28px; }
.lead { margin: 0; color: var(--muted); }

.steps {
  text-align: left;
  margin: 8px 0;
  padding-left: 22px;
  display: grid;
  gap: 6px;
}

.error { color: var(--accent); min-height: 1.45em; margin: 0; }
.note, .build { color: var(--muted); font-size: 14px; margin: 0; }

/* Skaner */
.scanner { position: fixed; inset: 0; overflow: hidden; background: #000; }

#video, #overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#video { object-fit: cover; }
#overlay { pointer-events: none; }

.banner {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--panel);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  text-align: center;
  font-size: 15px;
}

.banner.alert { background: rgba(160, 20, 20, 0.85); }

.bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 12px calc(12px + env(safe-area-inset-bottom));
  display: grid;
  gap: 10px;
}

.panel {
  max-height: 45vh;
  overflow-y: auto;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--panel);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  display: grid;
  gap: 12px;
  font-size: 14px;
}

.panel label { display: grid; gap: 4px; }
.panel output { color: var(--warn); font-variant-numeric: tabular-nums; }
.panel input[type="range"] { width: 100%; }
.panel p { margin: 0; color: var(--muted); }

#diagText {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font: 12px/1.4 ui-monospace, Menlo, monospace;
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.controls button { background: var(--panel); }
