:root,
:root[data-theme="graphite"] {
  color-scheme: dark;
  --canvas: #0b0d10;
  --rail: #0e1115;
  --surface: #15191f;
  --surface-raised: #1b2027;
  --surface-soft: #11151a;
  --text: #f1f3f5;
  --muted: #969eaa;
  --faint: #6f7782;
  --accent: #7f9fbc;
  --accent-strong: #40566b;
  --accent-soft: rgba(127, 159, 188, .14);
  --message-me: #263746;
  --message-peer: #171c22;
  --danger: #d66c70;
  --warning: #c7a56b;
  --success: #7fa98f;
  --border: rgba(237, 242, 247, .09);
  --border-strong: rgba(237, 242, 247, .16);
  --shadow-1: 0 12px 30px rgba(0, 0, 0, .24);
  --shadow-2: 0 24px 68px rgba(0, 0, 0, .38);
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --radius-s: 8px;
  --radius-m: 12px;
  --radius-l: 18px;
  --duration-fast: 120ms;
  --duration-base: 180ms;
  --duration-slow: 240ms;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --primary: var(--accent-strong);
  --primary-strong: var(--accent-strong);
  --secondary: var(--accent);
  --bg: var(--canvas);
}

:root[data-theme="warm-charcoal"] {
  --canvas: #100f0e;
  --rail: #13110f;
  --surface: #1a1715;
  --surface-raised: #221e1b;
  --surface-soft: #151210;
  --text: #f3efec;
  --muted: #a69c95;
  --faint: #776e68;
  --accent: #c08c75;
  --accent-strong: #6f4636;
  --accent-soft: rgba(192, 140, 117, .14);
  --message-me: #3b2922;
  --message-peer: #1c1816;
  --border: rgba(248, 237, 230, .09);
  --border-strong: rgba(248, 237, 230, .17);
}

:root[data-theme="deep-forest"] {
  --canvas: #0b100e;
  --rail: #0e1411;
  --surface: #121915;
  --surface-raised: #18211c;
  --surface-soft: #0f1512;
  --text: #eef1ed;
  --muted: #98a19a;
  --faint: #6f7971;
  --accent: #98a584;
  --accent-strong: #4c5d48;
  --accent-soft: rgba(152, 165, 132, .14);
  --message-me: #28372e;
  --message-peer: #141b17;
  --border: rgba(237, 244, 238, .09);
  --border-strong: rgba(237, 244, 238, .16);
}

:root[data-theme="dark-sand"] {
  --canvas: #100f0d;
  --rail: #13110e;
  --surface: #191713;
  --surface-raised: #211e18;
  --surface-soft: #15130f;
  --text: #f2eee7;
  --muted: #a69d90;
  --faint: #786f63;
  --accent: #b79b74;
  --accent-strong: #65523a;
  --accent-soft: rgba(183, 155, 116, .14);
  --message-me: #3b3226;
  --message-peer: #1b1813;
  --border: rgba(246, 237, 221, .09);
  --border-strong: rgba(246, 237, 221, .17);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

html,
body {
  background: var(--canvas);
}

body {
  font-family: Inter, "SF Pro Text", "Segoe UI Variable", "Segoe UI", sans-serif;
  letter-spacing: -.01em;
}

body,
button,
input,
textarea,
select,
.auth-shell,
.messenger,
.sidebar,
.chat-pane,
.settings-panel,
.peer-profile-panel,
.side-menu,
.composer,
.chat-header,
.bubble,
.dialog-card,
.profile-card,
.call-window {
  transition:
    color var(--duration-base) ease,
    background-color var(--duration-base) ease,
    border-color var(--duration-base) ease,
    box-shadow var(--duration-base) ease;
}

button {
  min-height: 44px;
  border-radius: var(--radius-s);
  background: var(--accent-strong);
  color: var(--text);
  font-weight: 680;
  box-shadow: none;
}

button:hover {
  transform: none;
  background-color: color-mix(in srgb, var(--accent-strong) 90%, white);
}

button:active {
  transform: scale(.975);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.auth-shell {
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent-strong) 8%, transparent), transparent 42%),
    var(--canvas);
}

