/* ==========================================================================
   Sirr (سِرّ) — Telegram-Clone Arabic Messaging App
   Production CSS — Light Mode + Dark Mode
   RTL Layout · Arabic (Tajawal) · PWA-Ready
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800&display=swap');

/* ==========================================================================
   1. CSS Variables
   ========================================================================== */

:root {
  /* ---- Brand / Primary ---- */
  --primary:            #2AABEE;
  --primary-dark:       #229ED9;
  --primary-light:      #E3F2FD;
  --primary-lighter:    #EAF5FD;
  --primary-alpha-10:   rgba(42, 171, 238, 0.10);
  --primary-alpha-20:   rgba(42, 171, 238, 0.20);

  /* ---- Backgrounds ---- */
  --bg-app:             #F0F0F0;
  --bg-card:            #FFFFFF;
  --bg-header:          #FFFFFF;
  --bg-nav:             #FFFFFF;
  --bg-input:           #F4F4F4;
  --bg-hover:           rgba(0, 0, 0, 0.04);
  --bg-active:          rgba(0, 0, 0, 0.06);
  --bg-overlay:         rgba(0, 0, 0, 0.40);
  --bg-overlay-light:   rgba(0, 0, 0, 0.20);
  --bg-tooltip:         rgba(0, 0, 0, 0.75);
  --bg-chat:            #E6EBEE;
  --bg-secondary:       #F0F0F0;

  /* ---- Bubbles ---- */
  --bubble-out:         #EFFDDE;
  --bubble-out-hover:   #E3F5D2;
  --bubble-in:          #FFFFFF;
  --bubble-in-hover:    #F5F5F5;

  /* ---- Text ---- */
  --text-primary:       #000000;
  --text-secondary:     #707579;
  --text-dim:           #A0A0A0;
  --text-link:          #2AABEE;
  --text-white:         #FFFFFF;
  --text-bubble-time:   #6EB569;
  --text-bubble-in-time:#A0ACB6;

  /* ---- Borders ---- */
  --border:             #E8E8E8;
  --border-light:       #F0F0F0;
  --border-input:       #DADCE0;

  /* ---- Status Colors ---- */
  --green:              #4DCA56;
  --green-dark:         #3EAE48;
  --red:                #E53935;
  --red-light:          #FDEDED;
  --orange:             #F5A623;
  --yellow:             #FFD54F;

  /* ---- Shadows ---- */
  --shadow-xs:          0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-sm:          0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md:          0 2px 8px rgba(0, 0, 0, 0.10);
  --shadow-lg:          0 4px 16px rgba(0, 0, 0, 0.12);
  --shadow-xl:          0 8px 32px rgba(0, 0, 0, 0.16);
  --shadow-header:      0 1px 0 rgba(0, 0, 0, 0.08);
  --shadow-nav:         0 -1px 0 rgba(0, 0, 0, 0.08);
  --shadow-fab:         0 3px 12px rgba(0, 0, 0, 0.18);
  --shadow-bubble:      0 1px 1px rgba(0, 0, 0, 0.04);

  /* ---- Dimensions ---- */
  --header-height:      56px;
  --nav-height:         56px;
  --chat-row-height:    72px;
  --settings-row-height:48px;
  --status-bar-height:  44px;
  --input-bar-height:   52px;

  /* ---- Avatars ---- */
  --avatar-list:        52px;
  --avatar-chat-header: 40px;
  --avatar-group-msg:   28px;
  --avatar-profile:     90px;
  --avatar-small:       36px;

  /* ---- Border Radius ---- */
  --radius-xs:          4px;
  --radius-sm:          8px;
  --radius-md:          12px;
  --radius-lg:          16px;
  --radius-xl:          20px;
  --radius-bubble:      18px;
  --radius-pill:        100px;
  --radius-circle:      50%;

  /* ---- Transitions ---- */
  --ease:               cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-out:           cubic-bezier(0, 0, 0.2, 1);
  --ease-in:            cubic-bezier(0.4, 0, 1, 1);
  --ease-spring:        cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast:      0.15s;
  --duration:           0.3s;
  --duration-slow:      0.45s;

  /* ---- Z-Index Layers ---- */
  --z-base:             1;
  --z-header:           100;
  --z-nav:              100;
  --z-fab:              200;
  --z-modal:            500;
  --z-sheet:            600;
  --z-context:          700;
  --z-toast:            800;
  --z-overlay:          400;

  /* ---- Phone Frame ---- */
  --frame-width:        390px;
  --frame-height:       844px;
  --frame-radius:       44px;
  --frame-border-color: #1A1A1A;

  /* ---- Safe Areas (defaults, overridden by env()) ---- */
  --safe-top:           env(safe-area-inset-top, 0px);
  --safe-bottom:        env(safe-area-inset-bottom, 0px);
  --safe-left:          env(safe-area-inset-left, 0px);
  --safe-right:         env(safe-area-inset-right, 0px);
}

/* ==========================================================================
   2. Reset & Base
   ========================================================================== */

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html {
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Tajawal', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-weight: 400;
  color: var(--text-primary);
  background-color: var(--bg-app);
  direction: rtl;
  text-align: right;
  height: 100%;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

a {
  color: var(--text-link);
  text-decoration: none;
  cursor: pointer;
}

a:active {
  opacity: 0.7;
}

img,
svg {
  display: block;
  max-width: 100%;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  border: none;
  background: none;
}

ul,
ol {
  list-style: none;
}

::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.25);
}

/* ==========================================================================
   3. Safe Areas & PWA
   ========================================================================== */

@supports (padding-top: env(safe-area-inset-top)) {
  #app {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
}

@media (display-mode: standalone) {
  body {
    background-color: var(--bg-app);
  }

  .phone-frame {
    max-width: 100% !important;
    height: 100% !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
  }

  .phone-notch {
    display: none !important;
  }

  .phone-screen {
    border-radius: 0 !important;
  }

  .status-bar {
    display: none !important;
  }
}

/* ==========================================================================
   4. Phone Frame (desktop only)
   ========================================================================== */

/* Mobile-first: no frame by default */
.phone-frame {
  position: relative;
  width: 100%;
  max-width: 100%;
  height: 100vh;
  height: 100dvh;
  margin: 0;
  border: none;
  border-radius: 0;
  overflow: hidden;
  box-shadow: none;
  background: none;
}

.phone-notch {
  display: none;
}

.phone-screen {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-app);
}

/* ==========================================================================
   5. Status Bar
   ========================================================================== */

.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--status-bar-height);
  padding: 14px 24px 0;
  background: var(--bg-header);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  position: relative;
  z-index: calc(var(--z-header) + 10);
  flex-shrink: 0;
}

.status-time {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.status-icons {
  display: flex;
  align-items: center;
  gap: 5px;
}

.status-icons svg {
  width: 18px;
  height: 18px;
}

/* ==========================================================================
   6. Layout & App Container
   ========================================================================== */

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  background: var(--bg-app);
  overflow: hidden;
  position: relative;
}

