/* The Members directory, /members/ (docs/MEMBERS_DIRECTORY_PLAN.md §8).
 *
 * Everything is scoped under .md so nothing leaks into the rest of the site.
 * The member's accent (--md-accent, set per card from DirectoryEntry.
 * accent_color, already run through seller.contrast) is used ONLY as a
 * fill/outline: the photo ring and the card's top stripe. Text never takes
 * it; card text uses the page's own colours below.
 *
 * Phone first: two-column cards, a sticky sort bar, the filter rail becomes
 * a bottom sheet, every tap target at least 44px, and nothing wider than the
 * viewport (the sort chips scroll inside their own bar, not the page).
 */
.md {
  --md-ink: #14161d;
  --md-soft: #4b5160;
  --md-muted: #6b7280;
  --md-line: #e6e8ee;
  --md-bg: #f6f7fb;
  --md-card: #ffffff;
  --md-brand: #1d4ed8;
  --md-brand-ink: #ffffff;
  --md-green: #16a34a;
  --md-gold: #b7791f;
  --md-radius: 14px;
  --md-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --md-shadow-lift: 0 10px 24px rgba(16, 24, 40, .12);
  color: var(--md-ink);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 16px 96px;
  box-sizing: border-box;
}
.md *, .md *::before, .md *::after { box-sizing: border-box; }
.md a { color: inherit; text-decoration: none; }
.md-sr {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* --- heading --------------------------------------------------------------- */
.md-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 8px 0 16px; }
.md-h1 { margin: 0; font-size: 28px; line-height: 1.15; font-weight: 800; letter-spacing: -.02em; }
.md-intro { margin: 6px 0 0; color: var(--md-soft); font-size: 15px; line-height: 1.5; max-width: 62ch; }
.md-maplink {
  display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto;
  min-height: 44px; padding: 0 16px; border: 1px solid var(--md-line); border-radius: 999px;
  background: var(--md-card); font-size: 14px; font-weight: 700; color: var(--md-ink);
}
.md-maplink svg { width: 18px; height: 18px; }
.md-maplink:hover { border-color: var(--md-soft); }

/* --- search ------------------------------------------------------------------ */
.md-search { position: relative; margin: 0 0 12px; }
.md-search-icon { position: absolute; left: 14px; top: 50%; width: 20px; height: 20px; transform: translateY(-50%); color: var(--md-muted); pointer-events: none; }
.md-search-input {
  width: 100%; min-height: 48px; padding: 10px 14px 10px 44px;
  border: 1px solid var(--md-line); border-radius: 12px; background: var(--md-card);
  font-size: 16px; /* 16px: iOS doesn't zoom the page on focus */
  color: var(--md-ink); box-shadow: var(--md-shadow);
}
.md-search-input:focus { outline: 2px solid var(--md-brand); outline-offset: 1px; border-color: transparent; }
.md-suggest {
  position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 6px);
  margin: 0; padding: 6px; list-style: none; background: var(--md-card);
  border: 1px solid var(--md-line); border-radius: 12px; box-shadow: var(--md-shadow-lift);
  max-height: 60vh; overflow-y: auto;
}
.md-suggest[hidden] { display: none; }
.md-suggest a { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 8px; border-radius: 8px; }
.md-suggest li[aria-selected="true"] a, .md-suggest a:hover { background: var(--md-bg); }
.md-suggest img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; }
.md-suggest .s-name { font-weight: 700; font-size: 14px; }
.md-suggest .s-sub { display: block; font-size: 12px; color: var(--md-muted); }
.md-suggest .s-tier { margin-left: 6px; }

