:root {
  --bg: #0a0f18;
  --panel: #121a28;
  --panel-2: #182233;
  --line: #2a364c;
  --text: #e9eef8;
  --muted: #8b9bb4;
  --accent: #3ec7d6;
  --accent-dim: #1a6f7a;
  --accent-soft: rgba(62, 199, 214, 0.14);
  --warn: #c4a574;
  --warn-bg: rgba(160, 110, 50, 0.22);
  --danger: #e07070;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; min-height: 100%;
  background: var(--bg); color: var(--text);
  font: 16px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
body {
  max-width: 430px; margin: 0 auto;
  min-height: 100dvh;
}

.screen { display: none; min-height: 100dvh; flex-direction: column; }
.screen.on { display: flex; }

/* —— Login —— */
.login-wrap {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  padding: calc(24px + var(--safe-t)) 24px calc(28px + var(--safe-b));
}
.eyes {
  display: flex; gap: 14px; justify-content: center; margin-bottom: 22px;
}
.eyes span {
  width: 14px; height: 36px; border-radius: 7px;
  background: var(--accent); box-shadow: 0 0 18px rgba(62, 199, 214, 0.45);
}
.login-wrap h1 {
  margin: 0; text-align: center; font-size: 1.55rem; font-weight: 700;
}
.sub {
  text-align: center; color: var(--muted); margin: 8px 0 20px; font-size: 0.95rem;
}
.net-badge {
  align-self: center; margin-bottom: 22px;
  padding: 8px 14px; border-radius: 999px; font-size: 0.82rem;
  border: 1px solid var(--line); color: var(--muted); background: var(--panel);
}
.net-badge.ok {
  border-color: var(--accent-dim); color: var(--accent); background: var(--accent-soft);
}
.net-badge.searching { opacity: 0.85; }
.net-badge.fail { color: var(--danger); border-color: #5a3030; }

.stack { display: flex; flex-direction: column; gap: 14px; }
label {
  display: block; font-size: 0.8rem; color: var(--muted);
}
label input, .pw-row input {
  margin-top: 6px; width: 100%;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 13px 14px;
  color: var(--text); font: inherit;
}
.pw-row { display: flex; gap: 8px; align-items: stretch; margin-top: 6px; }
.pw-row input { margin-top: 0; }

.btn {
  border: 1px solid var(--line); background: var(--panel);
  color: var(--text); border-radius: 12px; padding: 13px 16px;
  font: inherit; font-weight: 600; cursor: pointer;
}
.btn.primary {
  background: var(--accent); color: #062028; border-color: var(--accent);
}
.btn.block { width: 100%; }
.btn.send {
  width: 48px; height: 48px; padding: 0; border-radius: 14px;
  font-size: 1.2rem; flex-shrink: 0;
}
.btn:disabled { opacity: 0.45; }

.icon-btn {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; color: var(--muted); min-width: 48px;
  cursor: pointer; font: inherit;
}
.fine { text-align: center; color: var(--muted); font-size: 0.78rem; margin: 14px 0 8px; }
.fine.muted { opacity: 0.75; }
.linkish {
  background: none; border: 0; color: var(--accent); font: inherit;
  cursor: pointer; text-align: center; padding: 8px; text-decoration: underline;
  text-underline-offset: 3px;
}
.linkish.danger { color: var(--danger); font-size: 0.85rem; }

.adv {
  margin-top: 18px; border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; background: var(--panel);
}
.adv summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; }
.adv label { margin-top: 12px; }
.msg { font-size: 0.85rem; min-height: 1.3em; margin: 8px 0 0; color: var(--muted); }
.msg.ok { color: var(--accent); }
.msg.err { color: var(--danger); }

/* —— Setup —— */
.bar {
  display: flex; gap: 12px; align-items: center;
  padding: calc(14px + var(--safe-t)) 16px 12px;
  border-bottom: 1px solid var(--line);
}
.bar-title { font-weight: 700; }
.bar-sub { font-size: 0.78rem; color: var(--muted); }
.pad { padding: 20px 18px calc(24px + var(--safe-b)); }
.hint { color: var(--muted); font-size: 0.92rem; margin: 0 0 14px; }
.steps { color: var(--text); padding-left: 1.2rem; line-height: 1.7; }
.steps code {
  background: var(--panel); padding: 1px 6px; border-radius: 6px; color: var(--accent);
}

/* —— App shell —— */
.top {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: calc(12px + var(--safe-t)) 16px 8px;
}
.brand { font-size: 1.35rem; font-weight: 700; letter-spacing: 0.02em; color: var(--accent); }
.status { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }
.status .dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); margin-right: 6px; vertical-align: middle;
}
.who-pill {
  font-size: 0.78rem; padding: 6px 10px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line); color: var(--muted);
}

