
:root {
  color-scheme: dark;

  --ink-950: #081019;
  --ink-925: #0b131e;
  --ink-900: #10151f;
  --ink-875: #111b27;
  --ink-850: #15212d;
  --ink-800: #1a2835;
  --ink-750: #223341;
  --ink-700: #2a3c49;

  --surface-canvas: var(--ink-900);
  --surface-rail: var(--ink-950);
  --surface-sidebar: var(--ink-875);
  --surface-content: #121923;
  --surface-raised: var(--ink-850);
  --surface-overlay: #182633;
  --surface-input: #0d1721;
  --surface-hover: rgba(255, 255, 255, .055);
  --surface-active: rgba(107, 231, 199, .105);

  --text-primary: #f1f7f7;
  --text-secondary: #aebec5;
  --text-tertiary: #7f949e;
  --text-disabled: #61737c;
  --text-on-primary: #062018;

  --primary: #6be7c7;
  --primary-strong: #4fd7b4;
  --primary-soft: rgba(107, 231, 199, .12);
  --secondary: #65cce8;
  --secondary-soft: rgba(101, 204, 232, .12);
  --live: #ff7d72;
  --live-soft: rgba(255, 125, 114, .13);
  --warning: #efc36b;
  --warning-soft: rgba(239, 195, 107, .12);
  --success: #66d59f;
  --danger: #ff8278;

  --border-subtle: rgba(255, 255, 255, .08);
  --border-default: rgba(255, 255, 255, .14);
  --border-strong: rgba(255, 255, 255, .22);
  --focus-ring: 0 0 0 2px var(--primary), 0 0 0 5px rgba(107, 231, 199, .18);

  --shadow-sm: 0 8px 20px rgba(0, 0, 0, .18);
  --shadow-md: 0 18px 48px rgba(0, 0, 0, .34);
  --shadow-lg: 0 28px 80px rgba(0, 0, 0, .48);

  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  --rail-width: 72px;
  --sidebar-width: 264px;
  --members-width: 300px;
  --thread-width: 420px;
  --top-height: 62px;
  --mobile-nav-height: 72px;
  --app-viewport-height: 100dvh;
  --keyboard-inset: 0px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

html {
  background: var(--surface-canvas);
  scrollbar-color: var(--ink-700) transparent;
}

body {
  margin: 0;
  min-height: 100dvh;
  overflow: hidden;
  background: var(--surface-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select {
  color: inherit;
  font: inherit;
}

button {
  appearance: none;
  border: 0;
  background: transparent;
}

button,
[role="button"] {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible,
[role="button"]:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

button:disabled,
input:disabled,
textarea:disabled,
select:disabled,
.disabled {
  cursor: not-allowed !important;
  opacity: .48;
}

button:not(:disabled) {
  cursor: pointer;
}

::selection {
  background: rgba(107, 231, 199, .28);
  color: var(--text-primary);
}

.hidden {
  display: none !important;
}

.srOnly {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skipLink {
  position: fixed;
  left: var(--space-4);
  top: var(--space-4);
  z-index: 2000;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--text-on-primary);
  font-weight: 800;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform .16s ease;
}

.skipLink:focus {
  transform: translateY(0);
}

body.thread-open {
  --members-width: clamp(320px, var(--thread-width), min(42vw, 760px));
}

body.thread-resizing,
body.thread-resizing * {
  cursor: col-resize !important;
  user-select: none !important;
}

.app {
  display: grid;
  grid-template-columns: var(--rail-width) var(--sidebar-width) minmax(0, 1fr) var(--members-width);
  grid-template-rows: var(--top-height) minmax(0, 1fr) auto;
  grid-template-areas:
    "servers channels top members"
    "servers channels chat members"
    "servers channels composer members";
  width: 100%;
  height: var(--app-viewport-height, 100dvh);
  min-height: var(--app-viewport-height, 100dvh);
  background: var(--surface-content);
}

/* Workspace rail */
.servers {
  grid-area: servers;
  z-index: 45;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 10px 8px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface-rail);
  border-right: 1px solid var(--border-subtle);
}

.pill {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
  user-select: none;
  transition: color .16s ease, background .16s ease, border-color .16s ease, transform .12s ease;
}

.pill:hover {
  border-color: var(--border-default);
  background: var(--ink-800);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.pill:active {
  transform: translateY(0);
}

.pill.active {
  border-color: rgba(107, 231, 199, .34);
  background: var(--primary-soft);
  color: var(--primary);
}

.pill.active::before {
  content: "";
  position: absolute;
  left: -15px;
  width: 4px;
  height: 24px;
  border-radius: var(--radius-pill);
  background: var(--primary);
}

.pill.home {
  color: var(--primary);
}

.pill.add {
  border-style: dashed;
  border-color: rgba(107, 231, 199, .28);
  background: transparent;
  color: var(--primary);
}

.pill .badge {
  position: absolute;
  right: -6px;
  bottom: -5px;
  display: grid;
  place-items: center;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border: 3px solid var(--surface-rail);
  border-radius: var(--radius-pill);
  background: var(--live);
  color: #1c0b0a;
  font-size: 10px;
  font-weight: 900;
}

/* Channel sidebar */
.channels {
  grid-area: channels;
  z-index: 40;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--surface-sidebar);
  border-right: 1px solid var(--border-subtle);
}

.guildHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 var(--top-height);
  min-width: 0;
  padding: 0 12px 0 14px;
  border-bottom: 1px solid var(--border-subtle);
}

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

.brandMark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(107, 231, 199, .22);
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary);
}

.brandMark.large {
  width: 58px;
  height: 58px;
  border-radius: var(--radius-lg);
}

