/* ===========================================================================
   CipherChat styles
   =========================================================================== */
:root {
  --green: #00a884;
  --green-dark: #008f72;
  --tick-blue: #53bdeb;
  --radius: 14px;
  --bubble-radius: 10px;
  --sidebar-w: 380px;
}

[data-theme='dark'] {
  --bg: #0b141a;
  --bg-2: #111b21;
  --panel: #202c33;
  --panel-2: #2a3942;
  --header: #202c33;
  --text: #e9edef;
  --muted: #8696a0;
  --border: #2a3942;
  --bubble-in: #202c33;
  --bubble-out: #005c4b;
  --chat-bg: #0b141a;
  --chat-pattern: rgba(255, 255, 255, 0.02);
  --hover: #202c33;
  --active: #2a3942;
  --input-bg: #2a3942;
  --shadow: rgba(0, 0, 0, 0.4);
}

[data-theme='light'] {
  --bg: #ffffff;
  --bg-2: #f0f2f5;
  --panel: #ffffff;
  --panel-2: #f0f2f5;
  --header: #f0f2f5;
  --text: #111b21;
  --muted: #667781;
  --border: #e9edef;
  --bubble-in: #ffffff;
  --bubble-out: #d9fdd3;
  --chat-bg: #efeae2;
  --chat-pattern: rgba(0, 0, 0, 0.02);
  --hover: #f5f6f6;
  --active: #f0f2f5;
  --input-bg: #ffffff;
  --shadow: rgba(0, 0, 0, 0.13);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.screen { height: 100dvh; }

svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---- buttons ---- */
.icon-btn {
  background: transparent; border: 0; color: var(--muted); cursor: pointer;
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.btn-primary {
  background: var(--green); color: #fff; border: 0; padding: 13px 18px;
  border-radius: var(--radius); font-size: 15px; font-weight: 600; cursor: pointer; width: 100%;
  transition: background .15s;
}
.btn-primary:hover { background: var(--green-dark); }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.btn-danger {
  background: transparent; color: #f15c6d; border: 1px solid #f15c6d; padding: 10px 14px;
  border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 600;
}
.btn-danger:hover { background: rgba(241, 92, 109, .1); }
.link-btn { background: none; border: 0; color: var(--green); cursor: pointer; font-size: 14px; padding: 4px 0; }

/* ---- safe-area helpers (iPhone notch / home indicator) ---- */
.safe-top    { padding-top:    max(10px, env(safe-area-inset-top)); }
.safe-bottom { padding-bottom: max(10px, env(safe-area-inset-bottom)); }

/* ---- auth (login + signup) ---- */
.auth-screen { display: grid; place-items: center; padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom)); background: var(--bg); overflow-y: auto; }
.auth-card {
  width: 100%; max-width: 400px; background: var(--panel); padding: 28px 24px 26px;
  border-radius: 20px; box-shadow: 0 10px 40px var(--shadow);
}
.brand { display: flex; align-items: center; gap: 12px; justify-content: center; }
.brand-logo { width: 44px; height: 44px; }
.brand h1 { font-size: 26px; font-weight: 700; }
.tagline { text-align: center; color: var(--muted); margin: 8px 0 22px; font-size: 14px; }
.auth-tabs { display: flex; gap: 4px; background: var(--bg); border-radius: 10px; padding: 4px; margin-bottom: 22px; }
.auth-tab { flex: 1; background: transparent; border: 0; color: var(--muted); padding: 10px 8px; border-radius: 7px; cursor: pointer; font-size: 14px; font-weight: 600; transition: background .15s, color .15s; }
.auth-tab.active { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px var(--shadow); }
.auth-form { display: block; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .name-edit {
  width: 100%; padding: 13px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--input-bg); color: var(--text); font-size: 16px; /* 16px = no iOS zoom-in */
}
.field input:focus { outline: none; border-color: var(--green); }
.hint { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }
.ob-status { text-align: center; margin-top: 14px; font-size: 14px; min-height: 20px; }
.ob-status.err { color: #f15c6d; }
.ob-status.ok { color: var(--green); }
.fineprint { font-size: 12px; color: var(--muted); margin-top: 18px; text-align: center; line-height: 1.5; }

/* ---- app shell ---- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100dvh; }

/* ---- sidebar ---- */
.sidebar { display: flex; flex-direction: column; background: var(--bg-2); border-right: 1px solid var(--border); min-width: 0; }
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: var(--header); min-height: 60px; position: sticky; top: 0; z-index: 6;
}
.sidebar-head.safe-top { padding-top: calc(10px + env(safe-area-inset-top)); }
.me { display: flex; align-items: center; gap: 12px; min-width: 0; }
.me-info { display: flex; flex-direction: column; min-width: 0; }
.me-info strong { font-size: 15px; }
.me-id { font-size: 12px; }
.sidebar-actions { display: flex; gap: 2px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--green); color: #fff;
  display: grid; place-items: center; font-weight: 600; font-size: 16px; flex: none; text-transform: uppercase;
  position: relative;
}
.avatar.big { width: 90px; height: 90px; font-size: 36px; }
/* live "online" green dot */
.avatar.is-online::after {
  content: '';
  position: absolute; bottom: 0; right: 0;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #25d366; /* WhatsApp-style green, distinct from --green so it pops on a green avatar */
  border: 2px solid var(--bg-2);
  box-shadow: 0 0 0 1px rgba(0,0,0,.2);
}
.avatar.big.is-online::after { width: 18px; height: 18px; border-width: 3px; }
/* notification permission banner */
.notif-banner {
  display: flex; align-items: center; gap: 10px; margin: 6px 10px 8px;
  padding: 12px 12px 12px 14px; background: var(--panel);
  border: 1px solid var(--green); border-radius: 12px;
  box-shadow: 0 2px 8px var(--shadow);
}
.notif-banner-icon { font-size: 22px; flex: none; }
.notif-banner-body { flex: 1; display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.notif-banner-body strong { font-size: 14px; }
.notif-banner-body span { font-size: 12px; line-height: 1.35; }
.notif-banner-btn { width: auto; padding: 9px 16px; font-size: 14px; flex: none; border-radius: 8px; }
.notif-banner-dismiss { width: 32px; height: 32px; flex: none; }
.notif-banner-dismiss svg { width: 16px; height: 16px; }
@media (max-width: 480px) {
  .notif-banner { flex-wrap: wrap; }
  .notif-banner-body { flex-basis: calc(100% - 60px); }
  .notif-banner-btn { width: 100%; margin-top: 4px; order: 99; }
}

.search { padding: 8px 12px; background: var(--bg-2); }
.search input {
  width: 100%; padding: 9px 14px; border-radius: 8px; border: 0; background: var(--input-bg);
  color: var(--text); font-size: 14px;
}
.search input:focus { outline: 1px solid var(--green); }
.chat-list { list-style: none; overflow-y: auto; flex: 1; }
.chat-item {
  display: flex; align-items: center; gap: 13px; padding: 10px 16px; cursor: pointer;
  border-bottom: 1px solid var(--border); min-width: 0;
}
.chat-item:hover { background: var(--hover); }
.chat-item.active { background: var(--active); }
.chat-item .ci-main { flex: 1; min-width: 0; }
.chat-item .ci-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.chat-item .ci-name { font-size: 16px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .ci-time { font-size: 12px; color: var(--muted); flex: none; }
.chat-item .ci-preview { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 5px; }
.badge {
  background: var(--green); color: #fff; border-radius: 11px; min-width: 20px; height: 20px;
  font-size: 12px; display: grid; place-items: center; padding: 0 6px; flex: none;
}
.conn-state { padding: 6px 16px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--border); display: flex; align-items: center; gap: 6px; }
.conn-state::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #f15c6d; }
.conn-state.online::before { background: var(--green); }

/* ---- conversation ---- */
.conversation { position: relative; min-width: 0; background: var(--chat-bg); }
.empty-state {
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; color: var(--muted); gap: 12px; padding: 40px;
}
.empty-state img { width: 90px; height: 90px; opacity: .85; }
.empty-state h2 { color: var(--text); font-weight: 600; }
.empty-state p { max-width: 420px; font-size: 14px; line-height: 1.6; }

.chat { height: 100dvh; display: flex; flex-direction: column; }
.chat-head {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--header);
  min-height: 60px; border-left: 1px solid var(--border); z-index: 5; position: sticky; top: 0;
}
.chat-head.safe-top { padding-top: calc(8px + env(safe-area-inset-top)); }
.chat-head .chat-head-actions { margin-left: auto; }
.peer-info { flex: 1; min-width: 0; display: flex; flex-direction: column; cursor: pointer; }
.peer-info strong { font-size: 16px; }
.chat-head-actions { display: flex; align-items: center; gap: 4px; }
.ttl-indicator { display: inline-flex; align-items: center; gap: 4px; color: var(--green); font-size: 12px; }
.ttl-indicator svg { width: 16px; height: 16px; }
.back-btn { display: none; }