.auth-panel {
  width: min(430px, calc(100vw - 32px));
  gap: 14px;
  padding: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  backdrop-filter: none;
}

.brand-mark,
.empty-logo {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-m);
  background: var(--surface-raised);
  color: var(--accent);
  box-shadow: none;
}

.auth-panel input {
  background: var(--surface-soft);
  border-color: var(--border);
  border-radius: var(--radius-s);
}

.auth-panel input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  transform: none;
}

.eyebrow {
  color: var(--accent);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.messenger {
  height: 100dvh;
  display: grid;
  grid-template-columns: 68px 340px minmax(0, 1fr);
  gap: 0;
  background: var(--canvas);
}

.workspace-rail {
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 14px 8px;
  background: var(--rail);
  border-right: 1px solid var(--border);
}

.rail-brand {
  width: 44px;
  height: 44px;
  min-height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 13px;
  background: var(--surface-raised);
  color: var(--accent);
  font-size: 20px;
  font-weight: 800;
}

.rail-primary,
.rail-secondary {
  width: 100%;
  display: grid;
  gap: 6px;
}

.rail-primary {
  flex: 1;
  align-content: start;
}

.rail-secondary {
  align-content: end;
}

.rail-action {
  min-height: 52px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  padding: 5px 2px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
}

.rail-action span {
  font-size: 19px;
  line-height: 1;
}

.rail-action small {
  font-size: 9px;
  font-weight: 650;
}

.rail-action:hover,
.rail-action.active {
  background: var(--accent-soft);
  border-color: var(--border);
  color: var(--text);
}

.rail-profile {
  width: 44px;
  height: 44px;
  min-height: 44px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface-raised);
  color: var(--accent);
}

.rail-profile span,
.rail-profile img {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  border-radius: inherit;
  object-fit: cover;
}

.sidebar {
  position: relative;
  min-width: 0;
  height: 100dvh;
  margin: 0;
  padding: 18px 14px 12px;
  display: flex;
  flex-direction: column;
  border: 0;
  border-right: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface-soft);
  box-shadow: none;
  backdrop-filter: none;
}

.sidebar-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 2px 16px;
}

.sidebar-heading h2 {
  margin: 2px 0 0;
  font-size: 24px;
  font-weight: 720;
  letter-spacing: -.035em;
}

.sidebar-heading .eyebrow {
  margin: 0;
}

.new-chat-button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 11px;
  white-space: nowrap;
  border: 1px solid var(--border-strong);
  background: var(--surface-raised);
  color: var(--text);
  font-size: 12px;
}

.side-top {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 0;
}

.mobile-menu-btn {
  display: none;
}

.mobile-chat-back {
  display: none;
}

.search-box,
.panel-search {
  height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  background: var(--canvas);
  color: var(--muted);
}

.search-box:focus-within,
.panel-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.notice {
  margin: 12px 0 8px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  background: var(--accent-soft);
  color: var(--text);
  text-align: left;
}

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

.folder-tabs {
  margin: 4px -2px 6px;
  padding: 2px;
  gap: 6px;
  scrollbar-width: none;
}

.folder-tab {
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 680;
}

.folder-tab.active {
  border-color: var(--border-strong);
  background: var(--surface-raised);
  color: var(--text);
}

.list-section-label,
.contacts-title {
  min-height: auto;
  display: flex;
  justify-content: space-between;
  padding: 10px 8px 5px;
  color: var(--faint);
  font-size: 10px;
  font-weight: 760;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.list-section-label small {
  letter-spacing: .04em;
}

.chat-list {
  flex: 1;
  min-height: 120px;
  padding: 0;
}

.contacts {
  max-height: 22vh;
}

.chat-item,
.contact-item {
  position: relative;
  min-height: 66px;
  margin: 2px 0;
  padding: 9px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-m);
  background: transparent;
  color: var(--text);
}

.chat-item:hover,
.contact-item:hover {
  background: color-mix(in srgb, var(--surface-raised) 64%, transparent);
}

.chat-item.active {
  border-color: var(--border-strong);
  background: var(--accent-soft);
}

