:root {
  --violet: #5B21B6;
  --violet-deep: #3B0F82;
  --violet-light: #F1EBFA;
  --violet-bg: #EEE6FA;
  --text: #0A0A0A;
  --text-muted: #55555F;
  --text-faint: #77778A;
  --border: #EEEDF2;
  --surface: #F6F5F9;
  --white: #fff;
  --danger: #B42318;
  --success: #1A8F52;
  --radius-sm: 12px;
  --radius-md: 20px;
  --radius-lg: 28px;
  --radius-full: 999px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body { font-family: 'DM Sans', sans-serif; color: var(--text); background: var(--white); -webkit-font-smoothing: antialiased; min-width: 320px; }
a { color: var(--violet); text-decoration: none; }
a:hover { color: var(--violet-deep); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-family: inherit; font-size: 16px; font-weight: 700; border: none; cursor: pointer; transition: opacity .15s, transform .1s; border-radius: var(--radius-full); padding: 0 28px; height: 52px; white-space: nowrap; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--violet); color: #fff; }
.btn-primary:hover { background: var(--violet-deep); }
.btn-secondary { background: var(--violet-light); color: var(--violet-deep); }
.btn-ghost { background: var(--surface); color: var(--text); }
.btn-danger { background: #FEE2E2; color: var(--danger); }
.btn-full { width: 100%; }
.btn-lg { height: 60px; font-size: 18px; }
.btn-sm { height: 40px; font-size: 14px; padding: 0 18px; }

/* Inputs */
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: 14px; font-weight: 600; color: var(--text-muted); letter-spacing: .02em; }
.input { width: 100%; height: 56px; border-radius: var(--radius-md); border: 1.5px solid var(--border); background: var(--white); padding: 0 20px; font-family: inherit; font-size: 16px; color: var(--text); outline: none; transition: border-color .15s; }
.input:focus { border-color: var(--violet); }
.input.error { border-color: var(--danger); }
.input-hint { font-size: 13px; color: var(--text-faint); }
.input-error { font-size: 13px; color: var(--danger); }

/* OTP boxes */
.otp-row { display: flex; gap: 10px; justify-content: center; }
.otp-box { width: 56px; height: 68px; flex: none; border-radius: var(--radius-md); border: 1.5px solid var(--border); background: var(--surface); text-align: center; font-family: inherit; font-size: 28px; font-weight: 700; color: var(--text); outline: none; transition: border-color .15s; }
.otp-box:focus { border-color: var(--violet); background: var(--white); }
.otp-box.filled { border-color: var(--violet); background: var(--violet-light); }

/* Auth */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, var(--violet-bg) 0%, var(--white) 55%); padding: 32px 20px; }
.auth-card { width: 100%; max-width: 500px; background: var(--white); border-radius: var(--radius-lg); padding: 48px 44px; box-shadow: 0 0 0 1px rgba(10,10,10,.06), 0 24px 60px rgba(91,33,182,.13); display: flex; flex-direction: column; gap: 28px; }
.auth-logo { font-size: 24px; font-weight: 800; letter-spacing: -.8px; text-align: center; }
.auth-heading { text-align: center; display: flex; flex-direction: column; gap: 10px; }
.auth-heading h1 { font-size: 36px; font-weight: 800; letter-spacing: -1.4px; line-height: 1; }
.auth-heading p { font-size: 16px; color: var(--text-muted); }
.auth-footer { text-align: center; font-size: 14px; color: var(--text-faint); }
.auth-footer a { font-weight: 700; color: var(--violet); }