#appContent {
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.screen {
  min-height: 100%;
  background: var(--bg-secondary);
}

.screen-body {
  padding: 8px 0;
}

.screen-sub,
.screen-chats,
.screen-contacts,
.screen-settings,
.screen-profile,
.screen-info,
.screen-calls,
.screen-privacy,
.screen-notifications,
.screen-chat-settings,
.screen-storage,
.screen-devices,
.screen-folders,
.screen-edit-profile {
  min-height: 100%;
  background: var(--bg-secondary);
}

.screen-chat,
.screen-group,
.screen-channel {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-secondary);
}

/* ==========================================================================
   7. Screen Header
   ========================================================================== */

.screen-header {
  display: flex;
  align-items: center;
  height: var(--header-height);
  padding: 0 8px;
  background: var(--bg-header);
  box-shadow: var(--shadow-header);
  position: relative;
  z-index: var(--z-header);
  flex-shrink: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
}

.header-title {
  font-size: 19px;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
  padding: 0 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

/* ==========================================================================
   8. Icon Buttons
   ========================================================================== */

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-circle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background var(--duration-fast) var(--ease);
  flex-shrink: 0;
  position: relative;
}

.icon-btn:hover {
  background: var(--bg-hover);
}

.icon-btn:active {
  background: var(--bg-active);
}

.icon-btn svg,
.icon-btn i {
  width: 24px;
  height: 24px;
  font-size: 24px;
}

.icon-btn--primary {
  color: var(--primary);
}

.btn-back {
  color: var(--primary);
}

.btn-back svg {
  width: 24px;
  height: 24px;
}

.btn-more,
.btn-call,
.btn-mic,
.btn-send {
  /* Inherits .icon-btn styles when combined */
}

/* ==========================================================================
   9. Search Bar
   ========================================================================== */

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 4px;
  flex: 1;
  height: 36px;
  padding: 0 12px;
  background: var(--bg-input);
  border-radius: var(--radius-pill);
  transition: background var(--duration-fast) var(--ease);
}

.search-bar__icon {
  color: var(--text-dim);
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.search-bar__icon svg {
  width: 18px;
  height: 18px;
}

.search-bar__input {
  flex: 1;
  height: 36px;
  padding: 0 8px;
  background: transparent;
  border: none;
  font-size: 15px;
  color: var(--text-primary);
  outline: none;
}

.search-bar__input::placeholder {
  color: var(--text-dim);
}

.search-bar__input:focus {
  background: transparent;
}

/* ==========================================================================
   10. Bottom Navigation
   ========================================================================== */

.bottom-nav {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: var(--nav-height);
  padding-bottom: var(--safe-bottom);
  background: var(--bg-nav);
  box-shadow: var(--shadow-nav);
  position: relative;
  z-index: var(--z-nav);
  flex-shrink: 0;
  border-top: 0.5px solid var(--border);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  height: 100%;
  gap: 2px;
  position: relative;
  color: var(--text-secondary);
  transition: color var(--duration-fast) var(--ease);
  padding: 6px 0 2px;
}

.nav-icon-wrap {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill);
  transition: background var(--duration) var(--ease), color var(--duration-fast) var(--ease);
  position: relative;
}

.nav-icon {
  width: 24px;
  height: 24px;
  transition: transform var(--duration) var(--ease-spring);
}

.nav-label {
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
  transition: color var(--duration-fast) var(--ease);
}

/* Active tab state */
.nav-item.active {
  color: var(--primary);
}

.nav-item.active .nav-icon-wrap {
  background: var(--primary-alpha-10);
  padding: 0 16px;
  width: auto;
  min-width: 56px;
}

.nav-item.active .nav-icon {
  transform: scale(1.05);
}

.nav-item.active .nav-label {
  font-weight: 700;
}

/* Nav badge */
.nav-badge {
  position: absolute;
  top: -2px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--primary);
  color: var(--text-white);
  font-size: 11px;
  font-weight: 700;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ==========================================================================
   11. Chat List Rows
   ========================================================================== */

.chat-list {
  background: var(--bg-card);
}

.chat-row {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  height: var(--chat-row-height);
  gap: 12px;
  cursor: pointer;
  position: relative;
  transition: background var(--duration-fast) var(--ease);
}

.chat-row:hover {
  background: var(--bg-hover);
}

.chat-row:active {
  background: var(--bg-active);
}

.chat-row__avatar {
  width: var(--avatar-list);
  height: var(--avatar-list);
  border-radius: var(--radius-circle);
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-row__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 14px;
  height: 14px;
  background: var(--green);
  border: 2px solid var(--bg-card);
  border-radius: var(--radius-circle);
}

.chat-row__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

.chat-row__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chat-row__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chat-row__name {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.chat-row__name-text {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-row__verified {
  display: inline-flex;
  margin-inline-start: 2px;
  color: var(--primary);
  vertical-align: middle;
  flex-shrink: 0;
}

.chat-row__verified svg {
  width: 16px;
  height: 16px;
}

.chat-row__mute {
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.chat-row__mute svg {
  width: 16px;
  height: 16px;
}

.chat-row__time {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-dim);
  white-space: nowrap;
  flex-shrink: 0;
}

.chat-row__time--unread {
  color: var(--primary);
}

.chat-row__preview {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  font-size: 14px;
  font-weight: 400;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.chat-row__typing {
  color: var(--primary);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.chat-row__draft {
  color: var(--red);
  font-weight: 500;
}

.chat-row__checkmarks {
  display: inline-flex;
  align-items: center;
  margin-inline-end: 2px;
}

.chat-row__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.chat-row__pin {
  color: var(--text-dim);
  display: flex;
  align-items: center;
}

.chat-row__pin svg {
  width: 18px;
  height: 18px;
}

/* ==========================================================================
   12. Badge
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  background: var(--primary);
  color: var(--text-white);
  font-size: 12px;
  font-weight: 700;
  border-radius: var(--radius-pill);
  line-height: 1;
}

.badge--muted {
  background: var(--text-dim);
}

.badge--primary {
  background: var(--primary);
  color: var(--text-white);
}

.badge--green {
  background: var(--green);
  color: var(--text-white);
}

.badge--red {
  background: var(--red);
  color: var(--text-white);
}

.badge--outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
}

.badge--dot {
  width: 8px;
  height: 8px;
  min-width: 8px;
  padding: 0;
  border-radius: var(--radius-circle);
}

/* ==========================================================================
   13. Folder Tabs (Telegram-style with emoji + underline)
   ========================================================================== */

.folder-pills-wrap {
  background: var(--bg-card);
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-light);
}

.folder-pills {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-card);
  flex-shrink: 0;
}

.folder-pills::-webkit-scrollbar {
  display: none;
}

.folder-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 14px 8px;
  border-radius: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease);
  flex-shrink: 0;
  background: transparent;
  position: relative;
  border-bottom: 2px solid transparent;
}

.folder-pill:hover {
  background: var(--bg-hover);
}

.folder-pill:active {
  background: var(--bg-active);
}

.folder-pill.active {
  background: transparent;
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 700;
}