.chat-item.active::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 15px;
  bottom: 15px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.avatar {
  border: 1px solid var(--border-strong);
  background: var(--surface-raised);
  color: var(--accent);
  font-weight: 720;
  box-shadow: none;
}

.item-main strong {
  font-size: 13px;
}

.item-main span,
.item-meta {
  color: var(--muted);
  font-size: 11px;
}

.pin-mark {
  color: var(--accent);
}

.unread-badge {
  min-width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  margin-top: 6px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--accent-strong);
  color: var(--text);
  font-size: 10px;
}

.chat-pane {
  position: relative;
  min-width: 0;
  height: 100dvh;
  overflow: hidden;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--accent-strong) 3%, transparent), transparent 34%),
    var(--canvas);
}

.chat-header {
  left: 22px;
  right: 22px;
  top: 14px;
  height: 62px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: var(--shadow-1);
  backdrop-filter: none;
}

.header-copy strong {
  font-size: 14px;
  font-weight: 720;
}

.header-copy span {
  color: var(--muted);
  font-size: 11px;
}

.icon-btn {
  min-width: 42px;
  width: 42px;
  height: 42px;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
}

.icon-btn:hover {
  border-color: var(--border);
  background: var(--surface-raised);
  color: var(--text);
}

.messages {
  padding: 98px max(28px, calc((100% - 760px) / 2)) 122px;
  gap: 8px;
  scroll-behavior: smooth;
}

.bubble {
  max-width: min(610px, 78%);
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px 12px 12px 4px;
  background: var(--message-peer);
  box-shadow: none;
  animation: premiumMessageIn var(--duration-base) var(--ease-out) both;
}

.bubble.me {
  border-color: color-mix(in srgb, var(--accent) 20%, var(--border));
  border-radius: 12px 12px 4px 12px;
  background: var(--message-me);
}

.bubble.no-animate {
  animation: none;
}

.bubble .name,
.reply-preview strong,
.pinned-message-bar strong {
  color: var(--accent);
}

.bubble .time {
  color: color-mix(in srgb, var(--muted) 82%, transparent);
}

.message-status {
  margin-left: 4px;
  color: var(--muted);
}

.message-status.read {
  color: var(--accent);
}

.reaction-chip {
  border-color: var(--border);
  background: var(--surface-raised);
}

.reaction-chip.reaction-pop {
  animation: reactionPop var(--duration-base) var(--ease-out);
}

.composer {
  left: max(22px, calc((100% - 780px) / 2));
  right: max(22px, calc((100% - 780px) / 2));
  bottom: 16px;
  max-width: none;
  min-height: 64px;
  height: auto;
  grid-template-columns: auto minmax(0, 1fr) 42px 42px 46px;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-l);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  backdrop-filter: none;
}

.composer-tools {
  display: flex;
  align-items: center;
}

.composer-tools .icon-btn {
  width: 36px;
  min-width: 36px;
}

#messageInput {
  width: 100%;
  min-height: 42px;
  max-height: 132px;
  padding: 10px 8px;
  resize: none;
  overflow-y: auto;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  line-height: 1.35;
}

.send-btn {
  width: 46px;
  height: 46px;
  min-height: 46px;
  border: 1px solid color-mix(in srgb, var(--accent) 24%, transparent);
  border-radius: 12px;
  background: var(--accent-strong);
}

.reply-preview,
.upload-queue,
.voice-record-panel {
  left: max(22px, calc((100% - 760px) / 2));
  right: max(22px, calc((100% - 760px) / 2));
  max-width: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}

.reply-preview,
.upload-queue {
  bottom: 90px;
}

.emoji-picker {
  position: absolute;
  left: max(22px, calc((100% - 780px) / 2));
  bottom: 92px;
  z-index: 12;
  width: min(360px, calc(100vw - 32px));
  max-height: 390px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-l);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  animation: premiumMenuIn var(--duration-base) var(--ease-out) both;
}

.emoji-picker header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.emoji-section {
  margin-bottom: 8px;
}

.emoji-section small {
  display: block;
  margin: 3px 4px 7px;
  color: var(--faint);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 3px;
}

