:root {
  --bg: #090c10;
  --surface: #121821;
  --surface-2: #1a222e;
  --border: #263142;
  --text: #eef3f8;
  --muted: #8a9bb0;
  --accent: #00d084;
  --danger: #ff4757;
  --warn: #ffa502;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh; overscroll-behavior: none;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.container { max-width: 480px; margin: 0 auto; padding: 20px 16px 40px; }
.app-shell {
  max-width: 480px; margin: 0 auto; min-height: 100dvh;
  display: flex; flex-direction: column; padding-bottom: 72px;
}

.brand-header { text-align: center; margin-bottom: 18px; }
.brand-row { display: inline-flex; align-items: center; gap: 10px; }
.brand-header h1 { margin: 0; font-size: 1.9rem; letter-spacing: 3px; }
.subtitle { margin: 6px 0 0; color: var(--muted); font-size: 0.9rem; }

.led { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.led-green { background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.led-amber { background: var(--warn); box-shadow: 0 0 10px var(--warn); }
.led-red { background: var(--danger); box-shadow: 0 0 10px var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:0.35;} }

.badge {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--accent);
  font-size: 0.72rem; font-weight: 700; padding: 3px 8px; border-radius: 99px; letter-spacing: 1px;
}

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; margin-bottom: 14px;
}
.card-subtle { background: transparent; border-style: dashed; }
.card h2, .card h3 { margin-top: 0; }