.messages {
  flex: 1; overflow-y: auto; padding: 18px 8% 12px; display: flex; flex-direction: column; gap: 3px;
  background-image: radial-gradient(var(--chat-pattern) 1px, transparent 1px);
  background-size: 22px 22px;
}
.day-sep { align-self: center; background: var(--panel); color: var(--muted); font-size: 12px; padding: 5px 12px; border-radius: 8px; margin: 10px 0; box-shadow: 0 1px 1px var(--shadow); }

.bubble {
  max-width: min(70%, 560px); padding: 7px 9px 8px; border-radius: var(--bubble-radius);
  position: relative; box-shadow: 0 1px .5px var(--shadow); font-size: 14.5px; line-height: 1.4;
  word-wrap: break-word; overflow-wrap: anywhere; animation: pop .12s ease-out;
}
@keyframes pop { from { transform: scale(.96); opacity: .4; } to { transform: scale(1); opacity: 1; } }
.bubble.in { background: var(--bubble-in); align-self: flex-start; border-top-left-radius: 2px; }
.bubble.out { background: var(--bubble-out); align-self: flex-end; border-top-right-radius: 2px; }
.bubble + .bubble.same { margin-top: 1px; }
.bubble .reply-quote {
  border-left: 3px solid var(--green); background: rgba(0,0,0,.18); border-radius: 6px;
  padding: 4px 8px; margin-bottom: 4px; font-size: 13px; cursor: pointer;
}
.bubble .reply-quote .rq-name { color: var(--green); font-weight: 600; display: block; font-size: 12px; }
.bubble .reply-quote .rq-text { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.bubble .text { white-space: pre-wrap; }
.bubble .meta-line { display: flex; align-items: center; gap: 4px; justify-content: flex-end; margin-top: 2px; height: 15px; }
.bubble .time { font-size: 11px; color: var(--muted); }
.bubble.out .time { color: rgba(233,237,239,.6); }
.ticks { display: inline-flex; align-items: center; }
.ticks svg { width: 16px; height: 16px; stroke: rgba(233,237,239,.6); }
.ticks.read svg { stroke: var(--tick-blue); }
.bubble .lock { width: 12px; height: 12px; opacity: .5; stroke: currentColor; }

.bubble .msg-actions {
  position: absolute; top: 2px; right: 4px; opacity: 0; transition: opacity .12s;
  background: linear-gradient(transparent, var(--bubble-in)); border-radius: 6px;
}
.bubble:hover .msg-actions { opacity: 1; }
.bubble .reply-action { background: var(--panel); border: 0; color: var(--muted); border-radius: 50%; width: 26px; height: 26px; cursor: pointer; display: grid; place-items: center; box-shadow: 0 1px 3px var(--shadow); }
.bubble .reply-action svg { width: 15px; height: 15px; }

/* media bubbles */
.bubble img.media { max-width: 260px; border-radius: 8px; display: block; cursor: pointer; }
.bubble .file-chip { display: flex; align-items: center; gap: 10px; padding: 6px 4px; min-width: 200px; }
.bubble .file-chip .file-ic { width: 40px; height: 40px; border-radius: 8px; background: rgba(0,0,0,.2); display: grid; place-items: center; flex: none; }
.bubble .file-chip .file-meta { min-width: 0; }
.bubble .file-chip .fn { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.bubble .file-chip a { color: inherit; }
.voice { display: flex; align-items: center; gap: 10px; min-width: 200px; padding: 2px 0; }
.voice button.play { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--green); color: #fff; cursor: pointer; display: grid; place-items: center; flex: none; }
.voice .wave { flex: 1; height: 26px; display: flex; align-items: center; gap: 2px; }
.voice .wave i { flex: 1; background: var(--muted); border-radius: 2px; height: 30%; }
.voice .vdur { font-size: 12px; color: var(--muted); }

.system-note { align-self: center; background: rgba(0,0,0,.18); color: var(--muted); font-size: 12.5px; padding: 6px 14px; border-radius: 8px; margin: 8px 0; text-align: center; max-width: 80%; }

/* drag-over highlight when user is dragging a file in */
body.drop-active::after {
  content: 'Pusť obrázek pro odeslání';
  position: fixed; inset: 0;
  background: rgba(37,211,102,.15);
  border: 3px dashed #25d366;
  display: grid; place-items: center;
  color: #25d366; font-size: 22px; font-weight: 600;
  pointer-events: none; z-index: 200;
}

/* TOFU key-change warning banner */
.key-warning {
  display: flex; gap: 14px; align-items: flex-start;
  margin: 8px 0 14px; padding: 14px 16px;
  background: linear-gradient(135deg, rgba(239,68,68,.18), rgba(245,158,11,.12));
  border: 2px solid #ef4444; border-radius: 12px;
  align-self: stretch; max-width: 100%;
}
.kw-icon { font-size: 24px; flex: none; line-height: 1; }
.kw-body { flex: 1; min-width: 0; }
.kw-body strong { display: block; font-size: 15px; margin-bottom: 6px; color: #fca5a5; letter-spacing: .02em; }
.kw-body .small { font-size: 12.5px; line-height: 1.45; }
.kw-fp { background: rgba(0,0,0,.25); padding: 4px 8px; border-radius: 4px; margin-top: 6px; word-break: break-all; }
.kw-fp-new { border-left: 3px solid #ef4444; }
.kw-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.kw-actions button { flex: 1; min-width: 140px; padding: 9px 14px; font-size: 13px; }

/* verified contact badge → clickable */
.verified-badge { cursor: pointer; user-select: none; }
.verified-badge.verified-ok { background: rgba(34,197,94,.18); padding: 4px 10px; border-radius: 8px; color: #22c55e; }

/* sticker bubble — no background, just the art */
.bubble.sticker-bubble { background: transparent !important; box-shadow: none !important; padding: 2px 0 0; max-width: 160px; }
.bubble.sticker-bubble .sticker-art { width: 140px; height: 140px; display: block; }
.bubble.sticker-bubble .sticker-art svg { width: 100%; height: 100%; display: block; }
.bubble.sticker-bubble .meta-line { background: rgba(0,0,0,.3); border-radius: 8px; padding: 2px 6px; backdrop-filter: blur(4px); margin-top: -18px; align-self: flex-end; }

/* sticker picker (anchored above the composer) */
.sticker-picker {
  position: absolute; left: 12px; right: 12px; bottom: 70px; z-index: 10;
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 8px 32px var(--shadow); padding: 12px;
  max-height: 60vh; overflow-y: auto;
  animation: slideUp .15s ease-out;
}
@keyframes slideUp { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.sticker-picker-grid {
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
}
.sticker-tile {
  border: 0; background: transparent; cursor: pointer; padding: 6px;
  border-radius: 12px; transition: background .12s, transform .12s;
}
.sticker-tile:hover, .sticker-tile:active { background: var(--hover); transform: scale(1.05); }
.sticker-tile svg { width: 70px; height: 70px; display: block; margin: 0 auto; }
@media (max-width: 480px) {
  .sticker-picker { bottom: calc(70px + env(safe-area-inset-bottom)); }
  .sticker-picker-grid { grid-template-columns: repeat(4, 1fr); }
  .sticker-tile svg { width: 64px; height: 64px; }
}

/* prominent read/delivered/sent status line under the LAST outgoing bubble */
.receipt-line {
  align-self: flex-end; margin: 2px 4px 6px 0; font-size: 12px; color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 0;
}
.receipt-line::before { content: '✓'; color: var(--muted); }
.receipt-line.delivered::before { content: '✓✓'; color: var(--muted); letter-spacing: -2px; }
.receipt-line.read { color: var(--tick-blue); }
.receipt-line.read::before { content: '✓✓'; color: var(--tick-blue); letter-spacing: -2px; }

/* chat list "✓✓ Přečteno"-style indicator */
.ci-prev-text { display: inline-flex; align-items: center; gap: 4px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ci-rcpt { color: var(--muted); letter-spacing: -1px; flex: none; font-size: 12px; }
.ci-rcpt.read { color: var(--tick-blue); }
.ci-rcpt.delivered { color: var(--muted); }

/* ---- disappearing FAB ---- */
.ttl-fab-wrap { position: absolute; right: 22px; bottom: 86px; z-index: 6; }
.ttl-fab {
  display: flex; align-items: center; gap: 7px; background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 22px; padding: 8px 14px; cursor: pointer;
  box-shadow: 0 3px 12px var(--shadow); font-size: 13px;
}
.ttl-fab svg { width: 18px; height: 18px; color: var(--green); }
.ttl-fab.active { color: var(--green); border-color: var(--green); }
.ttl-menu {
  position: absolute; right: 0; bottom: 52px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 8px 28px var(--shadow); overflow: hidden; min-width: 170px;
}
.ttl-menu-title { padding: 10px 14px 6px; font-size: 12px; color: var(--muted); }
.ttl-menu button {
  display: block; width: 100%; text-align: left; background: transparent; border: 0; color: var(--text);
  padding: 10px 14px; cursor: pointer; font-size: 14px;
}
.ttl-menu button:hover { background: var(--hover); }
.ttl-menu button.sel { color: var(--green); font-weight: 600; }

/* ---- reply bar + composer ---- */
.reply-bar { display: flex; align-items: center; background: var(--panel); padding: 8px 16px; border-left: 3px solid var(--green); }
.reply-bar-content { flex: 1; min-width: 0; }
.reply-bar-name { color: var(--green); font-size: 13px; font-weight: 600; display: block; }
.reply-bar-text { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

.composer {
  display: flex; align-items: flex-end; gap: 6px; padding: 10px 12px;
  background: var(--header); border-left: 1px solid var(--border);
}
.composer.safe-bottom { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
.rec-overlay.safe-bottom { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
.composer textarea {
  flex: 1; resize: none; border: 0; border-radius: 10px; padding: 11px 14px; font-size: 15px;
  background: var(--input-bg); color: var(--text); max-height: 140px; line-height: 1.4;
  font-family: inherit;
}
.composer textarea:focus { outline: none; }
.send-btn, .mic-btn { background: var(--green); color: #fff; }
.send-btn:hover, .mic-btn:hover { background: var(--green-dark); color: #fff; }

/* ---- voice recording overlay ---- */
.rec-overlay { display: flex; align-items: center; gap: 14px; padding: 12px 18px; background: var(--header); border-left: 1px solid var(--border); }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: #f15c6d; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.rec-time { font-size: 16px; }
.rec-hint { color: var(--muted); flex: 1; }

/* ---- modal ---- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal-card { width: 100%; max-width: 420px; background: var(--panel); border-radius: 16px; padding: 22px; max-height: 86vh; overflow-y: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-head h3 { font-size: 18px; }
.directory { margin-top: 22px; }
.directory-title { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.directory-list { list-style: none; max-height: 240px; overflow-y: auto; }
.directory-list li { display: flex; align-items: center; gap: 12px; padding: 9px 6px; border-radius: 8px; cursor: pointer; }
.directory-list li:hover { background: var(--hover); }
.directory-list .du-name { font-size: 15px; }
.directory-list .du-id { font-size: 12px; color: var(--muted); }

/* ---- side panels ---- */
.panel { position: fixed; top: 0; right: 0; width: min(420px, 100%); height: 100dvh; background: var(--bg-2); z-index: 40; box-shadow: -4px 0 24px var(--shadow); display: flex; flex-direction: column; animation: slideIn .18s ease-out; }
@keyframes slideIn { from { transform: translateX(30px); opacity: .5; } to { transform: translateX(0); opacity: 1; } }
.panel-head { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--header); min-height: 60px; position: sticky; top: 0; z-index: 6; }
.panel-head.safe-top { padding-top: calc(14px + env(safe-area-inset-top)); }
.panel-head h3 { font-size: 18px; }
.panel-body { overflow-y: auto; padding: 8px 0 30px; }
.profile-block { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 26px 16px; }
.name-edit { max-width: 260px; text-align: center; font-size: 18px; }
.id-row { font-size: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; }
.ci-name { font-size: 20px; font-weight: 600; }
.setting-group { padding: 14px 18px; border-top: 8px solid var(--bg); }
.setting-group h4 { color: var(--green); font-size: 13px; margin-bottom: 12px; text-transform: uppercase; letter-spacing: .04em; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; }
.setting-row > label, .setting-row > div:first-child { flex: 1; }
.setting-group.danger { border-top-color: var(--bg); }
.verified-badge { color: var(--green); font-size: 13px; white-space: nowrap; }
select, .switch { accent-color: var(--green); }
select { background: var(--input-bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 14px; }
.switch { width: 44px; height: 26px; appearance: none; -webkit-appearance: none; background: var(--panel-2); border-radius: 14px; position: relative; cursor: pointer; transition: background .15s; flex: none; }
.switch::after { content: ''; position: absolute; width: 20px; height: 20px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: left .15s; }
.switch:checked { background: var(--green); }
.switch:checked::after { left: 21px; }
.app-version { text-align: center; padding: 24px 16px 0; }

/* ---- toast & lightbox ---- */
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: var(--panel); color: var(--text); padding: 12px 20px; border-radius: 10px; box-shadow: 0 6px 24px var(--shadow); z-index: 100; font-size: 14px; max-width: 90%; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); display: grid; place-items: center; z-index: 90; padding: 20px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

/* ---- responsive (mobile) ---- */
@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; height: 100dvh; }
  .conversation { position: fixed; inset: 0; z-index: 20; }
  .app:not(.show-chat) .conversation { display: none; }
  .app.show-chat .sidebar { display: none; }
  .back-btn { display: grid; }
  .messages { padding: 14px 4% 10px; }
  .bubble { max-width: 82%; }
  .ttl-fab-wrap { right: 14px; bottom: calc(80px + env(safe-area-inset-bottom)); }
  /* bigger tap targets on touch devices */
  .icon-btn { width: 44px; height: 44px; }
  .icon-btn svg { width: 22px; height: 22px; }
  .auth-card { padding: 22px 18px 22px; }
  .chat { height: 100dvh; }
  /* keep status bar from overlapping the topbars */
  .sidebar-head, .chat-head, .panel-head { min-height: 56px; }
}

/* iOS standalone PWA (installed via "Add to home screen") gets even safer insets */
@media (display-mode: standalone) {
  .sidebar-head, .chat-head, .panel-head { padding-top: calc(12px + env(safe-area-inset-top)); }
  .composer { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}
