/* ==========================================================================
   MinChat Modern Interface Style Layer (HQ #389, #388, #390)
   Visual direction:
   - Graphite, charcoal, milk, and neutral gray surfaces
   - Restrained expressive accent for key actions and selected states
   - Narrow global navigation rail -> chat list -> conversation stage on wide screen
   - Single main screen at a time on mobile with unambiguous back navigation
   - Exact typography, thin dividers, soft shadows, delicate depth
   - Contrast ratio >= 4.5:1 for body copy
   ========================================================================== */

/* 1. Surfaces & Color Palette for Modern */
:root {
  --modern-rail-width: 68px;
  --modern-list-width: 320px;
  --modern-divider-width: 1px;
}

/* Dark Theme Surfaces (Graphite & Charcoal) */
.theme-dark,
[data-theme="dark"],
.modern-workspace:not(.theme-light) {
  --modern-bg-rail: #090b0e;
  --modern-bg-list: #11141a;
  --modern-bg-stage: #0c0e12;
  --modern-bg-card: #151921;
  --modern-bg-card-hover: #1c222c;
  --modern-bg-card-selected: #222936;
  --modern-bg-input: #151922;
  --modern-bg-input-focus: #1a202b;
  
  --modern-border: rgba(255, 255, 255, 0.08);
  --modern-border-subtle: rgba(255, 255, 255, 0.05);
  --modern-border-focus: rgba(128, 107, 255, 0.5);

  --modern-text-primary: #f3f5f9;
  --modern-text-secondary: #a2adb9;
  --modern-text-muted: #6f7a88;
  --modern-text-inverse: #ffffff;

  --modern-bubble-in: #181d26;
  --modern-bubble-in-border: rgba(255, 255, 255, 0.07);
  --modern-bubble-in-text: #f0f2f7;

  --modern-bubble-out: #2b2554;
  --modern-bubble-out-border: rgba(128, 107, 255, 0.35);
  --modern-bubble-out-text: #ffffff;

  --modern-accent: #7358f0;
  --modern-accent-hover: #866df5;
  --modern-accent-soft: rgba(115, 88, 240, 0.16);

  --modern-shadow-card: 0 2px 8px rgba(0, 0, 0, 0.25);
  --modern-shadow-float: 0 8px 24px rgba(0, 0, 0, 0.35);
}

/* Light Theme Surfaces (Milk & Neutral Gray) */
.theme-light,
[data-theme="light"],
.modern-workspace.theme-light {
  --modern-bg-rail: #eaedf2;
  --modern-bg-list: #ffffff;
  --modern-bg-stage: #f6f8fb;
  --modern-bg-card: #ffffff;
  --modern-bg-card-hover: #f1f4f9;
  --modern-bg-card-selected: #e9ebf8;
  --modern-bg-input: #edf1f7;
  --modern-bg-input-focus: #ffffff;

  --modern-border: rgba(0, 0, 0, 0.08);
  --modern-border-subtle: rgba(0, 0, 0, 0.04);
  --modern-border-focus: rgba(99, 84, 224, 0.5);

  --modern-text-primary: #12161f;
  --modern-text-secondary: #4a5568;
  --modern-text-muted: #718096;
  --modern-text-inverse: #ffffff;

  --modern-bubble-in: #ffffff;
  --modern-bubble-in-border: rgba(0, 0, 0, 0.08);
  --modern-bubble-in-text: #171d26;

  --modern-bubble-out: #6354e0;
  --modern-bubble-out-border: transparent;
  --modern-bubble-out-text: #ffffff;

  --modern-accent: #6354e0;
  --modern-accent-hover: #5243cb;
  --modern-accent-soft: rgba(99, 84, 224, 0.12);

  --modern-shadow-card: 0 1px 3px rgba(0, 0, 0, 0.05);
  --modern-shadow-float: 0 8px 24px rgba(0, 0, 0, 0.10);
}

/* 2. Main Container & 3-Column Geometry */
.modern-app-shell {
  display: flex;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background: var(--modern-bg-stage);
  color: var(--modern-text-primary);
  font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, "Golos Text", Roboto, sans-serif);
  overflow: hidden;
  position: relative;
}