.banner {
  border-radius: 10px; padding: 11px 14px; font-size: 0.86rem; line-height: 1.4; margin-bottom: 12px;
}
.banner-info { background: #132235; border: 1px solid #24456b; color: #c7e0ff; }
.banner-accent { background: #0c2b21; border: 1px solid #155c42; color: #b9ffe3; }
.banner-warn { background: #2c200d; border: 1px solid #6b4913; color: #ffe0a3; }
.banner a, .banner a:link, .banner a:visited, .banner a:hover, .banner a:active {
  color: #00d084 !important; font-weight: 700; text-decoration: underline;
}

.plans-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.plan-card {
  background: var(--surface-2); border: 2px solid var(--border); border-radius: 12px;
  padding: 12px; text-align: left; cursor: pointer; color: var(--text); transition: 0.15s;
}
.plan-card.selected { border-color: var(--accent); background: #0e241d; }
.plan-card.disabled { opacity: 0.42; cursor: not-allowed; }
.plan-title { font-weight: 700; font-size: 1rem; }
.plan-price { color: var(--accent); font-weight: 700; font-size: 0.92rem; margin-top: 4px; }
.plan-note { color: var(--muted); font-size: 0.75rem; margin-top: 2px; }

.field-group { margin-bottom: 12px; }
.field-group label { display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 5px; }
input[type="text"], input[type="password"], select, textarea.mono-input {
  width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 11px 12px; font-size: 1rem; outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
.mono-input { font-family: monospace; font-size: 0.85rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; width: 100%;
  border: none; border-radius: 12px; padding: 12px 16px; font-weight: 700; font-size: 0.95rem;
  cursor: pointer; text-decoration: none; transition: transform 0.08s, opacity 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-lg { padding: 15px 18px; font-size: 1.05rem; }
.btn-sm { padding: 8px 12px; font-size: 0.82rem; width: auto; }
.btn-primary { background: var(--accent); color: #05140d; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-link { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 0.9rem; padding: 0; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.stack-actions { display: flex; flex-direction: column; gap: 8px; }
.file-label { cursor: pointer; }

.cred-box { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.cred-label { font-size: 0.72rem; color: var(--muted); letter-spacing: 1px; display: block; }
.cred-number { font-size: 1.7rem; font-weight: 800; letter-spacing: 2px; color: var(--accent); margin-top: 4px; }
.cred-token { display: block; word-break: break-all; font-size: 0.85rem; margin: 6px 0 10px; color: #fff; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.my-number { font-size: 1.08rem; font-weight: 800; letter-spacing: 1px; }
.my-meta { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.pill { font-size: 0.72rem; color: var(--muted); }
.pill-btn {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--accent);
  font-size: 0.68rem; font-weight: 700; padding: 3px 8px; border-radius: 6px; cursor: pointer;
}
.pill-btn.active { background: var(--accent); color: #05140d; }
.topbar-right { display: flex; gap: 6px; align-items: center; }
.icon-pill {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 7px 10px; font-size: 0.76rem; font-weight: 700; cursor: pointer; text-decoration: none;
}
.icon-pill.active { background: var(--warn); border-color: var(--warn); color: #160e00; }
.icon-pill-accent { border-color: #195f44; color: var(--accent); }

.tab-panel { padding: 14px 16px; flex: 1; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.panel-head h2 { margin: 0; }

/* AVATAR */
.avatar {
  width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0;
  background: var(--surface-2); border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.95rem; color: var(--accent); overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 38px; height: 38px; font-size: 0.82rem; }

/* CHATS OVERVIEW (WHATSAPP CLARITY + VIL DESIGN) */
.chat-toolbar { display: flex; gap: 8px; margin-bottom: 12px; }
.chat-toolbar input { padding: 10px 12px; font-size: 0.92rem; }
.chat-overview-list { display: flex; flex-direction: column; gap: 6px; }
.chat-row {
  background: var(--surface); border: 1px solid var(--border); border-radius: 13px;
  padding: 11px 12px; display: flex; align-items: center; gap: 12px; cursor: pointer;
  transition: border-color 0.12s;
}
.chat-row:active { border-color: var(--accent); }
.chat-row-mid { flex: 1; min-width: 0; }
.chat-row-title { font-weight: 700; font-size: 0.98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-row-preview { color: var(--muted); font-size: 0.82rem; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-row-right { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex-shrink: 0; }
.chat-row-time { font-size: 0.72rem; color: var(--muted); }
.unread-led {
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px;
  background: var(--accent); color: #04190f; font-size: 0.72rem; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 0 8px rgba(0, 208, 132, 0.5);
}

.privacy-blurred .chat-row-title,
.privacy-blurred .chat-row-preview {
  filter: blur(6px);
  transition: filter 0.15s;
}
.privacy-blurred .chat-row:active .chat-row-title,
.privacy-blurred .chat-row:active .chat-row-preview {
  filter: none;
}

.list-stack { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.list-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px; display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.list-title { font-weight: 700; font-size: 0.98rem; }
.list-sub { color: var(--muted); font-size: 0.8rem; margin-top: 2px; }
.list-actions { display: flex; gap: 6px; }
.kv-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; font-size: 0.92rem; }

.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; background: var(--surface); border-top: 1px solid var(--border);
  display: grid; grid-template-columns: repeat(3, 1fr); z-index: 15;
}
.nav-btn {
  background: none; border: none; color: var(--muted); padding: 15px 6px;
  font-size: 0.76rem; font-weight: 700; letter-spacing: 0.6px; cursor: pointer;
}
.nav-btn.active { color: var(--accent); border-top: 2px solid var(--accent); }
.nav-badge {
  display: inline-block; background: var(--accent); color: #04190f;
  font-size: 0.68rem; font-weight: 800; padding: 1px 6px; border-radius: 99px;
  margin-left: 4px; vertical-align: middle;
}

/* FULLSCREEN ACTIVE CHAT VIEW */
.chat-screen {
  position: fixed; inset: 0; height: 100dvh; max-width: 480px; margin: 0 auto; background: var(--bg);
  z-index: 35; display: flex; flex-direction: column;
}
.chat-topbar {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.chat-peer-head { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; cursor: pointer; }
.chat-peer-name { font-weight: 800; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-peer-sub { font-size: 0.72rem; color: var(--accent); }

.chat-ttl-bar {
  text-align: center; font-size: 0.72rem; color: var(--muted);
  padding: 5px 10px; background: #0d1219; border-bottom: 1px solid #1b2432;
}
.chat-thread {
  flex: 1; min-height: 0; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 10px;
}
.msg-bubble {
  max-width: 82%; padding: 9px 12px; border-radius: 14px; font-size: 0.94rem; line-height: 1.38;
  background: var(--surface); border: 1px solid var(--border); align-self: flex-start;
  word-break: break-word; position: relative;
}
.msg-bubble.me { align-self: flex-end; background: #0d2b21; border-color: #165e44; }
.msg-quote {
  border-left: 3px solid var(--accent); background: rgba(0,0,0,0.28);
  padding: 4px 8px; border-radius: 6px; font-size: 0.78rem; color: var(--muted); margin-bottom: 6px;
}
.msg-img { max-width: 100%; max-height: 240px; border-radius: 10px; display: block; cursor: pointer; }
.msg-video { max-width: 100%; max-height: 260px; border-radius: 10px; display: block; background: #000; }
.msg-voice { display: flex; align-items: center; gap: 8px; min-width: 210px; }
.msg-voice audio { height: 34px; max-width: 180px; }
.msg-sticker { font-size: 3.1rem; line-height: 1.1; padding: 4px 8px; }
.msg-reactions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.react-chip {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px;
  padding: 1px 6px; font-size: 0.76rem;
}
.msg-foot {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  font-size: 0.68rem; color: var(--muted); margin-top: 5px;
}
.msg-actions { display: flex; gap: 8px; }
.msg-act-btn { background: none; border: none; color: var(--muted); font-size: 0.72rem; cursor: pointer; padding: 0; }
.msg-act-btn:hover { color: var(--accent); }

.reply-preview-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 12px; background: var(--surface-2); border-top: 1px solid var(--border);
}
.reply-preview-text { font-size: 0.8rem; color: var(--muted); border-left: 3px solid var(--accent); padding-left: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.emoji-drawer {
  background: var(--surface); border-top: 1px solid var(--border); padding: 8px 10px; max-height: 200px; overflow-y: auto;
}
.emoji-tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.emoji-btn { background: none; border: none; font-size: 1.45rem; cursor: pointer; padding: 4px; border-radius: 8px; }
.emoji-btn:active { background: var(--surface-2); }
.sticker-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.sticker-btn {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px; font-size: 1.8rem; cursor: pointer;
}

.voice-rec-bar {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  background: #1c1216; border-top: 1px solid var(--danger);
}
.voice-timer { font-family: monospace; font-size: 0.9rem; font-weight: 700; min-width: 44px; }
#voice-wave-canvas { flex: 1; height: 32px; background: #0d090b; border-radius: 8px; }

.chat-composer {
  display: flex; align-items: flex-end; gap: 6px; padding: 8px 10px;
  background: var(--surface); border-top: 1px solid var(--border);
}
.chat-composer textarea {
  flex: 1; background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 12px; padding: 9px 11px; font-size: 0.96rem; font-family: inherit;
  resize: none; max-height: 110px; outline: none;
}
.comp-btn {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; width: 38px; height: 38px; font-size: 1.1rem; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.comp-btn-accent { border-color: #195f44; color: var(--accent); }

.dial-mini-btn {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
  border-radius: 8px; padding: 6px 10px; font-weight: 700; cursor: pointer;
}

/* VIDEO STAGE & FLIP */
.video-stage {
  position: relative; width: 100%; background: #000; border-radius: 14px; overflow: hidden; border: 1px solid var(--border);
}
.cam-flip-btn {
  position: absolute; top: 10px; right: 10px; z-index: 20; transform: translateZ(0);
  background: rgba(9, 12, 16, 0.88); border: 1px solid var(--accent); color: var(--text);
  border-radius: 99px; padding: 7px 12px; font-size: 0.72rem; font-weight: 800; cursor: pointer;
}

/* MODALS & HELPERS */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.8); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 60;
}
.modal-card {
  position: relative; width: 100%; max-width: 390px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 18px; padding: 22px 18px;
}
.ln-card { text-align: center; }
.modal-close {
  position: absolute; top: 12px; right: 14px; background: var(--surface-2);
  border: 1px solid var(--border); color: var(--text); width: 34px; height: 34px;
  border-radius: 50%; font-size: 1.3rem; line-height: 1; cursor: pointer;
}
.ln-amount { font-size: 1.35rem; font-weight: 800; color: var(--accent); margin: 4px 0 12px; }
.qr-box {
  background: #ffffff; padding: 12px; border-radius: 12px; display: inline-flex;
  justify-content: center; align-items: center; margin: 6px auto 16px; min-width: 210px; min-height: 210px;
}
.qr-box svg { width: 200px; height: 200px; display: block; }
.ln-status { margin-top: 12px; font-size: 0.85rem; color: var(--muted); }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 0.88rem; cursor: pointer; }
.gift-opt-box { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 10px; }

.toast {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--accent); color: var(--text);
  padding: 10px 16px; border-radius: 10px; font-size: 0.88rem; font-weight: 600; z-index: 120;
}
.chat-row-right { gap: 4px; }
.chat-row-del {
  background: none; border: 1px solid transparent; color: var(--muted);
  font-size: 1.05rem; line-height: 1; padding: 2px 6px; border-radius: 6px; cursor: pointer;
}
.chat-row-del:hover, .chat-row-del:active { color: var(--danger); border-color: var(--danger); }
.msg-act-btn {
  background: rgba(255,255,255,0.06); border-radius: 6px; padding: 3px 7px; font-size: 0.74rem;
}
.msg-edited { font-size: 0.68rem; color: var(--muted); margin-left: 6px; font-style: italic; }
.nav-badge-warn { background: var(--warn); color: #160e00; }
.sticker-img { width: 64px; height: 64px; object-fit: contain; display: block; }
.sticker-btn img { width: 42px; height: 42px; object-fit: contain; display: block; margin: 0 auto; }