.emoji-grid button,
.emoji-section button {
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border: 1px solid transparent;
  background: transparent;
  font-size: 20px;
}

.emoji-grid button:hover,
.emoji-section button:hover {
  border-color: var(--border);
  background: var(--surface-raised);
}

.pinned-message-bar,
.voice-room-bar,
.chat-search-panel {
  left: max(22px, calc((100% - 760px) / 2));
  right: max(22px, calc((100% - 760px) / 2));
  max-width: none;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}

.chat-search-panel {
  top: 84px;
}

.pinned-message-bar,
.voice-room-bar {
  top: 84px;
}

.global-search-results,
.side-menu,
.compose-menu,
.chat-actions-menu,
.message-context-menu,
.settings-dots-menu {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-m);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  animation: premiumMenuIn var(--duration-base) var(--ease-out) both;
}

.compose-menu {
  left: 82px;
  bottom: 18px;
}

.message-context-menu button,
.chat-actions-menu button,
.compose-menu button,
.side-menu button {
  min-height: 40px;
  background: transparent;
  color: var(--text);
}

.message-context-menu button:hover,
.chat-actions-menu button:hover,
.compose-menu button:hover,
.side-menu button:hover {
  background: var(--surface-raised);
}

.peer-profile-panel {
  top: 0;
  right: 0;
  bottom: 0;
  width: 340px;
  border: 0;
  border-left: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface-soft);
  box-shadow: -18px 0 48px rgba(0, 0, 0, .2);
  animation: premiumPanelIn var(--duration-slow) var(--ease-out) both;
}

.peer-profile-card,
.settings-card,
.notify-section,
.profile-info-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  background: var(--surface);
}

.peer-card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.peer-card-heading > div {
  display: flex;
  gap: 4px;
}

.peer-card-heading .text-action {
  width: auto;
  min-height: 30px;
  padding: 0 7px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 10px;
}

.peer-member-row {
  min-height: 54px;
  grid-template-columns: 36px minmax(0, 1fr) auto;
}

.member-actions {
  grid-column: 2 / -1;
  display: flex;
  gap: 3px;
}

.member-actions button {
  width: auto;
  min-height: 30px;
  padding: 0 7px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 10px;
}

.settings-panel {
  left: 68px;
  top: 0;
  bottom: 0;
  width: min(720px, calc(100vw - 68px));
  padding-bottom: 30px;
  border: 0;
  border-right: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface-soft);
  box-shadow: 20px 0 60px rgba(0, 0, 0, .26);
}

.settings-header {
  min-height: 70px;
  background: var(--surface-soft);
  border-bottom-color: var(--border);
}

.settings-card,
.notify-section {
  max-width: 620px;
  margin-left: auto;
  margin-right: auto;
}

.settings-card button,
.settings-row,
.privacy-row,
.settings-line {
  color: var(--text);
}

.settings-card button:hover,
.privacy-row:hover,
.settings-line:hover {
  background: var(--surface-raised);
}

.theme-presets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.theme-preset {
  min-height: 66px;
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  text-align: left;
}

.theme-preset i {
  width: 28px;
  height: 38px;
  border-radius: 7px;
  background: #15191f;
  box-shadow: inset 0 0 0 8px #40566b;
}

.theme-preset[data-theme-preset="warm-charcoal"] i {
  background: #1a1715;
  box-shadow: inset 0 0 0 8px #6f4636;
}

.theme-preset[data-theme-preset="deep-forest"] i {
  background: #121915;
  box-shadow: inset 0 0 0 8px #4c5d48;
}

.theme-preset[data-theme-preset="dark-sand"] i {
  background: #191713;
  box-shadow: inset 0 0 0 8px #65523a;
}

.theme-preset span {
  display: grid;
  gap: 3px;
}

.theme-preset small {
  color: var(--muted);
  font-size: 11px;
}

.theme-preset.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.profile-backdrop,
.dialog-backdrop,
.call-modal,
.media-viewer,
.screen-quality-backdrop {
  background: rgba(4, 6, 8, .76);
  backdrop-filter: blur(4px);
}

.profile-card,
.dialog-card,
.call-card,
.screen-quality-card {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  box-shadow: var(--shadow-2);
}

