/* Catalogue + Map pages */
.cat-shell { display: grid; grid-template-columns: minmax(340px, 440px) 1fr; height: calc(100vh - var(--header-h) - env(safe-area-inset-top)); min-height: 520px; }
.cat-side { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.cat-main { position: relative; min-height: 0; overflow: auto; }
.cat-filters { padding: 16px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.cat-filters .two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.cat-filters .two > * { min-width: 0; }
.cat-filters .two .field, .cat-filters .two select { width: 100%; min-width: 0; }
/* Filter buttons wrap onto a new line instead of running off the edge. */
.cat-filters .chips { flex-wrap: wrap; overflow: visible; }
.cat-summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); color: var(--mist); font-size: .92rem; }
.search-box { position: relative; }
.search-box svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--mist); }
.search-box .field { padding-left: 42px; border-radius: 999px; }
.filter-toggle { display: none; }
.vlist { flex: 1; overflow-y: auto; position: relative; min-height: 0; }
.vlist-inner { position: relative; }
.stone-row { position: absolute; left: 0; right: 0; display: flex; text-decoration: none; align-items: center; gap: 12px; padding: 0 16px; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--paper); text-align: left; font: inherit; cursor: pointer; }
.stone-row:hover, .stone-row[aria-current="true"] { background: var(--panel); }
.stone-row .dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.stone-row .nm { display: block; font-family: var(--sans); font-weight: 600; font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stone-row .sub { display: block; font-size: .84rem; color: var(--mist); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stone-row .mid { flex: 1; min-width: 0; }
.stone-row .end { text-align: right; flex: none; font-size: .82rem; }
.stone-row .end .ff { color: var(--ember-soft); display: block; }
.stone-row .end .ms { color: var(--mist); display: block; }
.empty { padding: 32px 20px; color: var(--mist); }

.dot.chondrite { background: #ea580c; }
.dot.achondrite { background: #7c3aed; }
.dot.iron { background: #6b7280; }
.dot.stony-iron { background: var(--sky); }
.dot.unknown { background: var(--line); }

/* Detail */
.detail { padding: 22px; max-width: 760px; }
.detail .photo:has(.none) { aspect-ratio: auto; min-height: 110px; }
.detail .photo { aspect-ratio: 4 / 3; max-height: 420px; border-radius: var(--radius); background: var(--raised); border: 1px solid var(--line); overflow: hidden; display: flex; align-items: flex-end; margin-bottom: 18px; }
.detail .photo img { width: 100%; height: 100%; object-fit: cover; }
.detail .photo .none { padding: 18px; color: var(--mist); font-size: .95rem; }
.detail .credit { font-size: .8rem; color: var(--mist); margin: -10px 0 16px; }
.detail .kind { color: var(--ember-soft); letter-spacing: .12em; text-transform: uppercase; font-size: .8rem; font-weight: 600; }
.detail h2 { font-size: clamp(1.4rem, 3.6vw, 2rem); margin: .2em 0 .3em; }
.detail .mini-map { height: 240px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); margin: 16px 0; background: var(--raised); }
.near-list button { width: 100%; display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--paper); font: inherit; text-align: left; cursor: pointer; }
.near-list button:hover .n { color: var(--ember-soft); }
.links { display: grid; gap: 8px; margin-top: 10px; }
.links a { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); text-decoration: none; color: var(--paper); }
.links a small { color: var(--mist); }
.back-btn { display: none; }
.welcome { padding: 40px 28px; max-width: 640px; }

/* Map page */
.map-shell .cat-main { overflow: hidden; }
#map { position: absolute; inset: 0; background: #eceae6; }
.map-legend { position: absolute; left: 12px; bottom: 28px; background: rgba(255, 255, 255, .94); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; font-size: .82rem; display: grid; gap: 4px; z-index: 2; }
.map-legend span { display: flex; align-items: center; gap: 8px; }
.map-card { position: absolute; right: 12px; top: 12px; width: min(420px, calc(100% - 24px)); max-height: calc(100% - 24px); overflow: auto; background: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); z-index: 3; box-shadow: 0 20px 60px rgba(0, 0, 0, .15); }
.map-card .detail { padding: 18px; }
.map-card .close { position: sticky; top: 8px; float: right; margin: 8px 8px 0 0; z-index: 2; }
.map-msg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--mist); text-align: center; padding: 20px; }
.maplibregl-popup-content { background: var(--ink) !important; color: var(--paper); border: 1px solid var(--line); border-radius: 12px !important; }
.maplibregl-popup-tip { border-top-color: var(--line) !important; border-bottom-color: var(--line) !important; }
.maplibregl-ctrl-attrib { background: rgba(255, 255, 255, .8) !important; color: var(--mist); }
.maplibregl-ctrl-attrib a { color: var(--mist) !important; }

@media (max-width: 860px) {
  .cat-shell { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .cat-side { border-right: 0; height: calc(100vh - var(--header-h) - env(safe-area-inset-top)); }
  .cat-shell.show-detail .cat-side { display: none; }
  .cat-shell:not(.show-detail) .cat-main.list-mode { display: none; }
  .back-btn { display: inline-flex; margin: 14px 16px 0; }
  .filter-toggle { display: inline-flex; }
  .cat-filters .more { display: none; }
  .cat-filters.open .more { display: grid; gap: 10px; }
  .map-shell { display: block; }
  .map-shell .cat-side { height: auto; border-bottom: 1px solid var(--line); }
  .map-shell .vlist, .map-shell .cat-summary + .vlist { display: none; }
  .map-shell .cat-main { height: 72vh; }
}
