/* phone screens: one column, servers + channels slide in from the left, people from the right */
#nav-btn, #nav-scrim { display: none; }
body.web #titlebar { display: none; }
body.web #app { height: 100%; }

@media (max-width: 760px) {
  html, body { overscroll-behavior: none; }
  /* sideways swipes are ours, not the browser's back gesture */
  #app, #messages, #channels, #rail, #members, #sidebar, .set-pane { touch-action: pan-y; overscroll-behavior: contain; }
  #app pre { touch-action: pan-x pan-y; }
  body.web { height: 100dvh; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
  #app { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 0; }
  [data-look=float] #app, [data-look=glass] #app { gap: 0; padding: 0; }
  [data-look] #chat { border-radius: 0; box-shadow: none; grid-column: 1; grid-row: 1; min-width: 0; }

  #nav-btn { display: grid; place-items: center; position: relative; flex: none; width: 40px; height: 40px; margin-left: -10px; border-radius: 10px; color: var(--text-2); }
  #nav-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
  #nav-btn i { position: absolute; right: 2px; top: 3px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--danger); color: #fff; font: 700 10px/16px var(--font); text-align: center; }
  #nav-btn i:empty { display: none; }

  #rail, #sidebar, #members { position: fixed; z-index: 35; top: env(safe-area-inset-top); bottom: env(safe-area-inset-bottom); transition: transform .24s var(--ease), visibility .24s; visibility: hidden; }
  body:not(.web) #rail, body:not(.web) #sidebar, body:not(.web) #members { top: 32px; }
  #rail { left: 0; width: 68px; transform: translateX(-340px); background: var(--bg-0) !important; }
  [data-look] #sidebar { left: 68px; width: min(300px, calc(100vw - 112px)); transform: translateX(-400px); border-radius: 0 16px 16px 0; background: var(--bg-2); backdrop-filter: none; }
  [data-look] #members, #members.hide { right: 0; width: min(290px, 82vw); padding: 16px 8px; overflow-y: auto; transform: translateX(310px); border-radius: 16px 0 0 16px; background: var(--bg-2); backdrop-filter: none; }
  .nav-open #rail, .nav-open #sidebar, .mem-open #members { transform: none !important; visibility: visible; }
  #nav-scrim { display: block; position: fixed; inset: 0; z-index: 34; background: #000a; opacity: 0; pointer-events: none; transition: opacity .24s; }
  .nav-open #nav-scrim, .mem-open #nav-scrim { opacity: 1; pointer-events: auto; }

  #chat-head { height: 54px; padding: 0 8px 0 14px; gap: 6px; }
  #chat-title { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #chat-head .divider, #chat-topic, .head-tools .search, #btn-mute, #btn-readall { display: none; }
  .head-tools { gap: 0; }
  .head-tools .icon-btn { width: 40px; height: 40px; }
  #stage { inset: 54px 0 0; }
  #side { top: 60px; max-height: calc(100% - 130px); }

  .ch { min-height: 44px; }
  .cat { min-height: 40px; }
  #me { margin-bottom: 4px; }
  #me .icon-btn { width: 40px; height: 40px; }
  #input { font-size: 16px; }
  input, select, textarea { font-size: 16px !important; }
  .msg { padding-left: 12px; padding-right: 12px; }
  .msg .tools { display: none; }
  .msg { -webkit-touch-callout: none; }
  #messages { -webkit-user-select: none; user-select: none; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
  #composer-wrap { padding-left: 8px; padding-right: 8px; }
  #composer .icon-btn, #send { width: 40px; height: 40px; }
  #emoji-pop, .emoji-pop { max-width: calc(100vw - 16px); left: 8px !important; right: 8px; }
  #menu { min-width: 230px; }
  #menu button { height: 44px; font-size: 15px; }
  #toast { max-width: calc(100vw - 32px); }
  #profile { max-width: calc(100vw - 24px); }

  #modal { inset: 0; place-items: end stretch; }
  .modal-card, .modal-card.wide { width: 100%; max-width: 100%; max-height: calc(100dvh - 40px - env(safe-area-inset-top)); overflow-y: auto; border-radius: 18px 18px 0 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); }
  .modal-card.full { width: 100%; height: calc(100dvh - 24px - env(safe-area-inset-top)); max-height: none; padding: 0; overflow: hidden; }
  .set-full { background: var(--bg-1); grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .set-nav { flex-direction: row; gap: 4px; margin-right: 56px; padding: 12px 4px 10px 10px; overflow-x: auto; scrollbar-width: none; }
  .set-nav::-webkit-scrollbar, .set-nav-head, .set-nav hr { display: none; }
  .set-nav button { flex: none; height: 38px; white-space: nowrap; }
  .set-nav button.on::before { left: 14px; right: 14px; top: auto; bottom: 0; width: auto; height: 2px; }
  .set-pane { position: static; background: var(--bg-2); min-width: 0; padding: 18px 16px calc(40px + env(safe-area-inset-bottom)); }
  .set-x { position: absolute; top: 12px; right: 10px; margin: 0; float: none; }
  .set-x small { display: none; }
  .set-row { flex-wrap: wrap; gap: 10px; }
  .set-row > span:first-child { flex: 1; min-width: 55%; }
  .set-preview { width: 100%; }
  .seg { flex-wrap: wrap; }
  .set-pass, .field-row { flex-wrap: wrap; }
  .role-ed { grid-template-columns: minmax(0, 1fr); }
  .role-side { position: static; }
  .role-pane, .perm-list { grid-template-columns: minmax(0, 1fr); }
  .role-list { max-height: 34vh; }
  .set-row.person-row > .person-who { width: auto; flex: 1; }
  .set-row.person-row > .person-roles { flex: 1 0 100%; order: 3; }
  .fr-page { padding: 14px 12px; }
  .fr-tabs button { padding: 0 10px; }
  .fr-row { padding: 9px 6px; }
  .auth-card { width: calc(100vw - 32px); }
  #voice-bar { flex-wrap: wrap; }
}
@media (hover: none) {
  .cat .cat-add { opacity: 1; }
}