.profile-banner-pattern {
  background:
    linear-gradient(120deg, var(--accent-soft), transparent 46%),
    var(--surface-raised);
}

.profile-grid input,
.profile-grid textarea,
.dialog-fields input,
.dialog-fields textarea,
.dialog-fields select {
  border-color: var(--border);
  background: var(--surface-soft);
  color: var(--text);
}

.call-window {
  top: 72px;
  right: 22px;
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-l);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  backdrop-filter: none;
}

.call-media-stage {
  position: relative;
  min-height: 250px;
  background: var(--canvas);
}

.call-media-stage video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.local-call-video {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  width: 104px !important;
  height: 132px !important;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-m);
  background: var(--surface-raised);
  box-shadow: var(--shadow-1);
}

.call-window-actions {
  grid-template-columns: 46px 46px 46px 1fr;
  background: var(--surface);
}

.toast {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  box-shadow: var(--shadow-2);
}

.messenger.dragging-files::after {
  inset: 14px;
  border: 1px dashed var(--accent);
  border-radius: var(--radius-l);
  background: color-mix(in srgb, var(--canvas) 92%, transparent);
  color: var(--text);
  backdrop-filter: none;
}

.skeleton-list {
  display: grid;
  gap: 8px;
  padding: 4px;
}

.skeleton-row {
  height: 62px;
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  background:
    linear-gradient(90deg, var(--surface) 25%, var(--surface-raised) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: skeletonMove 1.2s ease-in-out infinite;
}

.message-skeleton {
  width: min(420px, 62%);
  height: 58px;
  margin: 8px max(28px, calc((100% - 760px) / 2));
  border-radius: var(--radius-m);
  background: var(--surface);
  animation: skeletonPulse 1.1s ease-in-out infinite alternate;
}

@keyframes premiumMessageIn {
  from { opacity: 0; transform: translateY(6px) scale(.99); }
  to { opacity: 1; transform: none; }
}

@keyframes premiumMenuIn {
  from { opacity: 0; transform: translateY(4px) scale(.98); }
  to { opacity: 1; transform: none; }
}

@keyframes premiumPanelIn {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: none; }
}

@keyframes reactionPop {
  from { opacity: .4; transform: scale(.94); }
  to { opacity: 1; transform: none; }
}

@keyframes skeletonMove {
  from { background-position: 180% 0; }
  to { background-position: -20% 0; }
}

@keyframes skeletonPulse {
  from { opacity: .48; }
  to { opacity: .82; }
}

.settings-home-panel {
  left: 68px;
  right: auto;
  width: min(380px, calc(100vw - 68px));
  padding-bottom: 0;
  border: 0;
  border-right: 1px solid var(--border);
  background: var(--canvas);
  box-shadow: 20px 0 56px rgba(0, 0, 0, .24);
}

.settings-home-panel .settings-header {
  min-height: 64px;
  height: 64px;
  grid-template-columns: 44px minmax(0, 1fr) 44px 44px 44px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--canvas) 94%, transparent);
  backdrop-filter: blur(12px);
}

.settings-home-panel .settings-header > strong {
  font-size: 19px;
  font-weight: 720;
  letter-spacing: -.025em;
}

.settings-home-panel .settings-edit-button {
  color: var(--accent);
}

.settings-home-content {
  width: calc(100% - 24px);
  margin: 0 auto;
  padding: 10px 0 44px;
}

.settings-home-panel .settings-profile {
  gap: 5px;
  padding: 18px 20px 26px;
}

.settings-home-panel .settings-avatar {
  width: 108px;
  height: 108px;
  border: 1px solid var(--border-strong);
  background: var(--surface-raised);
  color: var(--accent);
  font-size: 38px;
  box-shadow: var(--shadow-1);
}

.settings-home-panel .settings-profile h2 {
  margin-top: 12px;
  font-size: 21px;
  font-weight: 740;
}

.settings-home-panel .settings-profile p {
  font-size: 13px;
  font-weight: 620;
}

.settings-home-panel .settings-card {
  max-width: none;
  margin: 0 0 14px;
  border-radius: var(--radius-l);
  background: var(--surface);
  box-shadow: none;
}

