/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  .topbar {
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 14px;
    padding-top: max(10px, env(safe-area-inset-top));
  }
  .brand {
    flex: 0 1 auto;
    margin-right: auto;
  }
  .search {
    order: 3;
    flex-basis: 100%;
    max-width: none;
  }
  .search kbd {
    display: none;
  }
  #editBtn span {
    display: none;
  }
  #editBtn {
    width: 40px;
    padding: 0;
  }
  .favs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 12px 14px 4px;
  }
  .favs::-webkit-scrollbar {
    display: none;
  }
  .fav {
    box-shadow: none;
  }
  main {
    padding: 8px 14px 40px;
  }
  .server-top {
    padding: 10px 0 14px;
  }
  .server-head h2 {
    font-size: 1.25rem;
  }
  .server-head .info {
    min-width: 0;
  }
  .server-head .server-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    font-size: 24px;
  }
  .grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  body[data-layout="compact"] #services .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  body.editing[data-layout="compact"] #services .grid {
    grid-template-columns: 1fr;
  }
  body[data-layout="list"] #services .card {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  body[data-layout="list"] #services .card .links {
    flex: 0 1 auto;
    max-width: 100%;
    justify-content: flex-start;
  }
  .services {
    gap: 18px;
  }
  .card {
    padding: 12px 14px;
    gap: 10px;
  }
  .card:hover {
    transform: none;
  }
  .icon {
    width: 42px;
    height: 42px;
  }
  .stats {
    width: 100%;
    gap: 8px;
  }
  .stat-card {
    flex: 1 1 100%;
    padding: 12px;
  }
  .stat-card.system {
    justify-content: space-around;
  }
  .stat-card.sensors,
  .stat-card.network,
  .stat-card.availability {
    width: auto;
  }
  .metric {
    min-width: 76px;
  }
  .gauge {
    width: 42px;
    height: 42px;
  }
  .gauge span {
    font-size: 0.72rem;
  }
  .gauge.badge svg {
    width: 18px;
    height: 18px;
  }
  .dock-hint {
    display: none;
  }
  .edit-dock {
    gap: 6px;
    padding: 6px;
  }
  .edit-dock .btn {
    padding: 0 9px;
  }

  dialog {
    width: 100vw;
    max-width: 100vw;
    margin: auto 0 0;
    border-radius: 20px 20px 0 0;
    border-bottom: 0;
    max-height: 92dvh;
  }
  .qr-dialog,
  .avail-dialog {
    width: 100vw;
  }
  dialog[open] {
    animation: sheet 0.22s ease;
  }
  .dialog-foot {
    padding-bottom: max(18px, env(safe-area-inset-bottom));
  }
}
@keyframes sheet {
  from {
    transform: translateY(40px);
    opacity: 0;
  }
}

@media (pointer: coarse) {
  .btn,
  .btn.sm,
  .icon-btn,
  .icon-btn.sm,
  .fav .icon-btn.sm,
  .info-value .icon-btn {
    min-width: 44px;
    min-height: 44px;
  }
  a.chip,
  .card .links a.chip,
  .link-pill,
  button.group-head,
  .unlisted summary,
  .seg button,
  .swatch {
    min-height: 44px;
  }
  .swatch {
    min-width: 44px;
  }
  .fav .icon-btn.sm {
    margin-right: 0;
  }
}

@media (max-width: 480px) {
  .dock-label {
    display: none;
  }
  .avail-tiles {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 540px) and (max-width: 720px) {
  .grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