.guildTitleWrap,
.meText {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.productEyebrow,
.contextEyebrow {
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .1em;
  line-height: 1.25;
  text-transform: uppercase;
}

.guildTitle {
  overflow: hidden;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebarUtility {
  padding: 12px 10px 4px;
}

.quickSwitcherBtn {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 40px;
  gap: 9px;
  padding: 0 9px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--surface-input);
  color: var(--text-secondary);
  text-align: left;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.quickSwitcherBtn:hover {
  border-color: var(--border-default);
  background: var(--ink-800);
  color: var(--text-primary);
}

.quickSwitcherBtn > span:not(.shortcut) {
  overflow: hidden;
  flex: 1;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shortcut,
.searchShortcut,
.escapeKey,
.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 20px;
  padding: 0 6px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, .045);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1;
}

.channelScroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 8px 8px 16px;
}

.section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 30px;
  margin-top: 7px;
  padding: 4px 8px;
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .085em;
  text-transform: uppercase;
}

.chan {
  display: flex;
  align-items: center;
  min-height: 38px;
  gap: 9px;
  margin: 1px 0;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 560;
  user-select: none;
  transition: color .14s ease, background .14s ease, border-color .14s ease;
}

.chan:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.chan.active {
  border-color: rgba(107, 231, 199, .13);
  background: var(--surface-active);
  color: var(--text-primary);
}

.chan .hash {
  display: grid;
  place-items: center;
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  color: var(--text-tertiary);
}

.chan.active .hash {
  color: var(--primary);
}

.channelFooter {
  display: flex;
  align-items: center;
  flex: 0 0 66px;
  gap: 5px;
  padding: 8px;
  background: var(--ink-925);
  border-top: 1px solid var(--border-subtle);
}

.me {
  display: flex;
  align-items: center;
  min-width: 0;
  flex: 1;
  gap: 9px;
  padding: 5px 6px;
  border-radius: var(--radius-sm);
  background: transparent;
  text-align: left;
}

.me:hover {
  background: var(--surface-hover);
}

.avatar {
  position: relative;
  display: block;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(107, 231, 199, .2);
  border-radius: 50%;
  background: linear-gradient(145deg, #24404a, #19303a);
}

.statusDot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 11px;
  height: 11px;
  border: 3px solid var(--ink-925);
  border-radius: 50%;
  background: var(--text-disabled);
}

.statusDot.online {
  background: var(--success);
}

.meName {
  overflow: hidden;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meTag {
  overflow: hidden;
  color: var(--text-tertiary);
  font-size: 10px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meChevron {
  flex: 0 0 auto;
  color: var(--text-tertiary);
}

.meBtns {
  display: flex;
  align-items: center;
  gap: 2px;
}

.iconBtn {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  line-height: 1;
  transition: color .14s ease, background .14s ease, border-color .14s ease, transform .12s ease;
}

.iconBtn:hover {
  border-color: var(--border-subtle);
  background: var(--surface-hover);
  color: var(--text-primary);
}

.iconBtn:active {
  transform: translateY(1px);
}

.iconBtn.active,
.iconBtn[aria-pressed="true"] {
  border-color: rgba(107, 231, 199, .2);
  background: var(--primary-soft);
  color: var(--primary);
}

.iconBtn .iconSlash {
  opacity: 0;
  transition: opacity .12s ease;
}

.iconBtn.active .iconSlash,
.iconBtn[aria-pressed="true"] .iconSlash {
  opacity: 1;
}

.drawerScrim {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  background: rgba(3, 8, 12, .7);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

.spacesScrim {
  z-index: 43;
}

/* Top bar */
.top {
  grid-area: top;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  gap: var(--space-4);
  padding: 0 18px;
  background: var(--surface-content);
  border-bottom: 1px solid var(--border-subtle);
}

.topLeft,
.topRight {
  display: flex;
  align-items: center;
  min-width: 0;
}

.topLeft {
  flex: 1;
  gap: 11px;
}

.topRight {
  flex: 0 1 auto;
  gap: 4px;
}

.channelsToggle {
  display: none;
}

.channelHeading {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.chTitle {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 7px;
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 780;
  white-space: nowrap;
}

.channelGlyph {
  color: var(--primary);
  font-size: 18px;
  font-weight: 650;
}

.topic {
  position: relative;
  overflow: hidden;
  max-width: min(42vw, 520px);
  padding-left: 13px;
  color: var(--text-tertiary);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topic::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 1px;
  height: 18px;
  background: var(--border-default);
  transform: translateY(-50%);
}

.search {
  display: flex;
  align-items: center;
  width: clamp(170px, 19vw, 260px);
  height: 36px;
  gap: 8px;
  margin-right: 5px;
  padding: 0 9px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--surface-input);
  color: var(--text-tertiary);
  transition: border-color .15s ease, background .15s ease;
}

.search:focus-within {
  border-color: rgba(107, 231, 199, .52);
  background: var(--ink-925);
  box-shadow: 0 0 0 3px rgba(107, 231, 199, .09);
}

.search input,
.commandSearch input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text-primary);
}

.search input {
  font-size: 12px;
}

.search input::placeholder,
textarea::placeholder,
input::placeholder {
  color: var(--text-tertiary);
  opacity: 1;
}

input[type="search"]::-webkit-search-cancel-button {
  filter: invert(.8);
}

.unreadIndicator {
  position: absolute;
  right: 7px;
  top: 6px;
  width: 7px;
  height: 7px;
  border: 2px solid var(--surface-content);
  border-radius: 50%;
  background: var(--live);
}

.membersToggle {
  display: none;
}

/* Main chat and meeting */
.chat {
  grid-area: chat;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 18px 22px 0;
  background: var(--surface-content);
}

.messageViewport {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

#chatMessages {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 2px 5px 18px 0;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

.meetingWrap {
  flex: 0 0 auto;
  min-width: 0;
  margin: 0 0 14px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--ink-925);
  box-shadow: var(--shadow-sm);
}

.meetingHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  gap: 14px;
  padding: 11px 12px 11px 14px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-raised);
}

