/* Umbra - styl: ciemny, szklany, w duchu najnowszego iOS; stonowany akcent */
:root {
  --bg: #000;
  --surface: #131316;
  --surface2: #1d1d21;
  --surface3: #2a2a30;
  --text: #f4f4f6;
  --text2: #9b9ba5;
  --text3: #62626b;
  --sep: rgba(255, 255, 255, .08);
  --accent: #5a8cf5;
  --out: #3a68e6;
  --out-text: #fff;
  --in: #25252b;
  --danger: #ff5f57;
  --ok: #3ecf8e;
  --glass: rgba(24, 24, 28, .62);
  --glass-border: rgba(255, 255, 255, .12);
  --shadow: 0 8px 30px rgba(0, 0, 0, .45);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f2f2f7;
    --surface: #fff;
    --surface2: #f6f6f9;
    --surface3: #e5e5ea;
    --text: #0b0b0e;
    --text2: #6b6b76;
    --text3: #a2a2ab;
    --sep: rgba(0, 0, 0, .09);
    --in: #e6e6ec;
    --out: #2f66ee;
    --glass: rgba(255, 255, 255, .7);
    --glass-border: rgba(0, 0, 0, .08);
    --shadow: 0 8px 30px rgba(0, 0, 0, .14);
  }
}
:root[data-theme="light"] {
    --bg: #f2f2f7;
    --surface: #fff;
    --surface2: #f6f6f9;
    --surface3: #e5e5ea;
    --text: #0b0b0e;
    --text2: #6b6b76;
    --text3: #a2a2ab;
    --sep: rgba(0, 0, 0, .09);
    --in: #e6e6ec;
    --out: #2f66ee;
    --glass: rgba(255, 255, 255, .7);
    --glass-border: rgba(0, 0, 0, .08);
    --shadow: 0 8px 30px rgba(0, 0, 0, .14);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 16px/1.35 var(--font); -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
body { position: fixed; inset: 0; overflow: hidden; }
#app { position: absolute; inset: 0; }
button, input, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; padding: 0; cursor: pointer; }
svg { display: block; flex: none; }
.cell > svg { width: 22px; height: 22px; color: var(--text2); }
.banner svg { display: inline; width: 13px; height: 13px; vertical-align: -2px; }
.hidden { display: none !important; }

/* ---------- ekrany ---------- */
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--bg); }
.chat-screen { transform: translateX(100%); transition: transform .26s cubic-bezier(.3, .8, .3, 1); z-index: 5; }
.has-chat .chat-screen { transform: none; box-shadow: var(--shadow); }
.has-chat .list-screen { transform: translateX(-22%); transition: transform .26s cubic-bezier(.3, .8, .3, 1); }
.list-screen { transition: transform .26s cubic-bezier(.3, .8, .3, 1); }
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(26px) saturate(1.7);
  backdrop-filter: blur(26px) saturate(1.7);
  border: .5px solid var(--glass-border);
}

/* ---------- nagłówki ---------- */
.large-head { padding: calc(var(--sat) + 14px) 20px 6px; display: flex; align-items: flex-end; justify-content: space-between; }
.large-head h1 { margin: 0; font-size: 34px; letter-spacing: -.02em; font-weight: 700; }
.round-btn { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; }
.round-btn svg { width: 20px; height: 20px; }
.round-btn.glass { box-shadow: var(--shadow); }
.search { margin: 6px 16px 8px; position: relative; }
.search input { width: 100%; border: 0; outline: 0; border-radius: 12px; background: var(--surface2); padding: 9px 12px 9px 36px; font-size: 16px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text3); }

