
:root {
  --bg:    #07080f;
  --card:  #0d1117;
  --n1:    #0f2044;
  --n2:    #1a3a6e;
  --grn:   #10b981;
  --grn2:  #059669;
  --acc:   #34d399;
  --txt:   #f0f4ff;
  --muted: #4a5568;
  --bdr:   #1a2235;
  --red:   #ef4444;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: var(--bg); color: var(--txt);
  font-family: 'DM Sans', sans-serif;
  height: 100%; overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
#app { height: 100%; display: flex; flex-direction: column; }

/* ── SCREENS ── */
.screen { display: none; flex-direction: column; height: 100%; overflow: hidden; }
.screen.active { display: flex; }

/* ── SPLASH ── */
#splash {
  background: linear-gradient(170deg, #07080f 0%, #0f2044 60%, #1a3a6e22 100%);
  align-items: center; justify-content: center; gap: 0; position: relative;
}
.splash-grid {
  position: absolute; inset: 0;
  background-image: linear-gradient(rgba(16,185,129,.04) 1px,transparent 1px),
    linear-gradient(90deg,rgba(16,185,129,.04) 1px,transparent 1px);
  background-size: 44px 44px;
}
.splash-glow {
  position: absolute; width: 340px; height: 340px; border-radius: 50%;
  background: radial-gradient(circle, rgba(16,185,129,.14) 0%, transparent 70%);
  top: 50%; left: 50%; transform: translate(-50%, -58%);
}
.icon-box {
  width: 108px; height: 108px;
  background: linear-gradient(148deg, var(--n2), var(--grn2));
  border-radius: 30px; display: flex; align-items: center; justify-content: center;
  position: relative; z-index: 2;
  box-shadow: 0 0 60px rgba(16,185,129,.45), 0 0 120px rgba(26,58,110,.5),
    inset 0 1px 0 rgba(255,255,255,.15);
}
.icon-box::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  background: linear-gradient(135deg,rgba(255,255,255,.18) 0%,transparent 45%);
}
.k-img { width: 62px; height: 68px; object-fit: contain;
  filter: brightness(0) invert(1); position: relative; z-index: 2; }