.meetingIdentity {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 11px;
}

.liveBadge {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  min-height: 26px;
  gap: 7px;
  padding: 0 9px;
  border: 1px solid rgba(255, 125, 114, .25);
  border-radius: var(--radius-pill);
  background: var(--live-soft);
  color: #ffaaa3;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.liveDot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warning);
}

.meetingWrap[data-state="joined"] .liveBadge {
  border-color: rgba(255, 125, 114, .25);
  background: var(--live-soft);
  color: #ffaaa3;
}

.meetingWrap[data-state="joined"] .liveDot {
  background: var(--live);
  animation: livePulse 2.2s ease-in-out infinite;
}

.meetingWrap[data-state="connecting"] .liveBadge,
.meetingWrap[data-state="recovering"] .liveBadge {
  border-color: rgba(239, 195, 107, .28);
  background: var(--warning-soft);
  color: #f4d692;
}

.meetingWrap[data-state="error"] .liveBadge {
  border-color: rgba(255, 130, 120, .35);
  background: var(--live-soft);
  color: #ffb3ad;
}

.meetingWrap[data-state="error"] .liveDot {
  background: var(--danger);
}

.meetingTitle {
  overflow: hidden;
  max-width: 28ch;
  margin: 0;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 780;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meetingMeta {
  overflow: hidden;
  max-width: 34ch;
  margin: 1px 0 0;
  color: var(--text-tertiary);
  font-size: 10px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meetingActions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  gap: 6px;
}

.actionBtn,
.button,
.authBtn,
.deviceButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid rgba(107, 231, 199, .2);
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: #c8fff0;
  font-size: 12px;
  font-weight: 720;
  text-decoration: none;
  transition: color .14s ease, background .14s ease, border-color .14s ease, transform .12s ease;
}

.actionBtn:hover,
.button.primary:hover,
.authBtn:hover {
  border-color: rgba(107, 231, 199, .42);
  background: rgba(107, 231, 199, .18);
}

.actionBtn:active,
.button:active,
.authBtn:active,
.deviceButton:active {
  transform: translateY(1px);
}

.actionBtn.ghost,
.button.secondary,
.deviceButton {
  border-color: var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
}

.actionBtn.ghost:hover,
.button.secondary:hover,
.deviceButton:hover {
  border-color: var(--border-default);
  background: var(--surface-hover);
  color: var(--text-primary);
}

.actionBtn.danger,
.button.danger {
  border-color: rgba(255, 125, 114, .24);
  background: var(--live-soft);
  color: #ffb3ad;
}

.actionBtn.danger:hover,
.button.danger:hover {
  border-color: rgba(255, 125, 114, .45);
  background: rgba(255, 125, 114, .2);
}

.button.primary,
.authBtn {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--text-on-primary);
}

.iconAction svg {
  flex: 0 0 auto;
}

.meetingFrame {
  position: relative;
  width: 100%;
  height: clamp(320px, 45vh, 540px);
  min-height: 300px;
  overflow: hidden;
  background: #070c12;
}

.meetingFrame:empty {
  display: grid;
  place-items: center;
}

.meetingFrame:empty::before {
  content: "Подготавливаем защищённое подключение…";
  max-width: 260px;
  padding-top: 38px;
  background: radial-gradient(circle at 50% 8px, var(--primary) 0 3px, transparent 4px);
  color: var(--text-tertiary);
  font-size: 12px;
  text-align: center;
}

.meetingFrame iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.meetingReturn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  gap: 14px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid rgba(107, 231, 199, .22);
  border-radius: var(--radius-md);
  background: linear-gradient(110deg, rgba(107, 231, 199, .1), rgba(101, 204, 232, .06));
  color: var(--text-secondary);
  font-size: 11px;
}

.meetingReturn.hidden {
  display: none;
}

.meetingReturn strong,
.meetingReturn span {
  display: block;
}

.meetingReturn strong {
  margin-bottom: 2px;
  color: var(--text-primary);
  font-size: 12px;
}

.meetingReturnActions {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 4px;
}

.meetingHint {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-height: 300px;
  padding: 24px;
  color: var(--text-secondary);
  text-align: center;
}

.meetingHintCard {
  width: min(520px, 100%);
  padding: 24px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
}

.meetingHintTitle {
  margin: 0;
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 800;
}

.meetingHintText {
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.55;
}

.meetingHintActions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}

