/* ==========================================================================
   dyur — iOS 26 look (black, liquid glass, violet accent)
   Loaded after style.css and overrides the original glass design.
   Themes:  classic / .dark-theme → black
            .light-theme          → light
   Rules are prefixed with ":root body" so they outrank the
   ".light-theme .x" / "body.dark-theme .x" rules in style.css.
========================================================================== */

/* ── Palette ──────────────────────────────────────────────── */
:root body {
  --ui-bg: #000000;
  --ui-row: #0b0b0b;            /* chat list rows */
  --ui-cell: #1c1c1e;           /* grouped settings cells, incoming bubbles */
  --ui-cell-press: #2c2c2e;
  --ui-field: #131313;          /* search field */
  --ui-glass: rgba(38,38,40,0.72);
  --ui-glass-border: rgba(255,255,255,0.08);
  --ui-glass-active: rgba(120,120,128,0.36);
  --ui-segment-bg: #1f1f21;
  --ui-segment-on: #636366;
  --ui-separator: rgba(255,255,255,0.1);
  --ui-text: #ffffff;
  --ui-text-2: #8e8e93;
  --ui-text-3: #48484a;
  --ui-accent: #5d17eb;         /* buttons, own bubbles, badges */
  --ui-accent-ink: #8b5cff;     /* icons and text links on dark */
  --ui-danger: #ff453a;
  --ui-own: #5d17eb;
  --ui-own-text: #ffffff;
  --ui-own-meta: rgba(255,255,255,0.7);
  --ui-in: #1c1c1e;
  --ui-in-text: #ffffff;
  --ui-in-meta: #8e8e93;
  --ui-chat-bg: #000000;
  --ui-shadow: 0 8px 30px rgba(0,0,0,0.5);
}
:root body.light-theme {
  --ui-bg: #f2f2f7;
  --ui-row: #ffffff;
  --ui-cell: #ffffff;
  --ui-cell-press: #e5e5ea;
  --ui-field: rgba(118,118,128,0.12);
  --ui-glass: rgba(255,255,255,0.75);
  --ui-glass-border: rgba(0,0,0,0.06);
  --ui-glass-active: rgba(118,118,128,0.16);
  --ui-segment-bg: rgba(118,118,128,0.12);
  --ui-segment-on: #ffffff;
  --ui-separator: rgba(60,60,67,0.18);
  --ui-text: #000000;
  --ui-text-2: #8e8e93;
  --ui-text-3: #c7c7cc;
  --ui-accent-ink: #5d17eb;
  --ui-danger: #ff3b30;
  --ui-in: #ffffff;
  --ui-in-text: #000000;
  --ui-in-meta: #8e8e93;
  --ui-chat-bg: #efeff4;
  --ui-shadow: 0 8px 30px rgba(0,0,0,0.12);
}

/* Map the app's own tokens onto the palette */
:root body {
  --bg-primary: var(--ui-bg);
  --bg-secondary: var(--ui-cell);
  --glass: var(--ui-cell);
  --glass-bg: var(--ui-cell);
  --glass-border: var(--ui-separator);
  --glass-hover: var(--ui-cell-press);
  --glass-shine: transparent;
  --text-primary: var(--ui-text);
  --text-secondary: var(--ui-text-2);
  --text-muted: var(--ui-text-2);
  --accent: var(--ui-accent);
  --accent-soft: color-mix(in srgb, var(--ui-accent) 18%, transparent);
  --danger: var(--ui-danger);
  --success: #30d158;
  --blur: none;
  --blur-heavy: none;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --glow-white: none;
  --shadow-glass: none;
  --inset-shine: none;
  --transition: 0.2s ease;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Roboto, sans-serif;
  letter-spacing: -0.01em;
  background: var(--ui-bg) !important;
  color: var(--ui-text);
}

/* No decorative blobs, no old glass */
:root body .blob { display: none !important; }
:root body .glass-card,
:root body .glass-card-sm,
:root body .glass-panel {
  background: var(--ui-cell);
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
:root body .btn::before { display: none; }

/* The theme decides the background */
:root body.app-bg-black,
:root body.app-bg-white { background: var(--ui-bg) !important; }
#theme-form > .theme-hint:first-child,
#theme-form .app-bg-picker,
#theme-form .app-bg-picker + .theme-section-divider { display: none !important; }

/* ── Liquid glass building blocks ─────────────────────────── */
.glass-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  border-radius: 22px;
  background: var(--ui-glass);
  border: 0.5px solid var(--ui-glass-border);
  box-shadow: inset 0 0.5px 0 rgba(255,255,255,0.08);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  color: var(--ui-text);
}
.glass-pill--text {
  padding: 0 16px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}
.glass-pill--title {
  height: 36px;
  padding: 0 16px;
  font-size: 17px;
  font-weight: 600;
}
.glass-pill--group { padding: 0 2px; gap: 0; }
.glass-pill-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--ui-text);
  font-size: 19px;
}
#create-group-btn.glass-pill-icon i {
  width: 22px;
  height: 22px;
  border: 1.7px solid currentColor;
  border-radius: 50%;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Buttons & inputs ─────────────────────────────────────── */
