.mobile-back {
  display: none;
}

@media (max-width: 768px) {
  html.mobile-app,
  html.mobile-app body {
    min-height: 100%;
    overflow: hidden;
  }

  body {
    min-height: 100dvh;
  }

  #app-view:not(.hidden) {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .topbar {
    min-height: auto;
    flex: 0 0 auto;
    padding: max(10px, env(safe-area-inset-top)) 12px 10px;
    gap: 10px;
    border-bottom: 1px solid var(--border);
  }

  .brand {
    min-width: 0;
  }

  .brand .subtitle {
    display: none;
  }

  .top-actions {
    gap: 6px;
  }

  .top-actions .link,
  .top-actions .ghost {
    min-height: 40px;
    padding: 8px 10px;
    font-size: 13px;
  }

  .top-actions .theme-toggle {
    display: none;
  }

  .workspace {
    position: relative;
    display: block;
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    padding: 0;
    overflow: hidden;
  }

  .sidebar,
  .chat {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-height: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    animation: none;
    background: var(--panel);
  }

  .sidebar {
    display: block;
    padding: 12px;
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
    overflow-y: auto;
  }

  .chat {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    transform: translateX(100%);
    transition: transform 180ms ease;
    z-index: 3;
  }

  body.mobile-chat-open .chat {
    transform: translateX(0);
  }

  body.mobile-chat-open .sidebar {
    pointer-events: none;
  }

  .mobile-back {
    display: inline-flex;
    flex: 0 0 auto;
    min-height: 40px;
    padding: 8px 10px;
  }

  .chat-header {
    min-height: 58px;
    padding: 10px 12px;
    gap: 8px;
    flex-wrap: nowrap;
  }

  .chat-meta {
    min-width: 0;
    flex: 1 1 auto;
  }

  .chat-title {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 17px;
  }

  #chat-status {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
  }

  #attach-file-btn {
    flex: 0 0 auto;
    min-height: 40px;
    padding: 8px 10px;
  }

  .typing {
    display: none;
  }

  .messages {
    min-height: 0;
    padding: 12px;
    gap: 10px;
  }

  .bubble {
    max-width: 86%;
    padding: 10px 12px;
    border-radius: 14px;
    overflow-wrap: anywhere;
  }

  .bubble .meta {
    font-size: 11px;
  }

  .message-box {
    position: static;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  }

  .message-box input {
    min-width: 0;
    min-height: 44px;
    font-size: 16px;
  }

  .message-box button[type="submit"] {
    min-width: 52px;
    min-height: 44px;
    padding: 8px 12px;
  }

  .sidebar .user,
  .group,
  .channel {
    min-height: 58px;
    padding: 10px;
  }

  .sidebar-section {
    margin-bottom: 14px;
  }

  .section-title {
    position: sticky;
    top: -12px;
    z-index: 1;
    padding: 10px 0 8px;
    background: var(--panel);
  }

  .auth-shell {
    min-height: 100dvh;
    display: block;
    padding: 14px;
  }

  .auth-hero {
    margin-bottom: 12px;
    padding: 18px;
  }

  .login-card {
    padding: 18px;
  }

  .modal-card {
    width: 100%;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    overflow-y: auto;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }
}
