* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #5288c1;
  --primary-dark: #4078b3;
  --bg: #eef3f7;
  --surface: #ffffff;
  --surface-2: #f4f7fa;
  --text: #17212b;
  --muted: #82909c;
  --border: #e1e7ec;
  --danger: #e55353;
  --shadow: 0 20px 60px rgba(30,45,60,.14);
}

html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
}

body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;

  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;

  background: var(--bg);
  color: var(--text);

  overflow: hidden;
  overscroll-behavior: none;

  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;

  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

input,
textarea {
  outline: none;
}

input,
textarea,
button {
  -webkit-appearance: none;
  appearance: none;
}

.hidden {
  display: none !important;
}


/* =========================================================
   TOAST
========================================================= */

#toast {
  position: fixed;
  z-index: 99999;

  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));

  transform: translate(-50%, 18px);

  opacity: 0;
  pointer-events: none;

  background: #202b35;
  color: #fff;

  padding: 11px 17px;

  border-radius: 13px;

  font-size: 13px;
  line-height: 1.5;

  max-width: calc(100% - 30px);

  text-align: center;

  transition:
    opacity .25s ease,
    transform .25s ease;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}


/* =========================================================
   AUTH
========================================================= */

.auth-screen {
  position: relative;

  width: 100%;
  height: 100dvh;
  min-height: 100dvh;

  display: flex;
  align-items: center;
  justify-content: center;

  padding:
    max(20px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));

  overflow-y: auto;
  overflow-x: hidden;

  overscroll-behavior: contain;

  background:
    radial-gradient(
      circle at 50% -10%,
      rgba(82,136,193,.22),
      transparent 42%
    ),
    linear-gradient(
      180deg,
      #f5f8fb 0%,
      #eef3f7 100%
    );
}

.auth-screen::before,
.auth-screen::after {
  content: "";

  position: absolute;

  pointer-events: none;

  border-radius: 50%;

  filter: blur(2px);
}

.auth-screen::before {
  width: 260px;
  height: 260px;

  top: -150px;
  right: -100px;

  background: rgba(82,136,193,.10);

  animation: authFloatOne 9s ease-in-out infinite;
}

.auth-screen::after {
  width: 210px;
  height: 210px;

  bottom: -130px;
  left: -90px;

  background: rgba(82,136,193,.07);

  animation: authFloatTwo 11s ease-in-out infinite;
}

@keyframes authFloatOne {
  0%,100% {
    transform: translate3d(0,0,0) scale(1);
  }

  50% {
    transform: translate3d(-18px,22px,0) scale(1.08);
  }
}

@keyframes authFloatTwo {
  0%,100% {
    transform: translate3d(0,0,0) scale(1);
  }

  50% {
    transform: translate3d(20px,-18px,0) scale(1.06);
  }
}


/* =========================================================
   AUTH CARD
========================================================= */

.auth-card {
  position: relative;
  z-index: 2;

  width: min(430px, 100%);

  padding: 32px;

  background: rgba(255,255,255,.94);

  border: 1px solid rgba(255,255,255,.8);

  border-radius: 26px;

  box-shadow:
    0 25px 70px rgba(30,45,60,.13),
    0 4px 18px rgba(30,45,60,.05);

  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);

  animation: authCardIn .55s cubic-bezier(.2,.8,.2,1);
}