/* --- sort bar (sticky) -------------------------------------------------------- */
.md-sortbar {
  position: sticky; top: 0; z-index: 30;
  margin: 0 -16px 12px; padding: 8px 16px;
  background: rgba(255, 255, 255, .96);
  -webkit-backdrop-filter: saturate(1.4) blur(6px); backdrop-filter: saturate(1.4) blur(6px);
  border-bottom: 1px solid var(--md-line);
}
.md-sortbar-top { display: flex; align-items: center; gap: 10px; }
.md-count { margin: 0; font-size: 14px; color: var(--md-soft); margin-right: auto; }
.md-count b { color: var(--md-ink); }
.md-views { display: inline-flex; border: 1px solid var(--md-line); border-radius: 10px; overflow: hidden; background: var(--md-card); }
.md-view { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; min-width: 44px; justify-content: center; padding: 0 12px; font-size: 13px; font-weight: 700; color: var(--md-soft); }
.md-view + .md-view { border-left: 1px solid var(--md-line); }
.md-view svg { width: 18px; height: 18px; }
.md-view.is-on { background: var(--md-ink); color: #fff; }
.md-filters-btn {
  display: none; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px;
  border: 1px solid var(--md-line); border-radius: 10px; background: var(--md-card);
  font-size: 14px; font-weight: 700; color: var(--md-ink); cursor: pointer;
}
.md-filters-btn svg { width: 18px; height: 18px; }
.md-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--md-brand); color: var(--md-brand-ink); font-size: 12px; }
.md-sorts { display: flex; gap: 8px; margin-top: 8px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.md-sorts::-webkit-scrollbar { display: none; }
.md-sort {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; flex: 0 0 auto;
  border: 1px solid var(--md-line); border-radius: 999px; background: var(--md-card);
  font-size: 13px; font-weight: 700; color: var(--md-soft); white-space: nowrap;
}
.md-sort:hover { border-color: var(--md-soft); color: var(--md-ink); }
.md-sort.is-on { background: var(--md-ink); border-color: var(--md-ink); color: #fff; }
.md-sort.is-disabled { opacity: .5; cursor: not-allowed; }

/* --- body: rail + results ------------------------------------------------------- */
.md-body { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 24px; align-items: start; }
.md-rail { position: sticky; top: 120px; max-height: calc(100vh - 140px); overflow-y: auto; padding-right: 4px; }
.md-sheet-head, .md-sheet-backdrop { display: none; }
.md-clear { display: inline-flex; align-items: center; min-height: 44px; font-size: 13px; font-weight: 700; color: var(--md-brand) !important; }
.md-facet-group { margin: 0 0 18px; }
.md-facet-h { margin: 0 0 6px; font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--md-muted); }
.md-facets { margin: 0; padding: 0; list-style: none; }
.md-facets--scroll { max-height: 280px; overflow-y: auto; }
.md-facet {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 44px; padding: 0 10px; border-radius: 10px; font-size: 14px; color: var(--md-ink);
}
.md-facet:hover { background: var(--md-card); box-shadow: var(--md-shadow); }
.md-facet.is-on { background: var(--md-ink); color: #fff; }
.md-facet.is-on .md-facet-n { color: rgba(255, 255, 255, .75); }
.md-facet--toggle.is-on .md-facet-l::before { content: '✓ '; }
.md-facet-l { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md-facet-n { flex: 0 0 auto; font-size: 12px; color: var(--md-muted); font-variant-numeric: tabular-nums; }
.md-facets--chips { display: flex; flex-wrap: wrap; gap: 6px; }
.md-facet--chip { display: inline-flex; min-height: 44px; padding: 0 12px; border: 1px solid var(--md-line); border-radius: 999px; background: var(--md-card); font-size: 13px; }
.md-more-facets summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; font-size: 13px; font-weight: 700; color: var(--md-brand); }
.md-more-facets[open] summary { margin-bottom: 4px; }

.md-results { min-width: 0; }
.md-results.htmx-request { opacity: .55; transition: opacity .15s; }
.md-hints { margin: 0 0 12px; }
.md-hint { margin: 0 0 6px; padding: 10px 14px; border-radius: 10px; background: #fff7e6; border: 1px solid #fde2a7; color: #7a4b00; font-size: 14px; }
.md-active { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 12px; }
.md-active-l { font-size: 13px; color: var(--md-muted); margin-right: 2px; }
.md-chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px;
  border-radius: 999px; background: #eef2ff; color: #1e2a78; font-size: 13px; font-weight: 700;
}
.md-chip span { font-size: 16px; line-height: 1; }
.md-chip--clear { background: transparent; color: var(--md-brand); }

/* --- cards -------------------------------------------------------------------- */
.md-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.md-card {
  --md-accent: #4f46e5;
  position: relative; display: flex; flex-direction: column; min-width: 0;
  background: var(--md-card); border: 1px solid var(--md-line); border-radius: var(--md-radius);
  box-shadow: var(--md-shadow); overflow: hidden; transition: transform .2s, box-shadow .2s;
}
.md-card::before { content: ''; display: block; height: 4px; background: var(--md-accent); }
.md-card:hover { transform: translateY(-2px); box-shadow: var(--md-shadow-lift); }
.md-photo { position: relative; display: block; margin: 16px auto 0; width: 64%; max-width: 160px; aspect-ratio: 1; border-radius: 50%; padding: 3px; background: var(--md-accent); }
.md-photo img { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 3px solid #fff; background: var(--md-bg); }
.md-dot { position: absolute; right: 8%; bottom: 8%; width: 16px; height: 16px; border-radius: 50%; background: var(--md-green); border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .06); }
.md-card-body { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px 14px; text-align: center; flex: 1 1 auto; }
.md-name { margin: 0; font-size: 16px; line-height: 1.3; font-weight: 800; letter-spacing: -.01em; overflow-wrap: anywhere; }
.md-name a:hover { text-decoration: underline; }
.md-flag { display: inline-block; width: 18px; height: auto; margin-left: 4px; vertical-align: -1px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .12); }
.md-tier { display: inline-block; margin-left: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; letter-spacing: .02em; vertical-align: 2px; }
.md-tier--trusted { background: #e0ecff; color: #173f9c; }
.md-tier--verified { background: #e9f7ef; color: #14532d; }
.md-you { display: inline-block; margin-left: 4px; padding: 2px 8px; border-radius: 999px; background: #eef0f4; color: var(--md-soft); font-size: 11px; font-weight: 800; vertical-align: 2px; }
.md-company { margin: 0; font-size: 13px; font-weight: 600; color: var(--md-soft); overflow-wrap: anywhere; }
.md-tagline { margin: 2px 0 0; font-size: 13px; font-style: italic; color: var(--md-soft); overflow-wrap: anywhere; }
.md-loc, .md-since { margin: 0; font-size: 13px; color: var(--md-muted); overflow-wrap: anywhere; }
.md-dist { font-weight: 700; color: var(--md-soft); white-space: nowrap; }
.md-interests { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin: 6px 0 0; padding: 0; list-style: none; }
.md-interests li { padding: 3px 9px; border-radius: 999px; background: var(--md-bg); border: 1px solid var(--md-line); font-size: 12px; color: var(--md-soft); }
.md-interests .md-interests-more { background: transparent; }
.md-badges { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin-top: 6px; font-size: 12px; }
.md-stars { color: #f2a842; white-space: nowrap; font-size: 12px; }
.md-stars-n { color: var(--md-muted); }
.md-badges .gm-trophy-wrap { margin-left: 0; }
.md-contrib { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.md-contrib--rising { background: #ecfdf3; color: #166534; }
.md-contrib--top { background: #fff4d6; color: #7a4b00; }
.md-band { margin: 4px 0 0; font-size: 12px; font-weight: 700; color: var(--md-green); }
.md-band--month { color: var(--md-soft); }
.md-mutual { margin: 0; font-size: 12px; color: var(--md-muted); }
.md-act { margin-top: auto; padding-top: 10px; display: flex; justify-content: center; }
.md-act form { margin: 0; width: 100%; }
.md-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 100%;
  min-height: 44px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--md-line);
  background: var(--md-card); color: var(--md-ink); font-size: 14px; font-weight: 700; cursor: pointer;
}
.md-btn--solid { background: var(--md-brand); border-color: var(--md-brand); color: var(--md-brand-ink); }
.md-btn.is-done { color: var(--md-muted); cursor: default; }
/* The friends app's own cluster, swapped in after an Add Friend / Accept. */
.md-act .rts-fbtn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: 100%; min-height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--md-line); background: var(--md-card); font-size: 13px; font-weight: 700; color: var(--md-soft); }
.md-act .rts-fb-form { width: 100%; }

/* --- list ---------------------------------------------------------------------- */
.md-listwrap { display: flex; gap: 12px; align-items: flex-start; }
.md-list { flex: 1 1 auto; min-width: 0; background: var(--md-card); border: 1px solid var(--md-line); border-radius: var(--md-radius); box-shadow: var(--md-shadow); overflow: hidden; }
.md-row {
  --md-accent: #4f46e5;
  display: grid; align-items: center; gap: 12px;
  grid-template-columns: 48px minmax(0, 2.2fr) minmax(0, 1.4fr) 88px 120px 124px 132px;
  padding: 8px 14px; border-top: 1px solid var(--md-line); border-left: 4px solid var(--md-accent);
  font-size: 14px; scroll-margin-top: 140px;
}
.md-row--head { border-top: 0; border-left-color: transparent; background: var(--md-bg); font-size: 12px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--md-muted); min-height: 44px; }
.md-colsort { display: inline-flex; align-items: center; min-height: 36px; }
.md-colsort.is-on { color: var(--md-ink); }
.md-colsort.is-on::after { content: ' ▾'; }
.md-row-ava { position: relative; display: block; width: 44px; height: 44px; }
.md-row-ava img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 2px var(--md-accent); }
.md-row .md-dot { right: -2px; bottom: -2px; width: 13px; height: 13px; border-width: 2px; }
.md-row-name { margin: 0; font-weight: 800; overflow-wrap: anywhere; }
.md-row-name a:hover { text-decoration: underline; }
.md-row-tag { margin: 2px 0 0; font-size: 13px; color: var(--md-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.md-row-loc { color: var(--md-soft); font-size: 13px; overflow-wrap: anywhere; }
.md-row-loc .md-dist { display: block; }
.md-row-since { color: var(--md-soft); font-size: 13px; }
.md-row-k { display: none; }
.md-row-band .md-band { margin: 0; }
.md-row-act .md-act { padding-top: 0; }
.md-rows .md-more { margin: 0; border-radius: 0; border-width: 1px 0 0; }
.md-anchor { display: block; }
.md-letters { flex: 0 0 auto; position: sticky; top: 130px; }
.md-letters-rail { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.md-letters-rail a { display: flex; align-items: center; justify-content: center; width: 32px; min-height: 26px; border-radius: 6px; font-size: 12px; font-weight: 800; color: var(--md-soft); }
.md-letters-rail a:hover { background: var(--md-card); color: var(--md-ink); }
.md-letters-select { display: none; }

/* --- wall (D-04) ----------------------------------------------------------------
 * A dense mosaic of square photos (plan §8.2): 6-8 across beside the desktop
 * rail, 3 across on a phone. The tile shows only the photo until it is
 * hovered (a pointer that can hover), focused (keyboard) or tapped once
 * (touch: members.js toggles .is-revealed); then a dark scrim fades in with
 * the name, flag, tier and -- for a signed-in viewer -- the band. The scrim is
 * faded with opacity, never display:none, so screen readers always read it.
 * The accent is an inset ring (a border, never text).
 */
/* 110px: 8 across beside the rail at 1280, 6 at 1024 and on a tablet. */
.md-wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; }
.md-tile {
  --md-accent: #4f46e5;
  position: relative; min-width: 0; aspect-ratio: 1; overflow: hidden;
  border-radius: 10px; background: var(--md-line);
}
/* The accent ring sits above the photo and below the scrim; it never
   takes a click. */
.md-tile::after {
  content: ''; position: absolute; inset: 0; z-index: 1; border-radius: inherit;
  box-shadow: inset 0 0 0 2px var(--md-accent); pointer-events: none;
}
.md-tile-a { display: block; width: 100%; height: 100%; -webkit-tap-highlight-color: transparent; }
.md-tile-a img {
  display: block; width: 100%; height: 100%; object-fit: cover;
  transition: transform .25s ease;
}
.md-tile-a:focus-visible { outline: 3px solid var(--md-brand); outline-offset: -3px; }
.md-tile-dot { top: 6px; right: 6px; bottom: auto; z-index: 3; width: 14px; height: 14px; border-width: 2px; }
.md-tile-over {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  padding: 28px 8px 8px;
  background: linear-gradient(to top, rgba(10, 12, 20, .88) 0%, rgba(10, 12, 20, .62) 60%, rgba(10, 12, 20, 0) 100%);
  color: #fff; font-size: 12px; line-height: 1.25;
  opacity: 0; transform: translateY(6px);
  transition: opacity .18s ease, transform .18s ease;
  /* Taps and clicks go to the tile link underneath; only the name takes the
     pointer, and only once revealed on a device that can hover. */
  pointer-events: none;
}
.md-tile-name {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  max-width: 100%; font-size: 13px; font-weight: 800; color: #fff !important; overflow-wrap: anywhere;
}
.md-tile-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
/* A fixed box, so a flag that fails to load can't spill its alt text. */
.md-tile .md-flag { margin-left: 0; width: 18px; height: 13px; overflow: hidden; }
.md-tile .md-tier, .md-tile .md-you { margin-left: 0; font-size: 10px; padding: 1px 6px; vertical-align: 0; }
.md-tile .md-contrib { font-size: 10px; padding: 1px 6px; }
.md-tile-band { font-size: 11px; font-weight: 700; color: #bbf7d0; }

.md-tile.is-revealed .md-tile-over,
.md-tile:focus-within .md-tile-over { opacity: 1; transform: none; }
@media (hover: hover) {
  .md-tile:hover .md-tile-over { opacity: 1; transform: none; }
  .md-tile:hover .md-tile-a img { transform: scale(1.04); }
  .md-tile:hover .md-tile-name { pointer-events: auto; }
  .md-tile-name:hover { text-decoration: underline; }
}

/* --- more / pager / empty -------------------------------------------------------- */
.md-more {
  grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; margin-top: 4px; border: 1px dashed var(--md-line); border-radius: 12px;
  font-size: 14px; font-weight: 700; color: var(--md-soft);
}
.md-more-spin { display: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--md-line); border-top-color: var(--md-soft); animation: md-spin .8s linear infinite; }
.md-more.htmx-request .md-more-spin { display: inline-block; }
@keyframes md-spin { to { transform: rotate(360deg); } }
.md-pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 20px 0 0; font-size: 13px; color: var(--md-muted); }
.md-pager-a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px; font-weight: 700; color: var(--md-brand) !important; }
.md-empty { padding: 40px 20px; border: 1px dashed var(--md-line); border-radius: var(--md-radius); text-align: center; background: var(--md-card); }
.md-empty-t { margin: 0 0 8px; font-size: 16px; font-weight: 700; }
.md-empty-a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 700; color: var(--md-brand) !important; }

/* --- responsive ------------------------------------------------------------------- */
@media (max-width: 1180px) {
  .md-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .md-row { grid-template-columns: 48px minmax(0, 2fr) minmax(0, 1.3fr) 80px 110px 132px; }
  .md-row-band { display: none; }
  .md-row--head .md-row-band { display: none; }
}

@media (max-width: 900px) {
  .md-body { grid-template-columns: minmax(0, 1fr); }
  .md-filters-btn { display: inline-flex; }
  /* The rail becomes a bottom sheet, above the fixed mobile footer nav. */
  .md-rail {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 1100;
    max-height: 82vh; overflow-y: auto; padding: 0 16px calc(24px + env(safe-area-inset-bottom, 0px));
    background: var(--md-card); border-radius: 18px 18px 0 0; box-shadow: 0 -12px 32px rgba(15, 18, 32, .22);
    transform: translateY(105%); transition: transform .25s cubic-bezier(.2, .7, .2, 1);
    visibility: hidden;
  }
  .md.is-sheet-open .md-rail { transform: none; visibility: visible; }
  .md-sheet-head {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 1; margin: 0 -16px 8px; padding: 10px 16px;
    background: var(--md-card); border-bottom: 1px solid var(--md-line);
  }
  .md-sheet-title { font-size: 16px; font-weight: 800; }
  .md-sheet-done { min-height: 44px; min-width: 64px; padding: 0 14px; border: 0; border-radius: 10px; background: var(--md-ink); color: #fff; font-weight: 700; font-size: 14px; }
  .md-sheet-backdrop { position: fixed; inset: 0; z-index: 1099; background: rgba(15, 18, 32, .45); }
  .md.is-sheet-open .md-sheet-backdrop { display: block; }
  .md-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

  .md-list { border-radius: 12px; }
  .md-row--head { display: none; }
  .md-row { grid-template-columns: 48px minmax(0, 1fr); gap: 4px 12px; padding: 10px 12px; }
  .md-row-ava { grid-row: span 3; align-self: start; }
  .md-row-loc, .md-row-since, .md-row-fb, .md-row-band, .md-row-act { grid-column: 2; }
  .md-row-band { display: block; }
  .md-row-loc, .md-row-since { font-size: 13px; }
  .md-row-k { display: inline; }
  .md-row-loc:empty, .md-row-since:empty, .md-row-fb:empty, .md-row-band:empty, .md-row-act:empty { display: none; }
  .md-row-loc .md-dist { display: inline; margin-left: 6px; }
  .md-row-act .md-btn, .md-row-act .rts-fbtn { width: auto; }
  .md-row-act .md-act { justify-content: flex-start; }
  .md-listwrap { flex-direction: column; gap: 8px; }
  .md-letters { position: static; width: 100%; }
  .md-letters-rail { display: none; }
  .md-letters-select { display: block; }
  .md-letters-select select { width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--md-line); border-radius: 10px; background: var(--md-card); font-size: 16px; }
}

@media (max-width: 600px) {
  .md { padding-top: 8px; }
  .md-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .md-h1 { font-size: 24px; }
  .md-intro { font-size: 14px; }
  .md-maplink { align-self: flex-start; }
  .md-view span { display: none; }
  .md-view { padding: 0 10px; }
  .md-card-body { padding: 10px 10px 12px; }
  .md-name { font-size: 15px; }
  .md-photo { width: 72%; margin-top: 12px; }
  .md-tier, .md-you { font-size: 10px; padding: 2px 6px; }
  /* Wall: exactly three across on a phone (a ~110px tile at 375px). */
  .md-wall { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .md-tile { border-radius: 8px; }
  .md-tile-over { padding: 22px 6px 6px; }
  .md-tile-name { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .md-card, .md-rail, .md-results.htmx-request, .md-tile-over, .md-tile-a img { transition: none; }
  .md-card:hover, .md-tile:hover .md-tile-a img { transform: none; }
  .md-more-spin { animation: none; }
}
