.mobile-menu-toggle,
.mobile-menu-close,
.mobile-menu-backdrop {
  display: none;
}

/* Keep every menu item reachable on short desktop windows as well. */
.app-sidebar {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.app-sidebar > .brand,
.app-sidebar > .sidebar-status {
  flex: 0 0 auto;
}

.app-sidebar > nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #d8dce2 transparent;
}

.app-sidebar > nav::-webkit-scrollbar {
  width: 5px;
}

.app-sidebar > nav::-webkit-scrollbar-thumb {
  background: #d8dce2;
  border-radius: 5px;
}

@media (max-width: 720px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  body.mobile-nav-open {
    overflow: hidden;
    touch-action: none;
  }

  .layout {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .app-sidebar {
    position: fixed;
    z-index: 1001;
    inset: 0 auto 0 0;
    width: min(282px, calc(100vw - 48px)) !important;
    max-width: 100%;
    height: 100vh !important;
    height: 100dvh !important;
    padding: 0 0 env(safe-area-inset-bottom, 0) !important;
    background: #fff;
    border-right: 1px solid #e5e7eb;
    box-shadow: 12px 0 32px rgba(17, 24, 39, .14);
    transform: translateX(-104%);
    visibility: hidden;
    transition: transform .22s ease, visibility 0s linear .22s;
  }

  body.mobile-nav-open .app-sidebar {
    transform: translateX(0);
    visibility: visible;
    transition: transform .22s ease;
  }

  .app-sidebar .brand {
    height: 64px;
    padding: 0 12px 0 16px !important;
    justify-content: flex-start !important;
    gap: 10px;
  }

  .app-sidebar .brand > div {
    display: flex !important;
    min-width: 0;
    flex: 1;
    flex-direction: column;
  }

  .app-sidebar .brand > div b,
  .app-sidebar .brand > div small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-menu-close {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: #606775;
    background: transparent;
    border: 0;
    border-radius: 6px;
  }

  .mobile-menu-close svg {
    width: 19px;
    height: 19px;
  }

  .mobile-menu-close:active {
    background: #f2f3f5;
  }

  .app-sidebar > nav {
    padding: 8px 10px 12px !important;
    scroll-padding: 8px;
  }

  .app-sidebar .nav {
    width: 100%;
    height: 44px;
    min-height: 44px;
    margin: 2px 0;
    padding: 0 12px !important;
    justify-content: flex-start !important;
    gap: 12px;
    font-size: 14px !important;
    text-align: left;
  }

  .app-sidebar .nav::before {
    display: none !important;
    content: none !important;
  }

  .app-sidebar .nav > span:last-child {
    display: inline !important;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app-sidebar .nav .nav-icon,
  .app-sidebar .nav svg {
    width: 19px;
    height: 19px;
    flex: 0 0 19px;
  }

  .app-sidebar .sidebar-status {
    min-height: 48px;
    padding: 0 18px;
    justify-content: flex-start;
    gap: 9px;
    background: #fff;
  }

  .app-sidebar .sidebar-status span:last-child {
    display: inline !important;
  }

  .mobile-menu-backdrop {
    position: fixed;
    z-index: 1000;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    padding: 0;
    background: rgba(17, 24, 39, .38);
    border: 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .22s ease, visibility 0s linear .22s;
  }

  body.mobile-nav-open .mobile-menu-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity .22s ease;
  }

  .app-main {
    width: 100%;
    min-width: 0;
    height: auto !important;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .app-header {
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    column-gap: 10px;
    row-gap: 8px;
    height: auto !important;
    min-height: 64px;
    padding: 10px 12px !important;
  }

  .mobile-menu-toggle {
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 0 10px;
    color: #343944;
    background: #fff;
    border: 1px solid #dfe3e8;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
  }

  .mobile-menu-toggle svg {
    width: 17px;
    height: 17px;
  }

  .mobile-menu-toggle:active,
  .mobile-menu-toggle[aria-expanded="true"] {
    color: var(--accent, #ff2442);
    background: var(--accent-soft, #fff1f3);
    border-color: #ffcbd3;
  }

  .app-header > .header-title {
    min-width: 0;
  }

  .app-header > .header-title h1,
  .app-header > .header-title p {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app-header > .header-title h1 {
    font-size: 17px;
  }

  .app-header > .header-title p {
    margin-top: 2px;
    font-size: 11px;
  }

  .app-header .header-actions {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
    justify-content: flex-end;
    gap: 8px;
  }

  .app-header #health {
    margin-right: auto;
  }

  .app-header #refresh {
    height: 34px;
    padding: 0 10px;
  }

  .page,
  .shortlink-page {
    width: 100%;
    max-width: 100%;
    padding: 12px !important;
    overflow-x: hidden;
  }

  .page .panel {
    max-width: 100%;
  }

  .shortlink-panel {
    padding: 12px !important;
  }

  .shortlink-records {
    width: 100%;
    margin-top: 0 !important;
    overflow: visible !important;
  }

  .shortlink-toolbar {
    width: 100%;
    height: auto !important;
    min-height: 0 !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center !important;
    gap: 8px;
    margin: 0 0 12px !important;
    padding: 0 !important;
  }

  .shortlink-toolbar .card-page-search,
  .shortlink-toolbar .card-page-search .search-input-shell {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    margin: 0 !important;
    flex: 1 1 auto !important;
  }

  .shortlink-toolbar .card-page-search .shortlink-search,
  .shortlink-toolbar .shortlink-search {
    width: 100% !important;
    min-width: 0 !important;
    height: 38px !important;
    padding: 0 34px 0 36px !important;
    font-size: 13px !important;
  }

  .shortlink-toolbar #newShortlinkTop {
    width: auto !important;
    min-width: 94px;
    height: 38px !important;
    margin: 0 !important;
    padding: 0 12px !important;
    white-space: nowrap;
  }

  .shortlink-table {
    width: 100%;
    min-width: 0 !important;
    display: grid;
    gap: 10px;
    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    overflow: visible !important;
  }

  .shortlink-table-head {
    display: none !important;
  }

  .shortlink-table-row {
    width: 100%;
    min-width: 0;
    display: grid !important;
    grid-template-columns: minmax(72px, auto) minmax(0, 1fr) !important;
    gap: 0 12px;
    align-items: center;
    padding: 14px !important;
    background: #fff;
    border: 1px solid #e3e6ea !important;
    border-radius: 7px;
  }

  .shortlink-table-row > div {
    min-width: 0;
    padding: 5px 0;
  }

  .shortlink-table-row > div:nth-child(1) {
    grid-column: 1;
    align-self: start;
  }

  .shortlink-table-row > div:nth-child(2) {
    grid-column: 2;
    align-self: start;
    color: #343944;
    font-weight: 600;
    text-align: right;
  }

  .shortlink-table-row > div:nth-child(n+3) {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 78px minmax(0, 1fr);
    gap: 8px;
    align-items: start;
    margin-top: 2px;
    border-top: 1px solid #f0f1f3;
  }

  .shortlink-table-row > div:nth-child(3)::before { content: "短链"; }
  .shortlink-table-row > div:nth-child(4)::before { content: "备注"; }
  .shortlink-table-row > div:nth-child(5)::before { content: "跳转连接"; }
  .shortlink-table-row > div:nth-child(6)::before { content: "归属 / 时间"; }
  .shortlink-table-row > div:nth-child(7)::before { content: "操作"; }

  .shortlink-table-row > div:nth-child(n+3)::before {
    color: #8a909b;
    font-size: 12px;
    line-height: 22px;
  }

  .shortlink-table-row b,
  .shortlink-table-row small {
    max-width: 100%;
    overflow: visible !important;
    overflow-wrap: anywhere;
    text-overflow: clip !important;
    white-space: normal !important;
    line-height: 1.55;
  }

  .shortlink-table-row > div:nth-child(6) small + small {
    margin-top: 2px;
    color: #8a909b;
  }

  .shortlink-actions {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 6px !important;
  }

  .shortlink-actions::before {
    grid-column: 1 / -1;
    grid-row: auto;
  }

  .shortlink-actions .btn {
    width: 100%;
    min-width: 0;
    height: 34px;
    padding: 0 7px !important;
    font-size: 12px;
    white-space: nowrap;
  }

  .table-wrap,
  .workspace-table-wrap,
  .credit-table-wrap {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 360px) {
  .shortlink-toolbar {
    grid-template-columns: 1fr;
  }

  .shortlink-toolbar #newShortlinkTop {
    width: 100% !important;
  }

  .shortlink-actions .btn {
    padding-right: 4px !important;
    padding-left: 4px !important;
    font-size: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-sidebar,
  .mobile-menu-backdrop {
    transition: none !important;
  }
}