@keyframes authCardIn {
  from {
    opacity: 0;
    transform: translateY(22px) scale(.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}


/* =========================================================
   BRAND
========================================================= */

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;

  gap: 12px;

  margin-bottom: 30px;

  text-align: right;
}

.brand-logo {
  width: 58px;
  height: 58px;

  flex-shrink: 0;

  object-fit: contain;

  border-radius: 16px;

  box-shadow:
    0 8px 22px rgba(82,136,193,.18);

  animation: logoEntrance .7s cubic-bezier(.2,.8,.2,1);
}

@keyframes logoEntrance {
  from {
    opacity: 0;
    transform: scale(.72) rotate(-8deg);
  }

  to {
    opacity: 1;
    transform: scale(1) rotate(0);
  }
}

.auth-brand strong {
  display: block;

  font-size: 21px;
  font-weight: 800;

  letter-spacing: -.3px;
}

.auth-brand span {
  display: block;

  color: var(--muted);

  font-size: 13px;

  margin-top: 4px;
}


/* =========================================================
   AUTH TITLE
========================================================= */

.auth-card h1 {
  font-size: 25px;
  line-height: 1.35;

  margin-bottom: 8px;

  font-weight: 800;

  letter-spacing: -.3px;
}

.auth-card > p {
  color: var(--muted);

  font-size: 13px;
  line-height: 1.8;

  margin-bottom: 24px;
}


/* =========================================================
   FIELDS
========================================================= */

.field,
.profile-field {
  margin-bottom: 15px;
}

.field label,
.profile-field label {
  display: block;

  margin-bottom: 7px;

  font-size: 12px;

  font-weight: 700;
}

.field input,
.profile-field input,
.profile-field textarea {
  width: 100%;

  border: 1px solid var(--border);

  background: var(--surface-2);

  color: var(--text);

  border-radius: 13px;

  padding: 13px 14px;

  transition:
    border-color .2s ease,
    background .2s ease,
    box-shadow .2s ease,
    transform .2s ease;
}

.field input::placeholder,
.profile-field input::placeholder,
.profile-field textarea::placeholder {
  color: #a1adb7;
}

.field input:focus,
.profile-field input:focus,
.profile-field textarea:focus {
  border-color: var(--primary);

  background: #fff;

  box-shadow:
    0 0 0 4px rgba(82,136,193,.10);

  transform: translateY(-1px);
}


/* =========================================================
   PASSWORD
========================================================= */

.password-field {
  position: relative;
}

.password-field input {
  padding-left: 46px;
}

.password-toggle {
  position: absolute;

  left: 7px;
  bottom: 7px;

  width: 34px;
  height: 34px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 9px;

  background: transparent;

  color: var(--muted);

  font-size: 17px;
}

.password-toggle:hover {
  background: var(--surface-2);
  color: var(--primary);
}


/* =========================================================
   BUTTONS
========================================================= */

.primary-btn,
.secondary-btn {
  width: 100%;

  min-height: 47px;

  border-radius: 13px;

  font-weight: 700;

  transition:
    transform .18s ease,
    box-shadow .18s ease,
    background .18s ease;
}

.primary-btn {
  background: linear-gradient(
    135deg,
    #5b91c8,
    #477fb7
  );

  color: #fff;

  box-shadow:
    0 7px 18px rgba(82,136,193,.20);
}

.primary-btn:hover {
  background: linear-gradient(
    135deg,
    #5288c1,
    #4078b3
  );

  transform: translateY(-1px);

  box-shadow:
    0 10px 24px rgba(82,136,193,.25);
}

.primary-btn:active,
.secondary-btn:active,
.text-btn:active,
.auth-switch:active {
  transform: scale(.98);
}

.secondary-btn {
  margin-top: 9px;

  background: var(--surface-2);

  color: var(--text);

  border: 1px solid var(--border);
}

.secondary-btn:hover {
  background: #eaf0f5;
}


/* =========================================================
   GOOGLE
========================================================= */

.google-btn {
  width: 100%;

  min-height: 47px;

  display: flex;
  align-items: center;
  justify-content: center;

  gap: 10px;

  margin-top: 10px;

  border-radius: 13px;

  background: #fff;

  color: #202124;

  border: 1px solid #dadce0;

  font-weight: 600;

  transition:
    background .18s ease,
    box-shadow .18s ease,
    transform .18s ease;
}

.google-btn:hover {
  background: #fafafa;

  box-shadow:
    0 5px 16px rgba(0,0,0,.08);

  transform: translateY(-1px);
}

.google-btn img,
.google-btn svg {
  width: 19px;
  height: 19px;

  flex-shrink: 0;
}


/* =========================================================
   TEXT BUTTONS
========================================================= */

.text-btn,
.auth-switch {
  display: block;

  margin: 14px auto 0;

  background: transparent;

  color: var(--primary);

  font-size: 12px;

  font-weight: 600;
}

.text-btn:hover,
.auth-switch:hover {
  text-decoration: underline;
}

.auth-switch {
  margin-top: 18px;
}


/* =========================================================
   APP
========================================================= */

.app {
  width: 100%;
  height: 100dvh;
  min-height: 100dvh;

  display: flex;

  position: relative;

  overflow: hidden;

  background: var(--surface);
}


/* =========================================================
   SIDEBAR
========================================================= */

.sidebar {
  width: 360px;
  height: 100%;

  flex-shrink: 0;

  display: flex;
  flex-direction: column;

  background: var(--surface);

  border-left: 1px solid var(--border);

  z-index: 20;

  overflow: hidden;
}

.sidebar-header {
  height: 70px;

  flex-shrink: 0;

  display: flex;
  align-items: center;

  padding: 0 14px;

  gap: 10px;
}

.icon-btn,
.top-icon,
.composer-icon,
.send-btn,
.mobile-back,
.back-icon {
  display: flex;
  align-items: center;
  justify-content: center;

  background: transparent;

  color: var(--text);
}

.icon-btn {
  width: 40px;
  height: 40px;

  border-radius: 50%;

  font-size: 20px;
}

.icon-btn:hover,
.top-icon:hover,
.composer-icon:hover {
  background: var(--surface-2);
}

.app-brand {
  flex: 1;

  min-width: 0;

  display: flex;
  align-items: center;

  gap: 10px;
}

.mini-logo {
  width: 40px;
  height: 40px;

  flex-shrink: 0;

  border-radius: 12px;

  object-fit: contain;
}

.app-brand strong,
.app-brand small {
  display: block;
}

.app-brand strong {
  font-size: 15px;
}

.app-brand small {
  color: #38a169;

  font-size: 11px;

  margin-top: 2px;
}


/* =========================================================
   SEARCH
========================================================= */

.search-box {
  margin: 0 13px 11px;

  height: 43px;

  flex-shrink: 0;

  display: flex;
  align-items: center;

  gap: 8px;

  padding: 0 13px;

  background: var(--surface-2);

  border-radius: 12px;

  color: var(--muted);
}

.search-box input {
  width: 100%;

  min-width: 0;

  border: 0;

  background: transparent;

  color: var(--text);

  font-size: 16px;
}


/* =========================================================
   TABS
========================================================= */

.chat-tabs {
  display: flex;

  gap: 4px;

  padding: 0 13px 8px;

  flex-shrink: 0;
}

.chat-tab {
  background: transparent;

  color: var(--muted);

  padding: 7px 12px;

  border-radius: 9px;

  font-size: 12px;
}

.chat-tab.active {
  background: rgba(82,136,193,.11);

  color: var(--primary);

  font-weight: 700;
}


/* =========================================================
   CHAT LIST
========================================================= */

.chat-list {
  flex: 1;

  min-height: 0;

  overflow-y: auto;
  overflow-x: hidden;

  padding: 3px 7px 15px;

  -webkit-overflow-scrolling: touch;
}

.chat {
  width: 100%;

  display: flex;
  align-items: center;

  gap: 11px;

  padding: 10px 9px;

  background: transparent;

  border-radius: 14px;

  text-align: right;

  margin-bottom: 2px;
}

.chat:hover,
.chat.selected {
  background: rgba(82,136,193,.10);
}

.chat .avatar,
.chat-avatar {
  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 50%;

  background: linear-gradient(
    145deg,
    #65a0d7,
    #477daf
  );

  color: white;

  font-weight: 700;
}

.chat .avatar {
  width: 48px;
  height: 48px;

  flex-shrink: 0;
}

.chat-info {
  min-width: 0;
  flex: 1;
}

.chat-info b,
.chat-info small {
  display: block;

  overflow: hidden;

  white-space: nowrap;

  text-overflow: ellipsis;
}

.chat-info b {
  font-size: 14px;
}

.chat-info small {
  color: var(--muted);

  font-size: 12px;

  margin-top: 4px;
}

.chat time {
  color: var(--muted);

  font-size: 10px;

  align-self: flex-start;

  margin-top: 4px;
}

.empty-list {
  text-align: center;

  padding: 50px 20px;

  color: var(--muted);

  font-size: 13px;
}


/* =========================================================
   MAIN
========================================================= */

.main {
  min-width: 0;

  flex: 1;

  height: 100%;

  display: flex;
  flex-direction: column;

  position: relative;

  overflow: hidden;

  background:
    radial-gradient(
      circle at top right,
      rgba(82,136,193,.07),
      transparent 35%
    ),
    #f7f9fb;
}

.topbar {
  height: 70px;

  flex-shrink: 0;

  display: flex;
  align-items: center;

  gap: 10px;

  padding: 0 15px;

  background: rgba(255,255,255,.96);

  border-bottom: 1px solid var(--border);

  z-index: 2;
}

.header-profile {
  flex: 1;

  min-width: 0;

  display: flex;
  align-items: center;

  gap: 10px;

  text-align: right;

  background: transparent;

  color: var(--text);
}

.chat-avatar {
  width: 43px;
  height: 43px;

  flex-shrink: 0;
}

.chat-title {
  min-width: 0;
}

.chat-title strong,
.chat-title small {
  display: block;

  overflow: hidden;

  white-space: nowrap;

  text-overflow: ellipsis;
}

.chat-title strong {
  font-size: 15px;
}

.chat-title small {
  color: var(--muted);

  font-size: 11px;

  margin-top: 3px;
}

.topbar-actions {
  display: flex;

  gap: 3px;

  flex-shrink: 0;
}

.top-icon {
  width: 39px;
  height: 39px;

  border-radius: 50%;

  font-size: 20px;
}

.mobile-back {
  display: none;

  width: 38px;
  height: 38px;

  border-radius: 50%;

  font-size: 28px;
}


/* =========================================================
   MESSAGES
========================================================= */

.messages {
  flex: 1;

  min-height: 0;

  overflow-y: auto;
  overflow-x: hidden;

  padding: 25px clamp(12px,5vw,75px);

  display: flex;
  flex-direction: column;

  gap: 7px;

  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.welcome {
  margin: auto;

  text-align: center;

  color: var(--muted);
}

.welcome-logo {
  width: 75px;
  height: 75px;

  object-fit: contain;

  margin-bottom: 15px;
}

.welcome h1 {
  color: var(--text);

  font-size: 27px;

  margin-bottom: 6px;
}

.welcome p {
  font-size: 13px;
}

.bubble {
  max-width: min(620px,78%);

  padding: 9px 13px;

  background: white;

  border-radius: 16px 16px 16px 5px;

  box-shadow:
    0 2px 10px rgba(30,40,60,.05);

  align-self: flex-start;

  line-height: 1.7;

  font-size: 14px;

  word-break: break-word;
}

.bubble.me {
  align-self: flex-end;

  background: #e4f1fd;

  border-radius: 16px 16px 5px 16px;
}

.bubble time {
  display: block;

  margin-top: 3px;

  font-size: 9px;

  opacity: .55;

  text-align: left;
}


/* =========================================================
   COMPOSER
========================================================= */

.composer {
  min-height: 68px;

  flex-shrink: 0;

  display: flex;
  align-items: center;

  gap: 8px;

  padding:
    10px
    clamp(10px,5vw,75px);

  background: rgba(255,255,255,.96);

  border-top: 1px solid var(--border);

  z-index: 3;
}

.composer > input[type=text] {
  flex: 1;

  min-width: 0;

  height: 45px;

  border: 1px solid var(--border);

  background: var(--surface-2);

  border-radius: 14px;

  padding: 0 14px;

  color: var(--text);

  font-size: 16px;
}

.composer-icon,
.send-btn {
  width: 43px;
  height: 43px;

  flex-shrink: 0;

  border-radius: 50%;

  font-size: 20px;
}

.send-btn {
  background: var(--primary);

  color: white;
}


/* =========================================================
   PANELS
========================================================= */

.overlay {
  position: fixed;

  inset: 0;

  z-index: 100;

  background: rgba(15,25,35,.28);

  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);

  display: flex;

  overflow: hidden;
}

.page-panel {
  width: min(440px,100%);

  height: 100%;

  background: var(--surface);

  margin-left: auto;

  overflow-y: auto;
  overflow-x: hidden;

  -webkit-overflow-scrolling: touch;

  box-shadow: var(--shadow);

  animation: panelIn .25s ease;
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateX(22px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.small-panel {
  width: min(500px,100%);
}

.page-header {
  height: 68px;

  flex-shrink: 0;

  display: flex;
  align-items: center;

  gap: 12px;

  padding: 0 17px;

  border-bottom: 1px solid var(--border);

  font-size: 16px;
}

.back-icon {
  width: 39px;
  height: 39px;

  flex-shrink: 0;

  border-radius: 50%;

  font-size: 27px;
}

.back-icon:hover {
  background: var(--surface-2);
}


/* =========================================================
   SETTINGS
========================================================= */

.settings-list {
  padding: 10px;
}

.settings-item,
.action-card {
  width: 100%;

  display: flex;
  align-items: center;

  gap: 13px;

  background: transparent;

  padding: 13px 10px;

  border-radius: 14px;

  text-align: right;
}

.settings-item:hover,
.action-card:hover {
  background: var(--surface-2);
}

.setting-icon {
  width: 42px;
  height: 42px;

  flex-shrink: 0;

  border-radius: 12px;

  background: var(--surface-2);

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 19px;
}

.settings-item div,
.action-card div {
  flex: 1;

  min-width: 0;
}

.settings-item strong,
.settings-item small,
.action-card strong,
.action-card small {
  display: block;
}

.settings-item strong,
.action-card strong {
  font-size: 14px;
}

.settings-item small,
.action-card small {
  color: var(--muted);

  font-size: 11px;

  margin-top: 3px;
}

.settings-item > b {
  color: var(--muted);

  font-size: 20px;
}

.danger {
  color: var(--danger);
}

.settings-content {
  padding: 18px;
}

.setting-card {
  background: var(--surface-2);

  padding: 15px;

  border-radius: 14px;

  margin-bottom: 10px;
}

.setting-card strong,
.setting-card p {
  display: block;
}

.setting-card p {
  color: var(--muted);

  font-size: 12px;

  line-height: 1.8;

  margin-top: 5px;
}


/* =========================================================
   PROFILE
========================================================= */

.profile-content {
  padding: 28px 20px;
}

.avatar-editor {
  text-align: center;
}

.profile-avatar {
  width: 105px;
  height: 105px;

  margin: 0 auto 12px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 50%;

  background: linear-gradient(
    145deg,
    #65a0d7,
    #477daf
  );

  color: white;

  font-size: 37px;
  font-weight: 800;

  overflow: hidden;
}

.profile-avatar img {
  width: 100%;
  height: 100%;

  object-fit: cover;
}

.avatar-actions {
  display: flex;
  justify-content: center;

  gap: 7px;

  margin-bottom: 14px;
}

.small-action {
  background: var(--surface-2);

  color: var(--primary);

  padding: 7px 10px;

  border-radius: 9px;

  font-size: 11px;
}

.danger-text {
  color: var(--danger);
}

.verification {
  width: 22px;
  height: 22px;

  margin: 0 auto 25px;
}

.verification img {
  width: 100%;
  height: 100%;

  object-fit: contain;
}

.username-input {
  display: flex;
  align-items: center;

  border: 1px solid var(--border);

  background: var(--surface-2);

  border-radius: 12px;

  padding-right: 11px;
}

.username-input span {
  color: var(--muted);
}

.username-input input {
  border: 0 !important;

  background: transparent !important;

  box-shadow: none !important;
}


/* =========================================================
   LANGUAGE
========================================================= */

.language-option {
  width: calc(100% - 24px);

  margin: 6px 12px;

  padding: 14px;

  display: flex;
  align-items: center;

  gap: 12px;

  border-radius: 13px;

  background: transparent;

  text-align: right;
}

.language-option:hover {
  background: var(--surface-2);
}

.language-option span:last-child {
  margin-right: auto;

  color: var(--primary);

  font-weight: 800;
}


/* =========================================================
   ABOUT
========================================================= */

.about-content {
  padding: 40px 22px;

  text-align: center;
}

.about-logo {
  width: 85px;
  height: 85px;

  object-fit: contain;

  margin-bottom: 14px;
}

.about-content p {
  color: var(--muted);

  font-size: 13px;

  margin: 6px 0 24px;
}

.about-card {
  background: var(--surface-2);

  border-radius: 15px;

  padding: 17px;

  text-align: right;
}

.about-card a {
  display: block;

  color: var(--primary);

  text-decoration: none;

  padding: 8px 0;

  font-size: 13px;
}

.support-row {
  font-size: 13px;

  padding-top: 8px;
}


/* =========================================================
   SCROLLBAR
========================================================= */

* {
  scrollbar-width: thin;

  scrollbar-color:
    #ccd6df
    transparent;
}

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-thumb {
  background: #ccd6df;

  border-radius: 10px;
}


/* =========================================================
   MOBILE — REAL MOBILE LAYOUT
========================================================= */

@media (max-width: 700px) {

  html,
  body {
    width: 100%;
    height: 100%;

    overflow: hidden;

    position: fixed;

    inset: 0;

    overscroll-behavior: none;
  }


  /* AUTH */

  .auth-screen {
    width: 100%;
    height: 100dvh;

    align-items: center;

    padding:
      max(16px, env(safe-area-inset-top))
      14px
      max(16px, env(safe-area-inset-bottom))
      14px;

    overflow-y: auto;
    overflow-x: hidden;

    -webkit-overflow-scrolling: touch;
  }

  .auth-card {
    width: 100%;
    max-width: 430px;

    padding: 24px 18px;

    border-radius: 22px;
  }

  .auth-brand {
    margin-bottom: 24px;
  }

  .brand-logo {
    width: 52px;
    height: 52px;
  }

  .auth-card h1 {
    font-size: 22px;
  }

  .auth-card > p {
    margin-bottom: 20px;
  }

  .field,
  .profile-field {
    margin-bottom: 13px;
  }

  .field input,
  .profile-field input,
  .profile-field textarea {
    min-height: 46px;

    font-size: 16px;
  }

  .primary-btn,
  .secondary-btn,
  .google-btn {
    min-height: 48px;
  }


  /* =======================================================
     APP
  ======================================================= */

  .app {
    width: 100%;
    height: 100dvh;

    display: block;

    position: fixed;

    inset: 0;

    overflow: hidden;
  }


  /* =======================================================
     SIDEBAR — FULL MOBILE SCREEN
  ======================================================= */

  .sidebar {
    width: 100%;
    height: 100%;

    position: absolute;

    inset: 0;

    display: flex;

    border: 0;

    z-index: 30;

    transform: translateX(0);

    transition: transform .25s ease;

    overflow: hidden;
  }

  .sidebar.hide {
    transform: translateX(100%);
  }


  /* =======================================================
     MAIN — FULL MOBILE SCREEN
  ======================================================= */

  .main {
    width: 100%;
    height: 100%;

    position: absolute;

    inset: 0;

    display: flex;

    z-index: 40;

    transform: translateX(100%);

    transition: transform .25s ease;

    overflow: hidden;
  }

  .main.show {
    transform: translateX(0);
  }


  /* =======================================================
     TOPBAR
  ======================================================= */

  .topbar {
    width: 100%;

    height: 63px;

    flex-shrink: 0;

    padding:
      0
      max(9px, env(safe-area-inset-right))
      0
      max(9px, env(safe-area-inset-left));
  }

  .mobile-back {
    display: flex;

    flex-shrink: 0;
  }

  .topbar-actions {
    gap: 1px;
  }

  .top-icon {
    width: 38px;
    height: 38px;
  }


  /* =======================================================
     CHAT MESSAGES
  ======================================================= */

  .messages {
    width: 100%;

    flex: 1;

    min-height: 0;

    padding:
      14px
      9px;

    overflow-y: auto;
    overflow-x: hidden;

    -webkit-overflow-scrolling: touch;
  }

  .bubble {
    max-width: 87%;

    font-size: 14px;
  }


  /* =======================================================
     COMPOSER
  ======================================================= */

  .composer {
    width: 100%;

    min-height: 62px;

    flex-shrink: 0;

    padding:
      8px
      max(8px, env(safe-area-inset-right))
      max(8px, env(safe-area-inset-bottom))
      max(8px, env(safe-area-inset-left));

    gap: 6px;
  }

  .composer > input[type=text] {
    height: 44px;

    min-width: 0;

    font-size: 16px;

    padding: 0 12px;
  }

  .composer-icon,
  .send-btn {
    width: 42px;
    height: 42px;

    flex-shrink: 0;
  }


  /* =======================================================
     MOBILE PANELS
  ======================================================= */

  .overlay {
    width: 100%;
    height: 100dvh;

    position: fixed;

    inset: 0;

    overflow: hidden;

    z-index: 100;
  }

  .page-panel,
  .small-panel {
    width: 100%;
    max-width: none;

    height: 100dvh;

    margin: 0;

    overflow-y: auto;
    overflow-x: hidden;

    -webkit-overflow-scrolling: touch;

    box-shadow: none;

    border-radius: 0;
  }

  .page-header {
    height: 63px;

    padding:
      0
      max(12px, env(safe-area-inset-right))
      0
      max(12px, env(safe-area-inset-left));
  }


  /* =======================================================
     MOBILE SETTINGS
  ======================================================= */

  .settings-list {
    padding:
      8px
      max(8px, env(safe-area-inset-right))
      max(20px, env(safe-area-inset-bottom))
      max(8px, env(safe-area-inset-left));
  }

  .settings-item,
  .action-card {
    min-height: 60px;
  }


  /* =======================================================
     MOBILE PROFILE
  ======================================================= */

  .profile-content {
    padding:
      24px
      max(18px, env(safe-area-inset-right))
      max(30px, env(safe-area-inset-bottom))
      max(18px, env(safe-area-inset-left));
  }


  /* =======================================================
     MOBILE ABOUT
  ======================================================= */

  .about-content {
    padding:
      30px
      max(18px, env(safe-area-inset-right))
      max(30px, env(safe-area-inset-bottom))
      max(18px, env(safe-area-inset-left));
  }


  /* =======================================================
     MOBILE LANGUAGE
  ======================================================= */

  .language-option {
    width: calc(100% - 20px);

    margin-left: 10px;
    margin-right: 10px;
  }
}


/* =========================================================
   SMALL ANDROID DEVICES
========================================================= */

@media (max-width: 380px) {

  .auth-screen {
    padding-left: 10px;
    padding-right: 10px;
  }

  .auth-card {
    padding: 21px 15px;

    border-radius: 20px;
  }

  .auth-brand {
    margin-bottom: 21px;
  }

  .auth-brand strong {
    font-size: 19px;
  }

  .auth-card h1 {
    font-size: 20px;
  }

  .field input {
    font-size: 16px;
  }

  .bubble {
    max-width: 91%;
  }
}


/* =========================================================
   SHORT SCREENS
========================================================= */

@media (max-height: 650px) {

  .auth-screen {
    align-items: flex-start;

    padding-top: 12px;
    padding-bottom: 12px;
  }

  .auth-card {
    margin: auto 0;

    padding-top: 18px;
    padding-bottom: 18px;
  }

  .auth-brand {
    margin-bottom: 16px;
  }

  .auth-card > p {
    margin-bottom: 14px;
  }

  .field {
    margin-bottom: 10px;
  }
}


/* =========================================================
   LANDSCAPE MOBILE
========================================================= */

@media (orientation: landscape) and (max-height: 600px) {

  html,
  body {
    position: fixed;

    width: 100%;
    height: 100%;

    overflow: hidden;
  }

  .auth-screen {
    align-items: flex-start;

    overflow-y: auto;
  }

  .auth-card {
    margin: 12px auto;
  }

  .sidebar {
    width: 310px;

    position: absolute;

    inset: 0;

    transform: translateX(0) !important;
  }

  .sidebar.hide {
    transform: translateX(100%) !important;
  }

  .main {
    position: absolute;

    inset: 0;

    width: 100%;

    transform: translateX(100%) !important;
  }

  .main.show {
    transform: translateX(0) !important;
  }

  .mobile-back {
    display: flex;
  }
}


/* =========================================================
   REDUCED MOTION
========================================================= */

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* BipolarChat icon system */
.setting-icon,.action-card>span:first-child{font-family:system-ui,sans-serif;display:inline-flex;align-items:center;justify-content:center;width:42px;height:42px;border-radius:12px;font-size:20px;flex:none}
.settings-item,.action-card{cursor:pointer}
.settings-item:disabled,.action-card:disabled,.primary-btn:disabled{opacity:.55;cursor:not-allowed}


/* =========================================================
   BipolarChat v5 — mobile/settings/icon repair
========================================================= */
.settings-item {
  box-sizing: border-box;
  min-width: 0;
  overflow: hidden;
}
.settings-item > div {
  min-width: 0;
  overflow: hidden;
}
.settings-item strong,
.settings-item small {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.55;
}
.setting-icon.svg-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.setting-icon.svg-icon {
  color: var(--primary);
}
.first-login-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 15, 25, .58);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}
.first-login-card {
  width: min(520px, 100%);
  max-height: min(720px, 90dvh);
  overflow: auto;
  box-sizing: border-box;
  padding: 26px;
  border-radius: 24px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0,0,0,.22);
}
.first-login-badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
}
.first-login-card h2 { margin: 14px 0 18px; }
.first-login-text { line-height: 2; font-size: 14px; }
.first-login-text p { margin: 0 0 12px; }
.first-login-text .notice-warning { font-weight: 800; }
.first-login-text .notice-en { direction: ltr; text-align: left; font-size: 12px; opacity: .75; }
.first-login-text .notice-version { text-align: center; font-weight: 800; margin-top: 18px; }
.first-login-card .primary-btn { width: 100%; margin-top: 8px; }


