:root {
  --bg: #0a0a0c;
  --surface: #121214;
  --elev: #1a1a1e;
  --fg: #f4f4f5;
  --muted: #a1a1aa;
  --accent: #e11d48;
  --border: #27272a;
  --gold: #e8b84a;
  --dev: #7dd3fc;
  --bubble-me: #e11d48;
  --bubble-other: #26262b;
  --wallpaper: none;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; background: var(--bg); color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: 15px; overflow: hidden; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.grow { flex: 1; min-width: 0; }
.row-name { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.mark-gold { color: var(--gold); font-size: 13px; }
.mark-dev { font-size: 10px; font-weight: 700; color: var(--dev); background: rgba(125,211,252,.12); padding: 1px 6px; border-radius: 999px; }
.mark-call { font-size: 10px; color: var(--muted); background: var(--elev); padding: 1px 6px; border-radius: 999px; }

#boot { position: fixed; inset: 0; display: grid; place-items: center; gap: 12px; background: var(--bg); z-index: 999; }
.bname { font-weight: 800; font-size: 22px; color: var(--accent); }
.view { position: fixed; inset: 0; }

/* AUTH */
#auth { display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 28px 22px; text-align: center; }
.auth-logo { margin-bottom: 10px; }
.auth-card h1 { font-size: 26px; color: var(--accent); }
.sub { color: var(--muted); margin: 6px 0 18px; font-size: 13px; }
.seg { display: flex; background: var(--elev); border-radius: 10px; padding: 3px; margin-bottom: 14px; }
.seg button { flex: 1; border: 0; background: transparent; color: var(--muted); padding: 10px; border-radius: 8px; font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--accent); color: #fff; }
form { display: flex; flex-direction: column; gap: 10px; text-align: left; }
input, textarea, select {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--elev); color: var(--fg); font: inherit; outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }
.primary { border: 0; border-radius: 12px; padding: 13px; background: var(--accent); color: #fff; font-weight: 700; cursor: pointer; font-size: 15px; }
.err { color: var(--accent); min-height: 18px; margin-top: 8px; font-size: 13px; }
.hint { margin-top: 14px; font-size: 12px; color: var(--muted); }

/* SHELL */
#shell { display: flex; flex-direction: column; padding-bottom: calc(64px + var(--safe-b)); }
.tab-pane { display: none; flex: 1; flex-direction: column; min-height: 0; overflow: hidden; }
.tab-pane.on { display: flex; }
.top { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 8px; }
.top h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.3px; }
.top-left { display: flex; align-items: center; gap: 10px; }
.logo-sm { width: 28px; height: 28px; border-radius: 8px; }
.top-actions { display: flex; gap: 2px; }
.ico { width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent; color: var(--fg); font-size: 18px; cursor: pointer; display: grid; place-items: center; }
.ico:active { background: var(--elev); }

.search-wrap { padding: 0 14px 8px; }
.search-wrap input { border: 0; background: var(--elev); }
.chips { display: flex; gap: 8px; padding: 0 14px 10px; overflow-x: auto; }
.chip { border: 0; background: var(--elev); color: var(--muted); padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; cursor: pointer; }
.chip.on { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); }