/* Messages rendered by app.js */
.dayMarker {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0 18px;
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.dayMarker::before,
.dayMarker::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

.msg {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: start;
  gap: 11px;
  margin: 1px 0;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  transition: background .13s ease, border-color .13s ease;
}

.msg:hover,
.msg:focus-within {
  border-color: rgba(255, 255, 255, .045);
  background: rgba(255, 255, 255, .025);
}

.msg > div:last-child {
  min-width: 0;
}

.msgAv,
.threadAv,
.mAv {
  display: grid;
  place-items: center;
  overflow: hidden;
  flex: 0 0 auto;
  border: 1px solid var(--border-subtle);
  border-radius: 50%;
  background: var(--ink-800);
  color: var(--text-secondary);
  font-weight: 800;
}

.msgAv {
  width: 38px;
  height: 38px;
  font-size: 12px;
}

.msgAvatarImg {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.msgHead,
.threadHead {
  display: flex;
  align-items: baseline;
  min-width: 0;
  gap: 7px;
  flex-wrap: wrap;
}

.msgName,
.threadName {
  color: var(--text-primary);
  font-weight: 760;
}

.msgName {
  font-size: 13px;
}

.roleTag {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 0 6px;
  border: 1px solid rgba(101, 204, 232, .16);
  border-radius: var(--radius-pill);
  background: var(--secondary-soft);
  color: #a8e7f7;
  font-size: 9px;
  font-weight: 820;
}

.msgTime,
.threadTime {
  color: var(--text-tertiary);
  font-size: 10px;
}

.msgBody,
.threadText {
  margin-top: 2px;
  color: #d8e3e5;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.msgBody {
  font-size: 13px;
}

.msg.deliveryPending {
  border-color: rgba(255, 255, 255, .055);
  background: rgba(255, 255, 255, .018);
}

.deliveryStatus {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  min-height: 24px;
  gap: 6px;
  margin-top: 5px;
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 700;
}

.deliveryStatus.failed {
  color: #ffaaa3;
}

.deliveryStatus.queued {
  color: #f4d692;
}

.deliveryIcon {
  width: 7px;
  height: 7px;
  border: 1px solid currentColor;
  border-radius: 50%;
}

.deliveryStatus.sending .deliveryIcon {
  border-top-color: transparent;
  animation: softSpin .8s linear infinite;
}

.deliveryActions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.deliveryAction {
  min-height: 28px;
  padding: 0 7px;
  border-radius: var(--radius-xs);
  background: transparent;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.deliveryAction:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.msgActions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity .12s ease, transform .12s ease;
}

.msg:hover .msgActions,
.msg:focus-within .msgActions {
  opacity: 1;
  transform: translateY(0);
}

.msgActionBtn,
.textButton {
  min-height: 28px;
  padding: 0 7px;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 700;
}

.msgActionBtn:hover,
.textButton:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.msgMeta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 7px;
}

.threadMetaBtn,
.reaction {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  gap: 5px;
  padding: 0 8px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, .035);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 720;
}

.threadMetaBtn:hover,
.reaction:hover {
  border-color: var(--border-default);
  background: var(--surface-hover);
  color: var(--text-primary);
}

.reactionBar {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.reaction.active {
  border-color: rgba(107, 231, 199, .33);
  background: var(--primary-soft);
  color: #c8fff0;
}

.reaction.add {
  min-width: 28px;
  padding: 0 7px;
}

.mention {
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--primary-soft);
  color: #baffed;
  font-weight: 700;
}

.link {
  color: var(--secondary);
  text-decoration: none;
}

.link:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.reactionPicker {
  position: fixed;
  z-index: 1000;
  display: flex;
  gap: 5px;
  padding: 7px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface-overlay);
  box-shadow: var(--shadow-md);
}

.reactionPicker button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 17px;
}

.reactionPicker button:hover {
  border-color: var(--border-subtle);
  background: var(--surface-hover);
}

/* Attachments */
.attachments,
.fileList,
.composerAttachments {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.attachments {
  margin-top: 9px;
}

.imageGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 8px;
}

.imageTile {
  position: relative;
  display: block;
  overflow: hidden;
  width: 100%;
  padding: 0;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--ink-925);
}

.imagePlaceholder {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: var(--space-4);
  color: var(--text-tertiary);
  font-size: 12px;
  text-align: center;
}

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

.attachment,
.attachChip {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  padding: 8px 9px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, .025);
}

.attachThumb,
.attachIcon {
  display: grid;
  place-items: center;
  overflow: hidden;
  flex: 0 0 50px;
  width: 50px;
  height: 50px;
  border-radius: var(--radius-sm);
  background: var(--ink-925);
}

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

.attachInfo,
.attachMeta {
  min-width: 0;
  flex: 1;
}

.attachInfo .attachName,
.attachName {
  display: block;
  overflow: hidden;
  max-width: 100%;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 680;
  text-decoration: none;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachInfo .attachMeta,
.attachSize {
  margin-top: 2px;
  color: var(--text-tertiary);
  font-size: 10px;
}

.attachDownload,
.attachRemove {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  text-decoration: none;
}

.attachDownload:hover,
.attachRemove:hover {
  border-color: var(--border-default);
  background: var(--surface-hover);
  color: var(--text-primary);
}

.composerAttachments {
  margin: 8px 0 4px;
}

.attachPreview {
  display: grid;
  place-items: center;
  overflow: hidden;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--ink-925);
}

.attachPreviewImg {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Composer */
.composer {
  grid-area: composer;
  min-width: 0;
  padding: 10px 22px calc(14px + env(safe-area-inset-bottom));
  background: var(--surface-content);
}

.composeBox {
  display: flex;
  align-items: flex-end;
  min-width: 0;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--surface-input);
  transition: border-color .15s ease, box-shadow .15s ease;
}

.composeBox:focus-within {
  border-color: rgba(107, 231, 199, .34);
  box-shadow: 0 0 0 3px rgba(107, 231, 199, .07);
}

.composeIcons {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 1px;
}

.composerTool {
  width: 34px;
  height: 34px;
}

.gifGlyph {
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .02em;
}

.composeArea {
  flex: 1;
  min-width: 0;
}

textarea {
  width: 100%;
  margin: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text-primary);
  resize: none;
}

#composerInput {
  display: block;
  min-height: 24px;
  max-height: 160px;
  padding: 3px 2px 0;
  font-size: 13px;
  line-height: 1.45;
}

