@media (max-width: 75rem) {
  .app {
    width: 100vw;
    height: 100vh;
    margin: 0;
    border-radius: 0;
  }

  .topbar {
    gap: 0.75rem;
  }

  .top-nav {
    order: 3;
    flex: 1 1 100%;
    justify-content: flex-start;
  }

  .top-actions {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(16rem, 22rem) minmax(0, 1fr);
  }

  .internal-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(16rem, 22rem) minmax(0, 1fr);
  }

  .panel-left {
    border-right: 0;
    border-bottom: 0.0625rem solid var(--stroke);
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .integration-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 45rem) {
  body {
    background: var(--bg);
  }

  body[data-theme="dark"] {
    background: var(--bg);
  }

  .app {
    width: 100vw;
    height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.75rem;
    padding: calc(0.75rem + env(safe-area-inset-top)) 0.875rem 0.75rem;
    border-radius: 0;
  }

  body[data-mobile-chat-open="true"] .topbar {
    display: none;
  }

  .brand {
    gap: 0.75rem;
  }

  .brand-dot {
    width: 2.25rem;
    height: 2.25rem;
  }

  .brand-title {
    font-size: 0.9375rem;
  }

  .brand-sub,
  .user-chip {
    display: none;
  }

  .top-actions {
    width: auto;
    gap: 0.5rem;
    margin-left: auto;
  }

  .top-actions .ghost {
    padding: 0.625rem 0.875rem;
    font-size: 0.8125rem;
  }

  .top-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    order: initial;
    justify-content: space-around;
    gap: 0.25rem;
    padding: 0.35rem calc(0.5rem + env(safe-area-inset-right)) calc(0.45rem + env(safe-area-inset-bottom)) calc(0.5rem + env(safe-area-inset-left));
    background: var(--header);
    border: 0;
    border-top: 0.0625rem solid var(--stroke);
    border-radius: 0;
    box-shadow: 0 -0.5rem 1.5rem rgba(17, 27, 33, 0.08);
    overflow: visible;
  }

  body[data-theme="dark"] .top-nav {
    background: #111b21;
  }

  .nav-btn {
    flex: 1;
    justify-content: center;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.45rem 0.25rem;
    border-radius: 0.875rem;
    font-size: 0.625rem;
  }

  .nav-icon {
    width: 1.5rem;
    height: 1.5rem;
  }

  .nav-label {
    display: block;
    font-size: 0.625rem;
  }

  .views {
    padding-bottom: 4.75rem;
  }

  body[data-mobile-chat-open="true"] .views {
    padding-bottom: 0;
  }

  .metrics-view,
  .client-view,
  .settings-view,
  .internal-view {
    padding: 0.875rem 0.875rem 1rem;
  }

  .metrics {
    grid-auto-flow: column;
    grid-template-columns: repeat(4, minmax(11.5rem, 1fr));
    overflow-x: auto;
    padding-bottom: 0.5rem;
  }

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

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

  .shell,
  .internal-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    border: 0;
    border-radius: 0;
  }

  .panel-left,
  .panel-center {
    border: 0;
  }

  .panel-header {
    padding: 0.875rem 0.875rem 0.625rem;
    background: var(--panel);
  }

  .panel-header h2 {
    margin-bottom: 0.625rem;
    font-size: 1.125rem;
  }

  .filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 0.125rem;
  }

  .filters .pill {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .search-box {
    margin: 0 0.75rem 0.625rem;
    padding: 0.75rem;
    border-radius: 0.875rem;
  }

  .search-tag,
  .conversation-tags,
  #templateBtn,
  #checklistBtn,
  .internal-view > .view-header {
    display: none;
  }

  .conversation-card {
    padding: 0.75rem 0.875rem;
    gap: 0.75rem;
  }

  .conversation-card.active {
    box-shadow: none;
  }

  .avatar {
    width: 3.125rem;
    height: 3.125rem;
  }

  .conversation-preview {
    margin-bottom: 0.35rem;
  }

  .conversation-secondary {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
  }

  .chat-header {
    padding: calc(0.625rem + env(safe-area-inset-top)) 0.75rem 0.625rem;
  }

  .mobile-back-btn {
    display: grid;
  }

  .chat-contact {
    gap: 0.625rem;
  }

  .chat-title {
    font-size: 0.9375rem;
  }

  .chat-meta {
    font-size: 0.75rem;
  }

  .chat-window-state {
    align-items: flex-start;
    gap: 0.4rem;
  }

  .chat-window-text {
    font-size: 0.6875rem;
  }

  .chat-actions {
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 0.25rem;
  }

  .internal-shell .chat-actions .ghost {
    display: none;
  }

  .chat-window {
    padding: 0.75rem 0.75rem 0.5rem;
  }

  .message {
    max-width: 88%;
  }

  .composer {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "attachment attachment"
      "utility utility"
      "field send";
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.625rem calc(0.625rem + env(safe-area-inset-bottom));
  }

  .composer-left {
    grid-area: utility;
    order: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 0.125rem;
  }

  .composer-left .ghost {
    flex: 0 0 auto;
  }

  .composer-attachment {
    grid-area: attachment;
  }

  .composer-field {
    grid-area: field;
    gap: 0.5rem;
  }

  #attachBtn,
  #recordAudioBtn {
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    font-size: 0;
    border-radius: 50%;
    display: grid;
    place-items: center;
  }

  #attachBtn::before {
    content: "+";
    font-size: 1.5rem;
    line-height: 1;
    font-weight: 500;
  }

  #recordAudioBtn::before {
    content: "\1F3A4";
    font-size: 1rem;
  }

  #recordAudioBtn.danger::before {
    content: "\25A0";
    font-size: 0.75rem;
  }

  .emoji-toggle {
    width: 2.75rem;
    height: 2.75rem;
  }

  .composer-field input {
    min-height: 3rem;
    border-radius: 1.5rem;
    padding: 0.8125rem 1rem;
  }

  #sendBtn {
    grid-area: send;
    width: 3rem;
    height: 3rem;
    padding: 0;
    border-radius: 50%;
    font-size: 0;
  }

  #sendBtn::before {
    content: "\27A4";
    font-size: 1rem;
    transform: translateX(0.0625rem);
  }

  .composer-attachment-card {
    grid-template-columns: auto 1fr auto;
  }

  .composer-attachment-preview {
    width: 3.5rem;
    height: 3.5rem;
    min-height: 3.5rem;
  }

  .emoji-picker {
    left: 0;
    right: 0;
    width: auto;
    bottom: calc(100% + 0.5rem);
  }

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

  .settings-actions {
    width: 100%;
  }

  .is-mobile-hidden {
    display: none !important;
  }
}
