:root {
  /* ARKA premium dark — nordic / electric sapphire */
  --tg-header: #060a12;
  --tg-blue: #1a6dff;
  --tg-blue-bright: #3d8bff;
  --tg-blue-glow: #7eb6ff;
  --tg-blue-dark: #0d3d99;
  --tg-bg: #05070c;
  --tg-surface: #0b1018;
  --tg-surface-2: #121925;
  --tg-text: #f2f6fc;
  --tg-muted: #8a94a8;
  --tg-line: rgba(90, 120, 170, .14);
  --tg-badge: #1a6dff;
  --tg-bubble-in: #121a28;
  --tg-bubble-out: #0c2d5c;
  --tg-silver: #e8eef8;
  --chat-font-size: 16.5px;
  --safe-top: 0px;
  --safe-bottom: 0px;
  --tabbar-h: 64px;
  --tabbar-gap: 10px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background: var(--tg-bg); color: var(--tg-text);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

.splash {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-content: center; justify-items: center; gap: 14px;
  background: #05080f; color: #fff;
  transition: opacity .3s ease;
}
.splash.is-out { opacity: 0; pointer-events: none; }
.splash-logo {
  width: 96px; height: 96px; border-radius: 22px;
  background: #05080f url("/static/arka-web/icon-192.png") center / cover no-repeat;
  box-shadow: 0 0 0 1px rgba(61,139,255,.35), 0 0 28px rgba(26,109,255,.35);
  font-size: 0; color: transparent;
}
.splash-name {
  font-size: 26px; font-weight: 700; letter-spacing: .12em;
  color: var(--tg-blue-glow);
  text-shadow: 0 0 18px rgba(26,109,255,.45);
}

html.arka-native-photoedit #photoEdit {
  display: none !important;
}
html.arka-native-splash #splash {
  display: none !important;
}
html.arka-native-login .auth-gate,
html.arka-native-passlock .pass-lock {
  display: none !important;
}
.auth-gate {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center; padding: 24px;
  background: radial-gradient(ellipse at 50% 0%, #0d1a33 0%, #05080f 55%);
}
.auth-card {
  width: min(400px, 100%); background: var(--tg-surface);
  border-radius: 16px; padding: 28px 22px; text-align: center;
  border: 1px solid rgba(61,139,255,.25);
  box-shadow: 0 0 40px rgba(26,109,255,.12);
}
.auth-logo {
  width: 72px; height: 72px; margin: 0 auto 12px; border-radius: 18px;
  background: #05080f url("/static/arka-web/icon-192.png") center / cover no-repeat;
  box-shadow: 0 0 0 1px rgba(61,139,255,.4);
  font-size: 0; color: transparent;
}
.auth-card h1 { margin: 0 0 6px; color: var(--tg-blue-glow); }
.auth-card p { margin: 0 0 16px; color: var(--tg-muted); font-size: 14px; }
.auth-card input {
  width: 100%; border: 1px solid var(--tg-line); border-radius: 10px;
  padding: 12px; margin-bottom: 10px; outline: none;
  background: var(--tg-bg); color: var(--tg-text);
}
.auth-card input:focus { border-color: var(--tg-blue); }
.auth-card button[type=submit] {
  width: 100%; border: 0; border-radius: 10px; padding: 12px;
  background: linear-gradient(180deg, var(--tg-blue-bright), var(--tg-blue));
  color: #fff; font-weight: 700;
  box-shadow: 0 0 16px rgba(26,109,255,.35);
}
.auth-err { color: #ff6b7a; min-height: 18px; margin-top: 8px; font-size: 13px; }
.auth-link { display: inline-block; margin-top: 14px; color: var(--tg-blue-glow); font-size: 14px; }



.tg-app {
  height: 100%;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background: var(--tg-bg);
}
/* Thin top bar: status inset + compact row */
.tg-top {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 8px;
  height: calc(48px + var(--safe-top));
  min-height: calc(48px + var(--safe-top));
  max-height: calc(48px + var(--safe-top));
  padding: var(--safe-top) 10px 0;
  background: linear-gradient(180deg, #070b12 0%, rgba(5,7,12,.92) 100%);
  color: #fff;
  border-bottom: 1px solid rgba(94, 160, 220, .12);
  box-sizing: border-box;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.tg-brand {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  pointer-events: none;
}
.tg-title {
  margin: 0;
  font-family: "Georgia", "Times New Roman", "Palatino Linotype", serif;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: .18em;
  color: #eaf2ff;
  text-shadow:
    0 0 10px rgba(94, 176, 255, .28),
    0 1px 0 rgba(255,255,255,.06);
  line-height: 1.1;
}
.tg-brand__runes {
  font-size: 8px;
  letter-spacing: .35em;
  color: rgba(126, 182, 255, .45);
  line-height: 1;
  transform: translateY(-1px);
}
.tg-icon-btn, .tg-avatar-btn {
  width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: transparent; color: var(--tg-blue-glow);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.tg-search-btn {
  width: 42px; height: 42px; border: 0; border-radius: 13px;
  background: rgba(10, 14, 22, .95);
  color: #f0f6ff;
  display: grid; place-items: center;
  flex-shrink: 0;
  box-shadow:
    0 0 0 1.5px rgba(126, 182, 255, .45),
    0 0 16px rgba(26, 109, 255, .22);
}
.tg-search-btn svg {
  display: block;
  width: 24px;
  height: 24px;
}
.tg-search-btn:active {
  transform: scale(.94);
  background: rgba(26, 109, 255, .2);
  color: #fff;
}
.tg-avatar {
  width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; color: #fff; font-weight: 700;
  background: linear-gradient(145deg, var(--tg-blue-bright), var(--tg-blue-dark));
}
.tg-avatar--saved {
  background: linear-gradient(145deg, #3d8bff, #1a6dff) !important;
  color: #fff;
  box-shadow: 0 0 0 1px rgba(94,176,255,.35), 0 4px 14px rgba(26,109,255,.28);
}
.tg-avatar--saved svg { display: block; }
.dialog-head .tg-avatar--saved { font-size: 0; }
.tg-chatrow--saved .tg-chatrow__top b {
  font-weight: 700;
}
.tg-avatar--lg { width: 64px; height: 64px; font-size: 26px; }
.dialog-head .tg-avatar { width: 36px; height: 36px; font-size: 14px; }

.tg-searchbar {
  flex: 0 0 auto;
  padding: 6px 10px; background: var(--tg-bg); border-bottom: 1px solid var(--tg-line);
}
.tg-searchbar input {
  width: 100%; border: 0; border-radius: 18px; padding: 8px 12px;
  background: var(--tg-surface); color: var(--tg-text); outline: none;
}

.tg-main {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  position: relative;
  background: var(--tg-bg);
  padding-bottom: 0;
}
.tg-screen { display: none; height: 100%; overflow: auto; -webkit-overflow-scrolling: touch; }
.tg-screen.is-active { display: block; }

/* Chats atmosphere — lightweight CSS/SVG, no heavy bitmap */
.tg-screen[data-screen="chats"] {
  position: relative;
  background-color: #05070c;
  background-image:
    linear-gradient(180deg, #05070c 0%, rgba(5,7,12,.88) 18%, rgba(5,7,12,.55) 48%, rgba(5,7,12,.82) 78%, #05070c 100%),
    radial-gradient(ellipse 70% 45% at 50% 42%, rgba(26,109,255,.07), transparent 70%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='640' height='640' viewBox='0 0 640 640'%3E%3Cg fill='none' stroke='%235eb0ff' stroke-opacity='0.11' stroke-width='1'%3E%3Ccircle cx='320' cy='300' r='210'/%3E%3Ccircle cx='320' cy='300' r='168'/%3E%3Ccircle cx='320' cy='300' r='126'/%3E%3Ccircle cx='320' cy='300' r='84'/%3E%3Cpath d='M320 90 L320 510 M110 300 L530 300 M170 150 L470 450 M470 150 L170 450'/%3E%3Cpath d='M320 120 l18 48 52 0-42 30 16 50-44-32-44 32 16-50-42-30 52 0z' stroke-opacity='0.14'/%3E%3Cpath d='M320 430 l12 32 34 0-28 20 10 34-28-20-28 20 10-34-28-20 34 0z' stroke-opacity='0.1'/%3E%3C/g%3E%3Cpath d='M40 560 Q160 500 320 540 T600 520 L640 640 L0 640 Z' fill='%230a1422' fill-opacity='0.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center center, center 40%, center 38%;
  background-size: 100% 100%, 100% 100%, min(920px, 140%) auto;
  background-attachment: local;
}
.tg-screen[data-screen="chats"] .tg-chatlist {
  position: relative;
  z-index: 1;
  padding: 0 0 calc(28px + var(--tabbar-gap));
  min-height: 100%;
}

.tg-chatlist { padding: 0 0 12px; }
.tg-chatrow {
  width: 100%; border: 0; background: transparent;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; text-align: left; color: inherit;
  border-bottom: 1px solid rgba(70, 100, 150, .12);
  transition: background .15s ease;
}
.tg-chatrow:active { background: rgba(26, 109, 255, .08); }
.tg-chatrow--muted {
  color: var(--tg-muted); justify-content: center;
  padding: 48px 20px; border: 0; flex-direction: column; gap: 8px;
}
.tg-chatrow__body { flex: 1; min-width: 0; }
.tg-chatrow__top { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 2px; }
.tg-chatrow__top b {
  font-size: 16px; font-weight: 560; color: #f7f9fc;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tg-time { color: #6f7b90; font-size: 12px; flex-shrink: 0; }
.tg-chatrow__bot { display: flex; align-items: center; gap: 8px; }
.tg-chatrow__preview {
  color: #9aa5b8; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1;
}
.tg-badge {
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px;
  background: var(--tg-badge); color: #fff; font-size: 12px; font-weight: 700;
  display: grid; place-items: center; flex-shrink: 0;
  box-shadow: 0 0 8px rgba(26,109,255,.45);
}

.tg-fab {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  width: 54px; height: 54px; border-radius: 16px; border: 0;
  display: grid; place-items: center;
  z-index: 25;
  background:
    linear-gradient(160deg, rgba(40, 70, 120, .55), rgba(8, 14, 24, .92));
  box-shadow:
    0 0 0 1px rgba(94, 176, 255, .45),
    0 0 18px rgba(26, 109, 255, .28),
    0 8px 20px rgba(0,0,0,.35);
  transition: transform .18s ease, box-shadow .18s ease, bottom .2s ease, opacity .15s ease;
}
.tg-fab--primary { background:
  linear-gradient(160deg, rgba(45, 90, 160, .5), rgba(8, 14, 24, .94)); }
.tg-fab svg path { fill: #dcecff; }
.tg-fab:active {
  transform: scale(.92);
  box-shadow:
    0 0 0 1px rgba(94, 176, 255, .55),
    0 0 12px rgba(26, 109, 255, .35);
}

.tg-empty { padding: 72px 28px; text-align: center; color: var(--tg-muted); }
.tg-empty.soft { color: rgba(232,238,248,.85); text-shadow: 0 1px 2px rgba(0,0,0,.35); padding: 40px 20px; }
.tg-empty__icon { font-size: 48px; margin-bottom: 10px; }
.tg-empty h2 { margin: 0 0 8px; color: var(--tg-text); font-weight: 500; font-size: 18px; }

.tg-settings {
  padding: 0 0 calc(24px + var(--safe-bottom));
  background: var(--tg-bg);
}
.tg-sethero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 8px 20px 22px;
}
.tg-sethero__avatar-wrap {
  position: relative;
  width: 112px;
  height: 112px;
  margin-bottom: 14px;
}
.tg-sethero__avatar {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 42px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(145deg, var(--tg-blue-bright), var(--tg-blue-dark));
  box-shadow: 0 0 0 1px rgba(94,176,255,.25), 0 8px 28px rgba(0,0,0,.35);
}
.tg-sethero__cam {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--tg-blue-bright), var(--tg-blue));
  display: grid;
  place-items: center;
  box-shadow: 0 0 0 3px var(--tg-bg), 0 4px 12px rgba(26,109,255,.4);
}
.tg-sethero__name {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: .04em;
  color: #fff;
  line-height: 1.2;
  text-transform: uppercase;
}
.tg-sethero__sub {
  margin-top: 6px;
  font-size: 14px;
  color: var(--tg-muted);
  word-break: break-all;
}
.tg-sethero__channel {
  margin-top: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--tg-blue-glow);
  max-width: 90%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tg-sethero__channel.is-empty {
  color: var(--tg-muted);
  font-weight: 500;
}
.acc-picklist {
  max-height: 42vh;
  overflow: auto;
  border: 1px solid rgba(61,139,255,.14);
  border-radius: 12px;
  background: #05080f;
}
.acc-pick {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid rgba(26,36,54,.95);
  background: transparent;
  color: #fff;
  text-align: left;
  font-size: 15px;
}
.acc-pick:last-child { border-bottom: 0; }
.acc-pick.is-on { background: rgba(26,109,255,.12); }
.acc-pick__mark { margin-left: auto; color: var(--tg-blue-glow); font-weight: 700; }
.acc-pick--channel .acc-pick__av {
  width: 40px; height: 40px; border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(145deg, #3d8bff, #0d3d99) center/cover no-repeat;
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.acc-pick__meta { min-width: 0; flex: 1; }
.acc-pick__meta b { display: block; font-size: 15px; font-weight: 600; }
.acc-pick__meta small { display: block; margin-top: 2px; color: var(--tg-muted); font-size: 12px; }
.acc-sheet__save--secondary {
  background: rgba(26,109,255,.16) !important;
  color: var(--tg-blue-glow) !important;
  box-shadow: none !important;
  margin-bottom: 8px;
}
.tg-sethero__sub {
  margin-top: 6px;
  font-size: 14px;
  color: var(--tg-muted);
  word-break: break-all;
}
.tg-setgroup {
  margin: 0 12px;
  background: #121a28;
  border: 1px solid rgba(61,139,255,.14);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.tg-setgroup--gap { margin-top: 12px; }
.tg-setitem {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid rgba(26,36,54,.95);
  background: transparent;
  color: inherit;
  text-align: left;
}
.tg-setitem:last-child { border-bottom: 0; }
.tg-setitem:active { background: rgba(26,109,255,.08); }
.tg-setitem__ico {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}
.tg-setitem__txt { min-width: 0; flex: 1; }
.tg-setitem__txt b {
  display: block;
  font-size: 16px;
  font-weight: 500;
  color: var(--tg-text);
}
.tg-setitem__txt small {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  color: var(--tg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tg-setitem__chev {
  color: var(--tg-muted);
  font-size: 22px;
  line-height: 1;
  opacity: .55;
}
body.settings-tab .tg-top {
  background: transparent;
  border-bottom: 0;
}
body.settings-tab .tg-avatar-btn,
body.settings-tab .tg-brand,
body.settings-tab .tg-title {
  visibility: hidden;
  pointer-events: none;
}
body.settings-tab .tg-icon-btn--more { display: grid; }
.tg-icon-btn--more.hidden { display: none !important; }

/* legacy rows kept for safety */
.tg-setrow {
  width: 100%; display: flex; gap: 14px; align-items: center;
  padding: 14px 16px; border: 0; border-bottom: 1px solid var(--tg-line);
  background: transparent; color: inherit; text-align: left;
}
.tg-setrow--profile { background: var(--tg-surface); }
.tg-setrow b { display: block; font-size: 16px; font-weight: 500; }
.tg-setrow small { color: var(--tg-muted); font-size: 13px; display: block; }
.tg-auth-note { color: var(--tg-blue-glow) !important; margin-top: 4px; }
.tg-setico {
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(26,109,255,.15);
  display: grid; place-items: center; font-size: 18px;
}

.tg-tabbar {
  flex: 0 0 auto;
  height: auto;
  min-height: var(--tabbar-h);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin: 0 var(--tabbar-gap) calc(var(--tabbar-gap) + var(--safe-bottom));
  padding: 6px;
  border: 1px solid rgba(94, 176, 255, .28);
  border-radius: 26px;
  background: rgba(8, 12, 20, .88);
  box-shadow:
    0 0 0 1px rgba(255,255,255,.03) inset,
    0 0 24px rgba(26, 109, 255, .16),
    0 10px 28px rgba(0,0,0,.4);
  z-index: 30;
}
html.arka-native-tabs .tg-tabbar,
html.arka-native-tabs #tabbar {
  display: none !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  box-shadow: none !important;
}
html.arka-native-tabs .tg-fab {
  /* над нативным таббаром, без лишнего +36px */
  bottom: var(--fab-clearance, 96px);
  right: 18px;
}
body.dialog-open .tg-fab,
body.cabinet-open .tg-fab,
body.account-open .tg-fab,
body.chat-settings-open .tg-fab,
body.privacy-open .tg-fab,
body.notify-open .tg-fab,
body.data-open .tg-fab {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}
html.arka-native-tabs .tg-screen[data-screen="chats"] .tg-chatlist,
html.arka-native-tabs .tg-screen[data-screen="contacts"] .tg-chatlist,
html.arka-native-tabs .tg-settings {
  padding-bottom: calc(88px + var(--safe-bottom, 0px));
}
html.arka-native-tabs .tg-screen[data-screen="calls"] .tg-empty {
  padding-bottom: calc(48px + var(--safe-bottom));
}
.tg-tab {
  border: 0; background: transparent; color: #8b93a7;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 10px; padding: 6px 4px; margin: 0; position: relative;
  height: 52px;
  min-height: 0;
  border-radius: 18px;
  transition: color .22s ease, background .22s ease, box-shadow .22s ease, transform .18s ease;
}
.tg-tab.is-active {
  color: #7eb6ff;
  background: rgba(26, 109, 255, .14);
  box-shadow:
    0 0 0 1px rgba(94, 176, 255, .4),
    0 0 14px rgba(26, 109, 255, .2);
}
.tg-tab.is-active svg { color: #dcecff; }
.tg-tab:active { transform: scale(.96); }
.tg-tab-badge {
  position: absolute; top: 4px; right: calc(50% - 18px);
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--tg-badge); color: #fff; font-size: 10px; font-weight: 700;
  display: grid; place-items: center;
}
.tg-tab-badge.is-dot {
  min-width: 8px; width: 8px; height: 8px; padding: 0; border-radius: 50%;
  right: calc(50% - 14px); top: 8px;
}
html.notify-hide-badge .tg-tab-badge,
html.notify-hide-badge .tg-badge { display: none !important; }



.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%);
  background: rgba(12,18,28,.92); color: #fff;
  border: 1px solid rgba(61,139,255,.3);
  padding: 8px 14px; border-radius: 16px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 95;
}
.toast.is-on { opacity: 1; }

body.dialog-open .tg-tabbar,
body.dialog-open .tg-top,
body.dialog-open .tg-searchbar,
body.cabinet-open .tg-tabbar,
body.cabinet-open .tg-top,
body.cabinet-open .tg-searchbar,
body.account-open .tg-tabbar,
body.account-open .tg-top,
body.account-open .tg-searchbar,
body.chat-settings-open .tg-tabbar,
body.chat-settings-open .tg-top,
body.chat-settings-open .tg-searchbar,
body.privacy-open .tg-tabbar,
body.privacy-open .tg-top,
body.privacy-open .tg-searchbar,
body.notify-open .tg-tabbar,
body.notify-open .tg-top,
body.notify-open .tg-searchbar,
body.data-open .tg-tabbar,
body.data-open .tg-top,
body.data-open .tg-searchbar { visibility: hidden; }
body.drawer-open { overflow: hidden; }
