/* Asystent Targowy – wygląd w stylu iOS: duże cele dotyku, systemowa czcionka, tryb jasny i ciemny. */
:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --card-2: #f2f2f7;
  --label: #000000;
  --label-2: rgba(60, 60, 67, .62);
  --label-3: rgba(60, 60, 67, .32);
  --sep: rgba(60, 60, 67, .2);
  --tint: #007aff;
  --tint-soft: rgba(0, 122, 255, .12);
  --red: #ff3b30;
  --red-soft: rgba(255, 59, 48, .12);
  --green: #34c759;
  --green-soft: rgba(52, 199, 89, .14);
  --orange: #ff9500;
  --orange-soft: rgba(255, 149, 0, .14);
  --yellow-soft: rgba(255, 204, 0, .18);
  --bar: rgba(249, 249, 249, .82);
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 6px 24px rgba(0, 0, 0, .06);
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 58px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --card-2: #2c2c2e;
    --label: #ffffff;
    --label-2: rgba(235, 235, 245, .62);
    --label-3: rgba(235, 235, 245, .3);
    --sep: rgba(84, 84, 88, .6);
    --tint: #0a84ff;
    --tint-soft: rgba(10, 132, 255, .2);
    --red: #ff453a;
    --red-soft: rgba(255, 69, 58, .2);
    --green: #30d158;
    --green-soft: rgba(48, 209, 88, .2);
    --orange: #ff9f0a;
    --orange-soft: rgba(255, 159, 10, .2);
    --yellow-soft: rgba(255, 214, 10, .16);
    --bar: rgba(22, 22, 24, .82);
    --shadow: none;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--label);
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; user-select: none; -webkit-user-select: none; }
button:disabled { cursor: default; }
input, textarea { font: inherit; color: inherit; }
a { color: var(--tint); text-decoration: none; }
svg { display: block; }
.hidden { display: none !important; }

/* ---------- układ ---------- */
.app { min-height: 100%; }
.top {
  padding: calc(var(--safe-top) + 10px) 20px 8px;
  background: var(--bg);
  display: flex; align-items: flex-end; gap: 10px;
}
.top h1 { flex: 1; margin: 0; font-size: 34px; line-height: 1.12; font-weight: 700; letter-spacing: -.02em; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--tint-soft); color: var(--tint);
  font-weight: 600; font-size: 15px; display: grid; place-items: center; flex: none;
}
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: 16px;
  font-size: 14px; font-weight: 600; white-space: nowrap; flex: none;
}
.pill svg { width: 16px; height: 16px; }
.pill.offline { background: var(--card-2); color: var(--label-2); }
.pill.queue { background: var(--orange-soft); color: var(--orange); }
.pill.sending { background: var(--tint-soft); color: var(--tint); }

.view { padding: 4px 16px calc(var(--tabbar-h) + var(--safe-bottom) + 24px); }
.view.with-send { padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 112px); }

.section-title {
  margin: 22px 4px 8px; font-size: 13px; font-weight: 600; letter-spacing: .02em;
  text-transform: uppercase; color: var(--label-2);
}
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card.pad { padding: 14px 16px; }
.hint { margin: 8px 6px 0; font-size: 14px; color: var(--label-2); }

/* ---------- baner instalacji ---------- */
.install-banner {
  display: flex; align-items: center; gap: 12px;
  margin-top: 8px; padding: 12px 12px 12px 14px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
}
.install-banner img { width: 44px; height: 44px; border-radius: 10px; flex: none; }
.install-banner .txt { flex: 1; min-width: 0; font-size: 14px; line-height: 1.25; }
.install-banner .txt b { display: block; font-size: 16px; }
.install-banner .txt span { color: var(--label-2); }
.install-banner .btn.small { padding: 0 14px; }
.banner-x { width: 28px; height: 28px; border-radius: 50%; background: var(--card-2); color: var(--label-2); display: grid; place-items: center; flex: none; margin-left: -4px; }
.banner-x svg { width: 12px; height: 12px; }

