:root {
  --bg: #0b1120;
  --bg-2: #131c31;
  --card: #16203a;
  --line: #24314f;
  --fg: #eef2ff;
  --muted: #93a3c4;
  --accent: #7c5cff;
  --accent-2: #a78bfa;
  --wa: #25d366;
  --err: #ff6b6b;
  --ok: #4ade80;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(1000px 600px at 15% -10%, #1e2a4d 0%, transparent 60%),
    radial-gradient(900px 500px at 90% 0%, #2a1e4d 0%, transparent 55%),
    var(--bg);
  color: var(--fg);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.wrap {
  max-width: 520px;
  margin: 0 auto;
  padding: 28px 18px 40px;
}

.head { text-align: center; margin-bottom: 22px; }
.head h1 { margin: 0 0 4px; font-size: 30px; letter-spacing: -0.02em; }
.muted { color: var(--muted); margin: 0; }
.muted strong { color: var(--accent-2); }

.card {
  background: linear-gradient(180deg, var(--card), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}

.step-label {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: 14px;
}

.num {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  letter-spacing: 0;
}

/* --- nagrywanie --- */
.recorder { display: flex; flex-direction: column; align-items: center; gap: 12px; }

.mic {
  position: relative;
  width: 104px;
  height: 104px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(160deg, var(--accent), #5b21b6);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform .12s ease, box-shadow .2s ease, background .2s ease;
  box-shadow: 0 10px 26px rgba(124, 92, 255, .35);
}
.mic:active { transform: scale(.96); }
.mic svg { width: 40px; height: 40px; fill: currentColor; }

.mic .ico-stop {
  display: none;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: #fff;
}

.mic.recording {
  background: linear-gradient(160deg, #ef4444, #b91c1c);
  box-shadow: 0 0 0 0 rgba(239, 68, 68, .55);
  animation: pulse 1.6s infinite;
}
.mic.recording .ico-mic { display: none; }
.mic.recording .ico-stop { display: block; }

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(239, 68, 68, .5); }
  70%  { box-shadow: 0 0 0 22px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.meter {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  opacity: .25;
  transition: opacity .2s;
}
.meter.on { opacity: 1; }
.meter span {
  width: 4px;
  height: 5px;
  border-radius: 3px;
  background: var(--accent-2);
  transition: height .08s linear;
}

.timer { font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 600; }
.hint { color: var(--muted); font-size: 14px; }

.preview { margin-top: 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; }

audio {
  width: 100%;
  height: 40px;
  border-radius: 10px;
}

/* --- przyciski --- */
button, .link { font: inherit; }

.primary, .wa {
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 15px 18px;
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform .12s ease, filter .2s ease;
}
.primary { background: linear-gradient(120deg, var(--accent), #4f46e5); }
.wa      { background: linear-gradient(120deg, var(--wa), #12a150); margin-top: 6px; }
.primary:active, .wa:active { transform: scale(.985); }

.primary:disabled {
  background: #263255;
  color: #6b7ba3;
  cursor: not-allowed;
}

.primary.busy .label { opacity: .75; }
.primary .spinner { display: none; }
.primary.busy .spinner {
  display: block;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.ico-wa { width: 22px; height: 22px; fill: currentColor; }

.link {
  background: none;
  border: none;
  color: var(--accent-2);
  text-decoration: underline;
  cursor: pointer;
  padding: 6px 2px;
  font-size: 15px;
}

.secondary-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

/* Male, dyskretne guziki (Nowa, Wyloguj) */
.btn-sm {
  display: inline-block;
  padding: 6px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #16203a;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.btn-sm:hover { color: var(--fg); border-color: var(--accent); }

.wa .spinner { display: none; }
.wa.busy .spinner {
  display: block;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.wa:disabled { background: #263255; color: #6b7ba3; cursor: not-allowed; }

.field { display: block; margin: 4px 0 12px; }
.field span {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  padding: 13px 15px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0e1730;
  color: var(--fg);
  font-size: 17px;
}
.field input:focus { outline: 2px solid var(--accent); border-color: transparent; }

/* --- wybor trybu przerobki --- */
.modes { display: flex; gap: 8px; margin-bottom: 14px; }

.mode { flex: 1; min-width: 0; cursor: pointer; }
.mode input { position: absolute; opacity: 0; pointer-events: none; }

.mode-box {
  display: block;
  padding: 12px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0e1730;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.mode-box strong { display: block; font-size: 14px; font-weight: 600; }

.mode input:checked + .mode-box {
  border-color: var(--accent);
  background: #17203f;
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.mode input:focus-visible + .mode-box { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* --- rozpoznany tekst --- */
.transcript {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
  background: #0e1730;
}
.transcript summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.transcript textarea {
  width: 100%;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0b1428;
  color: var(--fg);
  font: inherit;
  font-size: 15px;
  resize: vertical;
}
.transcript textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }

/* --- wybor odbiorcy --- */
.picker { position: relative; }

.chosen {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0e1730;
}
.chosen-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chosen-text strong { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chosen-text em { font-style: normal; font-size: 12px; color: var(--muted); }

.chosen .x {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.chosen .x:hover { color: var(--fg); }

.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(150deg, var(--accent), #4f46e5);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}
.avatar.grp { background: linear-gradient(150deg, #0ea5e9, #0369a1); }

.results {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  margin: 0;
  padding: 6px;
  list-style: none;
  max-height: 290px;
  overflow-y: auto;
  background: #101a33;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .5);
}
.results li {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: 9px;
  cursor: pointer;
}
.results li:hover, .results li:focus { background: #1b2848; }
.results .txt { min-width: 0; display: flex; flex-direction: column; }
.results .txt strong { font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results .txt em { font-style: normal; font-size: 12px; color: var(--muted); }
.results .empty { color: var(--muted); font-size: 14px; cursor: default; }
.results .empty:hover { background: none; }

/* --- zastrzezenie na samej gorze --- */
.disclaimer {
  margin: 0 0 14px;
  padding: 10px 14px;
  border: 1px solid rgba(251, 191, 36, .35);
  border-radius: 12px;
  background: rgba(251, 191, 36, .08);
  color: #fbbf24;
  font-size: 12.5px;
  line-height: 1.45;
  text-align: center;
}

/* --- pasek stanu WhatsAppa (zawsze widoczny, nad krokami) --- */
.wabar {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px 9px 14px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-2);
  font-size: 13.5px;
}
.wabar-text { flex: 1; min-width: 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.wabar .dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
}
.wabar.ok   .dot { background: var(--ok);  box-shadow: 0 0 0 3px rgba(74, 222, 128, .18); }
.wabar.warn .dot { background: #fbbf24; box-shadow: 0 0 0 3px rgba(251, 191, 36, .18); animation: blink 2s infinite; }
.wabar.ok   .wabar-text { color: var(--ok); }

@keyframes blink { 50% { opacity: .35; } }

.wabar-btn {
  flex: none;
  padding: 6px 13px;
  border-radius: 999px;
  background: var(--wa);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.wabar.ok .wabar-btn { background: #263255; color: var(--muted); font-weight: 500; }

.status { min-height: 20px; margin: 10px 0 0; font-size: 14px; color: var(--muted); text-align: center; }
.status.err { color: var(--err); }
.status.ok  { color: var(--ok); }

.meta { color: var(--muted); font-size: 13px; margin: 8px 0 12px; text-align: center; }

.hidden { display: none !important; }

.foot {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px 4px;
}

/* --- brama PIN --- */
body.gate { display: grid; place-items: center; min-height: 100vh; }

.gate-box {
  background: linear-gradient(180deg, var(--card), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 30px 26px;
  width: min(360px, 90vw);
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
}
.gate-icon { font-size: 40px; }
.gate-box h1 { margin: 8px 0 2px; font-size: 24px; }
.gate-box p { margin-bottom: 18px; font-size: 14px; }

.gate-box input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0e1730;
  color: var(--fg);
  font-size: 20px;
  text-align: center;
  letter-spacing: .3em;
  margin-bottom: 12px;
}
.gate-box input:focus { outline: 2px solid var(--accent); border-color: transparent; }

.gate-box button {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(120deg, var(--accent), #4f46e5);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
}

.err { color: var(--err); font-size: 14px; margin: 0 0 10px; }

/* --- strona parowania QR --- */
.qr-card { text-align: center; }

.qr-slot {
  display: grid;
  place-items: center;
  min-height: 300px;
  background: #fff;
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 6px;
}
.qr-slot img { width: 100%; max-width: 300px; height: auto; display: block; }

.qr-ok { font-size: 90px; color: var(--wa); line-height: 1; }

.spinner.big {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(0, 0, 0, .12);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}

.small { font-size: 13px; text-align: center; margin-top: 14px; }
