/* MDW Drive v1.4 — responsive application UI pass
   Layered after the legacy theme and v1.3.1 hotfix so it can modernize the
   interface without destabilizing the existing server/templates. */
:root {
  --mdw-safe-top: env(safe-area-inset-top, 0px);
  --mdw-safe-right: env(safe-area-inset-right, 0px);
  --mdw-safe-bottom: env(safe-area-inset-bottom, 0px);
  --mdw-safe-left: env(safe-area-inset-left, 0px);
  --mdw-vvh: 100dvh;
  --mdw-vv-top: 0px;
  --mdw-mobile-tabbar: 66px;
  --mdw-appbar: 58px;
  --mdw-radius: 12px;
  --mdw-radius-lg: 16px;
  --mdw-surface-0: #090c11;
  --mdw-surface-1: #10151c;
  --mdw-surface-2: #161c24;
  --mdw-surface-3: #1c232d;
  --mdw-divider: rgba(255,255,255,.075);
  --mdw-hover: rgba(255,255,255,.055);
}

html {min-height: 100%;min-height: 100dvh;background: var(--mdw-surface-0); }
/* Installed iOS PWAs have a long-standing WebKit height discrepancy with
   viewport-fit=cover. At rest, 100vh reaches the standalone app canvas more
   reliably than 100dvh/visualViewport. JS switches --mdw-vvh back to measured
   pixels only while the software keyboard is actually open. */