.folder-pill-emoji {
  font-size: 16px;
  line-height: 1;
}

.folder-pill-label {
  font-size: 13px;
  font-weight: inherit;
}

.folder-pill-count {
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-alpha-10);
  color: var(--primary);
  line-height: 1;
}

.folder-pill.active .folder-pill-count {
  background: var(--primary);
  color: var(--text-white);
}

/* ==========================================================================
   14. Chat Header
   ========================================================================== */

.chat-header {
  display: flex;
  align-items: center;
  height: var(--header-height);
  padding: 0 4px;
  background: var(--bg-header);
  box-shadow: var(--shadow-header);
  z-index: var(--z-header);
  flex-shrink: 0;
  gap: 4px;
}

.chat-header-info {
  flex: 1;
  min-width: 0;
  padding: 0 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.chat-header-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.chat-header-status {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.chat-header-status.online {
  color: var(--primary);
}

/* ==========================================================================
   15. Chat Body & Background
   ========================================================================== */

.chat-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 8px 4px;
  background: var(--bg-chat);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
}

.chat-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0.04;
  pointer-events: none;
}

.channel-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px;
  background: var(--bg-chat);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* ==========================================================================
   16. Chat Input Bar
   ========================================================================== */

.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 6px 8px;
  background: var(--bg-card);
  border-top: 0.5px solid var(--border);
  flex-shrink: 0;
  min-height: var(--input-bar-height);
}

.chat-input {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: 8px 12px;
  background: var(--bg-input);
  border-radius: 20px;
  font-size: 15px;
  line-height: 1.4;
  color: var(--text-primary);
  resize: none;
  overflow-y: auto;
  border: none;
  outline: none;
  direction: rtl;
  text-align: right;
}

.chat-input input {
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  outline: none;
  font-size: 15px;
  color: var(--text-primary);
  direction: rtl;
  text-align: right;
}

.chat-input::placeholder,
.chat-input input::placeholder {
  color: var(--text-dim);
}

.input-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-circle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: color var(--duration-fast) var(--ease), background var(--duration-fast) var(--ease);
}

.input-icon:hover {
  background: var(--bg-hover);
}

.input-icon:active {
  background: var(--bg-active);
}

.input-icon svg {
  width: 24px;
  height: 24px;
}

/* ==========================================================================
   17. Message Bubbles
   ========================================================================== */

.bubble {
  position: relative;
  padding: 7px 10px 6px;
  max-width: 85%;
  word-wrap: break-word;
  overflow-wrap: break-word;
  box-shadow: var(--shadow-bubble);
  margin-bottom: 2px;
}

.bubble--out {
  background: var(--bubble-out);
  border-radius: var(--radius-bubble) var(--radius-bubble) 6px var(--radius-bubble);
  align-self: flex-start;
  /* RTL: sent messages on the right = flex-start in RTL */
}

.bubble--in {
  background: var(--bubble-in);
  border-radius: var(--radius-bubble) var(--radius-bubble) var(--radius-bubble) 6px;
  align-self: flex-end;
  /* RTL: received messages on the left = flex-end in RTL */
}

.bubble__content {
  position: relative;
}

.bubble__text {
  font-size: 15px;
  line-height: 1.4;
  color: var(--text-primary);
  white-space: pre-wrap;
}

.bubble__sender {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 2px;
  line-height: 1.2;
}