.sendBtn {
  width: 36px;
  height: 36px;
  border-color: rgba(107, 231, 199, .24);
  background: var(--primary-soft);
  color: var(--primary);
}

.sendBtn:hover {
  border-color: rgba(107, 231, 199, .4);
  background: rgba(107, 231, 199, .17);
  color: #a9f8e4;
}

.hint {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  color: var(--text-tertiary);
  font-size: 9px;
}

.hint .kbd {
  min-height: 16px;
  padding: 0 4px;
  margin-right: 3px;
  font-size: 8px;
}

.composerConnectionHint {
  color: #f4d692;
  font-weight: 700;
}

.editNotice {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 5px;
  color: var(--warning);
  font-size: 10px;
}

.editCancelBtn {
  min-height: 26px;
  padding: 0 8px;
  border-radius: var(--radius-xs);
  background: var(--warning-soft);
  color: #f6d590;
  font-size: 10px;
  font-weight: 700;
}

/* Members and threads */
.members {
  grid-area: members;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--surface-sidebar);
  border-left: 1px solid var(--border-subtle);
}

.membersHeader {
  display: flex;
  align-items: center;
  flex: 0 0 var(--top-height);
  padding: 0 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.membersList {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 12px 9px;
}

.roleHeader {
  padding: 12px 8px 6px;
  color: var(--text-tertiary);
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.member {
  display: flex;
  align-items: center;
  min-height: 42px;
  gap: 9px;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: color .14s ease, background .14s ease;
}

.member:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.mAv {
  position: relative;
  width: 30px;
  height: 30px;
  font-size: 10px;
}

.mDot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 10px;
  height: 10px;
  border: 3px solid var(--surface-sidebar);
  border-radius: 50%;
  background: var(--success);
}

.memberName {
  overflow: hidden;
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.threadPanel {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.threadResizer {
  position: absolute;
  left: -8px;
  top: 0;
  bottom: 0;
  z-index: 5;
  width: 16px;
  cursor: col-resize;
}

.threadResizer::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 14px;
  bottom: 14px;
  width: 2px;
  border-radius: var(--radius-pill);
  background: var(--border-subtle);
  transition: background .14s ease;
}

.threadResizer:hover::after,
.threadResizer:focus-visible::after {
  background: var(--primary);
}

.threadHeader,
.panelHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  gap: 12px;
}

.threadHeader {
  flex: 0 0 var(--top-height);
  padding: 0 12px 0 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.threadTitle,
.panelHeader h2 {
  margin: 1px 0 0;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 780;
  line-height: 1.3;
}

.threadRoot {
  flex: 0 0 auto;
  max-height: 34%;
  overflow-y: auto;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, .018);
}

.threadMessages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 12px;
}

.threadMsg {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: start;
  gap: 9px;
  padding: 7px 3px;
}

.threadAv {
  width: 30px;
  height: 30px;
  font-size: 10px;
}

.threadBody {
  min-width: 0;
}

.threadName {
  font-size: 12px;
}

.threadText {
  font-size: 12px;
}

.threadComposer {
  display: flex;
  align-items: flex-end;
  flex: 0 0 auto;
  gap: 7px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border-subtle);
}

.threadComposer textarea {
  min-height: 40px;
  max-height: 150px;
  padding: 9px 10px;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--surface-input);
  font-size: 12px;
  line-height: 1.4;
}

.threadComposer textarea:focus-visible {
  border-color: rgba(107, 231, 199, .45);
}

.threadSend {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(107, 231, 199, .25);
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary);
}

/* Reusable states */
.stateView {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: min(460px, 100%);
  min-height: 240px;
  margin: auto;
  padding: 28px;
  color: var(--text-secondary);
  text-align: center;
}

.stateView.compact {
  min-height: 180px;
  padding: 22px;
}

.stateIcon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 13px;
  border: 1px solid rgba(107, 231, 199, .18);
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 18px;
  font-weight: 850;
}

.stateTitle {
  margin: 0;
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 780;
}

.stateDescription {
  max-width: 42ch;
  margin: 6px 0 0;
  color: var(--text-tertiary);
  font-size: 12px;
}

.stateView.error .stateIcon,
.errorState .stateIcon {
  border-color: rgba(255, 125, 114, .22);
  background: var(--live-soft);
  color: var(--danger);
}

.stateView.loading .stateIcon,
.loadingState .stateIcon {
  animation: softSpin 1.1s linear infinite;
}

.skeleton {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, .055);
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 0 35%, rgba(255, 255, 255, .07) 50%, transparent 65% 100%);
  transform: translateX(-100%);
  animation: skeletonSweep 1.6s ease-in-out infinite;
}

.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.is-loading::after {
  content: "";
  position: absolute;
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  color: var(--primary);
  animation: softSpin .8s linear infinite;
}

/* Panels, menus, status and toasts */
.popoverPanel,
.accountMenu {
  position: fixed;
  z-index: 90;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface-overlay);
  box-shadow: var(--shadow-md);
}

.popoverPanel {
  right: 16px;
  top: calc(var(--top-height) + 8px);
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 32px));
  max-height: min(680px, calc(100dvh - var(--top-height) - 24px));
  overflow: hidden;
}

.popoverPanel .panelHeader {
  padding: 15px 15px 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.panelToolbar {
  display: flex;
  justify-content: flex-end;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.notificationList {
  min-height: 0;
  overflow-y: auto;
}

.accountMenu {
  left: calc(var(--rail-width) + 10px);
  bottom: 76px;
  width: 242px;
  padding: 7px;
}

.accountSummary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 5px;
}

.accountSummary > span:last-child {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.accountSummary strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.accountSummary small {
  color: var(--text-tertiary);
  font-size: 10px;
}

.accountAvatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary-soft);
}