/* 2.1 Column 1: Narrow Global Navigation Rail */
.modern-rail {
  width: var(--modern-rail-width);
  min-width: var(--modern-rail-width);
  max-width: var(--modern-rail-width);
  height: 100%;
  background: var(--modern-bg-rail);
  border-right: 1px solid var(--modern-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  box-sizing: border-box;
  flex-shrink: 0;
  z-index: 50;
  user-select: none;
}

.modern-rail-brand {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--gradient-accent, linear-gradient(135deg, #806bff 0%, #a876ff 100%));
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 19px;
  margin-bottom: 24px;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(115, 88, 240, 0.3);
  transition: transform var(--duration-fast, 140ms) ease;
}

.modern-rail-brand:hover {
  transform: scale(1.05);
}

.modern-rail-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 0 10px;
  box-sizing: border-box;
}

.modern-rail-item {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--modern-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--duration-fast, 140ms) var(--ease-standard, ease);
  text-decoration: none;
}

.modern-rail-item:hover {
  background: var(--modern-bg-card-hover);
  color: var(--modern-text-primary);
}

.modern-rail-item.is-active,
.modern-rail-item[aria-current="page"] {
  background: var(--modern-accent-soft);
  color: var(--modern-accent);
  border-color: rgba(115, 88, 240, 0.25);
}

.modern-rail-item.is-active::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 14px;
  bottom: 14px;
  width: 3px;
  border-radius: 0 4px 4px 0;
  background: var(--modern-accent);
}

.modern-rail-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--modern-accent);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px var(--modern-bg-rail);
}

.modern-rail-badge--activity {
  background: var(--color-activity, #52d9d3);
  color: #080b10;
}

.modern-rail-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.modern-rail-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--modern-bg-card);
  border: 1px solid var(--modern-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--modern-text-primary);
  cursor: pointer;
  overflow: hidden;
  transition: border-color var(--duration-fast, 140ms) ease;
}

.modern-rail-avatar:hover {
  border-color: var(--modern-accent);
}

.modern-rail-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 2.2 Column 2: Chat List Panel */
.modern-chatlist-panel {
  width: var(--modern-list-width);
  min-width: var(--modern-list-width);
  max-width: var(--modern-list-width);
  height: 100%;
  background: var(--modern-bg-list);
  border-right: 1px solid var(--modern-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  box-sizing: border-box;
  overflow: hidden;
}

.modern-chatlist-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--modern-border-subtle);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modern-chatlist-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modern-chatlist-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--modern-text-primary);
  margin: 0;
}

.modern-chatlist-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.modern-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--modern-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--duration-fast, 140ms) ease;
}

.modern-icon-btn:hover {
  background: var(--modern-bg-card-hover);
  color: var(--modern-text-primary);
  border-color: var(--modern-border);
}

.modern-icon-btn:focus-visible {
  outline: 2px solid var(--modern-accent);
  outline-offset: 1px;
}

/* Search Bar */
.modern-search-bar {
  position: relative;
  width: 100%;
}

.modern-search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--modern-text-muted);
  pointer-events: none;
}

.modern-search-input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 34px;
  box-sizing: border-box;
  border-radius: 8px;
  border: 1px solid var(--modern-border);
  background: var(--modern-bg-input);
  color: var(--modern-text-primary);
  font-size: 13px;
  font-family: inherit;
  transition: all var(--duration-fast, 140ms) ease;
}

.modern-search-input:focus {
  outline: none;
  background: var(--modern-bg-input-focus);
  border-color: var(--modern-border-focus);
  box-shadow: 0 0 0 3px var(--modern-accent-soft);
}

.modern-search-input::placeholder {
  color: var(--modern-text-muted);
}

/* Filter Pills */
.modern-filter-pills {
  display: flex;
  gap: 6px;
  padding: 0 16px 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.modern-filter-pills::-webkit-scrollbar {
  display: none;
}

.modern-filter-pill {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: var(--modern-bg-card);
  color: var(--modern-text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--duration-fast, 140ms) ease;
}

.modern-filter-pill:hover {
  background: var(--modern-bg-card-hover);
  color: var(--modern-text-primary);
}

.modern-filter-pill.is-active {
  background: var(--modern-accent-soft);
  color: var(--modern-accent);
  border-color: rgba(115, 88, 240, 0.2);
  font-weight: 600;
}

/* Chat List Scroll Container */
.modern-chatlist-items {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Chat Item Card */
.modern-chat-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  text-align: left;
  user-select: none;
  transition: background-color var(--duration-fast, 140ms) ease, border-color var(--duration-fast, 140ms) ease;
  width: 100%;
  box-sizing: border-box;
}

.modern-chat-card:hover {
  background: var(--modern-bg-card-hover);
}

.modern-chat-card.is-selected {
  background: var(--modern-bg-card-selected);
  border-color: var(--modern-border);
}

.modern-chat-card:focus-visible {
  outline: 2px solid var(--modern-accent);
  outline-offset: -1px;
}

.modern-chat-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.modern-chat-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--modern-bg-card);
  border: 1px solid var(--modern-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: var(--modern-text-primary);
  overflow: hidden;
}

