:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #15171c;
  --muted: #5d6470;
  --border: #d5d9e0;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --rec: #dc2626;
  --ok: #16a34a;
  --error: #b91c1c;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --card: #1c1f26;
    --text: #eef0f4;
    --muted: #9aa2b1;
    --border: #2f3440;
    --accent: #3b82f6;
    --rec: #ef4444;
    --ok: #22c55e;
    --error: #f87171;
  }
}

* { box-sizing: border-box; }

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

main {
  max-width: 480px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 16px);
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}
.screen[hidden] { display: none; }

#screen-pin, #screen-done { justify-content: center; text-align: center; }
#screen-record { justify-content: flex-end; }

h1, h2 { margin: 0; }
.hint { color: var(--muted); margin: 0; text-align: center; }
.msg { min-height: 1.4em; margin: 0; text-align: center; color: var(--error); }
.msg.ok { color: var(--ok); }

/* Pola */
input, select, textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  min-height: 52px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
#pin-input { font-size: 32px; text-align: center; letter-spacing: 12px; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 15px; color: var(--muted); flex: 1; }
label.check { flex-direction: row; align-items: center; gap: 12px; font-size: 18px; color: var(--text); }
label.check input { width: 26px; min-height: 26px; height: 26px; }
label.time { flex: 0 0 120px; }
#preview-form { display: flex; flex-direction: column; gap: 14px; }

/* Przyciski */
.row { display: flex; gap: 12px; }
.btn {
  flex: 1;
  min-height: 56px;
  font: inherit;
  font-weight: 600;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn:disabled { opacity: .5; }
#pin-form { display: flex; flex-direction: column; gap: 16px; }

/* Duży przycisk nagrywania */
.rec-btn {
  align-self: center;
  width: min(68vw, 260px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font: 600 24px/1 inherit;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  cursor: pointer;
  margin: auto 0 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  -webkit-tap-highlight-color: transparent;
}
.rec-icon { width: 34px; height: 34px; border-radius: 50%; background: #fff; }
.rec-btn.recording { background: var(--rec); animation: pulse 1.4s ease-in-out infinite; }
.rec-btn.recording .rec-icon { border-radius: 6px; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, .5); }
  50% { box-shadow: 0 0 0 22px rgba(220, 38, 38, 0); }
}

/* Wyniki i historia */
.results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.results li { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.results li.fail { border-color: var(--error); color: var(--error); }
.results a { color: var(--accent); text-decoration: none; display: block; margin-top: 4px; font-size: 15px; }
.results .when { color: var(--muted); font-size: 13px; display: block; }
.queue { margin: 0; text-align: center; color: var(--muted); font-size: 15px; }
.history summary { color: var(--muted); cursor: pointer; padding: 8px 0; }

/* Zapisano */
.done-icon {
  width: 120px; height: 120px; margin: 0 auto;
  border-radius: 50%;
  background: var(--ok); color: #fff;
  font-size: 64px; line-height: 120px;
}

/* Czekanie */
.busy {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .45);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #fff; gap: 16px; z-index: 10;
}
.busy[hidden] { display: none; }
.spinner {
  width: 48px; height: 48px;
  border: 5px solid rgba(255, 255, 255, .3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Strona z dokumentem (polityka prywatności) */
.doc { line-height: 1.6; }
.doc h1 { margin-bottom: 16px; }
.doc h2 { font-size: 20px; margin: 24px 0 8px; }
