:root {
  --bg-main: #313338;
  --bg-sidebar: #2b2d31;
  --bg-guilds: #1e1f22;
  --bg-card: #232428;
  --bg-input: #1e1f22;
  --text-main: #dbdee1;
  --text-muted: #949ba4;
  --accent: #5865f2;
  --success: #23a559;
  --danger: #da373c;
  --border: #1a1b1e;
  --safe-bottom: max(0px, env(safe-area-inset-bottom, 0px));
  --safe-top: max(0px, env(safe-area-inset-top, 0px));
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  min-height: 100dvh;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
}

#root {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  position: relative;
  background: var(--bg-main);
  color: var(--text-main);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

/* Вне потока flex, чтобы #root растягивал только .layout. Не display:none — <audio> остаётся валидным для WebRTC. */
.remote-audio-host {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  z-index: 0;
}

.remote-video-host {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  z-index: 0;
}

button, input, textarea, label, select {
  font-family: inherit;
  touch-action: manipulation;
}

.notif-btn {
  position: relative;
  padding-right: 14px;
}

.notif-badge {
  position: absolute;
  right: -6px;
  top: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(218, 55, 60, 0.95);
  color: #fff;
  font-size: 0.72rem;
  line-height: 1;
  border: 2px solid var(--bg-main);
}

.notif-list {
  display: grid;
  gap: 8px;
}

.notif-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-main);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
}

.notif-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.notif-item.is-unread {
  border-color: rgba(88, 101, 242, 0.6);
  box-shadow: 0 0 0 1px rgba(88, 101, 242, 0.35) inset;
}

.notif-title {
  font-weight: 800;
  margin-bottom: 2px;
}

.notif-body {
  color: var(--text-muted);
  line-height: 1.25;
  margin-bottom: 6px;
  word-break: break-word;
}

/* Один вложенный root для flex: сетка (layout) + position:fixed оверлеи */
.app-shell {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  position: relative;
}

.layout {
  display: grid;
  /* layout-nav (иконки + боковая) | чат | участники */
  grid-template-columns: 352px 1fr 260px;
  grid-template-rows: minmax(0, 1fr);
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  align-content: stretch;
}

.guild-icon-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 16px;
  display: block;
}

.server-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.server-top-menu-btn {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
  display: grid;
  place-items: center;
}

.server-top-menu-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
}

.server-menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 240;
}

.server-menu {
  position: absolute;
  left: 76px;
  top: 58px;
  width: 260px;
  background: #1f2024;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.35);
}

.server-menu-item {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text-main);
  padding: 10px 10px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  display: block;
  font-size: 14px;
}

.server-menu-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.server-menu-item.danger {
  color: #ffb4b4;
}

.server-menu-item.danger:hover {
  background: rgba(218, 55, 60, 0.18);
}

.voice-connection-panel {
  margin-top: 10px;
  padding: 10px 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.06);
  display: grid;
  gap: 10px;
}

.voice-connection-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.voice-connection-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 2px rgba(35, 165, 89, 0.35);
  flex-shrink: 0;
}

.voice-connection-dot.is-joining {
  background: #5865f2;
  box-shadow: 0 0 0 2px rgba(88, 101, 242, 0.4);
  animation: voice-dot-pulse 1.1s ease-in-out infinite;
}

.voice-connection-titles {
  min-width: 0;
}

.voice-connection-title {
  font-weight: 800;
  font-size: 0.9rem;
  line-height: 1.1;
}