.menuItem {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 650;
  text-align: left;
}

.menuItem:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.menuItem.danger {
  color: #ffaaa3;
}

.networkStatus {
  position: fixed;
  left: 50%;
  top: calc(var(--top-height) + 10px);
  z-index: 120;
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: calc(100vw - 24px);
  min-height: 40px;
  padding: 6px 8px 6px 12px;
  border: 1px solid rgba(239, 195, 107, .25);
  border-radius: var(--radius-pill);
  background: #2b261b;
  box-shadow: var(--shadow-sm);
  color: #f3d99f;
  font-size: 11px;
  transform: translateX(-50%);
}

.networkDot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warning);
}

.networkStatus[data-state="offline"] {
  border-color: rgba(255, 130, 120, .3);
  background: #301f21;
  color: #ffc0ba;
}

.networkStatus[data-state="offline"] .networkDot {
  background: var(--danger);
}

.networkStatus[data-state="degraded"] .networkDot {
  background: var(--warning);
}

.toastRegion {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 130;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  width: min(380px, calc(100vw - 32px));
  gap: 8px;
  pointer-events: none;
}

.toast {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface-overlay);
  box-shadow: var(--shadow-md);
  color: var(--text-primary);
  font-size: 12px;
  pointer-events: auto;
}

.toast.success {
  border-color: rgba(102, 213, 159, .3);
}

.toast.error {
  border-color: rgba(255, 125, 114, .32);
}

/* Modal system */
.modal,
.shadeModal,
.authOverlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modalBackdrop,
.shadeModalBackdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  background: rgba(2, 7, 11, .82);
}

.commandCard,
.onboardingCard,
.formCard,
.prejoinCard,
.shadeModalCard,
.authCard {
  position: relative;
  z-index: 1;
  width: min(100%, 560px);
  max-height: min(760px, calc(100dvh - 40px));
  overflow: auto;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--surface-overlay);
  box-shadow: var(--shadow-lg);
}

.commandCard {
  align-self: start;
  width: min(100%, 660px);
  margin-top: min(12vh, 110px);
  overflow: hidden;
}

.commandSearch {
  display: flex;
  align-items: center;
  min-height: 62px;
  gap: 11px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--primary);
}

.commandSearch input {
  font-size: 16px;
  font-weight: 600;
}

.escapeKey {
  min-width: 40px;
  min-height: 26px;
}

.commandResults {
  max-height: min(440px, 52dvh);
  overflow-y: auto;
  padding: 8px;
}

.commandFooter {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 15px;
  min-height: 38px;
  padding: 0 13px;
  border-top: 1px solid var(--border-subtle);
  color: var(--text-tertiary);
  font-size: 9px;
}

.onboardingCard {
  width: min(100%, 520px);
  padding: 34px;
  text-align: center;
}

.modalClose {
  position: absolute;
  right: 12px;
  top: 12px;
}

.onboardingVisual {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
}

.onboardingCard h2 {
  margin: 6px 0 0;
  font-size: clamp(22px, 4vw, 30px);
  line-height: 1.15;
}

.onboardingCard > p {
  max-width: 46ch;
  margin: 12px auto 0;
  color: var(--text-secondary);
  font-size: 13px;
}

.onboardingChecklist {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  margin: 22px 0;
  padding: 0;
  list-style: none;
}

.onboardingChecklist li {
  padding: 6px 9px;
  border: 1px solid rgba(107, 231, 199, .18);
  border-radius: var(--radius-pill);
  background: var(--primary-soft);
  color: #c8fff0;
  font-size: 10px;
  font-weight: 750;
}

.onboardingActions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.onboardingActions .button {
  min-height: 44px;
}

.formCard,
.prejoinCard {
  padding: 18px;
}

.formCard .panelHeader,
.prejoinCard .panelHeader {
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 14px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 650;
}

.field input,
.field select,
.field textarea,
.shadeModalBody textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  outline: 0;
  background: var(--surface-input);
  color: var(--text-primary);
  font-size: 12px;
}

.field textarea,
.shadeModalBody textarea {
  min-height: 92px;
  resize: vertical;
}

.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible,
.shadeModalBody textarea:focus-visible {
  border-color: rgba(107, 231, 199, .48);
}

.formActions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.formActions .button {
  min-height: 40px;
}

.prejoinCard {
  width: min(100%, 680px);
}

.prejoinCard .panelHeader p {
  margin: 3px 0 0;
  color: var(--text-tertiary);
  font-size: 11px;
}

.prejoinPreview {
  display: grid;
  place-items: center;
  min-height: 300px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: #070c12;
  color: var(--text-tertiary);
}

.prejoinAvatar {
  width: 86px;
  height: 86px;
  border: 1px solid rgba(107, 231, 199, .18);
  border-radius: 50%;
  background: var(--primary-soft);
}

.prejoinPreview p {
  margin: -70px 0 0;
  font-size: 11px;
}

.prejoinControls {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}

.deviceButton[aria-pressed="true"] {
  border-color: rgba(255, 125, 114, .28);
  background: var(--live-soft);
  color: #ffb3ad;
}

/* Shade */
.shadeModalCard {
  display: flex;
  flex-direction: column;
  width: min(760px, 100%);
  overflow: hidden;
}

.shadeModalHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.shadeModalTitle {
  margin: 2px 0 0;
  font-size: 16px;
  line-height: 1.3;
}

.shadeModalSubtitle {
  margin: 3px 0 0;
  color: var(--text-tertiary);
  font-size: 11px;
}

.shadeModalBody {
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 12px;
  overflow-y: auto;
  padding: 16px 18px 20px;
}

