/* Książka teleadresowa — styl klienta PWA. Bez zewnętrznych fontów i CDN (sieć LAN, offline).
   Motyw: papier w chłodnym odcieniu, atrament morski, akcent głębokiej zieleni (Bałtyk).
   Nagłówki liter i nazwisko na karcie — krój szeryfowy z systemu, interfejs — krój bezszeryfowy z systemu. */
:root {
  color-scheme: light dark;
  --bg: #f3f6f6; --surface: #ffffff; --ink: #0f2329; --muted: #52666d; --faint: #62767d; --line: #dbe4e5;
  --accent: #0e6b66; --accent-strong: #0a5651; --accent-soft: #dff0ee; --accent-fg: #ffffff;
  --danger: #b3261e; --danger-soft: #fbe9e7; --warn: #86550a; --warn-soft: #fdf0d5; --ok: #1b7a43;
  --scrim: rgba(8, 24, 28, .46); --shadow: 0 -10px 40px rgba(8, 28, 32, .18);
  --av0b: #d3ebe7; --av0f: #0b5650; --av1b: #d9e6f7; --av1f: #1e4a86; --av2b: #e2e1f6; --av2f: #403e9c; --av3b: #eedcf1; --av3f: #74368a;
  --av4b: #f7dde1; --av4f: #963047; --av5b: #f6e6c6; --av5f: #7a5110; --av6b: #e3ebca; --av6f: #4b6113; --av7b: #dce3e8; --av7f: #3b4f5e;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Noto Serif", "DejaVu Serif", serif;
  --sticky-h: 116px;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1a1e; --surface: #15252a; --ink: #e7f0f1; --muted: #9db1b7; --faint: #8a9ea4; --line: #243940;
    --accent: #4cc3b6; --accent-strong: #7ad9cd; --accent-soft: #17383a; --accent-fg: #06211f;
    --danger: #ff8f86; --danger-soft: #3a1e1c; --warn: #f4c36a; --warn-soft: #3a2f14; --ok: #5fd58b;
    --scrim: rgba(0, 0, 0, .6); --shadow: 0 -10px 40px rgba(0, 0, 0, .5);
    --av0b: #1b3d3a; --av0f: #8ee0d4; --av1b: #1d3350; --av1f: #a5c6f2; --av2b: #2a2a52; --av2f: #b9b7f5; --av3b: #3a2646; --av3f: #dcb0ea;
    --av4b: #4a2530; --av4f: #f2b3be; --av5b: #463514; --av5f: #ecc77e; --av6b: #33401a; --av6f: #c5da86; --av7b: #27333c; --av7f: #b8c9d4;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; }
body { font: 16px/1.4 var(--sans); background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
/* maska pod pasek stanu (notch), gdy nagłówek jest przyklejony */
body::before { content: ""; position: fixed; inset: 0 0 auto 0; height: var(--safe-t); background: var(--bg); z-index: 30; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.noscript { padding: 24px; }
.icon { display: block; flex: none; }
ul { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, p { margin: 0; }

/* ---------- awatary ---------- */
.avatar { flex: none; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  font: 600 17px/1 var(--sans); letter-spacing: .02em; user-select: none; }
.avatar.lg { width: 56px; height: 56px; font-size: 21px; }
.avatar.xl { width: 104px; height: 104px; font-size: 38px; font-family: var(--serif); font-weight: 600; }
.avatar.plain { background: var(--accent-soft); color: var(--accent-strong); }
.av0 { background: var(--av0b); color: var(--av0f); } .av1 { background: var(--av1b); color: var(--av1f); }
.av2 { background: var(--av2b); color: var(--av2f); } .av3 { background: var(--av3b); color: var(--av3f); }
.av4 { background: var(--av4b); color: var(--av4f); } .av5 { background: var(--av5b); color: var(--av5f); }
.av6 { background: var(--av6b); color: var(--av6f); } .av7 { background: var(--av7b); color: var(--av7f); }

/* ---------- przyciski wspólne ---------- */
.iconbtn { width: 48px; height: 48px; border: 0; border-radius: 50%; background: none; display: grid; place-items: center; color: var(--ink); }
.iconbtn:active { background: var(--accent-soft); }
.btn { display: block; width: 100%; min-height: 54px; padding: 0 18px; border: 0; border-radius: 14px; background: var(--accent); color: var(--accent-fg);
  font-weight: 650; font-size: 17px; }
.btn:active { background: var(--accent-strong); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.slim { display: inline-block; width: auto; min-height: 48px; font-size: 16px; padding: 0 20px; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); margin-top: 10px; }
.btn.ghost:active { background: var(--accent-soft); }
.btn.danger { background: var(--danger); color: #fff; margin-top: 18px; }
@media (prefers-color-scheme: dark) { .btn.danger { background: #c4453d; } }
.linkbtn { min-height: 48px; padding: 0 12px; border: 0; background: none; color: var(--accent-strong); font-weight: 600; font-size: 16px;
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; border-radius: 10px; }
.linkbtn.small { font-size: 14px; min-height: 44px; }

/* ---------- logowanie ---------- */
.auth { position: relative; min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: calc(var(--safe-t) + 28px) 20px calc(var(--safe-b) + 28px); overflow: hidden; }
.auth-box { width: 100%; max-width: 400px; position: relative; z-index: 1; }
.mark-img { display: block; width: 64px; height: 64px; margin-bottom: 20px; }
.mark { width: 60px; height: 60px; border-radius: 18px; background: var(--accent); color: var(--accent-fg); display: grid; place-items: center; margin-bottom: 20px; }
.auth h1 { font: 600 34px/1.1 var(--serif); letter-spacing: -.01em; margin-bottom: 10px; }
.lead { color: var(--muted); margin-bottom: 22px; max-width: 34ch; }
.form label { display: block; font-weight: 600; font-size: 15px; margin: 16px 0 6px; }
.form input { width: 100%; min-height: 54px; padding: 0 16px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface); font-size: 17px; }
.form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form input.code { font: 650 24px/1.2 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .14em; text-align: center; text-transform: uppercase; }
.pinwrap { position: relative; }
.pinwrap input { padding-right: 56px; letter-spacing: .12em; }
.eye { position: absolute; right: 4px; top: 3px; width: 48px; height: 48px; border: 0; background: none; border-radius: 12px; display: grid; place-items: center; color: var(--muted); }
.hint { font-size: 14px; color: var(--muted); margin-top: 6px; }
.remember { margin-top: 18px; display: grid; grid-template-columns: 24px 1fr; column-gap: 12px; align-items: start; }
.form .remember input { width: 24px; min-height: 24px; height: 24px; padding: 0; margin: 2px 0 0; accent-color: var(--accent); }
.form .remember label { margin: 0; font-weight: 600; }
.remember .hint { grid-column: 2; margin-top: 4px; }
.device { margin-top: 14px; }
.device summary { min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 14px; cursor: pointer; border-radius: 8px; list-style: none; }
.device summary::-webkit-details-marker { display: none; }
.device[open] summary .icon { transform: rotate(180deg); }
.device input { min-height: 48px; margin-top: 4px; font-size: 16px; }
.err { color: var(--danger); font-size: 15px; margin-top: 14px; }
.err:empty { display: none; }
.form .btn { margin-top: 20px; }
.notice { background: var(--warn-soft); color: var(--warn); padding: 12px 14px; border-radius: 12px; font-size: 15px; margin-bottom: 8px; }
.alt { text-align: center; margin-top: 14px; }

/* ---------- nagłówek i wyszukiwanie ---------- */
.shell { max-width: 760px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; }
.topline { display: flex; align-items: center; gap: 10px; padding: calc(var(--safe-t) + 14px) 16px 6px; }
.brand { flex: 1; min-width: 0; }
.brand h1 { font: 600 27px/1.15 var(--serif); letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status { display: flex; align-items: center; gap: 8px; margin-top: 3px; font-size: 13px; color: var(--muted); min-height: 20px; }
.status-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.dot.ok { background: var(--ok); } .dot.err { background: var(--danger); } .dot.off { background: var(--warn); }
.dot.syncing { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.badge { flex: none; display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 12px; background: var(--warn-soft); color: var(--warn);
  font-size: 12.5px; font-weight: 650; }
.me { flex: none; width: 48px; height: 48px; border-radius: 50%; border: 1.5px solid var(--line); background: var(--surface); color: var(--accent-strong);
  display: grid; place-items: center; }
.me:active { background: var(--accent-soft); }
.me-ini { font-weight: 650; font-size: 16px; }

.sticky { position: sticky; top: var(--safe-t); z-index: 20; background: var(--bg); padding: 8px 16px 6px; border-bottom: 1px solid transparent; }
.sticky.stuck { border-bottom-color: var(--line); }
.searchrow { position: relative; display: flex; align-items: center; height: 50px; border-radius: 15px; background: var(--surface); border: 1.5px solid var(--line); }
.searchrow:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sicon { padding-left: 14px; color: var(--muted); display: grid; }
.search { flex: 1; min-width: 0; height: 100%; padding: 0 8px 0 10px; border: 0; background: none; font-size: 17px; -webkit-appearance: none; appearance: none; }
.search:focus { outline: none; }
.search::-webkit-search-cancel-button, .search::-webkit-search-decoration { -webkit-appearance: none; display: none; }
.clear { flex: none; width: 48px; height: 48px; border: 0; background: none; color: var(--muted); display: grid; place-items: center; border-radius: 50%; }
.chips { display: flex; gap: 8px; margin: 8px -16px 0; padding: 0 16px 2px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chipwrap { flex: none; display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: 22px; background: var(--surface); min-height: 44px; }
.chipwrap.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 41px; padding: 0 14px; border: 0; background: none; border-radius: 22px; font-size: 15px; font-weight: 550; white-space: nowrap; }
.chipwrap.active .chip { padding-right: 4px; }
.chip-v { max-width: 56vw; overflow: hidden; text-overflow: ellipsis; }
.chip-x { width: 41px; height: 41px; border: 0; background: none; border-radius: 50%; display: grid; place-items: center; color: inherit; }
.chip-x:active { background: var(--accent); color: var(--accent-fg); }
.summary { display: flex; align-items: center; justify-content: space-between; min-height: 44px; padding: 0 16px 0 18px; font-size: 14px; color: var(--muted); }

/* ---------- lista ---------- */
.list { padding-bottom: calc(var(--safe-b) + 32px); }
.list.has-rail .row { padding-right: 32px; }
.group { scroll-margin-top: calc(var(--sticky-h) + var(--safe-t)); }
.letter { position: sticky; top: calc(var(--sticky-h) + var(--safe-t)); z-index: 5; margin: 0; padding: 4px 18px 3px; background: var(--bg);
  font: 700 20px/1.2 var(--serif); color: var(--accent); }
.row { position: relative; display: flex; align-items: center; gap: 6px; padding: 0 14px 0 16px; }
.row::after { content: ""; position: absolute; left: 74px; right: 0; bottom: 0; height: 1px; background: var(--line); }
.rows .row:last-child::after { display: none; }
.row-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; min-height: 72px; padding: 10px 0; border: 0; background: none; text-align: left; border-radius: 12px; }
.row-main:active .txt { opacity: .6; }
.txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.txt > span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nm { font-size: 17px; line-height: 1.25; }
.ln { font-weight: 650; } .fn { font-weight: 400; }
.sb { font-size: 14px; color: var(--muted); }
.pl { font-size: 13px; color: var(--faint); }
.row-call { flex: none; width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-strong); text-decoration: none; margin-left: 2px; }
.row-call:active { background: var(--accent); color: var(--accent-fg); }
.empty { padding: 56px 28px 40px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty-ic { width: 68px; height: 68px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); display: grid; place-items: center; margin-bottom: 8px; }
.empty h2 { font: 600 22px/1.2 var(--serif); color: var(--ink); }
.empty p { max-width: 32ch; }
.empty .btn { margin-top: 14px; }
.firstsync { padding: 8px 18px 16px; color: var(--muted); }
.fs-title { font: 600 20px/1.2 var(--serif); color: var(--ink); margin-bottom: 4px; }
.row.skel { min-height: 72px; gap: 14px; }
.row.skel::after { display: none; }
.avatar.sk, .sk-line { background: var(--line); }
.sk-line { display: block; height: 12px; border-radius: 6px; }
.sk-line.w1 { width: 55%; height: 14px; margin-bottom: 8px; } .sk-line.w2 { width: 38%; }
@media (prefers-reduced-motion: no-preference) {
  .avatar.sk, .sk-line { animation: shimmer 1.4s ease-in-out infinite; }
  @keyframes shimmer { 50% { opacity: .5; } }
}

/* ---------- indeks alfabetu ---------- */
.rail { position: fixed; z-index: 15; right: max(0px, env(safe-area-inset-right)); top: calc(var(--sticky-h) + var(--safe-t) + 40px); bottom: calc(var(--safe-b) + 10px);
  width: 30px; padding-left: 8px; display: flex; flex-direction: column; touch-action: none; user-select: none; -webkit-user-select: none; }
.rl { flex: 1 1 0; min-height: 0; width: 100%; padding: 0; border: 0; background: none; font: 700 11px/1 var(--sans); color: var(--accent-strong); display: grid; place-items: center; }
.bubble { position: fixed; z-index: 16; left: 50%; top: 42%; width: 84px; height: 84px; margin: -42px 0 0 -42px; border-radius: 24px; background: var(--accent); color: var(--accent-fg);
  display: grid; place-items: center; font: 600 44px/1 var(--serif); pointer-events: none; opacity: 0; transition: opacity .12s; }
.bubble.show { opacity: .94; }

/* ---------- warstwy: arkusze i karta ---------- */
.layer { position: fixed; inset: 0; z-index: 50; }
.backdrop { position: absolute; inset: 0; background: var(--scrim); opacity: 0; touch-action: none; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 560px; max-height: 84vh; max-height: 84dvh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 24px 24px 0 0; box-shadow: var(--shadow); transform: translateY(100%); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 4px 22px; }
.sheet-head h2 { font: 600 22px/1.2 var(--serif); }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; padding: 4px 12px calc(var(--safe-b) + 18px); }
.sheet-hint { padding: 0 10px 8px; color: var(--muted); font-size: 14px; }
.sheet-search { width: calc(100% - 20px); margin: 0 10px 8px; min-height: 48px; padding: 0 14px; border-radius: 13px; border: 1.5px solid var(--line); background: var(--bg); font-size: 16px; }
.sheet-search:focus { outline: none; border-color: var(--accent); }
.opt { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 0 10px 0 12px; border: 0; background: none; border-radius: 12px; text-align: left; font-size: 17px; }
.opt:active { background: var(--accent-soft); }
.opt.sel { background: var(--accent-soft); color: var(--accent-strong); font-weight: 650; }
.opt:disabled { color: var(--faint); opacity: .6; cursor: default; }
.opt-t { flex: 1; min-width: 0; }
.opt-n { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.opt-c { width: 20px; display: grid; }
.opt-group { padding: 14px 12px 4px; font: 700 16px/1.2 var(--serif); color: var(--accent); }
.opt-empty { padding: 20px 12px; color: var(--muted); }

.menu .who { display: flex; align-items: center; gap: 14px; padding: 6px 10px 14px; }
.who-n { font: 600 21px/1.2 var(--serif); }
.who-c { color: var(--muted); font-size: 14px; }
.syncinfo { margin: 0 10px 10px; padding: 12px 14px; background: var(--bg); border-radius: 14px; font-size: 14px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.offtag { color: var(--warn); font-weight: 600; margin-top: 4px; }
.menu-item { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 54px; padding: 0 12px; border: 0; background: none; border-radius: 12px; font-size: 17px; text-align: left; }
.menu-item:active { background: var(--accent-soft); }
.menu-item.danger { color: var(--danger); }
.confirm-t { font: 600 21px/1.25 var(--serif); padding: 4px 10px 6px; }
.confirm-p { color: var(--muted); padding: 0 10px; }
.menu .btn { width: calc(100% - 20px); margin-left: 10px; margin-right: 10px; }
.menu .btn.ghost { margin-top: 10px; }

.detail-layer { background: var(--bg); }
.detail { position: absolute; inset: 0; overflow-y: auto; overscroll-behavior: contain; background: var(--bg); transform: translateX(24px); opacity: 0; }
.dbar { position: sticky; top: 0; z-index: 2; padding: calc(var(--safe-t) + 6px) 8px 4px; background: var(--bg); }
.dcontent { max-width: 560px; margin: 0 auto; padding: 0 16px calc(var(--safe-b) + 32px); }
.hero { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 4px 0 22px; }
.dname { font: 600 32px/1.12 var(--serif); letter-spacing: -.015em; margin-top: 16px; text-wrap: balance; overflow-wrap: anywhere; }
.dpos { font-size: 18px; margin-top: 6px; }
.ddep { color: var(--muted); margin-top: 1px; }
.dplace { display: flex; align-items: center; gap: 6px; margin-top: 10px; padding: 6px 12px 6px 10px; border-radius: 16px; background: var(--accent-soft); color: var(--accent-strong); font-size: 14px; font-weight: 550; max-width: 100%; }
.dplace span { overflow: hidden; text-overflow: ellipsis; }
.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(76px, 1fr)); gap: 10px; margin-bottom: 20px; }
.act { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; min-height: 80px; padding: 12px 4px; border-radius: 18px; background: var(--surface);
  border: 1.5px solid var(--line); color: var(--accent-strong); text-decoration: none; font-size: 13px; font-weight: 650; }
.act:active { background: var(--accent-soft); }
button.act { font: inherit; font-size: 13px; font-weight: 650; cursor: pointer; }
button.act:disabled { opacity: .6; }
.act.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.act.primary:active { background: var(--accent-strong); }
/* kafelek informacyjny (numer wewnętrzny): pasek na całą szerokość, przerywana ramka, bez reakcji na dotyk — nie jest przyciskiem */
.act.info { grid-column: 1 / -1; flex-direction: row; justify-content: flex-start; gap: 10px; min-height: 58px; padding: 10px 18px;
  background: transparent; border-style: dashed; border-color: var(--faint); color: var(--muted); cursor: default; user-select: text; -webkit-user-select: text; }
.act.info:active { background: transparent; }
.act.info span { font-weight: 550; font-size: 15px; }
.act.info strong { margin-left: auto; font-size: 24px; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: .03em; overflow-wrap: anywhere; }
.fields { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.fields:empty { display: none; }
.field { display: flex; align-items: center; gap: 10px; min-height: 60px; padding: 10px 16px; border-bottom: 1px solid var(--line); text-decoration: none; }
.field:last-child { border-bottom: 0; }
.field.link:active { background: var(--accent-soft); }
.fld { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.field .k { font-size: 13px; color: var(--muted); }
.field .v { font-size: 18px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.field.link .v { color: var(--accent-strong); font-weight: 550; }
.field.note .v { white-space: pre-wrap; font-size: 16px; }
.fi { color: var(--accent-strong); display: grid; }

@media (prefers-reduced-motion: no-preference) {
  .backdrop { transition: opacity .22s ease; }
  .sheet { transition: transform .26s cubic-bezier(.2, .8, .2, 1); }
  .detail { transition: transform .24s cubic-bezier(.2, .8, .2, 1), opacity .2s ease; }
}
.layer.open .backdrop { opacity: 1; }
.layer.open .sheet { transform: none; }
.layer.open .detail { transform: none; opacity: 1; }

@media (min-width: 760px) {
  .rail { right: calc(50% - 400px); }
  .sheet { bottom: 6vh; border-radius: 24px; }
}
@media (max-height: 560px) {
  .rl { font-size: 9px; }
}

/* =====================================================================
   Komunikator: dolna nawigacja, lista rozmów, czat
   ===================================================================== */
:root {
  --tab-h: 0px;
  --mine-b: #0e6b66; --mine-f: #ffffff;
  --adm-b: #fdf0d5; --adm-line: #ecd29a; --adm-ink: #4d3204;
}
@media (prefers-color-scheme: dark) {
  :root { --mine-b: #1d6b65; --mine-f: #effdfb; --adm-b: #3a2f14; --adm-line: #5c4a22; --adm-ink: #f6dca6; }
}

/* ---------- dolny pasek zakładek ---------- */
#app.with-tabs { --tab-h: calc(60px + var(--safe-b)); }
.m-tabbar { position: fixed; z-index: 26; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 8px;
  padding: 0 max(8px, env(safe-area-inset-right)) var(--safe-b) max(8px, env(safe-area-inset-left)); background: var(--surface); border-top: 1px solid var(--line); }
.m-tab { flex: 1 1 0; max-width: 280px; min-height: 60px; padding: 0; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 12.5px; font-weight: 600; }
.m-tab-ic { position: relative; width: 58px; height: 30px; border-radius: 15px; display: grid; place-items: center; }
.m-tab.on { color: var(--accent-strong); }
.m-tab.on .m-tab-ic { background: var(--accent-soft); }
.m-tab:active .m-tab-ic { background: var(--accent-soft); }
.m-tabbadge { position: absolute; top: -5px; right: 2px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--accent); color: var(--accent-fg);
  font-size: 12px; font-weight: 700; line-height: 20px; text-align: center; box-shadow: 0 0 0 2px var(--surface); font-variant-numeric: tabular-nums; }
.with-tabs .list { padding-bottom: calc(var(--tab-h) + 32px); }
.with-tabs .rail { bottom: calc(var(--tab-h) + 10px); }

.m-view { display: none; }
.tab-msgs .shell, .tab-msgs .rail, .tab-msgs .bubble { display: none; }
.tab-msgs .m-view { display: block; }
.m-shell { max-width: 760px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; padding-bottom: calc(var(--tab-h) + 100px); }
.m-sub { gap: 6px; }
.m-banner { display: flex; align-items: center; gap: 10px; margin: 6px 16px 4px; padding: 10px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); font-size: 14px; font-weight: 600; }
.m-banner[hidden] { display: none; }
.m-list { padding-top: 4px; }

/* ---------- lista rozmów ---------- */
.m-row { position: relative; display: flex; align-items: center; gap: 6px; padding: 0 14px 0 16px; }
.m-row::after { content: ""; position: absolute; left: 74px; right: 0; bottom: 0; height: 1px; background: var(--line); }
.rows .m-row:last-child::after { display: none; }
.m-row-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; min-height: 72px; padding: 10px 0; border: 0; background: none; text-align: left; border-radius: 12px; }
.m-row-main:active .txt { opacity: .6; }
.m-row .sb { font-size: 14.5px; }
.m-row.unread .sb { color: var(--ink); font-weight: 600; }
.m-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; min-width: 44px; }
.m-time { font-size: 12.5px; color: var(--faint); font-variant-numeric: tabular-nums; white-space: nowrap; }
.m-row.unread .m-time { color: var(--accent-strong); font-weight: 650; }
.m-unread { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--accent); color: var(--accent-fg); display: grid; place-items: center;
  font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.avatar.m-ann { background: var(--accent); color: var(--accent-fg); }
.avatar.sm { width: 40px; height: 40px; }
.m-rows-wrap { display: block; }
.m-empty { padding-top: 36px; }
.m-note { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 10px; margin-top: 14px; padding: 12px 14px; max-width: 360px; border-radius: 14px;
  background: var(--accent-soft); color: var(--accent-strong); font-size: 14px; text-align: left; }
.m-note p { flex: 1 1 200px; max-width: none; }
.m-fab { position: fixed; z-index: 24; right: max(16px, env(safe-area-inset-right)); bottom: calc(var(--tab-h) + 16px); min-height: 56px; padding: 0 20px 0 16px; border: 0; border-radius: 28px;
  background: var(--accent); color: var(--accent-fg); display: inline-flex; align-items: center; gap: 8px; font-weight: 650; font-size: 16px; box-shadow: 0 6px 20px rgba(8, 40, 40, .3); }
.m-fab:active { background: var(--accent-strong); }
.menu-state { margin-left: auto; color: var(--muted); font-size: 14px; }
.menu-item[aria-pressed="true"] .menu-state { color: var(--accent-strong); font-weight: 650; }
.m-langs .opt { min-height: 52px; }
.m-langs { margin: 10px 0 8px; }
.menu .err { padding: 0 10px; margin: 6px 0 0; }

/* wybór osoby */
.m-people { display: flex; flex-direction: column; }
.m-person { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 64px; padding: 8px 10px; border: 0; background: none; border-radius: 12px; text-align: left; }
.m-person:active { background: var(--accent-soft); }
.m-person:disabled { opacity: .55; cursor: default; }
.m-person .avatar { width: 44px; height: 44px; font-size: 16px; }

/* ---------- powiadomienie (toast) ---------- */
.m-toasts { position: fixed; z-index: 70; left: 0; right: 0; top: calc(var(--safe-t) + 10px); display: flex; justify-content: center; padding: 0 12px; pointer-events: none; }
.m-toast { pointer-events: auto; display: flex; align-items: stretch; width: min(440px, 100%); background: var(--ink); color: var(--bg); border-radius: 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); opacity: 0; transform: translateY(-14px); }
.m-toast.open { opacity: 1; transform: none; }
.m-toast-b { flex: 1; min-width: 0; min-height: 56px; display: flex; align-items: center; gap: 12px; padding: 10px 6px 10px 14px; border: 0; background: none; color: inherit; text-align: left; }
.m-toast-ic { flex: none; display: grid; }
.m-toast-t { display: flex; flex-direction: column; min-width: 0; }
.m-toast-t strong { font-size: 15px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-toast-t span { font-size: 14px; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-toast-x { flex: none; width: 48px; border: 0; background: none; color: inherit; display: grid; place-items: center; opacity: .8; }

/* ---------- czat ---------- */
.chat-layer { background: var(--bg); }
.chat { position: absolute; left: 0; right: 0; top: var(--vvt, 0px); height: var(--vvh, 100%); max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; background: var(--bg); opacity: 0; transform: translateX(24px); }
.layer.open .chat { opacity: 1; transform: none; }
.c-head { flex: none; display: flex; align-items: center; gap: 8px; padding: calc(var(--safe-t) + 6px) 14px 6px 6px; background: var(--surface); border-bottom: 1px solid var(--line); }
.c-av { flex: none; display: grid; }
.c-ht { flex: 1; min-width: 0; }
.c-title { font: 600 19px/1.2 var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat .m-banner { margin: 0; border-radius: 0; flex: none; }
.c-main { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.c-log { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 8px 12px 14px; display: flex; flex-direction: column; }
.c-log::before { content: ""; margin-top: auto; }
.c-log:focus { outline: none; }
.c-log > * { flex: none; }
.c-state { margin: auto; padding: 32px 20px; text-align: center; color: var(--muted); }
.c-state .btn { margin-top: 14px; }
.c-older { display: flex; justify-content: center; padding: 4px 0 8px; }
.c-olderbtn { min-height: 44px; padding: 0 18px; border: 1.5px solid var(--line); border-radius: 22px; background: var(--surface); color: var(--accent-strong); font-weight: 600; font-size: 14px; }
.c-olderbtn:disabled { opacity: .6; cursor: default; }
.c-day { display: flex; align-items: center; gap: 12px; margin: 14px 4px 6px; color: var(--muted); font-size: 13px; font-weight: 600; }
.c-day::before, .c-day::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.c-msg { display: flex; margin-top: 3px; }
.c-msg.first { margin-top: 11px; }
.c-msg.mine { justify-content: flex-end; }
.c-bub { position: relative; max-width: min(84%, 520px); padding: 8px 13px 6px; border-radius: 18px; -webkit-touch-callout: none; }
.theirs .c-bub { background: var(--surface); border: 1px solid var(--line); }
.theirs.first .c-bub { border-top-left-radius: 6px; }
.mine .c-bub { background: var(--mine-b); color: var(--mine-f); }
.mine.first .c-bub { border-top-right-radius: 6px; }
.c-msg.admin .c-bub { background: var(--adm-b); border: 1px solid var(--adm-line); color: var(--adm-ink); }
.c-sender { margin: 0 0 2px; display: flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 700; line-height: 1.3; }
.c-sender.adm { color: var(--adm-ink); }
.sn0 { color: var(--av0f); } .sn1 { color: var(--av1f); } .sn2 { color: var(--av2f); } .sn3 { color: var(--av3f); }
.sn4 { color: var(--av4f); } .sn5 { color: var(--av5f); } .sn6 { color: var(--av6f); } .sn7 { color: var(--av7f); }
.c-text { margin: 0; font-size: 16.5px; line-height: 1.38; white-space: pre-wrap; overflow-wrap: anywhere; }
.c-text.dim { opacity: .55; }
.c-text.is-orig { font-family: var(--serif); padding-left: 10px; border-left: 2px solid var(--accent); }
.c-del { font-style: italic; color: var(--faint); }
.mine .c-del { color: inherit; opacity: .8; }
.c-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; margin-top: 6px; padding-top: 5px; border-top: 1px solid var(--line); font-size: 12.5px; line-height: 1.35; color: var(--muted); }
.admin .c-strip { border-top-color: var(--adm-line); color: inherit; }
.c-strip .icon { opacity: .85; }
.c-strip.failed { color: var(--danger); }
.c-strip-t { min-width: 0; }
.c-link { position: relative; margin-left: auto; padding: 0 2px; border: 0; background: none; color: var(--accent-strong); font-size: 12.5px; font-weight: 650; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.c-strip.failed .c-link { margin-left: 0; }
.admin .c-link { color: inherit; }
.c-link::after, .c-more::after { content: ""; position: absolute; inset: -14px -6px; }
.c-spin { flex: none; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); }
.c-meta { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 4px 12px; margin-top: 2px; min-height: 16px; font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.admin .c-meta { color: inherit; opacity: .75; }
.mine .c-meta { color: var(--mine-f); opacity: .82; }
.c-more { position: relative; width: 20px; height: 16px; padding: 0; border: 0; background: none; color: inherit; display: grid; place-items: center; }
.c-msg.sending .c-bub { opacity: .72; }
.c-msg.failed .c-bub { background: var(--danger-soft); border: 1px solid var(--danger); color: var(--ink); }
.c-msg.failed .c-meta { justify-content: flex-start; color: var(--danger); opacity: 1; font-size: 12.5px; }
.c-msg.sending .c-meta { opacity: .9; gap: 5px; }
.c-fail { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.c-msg.failed .c-link { margin-left: 0; color: var(--ink); }
.c-newbtn { position: absolute; z-index: 3; left: 50%; bottom: 12px; transform: translateX(-50%); min-height: 44px; padding: 0 18px 0 14px; border: 0; border-radius: 22px; background: var(--accent); color: var(--accent-fg);
  display: inline-flex; align-items: center; gap: 6px; font-size: 14.5px; font-weight: 650; white-space: nowrap; box-shadow: 0 6px 18px rgba(8, 40, 40, .3); }
.c-newbtn[hidden] { display: none; }

.c-compose { flex: none; padding: 8px 10px calc(var(--safe-b) + 8px); background: var(--surface); border-top: 1px solid var(--line); }
.chat.kbd .c-compose { padding-bottom: 8px; }
.c-form { display: flex; align-items: flex-end; gap: 8px; }
.c-form[hidden], .c-readonly[hidden], .c-offnote[hidden] { display: none; }
.c-field { flex: 1; min-width: 0; }
.c-count { display: block; padding: 0 8px 3px; text-align: right; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.c-count:empty { display: none; }
.c-count.over { color: var(--danger); font-weight: 700; }
.c-input { display: block; width: 100%; min-height: 48px; max-height: 132px; padding: 12px 16px; border: 1.5px solid var(--line); border-radius: 24px; background: var(--bg);
  font: inherit; font-size: 16.5px; line-height: 22px; resize: none; overflow-y: auto; }
.c-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.c-send { flex: none; width: 48px; height: 48px; border: 0; border-radius: 50%; background: var(--accent); color: var(--accent-fg); display: grid; place-items: center; }
.c-send:active { background: var(--accent-strong); }
.c-send:disabled { background: var(--line); color: var(--faint); cursor: default; }
.c-offnote { display: flex; align-items: center; gap: 8px; margin: 0; padding: 0 6px 8px; font-size: 13.5px; color: var(--warn); font-weight: 600; }
.c-offnote.gone { display: none; }
.c-readonly { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 10px; color: var(--muted); font-size: 15px; }

@media (prefers-reduced-motion: no-preference) {
  .chat { transition: transform .24s cubic-bezier(.2, .8, .2, 1), opacity .2s ease; }
  .m-toast { transition: transform .22s cubic-bezier(.2, .8, .2, 1), opacity .18s ease; }
  .c-spin { animation: spin .9s linear infinite; }
  @keyframes spin { to { transform: rotate(360deg); } }
}
@media (min-width: 760px) {
  .m-fab { right: calc(50% - 364px); }
}