/* =========================================================
   BipolarChat v6 — navigation, icon and localization hardening
========================================================= */
#menuPanel, #settingsPanel, #profilePanel, #languagePanel, #aboutPanel,
#newChatPanel, #contactPanel, #groupPanel, #channelPanel {
  direction: rtl;
}

.settings-item .setting-icon {
  color: var(--primary);
  overflow: hidden;
}

.settings-item .setting-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
  flex: 0 0 auto;
}

.settings-item .settings-label {
  display: block;
  min-width: 0;
}

#settingsContent {
  direction: inherit;
  text-align: inherit;
}

.first-login-card {
  direction: rtl;
  text-align: right;
}

.first-login-card .notice-en {
  direction: ltr;
  text-align: left;
}

@media (max-width: 600px) {
  .settings-item {
    min-height: 68px;
    padding: 12px 8px;
  }
  .settings-item strong {
    white-space: normal;
  }
}

.saved-messages-list{display:flex;flex-direction:column;gap:10px;padding:12px}
.saved-message-item{display:flex;gap:8px;align-items:flex-start;padding:12px;border-radius:14px;background:var(--panel-bg,#f5f5f5)}
.saved-message-item .saved-content{flex:1;white-space:pre-wrap;word-break:break-word}
.saved-message-delete{border:0;background:transparent;cursor:pointer;opacity:.65}
.message-save-btn{display:block;margin-top:6px;border:0;background:transparent;cursor:pointer;font-size:12px;opacity:.65}

.saved-icon svg,.message-save-btn svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linejoin:round}
.message-save-btn{border:0;background:transparent;cursor:pointer;padding:4px;display:inline-flex;align-items:center}
.message-file{display:inline-block;max-width:260px;overflow-wrap:anywhere}
#voiceBtn{font-size:18px}