.shadeModalBody .field {
  margin: 0;
}

.shadeRow {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.shadeStatus {
  margin-left: auto;
  color: var(--text-tertiary);
  font-size: 11px;
}

.shadeStatus.warn {
  color: var(--warning);
}

.shadeTranscript {
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--surface-input);
  color: var(--text-secondary);
  font-size: 11px;
}

.shadeSettings {
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

.shadeSettings summary {
  width: fit-content;
  padding: 5px 2px;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 680;
}

.shadeSettingsBody {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.shadeLabel {
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 650;
}

/* Authentication */
.authOverlay {
  z-index: 999;
  background: var(--surface-canvas);
}

.authCard {
  width: min(420px, 100%);
  padding: 34px;
  text-align: center;
}

.authCard .brandMark {
  margin: 0 auto 18px;
}

.authTitle {
  margin: 0;
  font-size: 23px;
  line-height: 1.2;
}

.authText {
  margin: 10px 0 20px;
  color: var(--text-secondary);
  font-size: 12px;
}

.authBtn {
  width: 100%;
  min-height: 44px;
}

.authFootnote {
  margin: 13px 0 0;
  color: var(--text-tertiary);
  font-size: 10px;
}

/* Mobile bottom navigation */
.mobileNav {
  display: none;
}

/* Scrollbars */
*::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

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

*::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: var(--radius-pill);
  background: var(--ink-700);
  background-clip: content-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--text-disabled);
  background-clip: content-box;
}

@keyframes livePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 125, 114, 0); opacity: .78; }
  50% { box-shadow: 0 0 0 4px rgba(255, 125, 114, .12); opacity: 1; }
}

@keyframes softSpin {
  to { transform: rotate(360deg); }
}

@keyframes skeletonSweep {
  to { transform: translateX(100%); }
}

/* Compact desktop / tablet: context becomes a functional drawer. */
@media (max-width: 1199px) {
  .app {
    grid-template-columns: var(--rail-width) var(--sidebar-width) minmax(0, 1fr);
    grid-template-areas:
      "servers channels top"
      "servers channels chat"
      "servers channels composer";
  }

  .members {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 70;
    width: min(420px, calc(100vw - var(--rail-width)));
    border-left-color: var(--border-default);
    box-shadow: var(--shadow-lg);
    transform: translateX(104%);
    visibility: hidden;
    pointer-events: none;
    transition: transform .22s ease, visibility 0s linear .22s;
  }

  body.thread-open .members,
  body.members-open .members {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
    transition-delay: 0s;
  }

  .membersToggle {
    display: inline-grid;
  }

  .threadResizer {
    display: none;
  }

  .topic {
    max-width: 28vw;
  }

  .secondaryMeetingAction {
    display: none;
  }
}

/* Tablet: channel sidebar becomes an off-canvas drawer. */
@media (max-width: 900px) {
  .app {
    grid-template-columns: var(--rail-width) minmax(0, 1fr);
    grid-template-areas:
      "servers top"
      "servers chat"
      "servers composer";
  }

  .channels {
    position: fixed;
    left: var(--rail-width);
    top: 0;
    bottom: 0;
    z-index: 60;
    width: min(330px, calc(100vw - var(--rail-width)));
    border-right-color: var(--border-default);
    box-shadow: var(--shadow-lg);
    transform: translateX(calc(-100% - var(--rail-width)));
    visibility: hidden;
    transition: transform .22s ease, visibility 0s linear .22s;
  }

  body.channels-open .channels {
    transform: translateX(0);
    visibility: visible;
    transition-delay: 0s;
  }

  body.channels-open .channelsScrim {
    opacity: 1;
    pointer-events: auto;
  }

  .channelsToggle {
    display: inline-grid;
  }

  .topic {
    display: none;
  }

  .search {
    width: clamp(150px, 27vw, 220px);
  }

  .topAction:not(.membersToggle) {
    display: none;
  }

  .chat {
    padding-inline: 17px;
  }

  .composer {
    padding-inline: 17px;
  }

  .meetingHeader {
    align-items: flex-start;
  }

  .meetingActions {
    flex-wrap: wrap;
  }

  .meetingActions .iconAction span {
    display: none;
  }

  .meetingActions .actionBtn {
    width: 38px;
    padding: 0;
  }
}