/* ---------- lista czatów ---------- */
.rows { padding-bottom: calc(var(--sab) + 110px); }
.row { display: flex; gap: 12px; align-items: center; padding: 9px 16px; width: 100%; text-align: left; }
.row:active { background: var(--surface2); }
.row .body { flex: 1; min-width: 0; border-bottom: .5px solid var(--sep); padding-bottom: 10px; margin-bottom: -10px; padding-top: 2px; }
.row .top { display: flex; align-items: baseline; gap: 8px; }
.row .name { font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .time { color: var(--text2); font-size: 13px; }
.row .sub { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.row .preview { flex: 1; color: var(--text2); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row.unread .preview { color: var(--text); font-weight: 500; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.empty { text-align: center; color: var(--text2); padding: 70px 36px; }
.empty .moon { width: 64px; height: 64px; margin: 0 auto 14px; opacity: .8; }
.empty b { display: block; color: var(--text); font-size: 18px; margin-bottom: 6px; }

.avatar { flex: none; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 600; letter-spacing: .02em; box-shadow: inset 0 0 0 .5px rgba(255, 255, 255, .18); }

/* ---------- pływający pasek kart ---------- */
.tabbar { position: absolute; left: 50%; bottom: calc(var(--sab) + 14px); transform: translateX(-50%); display: flex; gap: 4px; padding: 5px; border-radius: 32px; box-shadow: var(--shadow); z-index: 3; }
.tab { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 26px 6px; border-radius: 26px; color: var(--text2); font-size: 11px; font-weight: 600; position: relative; }
.tab svg { width: 24px; height: 24px; }
.tab.active { color: var(--accent); background: rgba(127, 127, 140, .2); }
.tab .badge { position: absolute; top: 2px; right: 12px; min-width: 17px; height: 17px; font-size: 11px; padding: 0 4px; }

/* ---------- czat ---------- */
.chat-head { position: absolute; top: 0; left: 0; right: 0; z-index: 4; padding: calc(var(--sat) + 8px) 12px 10px; display: flex; align-items: center; gap: 8px; border-width: 0 0 .5px; }
.chat-head .back { display: flex; align-items: center; gap: 0; color: var(--accent); padding: 6px 4px; }
.chat-head .back svg { width: 22px; height: 22px; }
.chat-head .who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; text-align: left; }
.chat-head .who .t { min-width: 0; }
.chat-head .who b { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .who small { display: block; color: var(--text2); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .info { color: var(--accent); }
.msgs { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: calc(var(--sat) + 72px) 12px calc(var(--sab) + 84px); display: flex; flex-direction: column; }
.banner { align-self: center; text-align: center; color: var(--text2); font-size: 12px; background: var(--surface); padding: 7px 12px; border-radius: 14px; margin: 4px 0 12px; max-width: 86%; }
.banner.warn { color: var(--danger); background: rgba(255, 95, 87, .12); }
.day { align-self: center; color: var(--text2); font-size: 12px; font-weight: 600; margin: 12px 0 8px; }
.msg { display: flex; flex-direction: column; max-width: 78%; margin-top: 2px; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.msg.in { align-self: flex-start; align-items: flex-start; }
.msg.first { margin-top: 9px; }
.msg .who { font-size: 12px; color: var(--text2); margin: 0 12px 2px; }
.bubble { padding: 8px 13px; border-radius: 20px; word-break: break-word; white-space: pre-wrap; user-select: text; -webkit-user-select: text; }
.msg.in .bubble { background: var(--in); border-bottom-left-radius: 6px; }
.msg.out .bubble { background: var(--out); color: var(--out-text); border-bottom-right-radius: 6px; }
.msg.in:not(.first) .bubble { border-top-left-radius: 6px; }
.msg.out:not(.first) .bubble { border-top-right-radius: 6px; }
.msg.in:not(.last) .bubble { border-bottom-left-radius: 6px; }
.msg.out:not(.last) .bubble { border-bottom-right-radius: 6px; }
.msg.pending .bubble { opacity: .6; }
.msg.failed .bubble { background: rgba(255, 95, 87, .2); color: var(--danger); }
.msg .meta { font-size: 11px; color: var(--text3); margin: 3px 12px 0; }
.bubble.undecryptable { font-style: italic; color: var(--text2); background: transparent !important; border: .5px dashed var(--sep); }
.bubble a { color: inherit; text-decoration: underline; }
.bubble.media { padding: 0; overflow: hidden; background: var(--surface2) !important; }
.bubble.media img { display: block; max-width: 100%; height: auto; }
.bubble.media .ph { display: grid; place-items: center; color: var(--text3); background: var(--surface2); }
.filecard { display: flex; align-items: center; gap: 11px; padding: 9px 12px 9px 9px; text-align: left; min-width: 210px; }
.filecard .ic { width: 40px; height: 40px; border-radius: 10px; background: rgba(255, 255, 255, .18); display: grid; place-items: center; flex: none; }
.filecard .ic svg { width: 22px; height: 22px; }
.filecard .nm { font-weight: 600; font-size: 15px; word-break: break-all; }
.filecard .sz { font-size: 12px; opacity: .75; }

.composer { position: absolute; left: 10px; right: 10px; bottom: calc(var(--sab) + 10px); display: flex; align-items: flex-end; gap: 8px; z-index: 4; }
.composer .attach { flex: none; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; box-shadow: var(--shadow); color: var(--text2); }
.composer .attach svg { width: 22px; height: 22px; }
.composer .field { flex: 1; border-radius: 22px; padding: 5px 5px 5px 15px; display: flex; align-items: flex-end; gap: 6px; box-shadow: var(--shadow); min-height: 42px; }
.composer textarea { flex: 1; border: 0; outline: 0; background: none; resize: none; padding: 6px 0; max-height: 120px; line-height: 1.3; font-size: 16px; }
.composer textarea::placeholder { color: var(--text3); }
.send { flex: none; width: 32px; height: 32px; margin-bottom: 1px; border-radius: 50%; background: var(--out); color: #fff; display: grid; place-items: center; transition: transform .12s, opacity .12s; }
.send svg { width: 18px; height: 18px; }
.send:disabled { opacity: 0; transform: scale(.6); pointer-events: none; }

/* ---------- ustawienia ---------- */
.page-pad { padding: 0 16px calc(var(--sab) + 120px); }
.card { background: var(--surface); border-radius: 16px; margin: 12px 0; overflow: hidden; }
.card .hd { padding: 14px 16px 4px; font-size: 13px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .04em; }
.cell { display: flex; align-items: center; gap: 12px; padding: 12px 16px; width: 100%; text-align: left; border-top: .5px solid var(--sep); min-height: 48px; }
.card > .cell:first-child, .card .hd + .cell { border-top: 0; }
.cell .grow { flex: 1; min-width: 0; }
.cell small { color: var(--text2); display: block; font-size: 13px; }
.cell.danger { color: var(--danger); }
.cell.tap:active { background: var(--surface2); }
.profile { display: flex; align-items: center; gap: 14px; padding: 18px 16px; }
.profile b { font-size: 20px; display: block; }
.profile small { color: var(--text2); }
.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .02em; }
.safety { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 10px; padding: 14px 16px; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 17px; text-align: center; }
.switch { width: 51px; height: 31px; border-radius: 16px; background: var(--surface3); position: relative; transition: background .2s; flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, .3); transition: transform .2s; }
.switch.on { background: var(--ok); }
.switch.on::after { transform: translateX(20px); }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--surface3); color: var(--text2); font-weight: 600; }
.pill.ok { background: rgba(62, 207, 142, .15); color: var(--ok); }
.pill.warn { background: rgba(255, 95, 87, .15); color: var(--danger); }

/* ---------- arkusze / okna ---------- */
.backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .45); z-index: 20; animation: fade .2s; }
.sheet { position: absolute; left: 8px; right: 8px; bottom: calc(var(--sab) + 8px); max-height: 86%; z-index: 21; border-radius: 28px; background: var(--surface); box-shadow: var(--shadow); display: flex; flex-direction: column; animation: up .26s cubic-bezier(.3, .8, .3, 1); overflow: hidden; }
.sheet .grab { width: 36px; height: 5px; border-radius: 3px; background: var(--surface3); margin: 8px auto 0; flex: none; }
.sheet h2 { margin: 12px 20px 4px; font-size: 20px; }
.sheet .sub { margin: 0 20px 8px; color: var(--text2); font-size: 14px; }
.sheet .content { overflow-y: auto; padding: 4px 0 8px; }
.sheet .actions { display: flex; gap: 10px; padding: 8px 16px 16px; flex: none; }
.btn { flex: 1; padding: 13px; border-radius: 14px; background: var(--surface3); font-weight: 600; text-align: center; }
.btn.primary { background: var(--out); color: #fff; }
.btn.danger { background: rgba(255, 95, 87, .16); color: var(--danger); }
.btn:disabled { opacity: .45; }
.field-in { display: block; margin: 8px 16px; }
.field-in span { display: block; font-size: 13px; color: var(--text2); margin: 0 4px 5px; }
.field-in input { width: 100%; border: 0; outline: 0; background: var(--surface2); border-radius: 12px; padding: 12px 14px; font-size: 17px; }
.check { width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--text3); display: grid; place-items: center; flex: none; color: transparent; }
.check svg { width: 14px; height: 14px; }
.cell.sel .check { background: var(--accent); border-color: var(--accent); color: #fff; }
.toast { position: absolute; top: calc(var(--sat) + 12px); left: 50%; transform: translateX(-50%); z-index: 40; padding: 10px 16px; border-radius: 20px; font-size: 14px; max-width: 90%; text-align: center; animation: drop .25s; box-shadow: var(--shadow); }
.viewer { position: absolute; inset: 0; z-index: 30; background: rgba(0, 0, 0, .95); display: flex; flex-direction: column; animation: fade .2s; }
.viewer img { flex: 1; min-height: 0; object-fit: contain; width: 100%; padding: calc(var(--sat) + 56px) 0 calc(var(--sab) + 20px); }
.viewer .x { position: absolute; top: calc(var(--sat) + 10px); right: 14px; color: #fff; }

/* ---------- ekran startowy / rejestracja / pauza ---------- */
.center { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: calc(var(--sat) + 20px) 28px calc(var(--sab) + 20px); max-width: 460px; width: 100%; margin: 0 auto; }
.logo { width: 92px; height: 92px; border-radius: 24px; margin: 0 auto 18px; display: block; box-shadow: 0 10px 40px rgba(90, 140, 245, .22), 0 0 0 .5px rgba(255, 255, 255, .18); }
.center h1 { text-align: center; margin: 0; font-size: 32px; letter-spacing: -.02em; }
.center p.lead { text-align: center; color: var(--text2); margin: 6px 0 26px; }
.center .field-in { margin: 8px 0; }
.center .btn { margin-top: 14px; flex: none; width: 100%; padding: 15px; font-size: 17px; }
.err { color: var(--danger); text-align: center; font-size: 14px; margin-top: 12px; min-height: 18px; }
.hint { background: var(--surface); border-radius: 18px; padding: 16px 18px; color: var(--text2); font-size: 15px; line-height: 1.5; }
.hint b { color: var(--text); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--surface3); border-top-color: var(--accent); animation: spin .8s linear infinite; margin: 0 auto; }
.big-code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 24px; text-align: center; padding: 18px 8px; letter-spacing: .06em; user-select: all; -webkit-user-select: all; }

@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes drop { from { transform: translate(-50%, -20px); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.seg { display: flex; gap: 4px; background: var(--surface2); border-radius: 12px; padding: 3px; margin: 4px 16px 14px; }
.seg button { flex: 1; padding: 8px 4px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--text2); }
.seg button.on { background: var(--surface3); color: var(--text); }
.empty .moon svg { width: 100%; height: 100%; }
.scroll, .msgs, .sheet .content { scrollbar-width: none; }
.scroll::-webkit-scrollbar, .msgs::-webkit-scrollbar, .sheet .content::-webkit-scrollbar { display: none; }