.voice-connection-sub {
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voice-connection-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.voice-connection-hangup {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  background: rgba(218, 55, 60, 0.25);
  color: #faa;
  display: grid;
  place-items: center;
  font-size: 1rem;
  line-height: 1;
}

/* Две зоны слева (сервер/DM + список каналов) */
.layout-nav {
  display: grid;
  grid-template-columns: 72px 280px;
  grid-template-rows: minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  align-content: stretch;
  height: 100%;
}

.guilds {
  background: var(--bg-guilds);
  border-right: 1px solid var(--border);
  padding: 12px 10px;
  padding-top: max(12px, var(--safe-top));
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.guild-icon {
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: #3c45a5;
  cursor: pointer;
  flex-shrink: 0;
  border: none;
  color: #fff;
}

.guild-badge {
  position: absolute;
  right: -6px;
  top: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(218, 55, 60, 0.95);
  color: #fff;
  font-size: 0.72rem;
  line-height: 1;
  border: 2px solid var(--bg-main);
}

.server-top {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.server-top-title {
  font-size: 1.02rem;
  font-weight: 900;
}

.server-top-desc {
  margin-top: 4px;
  line-height: 1.25;
}

.server-top-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.guild-icon.active {
  outline: 3px solid #ffffff;
  outline-offset: -3px;
}

.guild-icon-add {
  background: #248046;
  font-size: 1.5rem;
  line-height: 1;
  font-weight: 300;
}

.server-name-header {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 600;
  padding: 0 14px 8px;
  border-bottom: 1px solid var(--border);
}

.channels {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.panel-header {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  flex-shrink: 0;
}

.panel-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.panel-header--sub {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding-top: 10px;
}

.channels-body {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
}

.channels-list {
  padding: 8px;
  overflow: visible;
  -webkit-overflow-scrolling: touch;
  flex: 0 0 auto;
  min-height: 0;
}

.channel-item {
  min-height: 40px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chan-avatar {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.chan-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.chan-avatar-fallback {
  font-weight: 800;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.9);
}

.chan-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
}

.channel-item.active, .channel-item:hover {
  background: #404249;
  color: var(--text-main);
}

.channel-create-box {
  padding: 0 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.channel-create-box input {
  width: 100%;
  background: var(--bg-input);
  border: 0;
  border-radius: 8px;
  color: var(--text-main);
  padding: 10px;
}

.channel-item--voice {
  font-size: 0.95rem;
}

.channel-voice-group {
  display: block;
}

.channel-item-spacer {
  flex: 1;
}

.icon-btn {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 0.9rem;
  line-height: 1;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
}

.icon-btn.danger {
  color: #ffb4b4;
}

.icon-btn.danger:hover {
  background: rgba(218, 55, 60, 0.18);
  color: #ffd0d0;
}

.voice-members-inline {
  list-style: none;
  margin: 6px 0 10px 26px;
  padding: 0;
  display: grid;
  gap: 4px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.voice-members-inline li {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.voice-member-avatar {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.voice-member-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.voice-members-inline li.is-speaking .voice-member-name {
  color: #fff;
  text-shadow: 0 0 0.01px rgba(255,255,255,0.2);
}

.voice-member-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-pill {
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(235, 69, 90, 0.18);
  border: 1px solid rgba(235, 69, 90, 0.35);
  color: #ffb7c2;
  flex-shrink: 0;
}

.small-btn--mini {
  padding: 4px 8px;
  font-size: 0.75rem;
  border-radius: 8px;
}

.screen-overlay {
  position: fixed;
  inset: 0;
  z-index: 260;
  background: rgba(0, 0, 0, 0.72);
  display: grid;
  grid-template-rows: auto 1fr;
  padding: 12px;
}

.screen-overlay--window {
  inset: auto 16px 16px auto;
  width: min(520px, calc(100vw - 32px));
  height: min(320px, calc(100vh - 32px));
  border-radius: 16px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid var(--border);
  box-shadow: 0 12px 30px rgba(0,0,0,0.45);
}

.screen-overlay-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
}

.screen-overlay-title {
  font-weight: 700;
}

.screen-overlay-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.screen-overlay-body {
  padding: 0 12px 12px 12px;
}

.screen-video {
  width: 100%;
  height: 100%;
  max-height: calc(100vh - 90px);
  border-radius: 14px;
  background: #0f1011;
  border: 1px solid var(--border);
  object-fit: contain;
}
.voice-members-inline__me {
  color: var(--text-main);
  font-weight: 600;
}

.channel-item-voice-ico {
  flex-shrink: 0;
  opacity: 0.85;
}

.voice-connection-panel {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: #1e1f22;
  padding: 10px 12px;
  flex-shrink: 0;
}

.voice-connection-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.voice-connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--success);
  font-size: 0.85rem;
  font-weight: 600;
}

.voice-connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 2px rgba(35, 165, 89, 0.35);
}

.voice-connection-panel--joining .voice-connection-row {
  margin-bottom: 0;
}

.voice-connection-panel--joining .voice-connection-status {
  color: var(--text-muted);
  font-weight: 500;
}

.voice-connection-dot--pulse {
  background: #5865f2;
  box-shadow: 0 0 0 2px rgba(88, 101, 242, 0.4);
  animation: voice-dot-pulse 1.1s ease-in-out infinite;
}

@keyframes voice-dot-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

.voice-link-sub {
  line-height: 1.3;
  margin-top: 2px;
  margin-bottom: 4px;
}

.voice-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

/* Video elements live in .remote-video-host; actual viewing is via .screen-overlay. */

.msg-text a {
  color: #7aa2ff;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-word;
}

.msg-text a:hover {
  color: #a8c0ff;
}

.voice-hangup {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  background: rgba(218, 55, 60, 0.25);
  color: #faa;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 1rem;
  line-height: 1;
}

.voice-hangup::before {
  content: "↓";
  font-weight: 700;
}

.voice-channel-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 6px;
  min-width: 0;
}

.voice-channel-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voice-roster {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.8rem;
  color: var(--text-main);
  max-height: 84px;
  overflow-y: auto;
}

.voice-roster li {
  padding: 2px 0;
}

.user-card {
  border-top: 1px solid var(--border);
  padding: 10px;
  background: #232428;
  flex-shrink: 0;
}

.user-card-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.user-card-identity {
  min-width: 0;
  flex: 1;
}

.user-voice-ctrl {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.user-voice-btn {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  background: #3f4249;
  font-size: 1rem;
  line-height: 1;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--text-main);
}

.user-voice-btn.is-off {
  background: rgba(218, 55, 60, 0.3);
  opacity: 0.9;
}

.chat {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.chat-header {
  min-height: 48px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  padding-top: max(8px, var(--safe-top));
  flex-wrap: nowrap;
  gap: 8px 12px;
}

.chat-header-top {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.chat-header-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  min-width: 40px;
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  background: #3f4249;
  color: #fff;
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
  cursor: pointer;
}

.back-btn:focus-visible,
.small-btn:focus-visible,
button:focus-visible,
.guild-icon:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chat-header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px 8px;
  flex-shrink: 0;
}

.layout--narrow .chat-header {
  flex-wrap: wrap;
  align-items: flex-start;
}

.layout--narrow .chat-header-top {
  width: 100%;
}

.layout--narrow .chat-header-actions {
  width: 100%;
  flex-basis: 100%;
  justify-content: flex-start;
}

.layout--narrow .chat-header-actions input[placeholder] {
  flex: 1;
  min-width: 120px;
  max-width: 100%;
}

.messages {
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 12px 14px;
  padding-left: max(12px, env(safe-area-inset-left, 0px));
  padding-right: max(14px, env(safe-area-inset-right, 0px));
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.only-narrow {
  display: none;
}

.layout--narrow .only-narrow {
  display: block;
}

.layout--narrow .hide-when-narrow {
  display: none;
}

.message {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 10px;
}

.msg-avatar {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar-fallback {
  font-weight: 800;
  color: rgba(255, 255, 255, 0.92);
}

.profile-avatar-edit {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 10px;
}

.avatar {
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.avatar--lg {
  width: 56px;
  height: 56px;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.message-top {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 6px 10px;
}

/* Автор + время + кнопки в одной линии слева, без растягивающей «пустоты» */
.message-top-left {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  min-width: 0;
}

.msg-author {
  font-weight: 700;
}

.msg-time {
  color: var(--text-muted);
  font-size: 12px;
}

.unread-badge {
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.message-actions {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  flex: 0 0 auto;
}

.message-actions button {
  min-height: 32px;
  min-width: 2.5rem;
  border: 0;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  color: #fff;
  background: #4a4f57;
}

.message-actions button.danger {
  background: var(--danger);
}

.msg-file {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  background: #1b1c1f;
  padding: 6px 8px;
  border-radius: 8px;
}

.msg-file button {
  min-height: 40px;
  border: 0;
  background: var(--accent);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
}

.composer {
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  padding-bottom: max(10px, var(--safe-bottom));
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.composer input[type="text"] {
  border: 0;
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text-main);
  padding: 10px 12px;
  min-width: 0;
  min-height: 44px;
}

.composer button, .small-btn {
  border: 0;
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 44px;
  cursor: pointer;
  color: white;
  background: var(--accent);
}

.small-btn {
  min-height: 40px;
  padding: 8px 10px;
  font-size: 12px;
}

.members {
  background: #2b2d31;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.members-list {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-height: 0;
}

.member {
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.1);
  min-height: 44px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-wrap {
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-top: max(16px, var(--safe-top));
  padding-bottom: max(16px, var(--safe-bottom));
  background: radial-gradient(circle at top, #2f3b84, #1e1f22 45%);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: #2b2d31;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  flex-shrink: 0;
}

.auth-card h1 {
  margin-top: 0;
  word-wrap: break-word;
}

.auth-card input, .auth-card textarea {
  width: 100%;
  max-width: 100%;
  border: 0;
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text-main);
  padding: 12px 10px;
  margin-bottom: 10px;
  min-height: 44px;
  font-size: 16px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.muted {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.45;
  word-wrap: break-word;
}

.danger {
  color: #ff8b8b;
}

.success {
  color: #70e397;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Узкие: одна «страница» — список или чат */
.layout--narrow {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  height: auto;
}

.layout--narrow[data-ui="list"] .chat,
.layout--narrow[data-ui="list"] .members {
  display: none;
}

.layout--narrow[data-ui="list"] .layout-nav {
  flex: 1;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  min-height: 0;
}

.layout--narrow[data-ui="list"] .guilds {
  width: 56px;
  min-width: 56px;
  padding: 10px 8px;
}

.layout--narrow[data-ui="list"] .guild-icon {
  width: 40px;
  min-width: 40px;
  height: 40px;
  min-height: 40px;
  border-radius: 12px;
  font-size: 0.9rem;
}

.layout--narrow[data-ui="chat"] .layout-nav {
  display: none;
}

.layout--narrow[data-ui="chat"] .chat {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Участники: на телефоне в боковой колонке нет, только sheet */
.layout--narrow .members {
  display: none !important;
}

/* Сообщение про push в узкой панели короче */
.layout--narrow .mobile-push-hint {
  display: none;
}

/* Toast */
.toast-bar {
  position: fixed;
  z-index: 200;
  right: max(12px, env(safe-area-inset-right, 0px));
  bottom: max(12px, env(safe-area-inset-bottom, 0px));
  max-width: min(400px, calc(100vw - 24px));
  background: #111214;
  border: 1px solid #2d2f35;
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  word-break: break-word;
}

/* Модалка «Участники» */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  padding-bottom: var(--safe-bottom);
}

/* Центровые модалки (создание сервера/каналов) */
.sheet-backdrop--center {
  align-items: center;
  padding: 16px;
  padding-top: max(16px, var(--safe-top));
  padding-bottom: max(16px, var(--safe-bottom));
}

.sheet-panel {
  width: 100%;
  max-height: 70dvh;
  max-height: 70vh;
  background: #2b2d31;
  border: 1px solid var(--border);
  border-radius: 12px 12px 0 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  animation: sheet-up 0.2s ease-out;
}

.sheet-panel--center {
  max-width: 520px;
  border-radius: 12px;
  max-height: min(80dvh, 80vh);
  animation: modal-pop 0.16s ease-out;
}

@keyframes modal-pop {
  from { transform: translateY(8px) scale(0.98); opacity: 0.9; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.form-field {
  width: 100%;
  max-width: 100%;
  border: 0;
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text-main);
  padding: 12px 10px;
  margin-bottom: 10px;
  min-height: 44px;
  font-size: 16px;
}

.form-field--textarea {
  min-height: 96px;
  resize: vertical;
}

@keyframes sheet-up {
  from { transform: translateY(20px); opacity: 0.9; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  flex-shrink: 0;
}

.sheet-close {
  width: 40px;
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  background: #3f4249;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.sheet-body {
  padding: 10px 12px 16px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-height: 0;
}

/* Планшеты: без правой панели участников */
@media (max-width: 1200px) and (min-width: 901px) {
  .layout {
    grid-template-columns: 304px 1fr;
  }

  .layout-nav {
    grid-template-columns: 64px 240px;
  }

  .members {
    display: none;
  }
}

/* Телефоны: шрифты в полях 16px — без авто-зума iOS */
@media (max-width: 900px) {
  .composer input[type="text"] {
    font-size: 16px;
  }

  .chat-header-actions input[placeholder] {
    font-size: 16px;
  }
}