html.mdw-ios-standalone {min-height: 100vh;background: var(--theme-bg2,#0e1116); }
html.mdw-ios-standalone body {min-height: 100vh;background: var(--theme-bg2,#0e1116); }
body {min-height: 100%;min-height: 100dvh;background: var(--mdw-surface-0);-webkit-text-size-adjust: 100%;text-rendering: optimizeLegibility;
}
body::selection {background: var(--theme-accent-soft,rgba(77,163,255,.32)); }
.ambient {opacity: .45; }

/* Desktop: make the product read as an application rather than a landing page. */
.topbar {min-height: 64px;padding: 10px clamp(18px,3vw,40px);gap: 22px;background: var(--theme-bg,rgba(9,12,17,.92));border-bottom-color: var(--mdw-divider);box-shadow: 0 1px 0 rgba(0,0,0,.2);
}
.brand-mark {width: 38px;height: 38px;border-radius: 11px;box-shadow: none; }
.brand strong {font-size: 14px; }
.brand small {font-size: 9px; }
.topbar nav {gap: 2px; }
.topbar nav a,
.link-button {min-height: 36px;display: inline-flex;align-items: center;position: relative;padding: 7px 10px;border-radius: 8px;font-size: 12px;
}
.topbar nav a.is-active {color: var(--theme-text,#fff);background: var(--theme-hover,rgba(255,255,255,.07));
}
.topbar nav a.is-active::after {content: "";position: absolute;left: 10px;right: 10px;bottom: 2px;height: 2px;border-radius: 999px;background: var(--blue);
}
.icon-button {transition: background .14s ease,border-color .14s ease,color .14s ease; }
.icon-button:hover {background: var(--mdw-surface-3);border-color: var(--theme-line2,#364556); }
.account-profile {width: 36px;height: 36px; }

.page {width: min(1400px,calc(100% - 36px));padding: 30px 0 64px;
}
.heading,.detail-head {margin-bottom: 20px;gap: 20px; }
.heading h1,.detail-head h1 {font-size: clamp(2rem,3.1vw,2.9rem);letter-spacing: -.045em;
}
.panel {padding: 20px;border-radius: var(--mdw-radius-lg);border-color: var(--mdw-divider);background: linear-gradient(180deg,var(--theme-surface,rgba(18,23,31,.98)),var(--theme-bg2,rgba(13,18,24,.98)));box-shadow: 0 12px 38px rgba(0,0,0,.22);
}
.button {border-radius: 9px;box-shadow: none; }
.button:hover {transform: none; }
.file-card,.room-card {transform: none !important; }
.file-card {min-height: 82px;border-radius: var(--mdw-radius);border-color: var(--mdw-divider);background: var(--theme-bg2,rgba(15,20,28,.76));
}
.file-card:hover,.room-card:hover {background: var(--theme-surface,#151c25); }
.toolbar {margin-bottom: 16px; }

/* Better keyboard/pointer focus without painting every mouse click. */
a:focus-visible,button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,[tabindex]:focus-visible {outline: 2px solid var(--theme-accent,rgba(103,183,255,.9));outline-offset: 2px;
}

/* Communications on desktop use the available viewport and keep the composer anchored. */
.page.channel-page {width: min(1540px,calc(100% - 24px));padding: 16px 0 18px; }
.discord-shell {height: calc(100dvh - 100px);min-height: 590px;border-radius: 14px;box-shadow: 0 16px 55px rgba(0,0,0,.28);
}
.channel-center {min-height: 0; }
.discord-chat-log {overscroll-behavior: contain;scrollbar-gutter: stable; }
.discord-compose {margin: 0 14px 14px;border: 1px solid var(--theme-divider,rgba(255,255,255,.045));border-radius: 11px;background: var(--theme-surface2,#242932);box-shadow: 0 6px 20px rgba(0,0,0,.13);
}
.discord-compose input {min-height: 46px; }
.message-delete {transition: opacity .12s ease,background .12s ease; }

.dm-heading {max-width: 1120px;margin-left: auto;margin-right: auto; }
.dm-heading h1 {margin: 2px 0 0;font-size: clamp(1.65rem,2.5vw,2.25rem);line-height: 1.08; }
.dm-shell {max-width: 1120px; }
.dm-chat-log {height: min(66vh,760px); }
.chat-message {border-radius: 9px; }

/* Notification settings: anchored popover on larger screens. */
.notification-panel {top: 68px;right: 18px;width: min(400px,calc(100vw - 36px));border-radius: 16px;border-color: var(--mdw-divider);background: var(--theme-bg2,rgba(15,20,28,.985));
}
.notification-panel label {min-height: 38px; }

/* Mobile-only navigation primitives are hidden on wider layouts. */
.mobile-tabbar,.mobile-more-sheet,.mobile-chat-back,.mobile-group-members-toggle,.group-attach-trigger {display: none; }
.group-attach-control {display: contents; }

/* Make scrollbars quieter on desktop while retaining affordance. */
@media (pointer:fine) {
  * {scrollbar-width: thin;scrollbar-color: var(--theme-line,#333c49) transparent; }
  *::-webkit-scrollbar {width: 10px;height: 10px; }
  *::-webkit-scrollbar-track {background: transparent; }
  *::-webkit-scrollbar-thumb {background: var(--theme-surface3,#333c49);border: 3px solid transparent;background-clip: padding-box;border-radius: 999px; }
  *::-webkit-scrollbar-thumb:hover {background: var(--theme-surface3,#465264);border: 2px solid transparent;background-clip: padding-box; }
}

@media (max-width: 800px) {
  html,body {overscroll-behavior-y: none; }
  body {background: var(--theme-bg2,#0d1015); }
  .ambient {display: none; }

  /* iOS auto-zooms focused form controls below ~16px. Keep editable controls at
     a true 16px on touch layouts instead of disabling user zoom. */
  input,select,textarea,
  .toolbar input,.toolbar select,
  .discord-compose input,.chat-compose input,.group-compose select {font-size: 16px !important;
  }

  /* Global mobile app bar. Primary navigation moves to the thumb zone below. */
  .topbar {position: sticky;top: 0;z-index: 60;min-height: calc(var(--mdw-appbar) + var(--mdw-safe-top));grid-template-columns: minmax(0,1fr) auto;gap: 8px;padding: calc(8px + var(--mdw-safe-top)) calc(10px + var(--mdw-safe-right)) 8px calc(10px + var(--mdw-safe-left));background: var(--theme-bg2,rgba(13,16,21,.96));backdrop-filter: blur(20px) saturate(130%);-webkit-backdrop-filter: blur(20px) saturate(130%);
  }
  .topbar .brand {min-width: 0;gap: 9px; }
  .topbar .brand-mark {width: 36px;height: 36px;border-radius: 10px;font-size: 18px; }
  .topbar .brand strong {font-size: 15px; }
  .topbar .brand small {display: none; }
  .topbar>nav {display: none !important; }
  .account {gap: 6px; }
  .account form,.account .link-button,#pwa-install,#pwa-update {display: none; }
  .account .icon-button,.account-profile {width: 44px;height: 44px;min-width: 44px;border-radius: 13px; }
  #notification-enable {border: 0;background: transparent;font-size: 0; }
  #notification-enable::before {content: "●";font-size: 18px;color: var(--theme-text,#aeb9c7); }
  .account-profile {background: var(--theme-surface3,#23374e); }
  body.mdw-ios-pwa .topbar {padding: calc(8px + var(--mdw-safe-top)) calc(10px + var(--mdw-safe-right)) 8px calc(10px + var(--mdw-safe-left));
  }

  .page {width: min(100% - 24px,1400px);padding: 22px 0 calc(var(--mdw-mobile-tabbar) + 28px + var(--mdw-safe-bottom));
  }
  body.mdw-ios-pwa .page,body.mdw-ios-pwa main {padding-bottom: calc(var(--mdw-mobile-tabbar) + 28px + var(--mdw-safe-bottom)); }
  html.mdw-ios-standalone,html.mdw-ios-standalone body {min-height: 100vh; }
  .heading,.detail-head {margin-bottom: 18px;gap: 12px;align-items: flex-start;flex-direction: column;
  }
  .heading h1,.detail-head h1 {margin-top: 2px;font-size: 30px;line-height: 1.05;letter-spacing: -.04em; }
  .heading p,.detail-head p {font-size: 13px;line-height: 1.45; }
  .eyebrow {font-size: 10px; }
  .heading>.button,.heading>.actions,.detail-head>.actions {align-self: stretch; }
  .heading>.button {min-height: 44px; }
  .actions .button,.row-actions .button {min-height: 44px; }
  .button.tiny {min-height: 40px; }
  .panel {padding: 16px;border-radius: 14px;box-shadow: none; }

  /* Bottom tab bar: one mobile primary nav, mirroring native chat/file apps. */
  .call-popup .mobile-tabbar,.call-popup .mobile-more-sheet {display: none !important; }
  .mobile-tabbar {position: fixed;z-index: 80;left: 0;right: 0;bottom: 0;min-height: calc(var(--mdw-mobile-tabbar) + var(--mdw-safe-bottom));padding: 6px max(6px,var(--mdw-safe-right)) calc(5px + var(--mdw-safe-bottom)) max(6px,var(--mdw-safe-left));display: grid;grid-template-columns: repeat(5,minmax(0,1fr));gap: 1px;border-top: 1px solid var(--theme-divider,rgba(255,255,255,.08));background: var(--theme-bg2,rgba(14,17,22,.965));backdrop-filter: blur(20px) saturate(135%);-webkit-backdrop-filter: blur(20px) saturate(135%);
  }
  .mobile-tabbar a,.mobile-tabbar button {position: relative;min-width: 0;min-height: 54px;padding: 5px 2px 3px;display: flex;flex-direction: column;align-items: center;justify-content: center;gap: 3px;border: 0;border-radius: 11px;background: transparent;color: var(--theme-muted,#7f8997);text-decoration: none;font: inherit;font-size: 10px;font-weight: 750;-webkit-tap-highlight-color: transparent;
  }
  .mobile-tabbar svg {width: 21px;height: 21px;fill: none;stroke: currentColor;stroke-width: 1.8;stroke-linecap: round;stroke-linejoin: round; }
  .mobile-tabbar .is-active {color: var(--theme-text,#eaf3ff);background: var(--theme-accent-soft,rgba(77,163,255,.1)); }
  .mobile-tabbar .is-active svg {color: var(--theme-accent-text,#6db7ff); }
  .mobile-tabbar .mobile-nav-badge {position: absolute;display: inline-grid;place-items: center;top: 2px;left: calc(50% + 7px);min-width: 17px;height: 17px;border-radius: 999px;background: var(--theme-danger-fill,#e34d62);color: var(--theme-text,#fff);padding: 0 4px;border: 2px solid var(--theme-line,#0e1116);font-size: 9px;font-weight: 900;
  }
  .mobile-nav-badge[hidden] {display: none !important; }

  /* iOS standalone can size the fixed-position containing block short by the
     bottom safe area. Overscan the tab bar by exactly that inset while preserving
     the visible control positions. If WebKit already reaches the physical edge,
     the excess is simply clipped and the layout is unchanged. */
  body.mdw-ios-pwa .mobile-tabbar {bottom: calc(0px - var(--mdw-safe-bottom));min-height: calc(var(--mdw-mobile-tabbar) + var(--mdw-safe-bottom) + var(--mdw-safe-bottom));padding-bottom: calc(5px + var(--mdw-safe-bottom) + var(--mdw-safe-bottom));background: var(--theme-bg2,#0e1116);
  }
  body.mdw-ios-pwa .mobile-tabbar::after {content: "";position: absolute;z-index: -1;left: 0;right: 0;top: 100%;height: 96px;background: var(--theme-bg2,#0e1116);pointer-events: none;
  }

  /* More is a bottom sheet rather than another desktop menu. */
  .mobile-more-sheet[hidden] {display: none !important; }
  .mobile-more-sheet {position: fixed;inset: 0;z-index: 120;display: grid;align-items: end;
  }
  .mobile-sheet-backdrop {position: absolute;inset: 0;border: 0;background: rgba(0,0,0,.58);backdrop-filter: blur(2px); }
  .mobile-sheet-card {position: relative;max-height: min(78dvh,680px);overflow: auto;padding: 8px calc(14px + var(--mdw-safe-right)) calc(14px + var(--mdw-safe-bottom)) calc(14px + var(--mdw-safe-left));border-radius: 20px 20px 0 0;border: 1px solid var(--theme-divider,rgba(255,255,255,.08));border-bottom: 0;background: var(--theme-surface,#171b22);box-shadow: 0 -18px 60px rgba(0,0,0,.42);
  }
  .mobile-sheet-handle {width: 38px;height: 4px;margin: 2px auto 12px;border-radius: 999px;background: var(--theme-surface3,#4e5662); }
  .mobile-sheet-profile {display: flex;align-items: center;gap: 12px;padding: 8px 6px 14px; }
  .mobile-sheet-profile .account-profile {width: 46px;height: 46px;min-width: 46px; }
  .mobile-sheet-profile strong,.mobile-sheet-profile small {display: block; }
  .mobile-sheet-profile small {color: var(--muted); }
  .mobile-sheet-links {display: grid;gap: 4px; }
  .mobile-sheet-links a,.mobile-sheet-links button,.mobile-sheet-links .mobile-sheet-logout {width: 100%;min-height: 48px;display: flex;align-items: center;gap: 12px;padding: 10px 12px;border: 0;border-radius: 11px;background: transparent;color: var(--theme-text,#e3e9ef);text-decoration: none;text-align: left;font: inherit;font-size: 15px;font-weight: 700;
  }
  .mobile-sheet-links a:active,.mobile-sheet-links button:active {background: var(--theme-hover,rgba(255,255,255,.07)); }
  .mobile-sheet-divider {height: 1px;margin: 7px 6px;background: var(--theme-hover,rgba(255,255,255,.08)); }
  .mobile-sheet-links form {margin: 0; }
  .mobile-sheet-links .danger-link {color: var(--theme-danger,#ff9aa7); }

  /* Notification controls become a real mobile sheet. */
  .notification-panel {position: fixed;left: 8px;right: 8px;top: auto;bottom: calc(8px + var(--mdw-safe-bottom));z-index: 150;width: auto;max-height: calc(var(--mdw-vvh) - var(--mdw-safe-top) - 22px);overflow: auto;padding: 18px;border-radius: 20px;box-shadow: 0 18px 65px rgba(0,0,0,.5);
  }
  .notification-panel label {min-height: 44px; }
  .notification-panel input[type=checkbox] {width: 20px;height: 20px;min-height: 20px; }
  .notification-panel .actions {display: grid;grid-template-columns: 1fr 1fr;gap: 8px; }
  .notification-panel .actions .button {min-height: 44px; }
  #push-disable {grid-column: 1/-1; }

  /* Mobile files are a scan-friendly list rather than desktop cards squeezed narrow. */
  .toolbar {grid-template-columns: 1fr;gap: 8px; }
  .toolbar .button {min-height: 44px; }
  .file-grid {display: block;border-top: 1px solid var(--mdw-divider); }
  .file-card {grid-template-columns: 50px minmax(0,1fr) auto;gap: 11px;min-height: 78px;padding: 11px 2px;border: 0;border-bottom: 1px solid var(--mdw-divider);border-radius: 0;background: transparent;
  }
  .file-card:active {background: var(--theme-hover,rgba(255,255,255,.04)); }
  .file-card .file-glyph {width: 44px;height: 50px; }
  .private-badge,.share-count {grid-column: auto;align-self: center; }
  .file-copy span {font-size: 11px; }

  /* Mobile channels / DMs / people use list hierarchy instead of card grids. */
  .community-overview {gap: 8px; }
  .community-overview aside {order: initial; }
  .room-grid,.dm-list,.people-grid {display: block;max-width: none; }
  .room-card,.dm-row,.person-card {margin: 0;border: 0;border-bottom: 1px solid var(--mdw-divider);border-radius: 0;background: transparent;
  }
  .room-card {min-height: 78px;padding: 13px 4px; }
  .room-card:active,.dm-row:active {background: var(--theme-hover,rgba(255,255,255,.045)); }
  .room-card h2 {font-size: 17px; }
  .room-card p {font-size: 12px; }
  .room-hash {width: 42px;height: 42px;font-size: 21px; }
  .dm-row {min-height: 72px;padding: 10px 4px; }
  .dm-row>div strong {font-size: 15px; }
  .dm-row>div span {font-size: 12px; }
  .people-grid {border-top: 1px solid var(--mdw-divider); }
  .person-card {grid-template-columns: auto minmax(0,1fr);padding: 14px 2px; }
  .person-card .avatar-xl {width: 54px;height: 54px; }
  .person-card h2 {margin-bottom: 0;font-size: 17px; }
  .person-card .row-actions {grid-column: 2;gap: 6px; }
  .person-card .row-actions .button {min-height: 38px; }
  .section-label {margin: 24px 0 8px;font-size: 10px; }

  /* General mobile detail/forms. */
  .detail-grid,.settings-grid {gap: 12px; }
  .facts div {grid-template-columns: 82px minmax(0,1fr);gap: 8px; }
  .share-row {padding: 12px; }
  .profile-hero {margin: 0 auto; }
  .profile-hero h1 {font-size: 34px; }
  .auth-page {padding-bottom: 24px; }
  .auth-panel {padding: 22px; }
  .upload-panel {margin: 0 auto; }
  .upload-form input[type=file] {min-height: 110px;padding: 38px 14px; }

  /* Conversation pages become self-contained mobile screens. */
  body.v14-conversation-view {overflow: hidden;height: var(--mdw-vvh);min-height: 0; }
  body.v14-conversation-view>.topbar,
  body.v14-conversation-view>.mobile-tabbar,
  body.v14-conversation-view>.ambient {display: none !important; }
  body.v14-conversation-view>.page {position: fixed;z-index: 1;left: 0;right: 0;top: var(--mdw-vv-top);width: 100%;height: var(--mdw-vvh);min-height: 0;margin: 0;padding: 0;overflow: hidden;background: var(--theme-surface,#171a1f);
  }
  body.mdw-ios-pwa.v14-conversation-view>.page,body.mdw-ios-pwa.v14-conversation-view>main {padding: 0 !important; }

  /* Channel conversation screen. */
  .page.channel-page {width: 100%;padding: 0; }
  .discord-shell {width: 100%;height: 100%;min-height: 0;grid-template-columns: 1fr;border: 0;border-radius: 0;box-shadow: none;
  }
  .channel-center {height: 100%;grid-template-rows: auto minmax(0,1fr) auto; }
  .channel-header {min-height: calc(54px + var(--mdw-safe-top));padding: var(--mdw-safe-top) calc(8px + var(--mdw-safe-right)) 0 calc(7px + var(--mdw-safe-left));gap: 6px;background: var(--theme-surface,rgba(24,27,32,.97));
  }
  .channel-title {gap: 5px;min-width: 0; }
  .channel-title strong {max-width: 38vw;overflow: hidden;text-overflow: ellipsis; }
  .channel-title em {display: none; }
  .channel-header-actions {gap: 1px; }
  .channel-header-actions .icon-text-button,
  .mobile-rail-toggle {min-width: 44px;min-height: 44px;display: inline-flex;align-items: center;justify-content: center;padding: 7px;border-radius: 11px;-webkit-tap-highlight-color: transparent;
  }
  .channel-header-actions b {display: none; }
  .channel-header-actions .icon-text-button {font-size: 16px; }
  .channel-header-actions .bell-glyph {font-size: 17px; }
  .member-drawer-toggle {font-size: 0; }
  .member-drawer-toggle::before {content: "☷";font-size: 21px; }
  .channel-drawer-toggle {font-size: 0; }
  .channel-drawer-toggle::before {content: "☰";font-size: 20px; }
  .discord-chat-log {padding: 10px 0 8px; }
  .discord-chat-log .chat-message {padding: 6px calc(10px + var(--mdw-safe-right)) 6px calc(10px + var(--mdw-safe-left)); }
  .message-head {gap: 8px; }
  .message-head time {font-size: 9px; }
  .message-body {font-size: 14px;line-height: 1.45; }
  .message-delete {opacity: .45;width: 32px;height: 32px; }
  .discord-compose,.chat-compose {margin: 0;padding: 7px calc(8px + var(--mdw-safe-right)) calc(7px + var(--mdw-safe-bottom)) calc(8px + var(--mdw-safe-left));grid-template-columns: minmax(0,1fr) auto;gap: 7px;border: 0;border-top: 1px solid var(--mdw-divider);border-radius: 0;background: var(--theme-surface,#181b21);box-shadow: none;
  }
  .discord-compose input,.chat-compose input {min-height: 46px;padding: 10px 13px;border: 1px solid var(--theme-divider,rgba(255,255,255,.06));border-radius: 18px;background: var(--theme-surface2,#252a32);
  }
  .discord-compose .button,.chat-compose .button {width: 46px;min-width: 46px;height: 46px;min-height: 46px;margin: 0;padding: 0;border-radius: 50%;font-size: 0;
  }
  .discord-compose .button::before,.chat-compose .button::before {content: "↑";font-size: 20px;font-weight: 900; }
  .mention-hint {display: none; }
  body.mdw-ios-pwa.v14-conversation-view .discord-compose,body.mdw-ios-pwa.v14-conversation-view .chat-compose {padding-bottom: calc(7px + var(--mdw-safe-bottom)); }
  body.v14-keyboard-open .discord-compose,body.v14-keyboard-open .chat-compose,body.mdw-ios-pwa.v14-keyboard-open .discord-compose,body.mdw-ios-pwa.v14-keyboard-open .chat-compose {padding-bottom: 7px; }
  .read-only-channel {margin: 0;padding-bottom: calc(11px + var(--mdw-safe-bottom));border-radius: 0; }

  /* Channel/member drawers gain safe areas and a dismissable app-like surface. */
  .discord-shell.mobile-channels-open .channel-sidebar,
  .discord-shell.mobile-members-open .member-sidebar {top: var(--mdw-vv-top);bottom: auto;height: var(--mdw-vvh);max-height: var(--mdw-vvh);padding-top: var(--mdw-safe-top);padding-bottom: var(--mdw-safe-bottom);z-index: 170;
  }
  .discord-shell.mobile-channels-open .channel-sidebar {width: min(315px,88vw); }
  .discord-shell.mobile-members-open .member-sidebar {width: min(315px,88vw); }
  .channel-link {min-height: 46px; }
  .channel-member {min-height: 46px; }

  /* Direct and group threads get a native-style compact chat header. */
  .page.dm-thread-page,.page.group-thread-page {display: grid;grid-template-rows: auto minmax(0,1fr);
  }
  .dm-heading {position: relative;z-index: 3;width: 100%;max-width: none;min-height: calc(58px + var(--mdw-safe-top));margin: 0;padding: var(--mdw-safe-top) calc(8px + var(--mdw-safe-right)) 0 calc(8px + var(--mdw-safe-left));display: grid;grid-template-columns: 44px minmax(0,1fr) auto;align-items: center;gap: 6px;border-bottom: 1px solid var(--mdw-divider);background: var(--theme-surface,rgba(24,27,32,.98));
  }
  .mobile-chat-back {width: 44px;height: 44px;display: grid;place-items: center;border-radius: 11px;color: var(--theme-text,#cbd4df);text-decoration: none;font-size: 31px;font-weight: 400;line-height: 1;
  }
  .dm-person {min-width: 0;gap: 9px; }
  .dm-person .avatar-md {width: 36px;height: 36px; }
  .dm-person .eyebrow,.dm-person p {display: none; }
  .dm-heading h1 {margin: 0;font-size: 16px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;letter-spacing: -.01em; }
  .dm-heading>.actions {width: auto;display: flex;flex-wrap: nowrap;gap: 2px; }
  .dm-heading>.actions>* {flex: 0 0 auto; }
  .dm-heading>.actions>.desktop-thread-action {display: none; }
  .dm-heading>.actions .button,
  .dm-heading>.actions form .button,
  .mobile-group-members-toggle {width: 44px;min-width: 44px;height: 44px;min-height: 44px;padding: 0 7px;border: 0;border-radius: 11px;background: transparent;font-size: 0;
  }
  .dm-heading>.actions form[data-call-popout] .button::before {content: "☎";font-size: 19px; }
  .dm-heading>.actions>a[href*="settings"]::before {content: "⚙";font-size: 18px; }
  #group-mute::before {content: "🔔";font-size: 16px; }
  .mobile-group-members-toggle {display: inline-grid;place-items: center;color: var(--theme-text,#d7dce3);cursor: pointer; }
  .mobile-group-members-toggle::before {content: "☷";font-size: 21px; }

  .page.dm-thread-page .dm-shell,
  .page.group-thread-page .group-comms-layout {width: 100%;max-width: none;height: 100%;min-height: 0;margin: 0;
  }
  .page.dm-thread-page .dm-shell,
  .page.group-thread-page .dm-shell {display: grid;grid-template-rows: minmax(0,1fr) auto;padding: 0;border: 0;border-radius: 0;background: var(--theme-surface,#191c21);box-shadow: none;
  }
  .dm-chat-log,.page.group-thread-page .dm-chat-log {width: 100%;height: auto;min-height: 0;padding: 10px calc(8px + var(--mdw-safe-right)) 8px calc(8px + var(--mdw-safe-left));gap: 7px;overscroll-behavior: contain;
  }
  .dm-chat-log .chat-message {margin: 0;padding: 8px 9px;border-radius: 10px; }

  .group-comms-layout {display: block; }
  .page.group-thread-page .group-comms-layout>section {height: 100%; }
  .page.group-thread-page .group-members {display: none;position: fixed;z-index: 175;right: 0;top: var(--mdw-vv-top);width: min(315px,88vw);height: var(--mdw-vvh);max-height: var(--mdw-vvh);margin: 0;padding: calc(16px + var(--mdw-safe-top)) calc(12px + var(--mdw-safe-right)) calc(16px + var(--mdw-safe-bottom)) 12px;overflow: auto;border-radius: 0;box-shadow: -24px 0 60px rgba(0,0,0,.5);
  }
  body.v14-group-members-open .page.group-thread-page .group-members {display: block; }
  .group-member-row {min-height: 48px; }

  /* Attachment chooser is a compact + action in the mobile composer. */
  .group-compose {grid-template-columns: auto minmax(0,1fr) auto;align-items: end; }
  .group-attach-control {display: block;position: relative;width: 46px;height: 46px;order: -1; }
  .group-attach-trigger {width: 46px;height: 46px;display: grid;place-items: center;border: 0;border-radius: 50%;background: var(--theme-surface2,#2a3039);color: var(--theme-text,#cfd7e2);font-size: 25px;line-height: 1;cursor: pointer;
  }
  .group-attach-trigger[data-count]:not([data-count="0"])::after {content: attr(data-count);position: absolute;right: -2px;top: -3px;min-width: 18px;height: 18px;display: grid;place-items: center;padding: 0 4px;border: 2px solid var(--theme-line,#181b21);border-radius: 999px;background: var(--theme-danger-fill,#e34d62);color: var(--theme-text,#fff);font-size: 9px;font-weight: 900;
  }
  .group-attach-control select {position: absolute;inset: 0;width: 46px !important;height: 46px;min-height: 46px !important;opacity: .001;cursor: pointer;
  }
  .group-compose>input {grid-column: 2;grid-row: 1; }
  .group-compose>.button {grid-column: 3;grid-row: 1; }

  /* Calls: thumb-sized controls and viewport-safe chrome. */
  .call-popup .call-workspace {height: var(--mdw-vvh);min-height: 0; }
  .call-topbar {min-height: calc(60px + var(--mdw-safe-top));padding: calc(8px + var(--mdw-safe-top)) calc(10px + var(--mdw-safe-right)) 8px calc(10px + var(--mdw-safe-left)); }
  .call-topbar h1 {font-size: 16px; }
  .call-video-grid {min-height: 0;overflow: auto; }
  .call-control {min-width: 64px;min-height: 48px; }
  .call-dock {padding: 10px calc(8px + var(--mdw-safe-right)) calc(10px + var(--mdw-safe-bottom)) calc(8px + var(--mdw-safe-left));gap: 8px; }

  /* Toasts avoid the tab bar/home indicator. */
  .toast {left: 12px;right: 12px;bottom: calc(var(--mdw-mobile-tabbar) + var(--mdw-safe-bottom) + 10px);text-align: center; }
  body.v14-conversation-view .toast {bottom: calc(var(--mdw-safe-bottom) + 74px); }
  .incoming-call-banner {left: 10px;right: 10px;top: calc(8px + var(--mdw-safe-top)); }
}

@media (max-width: 390px) {
  .channel-title strong {max-width: 31vw; }
  .mobile-tabbar a,.mobile-tabbar button {font-size: 9px; }
  .heading h1,.detail-head h1 {font-size: 28px; }
  .private-badge,.share-count {font-size: 8px;padding: 4px 5px; }
  .dm-heading {grid-template-columns: 40px minmax(0,1fr) auto; }
  .mobile-chat-back {width: 40px; }
}

@media (hover:none) and (pointer:coarse) {
  .button:hover,.file-card:hover,.room-card:hover,.channel-member:hover,.channel-link:hover {transform: none; }
  .message-delete {opacity: .55; }
}

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