.modern-chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modern-presence-dot {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--modern-bg-list);
  background: var(--color-success, #52c788);
}

.modern-presence-dot.is-dnd {
  background: var(--color-danger, #ff6b6b);
}

.modern-presence-dot.is-offline {
  background: var(--modern-text-muted);
}

.modern-chat-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.modern-chat-meta-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.modern-chat-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--modern-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.modern-chat-time {
  font-size: 11px;
  font-family: var(--font-mono, monospace);
  font-variant-numeric: tabular-nums;
  color: var(--modern-text-muted);
  flex-shrink: 0;
}

.modern-chat-meta-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.modern-chat-snippet {
  font-size: 13px;
  color: var(--modern-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.35;
  flex: 1;
}

.modern-chat-card.is-selected .modern-chat-snippet {
  color: var(--modern-text-primary);
}

.modern-chat-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--modern-accent);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.modern-chat-badge--muted {
  background: var(--modern-bg-card-hover);
  color: var(--modern-text-muted);
  border: 1px solid var(--modern-border);
}

.modern-chat-muted-icon {
  color: var(--modern-text-muted);
  font-size: 12px;
  flex-shrink: 0;
}

/* 2.3 Column 3: Conversation Stage */
.modern-conversation-stage {
  flex: 1;
  min-width: 0;
  height: 100%;
  background: var(--modern-bg-stage);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* Stage Header */
.modern-stage-header {
  height: 64px;
  padding: 0 20px;
  border-bottom: 1px solid var(--modern-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--modern-bg-stage);
  flex-shrink: 0;
  z-index: 20;
}

.modern-stage-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.modern-back-btn {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--modern-border);
  background: var(--modern-bg-card);
  color: var(--modern-text-primary);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.modern-stage-peer-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--modern-bg-card);
  border: 1px solid var(--modern-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
  overflow: hidden;
}

.modern-stage-peer-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modern-stage-peer-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.modern-stage-peer-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--modern-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.modern-stage-peer-status {
  font-size: 12px;
  color: var(--modern-text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.modern-stage-peer-status.is-online {
  color: var(--color-success, #52c788);
}

.modern-stage-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Disconnected Banner */
.modern-offline-banner {
  display: none;
  background: rgba(255, 107, 107, 0.12);
  border-bottom: 1px solid rgba(255, 107, 107, 0.25);
  color: var(--color-danger, #ff6b6b);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.modern-offline-banner.is-active {
  display: flex;
}

/* Messages Scroll Container */
.modern-messages-flow {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modern-date-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 12px 0;
  position: relative;
}

.modern-date-divider span {
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--modern-bg-card);
  border: 1px solid var(--modern-border);
  color: var(--modern-text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Message Bubble */
.modern-msg-row {
  display: flex;
  gap: 10px;
  max-width: 78%;
  align-self: flex-start;
  animation: modernMessageIn 160ms ease-out both;
}

@keyframes modernMessageIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.modern-msg-row.is-own {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.modern-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--modern-bg-card);
  border: 1px solid var(--modern-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
  overflow: hidden;
}

.modern-msg-bubble {
  position: relative;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--modern-bubble-in);
  border: 1px solid var(--modern-bubble-in-border);
  color: var(--modern-bubble-in-text);
  box-shadow: var(--modern-shadow-card);
  word-break: break-word;
  line-height: 1.5;
  font-size: 14px;
}

.modern-msg-row.is-own .modern-msg-bubble {
  background: var(--modern-bubble-out);
  border-color: var(--modern-bubble-out-border);
  color: var(--modern-bubble-out-text);
  border-bottom-right-radius: 4px;
}

.modern-msg-row:not(.is-own) .modern-msg-bubble {
  border-bottom-left-radius: 4px;
}

.modern-msg-author {
  font-size: 12px;
  font-weight: 700;
  color: var(--modern-accent);
  margin-bottom: 4px;
}

.modern-msg-text {
  font-size: 14px;
  line-height: 1.5;
}

.modern-msg-text p {
  margin: 0 0 6px;
}

.modern-msg-text p:last-child {
  margin-bottom: 0;
}

/* Reply Block */
.modern-reply-quote {
  padding: 6px 10px;
  margin-bottom: 8px;
  border-left: 3px solid var(--modern-accent);
  background: rgba(0, 0, 0, 0.15);
  border-radius: 0 6px 6px 0;
  font-size: 12px;
  color: var(--modern-text-secondary);
}

.modern-reply-author {
  font-weight: 700;
  color: var(--modern-text-primary);
  margin-bottom: 2px;
}

/* Message Meta & Status */
.modern-msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 4px;
  font-size: 11px;
  font-family: var(--font-mono, monospace);
  font-variant-numeric: tabular-nums;
  color: var(--modern-text-muted);
}

.modern-msg-row.is-own .modern-msg-meta {
  color: rgba(255, 255, 255, 0.7);
}

.modern-msg-status {
  display: inline-flex;
  font-size: 12px;
}

/* 2.4 Composer Section */
.modern-composer-box {
  padding: 12px 20px 16px;
  background: var(--modern-bg-stage);
  border-top: 1px solid var(--modern-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

/* Reply preview in composer */
.modern-composer-reply-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--modern-bg-card);
  border-left: 3px solid var(--modern-accent);
  font-size: 12px;
}

.modern-composer-reply-bar.is-active {
  display: flex;
}

.modern-composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--modern-bg-input);
  border: 1px solid var(--modern-border);
  border-radius: 12px;
  padding: 6px 10px;
  transition: all var(--duration-fast, 140ms) ease;
}

.modern-composer-row:focus-within {
  background: var(--modern-bg-input-focus);
  border-color: var(--modern-border-focus);
  box-shadow: 0 0 0 3px var(--modern-accent-soft);
}

.modern-composer-textarea {
  flex: 1;
  min-height: 24px;
  max-height: 140px;
  border: none;
  background: transparent;
  color: var(--modern-text-primary);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.45;
  resize: none;
  padding: 6px 4px;
  outline: none;
}

.modern-composer-textarea::placeholder {
  color: var(--modern-text-muted);
}

.modern-composer-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.modern-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: var(--modern-accent);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color var(--duration-fast, 140ms) ease, transform 100ms ease;
}

.modern-send-btn:hover {
  background: var(--modern-accent-hover);
}

.modern-send-btn:active {
  transform: scale(0.95);
}

.modern-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* 3. Empty & Skeleton States */
.modern-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 32px 24px;
  color: var(--modern-text-muted);
}