/* Named color rotation for group senders */
.bubble__sender--color-1 { color: #E17076; }
.bubble__sender--color-2 { color: #7BC862; }
.bubble__sender--color-3 { color: #E5C441; }
.bubble__sender--color-4 { color: #65AADD; }
.bubble__sender--color-5 { color: #A695E7; }
.bubble__sender--color-6 { color: #EE7AE6; }
.bubble__sender--color-7 { color: #6EC9CB; }
.bubble__sender--color-8 { color: #FAA774; }

.bubble__meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  margin-top: 1px;
  float: left;
  padding-right: 8px;
}

.bubble__time {
  font-size: 11px;
  font-weight: 400;
  line-height: 1;
  white-space: nowrap;
}

.bubble--out .bubble__time {
  color: var(--text-bubble-time);
}

.bubble--in .bubble__time {
  color: var(--text-bubble-in-time);
}

/* Reply block inside bubble */
.bubble__reply-block {
  border-right: 3px solid var(--primary);
  padding: 4px 10px 4px 4px;
  margin-bottom: 4px;
  border-radius: var(--radius-xs);
  background: rgba(0, 0, 0, 0.04);
  cursor: pointer;
}

.dark-mode .bubble__reply-block {
  background: rgba(255, 255, 255, 0.06);
}

.bubble__reply-text {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
  max-width: 230px;
}

/* Forward label */
.bubble__forward-label {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 400;
  font-style: italic;
  color: var(--text-secondary);
}

/* Image message inside bubble */
.bubble__image {
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  max-width: 280px;
  cursor: pointer;
}

.bubble__image-placeholder {
  background: var(--bg-input);
  aspect-ratio: 4/3;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
}

.bubble__image-placeholder svg {
  width: 48px;
  height: 48px;
  opacity: 0.4;
}

.bubble__caption {
  font-size: 14px;
  color: var(--text-primary);
  margin-top: 6px;
  line-height: 1.4;
}

/* Voice message inside bubble */
.bubble__voice {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 200px;
  padding: 4px 0;
}

.bubble__voice-play {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-circle);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: opacity var(--duration-fast) var(--ease);
}

.bubble__voice-play:active {
  opacity: 0.7;
}

.bubble--out .bubble__voice-play {
  background: var(--green);
  color: var(--text-white);
}

.bubble--in .bubble__voice-play {
  background: var(--primary);
  color: var(--text-white);
}

.bubble__voice-wave {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}

.bubble__voice-wave svg {
  width: 100%;
  height: 28px;
}

.bubble__voice-dur {
  font-size: 11px;
  flex-shrink: 0;
}

.bubble--out .bubble__voice-dur {
  color: var(--text-bubble-time);
}

.bubble--in .bubble__voice-dur {
  color: var(--text-bubble-in-time);
}

/* File message inside bubble */
.bubble__file {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  padding: 4px 0;
  cursor: pointer;
}

.bubble__file-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--primary);
  color: var(--text-white);
}

.bubble__file-icon svg {
  width: 22px;
  height: 22px;
}

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

.bubble__file-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.bubble__file-size {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 1px;
  display: block;
}

/* Link preview inside bubble */
.bubble__link {
  margin-top: 6px;
  cursor: pointer;
}

.bubble__link-preview {
  border-right: 3px solid var(--primary);
  padding-right: 10px;
}

.bubble__link-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  display: block;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.bubble__link-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.3;
  display: block;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.bubble__link-url {
  font-size: 12px;
  color: var(--text-link);
  margin-top: 2px;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sent/Received helpers */
.bubble-sent {
  align-self: flex-start;
}

.bubble-received {
  align-self: flex-end;
}

/* Checkmarks */
.checkmarks {
  display: inline-flex;
  align-items: center;
}

.checkmarks svg {
  width: 16px;
  height: 16px;
}

.checkmarks--sent svg {
  color: var(--text-dim);
}

.checkmarks--delivered svg {
  color: var(--text-bubble-time);
}

.checkmarks--read svg {
  color: var(--text-bubble-time);
}

/* Spacing between bubble groups */
.bubble--out + .bubble--in,
.bubble--in + .bubble--out {
  margin-top: 8px;
}

/* ==========================================================================
   18. Date Separator & Typing Indicator
   ========================================================================== */

.date-separator {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
  position: sticky;
  top: 0;
  z-index: 2;
}

.date-separator__pill {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-white);
  background: rgba(0, 0, 0, 0.25);
  padding: 3px 12px;
  border-radius: var(--radius-pill);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* ==========================================================================
   19. Settings Cards & Rows
   ========================================================================== */

.settings-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  margin: 8px 16px;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  padding: 8px 16px 4px;
  letter-spacing: 0.3px;
}

.section-count {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-dim);
  margin-inline-start: 4px;
}

.settings-row {
  display: flex;
  align-items: center;
  min-height: var(--settings-row-height);
  padding: 10px 16px;
  gap: 14px;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease);
  position: relative;
}

.settings-row:hover {
  background: var(--bg-hover);
}

.settings-row:active {
  background: var(--bg-active);
}

.settings-row + .settings-row {
  border-top: 0.5px solid var(--border);
}

.settings-row__icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.settings-row__icon svg,
.settings-row__icon i {
  width: 18px;
  height: 18px;
  font-size: 18px;
  color: var(--text-white);
}

.settings-row__icon--blue    { background: var(--primary); }
.settings-row__icon--green   { background: var(--green); }
.settings-row__icon--red     { background: var(--red); }
.settings-row__icon--orange  { background: var(--orange); }
.settings-row__icon--purple  { background: #9C27B0; }
.settings-row__icon--yellow  { background: var(--yellow); }
.settings-row__icon--gray    { background: var(--text-secondary); }
.settings-row__icon--teal    { background: #00BCD4; }
.settings-row__icon--pink    { background: #E91E63; }

.settings-row__body {
  flex: 1;
  min-width: 0;
}

.settings-row__content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.settings-row__text {
  flex: 1;
  min-width: 0;
}

.settings-row__label {
  font-size: 15px;
  font-weight: 400;
  color: var(--text-primary);
  line-height: 1.3;
}

.settings-row__subtitle {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-top: 1px;
  line-height: 1.3;
  display: block;
}

.settings-row__end {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.settings-row__value {
  font-size: 14px;
  color: var(--primary);
  flex-shrink: 0;
}

.settings-row__arrow {
  width: 20px;
  height: 20px;
  color: var(--text-dim);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  /* Flip for RTL */
  transform: scaleX(-1);
}

.settings-row__arrow svg {
  width: 18px;
  height: 18px;
}

.settings-row__label--danger {
  color: var(--red);
}

/* Settings icon (colored circle with white SVG) */
.settings-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.settings-icon svg {
  width: 18px;
  height: 18px;
}

/* Settings profile card */
.settings-profile-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  margin: 8px 16px;
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease);
}

.settings-profile-card:hover {
  background: var(--bg-hover);
}

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

.settings-profile-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.settings-profile-phone {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 2px;
  direction: ltr;
  text-align: right;
}

.settings-profile-username {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 1px;
}

.settings-profile-arrow {
  color: var(--text-dim);
  flex-shrink: 0;
}

.settings-profile-arrow svg {
  width: 20px;
  height: 20px;
}

/* Simple settings rows (no icon) */
.settings-simple-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  min-height: 44px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.settings-simple-row:last-child {
  border-bottom: none;
}

.settings-simple-label {
  font-size: 15px;
  color: var(--text-primary);
}

.settings-simple-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  display: block;
  margin-top: 2px;
}

.settings-info-text {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 12px 16px;
  line-height: 1.6;
}

.settings-hint {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 6px 16px 14px;
  line-height: 1.4;
}

/* ==========================================================================
   20. Toggle Switch
   ========================================================================== */

.toggle {
  position: relative;
  width: 51px;
  height: 31px;
  flex-shrink: 0;
  cursor: pointer;
  display: inline-block;
}

.toggle__input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle__slider {
  position: absolute;
  inset: 0;
  background: #E0E0E0;
  border-radius: 31px;
  transition: background var(--duration) var(--ease);
}

.toggle__slider::before {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 27px;
  height: 27px;
  background: var(--bg-card);
  border-radius: var(--radius-circle);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform var(--duration) var(--ease);
}

.toggle__input:checked + .toggle__slider {
  background: var(--green);
}

.toggle__input:checked + .toggle__slider::before {
  transform: translateX(-20px);
}

/* Alternative toggle-switch class */
.toggle-switch {
  position: relative;
  width: 51px;
  height: 31px;
  flex-shrink: 0;
  cursor: pointer;
  display: inline-block;
  background: #E0E0E0;
  border-radius: 31px;
  transition: background var(--duration) var(--ease);
}

.toggle-switch::before {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 27px;
  height: 27px;
  background: var(--bg-card);
  border-radius: var(--radius-circle);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform var(--duration) var(--ease);
}

.toggle-switch.checked {
  background: var(--green);
}

.toggle-switch.checked::before {
  transform: translateX(-20px);
}

/* ==========================================================================
   21. Contacts
   ========================================================================== */

.contact-list {
  background: var(--bg-card);
}

.contact-letter-sep {
  padding: 8px 16px 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  background: var(--bg-app);
  position: sticky;
  top: 0;
  z-index: 2;
}

.contact-row {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  gap: 12px;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease);
}

.contact-row:hover {
  background: var(--bg-hover);
}

.contact-row:active {
  background: var(--bg-active);
}

.contact-row__avatar {
  width: var(--avatar-list);
  height: var(--avatar-list);
  border-radius: var(--radius-circle);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
}

.contact-row__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.contact-row__body {
  flex: 1;
  min-width: 0;
}

.contact-row__name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.contact-row__status {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
  display: block;
}

.contact-row__status--online {
  color: var(--primary);
}

/* ==========================================================================
   22. Profile / Info Screen
   ========================================================================== */

.profile-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 16px;
  background: var(--bg-card);
}

.profile-avatar-wrap {
  position: relative;
  width: var(--avatar-profile);
  height: var(--avatar-profile);
  border-radius: var(--radius-circle);
  overflow: hidden;
  margin-bottom: 12px;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
}

.profile-avatar-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-camera-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease);
  cursor: pointer;
  color: var(--text-white);
}

.profile-avatar-wrap:hover .profile-camera-overlay {
  opacity: 1;
}

.profile-camera-overlay svg {
  width: 28px;
  height: 28px;
}

.profile-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
}

.profile-phone {
  font-size: 15px;
  color: var(--text-secondary);
  margin-top: 4px;
  direction: ltr;
}