:root body .btn {
  border-radius: 22px;
  font-weight: 600;
  font-size: 15px;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
:root body .btn-primary {
  background: var(--ui-accent);
  border-color: var(--ui-accent);
  color: #fff;
}
:root body .btn-ghost {
  background: var(--ui-glass);
  border: 0.5px solid var(--ui-glass-border);
  color: var(--ui-text);
}
:root body .btn-ghost:hover { background: var(--ui-cell-press); color: var(--ui-text); }
:root body .btn-icon { color: var(--ui-text); background: transparent; border: none; box-shadow: none; }

:root body :where(input:not([type=checkbox]):not([type=radio]):not([type=range]), textarea, select) {
  background: var(--ui-cell) !important;
  border: 0.5px solid var(--ui-separator) !important;
  color: var(--ui-text) !important;
  border-radius: 14px;
  box-shadow: none !important;
}
:root body :where(input, textarea):focus { border-color: var(--ui-accent) !important; outline: none; }
:root body input::placeholder,
:root body textarea::placeholder { color: var(--ui-text-2); }

/* Fields that sit inside their own card are borderless */
:root body .auth-field input,
:root body .tg-search-field input,
:root body #edit-profile-form .form-group input,
:root body #edit-profile-form .form-group textarea,
:root body .chat-input-wrap textarea {
  background: transparent !important;
  border: none !important;
  border-radius: 0;
  padding-left: 0;
  padding-right: 0;
}

:root body .verified-badge,
:root body .verified-badge i { color: var(--ui-accent-ink) !important; }

/* iOS switch */
:root body .toggle-slider {
  display: block;
  flex-shrink: 0;
  width: 51px;
  height: 31px;
  border: none;
  border-radius: 16px;
  background: var(--ui-text-3);
}
:root body .toggle-slider::after {
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  background: #fff;
  box-shadow: 0 3px 8px rgba(0,0,0,0.15);
}
:root body .toggle-checkbox:checked + .toggle-slider { background: var(--ui-accent); }
:root body .toggle-checkbox:checked + .toggle-slider::after { left: 22px; transform: none; background: #fff; }

/* ── Desktop top navbar ───────────────────────────────────── */
:root body .navbar {
  background: var(--ui-glass);
  border-bottom: 0.5px solid var(--ui-glass-border);
  box-shadow: none;
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
}
:root body .nav-logo { color: var(--ui-text); background: none; -webkit-text-fill-color: currentColor; }
@media (min-width: 769px) {
  :root body .nav-center {
    background: var(--ui-glass);
    border: 0.5px solid var(--ui-glass-border);
    box-shadow: var(--ui-shadow);
    backdrop-filter: saturate(180%) blur(24px);
    -webkit-backdrop-filter: saturate(180%) blur(24px);
  }
  :root body .nav-link { color: var(--ui-text); border-radius: 18px; }
  :root body .nav-link.active { background: var(--ui-glass-active); color: var(--ui-accent-ink); box-shadow: none; }
  :root body .nav-search-circle {
    background: var(--ui-glass);
    border: 0.5px solid var(--ui-glass-border);
    color: var(--ui-text);
    box-shadow: var(--ui-shadow);
  }
}

/* ── Floating bottom tab bar (mobile) ─────────────────────── */
@media (max-width: 768px) {
  :root body .nav-center {
    left: 28px;
    right: 28px;
    bottom: max(14px, env(safe-area-inset-bottom, 14px));
    transform: none;
    width: auto;
    max-width: none;
    height: 64px;
    padding: 4px;
    gap: 0;
    justify-content: space-between;
    border-radius: 32px;
    background: var(--ui-glass);
    border: 0.5px solid var(--ui-glass-border);
    box-shadow: var(--ui-shadow), inset 0 0.5px 0 rgba(255,255,255,0.1);
    backdrop-filter: saturate(180%) blur(24px);
    -webkit-backdrop-filter: saturate(180%) blur(24px);
  }
  :root body .nav-link {
    flex: 1 1 0;
    height: 56px;
    padding: 0;
    border-radius: 28px;
    background: transparent !important;
    box-shadow: none !important;
    color: var(--ui-text);
    transition: background 0.2s ease, color 0.2s ease;
  }
  :root body .nav-link i { font-size: 22px; height: auto; line-height: 1; }
  :root body .nav-link span { display: none; }
  :root body .nav-link.active {
    background: var(--ui-glass-active) !important;
    color: var(--ui-accent-ink);
  }
  :root body .nav-link.active i { color: var(--ui-accent-ink); }
  :root body .nav-link-profile-mobile .nav-avatar-mini { width: 26px; height: 26px; }
  :root body .nav-link.active .nav-avatar-mini { box-shadow: 0 0 0 2px var(--ui-accent-ink); }

  :root body .nav-search-circle { display: none !important; }

  :root body .main-content {
    padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  }
  /* Split pages fill the screen and scroll beneath the floating bar */
  :root body .main-content:has(> .page-split.active) { padding-bottom: 0; }
  :root body .page-split {
    height: calc(100vh - env(safe-area-inset-top, 0px));
    height: calc(100dvh - env(safe-area-inset-top, 0px));
  }
  :root body .chat-list,
  :root body .channel-slim-list { padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px)); }
}

/* ── List screens: Chats / Channels ───────────────────────── */
:root body .sidebar-panel {
  background: var(--ui-bg);
  border: none;
  border-right: 0.5px solid var(--ui-separator);
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
@media (max-width: 768px) {
  :root body .sidebar-panel { border-right: none; }
}
:root body .sidebar-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60px;
  padding: 8px 16px;
  border-bottom: none;
  background: transparent;
}
:root body .sidebar-header h3 {
  height: 36px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  border-radius: 18px;
  font-size: 17px;
  font-weight: 600;
  color: var(--ui-text);
  background: var(--ui-glass);
  border: 0.5px solid var(--ui-glass-border);
  box-shadow: none;
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
}
/* Channels header: single round action on the right */
:root body .sidebar-header:not(.tg-list-header) > .btn,
:root body .sidebar-header:not(.tg-list-header) > button {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  background: var(--ui-glass);
  border: 0.5px solid var(--ui-glass-border);
  box-shadow: none;
  color: var(--ui-text);
  font-size: 17px;
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
}
:root body .tg-list-header { justify-content: space-between; }
:root body .tg-list-header #create-group-btn,
:root body .tg-list-header #create-group-btn:hover {
  position: static;
  transform: none;
  width: 44px;
  height: 44px;
  background: transparent;
  border: none;
  box-shadow: none;
  color: var(--ui-text);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
:root body .tg-list-header .glass-pill--title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

/* Search field */
.tg-search-field,
:root body .sidebar-search {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 16px 10px;
  height: 44px;
  padding: 0 16px;
  border-radius: 22px;
  background: var(--ui-field);
  border: 0.5px solid var(--ui-glass-border);
  box-shadow: none;
  color: var(--ui-text-2);
  flex-shrink: 0;
  cursor: text;
}
.tg-search-field i,
:root body .sidebar-search i { font-size: 17px; color: var(--ui-text-2); }
.tg-search-field input,
:root body .sidebar-search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  background: transparent !important;
  border: none !important;
  font-size: 17px;
  padding: 0 !important;
}
.tg-search-field input::-webkit-search-cancel-button { filter: grayscale(1); }

/* Segmented control */
.tg-segmented {
  display: flex;
  margin: 4px 16px 12px;
  padding: 3px;
  height: 40px;
  border-radius: 20px;
  background: var(--ui-segment-bg);
  flex-shrink: 0;
}
.tg-segment {
  flex: 1;
  border-radius: 17px;
  color: var(--ui-text);
  font-size: 15px;
  font-weight: 600;
  transition: background 0.2s ease;
}
.tg-segment.active { background: var(--ui-segment-on); box-shadow: 0 2px 6px rgba(0,0,0,0.15); }

/* Stories strip */
:root body .stories-strip {
  background: transparent;
  border: none;
  box-shadow: none;
  margin-bottom: 6px;
}