/* Mobile: full-width content, both side areas become drawers, bottom navigation appears. */
@media (max-width: 700px) {
  :root {
    --top-height: 56px;
  }

  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: calc(var(--top-height) + env(safe-area-inset-top)) minmax(0, 1fr) auto;
    grid-template-areas:
      "top"
      "chat"
      "composer";
  }

  .servers {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 80;
    width: 82px;
    border-right-color: var(--border-default);
    box-shadow: var(--shadow-lg);
    transform: translateX(-106%);
    visibility: hidden;
    transition: transform .22s ease, visibility 0s linear .22s;
    padding-top: calc(10px + env(safe-area-inset-top));
    padding-left: calc(8px + env(safe-area-inset-left));
  }

  body.spaces-open .servers {
    transform: translateX(0);
    visibility: visible;
    transition-delay: 0s;
  }

  body.spaces-open .spacesScrim {
    opacity: 1;
    pointer-events: auto;
  }

  .channels {
    left: 0;
    width: min(330px, 88vw);
    transform: translateX(-104%);
  }

  .top {
    padding: env(safe-area-inset-top) max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
  }

  .top .iconBtn {
    width: 44px;
    height: 44px;
  }

  .topLeft {
    gap: 7px;
  }

  .channelHeading {
    gap: 0;
  }

  .chTitle {
    max-width: 46vw;
    font-size: 14px;
  }

  .search,
  .membersToggle {
    display: none;
  }

  .chat {
    padding: 12px 10px 0;
  }

  .composer {
    padding: 8px max(10px, env(safe-area-inset-right)) calc(var(--mobile-nav-height) + 8px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }

  .composeBox {
    gap: 5px;
    padding: 7px;
  }

  .optionalComposerTool,
  .hint {
    display: none;
  }

  .composerTool,
  .sendBtn {
    width: 44px;
    height: 44px;
  }

  #composerInput {
    min-height: 32px;
    padding-top: 7px;
    font-size: 14px;
  }

  .msg {
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 9px;
    padding: 8px 5px;
  }

  .msgAv {
    width: 34px;
    height: 34px;
  }

  .msgActions {
    opacity: 1;
    transform: none;
  }

  .msgActionBtn {
    min-width: 44px;
    min-height: 44px;
  }

  .meetingWrap {
    margin-inline: -10px;
    border-inline: 0;
    border-radius: 0;
  }

  .meetingHeader {
    align-items: flex-start;
    padding: 10px;
  }

  .liveBadge {
    display: none;
  }

  .meetingTitle {
    max-width: 38vw;
  }

  .meetingActions {
    gap: 4px;
  }

  .meetingActions .actionBtn {
    width: 44px;
    min-height: 44px;
  }

  .meetingFrame {
    height: clamp(300px, 52dvh, 520px);
  }

  .members {
    width: min(100%, 420px);
  }

  .mobileNav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 55;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    height: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom));
    padding: 5px max(5px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(5px, env(safe-area-inset-left));
    border-top: 1px solid var(--border-default);
    background: var(--ink-925);
  }

  .mobileNavItem {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 56px;
    gap: 3px;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-tertiary);
    font-size: 8px;
    font-weight: 700;
  }

  .mobileNavItem:hover,
  .mobileNavItem.active {
    background: var(--surface-hover);
    color: var(--primary);
  }

  .mobileNavItem.mobileCreate svg {
    width: 36px;
    height: 36px;
    padding: 8px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--text-on-primary);
  }

  .popoverPanel {
    left: 8px;
    right: 8px;
    top: calc(var(--top-height) + 6px);
    width: auto;
    max-height: calc(100dvh - var(--top-height) - var(--mobile-nav-height) - 20px);
  }

  .accountMenu {
    left: 8px;
    right: 8px;
    bottom: calc(var(--mobile-nav-height) + 8px + env(safe-area-inset-bottom));
    width: auto;
  }

  .toastRegion {
    left: 10px;
    right: 10px;
    bottom: calc(var(--mobile-nav-height) + 10px + env(safe-area-inset-bottom));
    width: auto;
  }

  .modal,
  .shadeModal,
  .authOverlay {
    align-items: end;
    padding: 0;
  }

  .commandCard,
  .onboardingCard,
  .formCard,
  .prejoinCard,
  .shadeModalCard,
  .authCard {
    width: 100%;
    max-height: calc(100dvh - 14px);
    border-width: 1px 0 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .commandCard {
    align-self: end;
    margin: 0;
  }

  .onboardingCard,
  .authCard {
    padding: 28px 22px calc(24px + env(safe-area-inset-bottom));
  }

  .formCard,
  .prejoinCard {
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }

  .prejoinPreview {
    min-height: 240px;
  }

  .prejoinControls {
    flex-wrap: wrap;
  }

  .deviceButton {
    min-height: 44px;
  }

  .shadeModalBody {
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }

  .networkStatus {
    top: calc(var(--top-height) + 8px + env(safe-area-inset-top));
    width: calc(100vw - 16px - env(safe-area-inset-left) - env(safe-area-inset-right));
    border-radius: var(--radius-md);
  }

  body.keyboard-open .mobileNav {
    display: none;
  }

  body.keyboard-open .composer {
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }

  .meetingReturn {
    align-items: flex-start;
    margin-inline: 2px;
  }
}

@media (max-width: 420px) {
  .channelGlyph {
    display: none;
  }

  .chTitle {
    max-width: 44vw;
  }

  .meetingTitle {
    max-width: 32vw;
  }

  .msgHead {
    gap: 5px;
  }

  .roleTag {
    display: none;
  }

  .formActions {
    flex-direction: column-reverse;
  }

  .formActions .button {
    width: 100%;
    min-height: 44px;
  }
}

/* Full-screen call enhancement on small screens. */
@media (max-width: 700px) {
  body:has(.meetingWrap:not(.hidden)) .mobileNav {
    display: none;
  }

  body:has(.meetingWrap:not(.hidden)) .composer {
    display: none;
  }

  body:has(.meetingWrap:not(.hidden)) .chat {
    padding: 0;
  }

  body:has(.meetingWrap:not(.hidden)) .meetingWrap {
    display: flex;
    flex-direction: column;
    height: 100%;
    margin: 0;
    border: 0;
  }

  body:has(.meetingWrap:not(.hidden)) .meetingFrame {
    flex: 1;
    height: auto;
    min-height: 0;
  }

  body:has(.meetingWrap:not(.hidden)) .messageViewport {
    display: none;
  }
}

@media (hover: none) {
  .msgActions {
    opacity: 1;
    transform: none;
  }
}

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

@media (forced-colors: active) {
  .statusDot,
  .liveDot,
  .networkDot,
  .unreadIndicator {
    forced-color-adjust: none;
    border: 1px solid CanvasText;
  }

  .pill.active,
  .chan.active,
  .reaction.active {
    outline: 2px solid Highlight;
  }
}

@supports (-webkit-touch-callout: none) {
  body,
  .app {
    min-height: -webkit-fill-available;
  }
}