/* Shared responsive rules; load after the page and cinematic stylesheets. */
img,
svg,
video,
canvas {
  max-width: 100%;
}

main,
section,
article,
aside,
form,
nav,
.container,
.mc-main,
.dashboard-main,
.create-profile-main,
.payment-main,
.auth-card,
.discover-container,
.dashboard-chart-card,
.admin-chart-card,
.profile-editor,
.profile-preview-card {
  min-width: 0;
}

p,
dd,
label,
button,
a,
.mc-message-bubble,
.mc-profile-info,
.profile-preview-content {
  overflow-wrap: anywhere;
}

input,
select,
textarea,
button {
  max-width: 100%;
}

@media (max-width: 960px) {
  .hero-in,
  .auth,
  .preview,
  .fee-band {
    grid-template-columns: minmax(0, 1fr);
  }

  .stack {
    width: min(100%, 540px);
    height: 400px;
    margin-inline: auto;
  }

  .g3,
  .g4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .auth-side {
    display: none;
  }
}

@media (max-width: 900px) {
  .mc-topbar {
    height: auto;
    min-height: 68px;
    flex-wrap: wrap;
    gap: 8px 12px;
    padding-block: 10px;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }

  .mc-brand {
    order: 1;
    min-width: 0;
  }

  .mc-account {
    order: 2;
    min-width: 0;
    margin-left: auto;
  }

  .mc-nav {
    order: 3;
    display: flex;
    flex: 1 0 100%;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 4px;
    overflow-x: auto;
    padding: 6px 0 1px;
    border-top: 1px solid var(--mc-border);
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }

  .mc-nav a {
    flex: 0 0 auto;
    padding: 9px 11px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
  }

  .mc-account {
    min-height: 44px;
  }

  .mc-chat-layout {
    grid-template-columns: minmax(0, 270px) minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  .g2,
  .g3,
  .g4,
  .row2,
  .preview,
  .dashboard-grid,
  .dashboard-analytics,
  .admin-chart-grid,
  .discover-layout,
  .profile-editor-layout,
  .profile-form-grid,
  .mc-profile-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .dashboard-featured,
  .dashboard-membership,
  .dashboard-safety,
  .admin-wide-chart,
  .admin-full-chart {
    grid-column: 1;
    grid-row: auto;
  }

  .profile-preview-column {
    position: static;
  }

  .mc-chat-layout {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .mc-chat-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--mc-border);
  }

  .mc-chat-panel {
    min-width: 0;
    min-height: 0;
  }

  .mc-main {
    margin-top: 18px;
  }

  .mc-heading {
    margin-bottom: 14px;
  }

  .mc-messages {
    min-height: clamp(120px, 21vh, 160px);
    max-height: min(42vh, 340px);
  }

  .mc-chat-composer {
    position: sticky;
    bottom: env(safe-area-inset-bottom);
    z-index: 2;
  }

  .mc-profile-photo-card {
    min-height: 0;
  }

  .mc-profile-photo {
    height: clamp(320px, 100vw, 560px);
    min-height: 320px;
  }

  .admin-stat-grid,
  .dashboard-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pending-payment-actions {
    align-items: stretch;
  }

  .pending-payment-actions .mc-button {
    flex: 1 1 140px;
    min-height: 44px;
  }

  .payment-admin-note {
    flex: 1 0 100%;
    min-width: 0;
  }

  .discover-nav {
    align-items: flex-start;
    flex-direction: column;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }

  .discover-links {
    width: 100%;
    gap: 8px 16px;
  }

  .discover-links a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding-block: 8px;
  }

  .discover-page .member-photo {
    height: clamp(300px, 95vw, 520px);
  }

  .section {
    padding-block: clamp(42px, 8vw, 60px);
  }
}

@media (max-width: 760px) {
  .burger {
    display: block;
    flex: 0 0 44px;
  }

  .nav-cta .btn-ghost {
    display: none;
  }

  .nav-links {
    position: absolute;
    top: 68px;
    left: 0;
    right: 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 8px max(16px, env(safe-area-inset-left)) 12px;
    border-bottom: 1px solid var(--line);
    background: rgba(7, 18, 46, .98);
    max-height: calc(100dvh - 76px);
    overflow-y: auto;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-links li {
    width: 100%;
  }

  .nav-links a {
    display: block;
    padding: 14px 0;
  }
}

@media (max-width: 560px) {
  .nav-in {
    min-height: 68px;
    height: auto;
    padding-block: 8px;
    gap: 8px;
  }

  .nav-cta {
    gap: 6px;
  }

  .nav-cta .btn {
    min-height: 42px;
    padding: 9px 13px;
    white-space: nowrap;
  }

  .g2,
  .g3,
  .g4,
  .row2,
  .admin-stat-grid,
  .dashboard-stat-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .pc1 {
    display: none;
  }

  .pc2 {
    right: 0;
  }

  .pc3 {
    right: 0;
    left: auto;
  }

  .stack {
    height: 370px;
    max-width: 360px;
  }

  .fee-band {
    padding: clamp(18px, 6vw, 26px);
  }

  .table-scroll,
  .table-responsive {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table-scroll table,
  .table-responsive table {
    min-width: 540px;
  }

  .hero {
    padding-block: clamp(44px, 12vw, 64px);
  }

  .hero h1 {
    font-size: clamp(2rem, 10vw, 3rem);
  }

  .hero-btns .btn {
    flex: 1 1 130px;
  }

  .fee-chip {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .price {
    font-size: clamp(2rem, 10vw, 2.5rem);
  }

  .profile-form-actions {
    flex-direction: column;
  }

  .profile-form-actions .mc-button,
  #manualPaymentForm button {
    width: 100%;
    min-height: 44px;
  }

  .pending-payment dl {
    grid-template-columns: minmax(0, 1fr);
  }

  .payment-details > div {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .payment-filter,
  #manualPaymentForm {
    width: 100%;
    max-width: 100%;
  }

  #toasts {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
    left: max(12px, env(safe-area-inset-left));
  }

  .toast {
    width: 100%;
    max-width: none;
  }

  .mc-toast {
    bottom: max(16px, env(safe-area-inset-bottom));
  }

  .safety-page header {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
}

@media (max-width: 380px) {
  .container,
  .mc-main,
  .dashboard-main,
  .create-profile-main,
  .payment-main,
  .discover-container {
    width: calc(100% - 28px);
  }

  .card,
  .dashboard-chart-card,
  .admin-chart-card {
    padding: 16px;
  }

  .dashboard-welcome {
    padding: 22px 16px;
  }

  .mc-account .mc-avatar {
    width: 32px;
    height: 32px;
  }

  .mc-account {
    gap: 6px;
  }

  .mc-chat-composer .mc-button {
    margin-left: auto;
  }

  .mc-detail-list {
    grid-template-columns: minmax(0, 1fr);
  }

  .dashboard-chart-heading {
    flex-wrap: wrap;
  }
}

@media (max-width: 760px) and (orientation: landscape) {
  .mc-chat-panel {
    min-height: 360px;
  }

  .mc-messages {
    min-height: 220px;
    max-height: 55vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pc2 {
    animation: none;
  }
}