/* Chat rows: rounded cards */
:root body .chat-list { padding: 4px 0 0; }
:root body .chat-item-wrap {
  position: relative;
  margin: 0 16px 8px;
  background: transparent;
  border-radius: 24px;
}
:root body .chat-item,
:root body .channel-slim-item {
  position: relative;
  z-index: 1;
  gap: 12px;
  margin: 0;
  padding: 0 16px 0 14px;
  height: 80px;
  border: none;
  border-radius: 24px;
  background: var(--ui-row);
  box-shadow: none;
  transition: transform 0.25s ease, background 0.15s ease;
}
:root body .channel-slim-item { margin: 0 16px 8px; }
:root body .chat-item::after,
:root body .channel-slim-item::after { display: none; }
:root body .chat-item:hover,
:root body .channel-slim-item:hover { background: var(--ui-row); }
:root body .chat-item:active,
:root body .channel-slim-item:active,
:root body .chat-item.active,
:root body .channel-slim-item.active { background: var(--ui-cell-press); }
:root body .chat-item-avatar { flex-shrink: 0; position: relative; }
:root body .chat-item-avatar img,
:root body .channel-slim-item img,
:root body .group-default-av {
  width: 56px;
  height: 56px;
  border: none;
  box-shadow: none;
}
:root body .chat-item-info { align-self: stretch; padding-top: 17px; min-width: 0; }
:root body .chat-item-name {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 17px;
  font-weight: 600;
  color: var(--ui-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
:root body .chat-item-name .verified-badge { font-size: 14px; flex-shrink: 0; }
:root body .chat-item-last {
  margin-top: 3px;
  font-size: 15px;
  color: var(--ui-text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
:root body .chat-item-meta {
  align-self: stretch;
  align-items: flex-end;
  justify-content: flex-start;
  padding-top: 18px;
  gap: 6px;
  flex-shrink: 0;
}
:root body .chat-item-time { font-size: 14px; color: var(--ui-text-2); }
:root body .chat-item-unread {
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 11px;
  background: var(--ui-accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 22px;
  text-align: center;
  box-shadow: none;
  border: none;
}
:root body .chat-item-chevron { color: var(--ui-text-3); font-size: 14px; flex-shrink: 0; }
:root body .chat-item-more { display: none; }
:root body .chat-pin-indicator {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%) rotate(30deg);
  color: var(--ui-accent-ink);
  font-size: 13px;
}
:root body .chat-item:has(.chat-pin-indicator) { padding-left: 28px; }
:root body .group-member-count { color: var(--ui-text-2); font-weight: 400; font-size: 13px; }
:root body .group-name-icon { color: var(--ui-text-2); font-size: 13px; }
:root body .group-default-av {
  border-radius: 50%;
  background: linear-gradient(135deg, #7a33fb, #5d17eb);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Swipe / edit-mode delete action */
.chat-swipe-action {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 88px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--ui-text);
  font-size: 13px;
}
.chat-swipe-circle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--ui-accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
:root body .chat-list.editing .chat-item { transform: translateX(-96px) !important; }

:root body .avatar-online-dot {
  width: 14px;
  height: 14px;
  background: #30d158;
  border: 2.5px solid var(--ui-row);
  box-shadow: none;
}

/* Action sheet (long press / right click) */
:root body .chat-action-sheet-overlay { background: rgba(0,0,0,0.4); }
:root body .chat-action-sheet {
  margin: 0 8px calc(8px + env(safe-area-inset-bottom, 0px));
  padding: 8px;
  border: 0.5px solid var(--ui-glass-border);
  border-radius: 28px;
  background: var(--ui-glass);
  box-shadow: var(--ui-shadow);
  backdrop-filter: saturate(180%) blur(30px);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
}
:root body .chat-action-sheet-title { color: var(--ui-text-2); border: none; font-size: 13px; }
:root body .chat-action-sheet-btn {
  border: none;
  border-radius: 20px;
  color: var(--ui-text);
  font-size: 17px;
}
:root body .chat-action-sheet-btn:active { background: var(--ui-glass-active); }
:root body .chat-action-sheet-btn.cas-danger,
:root body .chat-action-sheet-btn.danger { color: var(--ui-danger); }
:root body .chat-action-sheet-btn.cas-cancel,
:root body #gas-cancel { color: var(--ui-text); font-weight: 600; border-top: none; }

/* ── Conversation ─────────────────────────────────────────── */
:root body .chat-main,
:root body .channel-main { background: var(--ui-chat-bg); }
:root body:not([class*="chat-bg-"]) #chat-messages-area,
:root body.chat-bg-classic #chat-messages-area { background: transparent !important; }

:root body .chat-header,
:root body.chat-is-open .chat-header {
  min-height: 60px;
  padding: 8px 12px;
  background: transparent;
  border-bottom: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
}
@media (max-width: 768px) {
  :root body.chat-is-open .chat-header { padding-top: calc(8px + env(safe-area-inset-top, 0px)); }
}
:root body .chat-back-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  background: var(--ui-glass);
  border: 0.5px solid var(--ui-glass-border);
  box-shadow: none;
  color: var(--ui-text);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
}
:root body .chat-back-btn:hover { background: var(--ui-cell-press); transform: none; box-shadow: none; }
:root body .chat-back-label { display: none; }
:root body .chat-header-name-card {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 140px);
  margin: 0;
  padding: 5px 18px;
  border-radius: 22px;
  background: var(--ui-glass);
  border: 0.5px solid var(--ui-glass-border);
  box-shadow: none;
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
}
:root body .chat-header-name-card:hover { background: var(--ui-glass); }
:root body .chat-header-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--ui-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
:root body .chat-header-status { font-size: 12px; color: var(--ui-text-2); margin-top: 0; }
:root body .chat-header-status.online { color: var(--ui-accent-ink); }
:root body .chat-header-avatar-circle {
  width: 44px;
  height: 44px;
  border: none;
  box-shadow: none;
}
:root body .chat-header-avatar-circle:hover { transform: none; box-shadow: none; }
:root body .chat-header-avatar-wrap .avatar-online-dot { display: none; }
:root body .chat-header-avatar-wrap.has-story .chat-header-avatar-circle,
:root body .chat-header-avatar-wrap.has-story:hover .chat-header-avatar-circle {
  box-shadow: 0 0 0 2px var(--ui-chat-bg), 0 0 0 4px var(--ui-accent-ink);
}

:root body .chat-messages { padding: 8px 10px 10px; gap: 2px; }

/* Day separators */
:root body .tg-date-sep {
  position: sticky;
  top: 6px;
  z-index: 3;
  display: flex;
  justify-content: center;
  margin: 10px 0 8px;
  pointer-events: none;
}
:root body .tg-date-sep span {
  padding: 4px 12px;
  border-radius: 14px;
  background: var(--ui-glass);
  border: 0.5px solid var(--ui-glass-border);
  color: var(--ui-text);
  font-size: 13px;
  font-weight: 600;
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
}

/* Bubbles */
:root body .message-bubble {
  max-width: min(78%, 480px);
  padding: 7px 12px 8px 13px;
  border: none;
  border-radius: 20px;
  font-size: 16.5px;
  line-height: 21px;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  display: flow-root;
}
:root body .message-bubble.other { background: var(--ui-in); color: var(--ui-in-text); border: none; }
:root body .message-bubble.own { background: var(--ui-own); color: var(--ui-own-text); }
:root body .message-bubble .msg-text { color: inherit !important; word-wrap: break-word; }
:root body .message-bubble .mention { color: var(--ui-accent-ink); }
:root body .message-bubble.own .msg-text a,
:root body .message-bubble.own .mention { color: #fff; text-decoration: underline; }

/* Grouping: consecutive messages from one sender */
:root body .message-wrap { margin-bottom: 6px; }
:root body .message-wrap.tg-cont { margin-bottom: 0; }
:root body .message-wrap.own.tg-cont .message-bubble { border-bottom-right-radius: 6px; }
:root body .message-wrap.own.tg-follow .message-bubble { border-top-right-radius: 6px; }
:root body .message-wrap.other.tg-cont .message-bubble { border-bottom-left-radius: 6px; }
:root body .message-wrap.other.tg-follow .message-bubble { border-top-left-radius: 6px; }
:root body .message-wrap.tg-follow .group-msg-sender { display: none; }

/* Time + checks inside the bubble, floated to the bottom-right */
:root body .message-bubble .message-meta {
  float: right;
  position: relative;
  top: 6px;
  margin: 0 -3px 0 10px;
  padding: 0;
  gap: 3px;
  height: 18px;
  font-size: 11.5px;
  line-height: 18px;
  white-space: nowrap;
  color: var(--ui-in-meta);
}
:root body .message-bubble.own .message-meta { color: var(--ui-own-meta); }
:root body .message-bubble .edited-tag { font-style: normal; color: inherit; }
:root body .message-bubble .message-status { gap: 0; margin-left: 1px; }
:root body .message-bubble .message-status i { font-size: 10px; color: var(--ui-own-meta); }
:root body .message-bubble .message-status.read i { color: #fff; }
:root body .message-bubble .message-status i + i { margin-left: -5px; }

/* Media bubbles: time over the picture */
:root body .message-bubble:has(> .msg-photo-wrap),
:root body .message-bubble:has(> .story-msg-wrap) { padding: 3px; }
:root body .message-bubble:has(> .msg-photo-wrap) .msg-photo,
:root body .message-bubble:has(> .story-msg-wrap) .story-msg-img { border-radius: 17px; }
:root body .message-bubble:has(> .msg-photo-wrap) .message-meta,
:root body .message-bubble.vn-bubble .message-meta {
  position: absolute;
  float: none;
  top: auto;
  right: 10px;
  bottom: 10px;
  margin: 0;
  padding: 0 7px;
  border-radius: 9px;
  background: rgba(0,0,0,0.5);
  color: #fff;
}
:root body .message-bubble:has(> .msg-photo-wrap) .message-status i,
:root body .message-bubble.vn-bubble .message-status i { color: #fff; }
:root body .message-bubble.vn-bubble { background: transparent; padding: 0; }

/* Reactions: own row inside the bubble, time on the right */
:root body .message-bubble:has(> .message-reactions:not(:empty)) {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  column-gap: 10px;
}
:root body .message-bubble:has(> .message-reactions:not(:empty)) > * { grid-column: 1 / -1; }
:root body .message-bubble:has(> .message-reactions:not(:empty)) > .message-reactions { grid-column: 1; }
:root body .message-bubble:has(> .message-reactions:not(:empty)) > .message-meta {
  grid-column: 2;
  float: none;
  top: 0;
  margin: 0 -3px 0 0;
}
:root body .message-bubble .message-reactions { margin: 6px 0 0; padding: 0; }
:root body .message-bubble .message-reactions:empty { display: none; }
:root body .reaction-pill {
  padding: 3px 9px 3px 7px;
  border: none;
  border-radius: 14px;
  background: color-mix(in srgb, var(--ui-accent-ink) 22%, transparent);
  color: var(--ui-text);
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  font-size: 14px;
}
:root body .message-bubble.own .reaction-pill { background: rgba(255,255,255,0.2); color: #fff; }
:root body .reaction-pill:hover { transform: none; }

/* Hover actions (desktop only) */
:root body .msg-action-btn,
:root body .message-bubble .react-btn {
  border: 0.5px solid var(--ui-glass-border);
  background: var(--ui-glass);
  color: var(--ui-text);
  box-shadow: none;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
:root body .msg-action-btn:hover { transform: none; background: var(--ui-accent); color: #fff; }
@media (hover: none) {
  :root body .message-bubble .react-btn,
  :root body .msg-actions { display: none; }
}

/* Replies / forwards */
:root body .reply-quote {
  border-left: 3px solid var(--ui-accent-ink);
  border-radius: 6px;
  background: color-mix(in srgb, var(--ui-accent-ink) 14%, transparent);
  margin-bottom: 4px;
}
:root body .reply-quote-author { color: var(--ui-accent-ink); font-weight: 600; }
:root body .reply-quote-text { color: inherit; opacity: 0.85; }
:root body .message-bubble.own .reply-quote { border-left-color: #fff; background: rgba(255,255,255,0.16); }
:root body .message-bubble.own .reply-quote-author,
:root body .message-bubble.own .reply-quote-text { color: #fff; }
:root body .forwarded-label { color: var(--ui-accent-ink); font-size: 14px; }
:root body .message-bubble.own .forwarded-label { color: rgba(255,255,255,0.85); }

/* Voice messages */
:root body .message-bubble .vm-play-btn { background: var(--ui-accent); color: #fff; }
:root body .message-bubble.own .vm-play-btn { background: #fff; color: var(--ui-own); }
:root body .message-bubble .vw-bar { background: color-mix(in srgb, var(--ui-accent-ink) 40%, transparent); }
:root body .message-bubble .vw-bar.played { background: var(--ui-accent-ink); }
:root body .message-bubble.own .vw-bar { background: rgba(255,255,255,0.4); }
:root body .message-bubble.own .vw-bar.played { background: #fff; }

/* Group sender */
:root body .group-msg-sender { margin: 0 0 3px 6px; gap: 6px; }
:root body .group-msg-av { width: 22px; height: 22px; }
:root body .group-msg-name { color: var(--ui-accent-ink); font-size: 14px; font-weight: 600; }

/* Typing / reply bars */
:root body .typing-indicator { color: var(--ui-text-2); background: transparent; padding: 2px 16px 4px; font-size: 13px; }
:root body .typing-dot { background: var(--ui-accent-ink); }
:root body .reply-preview-bar {
  margin: 0 12px 6px;
  border: 0.5px solid var(--ui-glass-border);
  border-radius: 18px;
  background: var(--ui-glass);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
}
:root body .reply-preview-inner { border-left: 2px solid var(--ui-accent-ink); color: var(--ui-accent-ink); }
:root body .reply-cancel-btn { color: var(--ui-text-2); background: transparent; border: none; }

/* Input bar: floating glass controls */
:root body .chat-input-area,
:root body.dark-theme .chat-input-bar {
  align-items: flex-end;
  gap: 8px;
  padding: 6px 12px 10px;
  background: transparent;
  border-top: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
@media (max-width: 768px) {
  :root body .chat-input-area { padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
}
:root body .chat-attach-btn,
:root body .voice-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0.5px solid var(--ui-glass-border);
  background: var(--ui-glass);
  box-shadow: none;
  color: var(--ui-text);
  font-size: 19px;
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
}
:root body .chat-attach-btn:hover,
:root body .voice-btn:hover {
  background: var(--ui-cell-press);
  border-color: var(--ui-glass-border);
  color: var(--ui-text);
  transform: none;
}
:root body .chat-attach-btn i { transform: rotate(-45deg); }
:root body .voice-btn.send-mode,
:root body .voice-btn.locked-send,
:root body .voice-btn.recording {
  background: var(--ui-accent);
  border-color: var(--ui-accent);
  color: #fff;
  transform: none;
}
:root body .voice-btn.video-note-mode { background: var(--ui-glass); color: var(--ui-text); animation: none; }
:root body .chat-input-wrap {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 22px;
  border: 0.5px solid var(--ui-glass-border);
  background: var(--ui-glass);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  align-items: center;
}
:root body .chat-input-wrap textarea {
  min-height: 42px;
  padding: 11px 0 !important;
  font-size: 17px;
  line-height: 21px;
}

/* Message context menu */
:root body .msg-context-menu {
  background: var(--ui-glass);
  border: 0.5px solid var(--ui-glass-border);
  border-radius: 22px;
  box-shadow: var(--ui-shadow);
  backdrop-filter: saturate(180%) blur(30px);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
}

:root body .chat-empty-state { color: var(--ui-text-2); justify-content: center; height: 100%; }
:root body .chat-empty-state i { display: none; }
:root body .chat-empty-state p {
  padding: 6px 14px;
  border-radius: 16px;
  background: var(--ui-glass);
  border: 0.5px solid var(--ui-glass-border);
  color: var(--ui-text);
  font-size: 14px;
}

/* ── Profile = Settings ───────────────────────────────────── */
:root body #page-profile,
:root body #page-profile .page-content,
:root body .profile-slider-panel { background: var(--ui-bg); }
:root body .profile-header { background: transparent; border: none; box-shadow: none; padding: 0; }
:root body .own-profile-cover-wrap { margin: 0; }
:root body .own-profile-cover { border-radius: 0; border: none; box-shadow: none; background-color: transparent; }
:root body .cover-upload-btn {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top, 0px));
  right: 16px;
  left: auto;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
}
:root body .view-profile-avatar { border: none; box-shadow: none; }
:root body .own-avatar-wrap { box-shadow: none; }
:root body .view-profile-name { font-size: 26px; font-weight: 700; color: var(--ui-text); }
:root body .view-profile-username-pill {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  font-size: 15px;
  color: var(--ui-text-2);
}
:root body .view-profile-bio { color: var(--ui-text-2); }
:root body .avatar-upload-btn,
:root body .cover-upload-btn {
  background: var(--ui-glass);
  color: var(--ui-text);
  border: 0.5px solid var(--ui-glass-border);
  box-shadow: none;
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
}

/* Grouped list (settings menu) */
:root body .profile-menu {
  margin-top: 20px;
  border: none;
  border-radius: 24px;
  background: var(--ui-cell);
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
:root body .profile-menu-item {
  position: relative;
  gap: 16px;
  min-height: 52px;
  padding: 0 16px;
  border: none;
  background: var(--ui-cell);
  color: var(--ui-text);
  font-size: 17px;
}
:root body .profile-menu-item:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 62px;
  right: 16px;
  bottom: 0;
  height: 0.5px;
  background: var(--ui-separator);
}
:root body .profile-menu-item:hover { background: var(--ui-cell); }
:root body .profile-menu-item:active { background: var(--ui-cell-press); }
:root body .profile-menu-label { font-weight: 400; }
:root body .profile-menu-arrow { color: var(--ui-text-3); font-size: 14px; }
:root body .profile-menu-icon {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 8px;
  box-shadow: none;
  color: #fff;
  font-size: 15px;
  background: #8e8e93;
}
#create-post-btn .profile-menu-icon       { background: #5d17eb; }
#add-story-btn .profile-menu-icon         { background: #ff9f0a; }
#edit-profile-btn .profile-menu-icon      { background: #30d158; }
#privacy-settings-btn .profile-menu-icon  { background: #0a84ff; }
#theme-settings-btn .profile-menu-icon    { background: #64d2ff; }
#verify-request-btn .profile-menu-icon    { background: #5e5ce6; }
#verify-request-btn .profile-menu-icon i::before { content: "\f0a3"; }
:root body .profile-menu-item--danger .profile-menu-icon { background: var(--ui-danger); color: #fff; }
:root body .profile-menu-item--danger .profile-menu-label { color: var(--ui-danger); }
:root body .profile-menu-item--danger .profile-menu-arrow { display: none; }

/* Sub-page header: (‹) Title  or  Отмена · Title · Сохранить */
:root body .profile-sub-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
  background: var(--ui-bg);
  border-bottom: none;
  box-shadow: none;
}
:root body .profile-sub-back,
:root body .profile-sub-save {
  height: 44px;
  border-radius: 22px;
  background: var(--ui-glass);
  border: 0.5px solid var(--ui-glass-border);
  color: var(--ui-text);
  font-size: 17px;
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
}
:root body .profile-sub-back { justify-self: start; width: 44px; padding: 0; }
:root body .profile-sub-back i { font-size: 18px; }
:root body .profile-sub-cancel,
:root body .profile-sub-save { display: none; }
:root body .profile-sub-title {
  max-width: 50vw;
  font-size: 17px;
  font-weight: 600;
  color: var(--ui-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}
:root body .profile-sub-header.has-save .profile-sub-back { width: auto; padding: 0 16px; }
:root body .profile-sub-header.has-save .profile-sub-back i { display: none; }
:root body .profile-sub-header.has-save .profile-sub-cancel { display: inline; color: var(--ui-accent-ink); }
:root body .profile-sub-header.has-save .profile-sub-save {
  display: inline-flex;
  align-items: center;
  justify-self: end;
  padding: 0 16px;
  color: var(--ui-accent-ink);
  font-weight: 600;
}
/* Header «Сохранить» replaces the in-form buttons */
:root body .profile-sub-header.has-save ~ .page-content .form-actions { display: none; }
:root body #profile-sub-content { padding: 8px 16px 120px; }
:root body #profile-sub-content > .glass-card {
  background: transparent;
  padding: 0;
}
:root body #profile-sub-content > .glass-card > h3 { display: none; }

/* Edit profile: one card per field, hint under the value */
:root body #edit-profile-form .form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
  padding: 14px 18px;
  border-radius: 24px;
  background: var(--ui-cell);
}
:root body #edit-profile-form .form-group > label:not(.toggle-row) {
  order: 2;
  margin: 0;
  font-size: 13px;
  font-weight: 400;
  color: var(--ui-text-2);
  text-transform: none;
}
:root body #edit-profile-form .form-group > .form-hint { order: 3; font-size: 13px; color: var(--ui-text-2); }
:root body #edit-profile-form .form-group input,
:root body #edit-profile-form .form-group textarea { font-size: 17px; padding-top: 2px !important; padding-bottom: 2px !important; min-height: 0; }
:root body #edit-profile-form .username-input-wrap { background: transparent; border: none; padding: 0; }
:root body #edit-profile-form .username-at { color: var(--ui-text-2); border: none; padding: 0 2px 0 0; line-height: inherit; }
:root body #edit-profile-form .toggle-row { margin: 0; color: var(--ui-text); font-size: 17px; }

/* Privacy: uppercase section titles over grouped cells */
:root body .privacy-card { background: transparent; padding: 0; }
:root body .privacy-section { margin-bottom: 24px; background: transparent; border: none; padding: 0; }
:root body .privacy-section-title {
  margin: 8px 16px 8px;
  padding: 0;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ui-text-2);
  background: none;
  border: none;
}
:root body .privacy-section-title i { display: none; }
:root body .privacy-row,
:root body .blocked-list {
  position: relative;
  margin: 0;
  padding: 0 16px;
  min-height: 52px;
  border: none;
  border-radius: 0;
  background: var(--ui-cell);
}
:root body .privacy-section-title + .privacy-row,
:root body .blocked-list { border-top-left-radius: 24px; border-top-right-radius: 24px; }
:root body .privacy-row:last-child,
:root body .blocked-list { border-bottom-left-radius: 24px; border-bottom-right-radius: 24px; }
:root body .blocked-list { padding: 8px 16px; }
:root body .blocked-list:empty::before {
  content: 'Пока никого нет';
  display: block;
  padding: 8px 0;
  color: var(--ui-text-2);
  font-size: 15px;
}
:root body .privacy-row { display: flex; align-items: center; justify-content: space-between; }
:root body .privacy-row:not(:last-child) {
  background:
    linear-gradient(var(--ui-separator), var(--ui-separator)) 62px 100% / calc(100% - 78px) 0.5px no-repeat,
    var(--ui-cell);
}
:root body .privacy-card,
:root body .privacy-section { background: transparent !important; box-shadow: none !important; }
:root body .privacy-row-label {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 17px;
  color: var(--ui-text);
}
:root body .privacy-row-label i {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  background: #8e8e93;
}
:root body .privacy-row:nth-of-type(2) .privacy-row-label i { background: #0a84ff; }
:root body .privacy-row:nth-of-type(3) .privacy-row-label i { background: #ff9f0a; }
:root body .privacy-row:nth-of-type(4) .privacy-row-label i { background: #30d158; }
:root body .privacy-row:nth-of-type(5) .privacy-row-label i { background: #ff375f; }
:root body .privacy-row:nth-of-type(6) .privacy-row-label i { background: #5e5ce6; }
:root body .privacy-row:nth-of-type(7) .privacy-row-label i { background: #5d17eb; }
:root body .privacy-select {
  background: transparent !important;
  border: none !important;
  color: var(--ui-text-2) !important;
  font-size: 17px;
  text-align: right;
  text-align-last: right;
  padding-right: 18px !important;
  background-image: none;
}
:root body .privacy-row::before {
  content: '\f078';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  position: absolute;
  right: 16px;
  font-size: 11px;
  color: var(--ui-text-3);
  pointer-events: none;
}

/* Theme picker previews */
#theme-form .theme-label { color: var(--ui-text); }
#theme-form .theme-card { background: var(--ui-cell); border: none; border-radius: 20px; }
#theme-form .theme-preview { border: none; box-shadow: inset 0 0 0 0.5px var(--ui-separator); }
#theme-form .theme-preview--classic,
#theme-form .theme-preview--dark { background: #000; }
#theme-form .theme-preview--classic .tp-other,
#theme-form .theme-preview--dark .tp-other { background: #1c1c1e; }
#theme-form .theme-preview--classic .tp-own,
#theme-form .theme-preview--dark .tp-own,
#theme-form .theme-preview--light .tp-own { background: #5d17eb; }
#theme-form .theme-preview--light { background: #efeff4; }
#theme-form .theme-preview--light .tp-other { background: #fff; }
#theme-form .theme-check,
#theme-form .app-bg-check { color: var(--ui-accent-ink); }
#theme-form .theme-hint { color: var(--ui-text-2); text-transform: uppercase; font-size: 13px; }

/* ── Feed, posts, contacts, modals ────────────────────────── */
:root body .post-card,
:root body .contact-card,
:root body .feed-composer,
:root body .ch-inline-composer {
  background: var(--ui-cell);
  border: none;
  border-radius: 24px;
  box-shadow: none;
}
:root body .feed-header h2 {
  padding: 0;
  background: none;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  color: var(--ui-text);
  font-size: 34px;
  font-weight: 700;
}
:root body .feed-tabs,
:root body .tabs-container {
  padding: 3px;
  border: none;
  border-radius: 20px;
  background: var(--ui-segment-bg);
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
:root body .tabs-container::before {
  top: 3px;
  left: 3px;
  width: calc(50% - 3px);
  height: calc(100% - 6px);
  border: none;
  border-radius: 17px;
  background: var(--ui-segment-on);
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
:root body .feed-tab,
:root body .tab-btn {
  border-radius: 17px;
  color: var(--ui-text);
  font-size: 15px;
  font-weight: 600;
  background: transparent;
  box-shadow: none;
  padding: 8px;
}
:root body .feed-tab.active { background: var(--ui-segment-on); color: var(--ui-text); }
:root body .post-footer { border-top: 0.5px solid var(--ui-separator); }
:root body .post-action-btn,
:root body .post-like-btn {
  border: none;
  border-radius: 18px;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  color: var(--ui-text-2);
  font-size: 17px;
}
:root body .post-action-btn:hover,
:root body .post-like-btn:hover { background: var(--ui-cell-press); transform: none; }
:root body .post-like-btn.liked,
:root body .post-like-btn.liked i { color: #ff375f; }
:root body .post-views { color: var(--ui-text-2); }

:root body .modal-overlay { background: rgba(0,0,0,0.5); backdrop-filter: none; -webkit-backdrop-filter: none; }
:root body .modal {
  background: var(--ui-cell);
  border: 0.5px solid var(--ui-glass-border);
  border-radius: 28px;
  box-shadow: var(--ui-shadow);
}
:root body .dropdown-menu {
  background: var(--ui-glass);
  border: 0.5px solid var(--ui-glass-border);
  border-radius: 20px;
  box-shadow: var(--ui-shadow);
  backdrop-filter: saturate(180%) blur(30px);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
}
:root body .dropdown-item.danger { color: var(--ui-danger); }
:root body .channel-action-btn {
  background: var(--ui-glass);
  border: 0.5px solid var(--ui-glass-border);
  box-shadow: none;
  color: var(--ui-text);
}

/* ── Auth ─────────────────────────────────────────────────── */
:root body .auth-page {
  background: var(--ui-bg);
  min-height: 100vh;
  min-height: 100dvh;
}
:root body .auth-container {
  width: 100%;
  max-width: 420px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 24px calc(24px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
}
.auth-screen {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  animation: auth-in 0.3s ease;
}
@keyframes auth-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.auth-welcome {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding-bottom: 6vh;
}
.auth-hero {
  position: relative;
  margin-bottom: 36px;
}
.auth-hero::before {
  content: '';
  position: absolute;
  inset: -70px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(93,23,235,0.35) 0%, rgba(93,23,235,0.12) 40%, transparent 70%);
  pointer-events: none;
}
.auth-hero-circle {
  position: relative;
  width: 148px;
  height: 148px;
  border-radius: 50%;
  background: #000;
  border: 1px solid rgba(122,51,251,0.35);
  box-shadow: 0 0 40px rgba(93,23,235,0.45), inset 0 0 24px rgba(93,23,235,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #d4d4d8;
}
.auth-hero-circle svg { width: 64px; height: 64px; }
:root body.light-theme .auth-hero-circle { background: #fff; color: #3a3a3c; }
.auth-title {
  margin: 0 0 10px;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--ui-text);
}
.auth-subtitle {
  margin: 0 0 32px;
  font-size: 17px;
  color: var(--ui-text-2);
}
.auth-actions {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 28px;
}
.auth-btn {
  width: 100%;
  height: 56px;
  border-radius: 28px;
  font-size: 19px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.auth-btn:active { transform: scale(0.98); }
.auth-btn:disabled { opacity: 0.6; }
.auth-btn--primary { background: var(--ui-accent); color: #fff; }
.auth-btn--secondary {
  background: #101010;
  border: 1px solid #1f1f1f;
  color: var(--ui-text);
  font-weight: 400;
}
:root body.light-theme .auth-btn--secondary { background: #fff; border-color: rgba(0,0,0,0.08); }

/* Step screens */
.auth-form { padding-top: 76px; }
.auth-form .auth-title { font-size: 32px; }
.auth-form .auth-subtitle { margin-bottom: 28px; }
:root body .auth-back-btn {
  position: absolute;
  top: 0;
  left: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--ui-glass);
  border: 0.5px solid var(--ui-glass-border);
  color: var(--ui-text);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
}
.auth-user-pill { color: var(--ui-text); font-weight: 600; }
.auth-field-group {
  border-radius: 20px;
  background: var(--ui-cell);
  overflow: hidden;
}
.auth-field {
  position: relative;
  display: flex;
  align-items: center;
  height: 56px;
  padding: 0 18px;
  border-radius: 20px;
  background: var(--ui-cell);
}
.auth-field-group .auth-field { border-radius: 0; }
.auth-field-group .auth-field + .auth-field::before {
  content: '';
  position: absolute;
  top: 0;
  left: 18px;
  right: 0;
  height: 0.5px;
  background: var(--ui-separator);
}
:root body .auth-field input { flex: 1; height: 100%; font-size: 17px; }
:root body .auth-field .toggle-password {
  position: static;
  transform: none;
  color: var(--ui-text-2);
  background: transparent;
  font-size: 16px;
  padding: 8px 0 8px 12px;
}
.auth-hint { margin: 10px 18px 0; font-size: 13px; color: var(--ui-text-2); }
:root body .auth-form .form-error {
  margin: 12px 4px 0;
  padding: 0;
  background: none;
  border: none;
  color: var(--ui-danger);
  font-size: 14px;
}
.auth-form .auth-btn { margin-top: 28px; }

#theme-form .theme-card[data-theme="dark"] { display: none; }
:root body #edit-profile-form .toggle-row { width: 100%; }
#theme-form .theme-hint { padding: 0 16px; margin-top: 8px; overflow: visible; }

/* ── Fixes: profile @username, verified spacing ───────────── */
:root body .view-profile-username-pill { gap: 0; }
:root body .verified-badge { margin-right: 0.3em; }
:root body .chat-item-name .verified-badge,
:root body .chat-header-name .verified-badge { margin-right: 0; }

/* ── Conversation: header floats over the messages ────────── */
:root body .chat-main { --chat-header-h: 60px; }
:root body .chat-main .chat-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  isolation: isolate;
  background: transparent;
}
/* soft blurred strip behind the pills that fades into the chat */
:root body .chat-main .chat-header::before {
  content: '';
  position: absolute;
  inset: 0 0 -36px 0;
  z-index: -1;
  background: linear-gradient(to bottom,
    color-mix(in srgb, var(--ui-chat-bg) 80%, transparent) 0%,
    color-mix(in srgb, var(--ui-chat-bg) 45%, transparent) 65%,
    transparent 100%);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  -webkit-mask-image: linear-gradient(to bottom, #000 65%, transparent);
          mask-image: linear-gradient(to bottom, #000 65%, transparent);
  pointer-events: none;
}
:root body #chat-messages-area {
  padding-top: calc(var(--chat-header-h) + 12px);
  scroll-padding-top: calc(var(--chat-header-h) + 12px);
}
@media (max-width: 768px) {
  :root body.chat-is-open #chat-messages-area {
    padding-top: calc(var(--chat-header-h) + 12px + env(safe-area-inset-top, 0px));
  }
  :root body .chat-input-area { padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px)); }
}
:root body .tg-date-sep { top: calc(var(--chat-header-h) + 4px); }
@media (max-width: 768px) {
  :root body.chat-is-open .tg-date-sep { top: calc(var(--chat-header-h) + 4px + env(safe-area-inset-top, 0px)); }
}

/* Messages sit at the bottom, right above the input, like in Telegram */
:root body #chat-messages-area > :first-child { margin-top: auto; }

/* Reply / edit preview goes above the input instead of under the header */
:root body .chat-main > #chat-messages-area { order: 1; }
:root body .chat-main > .typing-indicator { order: 2; }
:root body .chat-main > .reply-preview-bar { order: 3; margin-top: 4px; }
:root body .chat-main > .chat-input-area { order: 4; }

/* ── Message context menu: transparent backdrop, glass menu ─ */
:root body .msg-context-overlay {
  background: rgba(0,0,0,0.25);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  animation: ctx-fade 0.15s ease;
}
:root body .msg-context-menu {
  min-width: 230px;
  padding: 6px;
  border: 0.5px solid var(--ui-glass-border);
  border-radius: 22px;
  background: color-mix(in srgb, var(--ui-cell) 62%, transparent);
  box-shadow: 0 12px 40px rgba(0,0,0,0.35);
  backdrop-filter: saturate(180%) blur(40px);
  -webkit-backdrop-filter: saturate(180%) blur(40px);
  animation: ctx-pop 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
:root body .msg-ctx-item {
  border-radius: 16px;
  color: var(--ui-text);
  font-size: 16px;
  background: transparent;
}
:root body .msg-ctx-item:hover,
:root body .msg-ctx-item:active { background: var(--ui-glass-active); }
:root body .msg-ctx-item i { color: var(--ui-text); opacity: 0.85; }
:root body .msg-ctx-item.danger,
:root body .msg-ctx-item.danger i,
:root body #ctx-delete-all,
:root body #ctx-delete-all i,
:root body #ctx-delete-me,
:root body #ctx-delete-me i { color: var(--ui-danger); }
.ctx-bubble-clone {
  position: fixed !important;
  margin: 0 !important;
  max-width: none !important;
  z-index: 1;
  pointer-events: none;
  animation: ctx-lift 0.18s ease;
}
.ctx-bubble-clone .react-btn { display: none !important; }
@keyframes ctx-fade { from { opacity: 0; } }
@keyframes ctx-pop  { from { opacity: 0; transform: scale(0.85); } }
@keyframes ctx-lift { from { transform: scale(0.97); } }
:root body .msg-context-overlay .msg-context-menu { z-index: 2; }

/* Day separators stay in place: stacked sticky labels piled up in long chats */
:root body .tg-date-sep,
:root body.chat-is-open .tg-date-sep { position: relative; top: auto; }

/* ── Conversation: input bar floats over the messages ────── */
:root body .chat-main > .chat-input-area {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  isolation: isolate;
  background: transparent;
}
/* blurred strip behind the three pills, fading upwards into the chat */
:root body .chat-main > .chat-input-area::before {
  content: '';
  position: absolute;
  inset: -36px 0 0 0;
  z-index: -1;
  background: linear-gradient(to top,
    color-mix(in srgb, var(--ui-chat-bg) 80%, transparent) 0%,
    color-mix(in srgb, var(--ui-chat-bg) 45%, transparent) 65%,
    transparent 100%);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  -webkit-mask-image: linear-gradient(to top, #000 65%, transparent);
          mask-image: linear-gradient(to top, #000 65%, transparent);
  pointer-events: none;
}
:root body .chat-main > .reply-preview-bar {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: var(--chat-input-h, 60px);
  z-index: 21;
  margin: 0 0 6px;
}
:root body .chat-main > .typing-indicator {
  position: absolute;
  left: 0;
  bottom: calc(var(--chat-input-h, 60px) + var(--chat-reply-h, 0px));
  z-index: 21;
}
:root body #chat-messages-area {
  padding-bottom: calc(var(--chat-input-h, 60px) + var(--chat-reply-h, 0px) + 8px);
}

/* Floating day label under the header while scrolling */
.tg-floating-date {
  position: absolute;
  top: calc(var(--chat-header-h) + 8px);
  left: 50%;
  z-index: 19;
  transform: translate(-50%, -6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
@media (max-width: 768px) {
  :root body.chat-is-open .tg-floating-date { top: calc(var(--chat-header-h) + 8px + env(safe-area-inset-top, 0px)); }
}
.tg-floating-date.visible { opacity: 1; transform: translate(-50%, 0); }
.tg-floating-date span {
  display: block;
  padding: 4px 12px;
  border-radius: 14px;
  background: var(--ui-glass);
  border: 0.5px solid var(--ui-glass-border);
  color: var(--ui-text);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
}

/* Input row: three separate pills, no backdrop, sitting at the very bottom.
   Only part of the home-indicator inset is kept (iOS 26 floating controls). */
:root body .chat-main > .chat-input-area::before { display: none; }
:root body .chat-main > .chat-input-area,
:root body.chat-is-open .chat-main > .chat-input-area {
  padding: 6px 12px max(8px, calc(env(safe-area-inset-bottom, 0px) - 12px));
  background: transparent;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* Chat screen spans the whole viewport (JS adjusts it only while the keyboard is open) */
@media (max-width: 768px) {
  :root body.chat-is-open #page-chats { top: 0; bottom: 0; height: auto; }
}

/* iOS 26 Home Screen apps: with black-translucent + viewport-fit=cover a
   height:100% html/body (and the fixed layout box) stops one status-bar
   height short of the screen bottom. 100vh is the full screen there. */
@media (display-mode: standalone) {
  html,
  :root body,
  :root body.chat-is-open { height: 100vh; }
  :root body.chat-is-open #page-chats { bottom: auto; height: 100vh; }
}

/* ── Microphone & camera permissions ──────────────────────── */
#permissions-settings-btn .profile-menu-icon { background: #ff375f; }
:root body #permissions-form .perm-row::before { display: none; }
:root body #permissions-form .perm-row { min-height: 64px; }
:root body #permissions-form .perm-row[data-perm="microphone"] .privacy-row-label i { background: #ff9f0a; }
:root body #permissions-form .perm-row[data-perm="camera"] .privacy-row-label i { background: #30d158; }
:root body #permissions-form .privacy-row-label > span { display: flex; flex-direction: column; line-height: 1.2; }
.perm-status { margin-top: 2px; font-size: 13px; color: var(--ui-text-2); }
.perm-row[data-state="granted"] .perm-status { color: #30d158; }
.perm-row[data-state="denied"] .perm-status { color: var(--ui-danger); }
.perm-btn {
  flex-shrink: 0;
  height: 34px;
  padding: 0 16px;
  border-radius: 17px;
  background: var(--ui-accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}
.perm-btn:disabled { background: var(--ui-cell-press); color: var(--ui-text-2); }
.perm-row[data-state="denied"] .perm-btn { background: var(--ui-cell-press); color: var(--ui-accent-ink); }
.perm-hint { margin: -12px 16px 0; font-size: 13px; line-height: 1.4; color: var(--ui-text-2); }
.perm-row[data-state="granted"] .perm-btn,
.perm-row[data-state="insecure"] .perm-btn { display: none; }