.app-title {
  font-family: 'Syne', sans-serif; font-size: 46px; font-weight: 800;
  letter-spacing: -3px; line-height: 1; margin-top: 20px; position: relative; z-index: 2;
  background: linear-gradient(135deg, #fff, var(--acc));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.app-tagline {
  font-size: 11px; letter-spacing: 5px; color: var(--grn);
  margin-top: 8px; font-weight: 600; position: relative; z-index: 2;
}
.sec-badge {
  position: relative; z-index: 2; margin-top: 22px;
  background: rgba(16,185,129,.1); border: .5px solid rgba(16,185,129,.35);
  border-radius: 22px; padding: 7px 16px;
  display: flex; align-items: center; gap: 8px;
}
.sec-badge svg { flex-shrink: 0; }
.sec-badge span { font-size: 9px; color: var(--acc); letter-spacing: .5px; }
.load-wrap {
  position: absolute; bottom: 52px;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
}
.load-bar {
  height: 3px; background: linear-gradient(90deg,var(--n2),var(--grn));
  border-radius: 2px; animation: lb 2.2s ease-in-out infinite;
}
@keyframes lb { 0%{width:18px;opacity:.4} 50%{width:70px;opacity:1} 100%{width:18px;opacity:.4} }
.load-txt { font-size: 8.5px; letter-spacing: 2px; color: #1e2a40; }

/* ── AUTH ── */
#auth {
  background: var(--bg);
  overflow-y: auto;
}
.auth-inner { padding: 20px 20px 32px; min-height: 100%; display: flex; flex-direction: column; }
.auth-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; margin-top: 12px; }
.auth-logo-box {
  width: 44px; height: 44px;
  background: linear-gradient(148deg,var(--n2),var(--grn2));
  border-radius: 14px; display: flex; align-items: center; justify-content: center;
}
.auth-logo-box img { width: 24px; height: 26px; object-fit: contain; filter: brightness(0) invert(1); }
.auth-logo span { font-family: 'Syne',sans-serif; font-size: 28px; font-weight: 800;
  letter-spacing: -1.5px; background: linear-gradient(135deg,#fff,var(--acc));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.auth-tabs { display: flex; gap: 0; background: var(--card); border-radius: 12px;
  padding: 4px; margin-bottom: 22px; }
.auth-tab { flex: 1; text-align: center; padding: 9px; border-radius: 9px;
  font-size: 12px; font-weight: 600; cursor: pointer; transition: all .2s; color: var(--muted); }
.auth-tab.on { background: var(--n2); color: var(--acc); }
.auth-title { font-family: 'Syne',sans-serif; font-size: 22px; font-weight: 800;
  color: var(--txt); margin-bottom: 4px; }
.auth-sub { font-size: 11px; color: var(--muted); margin-bottom: 20px; }
.field-wrap { margin-bottom: 12px; }
.field-label { font-size: 10px; color: var(--muted); letter-spacing: .5px; margin-bottom: 5px; }
.field {
  width: 100%; background: var(--card); border: 1px solid var(--bdr);
  border-radius: 12px; padding: 12px 14px; font-size: 13px; color: var(--txt);
  font-family: 'DM Sans', sans-serif; outline: none; transition: border .2s;
}
.field:focus { border-color: var(--grn); }
.field::placeholder { color: #2a3a50; }
.btn-main {
  width: 100%; background: linear-gradient(135deg,var(--n2),var(--grn2));
  border: none; border-radius: 14px; padding: 14px;
  font-family: 'Syne',sans-serif; font-size: 14px; font-weight: 700;
  color: #fff; cursor: pointer; margin-top: 4px;
  box-shadow: 0 4px 20px rgba(16,185,129,.3);
}
.btn-main:active { transform: scale(.98); }
.auth-err { background: rgba(239,68,68,.1); border: .5px solid rgba(239,68,68,.4);
  border-radius: 10px; padding: 10px 13px; font-size: 11px; color: #fca5a5;
  margin-bottom: 12px; display: none; }
.auth-note { text-align: center; font-size: 10px; color: #1e2a38; margin-top: 16px; line-height: 1.6; }

/* ── TOP BAR ── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px; flex-shrink: 0;
}
.topbar-title { font-family: 'Syne',sans-serif; font-size: 21px; font-weight: 800; color: var(--txt); }
.icon-btn {
  width: 36px; height: 36px; background: var(--card); border-radius: 50%;
  display: flex; align-items: center; justify-content: center; cursor: pointer; border: none;
}

/* ── NAV BAR ── */
.navbar {
  display: flex; justify-content: space-around; padding: 8px 0 max(14px,env(safe-area-inset-bottom));
  border-top: .5px solid var(--bdr); background: var(--bg); flex-shrink: 0;
}
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; padding: 2px 14px; }
.nav-item svg { width: 22px; height: 22px; }
.nav-item span { font-size: 9px; color: var(--muted); }
.nav-item.on span { color: var(--grn); }

/* ── CHAT LIST ── */
#home { background: var(--bg); }
.search-bar {
  margin: 0 14px 10px; background: var(--card);
  border-radius: 12px; padding: 9px 13px;
  display: flex; align-items: center; gap: 9px; border: .5px solid var(--bdr);
}
.search-bar input {
  flex: 1; background: none; border: none; outline: none;
  font-size: 12px; color: var(--txt); font-family: 'DM Sans',sans-serif;
}
.search-bar input::placeholder { color: #2a3a50; }
.chat-filters { display: flex; gap: 5px; padding: 0 14px 8px; overflow-x: auto; }
.cf { padding: 5px 13px; border-radius: 18px; font-size: 9px; cursor: pointer; white-space: nowrap; }
.cf.on { background: var(--n1); color: var(--acc); border: .5px solid rgba(52,211,153,.3); }
.cf.off { background: var(--card); color: var(--muted); }
.chat-list { flex: 1; overflow-y: auto; }
.chat-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 15px; cursor: pointer; transition: background .15s;
  border-bottom: .5px solid var(--bdr);
}
.chat-item:active { background: var(--card); }
.av {
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-family: 'Syne',sans-serif; font-weight: 700; color: #fff; flex-shrink: 0;
}
.av-grp { border-radius: 14px !important; }
.online-dot {
  position: absolute; bottom: 0; right: 0;
  width: 10px; height: 10px; background: var(--grn);
  border-radius: 50%; border: 2px solid var(--bg);
}
.chat-info { flex: 1; min-width: 0; }
.chat-name { font-family: 'Syne',sans-serif; font-size: 13px; color: var(--txt); font-weight: 600; }
.chat-preview { font-size: 10.5px; color: var(--muted); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.chat-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.chat-time { font-size: 9px; color: #1e2a38; }
.badge {
  background: var(--grn); color: var(--bg); border-radius: 10px;
  font-size: 9px; padding: 1px 7px; font-weight: 700;
}
.live-badge { background: var(--red); color: #fff; border-radius: 10px;
  font-size: 8px; padding: 1px 7px; display: flex; align-items: center; gap: 3px; }

/* ── CONVERSATION ── */
#conv { background: var(--bg); }
.conv-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-bottom: .5px solid var(--bdr); flex-shrink: 0;
}
.back-btn { color: var(--acc); font-size: 22px; cursor: pointer; padding: 0 4px; border: none; background: none; }
.conv-name { font-family: 'Syne',sans-serif; font-size: 14px; color: var(--txt); font-weight: 600; }
.conv-status { font-size: 9px; color: var(--grn); margin-top: 1px; }
.e2e-bar {
  background: rgba(16,185,129,.08); padding: 4px 14px;
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}
.e2e-bar span { font-size: 8.5px; color: var(--grn); }
.messages { flex: 1; overflow-y: auto; padding: 12px 13px; display: flex; flex-direction: column; gap: 8px; }
.day-sep { text-align: center; font-size: 9px; color: #1e2a38; margin: 4px 0; }
.msg { display: flex; flex-direction: column; gap: 2px; }
.msg.out { align-items: flex-end; }
.msg.in { align-items: flex-start; }
.msg-bubble {
  max-width: 80%; padding: 9px 12px; font-size: 12px; line-height: 1.5; border-radius: 16px;
}
.msg.out .msg-bubble {
  background: linear-gradient(135deg,var(--n2),var(--grn2)); color: #fff;
  border-radius: 16px 16px 4px 16px;
}
.msg.in .msg-bubble {
  background: var(--card); color: #c0d0e0; border-radius: 16px 16px 16px 4px;
}
.msg-time { font-size: 8.5px; color: #1e2a38; }
.msg-input-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 13px 16px; flex-shrink: 0;
}
.msg-input {
  flex: 1; background: var(--card); border: .5px solid var(--bdr);
  border-radius: 24px; padding: 10px 14px; font-size: 12px; color: var(--txt);
  font-family: 'DM Sans',sans-serif; outline: none; transition: border .2s;
}
.msg-input:focus { border-color: rgba(16,185,129,.5); }
.msg-input::placeholder { color: #2a3a50; }
.send-btn {
  width: 40px; height: 40px; border-radius: 50%; border: none;
  background: linear-gradient(135deg,var(--n2),var(--grn2));
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  flex-shrink: 0; box-shadow: 0 4px 14px rgba(16,185,129,.3);
}
.send-btn:active { transform: scale(.95); }

/* ── PROFILE ── */
#profile { background: var(--bg); overflow-y: auto; }
.prof-header {
  padding: 14px 16px 14px;
  display: flex; align-items: center; gap: 13px;
  border-bottom: .5px solid var(--bdr);
}
.prof-name { font-family: 'Syne',sans-serif; font-size: 17px; font-weight: 700; color: var(--txt); }
.prof-badge { font-size: 10px; color: var(--grn); margin-top: 3px; }
.prof-stats { display: flex; padding: 12px 16px; border-bottom: .5px solid var(--bdr); }
.stat { flex: 1; text-align: center; }
.stat-val { font-family: 'Syne',sans-serif; font-size: 16px; font-weight: 800; color: var(--txt); }
.stat-lbl { font-size: 9px; color: var(--muted); margin-top: 2px; }
.setting-section { padding: 10px 16px 3px; font-size: 9px; color: #1e2a38; letter-spacing: 1px; text-transform: uppercase; }
.setting-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: .5px solid var(--card);
}
.setting-icon { font-size: 16px; }
.setting-label { flex: 1; font-size: 13px; color: #b0c0d8; }
.setting-arrow { font-size: 15px; color: var(--muted); }
.toggle { width: 36px; height: 20px; background: var(--grn); border-radius: 10px; position: relative; }
.toggle .knob { width: 16px; height: 16px; background: #fff; border-radius: 50%; position: absolute; top: 2px; right: 2px; }
.sign-out-btn {
  margin: 16px; width: calc(100% - 32px);
  background: rgba(239,68,68,.1); border: .5px solid rgba(239,68,68,.3);
  border-radius: 14px; padding: 13px; font-family: 'Syne',sans-serif;
  font-size: 13px; color: var(--red); font-weight: 700; cursor: pointer;
}

/* ── STATES ── */
.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 32px; }
.empty-icon { font-size: 48px; }
.empty-txt { font-family: 'Syne',sans-serif; font-size: 16px; font-weight: 700; color: var(--txt); text-align: center; }
.empty-sub { font-size: 11px; color: var(--muted); text-align: center; line-height: 1.6; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--card); border-top-color: var(--grn); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }


/* ════ LANG SCREEN ════ */
#lang { background: var(--bg); }
.lang-header {
  padding: 14px 16px 12px;
  border-bottom: .5px solid var(--bdr);
  flex-shrink: 0;
}
.lang-header-top {
  display: flex; align-items: center; gap: 11px; margin-bottom: 10px;
}
.lang-logo-box {
  width: 38px; height: 38px;
  background: linear-gradient(148deg,var(--n2),var(--grn2));
  border-radius: 12px; display: flex; align-items: center; justify-content: center;
}
.lang-logo-box img { width: 20px; height: 22px; object-fit: contain; filter: brightness(0) invert(1); }
.lang-app-name {
  font-family: 'Syne',sans-serif; font-size: 22px; font-weight: 800;
  letter-spacing: -1px; background: linear-gradient(135deg,#fff,var(--acc));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.lang-title {
  font-family: 'Syne',sans-serif; font-size: 19px; font-weight: 800;
  color: var(--txt); margin-bottom: 3px;
}
.lang-sub { font-size: 11px; color: var(--muted); }
.lang-search-wrap {
  padding: 10px 14px 0; flex-shrink: 0;
}
.lang-search {
  width: 100%; background: var(--card); border: .5px solid var(--bdr);
  border-radius: 12px; padding: 10px 14px; font-size: 12px; color: var(--txt);
  font-family: 'DM Sans',sans-serif; outline: none;
}
.lang-search::placeholder { color: #2a3a50; }
.lang-search:focus { border-color: rgba(16,185,129,.5); }
.lang-list { flex: 1; overflow-y: auto; padding: 6px 0; }
.lang-item {
  display: flex; align-items: center; gap: 13px;
  padding: 13px 16px; cursor: pointer; transition: background .15s;
  border-bottom: .5px solid rgba(255,255,255,.03);
}
.lang-item:active { background: var(--card); }
.lang-item.selected { background: rgba(16,185,129,.06); }
.lang-flag { font-size: 24px; flex-shrink: 0; }
.lang-names { flex: 1; }
.lang-native { font-size: 14px; font-weight: 600; color: var(--txt); }
.lang-english { font-size: 11px; color: var(--muted); margin-top: 1px; }
.lang-check {
  width: 22px; height: 22px; background: var(--grn);
  border-radius: 50%; display: none; align-items: center; justify-content: center;
  color: var(--bg); font-size: 12px; font-weight: 800; flex-shrink: 0;
}
.lang-item.selected .lang-check { display: flex; }
.lang-footer { padding: 10px 14px 16px; flex-shrink: 0; }
.lang-continue-btn {
  width: 100%; background: linear-gradient(135deg,var(--n2),var(--grn2));
  border: none; border-radius: 14px; padding: 14px;
  font-family: 'Syne',sans-serif; font-size: 14px; font-weight: 700;
  color: #fff; cursor: pointer; opacity: .4; transition: opacity .2s;
  box-shadow: 0 4px 20px rgba(16,185,129,.25);
}
.lang-continue-btn.ready { opacity: 1; }
.lang-continue-btn:active { transform: scale(.98); }
.detected-badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(16,185,129,.12); border: .5px solid rgba(16,185,129,.35);
  border-radius: 20px; padding: 4px 10px; margin-top: 6px;
  font-size: 9px; color: var(--acc);
}