.settings-home-panel .settings-row,
.settings-home-panel .settings-card button {
  min-height: 58px;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 12px;
  padding: 9px 14px;
  font-weight: 660;
  box-shadow: inset 0 -1px 0 var(--border);
}

.settings-home-panel .settings-row > span,
.settings-home-panel .settings-card button > span {
  color: var(--muted);
  font-size: 19px;
}

.settings-home-panel .settings-row strong {
  font-weight: 690;
}

.settings-home-panel .settings-row small {
  margin-top: 2px;
  font-size: 12px;
  font-weight: 560;
}

.settings-home-panel .settings-security-card {
  margin-bottom: max(24px, env(safe-area-inset-bottom));
}

.profile-backdrop {
  left: 68px;
  padding: 0;
  display: block;
  background: transparent;
  backdrop-filter: none;
}

.profile-card {
  position: absolute;
  inset: 0 auto auto 0;
  width: min(380px, calc(100vw - 68px));
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0 18px 36px;
  gap: 0;
  border-width: 0 1px 0 0;
  border-radius: 0;
  background: var(--canvas);
  box-shadow: 20px 0 56px rgba(0, 0, 0, .28);
}

.profile-edit-header {
  position: sticky;
  top: 0;
  z-index: 5;
  min-height: 64px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin: 0 -18px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--canvas) 94%, transparent);
  backdrop-filter: blur(12px);
}

.profile-edit-header > strong {
  font-size: 19px;
  font-weight: 720;
}

.profile-close {
  position: static;
  color: var(--muted);
  background: transparent;
  font-size: 27px;
}

.profile-save-top {
  width: auto;
  min-height: 38px;
  padding: 0 10px;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
}

.profile-save-top:hover {
  background: var(--accent-soft);
}

.profile-edit-avatar {
  display: grid;
  place-items: center;
  padding: 30px 0 26px;
}

.profile-avatar-wrap .avatar {
  width: 112px;
  height: 112px;
  border: 1px solid var(--border-strong);
  background: var(--surface-raised);
  color: var(--accent);
  font-size: 38px;
  box-shadow: var(--shadow-1);
}

.profile-camera-mark {
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 3px solid var(--canvas);
  border-radius: 50%;
  background: var(--accent-strong);
  color: var(--text);
  font-size: 15px;
}

.profile-legacy-data,
.profile-actions-fallback {
  display: none;
}

.profile-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.profile-edit-group {
  overflow: hidden;
  display: grid;
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  background: var(--surface);
}

.profile-grid .profile-edit-group label {
  gap: 3px;
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--accent);
  font-size: 11px;
  font-weight: 620;
}

.profile-grid .profile-edit-group label:last-child {
  border-bottom: 0;
}

.profile-grid .profile-edit-group input,
.profile-grid .profile-edit-group textarea {
  min-height: 36px;
  padding: 2px 0 5px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  font-weight: 590;
  box-shadow: none;
}

.profile-grid .profile-edit-group textarea {
  min-height: 74px;
}

.profile-grid .profile-edit-group input:focus,
.profile-grid .profile-edit-group textarea:focus {
  border: 0;
  box-shadow: none;
  transform: none;
}