.profile-username {
  font-size: 15px;
  color: var(--text-link);
  margin-top: 2px;
}

.profile-bio {
  font-size: 14px;
  color: var(--text-primary);
  margin-top: 8px;
  text-align: center;
  line-height: 1.5;
  max-width: 300px;
}

/* Profile quick-action rows */
.profile-quick-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease);
}

.profile-quick-row:hover {
  background: var(--bg-hover);
}

.profile-quick-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-circle);
  background: var(--primary-alpha-10);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
}

.profile-quick-icon svg {
  width: 22px;
  height: 22px;
}

.profile-quick-content {
  flex: 1;
  min-width: 0;
}

.profile-quick-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

.profile-quick-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 1px;
}

.profile-quick-arrow {
  color: var(--text-dim);
  flex-shrink: 0;
}

.profile-quick-arrow svg {
  width: 18px;
  height: 18px;
}

/* Info screen (contact/group info) */
.info-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 16px;
  background: var(--bg-card);
}

.info-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
  margin-top: 12px;
}

.info-status {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.info-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 16px;
  background: var(--bg-card);
  border-top: 0.5px solid var(--border);
}

.info-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: opacity var(--duration-fast) var(--ease);
}

.info-action-btn:active {
  opacity: 0.6;
}

.info-action-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-circle);
  background: var(--primary-alpha-10);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

.info-action-icon svg {
  width: 22px;
  height: 22px;
}

.info-action-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--primary);
}

.info-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease);
}

.info-row:hover {
  background: var(--bg-hover);
}

.info-row-icon {
  width: 24px;
  height: 24px;
  color: var(--text-secondary);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.info-row-icon svg {
  width: 22px;
  height: 22px;
}

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

.info-row-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.info-row-value {
  font-size: 15px;
  color: var(--text-primary);
  margin-top: 1px;
}

/* ==========================================================================
   23. Channel Posts
   ========================================================================== */

.post {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  margin: 4px 8px;
  padding: 12px;
  box-shadow: var(--shadow-xs);
}

.post__text {
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.post__image-placeholder {
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 8px;
  background: var(--bg-input);
  aspect-ratio: 16/9;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
}

.post__image-placeholder svg {
  width: 48px;
  height: 48px;
  opacity: 0.4;
}

.post__reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  margin-bottom: 8px;
}

.post__reaction {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--bg-input);
  font-size: 14px;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease);
  border: 1.5px solid transparent;
}

.post__reaction:hover {
  background: var(--primary-lighter);
}

.post__reaction.active {
  background: var(--primary-alpha-10);
  border-color: var(--primary);
}

.post__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.post__views {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-dim);
}

.post__views svg {
  width: 16px;
  height: 16px;
}

.post__time {
  font-size: 12px;
  color: var(--text-dim);
}

/* ==========================================================================
   24. Calls
   ========================================================================== */

.call-list {
  background: var(--bg-card);
}

.call-row {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  gap: 12px;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease);
}

.call-row:hover {
  background: var(--bg-hover);
}

.call-row:active {
  background: var(--bg-active);
}

.call-row__avatar {
  width: var(--avatar-list);
  height: var(--avatar-list);
  border-radius: var(--radius-circle);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
}

.call-row__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.call-row__body {
  flex: 1;
  min-width: 0;
}

.call-row__name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

.call-row__info {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.call-row__dir {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.call-row__dir svg {
  width: 16px;
  height: 16px;
}

.call-row__detail {
  font-size: 13px;
  color: var(--text-secondary);
}

.call-row__action {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-circle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
  transition: background var(--duration-fast) var(--ease);
}

.call-row__action:hover {
  background: var(--primary-alpha-10);
}

.call-row__action svg {
  width: 22px;
  height: 22px;
}

/* ==========================================================================
   25. Sessions / Devices
   ========================================================================== */

.session-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease);
}

.session-card:hover {
  background: var(--bg-hover);
}

.session-card:active {
  background: var(--bg-active);
}

.session-card + .session-card {
  border-top: 0.5px solid var(--border);
}

.session-card--current {
  background: rgba(77, 202, 86, 0.05);
}

.session-card__icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--primary-alpha-10);
  color: var(--primary);
}

.session-card__icon svg {
  width: 24px;
  height: 24px;
}

.session-card__body {
  flex: 1;
  min-width: 0;
}

.session-card__name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

.session-card__platform {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 1px;
}

.session-card__location {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 1px;
}

.session-card__active {
  font-size: 12px;
  margin-top: 2px;
  color: var(--text-dim);
}

.session__current {
  padding: 16px;
}

.current-device-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: rgba(77, 202, 86, 0.05);
  border-radius: var(--radius-md);
}

/* ==========================================================================
   26. Folders Management
   ========================================================================== */

.folder-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease);
}

.folder-row:hover {
  background: var(--bg-hover);
}

.folder-row + .folder-row {
  border-top: 0.5px solid var(--border);
}

.folder-row__icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--primary-alpha-10);
  color: var(--primary);
}

.folder-row__icon svg {
  width: 20px;
  height: 20px;
}

.folder-row__body {
  flex: 1;
  min-width: 0;
}

.folder-row__name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

.folder-row__count {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 1px;
}

.folder-row__arrow {
  color: var(--text-dim);
  flex-shrink: 0;
}

.folder-row__arrow svg {
  width: 18px;
  height: 18px;
}

.create-folder-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  cursor: pointer;
  color: var(--primary);
  font-size: 15px;
  font-weight: 500;
  transition: background var(--duration-fast) var(--ease);
}

.create-folder-row:hover {
  background: var(--bg-hover);
}

.create-folder-row svg {
  width: 22px;
  height: 22px;
}

/* ==========================================================================
   27. Forms & Inputs
   ========================================================================== */

.form-row {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-card);
  border-bottom: 0.5px solid var(--border);
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--primary);
  margin-bottom: 6px;
  padding: 0 4px;
}

.form-input {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 15px;
  color: var(--text-primary);
  transition: border-color var(--duration-fast) var(--ease);
  direction: rtl;
  text-align: right;
}

.form-input:focus {
  border-color: var(--primary);
}

.form-input::placeholder {
  color: var(--text-dim);
}

.form-textarea {
  width: 100%;
  min-height: 80px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 15px;
  color: var(--text-primary);
  resize: vertical;
  transition: border-color var(--duration-fast) var(--ease);
  direction: rtl;
  text-align: right;
}

.form-textarea:focus {
  border-color: var(--primary);
}

.char-count {
  font-size: 12px;
  color: var(--text-dim);
  text-align: left;
  padding: 4px 4px 0;
}

.edit-avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px;
  background: var(--bg-card);
}

/* ==========================================================================
   28. Media Grid
   ========================================================================== */

.media-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 0 2px;
}

.media-grid__cell {
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 2px;
  cursor: pointer;
  transition: opacity var(--duration-fast) var(--ease);
}

.media-grid__cell:hover {
  opacity: 0.85;
}

.media-grid__cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-grid__placeholder {
  aspect-ratio: 1;
  background: var(--bg-input);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
}

