:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #15181d;
  --muted: #6b7280;
  --line: #e3e6eb;
  --accent: #2f6fed;
  --accent-soft: #e8effd;
  --ok: #1f9d55;
  --err: #d93a3a;
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #181b21;
    --text: #e8eaef;
    --muted: #9aa1ad;
    --line: #2a2f38;
    --accent: #6b97ff;
    --accent-soft: #1d2740;
    --ok: #3fbf7a;
    --err: #ff6b6b;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }

.screen {
  max-width: 560px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px 16px;
}
.muted { color: var(--muted); }
.small { font-size: 14px; }
.brand { font-size: 26px; font-weight: 700; display: flex; align-items: center; gap: 10px; margin: 8px 0 12px; }
.small-brand { font-size: 18px; margin: 0; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 7px; flex: none;
  background: linear-gradient(135deg, var(--accent), #8fb0ff);
}

.btn {
  font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 16px; cursor: pointer; text-decoration: none; display: inline-block;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.big { width: 100%; padding: 16px; font-size: 18px; font-weight: 600; margin: 12px 0; }
.btn.icon { padding: 10px 12px; }
.btn.small { padding: 6px 12px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }

.qr {
  background: #fff; border-radius: var(--radius); padding: 16px;
  display: flex; justify-content: center; margin: 12px 0;
}
.qr svg, .qr img { width: min(100%, 300px); height: auto; display: block; }
.status { color: var(--muted); font-size: 14px; }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }

.chat { display: flex; flex-direction: column; min-height: 100dvh; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.top { display: flex; align-items: center; justify-content: space-between; padding: 4px 0 10px; }
.feed { flex: 1; display: flex; flex-direction: column; gap: 8px; padding-bottom: 8px; }
.empty { text-align: center; margin: 24px 0; }
.composer { display: flex; gap: 8px; position: sticky; bottom: 0; background: var(--bg); padding-top: 8px; }
.text {
  flex: 1; min-width: 0; font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px;
}

.bubble {
  max-width: 86%; padding: 10px 14px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line); word-break: break-word;
}
.bubble.out { align-self: flex-end; background: var(--accent-soft); border-color: transparent; }
.bubble.in { align-self: flex-start; }
.bubble .name { font-weight: 600; }
.bubble .meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.bubble .meta.ok { color: var(--ok); }
.bubble .meta.err { color: var(--err); }
.bubble img.preview { display: block; max-width: 100%; max-height: 240px; border-radius: 10px; margin-top: 8px; }
.bubble a.save { display: inline-block; margin-top: 8px; }
.bar { height: 6px; background: var(--line); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }

.note { text-align: center; margin: 8px 0 16px; }