#screen-app { position: relative; }
#screen-app .panel {
  display: none; flex: 1; flex-direction: column; min-height: 0;
  padding: 0 14px;
}
#screen-app .panel.on { display: flex; }

.log {
  flex: 1; overflow: auto; padding: 8px 2px 12px;
  display: flex; flex-direction: column; gap: 10px;
}
.bubble {
  max-width: 88%; padding: 11px 13px; border-radius: 16px;
  background: var(--panel); border: 1px solid var(--line);
  white-space: pre-wrap; word-break: break-word;
}
.bubble.me { align-self: flex-end; background: var(--panel-2); border-color: var(--accent-dim); }
.bubble.lio { align-self: flex-start; }
.bubble .meta { display: block; font-size: 0.7rem; color: var(--muted); margin-bottom: 4px; }
.bubble img {
  display: block; width: 100%; max-width: 260px; border-radius: 10px;
  margin-top: 8px; border: 1px solid var(--line);
}

.live-cards { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.live-card {
  background: var(--warn-bg); border: 1px solid rgba(196, 165, 116, 0.35);
  border-radius: 12px; padding: 10px 12px; color: var(--warn); font-size: 0.88rem;
}
.live-card strong { display: block; color: var(--text); margin-bottom: 2px; }

.composer-wrap {
  border-top: 1px solid var(--line);
  padding: 8px 0 calc(8px + var(--safe-b));
  background: var(--bg);
}
.chips { display: flex; gap: 8px; margin-bottom: 8px; overflow-x: auto; }
.chips button {
  flex: 0 0 auto; border: 1px solid var(--line); background: var(--panel);
  color: var(--text); border-radius: 999px; padding: 8px 14px;
  font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer;
}
.composer { display: flex; gap: 8px; align-items: center; }
.composer input {
  flex: 1; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 13px 14px; color: var(--text); font: inherit;
}

.pad-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.pad-grid button {
  padding: 20px 12px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--panel);
  color: var(--text); font: inherit; font-weight: 650; cursor: pointer;
}
.out {
  margin-top: 14px; padding: 12px; min-height: 4rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  white-space: pre-wrap; color: var(--muted); font-size: 0.85rem;
}

.photos-head {
  display: flex; justify-content: space-between; align-items: center;
}
.gallery {
  display: grid; gap: 12px; padding-bottom: 12px; overflow: auto; flex: 1;
}
.gallery .card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.gallery img { width: 100%; display: block; background: #000; }
.gallery .cap {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px; padding: 10px 12px; font-size: 0.85rem; color: var(--muted);
}
.gallery .cap button {
  border: 0; background: transparent; color: var(--danger);
  font: inherit; font-size: 0.8rem; cursor: pointer; text-decoration: underline;
}

.tabs {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 4px; padding: 6px 10px calc(10px + var(--safe-b));
  border-top: 1px solid var(--line); background: var(--bg);
}
.tab {
  background: transparent; border: 0; color: var(--muted);
  padding: 10px 4px; border-radius: 12px; font: inherit; font-weight: 600;
  font-size: 0.82rem; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tab.on { background: var(--panel); color: var(--text); }
.tab-ico {
  width: 18px; height: 18px; border-radius: 4px;
  background: var(--line); display: block;
}
.tab.on .tab-ico { background: var(--accent); }
.tab[data-tab="chat"] .tab-ico { border-radius: 50%; }
.tab[data-tab="remote"] .tab-ico { width: 20px; height: 14px; }
.tab[data-tab="photos"] .tab-ico { border-radius: 3px; width: 16px; height: 16px; }