.media-grid__placeholder svg {
  width: 32px;
  height: 32px;
  opacity: 0.4;
}

/* ==========================================================================
   29. Storage
   ========================================================================== */

.storage-bar {
  height: 8px;
  border-radius: 8px;
  background: var(--bg-input);
  overflow: hidden;
  display: flex;
  margin: 8px 0;
}

.storage-bar__track {
  display: flex;
  width: 100%;
  height: 100%;
}

.storage-bar__segment {
  height: 100%;
  min-width: 3px;
  transition: width var(--duration) var(--ease);
}

.storage-bar__segment--photos  { background: #2196F3; }
.storage-bar__segment--videos  { background: #9C27B0; }
.storage-bar__segment--files   { background: #4CAF50; }
.storage-bar__segment--music   { background: #FF9800; }
.storage-bar__segment--other   { background: #607D8B; }

.storage-details {
  padding: 8px 0;
}

.storage-detail-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.storage-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-circle);
  flex-shrink: 0;
}

.storage-size {
  font-weight: 500;
  color: var(--text-primary);
  margin-inline-start: auto;
}

/* ==========================================================================
   30. Slider
   ========================================================================== */

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 4px;
  background: var(--border);
  outline: none;
  direction: ltr;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  transition: transform var(--duration-fast) var(--ease);
}

.slider::-webkit-slider-thumb:active {
  transform: scale(1.2);
}

.slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.slider-group {
  padding: 12px 16px;
}

.slider-group__label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.slider-group__row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.slider-group__value {
  font-size: 13px;
  color: var(--text-secondary);
  flex-shrink: 0;
  min-width: 20px;
  text-align: center;
}

/* ==========================================================================
   31. Chat Settings Preview
   ========================================================================== */

.chat-preview-area {
  padding: 16px;
  background: var(--bg-chat);
  border-radius: var(--radius-md);
  margin: 8px 16px;
}

.preview-bubble {
  background: var(--bubble-out);
  padding: 8px 12px;
  border-radius: var(--radius-bubble);
  max-width: 80%;
  margin-bottom: 8px;
}

.preview-text {
  font-size: 15px;
  color: var(--text-primary);
}

.preview-time {
  font-size: 11px;
  color: var(--text-bubble-time);
  text-align: left;
  margin-top: 2px;
}

.theme-swatches {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  flex-wrap: wrap;
}

.theme-dot {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-circle);
  cursor: pointer;
  border: 3px solid transparent;
  transition: border-color var(--duration-fast) var(--ease), transform var(--duration-fast) var(--ease);
}

.theme-dot:hover {
  transform: scale(1.1);
}

.theme-dot.active {
  border-color: var(--primary);
}

/* ==========================================================================
   32. FAB (Floating Action Button)
   ========================================================================== */

.fab {
  position: fixed;
  bottom: calc(var(--nav-height) + 20px + var(--safe-bottom));
  left: 20px;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-circle);
  background: var(--primary);
  color: var(--text-white);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-fab);
  z-index: var(--z-fab);
  cursor: pointer;
  transition: transform var(--duration) var(--ease-spring), background var(--duration-fast) var(--ease);
}

.fab:hover {
  background: var(--primary-dark);
}

.fab:active {
  transform: scale(0.92);
}

.fab svg {
  width: 24px;
  height: 24px;
}

/* ==========================================================================
   33. Modals & Bottom Sheets
   ========================================================================== */

.bottom-sheet-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: var(--z-overlay);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--duration) var(--ease), visibility var(--duration) var(--ease);
}

.bottom-sheet-overlay--visible {
  opacity: 1;
  visibility: visible;
}

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  z-index: var(--z-sheet);
  transform: translateY(100%);
  transition: transform var(--duration) var(--ease-out);
  max-height: 85vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.bottom-sheet--visible {
  transform: translateY(0);
}

.bottom-sheet__handle {
  width: 36px;
  height: 4px;
  background: #D0D0D0;
  border-radius: 4px;
  margin: 8px auto;
}

.bottom-sheet__header {
  padding: 12px 20px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bottom-sheet__title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.bottom-sheet__close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-circle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease);
}

.bottom-sheet__close:hover {
  background: var(--bg-hover);
}

.bottom-sheet__close svg {
  width: 20px;
  height: 20px;
}

.bottom-sheet__content {
  padding: 4px 0 16px;
}

/* ==========================================================================
   34. Context Menu
   ========================================================================== */

.context-menu {
  position: fixed;
  min-width: 200px;
  max-width: 260px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-context);
  padding: 6px 0;
  opacity: 0;
  transform: scale(0.9);
  transform-origin: top right;
  transition: opacity var(--duration-fast) var(--ease), transform var(--duration-fast) var(--ease-spring);
  pointer-events: none;
}

.context-menu--visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: all;
}

.context-menu__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease);
}

.context-menu__item:hover {
  background: var(--bg-hover);
}

.context-menu__item:active {
  background: var(--bg-active);
}

.context-menu__icon {
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.context-menu__icon svg {
  width: 20px;
  height: 20px;
}

.context-menu__label {
  font-size: 14px;
  color: var(--text-primary);
}

.context-menu__item--danger {
  color: var(--red);
}

.context-menu__item--danger .context-menu__icon {
  color: var(--red);
}

.context-menu__item--danger .context-menu__label {
  color: var(--red);
}

/* ==========================================================================
   35. Toast Notifications
   ========================================================================== */

.toast-container {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: var(--bg-tooltip);
  color: var(--text-white);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  white-space: nowrap;
  pointer-events: all;
  animation: toastIn var(--duration) var(--ease-spring) forwards;
  opacity: 0;
  transform: translateY(12px) scale(0.95);
}

.toast--visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.toast--exit {
  animation: toastOut var(--duration-fast) var(--ease) forwards;
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateY(-8px) scale(0.95);
  }
}

/* ==========================================================================
   36. Ripple Effect
   ========================================================================== */

/* JS-created ripple spans (from UI.addRipple) */
span.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.12);
  transform: scale(0);
  animation: ripple-anim 0.5s ease-out forwards;
  pointer-events: none;
}

@keyframes ripple-anim {
  to {
    transform: scale(1);
    opacity: 0;
  }
}

/* ==========================================================================
   37. Buttons
   ========================================================================== */

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 14px 24px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-full {
  width: 100%;
}

.btn-danger {
  background: var(--red);
  color: var(--text-white);
  border: none;
  padding: 14px 24px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-danger:hover {
  background: #D32F2F;
}

.btn-text {
  background: transparent;
  color: var(--primary);
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease);
}

.btn-text:hover {
  background: var(--primary-alpha-10);
}

.btn-text-small {
  background: transparent;
  color: var(--primary);
  border: none;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease);
}

.btn-text-small:hover {
  background: var(--primary-alpha-10);
}

/* ==========================================================================
   38. Premium / Stars / Gift / FAQ Screens
   ========================================================================== */

