/* Mobile console stability and modal fixes. Keep this stylesheet last. */
@media (max-width: 767px) {
  .app-topbar,
  .app-topbar-inner,
  .app-topbar-inner > div {
    max-width: 100vw;
    overflow: hidden;
  }

  .app-topbar-inner {
    padding-left: max(4px, env(safe-area-inset-left)) !important;
    padding-right: max(4px, env(safe-area-inset-right)) !important;
  }

  .app-topbar-inner > div {
    gap: 6px !important;
    padding-left: 8px !important;
    padding-right: 8px !important;
  }

  .app-topbar-inner > div > nav {
    display: none !important;
  }

  .app-topbar-inner > div > div:first-child {
    flex: 0 0 auto !important;
    min-width: 0 !important;
  }

  .app-topbar-inner > div > div:last-child {
    flex: 0 1 auto !important;
    min-width: 0 !important;
    margin-left: auto !important;
    gap: 6px !important;
  }

  .app-topbar-inner > div > div:last-child button,
  .app-topbar-inner > div > div:last-child a {
    flex-shrink: 0;
  }

  #toska-header-qq-support {
    width: 30px !important;
    min-width: 30px !important;
    height: 30px !important;
    padding: 0 !important;
  }

  #toska-header-qq-support > span:last-child {
    display: none !important;
  }

  .semi-modal-wrap {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    height: 100vh !important;
    height: 100dvh !important;
    padding-top: max(10px, env(safe-area-inset-top)) !important;
    padding-right: max(10px, env(safe-area-inset-right)) !important;
    padding-bottom: max(10px, env(safe-area-inset-bottom)) !important;
    padding-left: max(10px, env(safe-area-inset-left)) !important;
    overflow: hidden !important;
    overscroll-behavior: contain;
  }

  .semi-modal.semi-modal-full-width {
    position: relative !important;
    top: auto !important;
    width: 100% !important;
    max-width: none !important;
    max-height: calc(100vh - 20px) !important;
    max-height: calc(100dvh - 20px) !important;
    margin: 0 !important;
  }

  .semi-modal.semi-modal-full-width > .semi-modal-content {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-height: calc(100vh - 20px) !important;
    max-height: calc(100dvh - 20px) !important;
    overflow: hidden !important;
  }

  .semi-modal-full-width .semi-modal-header {
    flex: 0 0 auto !important;
    min-height: 0 !important;
    padding: 14px 46px 10px 14px !important;
  }

  .semi-modal-full-width .semi-modal-title {
    width: 100% !important;
    min-width: 0 !important;
    line-height: 1.3 !important;
  }

  .semi-modal-full-width .semi-modal-title > .flex {
    align-items: flex-start !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    gap: 8px !important;
  }

  .semi-modal-full-width .semi-modal-title > .flex > span:first-child {
    font-size: 18px;
    font-weight: 700;
    white-space: normal;
  }

  .semi-modal-full-width .semi-modal-title .semi-tabs {
    width: 100% !important;
    min-width: 0 !important;
  }

  .semi-modal-full-width .semi-modal-title .semi-tabs-bar {
    width: 100% !important;
    overflow-x: auto !important;
    scrollbar-width: none;
  }

  .semi-modal-full-width .semi-modal-title .semi-tabs-content {
    display: none !important;
  }

  .semi-modal-full-width .semi-modal-body {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    padding: 10px 12px !important;
    overflow: hidden !important;
  }

  .semi-modal-full-width .semi-modal-body > .notice-content-scroll,
  .semi-modal-full-width .semi-modal-body > .card-content-scroll {
    width: 100% !important;
    height: 100% !important;
    max-height: none !important;
    padding: 12px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .semi-modal-full-width .semi-modal-footer {
    flex: 0 0 auto !important;
    padding: 10px 12px max(10px, env(safe-area-inset-bottom)) !important;
  }

  .semi-modal-full-width .semi-modal-footer > .flex {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px !important;
    width: 100%;
  }

  .semi-modal-full-width .semi-modal-footer button {
    min-width: 0 !important;
    margin: 0 !important;
    padding-left: 8px !important;
    padding-right: 8px !important;
    white-space: normal !important;
  }

  .semi-modal-full-width .semi-timeline-item-content {
    min-width: 0 !important;
    overflow-wrap: anywhere;
  }

  .dashboard-announcement-body {
    margin: 8px !important;
  }

  .toska-announcement-support-button {
    max-width: 100%;
    white-space: normal;
  }
}

@media (max-width: 359px) {
  .app-topbar-inner > div {
    gap: 4px !important;
    padding-left: 6px !important;
    padding-right: 6px !important;
  }

  .app-topbar-inner > div > div:last-child {
    gap: 4px !important;
  }

  .semi-modal-full-width .semi-modal-header {
    padding-left: 12px !important;
  }
}