.status-strip, .story-row { display: flex; gap: 12px; padding: 6px 14px 12px; overflow-x: auto; }
.story {
  width: 72px; flex-shrink: 0; border: 0; background: transparent; color: inherit; cursor: pointer; text-align: center;
}
.story .ring { width: 56px; height: 56px; margin: 0 auto; border-radius: 50%; padding: 2px; background: linear-gradient(135deg, var(--accent), #fb7185); }
.story .ring.me { background: var(--border); }
.story .av { width: 100%; height: 100%; border: 2px solid var(--bg); }
.story span { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-list { flex: 1; overflow-y: auto; }
.item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 14px;
  border: 0; background: transparent; color: inherit; text-align: left; cursor: pointer;
}
.item:active { background: var(--elev); }
.av {
  width: 48px; height: 48px; border-radius: 50%; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 700; flex-shrink: 0;
  background-size: cover; background-position: center; overflow: hidden;
}
.av.sm { width: 40px; height: 40px; font-size: 14px; }
.av.lg { width: 72px; height: 72px; font-size: 28px; }
.av.xl { width: 110px; height: 110px; font-size: 40px; margin: 0 auto 16px; }
.item-body { flex: 1; min-width: 0; }
.item-top { display: flex; justify-content: space-between; gap: 8px; }
.preview { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.time { font-size: 11px; color: var(--muted); flex-shrink: 0; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.section-label { font-size: 13px; color: var(--muted); padding: 8px 14px; font-weight: 600; }
.muted-box { margin: 8px 14px; padding: 16px; border-radius: 12px; background: var(--elev); color: var(--muted); font-size: 13px; }

.call-quick { display: flex; gap: 10px; padding: 8px 14px 12px; }
.qbtn { flex: 1; border: 0; background: var(--elev); color: var(--fg); border-radius: 14px; padding: 14px 8px; font-weight: 600; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; }
.qbtn span { font-size: 20px; }

.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; height: calc(64px + var(--safe-b));
  padding-bottom: var(--safe-b); display: flex; background: var(--surface); border-top: 1px solid var(--border); z-index: 40;
}
.nav { flex: 1; border: 0; background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 600; cursor: pointer; }
.nav.on { color: var(--accent); }
.ni { font-size: 20px; line-height: 1; }

.me-card {
  display: flex; align-items: center; gap: 12px; width: calc(100% - 28px); margin: 8px 14px 16px;
  padding: 12px; border-radius: 14px; border: 1px solid var(--border); background: var(--elev);
  color: inherit; text-align: left; cursor: pointer;
}
.chev { color: var(--muted); font-size: 22px; }
.menu { padding: 0 6px 20px; }
.menu-item {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 10px;
  border: 0; background: transparent; color: inherit; text-align: left; cursor: pointer; border-radius: 12px;
}
.menu-item:active { background: var(--elev); }
.menu-item span { font-size: 20px; width: 28px; text-align: center; }
.menu-item b { display: block; font-size: 15px; }
.menu-item small { color: var(--muted); font-size: 12px; }

/* CHAT */
#chat { display: flex; flex-direction: column; background: var(--bg); }
.chat-bar {
  display: flex; align-items: center; gap: 4px; padding: 8px 6px;
  background: var(--surface); border-bottom: 1px solid var(--border); min-height: 56px;
}
.partner { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; border: 0; background: transparent; color: inherit; cursor: pointer; text-align: left; }
.msgs {
  flex: 1; overflow-y: auto; padding: 10px 12px 6px; display: flex; flex-direction: column; gap: 4px;
  background-color: var(--bg); background-image: var(--wallpaper); background-size: cover; background-position: center;
}
.msg {
  max-width: 78%; padding: 6px 10px 4px; border-radius: 12px; line-height: 1.35;
  word-break: break-word; font-size: 14.5px; animation: rise .15s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.msg.me { align-self: flex-end; background: var(--bubble-me); color: #fff; border-bottom-right-radius: 3px; }
.msg.other { align-self: flex-start; background: var(--bubble-other); color: var(--fg); border-bottom-left-radius: 3px; }
.msg .t { font-size: 10.5px; opacity: .7; margin-top: 2px; text-align: right; }
.msg.other .t { text-align: left; }
.msg .who { font-size: 11px; font-weight: 700; color: var(--accent); margin-bottom: 1px; }

.composer {
  display: flex; align-items: flex-end; gap: 6px; padding: 8px 8px calc(8px + var(--safe-b));
  background: var(--surface); border-top: 1px solid var(--border);
}
.input-wrap {
  flex: 1; display: flex; align-items: flex-end; background: var(--elev); border-radius: 22px; padding: 2px 4px 2px 12px;
}
#input {
  flex: 1; border: 0; background: transparent; color: var(--fg); resize: none;
  max-height: 100px; padding: 10px 0; line-height: 1.35; font-size: 15px;
}
.ico.in { width: 36px; height: 36px; font-size: 16px; color: var(--muted); }
.send {
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--accent);
  color: #fff; font-size: 16px; cursor: pointer; flex-shrink: 0;
}

/* SHEET */
.sheet { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.scrim { position: absolute; inset: 0; background: rgba(0,0,0,.6); }
.panel {
  position: relative; width: 100%; max-width: 480px; max-height: 92vh; overflow-y: auto;
  background: var(--surface); border-radius: 18px 18px 0 0; padding: 16px 16px calc(20px + var(--safe-b));
}
.panel h2 { font-size: 18px; margin-bottom: 12px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.toggle { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; font-size: 14px; gap: 12px; }
.sw { width: 48px; height: 28px; border-radius: 28px; border: 0; background: var(--elev); position: relative; cursor: pointer; flex-shrink: 0; }
.sw.on { background: var(--accent); }
.sw::after { content: ""; position: absolute; width: 22px; height: 22px; border-radius: 50%; background: #fff; left: 3px; top: 3px; transition: .15s; }
.sw.on::after { transform: translateX(20px); }
.themes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.theme-btn { border: 2px solid transparent; border-radius: 12px; padding: 12px 4px; background: var(--elev); color: var(--fg); font-size: 11px; font-weight: 600; cursor: pointer; }
.theme-btn.on { border-color: var(--accent); }
.color-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; font-size: 14px; }
.color-row input[type=color] { width: 40px; height: 30px; border: 0; background: transparent; }
.danger { width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--accent); background: transparent; color: var(--accent); font-weight: 600; cursor: pointer; margin-top: 8px; }
.btn-line { display: inline-block; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border); background: transparent; color: var(--fg); font-size: 13px; cursor: pointer; }
.banner { height: 100px; border-radius: 12px; background: var(--elev); background-size: cover; background-position: center; margin-bottom: 12px; }
.admin-card { border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 8px; }
.admin-card .acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.admin-card .acts button { padding: 7px 10px; border: 0; border-radius: 8px; background: var(--elev); color: var(--fg); font-size: 12px; cursor: pointer; }
.menu-list button {
  display: block; width: 100%; text-align: left; padding: 14px 12px; border: 0; background: transparent;
  color: var(--fg); font-size: 15px; cursor: pointer; border-radius: 10px;
}
.menu-list button:active { background: var(--elev); }

.call { position: fixed; inset: 0; z-index: 200; background: #0a0a0c; display: grid; place-items: center; padding: 24px; }
.call-ui { text-align: center; width: 100%; max-width: 320px; }
#call-vid { width: 100%; aspect-ratio: 16/9; border-radius: 16px; background: #000; margin-bottom: 14px; object-fit: cover; }
.cname { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.ctime { color: var(--accent); min-height: 22px; margin: 12px 0 24px; font-variant-numeric: tabular-nums; }
.cbtns { display: flex; justify-content: center; gap: 18px; }
.cbtn { width: 60px; height: 60px; border-radius: 50%; border: 0; background: rgba(255,255,255,.1); color: #fff; cursor: pointer; }
.cbtn.end { background: var(--accent); width: 68px; height: 68px; }

.toast {
  position: fixed; bottom: calc(80px + var(--safe-b)); left: 50%; transform: translateX(-50%);
  background: var(--elev); border: 1px solid var(--border); padding: 10px 16px; border-radius: 12px;
  font-size: 13px; z-index: 300; max-width: 90%;
}

body.glass .bottom, body.glass .chat-bar, body.glass .composer, body.glass .auth-card, body.glass .panel {
  background: rgba(18,18,20,.78); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}

@media (min-width: 900px) {
  #shell { max-width: 420px; border-right: 1px solid var(--border); }
  #chat:not(.hidden) { left: 420px; }
}