.premium-hero {
  text-align: center;
  padding: 32px 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  margin-bottom: 16px;
}

.premium-star {
  font-size: 48px;
  margin-bottom: 12px;
}

.premium-title {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 8px;
  color: #fff;
}

.premium-desc {
  font-size: 14px;
  opacity: 0.9;
  margin: 0;
  line-height: 1.6;
}

.premium-cta {
  padding: 16px;
}

.premium-feature {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.premium-feature:last-child {
  border-bottom: none;
}

.pf-icon {
  font-size: 24px;
  flex-shrink: 0;
  width: 32px;
  text-align: center;
}

.pf-text strong {
  font-size: 15px;
  color: var(--text-primary);
  display: block;
  margin-bottom: 2px;
}

.pf-text p {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}

/* Stars */
.stars-pack {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.stars-pack:last-child {
  border-bottom: none;
}

.stars-price {
  color: var(--primary);
  font-weight: 600;
}

.stars-balance {
  text-align: center;
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  padding: 24px 16px;
}

/* Gift */
.gift-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  position: relative;
}

.gift-option:last-child {
  border-bottom: none;
}

.gift-option.popular {
  background: rgba(42, 171, 238, 0.06);
}

.gift-duration {
  font-size: 15px;
  font-weight: 500;
}

.gift-price {
  color: var(--primary);
  font-weight: 600;
}

.gift-badge {
  position: absolute;
  top: 4px;
  left: 16px;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}

/* Help / FAQ */
.help-version {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  padding: 24px 16px;
  line-height: 1.6;
}

.faq-item {
  padding: 14px 16px;
}

.faq-question {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.faq-answer {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 0 16px;
}

/* Language */
.lang-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease);
}

.lang-row:hover {
  background: var(--bg-hover);
}

.lang-row.selected {
  background: rgba(42, 171, 238, 0.06);
}

.lang-info {
  display: flex;
  flex-direction: column;
}

.lang-check svg {
  width: 20px;
  height: 20px;
}

/* ==========================================================================
   39. Shared Media / Info Rows
   ========================================================================== */

.shared-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease);
}

.shared-row:hover {
  background: var(--bg-hover);
}

.shared-row-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--primary-alpha-10);
  color: var(--primary);
}

.shared-row-icon svg {
  width: 20px;
  height: 20px;
}

.shared-row-content {
  flex: 1;
  min-width: 0;
}

.shared-row-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

.shared-row-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 1px;
}

/* ==========================================================================
   40. Danger Section
   ========================================================================== */

.danger-section {
  margin: 8px 16px;
}

.danger {
  color: var(--red);
  font-weight: 500;
}

/* ==========================================================================
   41. Overlay
   ========================================================================== */

.overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: var(--z-overlay);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--duration) var(--ease), visibility var(--duration) var(--ease);
}

.overlay.active,
.overlay--visible {
  opacity: 1;
  visibility: visible;
}

/* ==========================================================================
   42. Animations & Transitions
   ========================================================================== */

/* Slide in from right (for RTL: from left visually) */
@keyframes slideInRight {
  from {
    transform: translateX(-100%);
    opacity: 0.5;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(-100%);
    opacity: 0.5;
  }
}

/* Slide in from left (for RTL: from right visually) */
@keyframes slideInLeft {
  from {
    transform: translateX(100%);
    opacity: 0.5;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutLeft {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0.5;
  }
}

/* Fade */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* Scale pop */
@keyframes scaleIn {
  from {
    transform: scale(0.85);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Slide up */
@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Stagger children */
.stagger-children > * {
  opacity: 0;
  animation: slideUp var(--duration) var(--ease-out) forwards;
}

.stagger-children > *:nth-child(1)  { animation-delay: 0.00s; }
.stagger-children > *:nth-child(2)  { animation-delay: 0.03s; }
.stagger-children > *:nth-child(3)  { animation-delay: 0.06s; }
.stagger-children > *:nth-child(4)  { animation-delay: 0.09s; }
.stagger-children > *:nth-child(5)  { animation-delay: 0.12s; }
.stagger-children > *:nth-child(6)  { animation-delay: 0.15s; }
.stagger-children > *:nth-child(7)  { animation-delay: 0.18s; }
.stagger-children > *:nth-child(8)  { animation-delay: 0.21s; }
.stagger-children > *:nth-child(9)  { animation-delay: 0.24s; }
.stagger-children > *:nth-child(10) { animation-delay: 0.27s; }

/* Press effect */
.press-effect {
  transition: transform var(--duration-fast) var(--ease);
}

.press-effect:active {
  transform: scale(0.97);
}

/* Page transition helpers */
.view-enter {
  animation: slideInRight var(--duration) var(--ease-out);
}

.view-exit {
  animation: slideOutLeft var(--duration-fast) var(--ease);
}

.view-enter-back {
  animation: slideInLeft var(--duration) var(--ease-out);
}

.view-exit-back {
  animation: slideOutRight var(--duration-fast) var(--ease);
}

/* Spin animation (for loaders) */
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Shimmer / Skeleton loader */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(90deg,
    var(--bg-input) 0%,
    var(--bg-hover) 40%,
    var(--bg-input) 80%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-xs);
}

/* ==========================================================================
   43. Dark Mode
   ========================================================================== */

.dark-mode {
  --bg-app:             #181818;
  --bg-card:            #212121;
  --bg-header:          #212121;
  --bg-nav:             #212121;
  --bg-input:           #2C2C2C;
  --bg-hover:           rgba(255, 255, 255, 0.06);
  --bg-active:          rgba(255, 255, 255, 0.10);
  --bg-overlay:         rgba(0, 0, 0, 0.55);
  --bg-overlay-light:   rgba(0, 0, 0, 0.35);
  --bg-tooltip:         rgba(50, 50, 50, 0.92);
  --bg-chat:            #0E1621;
  --bg-secondary:       #181818;

  --bubble-out:         #2B5278;
  --bubble-out-hover:   #2D5A85;
  --bubble-in:          #182533;
  --bubble-in-hover:    #1D2D3E;

  --text-primary:       #FFFFFF;
  --text-secondary:     #AAAAAA;
  --text-dim:           #707579;
  --text-bubble-time:   #7EB8DE;
  --text-bubble-in-time:#6D8799;

  --border:             #303030;
  --border-light:       #282828;
  --border-input:       #404040;

  --shadow-xs:          0 1px 2px rgba(0, 0, 0, 0.15);
  --shadow-sm:          0 1px 3px rgba(0, 0, 0, 0.20);
  --shadow-md:          0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-lg:          0 4px 16px rgba(0, 0, 0, 0.30);
  --shadow-xl:          0 8px 32px rgba(0, 0, 0, 0.40);
  --shadow-header:      0 1px 0 rgba(255, 255, 255, 0.05);
  --shadow-nav:         0 -1px 0 rgba(255, 255, 255, 0.05);
  --shadow-fab:         0 3px 12px rgba(0, 0, 0, 0.35);
  --shadow-bubble:      none;

  --red-light:          rgba(229, 57, 53, 0.15);
  --primary-light:      rgba(42, 171, 238, 0.15);
  --primary-lighter:    rgba(42, 171, 238, 0.08);
}

.dark-mode body,
.dark-mode #app {
  background: var(--bg-app);
}

.dark-mode .status-bar {
  background: var(--bg-header);
  color: var(--text-primary);
}

.dark-mode ::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
}

