.mobile-topbar,
.sidebar-backdrop {
  display: none;
}

@media (max-width: 768px) {
  :root {
    --sidebar-width: 0px;
    --mobile-topbar-height: 3.25rem;
    --mobile-safe-top: env(safe-area-inset-top, 0px);
    --mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
  }

  body.layout:not(.layout-auth) .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 160;
    height: calc(var(--mobile-topbar-height) + var(--mobile-safe-top));
    padding: var(--mobile-safe-top) 0.75rem 0 0.85rem;
    border-bottom: 1px solid var(--color-border);
    background: rgba(18, 38, 66, 0.97);
    backdrop-filter: blur(12px);
  }

  body.layout:not(.layout-auth) .layout-body {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    padding-top: calc(var(--mobile-topbar-height) + var(--mobile-safe-top));
  }

  body.layout:not(.layout-auth) .sidebar {
    width: min(88vw, 300px) !important;
    z-index: 200;
    animation: none !important;
    transform: translate3d(-110%, 0, 0) !important;
    visibility: hidden;
    pointer-events: none;
    transition:
      transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
      visibility 0.28s step-end;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.45);
    padding-top: calc(0.85rem + var(--mobile-safe-top));
  }

  body.layout:not(.layout-auth) .sidebar .sidebar-category {
    animation: none !important;
  }

  body.layout.mobile-nav-open:not(.layout-auth) .sidebar {
    transform: translate3d(0, 0, 0) !important;
    visibility: visible;
    pointer-events: auto;
    transition:
      transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
      visibility 0s;
  }

  body.layout:not(.layout-auth) .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 190;
    border: 0;
    margin: 0;
    padding: 0;
    background: rgba(2, 8, 18, 0.62);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.24s ease;
  }

  body.layout:not(.layout-auth) .sidebar-backdrop[hidden] {
    display: block;
    opacity: 0;
    pointer-events: none;
  }

  body.layout.mobile-nav-open:not(.layout-auth) .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  body.mobile-nav-open {
    touch-action: none;
  }

  body.mobile-nav-open .layout-body {
    overflow: hidden;
  }

  .mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-bg-surface-2);
    color: #e2e8f0;
    cursor: pointer;
    touch-action: manipulation;
  }

  .mobile-menu-icon {
    position: relative;
    display: block;
    width: 1.125rem;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
    transition: background 0.2s ease;
  }

  .mobile-menu-icon::before,
  .mobile-menu-icon::after {
    content: "";
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
    transition: transform 0.22s ease, top 0.22s ease;
  }

  .mobile-menu-icon::before {
    top: -6px;
  }

  .mobile-menu-icon::after {
    top: 6px;
  }

  body.mobile-nav-open .mobile-menu-icon {
    background: transparent;
  }

  body.mobile-nav-open .mobile-menu-icon::before {
    top: 0;
    transform: rotate(45deg);
  }

  body.mobile-nav-open .mobile-menu-icon::after {
    top: 0;
    transform: rotate(-45deg);
  }

  .mobile-topbar-brand {
    display: inline-flex;
    align-items: baseline;
    gap: 0;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: 0.02em;
    text-decoration: none;
    color: inherit;
    min-width: 0;
  }

  .mobile-topbar-badge {
    margin-left: auto;
    padding-right: 0.35rem;
    font-size: 0.5625rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 42%;
  }

  body.layout:not(.layout-auth) .sidebar .sidebar-tab {
    min-height: 2.75rem;
    padding: 0.55rem 0.75rem;
    font-size: 0.8125rem;
  }

  body.layout:not(.layout-auth) .main {
    padding: 1rem 0.85rem 1.25rem;
  }

  .layout-wide .main {
    max-width: 100%;
  }

  .page-title {
    font-size: 1.25rem;
    margin-bottom: 1rem;
  }

  .card {
    padding: 1rem 1.05rem;
  }

  .site-footer-thin {
    padding: 0.55rem 0.85rem calc(0.55rem + var(--mobile-safe-bottom));
  }

  .site-footer-thin-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.45rem;
  }

  .site-footer-thin-links {
    margin-left: 0;
    justify-content: flex-start;
    gap: 0.5rem 0.85rem;
  }

  .live-price-wrap {
    padding: 0.7rem 0.85rem calc(0.7rem + var(--mobile-safe-bottom));
  }

  .live-price-hint {
    font-size: 0.8125rem;
  }

  .wizard-head {
    padding-bottom: 1rem;
  }

  .wizard-title {
    font-size: 1.25rem;
  }

  .wizard-steps {
    flex-wrap: nowrap;
    gap: 0.4rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.15rem;
  }

  .wizard-steps::-webkit-scrollbar {
    display: none;
  }

  .wizard-step {
    flex: 0 0 auto;
    font-size: 0.8125rem;
  }

  .wizard-step .wizard-step-label {
    display: none;
  }

  .wizard-step.is-current .wizard-step-label {
    display: inline;
    max-width: 5.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .plan-grid,
  .stack-grid,
  .soft-grid {
    grid-template-columns: 1fr;
  }

  .tier-slider-shell {
    padding: 1rem 0.85rem;
  }

  .tier-slider-gb {
    font-size: 1.65rem;
  }

  .tier-slider-ticks {
    display: none;
  }

  .tier-slider-range {
    margin-bottom: 0.15rem;
  }

  .storage-backup-wrap {
    max-width: 100%;
  }

  .summary-layout {
    grid-template-columns: 1fr;
  }

  .page-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 0.3rem;
    padding: 0.3rem;
  }

  .page-tabs::-webkit-scrollbar {
    display: none;
  }

  .page-tab {
    flex: 0 0 auto;
    min-height: 2.75rem;
    padding: 0.5rem 0.8rem;
    white-space: nowrap;
  }

  .billing-wallet-layout {
    grid-template-columns: 1fr;
  }

  .billing-hero {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
  }

  .billing-hero-balance {
    width: 100%;
    align-items: flex-start;
  }

  .billing-service-metrics {
    grid-template-columns: 1fr 1fr;
  }

  .billing-tx-item {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .billing-tx-side {
    grid-column: 2;
    text-align: left;
  }

  .server-layout {
    grid-template-columns: 1fr;
  }

  .server-page-header-row {
    flex-direction: column;
    align-items: stretch;
  }

  .server-connection-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .server-connection-inner .btn {
    width: 100%;
    min-height: 2.75rem;
  }

  .dashboard-power-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .dashboard-power-actions .btn-sm {
    width: 100%;
    min-height: 2.75rem;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }

  .admin-mail-layout,
  .admin-paypal-layout,
  .admin-mail-edit-layout,
  .admin-mail-bulk-layout {
    grid-template-columns: 1fr;
  }

  .billing-form-grid {
    grid-template-columns: 1fr;
  }

  .billing-form-grid .field-span-2 {
    grid-column: auto;
  }

  .btn,
  .btn-sm {
    min-height: 2.75rem;
  }

  .btn-block {
    width: 100%;
  }

  .modal-overlay {
    padding: 0.85rem;
    padding-bottom: calc(0.85rem + var(--mobile-safe-bottom));
    align-items: flex-end;
  }

  .modal-dialog {
    width: 100%;
    max-height: min(88vh, calc(100dvh - 2rem));
    overflow-y: auto;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }

  .modal-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .modal-actions .btn {
    width: 100%;
  }

  .layout-ticket-chat .main {
    padding: 0.65rem 0.75rem 0.85rem;
  }

  .layout-ticket-chat .layout-body {
    height: calc(100dvh - var(--mobile-topbar-height) - var(--mobile-safe-top));
    max-height: calc(100dvh - var(--mobile-topbar-height) - var(--mobile-safe-top));
  }

  .ticket-composer-dock {
    padding-bottom: var(--mobile-safe-bottom);
  }

  .contact-choice-grid {
    grid-template-columns: 1fr;
  }

  .data-table-wrap:not(:has(.dashboard-server-table)) {
    margin-left: -0.15rem;
    margin-right: -0.15rem;
    border-radius: 8px;
  }

  .data-table-wrap:has(.dashboard-server-table) {
    overflow-x: visible;
    margin: 0;
  }

  .dashboard-server-table {
    border-collapse: separate;
    border-spacing: 0 0.75rem;
  }

  .dashboard-server-table thead {
    display: none;
  }

  .dashboard-server-table tbody {
    display: block;
  }

  .dashboard-server-table tbody tr {
    display: block;
    padding: 0.95rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: var(--color-bg-raised);
  }

  .dashboard-server-table tbody td {
    display: grid;
    grid-template-columns: 4.5rem minmax(0, 1fr);
    gap: 0.2rem 0.65rem;
    align-items: start;
    padding: 0.45rem 0;
    border-bottom: 1px solid rgba(30, 53, 84, 0.55);
  }

  .dashboard-server-table tbody td:last-child {
    border-bottom: none;
    padding-bottom: 0;
  }

  .dashboard-server-table tbody td::before {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: #64748b;
    line-height: 1.45;
  }

  .dashboard-server-table tbody td:nth-child(2)::before {
    content: "契約日";
  }

  .dashboard-server-table tbody td:nth-child(3)::before {
    content: "更新日";
  }

  .dashboard-server-table tbody td:nth-child(4)::before {
    content: "アドレス";
  }

  .dashboard-server-table tbody td:nth-child(5)::before {
    content: "アプリ";
  }

  .dashboard-server-table tbody td:nth-child(6)::before {
    content: "操作";
  }

  .dashboard-server-table tbody td:first-child {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.5rem;
    padding: 0 0 0.7rem;
    margin-bottom: 0.15rem;
    border-bottom: 1px solid var(--color-border);
  }

  .dashboard-server-table tbody td:first-child::before {
    content: none;
    display: none;
  }

  .dashboard-server-table .dashboard-server-name {
    min-width: 0;
  }

  .dashboard-server-table .dashboard-server-name .text-link {
    font-size: 1.0625rem;
    font-weight: 600;
    line-height: 1.35;
  }

  .dashboard-server-table .host-display {
    font-size: 0.8125rem;
    line-height: 1.45;
  }

  .dashboard-server-table tbody td:nth-child(6) {
    display: block;
    padding-top: 0.55rem;
  }

  .dashboard-server-table tbody td:nth-child(6)::before {
    display: block;
    margin-bottom: 0.45rem;
  }

  .dashboard-server-table .dashboard-server-actions {
    min-width: 0;
  }

  .dashboard-server-table .dashboard-power-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
  }

  .dashboard-server-table .dashboard-power-actions .btn-sm {
    width: 100%;
    min-height: 2.75rem;
    font-size: 0.8125rem;
  }

  .card-draft .summary-dl-compact {
    grid-template-columns: 1fr;
  }

  .admin-view-banner {
    font-size: 0.8125rem;
    line-height: 1.5;
  }

  .app-toast-stack {
    left: 0.75rem;
    right: 0.75rem;
    bottom: calc(0.75rem + var(--mobile-safe-bottom));
  }
}
