/* Drop 8: phone layout in the style of the Discord mobile app. Only applies on narrow screens; desktop is untouched. */
@media (max-width: 760px) {
  /* The chat header is the top bar (no extra bar above it). Repositories keeps its small tab bar so you can get back. */
  #app:has(#track[data-tab="messaging"]) .topbar { display: none; }
  #app { height: var(--vvh, 100dvh); }

  /* Left drawer: server list + channel list side by side, chat peeking on the right */
  .drawer { width: min(344px, 88%); background: var(--c-darkest); box-shadow: none; transition: transform .28s cubic-bezier(.2, .8, .2, 1), box-shadow .28s; padding-top: env(safe-area-inset-top); }
  .pane.sidebar-open .drawer { box-shadow: 8px 0 32px rgba(0, 0, 0, .55); }
  .scrim { background: rgba(0, 0, 0, .6); }
  .rail { width: 64px; padding: 10px 0 calc(10px + env(safe-area-inset-bottom)); }
  .rail-btn { width: 48px; height: 48px; }
  .sidebar { border-top-left-radius: 20px; background: var(--c-side); }
  .server-head { height: 56px; font-size: 17px; border-top-left-radius: 20px; }
  .side-scroll { padding: 8px 8px 12px; }
  .nav-item { min-height: 44px; font-size: 16px; border-radius: 8px; padding: 0 10px; }
  .nav-item .hash { font-size: 20px; }
  .side-label, .cat-toggle { font-size: 13px; }

  /* "Repositories" shortcut above your profile, since the top tab bar is gone in chat */
  .m-repo { display: flex; align-items: center; gap: 10px; margin: 0 8px 4px; padding: 10px 12px; border-radius: 8px; color: var(--c-muted); font-size: 15px; font-weight: 600; text-align: left; }
  .m-repo:hover, .m-repo:active { background: var(--c-hover); color: var(--c-strong); }

  .userpanel { padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: var(--c-darkest); border-radius: 12px 12px 0 0; }

  /* Chat header like Discord mobile: back arrow, channel name, action icons */
  .chat-head { height: calc(52px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 8px 0 4px; gap: 2px; background: var(--c-chat); box-shadow: 0 1px 0 rgba(0, 0, 0, .25); }
  .chat-head .icon-btn, .chat-head .icon-action { width: 44px; height: 44px; display: grid; place-items: center; }
  .chat-title { font-size: 17px; align-items: center; }
  .conn { display: none; }
  .chat-head [hidden] { display: none !important; } /* the 44px button rule above must not show hidden buttons */

  /* Composer: round "+" button, pill input, round send button */
  .composer { gap: 8px; padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); background: var(--c-chat); align-items: flex-end; }
  .composer .attach-btn { order: -1; flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--c-btn2); color: var(--c-strong); display: grid; place-items: center; }
  .composer textarea { border-radius: 22px; padding: 10px 16px; max-height: 120px; min-height: 40px; }
  .composer .send { flex: none; width: 40px; height: 40px; min-height: 40px; padding: 0; border-radius: 50%; font-size: 0; background: var(--c-accent); position: relative; }
  .composer .send::after { content: "\27A4"; font-size: 17px; color: #fff; position: absolute; inset: 0; display: grid; place-items: center; }
  .composer .send:disabled { background: var(--c-btn2); opacity: 1; }
  .composer .send:disabled::after { color: var(--c-muted2); }

  /* Messages: roomier avatars, always-visible action buttons */
  .msg { padding: 3px 12px; }
  .avatar { width: 40px; height: 40px; }
  .msg { grid-template-columns: 40px minmax(0, 1fr); }

  /* Member list slides in from the right (swipe left, or tap the people icon) */
  .members:not([hidden]) {
    display: block; position: absolute; z-index: 40; top: 0; right: 0; bottom: 0; width: min(320px, 86%);
    padding-top: calc(8px + env(safe-area-inset-top)); border-radius: 16px 0 0 16px; border-left: 0;
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .55); animation: m-slide .22s cubic-bezier(.2, .8, .2, 1);
  }
  .mp-row { min-height: 48px; }

  /* Pop-ups become bottom sheets */
  .sf-bg { align-items: end; }
  .mcard { max-width: calc(100vw - 24px); }
  .fs-close { top: calc(10px + env(safe-area-inset-top)); }

  /* What's New button sits above the composer, away from the send button */
  .wn-btn, #whatsNewBtn { bottom: calc(76px + env(safe-area-inset-bottom)); }
}
@keyframes m-slide { from { transform: translateX(100%); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .members:not([hidden]) { animation: none; } .drawer { transition: none; } }
@media (max-width: 760px) {
  #messages .msg .actions { opacity: 0; pointer-events: none; }
  #messages .msg.m-open .actions { opacity: 1; pointer-events: auto; transform: none; }
}