.dark-mode ::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.20);
}

.dark-mode .toggle__slider {
  background: #3A3A3A;
}

.dark-mode .toggle-switch {
  background: #3A3A3A;
}

.dark-mode span.ripple {
  background: rgba(255, 255, 255, 0.15);
}

.dark-mode .bottom-nav {
  border-top-color: var(--border);
}

.dark-mode .context-menu {
  background: #2A2A2A;
}

/* ==========================================================================
   44. Utilities
   ========================================================================== */

.text-primary   { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-dim       { color: var(--text-dim) !important; }
.text-link      { color: var(--text-link) !important; }
.text-white     { color: var(--text-white) !important; }
.text-green     { color: var(--green) !important; }
.text-red       { color: var(--red) !important; }

.bg-primary     { background: var(--primary) !important; }
.bg-card        { background: var(--bg-card) !important; }
.bg-app         { background: var(--bg-app) !important; }

.font-light     { font-weight: 300 !important; }
.font-regular   { font-weight: 400 !important; }
.font-medium    { font-weight: 500 !important; }
.font-bold      { font-weight: 700 !important; }
.font-extrabold { font-weight: 800 !important; }

.text-center    { text-align: center !important; }
.text-start     { text-align: right !important; } /* RTL start = right */
.text-end       { text-align: left !important; }  /* RTL end = left */

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.flex           { display: flex !important; }
.flex-col       { flex-direction: column !important; }
.flex-center    { display: flex; align-items: center; justify-content: center; }
.flex-between   { display: flex; align-items: center; justify-content: space-between; }
.flex-1         { flex: 1 !important; }
.flex-shrink-0  { flex-shrink: 0 !important; }
.gap-4          { gap: 4px !important; }
.gap-8          { gap: 8px !important; }
.gap-12         { gap: 12px !important; }
.gap-16         { gap: 16px !important; }

.p-0            { padding: 0 !important; }
.p-8            { padding: 8px !important; }
.p-12           { padding: 12px !important; }
.p-16           { padding: 16px !important; }
.px-16          { padding-left: 16px !important; padding-right: 16px !important; }
.py-8           { padding-top: 8px !important; padding-bottom: 8px !important; }
.py-12          { padding-top: 12px !important; padding-bottom: 12px !important; }
.mt-4           { margin-top: 4px !important; }
.mt-8           { margin-top: 8px !important; }
.mt-16          { margin-top: 16px !important; }
.mb-8           { margin-bottom: 8px !important; }
.mb-16          { margin-bottom: 16px !important; }

.w-full         { width: 100% !important; }
.h-full         { height: 100% !important; }

.rounded-sm     { border-radius: var(--radius-sm) !important; }
.rounded-md     { border-radius: var(--radius-md) !important; }
.rounded-lg     { border-radius: var(--radius-lg) !important; }
.rounded-full   { border-radius: var(--radius-circle) !important; }

.hidden         { display: none !important; }
.invisible      { visibility: hidden !important; }
.overflow-hidden { overflow: hidden !important; }
.cursor-pointer { cursor: pointer !important; }
.select-text    { user-select: text !important; -webkit-user-select: text !important; }
.no-select      { user-select: none !important; -webkit-user-select: none !important; }

.ltr            { direction: ltr !important; text-align: left !important; }
.rtl            { direction: rtl !important; text-align: right !important; }

/* ==========================================================================
   45. Responsive & Media Queries
   ========================================================================== */

/* Mobile: hide status bar */
.status-bar {
  display: none;
}

/* Desktop: add phone frame */
@media (min-width: 768px) {
  body {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1A1A1A;
    min-height: 100vh;
  }

  .phone-frame {
    width: var(--frame-width);
    max-width: var(--frame-width);
    height: calc(100vh - 32px);
    max-height: var(--frame-height);
    margin: 16px auto;
    border: 3px solid var(--frame-border-color);
    border-radius: var(--frame-radius);
    box-shadow:
      0 0 0 2px #333,
      0 20px 60px rgba(0, 0, 0, 0.4),
      0 0 0 8px rgba(0, 0, 0, 0.1);
    background: var(--frame-border-color);
  }

  .phone-notch {
    display: block;
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 126px;
    height: 34px;
    background: var(--frame-border-color);
    border-radius: 0 0 20px 20px;
    z-index: 1000;
  }

  .phone-notch::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 12px;
    background: #2C2C2C;
    border-radius: 50%;
    box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.5);
  }

  .phone-screen {
    border-radius: calc(var(--frame-radius) - 3px);
  }

  .status-bar {
    display: flex;
  }
}

/* Landscape phone */
@media (max-width: 767px) and (orientation: landscape) {
  .bottom-nav {
    height: 44px;
  }

  .screen-header {
    height: 44px;
  }

  .chat-header {
    height: 44px;
  }
}

/* PWA standalone */
@media (display-mode: standalone) {
  .phone-frame {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: none;
  }

  .phone-notch {
    display: none;
  }

  .phone-screen {
    border-radius: 0;
  }

  .status-bar {
    display: none;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Print */
@media print {
  .phone-frame {
    border: none;
    box-shadow: none;
    border-radius: 0;
    max-width: 100%;
    height: auto;
  }

  .bottom-nav,
  .fab,
  .status-bar {
    display: none !important;
  }
}

/* ==========================================================================
   46. Avatar SVG Helpers
   ========================================================================== */

.avatar {
  display: inline-block;
  flex-shrink: 0;
  vertical-align: middle;
}

.avatar-sm { width: 28px; height: 28px; }
.avatar-md { width: 40px; height: 40px; }
.avatar-lg { width: 52px; height: 52px; }
.avatar-xl { width: 90px; height: 90px; }

/* ==========================================================================
   47. Empty State
   ========================================================================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.empty-state__icon {
  width: 80px;
  height: 80px;
  margin-bottom: 16px;
  color: var(--text-dim);
  opacity: 0.5;
}

.empty-state__title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.empty-state__text {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  max-width: 260px;
}

/* ==========================================================================
   48. Verified Icon
   ========================================================================== */

.verified-icon {
  display: inline-flex;
  color: var(--primary);
  vertical-align: middle;
}

.verified-icon svg {
  width: 16px;
  height: 16px;
}

/* ==========================================================================
   49. Pill variants
   ========================================================================== */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
}

.pill--primary {
  background: var(--primary-alpha-10);
  color: var(--primary);
}

.pill--filled {
  background: var(--primary);
  color: var(--text-white);
}

/* ==========================================================================
   50. Search Highlight
   ========================================================================== */

.search-highlight {
  background: var(--yellow);
  color: var(--text-primary);
  border-radius: 2px;
  padding: 0 1px;
}