/* ---------- przyciski ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 56px; padding: 0 20px; border-radius: 14px;
  font-size: 18px; font-weight: 600;
  transition: transform .12s ease, opacity .12s ease;
}
.btn:active:not(:disabled) { transform: scale(.97); opacity: .85; }
.btn svg { width: 24px; height: 24px; }
.btn.primary { background: var(--tint); color: #fff; }
.btn.primary:disabled { opacity: .38; }
.btn.tinted { background: var(--tint-soft); color: var(--tint); }
.btn.plain { background: var(--card); color: var(--tint); }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.small { min-height: 44px; font-size: 16px; width: auto; padding: 0 16px; border-radius: 12px; }
.btn.xl { min-height: 60px; font-size: 19px; border-radius: 16px; }
.link-btn { color: var(--tint); font-size: 17px; padding: 14px; width: 100%; }

/* ---------- nowy kontakt ---------- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 112px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow);
  color: var(--tint); font-size: 16px; font-weight: 600;
  transition: transform .12s ease;
}
.tile:active { transform: scale(.96); }
.tile svg { width: 34px; height: 34px; }
.tile.big { grid-column: span 2; flex-direction: row; min-height: 76px; gap: 12px; font-size: 18px; }
.tile.big svg { width: 30px; height: 30px; }

.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.thumb { position: relative; aspect-ratio: 4 / 3; border-radius: 12px; overflow: hidden; background: var(--card-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .x {
  position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; border-radius: 50%;
  background: rgba(0, 0, 0, .55); color: #fff; display: grid; place-items: center;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.thumb .x svg { width: 16px; height: 16px; }

.recorder { display: flex; align-items: center; gap: 16px; padding: 14px 16px; }
.rec-btn {
  width: 76px; height: 76px; border-radius: 50%; flex: none;
  background: var(--red); color: #fff; display: grid; place-items: center;
  box-shadow: 0 0 0 4px var(--card), 0 0 0 6px var(--red-soft);
  transition: transform .12s ease;
}
.rec-btn:active { transform: scale(.94); }
.rec-btn svg { width: 34px; height: 34px; }
.rec-btn.on { animation: pulse 1.4s ease-in-out infinite; }
.rec-btn.on svg { width: 28px; height: 28px; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 4px var(--card), 0 0 0 6px var(--red-soft); } 50% { box-shadow: 0 0 0 4px var(--card), 0 0 0 14px var(--red-soft); } }
.rec-info { flex: 1; min-width: 0; }
.rec-info b { display: block; font-size: 18px; }
.rec-info span { color: var(--label-2); font-size: 15px; }
.rec-time { font-variant-numeric: tabular-nums; font-size: 28px; font-weight: 600; letter-spacing: -.01em; }
.levels { display: flex; align-items: center; gap: 4px; height: 34px; margin-top: 2px; }
.levels i { display: block; width: 6px; height: 6px; border-radius: 3px; background: var(--red); transition: height .08s linear; }

.row { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px 16px; position: relative; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--sep); }
.row .grow { flex: 1; min-width: 0; }
.row .sub { color: var(--label-2); font-size: 15px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none; color: var(--tint);
}
.icon-btn.fill { background: var(--tint-soft); }
.icon-btn.red { color: var(--red); }
.icon-btn svg { width: 22px; height: 22px; }

textarea.note {
  display: block; width: 100%; min-height: 110px; padding: 14px 16px; border: 0; outline: 0; resize: none;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); font-size: 17px; line-height: 1.4;
}
textarea.note::placeholder { color: var(--label-3); }

.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  min-height: 48px; padding: 0 18px; border-radius: 24px; background: var(--card); box-shadow: var(--shadow);
  font-size: 17px; font-weight: 500; display: inline-flex; align-items: center; gap: 8px;
  transition: background .15s ease, color .15s ease;
}
.chip svg { width: 18px; height: 18px; }
.chip.on { background: var(--tint); color: #fff; }

.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; border-radius: 14px; background: var(--card-2); }
.segmented button { min-height: 48px; border-radius: 11px; font-size: 16px; font-weight: 600; color: var(--label-2); line-height: 1.1; }
.segmented button small { display: block; font-size: 12px; font-weight: 500; }
.segmented button.on { background: var(--card); color: var(--label); box-shadow: 0 1px 4px rgba(0, 0, 0, .12); }
.segmented button.on.A { color: var(--red); }
.segmented button.on.B { color: var(--orange); }
.segmented button.on.C { color: var(--green); }

.adding {
  display: flex; align-items: center; gap: 10px; margin-top: 8px; padding: 10px 8px 10px 14px;
  border-radius: 14px; background: var(--tint-soft); color: var(--tint); font-weight: 600;
}
.adding .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.send-bar {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-bottom)); z-index: 15;
  padding: 10px 16px 10px; background: linear-gradient(to bottom, transparent, var(--bg) 22%);
}
.send-bar .hint { text-align: center; margin: 6px 0 0; font-size: 13px; }

/* ---------- lista kontaktów ---------- */
.list .row { min-height: 72px; padding: 10px 14px 10px 12px; }
.list .row + .row::before { left: 76px; }
.list .row:active { background: var(--card-2); }
.ava {
  width: 52px; height: 52px; border-radius: 12px; flex: none; overflow: hidden;
  background: var(--tint-soft); color: var(--tint); display: grid; place-items: center; font-weight: 700; font-size: 18px;
}
.ava img { width: 100%; height: 100%; object-fit: cover; }
.ava svg { width: 26px; height: 26px; }
.title-line { display: flex; align-items: center; gap: 6px; }
.title-line .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prio { flex: none; min-width: 24px; height: 22px; padding: 0 6px; border-radius: 6px; font-size: 13px; font-weight: 700; display: inline-grid; place-items: center; }
.prio.A { background: var(--red-soft); color: var(--red); }
.prio.B { background: var(--orange-soft); color: var(--orange); }
.prio.C { background: var(--green-soft); color: var(--green); }
.status { display: flex; align-items: center; gap: 5px; font-size: 14px; color: var(--label-2); margin-top: 1px; }
.status svg { width: 15px; height: 15px; flex: none; }
.status.ok { color: var(--green); }
.status.warn { color: var(--orange); }
.status.err { color: var(--red); }
.status.busy { color: var(--tint); }
.chev { color: var(--label-3); width: 14px; flex: none; }
.empty { text-align: center; color: var(--label-2); padding: 48px 24px; }
.empty svg { width: 56px; height: 56px; margin: 0 auto 12px; color: var(--label-3); }
.empty b { display: block; color: var(--label); font-size: 20px; margin-bottom: 4px; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- pasek zakładek ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--tabbar-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--bar); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: .5px solid var(--sep);
}
.tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--label-2); font-size: 11px; font-weight: 500; position: relative; }
.tabbar button svg { width: 28px; height: 28px; }
.tabbar button.on { color: var(--tint); }
.badge {
  position: absolute; top: 4px; left: calc(50% + 8px); min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--red); color: #fff; font-size: 13px; font-weight: 600; display: grid; place-items: center;
}

