: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: 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: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; overflow: hidden; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .tiny { font-size: 12px; } .grow { flex: 1; min-width: 0; }
.nm { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.nm.light, .light { color: #fff; }
.badge-gold { color: var(--gold); } .badge-dev { font-size: 10px; font-weight: 700; color: var(--dev); background: rgba(125,211,252,.12); padding: 1px 6px; border-radius: 999px; }

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

#auth { display: grid; place-items: center; padding: 20px; }
.card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 28px 22px; text-align: center; }
.card h1 { color: var(--accent); margin-top: 8px; font-size: 26px; }
.sub { color: var(--muted); font-size: 13px; margin: 6px 0 16px; }
.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; }
.stack { 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); }
.btn { border: 0; border-radius: 12px; padding: 13px; background: var(--accent); color: #fff; font-weight: 700; cursor: pointer; font-size: 15px; width: 100%; }
.err { color: var(--accent); min-height: 18px; margin-top: 8px; font-size: 13px; }
.hint { margin-top: 12px; font-size: 12px; color: var(--muted); }

#shell { display: flex; flex-direction: column; padding-bottom: calc(64px + var(--safe)); }
.pane { display: none; flex: 1; flex-direction: column; min-height: 0; overflow: hidden; }
.pane.on { display: flex; }
.top { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 8px; }
.top h1 { font-size: 22px; font-weight: 800; }
.brand { display: flex; align-items: center; gap: 10px; }
.top-btns { display: flex; }
.ico { width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent; color: var(--fg); display: grid; place-items: center; cursor: pointer; }
.ico:active { background: var(--elev); }
.ico.light { color: #fff; }
.search-wrap { padding: 0 14px 8px; }
.search-wrap input { border: 0; }
.filters { 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; cursor: pointer; white-space: nowrap; }
.chip.on { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); }
.scroll { flex: 1; overflow-y: auto; }

.item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 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; }
.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); }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }

/* Status board */
.status-mine, .status-row {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px;
  border: 0; background: transparent; color: inherit; text-align: left; cursor: pointer;
}
.status-mine:active, .status-row:active { background: var(--elev); }
.ring { padding: 2px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), #fb7185); display: inline-block; }
.ring.off { background: var(--border); }
.ring .av { border: 2px solid var(--bg); }
.section-h { font-size: 13px; font-weight: 600; color: var(--muted); padding: 8px 14px; }

.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; height: calc(64px + var(--safe));
  padding-bottom: var(--safe); 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); }

.me-card {
  display: flex; align-items: center; gap: 12px; margin: 8px 14px 16px; padding: 12px;
  border-radius: 14px; border: 1px solid var(--border); background: var(--elev); color: inherit; width: calc(100% - 28px); text-align: left; cursor: pointer;
}
.menu { padding: 0 8px 24px; }
.mi { display: block; width: 100%; text-align: left; padding: 14px 12px; border: 0; background: transparent; color: var(--fg); font-size: 15px; border-radius: 10px; cursor: pointer; }
.mi:active { background: var(--elev); }
.mi.danger { color: var(--accent); }

#chat { display: flex; flex-direction: column; }
.chat-bar { display: flex; align-items: center; gap: 2px; padding: 8px 4px; 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; display: flex; flex-direction: column; gap: 4px; background-image: var(--wallpaper); background-size: cover; background-position: center; }
.msg { max-width: 78%; padding: 6px 10px 4px; border-radius: 12px; word-break: break-word; font-size: 14.5px; }
.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); border-bottom-left-radius: 3px; }
.msg .t { font-size: 10.5px; opacity: .7; margin-top: 2px; text-align: right; }
.msg .who { font-size: 11px; font-weight: 700; color: var(--accent); margin-bottom: 1px; }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 8px 8px calc(8px + var(--safe)); background: var(--surface); border-top: 1px solid var(--border); }
.pill { flex: 1; background: var(--elev); border-radius: 22px; padding: 2px 14px; }
#input { border: 0; background: transparent; resize: none; max-height: 100px; padding: 10px 0; }
.send { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; cursor: pointer; }

/* Status viewer */
#status-view { background: #000; z-index: 150; display: flex; flex-direction: column; }
.sv-bg { position: absolute; inset: 0; background: linear-gradient(160deg, #1a0510, #0a0a0c 50%, #120808); }
.sv-top { position: relative; z-index: 2; display: flex; align-items: center; gap: 8px; padding: 12px 8px; padding-top: max(12px, env(safe-area-inset-top)); }
.sv-user { display: flex; align-items: center; gap: 10px; flex: 1; }
.sv-body { position: relative; z-index: 2; flex: 1; display: grid; place-items: center; padding: 24px; text-align: center; font-size: 22px; font-weight: 600; line-height: 1.4; color: #fff; white-space: pre-wrap; }
.sv-bar { position: absolute; top: max(6px, env(safe-area-inset-top)); left: 8px; right: 8px; height: 3px; background: rgba(255,255,255,.25); border-radius: 2px; z-index: 3; overflow: hidden; }
.sv-bar i { display: block; height: 100%; width: 0%; background: #fff; border-radius: 2px; }

.call { background: #0a0a0c; display: grid; place-items: center; z-index: 200; }
.call-ui { text-align: center; width: 100%; max-width: 320px; padding: 24px; }
#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; }

.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: 90vh; overflow-y: auto; background: var(--surface); border-radius: 18px 18px 0 0; padding: 16px 16px calc(20px + var(--safe)); }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.panel h2 { font-size: 18px; }
.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; 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; }
.color-row input[type=color] { width: 40px; height: 30px; border: 0; background: transparent; }
.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; }
.acc-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--border); margin-bottom: 8px; background: transparent; color: inherit; text-align: left; cursor: pointer; }
.acc-row.on { border-color: var(--accent); }

.toast { position: fixed; bottom: calc(80px + var(--safe)); 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 .card, body.glass .panel {
  background: rgba(18,18,20,.78); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
