.feed {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 24px;
  padding-bottom: 64px;
}

/* Staggered masonry — independent flex columns. JS distributes cards into the
   shortest column on load and on infinite-scroll append, so newly arriving
   cards never reflow the existing layout. Capped at 3 columns. */
.feed-list {
  margin-top: 10px;
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
.feed-col {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}
.feed-list > .feed-empty {
  flex: 1 1 100%;
  margin: 0;
}

/* Filters */
.feed-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.feed-filter-group { display: flex; gap: 12px; flex-wrap: wrap; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  padding: 11px 22px;
  border-radius: 999px;
  background: var(--background);
  border: 1px solid var(--border);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text);
  transition: border-color 0.15s var(--ease);
}
.pill input { display: none; }
.pill:hover { border-color: #D4D4D4; }
.pill.is-active {
  border-color: #bababa;
  font-weight: 600;
}

.feed-filter-controls { display: flex; gap: 8px; flex-wrap: wrap; }
.feed-filter-controls select {
  appearance: none;
  -webkit-appearance: none;
  padding: 11px 38px 11px 22px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background-color: var(--background);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' stroke='%230B2545' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 12px 12px;
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: border-color 0.15s var(--ease);
}
.feed-filter-controls select:hover,
.feed-filter-controls select:focus-visible { border-color: #bababa; outline: none; box-shadow: none; }

@media (prefers-color-scheme: dark) {
  .pill,
  .feed-filter-controls select { border-color: var(--border); }
  .pill:hover,
  .pill.is-active,
  .feed-filter-controls select:hover,
  .feed-filter-controls select:focus-visible {
    border-color: color-mix(in srgb, var(--text) 30%, var(--border));
  }
  .feed-filter-controls select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' stroke='%23E8EEF7' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }
}

/* Location picker — acts as the third scope pill (the "Nearby" option). */
.country-picker { position: relative; display: inline-flex; }
.country-picker > input[type="radio"] { display: none; }

/* The trigger reuses .pill styling. Override only what's needed for the dropdown. */
.country-trigger {
  font-family: var(--font-sans);
  transition: border-color 0.15s var(--ease);
}
.country-picker.is-open .country-trigger {
  border-color: #D4D4D4;
  box-shadow: none;
}
@media (prefers-color-scheme: dark) {
  .country-picker.is-open .country-trigger {
    border-color: color-mix(in srgb, var(--text) 30%, var(--border));
  }
}
.country-trigger-flag { font-size: 15px; line-height: 1; }
.country-trigger-label {
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.country-trigger-caret {
  font-size: 10px;
  color: inherit;
  opacity: 0.7;
  transition: transform 0.15s var(--ease);
}
.country-picker.is-open .country-trigger-caret { transform: rotate(180deg); }

.country-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 280px;
  max-width: calc(100vw - 32px);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 8px;
  z-index: 30;
}
.country-search-row {
  position: relative;
  margin-bottom: 6px;
}
.country-search-icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--text-muted);
  pointer-events: none;
}
.country-search {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 32px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
}
.country-search:focus {
  outline: none;
  border-color: var(--unique);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--unique) 22%, transparent);
}

.country-list {
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.country-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.country-option:hover { background: color-mix(in srgb, var(--unique) 8%, transparent); }
.country-option.is-selected {
  background: color-mix(in srgb, var(--unique) 12%, transparent);
  color: var(--unique);
  font-weight: 600;
}
.country-option-flag { font-size: 16px; line-height: 1; }
.country-option[hidden] { display: none; }

.country-empty {
  padding: 14px 10px;
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
}

/* Card base */
.card {
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-author {
  display: flex; align-items: center;
  padding: 12px 14px;
  gap: 10px;
}
.author-link { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.author-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface);
  display: grid; place-items: center;
  flex-shrink: 0;
  font-size: 18px;
}
.author-avatar img { width: 100%; height: 100%; object-fit: cover; }
.author-info { min-width: 0; }
.author-name {
  font-size: 15px; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.author-time { font-size: 13px; color: var(--text-muted); }

.card-media {
  position: relative;
  display: block;
  background: var(--surface);
  overflow: hidden;
}
.card-media img { width: 100%; object-fit: cover; }
.card-media-empty { display: grid; place-items: center; height: 100%; font-size: 48px; color: var(--text-muted); }
.card-badge {
  position: absolute;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}
.card-badge.top-right { top: 8px; right: 8px; }
.card-badge.bottom-left { bottom: 8px; left: 8px; }

.card-chips {
  display: flex; flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px 0;
}
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 10px;
  background: var(--text);
  color: var(--background);
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
}
.chip i { font-size: 13px; line-height: 1; }

/* Tier-coloured variants. Mirrors iOS gradeTierColor():
   S→gold, A→silver, B→bronze, C→blue, D→muted. */
.chip.chip-tier-S { background: var(--tier-gold);   color: #fff; }
.chip.chip-tier-A { background: var(--tier-silver); color: var(--brand-deep); }
.chip.chip-tier-B { background: var(--tier-bronze); color: #fff; }
.chip.chip-tier-C { background: var(--unique);      color: #fff; }
.chip.chip-tier-D { background: var(--text-muted);  color: var(--background); }

.card-actions {
  display: flex; align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  margin-top: 10px;
}
.card-action {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 14px;
  color: var(--text-muted);
  padding: 5px 8px;
  border-radius: 8px;
}
.card-action:hover { color: var(--text); background: var(--surface); }
.card-action i { font-size: 16px; line-height: 1; }
.like-icon {
  font-size: 17px;
  line-height: 1;
  transition: color 0.15s ease, transform 0.18s ease;
}
.like-icon.liked { color: var(--danger); animation: like-pop 0.32s cubic-bezier(0.18, 0.89, 0.32, 1.28); }
.card-action[data-liked="1"] { color: var(--text); }
.card-action[data-liked="1"]:hover .like-icon { color: color-mix(in srgb, var(--danger) 80%, black); }
@keyframes like-pop {
  0%   { transform: scale(1);   }
  50%  { transform: scale(1.35); }
  100% { transform: scale(1);   }
}
@media (prefers-reduced-motion: reduce) {
  .like-icon.liked { animation: none; }
}

.card-body { padding: 4px 14px 14px; }
.aircraft-name { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.aircraft-desc { font-size: 14px; color: var(--text-muted); line-height: 1.5; }
.post-caption { font-size: 15px; line-height: 1.55; color: var(--text); }

/* New user / new device cards */
.new-user-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
}
.new-user-row { display: flex; align-items: center; gap: 10px; }
.new-user-stats {
  display: flex; gap: 14px; flex-wrap: wrap;
  font-size: 14px;
}
.new-user-stats strong { font-weight: 600; }

.new-device-card {
  display: flex; align-items: center;
  gap: 8px;
  padding: 12px 14px;
  font-size: 14px;
  color: var(--text-muted);
}

/* Loading sentinel */
.feed-sentinel {
  display: grid; place-items: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 14px;
}

/* Empty */
.feed-empty {
  padding: 48px 16px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
}