.modern-empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--modern-bg-card);
  border: 1px solid var(--modern-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--modern-accent);
  margin-bottom: 16px;
}

.modern-empty-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--modern-text-primary);
  margin: 0 0 6px;
}

.modern-empty-desc {
  font-size: 13px;
  color: var(--modern-text-secondary);
  max-width: 36ch;
  margin: 0;
  line-height: 1.5;
}

/* 4. Responsive Viewport Adaptations */
@media (max-width: 768px) {
  .modern-rail {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    min-width: 100%;
    max-width: 100%;
    height: 56px;
    border-right: none;
    border-top: 1px solid var(--modern-border);
    flex-direction: row;
    justify-content: space-around;
    padding: 0 12px;
    z-index: 100;
  }

  .modern-rail-brand,
  .modern-rail-bottom {
    display: none;
  }

  .modern-rail-nav {
    flex-direction: row;
    justify-content: space-around;
    padding: 0;
  }

  .modern-rail-item {
    width: 44px;
    height: 44px;
  }

  .modern-rail-item.is-active::before {
    left: 12px;
    right: 12px;
    top: auto;
    bottom: -2px;
    width: auto;
    height: 3px;
    border-radius: 4px 4px 0 0;
  }

  .modern-chatlist-panel {
    width: 100%;
    min-width: 100%;
    max-width: 100%;
    height: calc(100% - 56px);
  }

  /* One main screen at a time on mobile */
  .modern-app-shell:not(.has-active-chat) .modern-conversation-stage {
    display: none;
  }

  .modern-app-shell.has-active-chat .modern-chatlist-panel,
  .modern-app-shell.has-active-chat .modern-rail {
    display: none;
  }

  .modern-app-shell.has-active-chat .modern-conversation-stage {
    display: flex;
    width: 100%;
    height: 100%;
  }

  .modern-back-btn {
    display: flex;
  }

  .modern-messages-flow {
    padding: 16px 14px;
  }

  .modern-composer-box {
    padding: 10px 14px 14px;
  }
}

/* 5. Reduced Motion & Accessibility */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