/* ---------- arkusze (sheets) ---------- */
.backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .4); opacity: 0; transition: opacity .25s ease; }
.backdrop.show { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; max-height: calc(100% - var(--safe-top) - 24px);
  display: flex; flex-direction: column;
  background: var(--bg); border-radius: 14px 14px 0 0; transform: translateY(100%);
  transition: transform .32s cubic-bezier(.2, .9, .3, 1);
}
.sheet.show { transform: none; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 14px 12px 8px 20px; }
.sheet-head h2 { flex: 1; margin: 0; font-size: 22px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-head .close { width: 36px; height: 36px; border-radius: 50%; background: var(--card-2); color: var(--label-2); display: grid; place-items: center; flex: none; }
.sheet-head .close svg { width: 16px; height: 16px; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 16px calc(var(--safe-bottom) + 24px); }

.fields .row { min-height: 52px; align-items: flex-start; padding-top: 12px; padding-bottom: 12px; }
.fields .k { width: 104px; flex: none; color: var(--label-2); font-size: 15px; padding-top: 1px; }
.fields .v { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.note-box { padding: 12px 16px; font-size: 16px; }
.note-box + .note-box { border-top: .5px solid var(--sep); }
.note-box .who { font-size: 13px; color: var(--label-2); margin-bottom: 2px; }
.warn-box { margin-top: 12px; padding: 12px 14px; border-radius: 14px; background: var(--yellow-soft); font-size: 15px; }
.err-box { margin-top: 12px; padding: 12px 14px; border-radius: 14px; background: var(--red-soft); color: var(--red); font-size: 15px; }
.photos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.photos img { width: 100%; border-radius: 12px; display: block; background: var(--card-2); min-height: 80px; }
.actions { display: grid; gap: 10px; margin-top: 24px; }
.big-status { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.big-status svg { width: 28px; height: 28px; flex: none; }

.steps { counter-reset: step; }
.step { display: flex; gap: 14px; align-items: center; padding: 14px 16px; }
.step + .step { border-top: .5px solid var(--sep); }
.step .n { width: 32px; height: 32px; border-radius: 50%; background: var(--tint); color: #fff; font-weight: 700; display: grid; place-items: center; flex: none; }
.step .ic { display: inline-grid; place-items: center; vertical-align: -6px; width: 28px; height: 28px; border-radius: 7px; background: var(--card-2); color: var(--tint); margin: 0 2px; }
.step .ic svg { width: 18px; height: 18px; }

/* ---------- ekran powitalny ---------- */
.welcome {
  min-height: 100%; display: flex; flex-direction: column; align-items: stretch; justify-content: center;
  padding: calc(var(--safe-top) + 32px) 24px calc(var(--safe-bottom) + 24px); max-width: 520px; margin: 0 auto;
}
.welcome .logo { width: 104px; height: 104px; border-radius: 24px; margin: 0 auto 18px; box-shadow: 0 10px 30px rgba(220, 44, 28, .3); }
.welcome h1 { text-align: center; margin: 0; font-size: 30px; letter-spacing: -.02em; }
.welcome p.lead { text-align: center; color: var(--label-2); margin: 8px 0 28px; }
.welcome .stack { display: grid; gap: 12px; }
.code-input {
  width: 100%; min-height: 60px; border: 0; outline: 0; border-radius: 14px; background: var(--card); box-shadow: var(--shadow);
  text-align: center; font-size: 24px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
}
.code-input::placeholder { color: var(--label-3); letter-spacing: .06em; font-weight: 500; }
.welcome .err { color: var(--red); text-align: center; font-size: 15px; min-height: 20px; }
.welcome .who { text-align: center; font-size: 17px; margin-bottom: 4px; }
.welcome .who b { color: var(--tint); }

/* ---------- komunikaty ---------- */
.toast {
  position: fixed; left: 50%; top: calc(var(--safe-top) + 12px); z-index: 80;
  transform: translate(-50%, -150%); transition: transform .3s cubic-bezier(.2, .9, .3, 1);
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 22px;
  background: rgba(30, 30, 32, .92); color: #fff; font-size: 16px; font-weight: 500; box-shadow: 0 8px 30px rgba(0, 0, 0, .25);
  display: flex; align-items: center; gap: 8px;
}
.toast svg { width: 20px; height: 20px; flex: none; }
.toast.show { transform: translate(-50%, 0); }

.action-sheet { position: fixed; left: 8px; right: 8px; bottom: calc(var(--safe-bottom) + 8px); z-index: 61; transform: translateY(120%); transition: transform .28s cubic-bezier(.2, .9, .3, 1); display: grid; gap: 8px; }
.action-sheet.show { transform: none; }
.action-sheet .group { background: var(--card); border-radius: 14px; overflow: hidden; }
.action-sheet .msg { padding: 14px 16px; text-align: center; color: var(--label-2); font-size: 14px; border-bottom: .5px solid var(--sep); }
.action-sheet button { width: 100%; min-height: 58px; font-size: 19px; color: var(--tint); }
.action-sheet button + button { border-top: .5px solid var(--sep); }
.action-sheet button.destructive { color: var(--red); }
.action-sheet button.cancel { font-weight: 600; }