/* Nav */
.nav { height: 68px; padding: 0 48px; display: flex; align-items: center; gap: 48px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--white); z-index: 100; }
.nav-logo { font-size: 22px; font-weight: 800; letter-spacing: -.8px; flex: 1; color: var(--text); }
.nav-links { display: flex; gap: 36px; font-size: 16px; font-weight: 500; }
.nav-links a { color: var(--text-muted); padding: 4px 0; transition: color .15s; }
.nav-links a:hover { color: var(--text); }
.nav-links a.active { color: var(--text); font-weight: 700; border-bottom: 2.5px solid var(--violet); }
.nav-actions { display: flex; gap: 12px; align-items: center; }
.nav-hamburger { display: none; background: none; border: none; cursor: pointer; padding: 8px; }
.mobile-nav { display: none; position: fixed; inset: 0; background: var(--white); z-index: 200; flex-direction: column; padding: 28px 24px; gap: 8px; }
.mobile-nav.open { display: flex; }
.mobile-nav-close { align-self: flex-end; background: var(--surface); border: none; border-radius: var(--radius-full); width: 44px; height: 44px; cursor: pointer; font-size: 22px; margin-bottom: 16px; }
.mobile-nav a { font-size: 24px; font-weight: 700; color: var(--text); padding: 16px 0; border-bottom: 1px solid var(--border); display: block; }

/* Feed */
.feed-wrap { width: 100%; max-width: 1600px; margin: 0 auto; padding: 36px 48px 80px; display: flex; gap: 32px; align-items: flex-start; }
.feed-sidebar { width: 200px; flex: none; display: flex; flex-direction: column; gap: 8px; position: sticky; top: 100px; }
.feed-sidebar-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-faint); padding: 8px 4px 4px; }
.feed-main { flex: 1; min-width: 0; }
.feed-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }

/* Pills */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 10px 18px; border-radius: var(--radius-full); font-size: 14px; font-weight: 600; cursor: pointer; transition: background .15s, color .15s; border: none; font-family: inherit; white-space: nowrap; }
.pill-active { background: var(--violet); color: #fff; }
.pill-default { background: var(--surface); color: var(--text); }
.pill-default:hover { background: var(--border); }
.pill-tonight { background: #E3F6EB; color: #116B3C; font-weight: 700; }
.pill-tonight.active { background: var(--success); color: #fff; }

/* Activity card */
.activity-card { position: relative; aspect-ratio: 3/4; border-radius: 24px; overflow: hidden; cursor: pointer; display: block; transition: transform .2s; }
.activity-card:hover { transform: translateY(-4px); }
.activity-card-bg { position: absolute; inset: 0; object-fit: cover; width: 100%; height: 100%; }
.activity-card-gradient { position: absolute; inset: 0; background: linear-gradient(to top, rgba(10,10,10,.88) 0%, rgba(10,10,10,.1) 55%, transparent 100%); }
.activity-card-emoji { position: absolute; top: 16px; left: 16px; width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.95); display: flex; align-items: center; justify-content: center; font-size: 22px; }
.activity-card-bookmark { position: absolute; top: 16px; right: 16px; width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.95); display: flex; align-items: center; justify-content: center; border: none; cursor: pointer; transition: transform .15s; }
.activity-card-bookmark:hover { transform: scale(1.1); }
.activity-card-body { position: absolute; left: 18px; right: 18px; bottom: 18px; color: #fff; display: flex; flex-direction: column; gap: 6px; }
.activity-card-title { font-size: 20px; font-weight: 800; letter-spacing: -.6px; line-height: 1.1; }
.activity-card-meta { font-size: 13px; opacity: .85; font-weight: 500; }
.activity-card-badge { position: absolute; top: 16px; left: 68px; background: var(--violet); color: #fff; font-size: 11px; font-weight: 800; padding: 4px 10px; border-radius: var(--radius-full); letter-spacing: .02em; }

/* Profile */
.profile-wrap { width: 100%; max-width: 1400px; margin: 0 auto; padding: 40px 48px 80px; display: flex; gap: 36px; align-items: flex-start; }
.profile-sidebar { width: 360px; flex: none; display: flex; flex-direction: column; gap: 20px; position: sticky; top: 100px; }
.profile-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 36px; }
.profile-card { padding: 32px 28px; border-radius: var(--radius-lg); background: var(--surface); display: flex; flex-direction: column; align-items: center; gap: 18px; text-align: center; }
.profile-avatar { width: 120px; height: 120px; border-radius: 50%; overflow: hidden; background: var(--violet-light); display: flex; align-items: center; justify-content: center; font-size: 44px; font-weight: 800; color: var(--violet); flex: none; }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-name { font-size: 28px; font-weight: 800; letter-spacing: -1px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.verified-badge { width: 26px; height: 26px; border-radius: 50%; background: var(--violet); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.profile-location { font-size: 15px; color: var(--text-muted); }
.stat-box { padding: 16px 18px; border-radius: var(--radius-md); background: var(--white); display: flex; flex-direction: column; gap: 4px; }
.stat-value { font-size: 26px; font-weight: 800; letter-spacing: -.8px; }
.stat-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.passport-stamp { flex: 1; padding: 16px 8px; border-radius: 20px; background: var(--white); display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 72px; }
.menu-item { display: flex; align-items: center; height: 60px; border-bottom: 1px solid var(--border); font-size: 16px; font-weight: 500; cursor: pointer; color: var(--text); transition: color .15s; }
.menu-item:hover { color: var(--violet); }
.menu-item-label { flex: 1; }
.menu-item-danger { color: var(--danger); }

/* Matches/chat */
.matches-wrap { width: 100%; max-width: 1600px; margin: 0 auto; display: flex; height: calc(100vh - 68px); }
.matches-list { width: 360px; flex: none; border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.matches-list-header { padding: 28px 24px 16px; font-size: 30px; font-weight: 800; letter-spacing: -1.2px; flex: none; border-bottom: 1px solid var(--border); }
.matches-list-scroll { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.match-item { display: flex; align-items: center; gap: 14px; padding: 14px 12px; border-radius: 18px; cursor: pointer; transition: background .15s; text-decoration: none; color: inherit; }
.match-item:hover { background: var(--surface); }
.match-item.active { background: var(--violet); color: #fff; }
.match-avatar { position: relative; width: 54px; height: 54px; flex: none; border-radius: 50%; overflow: hidden; background: var(--violet-light); display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700; color: var(--violet); }
.match-avatar img { width: 100%; height: 100%; object-fit: cover; }
.match-emoji-badge { position: absolute; right: -3px; bottom: -3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; box-shadow: 0 0 0 1.5px var(--border); }
.match-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.match-name-row { display: flex; align-items: center; gap: 8px; }
.match-name { flex: 1; font-size: 16px; font-weight: 700; }
.match-time { font-size: 12px; opacity: .7; }
.match-preview { font-size: 14px; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-header { height: 76px; flex: none; padding: 0 32px; display: flex; align-items: center; gap: 16px; border-bottom: 1px solid var(--border); }
.chat-body { flex: 1; padding: 28px 32px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; background: #FBFAFD; }
.chat-bubble { max-width: 520px; padding: 14px 20px; border-radius: 22px; font-size: 15px; line-height: 1.5; }
.chat-bubble-in { background: var(--white); box-shadow: 0 0 0 1px var(--border); border-bottom-left-radius: 6px; align-self: flex-start; }
.chat-bubble-out { background: var(--violet); color: #fff; border-bottom-right-radius: 6px; align-self: flex-end; }
.plan-card { background: var(--white); border-radius: 24px; box-shadow: 0 0 0 1px #E4DAF5, 0 12px 30px rgba(91,33,182,.1); overflow: hidden; align-self: center; width: 440px; max-width: 100%; }
.plan-card-map { height: 120px; background: var(--violet-light); }
.plan-card-body { padding: 20px 22px; display: flex; align-items: center; gap: 16px; }
.plan-card-label { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--violet); }
.plan-card-venue { font-size: 18px; font-weight: 800; letter-spacing: -.5px; }
.plan-card-meta { font-size: 14px; color: var(--text-muted); }
.chat-footer { height: 88px; flex: none; padding: 0 32px; display: flex; align-items: center; gap: 12px; border-top: 1px solid var(--border); background: var(--white); }
.chat-input { flex: 1; height: 54px; border-radius: var(--radius-full); background: var(--surface); border: none; padding: 0 24px; font-family: inherit; font-size: 16px; color: var(--text); outline: none; }
.chat-send { width: 54px; height: 54px; border-radius: 50%; background: var(--violet); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; flex: none; transition: background .15s; }
.chat-send:hover { background: var(--violet-deep); }

/* Verify */
.verify-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, var(--violet-bg) 0%, var(--white) 55%); padding: 32px 20px; }
.verify-card { width: 100%; max-width: 540px; background: var(--white); border-radius: var(--radius-lg); padding: 52px 44px; box-shadow: 0 0 0 1px rgba(10,10,10,.06), 0 24px 60px rgba(91,33,182,.13); display: flex; flex-direction: column; align-items: center; gap: 28px; text-align: center; }
.verify-icon { width: 88px; height: 88px; border-radius: 24px; background: var(--violet-light); display: flex; align-items: center; justify-content: center; font-size: 42px; }
.verify-steps { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.verify-step { display: flex; align-items: center; gap: 16px; padding: 18px; border-radius: var(--radius-md); background: var(--surface); text-align: left; }
.verify-step-num { width: 34px; height: 34px; border-radius: 50%; background: var(--violet); color: #fff; font-size: 15px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: none; }
.verify-step-text { font-size: 15px; font-weight: 500; line-height: 1.4; }

/* Alerts */
.alert { padding: 16px 20px; border-radius: var(--radius-md); font-size: 14px; font-weight: 500; line-height: 1.4; }
.alert-error { background: #FEE2E2; color: var(--danger); }
.alert-success { background: #DCFCE7; color: #166534; }
.alert-info { background: var(--violet-light); color: var(--violet-deep); }

/* Skeleton */
.skeleton { background: linear-gradient(90deg, var(--border) 25%, var(--surface) 50%, var(--border) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Spinner */
.spinner { width: 24px; height: 24px; border: 2.5px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.spinner-violet { border-color: var(--violet-light); border-top-color: var(--violet); }
.spinner-lg { width: 40px; height: 40px; border-width: 3.5px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Responsive — tablet */
@media (max-width: 1100px) {
  .feed-wrap { padding: 28px 32px 80px; }
  .profile-wrap { padding: 32px 32px 80px; }
  .feed-sidebar { width: 160px; }
  .profile-sidebar { width: 320px; }
}

/* Responsive — mobile */
@media (max-width: 860px) {
  .nav { padding: 0 24px; height: 60px; gap: 0; }
  .nav-links, .nav-actions { display: none; }
  .nav-hamburger { display: block; margin-left: auto; }
  .feed-wrap { padding: 20px 16px 80px; flex-direction: column; gap: 16px; }
  .feed-sidebar { width: 100%; position: static; flex-direction: row; flex-wrap: nowrap; overflow-x: auto; gap: 8px; padding-bottom: 4px; }
  .feed-sidebar::-webkit-scrollbar { display: none; }
  .feed-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .profile-wrap { padding: 20px 16px 80px; flex-direction: column; gap: 20px; }
  .profile-sidebar { width: 100%; position: static; }
  .matches-wrap { flex-direction: column; height: auto; max-width: 100%; }
  .matches-list { width: 100%; border-right: none; border-bottom: 1px solid var(--border); max-height: 280px; }
  .matches-list-header { padding: 20px 16px 12px; font-size: 24px; }
  .chat-wrap { min-height: 60vh; }
  .chat-body { padding: 20px 16px; }
  .chat-footer { padding: 0 16px; }
  .chat-header { padding: 0 16px; }
  .auth-card { padding: 32px 24px; }
  .verify-card { padding: 36px 24px; }
}

@media (max-width: 480px) {
  .feed-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .activity-card-title { font-size: 16px; }
  .activity-card-meta { font-size: 12px; }
  .auth-heading h1 { font-size: 30px; }
  .btn-lg { height: 56px; font-size: 17px; }
}

/* ===================== MOBILE PASS ===================== */
html { -webkit-text-size-adjust: 100%; }
body { overflow-x: clip; -webkit-tap-highlight-color: transparent; padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
img, svg, video, canvas { max-width: 100%; }
.chat-bubble { overflow-wrap: anywhere; }
.chat-back { display: none; }
.nav-hamburger { position: relative; }
.hb-dot { position: absolute; top: 8px; right: 8px; width: 10px; height: 10px; border-radius: 50%; background: #E53E3E; border: 2px solid #fff; }

/* 100vh counts the iPhone browser bar; dvh does not */
@supports (height: 100dvh) {
  .matches-wrap { height: calc(100dvh - 68px); }
  .auth-wrap, .verify-wrap { min-height: 100dvh; }
  [style*="height:calc(100vh - 72px)"]  { height: calc(100dvh - 72px) !important; }
  [style*="height:calc(100vh - 100px)"] { height: calc(100dvh - 100px) !important; }
}

@media (max-width: 860px) {
  /* ---- nav / menu ---- */
  .nav-hamburger { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; margin-left: auto; }
  .mobile-nav { overflow-y: auto; padding: calc(16px + env(safe-area-inset-top)) 24px calc(24px + env(safe-area-inset-bottom)); }
  .mobile-nav a { font-size: 22px; padding: 14px 0; }
  .mobile-nav a.btn { color: #fff; font-size: 17px; padding: 0 24px; border-bottom: none; display: flex; margin-top: 12px; }
  .mobile-nav .nav-badge { position: static !important; margin-left: 10px; vertical-align: middle; }

  /* ---- page shells: remove the 48px desktop side padding ---- */
  [style*="padding:40px 48px"] { padding: 24px 16px 80px !important; }

  /* ---- two column layouts -> one column ---- */
  [style*="grid-template-columns:1fr 360px"] { grid-template-columns: 1fr !important; gap: 20px !important; }
  [style*="width:280px"] { width: 100% !important; }
  [style*="repeat(auto-fill,minmax(180px,1fr))"] { grid-template-columns: repeat(2, 1fr) !important; }
  [style*="width:fit-content"] { max-width: 100%; overflow-x: auto; }

  /* ---- headings ---- */
  [style*="font-size:38px"], [style*="font-size:36px"] { font-size: 30px !important; letter-spacing: -1.1px !important; }
  [style*="font-size:32px"] { font-size: 28px !important; }

  /* ---- feed ---- */
  .feed-sidebar { margin: 0 -16px; padding: 0 16px 6px; }
  .feed-sidebar > * { flex: none; }
  .feed-sidebar-label { display: none; }
  #cat-pills { flex-wrap: nowrap !important; }
  .activity-card:hover { transform: none; }

  /* ---- matches: list -> chat -> back ---- */
  .matches-wrap { position: relative; flex-direction: column; height: calc(100vh - 60px); }
  @supports (height: 100dvh) { .matches-wrap { height: calc(100dvh - 60px); } }
  .matches-list { width: 100%; max-height: none; flex: 1; min-height: 0; border: none; }
  .chat-wrap { display: none; position: absolute; inset: 0; min-height: 0; background: var(--white); z-index: 5; }
  .matches-wrap.chat-open .chat-wrap { display: flex; }
  .matches-wrap.chat-open .matches-list { display: none; }
  .chat-back { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex: none; border: none; border-radius: 50%; background: var(--surface); font-size: 26px; line-height: 1; cursor: pointer; color: var(--text); }
  .chat-header { height: auto; min-height: 64px; flex-wrap: wrap; padding: 10px 12px; gap: 8px 10px; }
  .chat-header .btn { height: 36px !important; font-size: 13px !important; padding: 0 14px !important; }
  .chat-body { padding: 16px 12px; }
  .chat-bubble { max-width: 85%; }
  .plan-card { width: 100%; }
  .chat-footer { height: auto; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); gap: 8px; }
  .chat-footer .btn { height: 48px !important; padding: 0 16px !important; }
  .chat-input { height: 48px; padding: 0 18px; min-width: 0; }
  .chat-send { width: 48px; height: 48px; }

  /* ---- group chat page ---- */
  [style*="height:calc(100vh - 100px)"] { height: calc(100vh - 60px) !important; padding: 12px !important; }
  @supports (height: 100dvh) { [style*="height:calc(100vh - 100px)"] { height: calc(100dvh - 60px) !important; } }

  /* ---- map: map on top, list underneath ---- */
  [style*="height:calc(100vh - 72px)"] { flex-direction: column !important; height: calc(100vh - 60px) !important; }
  @supports (height: 100dvh) { [style*="height:calc(100vh - 72px)"] { height: calc(100dvh - 60px) !important; } }
  #map { flex: none !important; height: 42% !important; min-height: 240px; }
  [style*="width:340px"] { width: 100% !important; flex: 1 !important; min-height: 0; border-left: none !important; border-top: 1px solid var(--border); }

  /* ---- bottom sheets / modals ---- */
  [style*="border-radius:28px 28px 0 0"] { padding-bottom: calc(32px + env(safe-area-inset-bottom)) !important; }

  /* ---- auth + codes ---- */
  .otp-row { gap: 8px; }
  .otp-box { flex: 1 1 0; width: auto; min-width: 0; max-width: 56px; height: 60px; font-size: 24px; }
  .auth-wrap, .verify-wrap { padding: 20px 16px; }
}

@media (max-width: 480px) {
  [style*="grid-template-columns:1fr 1fr"] { grid-template-columns: 1fr !important; }
  .auth-card { padding: 28px 20px; gap: 22px; }
  .verify-card { padding: 32px 20px; }
  .btn { padding: 0 22px; }
}

/* Demo account badge */
.demo-tag { display: inline-block; vertical-align: middle; background: #FEF3C7; color: #92400E; font-size: 10px; font-weight: 800; letter-spacing: .06em; line-height: 1; padding: 3px 7px; border-radius: 999px; margin-left: 4px; text-transform: uppercase; }

/* ===================== MOBILE OVERFLOW FIX ===================== */
@media (max-width: 860px) {
  /* The real cause: columns sized by their contents let a sideways-scrolling row stretch the whole page */
  .feed-wrap, .profile-wrap { align-items: stretch; }
  .feed-wrap > *, .profile-wrap > *, .profile-main, .feed-main { width: 100%; min-width: 0; max-width: 100%; }
  main, section, aside, form { min-width: 0; max-width: 100%; }

  /* Sideways-scrolling rows stay inside their own box */
  #groups-section, #cat-pills, .feed-sidebar { max-width: 100%; }
  #groups-section > div[style*="overflow-x"] { max-width: 100%; }

  /* Grids can't be pushed wider by their cards */
  .feed-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  [style*="repeat(auto-fill"] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }

  /* Media and form fields never exceed the screen */
  img, svg, video, canvas, iframe, table { max-width: 100%; }
  input, select, textarea { max-width: 100%; }

  /* Long words and emails wrap instead of pushing the page */
  .activity-card-title, .activity-card-meta, .match-name, .match-preview, .profile-name, .chat-bubble, h1, h2, h3, p { overflow-wrap: anywhere; }

  /* Last resort: the page itself never scrolls sideways (sticky nav keeps working) */
  html { overflow-x: hidden; }
  body { overflow-x: clip; max-width: 100%; }
}

/* Feed: three buttons on one row, category pills on their own scrolling row */
@media (max-width: 860px) {
  .feed-sidebar { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; gap: 8px; }
  .feed-sidebar > button { flex: 0 0 auto; }
  #cat-pills { flex: 0 0 100% !important; width: 100%; overflow-x: auto; flex-wrap: nowrap !important; padding-bottom: 4px; scrollbar-width: none; }
  #cat-pills::-webkit-scrollbar { display: none; }
  #cat-pills > * { flex: none; }
}
