/* These controls are exclusive to the compact Studio layout. */
.mobile-menu-toggle,
.mobile-view-switch,
.mobile-sidebar-heading,
.mobile-sidebar-backdrop {
  display: none;
}

@media (max-width: 1023px) {
  body.mm-dashboard {
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
  }

  .mm-dashboard .dashboard-container {
    position: fixed;
    top: var(--mm-mobile-top, 0px);
    left: 0;
    width: 100%;
    height: var(--mm-mobile-height, 100dvh);
    min-height: 0;
    box-sizing: border-box;
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
    overflow: hidden;
    background: #111318;
  }

  .mm-dashboard .dashboard-header {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    gap: 8px;
    min-height: 64px;
    padding: 8px 12px;
    border: 0;
    background: #111318;
    z-index: 20;
  }

  .mm-dashboard .dashboard-header .logo-section,
  .mm-dashboard .dashboard-header .username,
  .mm-dashboard .dashboard-header .mm-token-pill {
    display: none;
  }

  .mm-dashboard .dashboard-account,
  .mm-dashboard .dashboard-header .user-section {
    justify-content: flex-end;
  }

  .mm-dashboard .dashboard-header .user-avatar {
    width: 44px !important;
    height: 44px !important;
  }

  .mm-dashboard #mobile-menu-toggle,
  .mm-dashboard .mobile-sidebar-heading button {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    min-height: 44px;
    margin: 0;
    padding: 0;
    border: 1px solid #363940;
    border-radius: 50%;
    background: #202227;
    color: #f1f1f1;
  }

  .mm-dashboard .mobile-view-switch {
    display: flex;
    justify-self: center;
    gap: 2px;
    padding: 3px;
    border: 1px solid #363940;
    border-radius: 28px;
    background: #202227;
  }

  .mm-dashboard .mobile-view-switch button {
    width: auto;
    min-height: 44px;
    margin: 0;
    padding: 8px 16px;
    border: 0;
    border-radius: 24px;
    background: transparent;
    color: #d1d5db;
    font-size: 16px;
    line-height: 1.25;
    white-space: nowrap;
  }

  .mm-dashboard .mobile-view-switch button[aria-pressed="true"] {
    background: #3b3e45;
    color: #fff;
  }

  .mm-dashboard .dashboard-body {
    flex: 1 1 0;
    min-height: 0;
    height: auto;
    overflow: hidden;
  }

  .mm-dashboard .dashboard-body :is(.sidebar-resizer, .middle-resizer, .input-resizer) {
    display: none;
  }

  .mm-dashboard .dashboard-body .main-content {
    flex: 1 1 0;
    min-height: 0;
    width: 100%;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas: "chat" "input";
    gap: 0;
    overflow: hidden;
  }

  .mm-dashboard .viewer-column { display: none; }
  .mm-dashboard [data-mobile-view="viewer"] .main-content { grid-template-areas: "viewer" "input"; }
  .mm-dashboard [data-mobile-view="viewer"] .viewer-column { display: block; }
  .mm-dashboard [data-mobile-view="viewer"] .chat-column { display: none; }

  .mm-dashboard .dashboard-body .chat-area {
    min-height: 0;
    max-height: none;
    padding: 0;
    border-radius: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: #111318;
  }

  .mm-dashboard .dashboard-body .messages-container { padding: 16px !important; }
  .mm-dashboard .welcome-message { padding: 24px 0; }
  .mm-dashboard .welcome-message h2 { font-size: 1.35rem; }
  .mm-dashboard .example-prompts { gap: 10px; }

  .mm-dashboard .dashboard-body .input-area {
    position: relative;
    flex: none;
    width: calc(100% - 16px);
    max-height: 55%;
    max-height: calc(var(--mm-mobile-height, 100dvh) * 0.55);
    min-height: 0;
    margin: 8px;
    padding: 10px 12px;
    border: 1px solid #383b42;
    border-radius: 24px;
    background: #202227;
    box-shadow: none;
    overflow-y: auto;
  }

  .mm-dashboard .model-selector {
    flex: 0 0 auto;
    margin: 0;
    font-size: 12px;
  }
  .mm-dashboard .model-selector summary { color: #bfc5ce; line-height: 24px; }
  .mm-dashboard .model-selector-grid { max-height: 22vh; overflow: auto; }
  .mm-dashboard .model-selector-grid label { color: #cdd3dc; }
  .mm-dashboard .model-selector-grid select { font-size: 16px; }

  .mm-dashboard .dashboard-body .input-container {
    display: grid !important;
    grid-template-columns: 44px minmax(0, 1fr);
    grid-template-rows: auto 44px;
    flex: 0 0 auto;
    min-height: 0;
  }
  .mm-dashboard .dashboard-body .message-input {
    grid-column: 1 / -1;
    grid-row: 1;
    box-sizing: border-box;
    width: 100%;
    min-height: 44px;
    max-height: 120px;
    max-height: min(120px, 20dvh);
    margin: 0;
    padding: 8px 4px;
    border: 0;
    box-shadow: none;
    background: transparent;
    color: #f1f1f1;
    font-size: 16px;
    line-height: 1.4;
  }
  .mm-dashboard .message-input::placeholder { color: #a0a5ae; }
  .mm-dashboard #attachButton { grid-column: 1; grid-row: 2; }
  .mm-dashboard .input-buttons { grid-column: 2; grid-row: 2; justify-self: end; margin: 0; }
  .mm-dashboard .input-container button {
    width: 44px;
    min-width: 44px;
    max-width: none;
    height: 44px;
    min-height: 44px;
    margin: 0;
    padding: 0;
    border-radius: 50%;
    font-size: 20px;
  }

  .mm-dashboard.large-controls .dashboard-body .message-input { font-size: 18px; min-height: 48px; }
  .mm-dashboard.large-controls .dashboard-body .input-container { grid-template-columns: 48px minmax(0, 1fr); grid-template-rows: auto 48px; }
  .mm-dashboard.large-controls .input-container button { width: 48px; min-width: 48px; height: 48px; min-height: 48px; }

  .mm-dashboard .dashboard-body #sidebar {
    position: absolute;
    inset: 0 auto 0 0;
    z-index: 40;
    visibility: hidden;
    width: min(320px, calc(100% - 48px)) !important;
    max-width: none !important;
    height: 100% !important;
    box-sizing: border-box;
    padding: max(12px, env(safe-area-inset-top, 0px)) 12px max(12px, env(safe-area-inset-bottom, 0px));
    background: #1b1e25;
    box-shadow: 12px 0 40px #0006;
    overflow: hidden;
  }
  .mm-dashboard .dashboard-body #sidebar.mobile-open { visibility: visible; }
  .mm-dashboard .dashboard-body #sidebar .nav-scroll {
    flex: 1 1 0 !important;
    max-height: none;
    overscroll-behavior: contain;
  }
  .mm-dashboard .mobile-sidebar-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 0 0 auto;
    gap: 12px;
    margin-bottom: 12px;
  }
  .mm-dashboard .mobile-sidebar-heading a { color: #f1f1f1; font-weight: 700; }
  .mm-dashboard .mobile-sidebar-heading button { font-size: 28px; }
  .mm-dashboard .mobile-sidebar-backdrop:not([hidden]) {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 30;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: #0008;
  }
}