.profile-edit-hint {
  margin: -2px 10px 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.profile-username-group label {
  color: var(--accent) !important;
}

.profile-card > .error {
  margin: 10px 8px 0;
}

@media (min-width: 1320px) {
  .chat-pane.inspector-open {
    padding-right: 340px;
  }
}

@media (max-width: 1040px) {
  .messenger {
    grid-template-columns: 62px 310px minmax(0, 1fr);
  }

  .chat-pane {
    display: block;
  }

  .messenger.chat-open .sidebar {
    display: flex;
  }

  .workspace-rail {
    padding-left: 6px;
    padding-right: 6px;
  }

  .settings-panel {
    left: 62px;
    width: min(680px, calc(100vw - 62px));
  }

  .settings-home-panel {
    right: auto;
    width: min(380px, calc(100vw - 62px));
  }

  .profile-backdrop {
    left: 62px;
  }

  .profile-card {
    width: min(380px, calc(100vw - 62px));
  }

  .sidebar-heading {
    align-items: flex-start;
  }

  .new-chat-button {
    width: 40px;
    padding: 0;
    justify-content: center;
    font-size: 0;
  }

  .new-chat-button span {
    font-size: 18px;
  }
}

@media (max-width: 700px) {
  .messenger {
    display: block;
  }

  .chat-pane {
    display: none;
  }

  .messenger.chat-open .sidebar {
    display: none;
  }

  .messenger.chat-open .chat-pane {
    display: block;
    height: 100dvh;
  }

  .mobile-chat-back {
    display: grid;
  }

  .chat-header {
    grid-template-columns: 40px 42px minmax(0, 1fr) auto;
  }

  .workspace-rail {
    position: fixed;
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    z-index: 30;
    width: auto;
    height: calc(64px + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: 5px 8px env(safe-area-inset-bottom);
    border: 0;
    border-top: 1px solid var(--border);
  }

  .rail-brand,
  .rail-secondary .rail-action:first-child,
  .rail-profile {
    display: none;
  }

  .rail-primary,
  .rail-secondary {
    display: contents;
  }

  .rail-action {
    min-height: 52px;
  }

  .rail-secondary [data-rail-action="settings"] {
    display: grid;
  }

  .sidebar {
    height: 100dvh;
    padding-bottom: calc(74px + env(safe-area-inset-bottom));
    border-right: 0;
  }

  .messenger.chat-open .workspace-rail {
    display: none;
  }

  .chat-header,
  .composer,
  .chat-search-panel,
  .reply-preview,
  .upload-queue,
  .voice-record-panel,
  .pinned-message-bar,
  .voice-room-bar {
    left: 10px;
    right: 10px;
    max-width: none;
  }

  .messages {
    padding-left: 12px;
    padding-right: 12px;
  }

  .settings-panel {
    left: 0;
    width: 100vw;
  }

  .settings-home-panel {
    right: 0;
    width: 100vw;
    z-index: 35;
  }

  .messenger:has(.settings-home-panel:not(.hidden)) .workspace-rail {
    display: none;
  }

  .settings-home-panel .settings-header {
    padding-left: 10px;
    padding-right: 10px;
  }

  .settings-home-content {
    width: min(520px, calc(100% - 24px));
  }

  .profile-backdrop {
    left: 0;
    padding-left: 0;
  }

  .profile-card {
    width: 100%;
    border: 0;
  }

  .peer-profile-panel {
    width: min(390px, 100vw);
  }

  .emoji-picker {
    left: 10px;
    bottom: calc(88px + env(safe-area-inset-bottom));
  }

  .compose-menu {
    left: 12px;
    right: 12px;
    bottom: calc(72px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 560px) {
  .sidebar {
    padding: 18px 12px calc(76px + env(safe-area-inset-bottom));
  }

  .sidebar-heading h2 {
    font-size: 23px;
  }

  .side-top {
    position: static;
    background: transparent;
    padding: 0;
  }

  .notice,
  .contacts-title,
  .contacts {
    display: none;
  }

  .chat-header {
    top: 8px;
    border-radius: var(--radius-m);
  }

  .chat-header-actions .icon-btn:nth-of-type(3) {
    display: none;
  }

  .messages {
    padding-top: 82px;
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
  }

  .bubble {
    max-width: 88%;
  }

  .composer {
    bottom: calc(8px + env(safe-area-inset-bottom));
    grid-template-columns: auto minmax(0, 1fr) 38px 42px;
    padding: 6px;
  }

  .composer-tools {
    width: 68px;
    display: flex;
    flex-wrap: nowrap;
  }

  #scheduleBtn {
    display: none;
  }

  #emojiBtn {
    display: grid;
  }

  .call-window-actions {
    grid-template-columns: 42px 42px 42px 1fr;
  }

  .theme-presets {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation: none !important;
    transition-duration: .01ms !important;
  }
}

.no-animations *,
.no-animations *::before,
.no-animations *::after {
  scroll-behavior: auto !important;
  animation: none !important;
  transition: none !important;
}
