:root {
  color-scheme: dark;
  --bg: #0b1220;
  --panel: #111827;
  --panel-2: #1f2937;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --line: #334155;
  --accent: #38bdf8;
}

* { box-sizing: border-box; }
html { scroll-behavior: auto; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.35 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select { font: inherit; }
button {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
}
button.primary { background: #075985; border-color: #0ea5e9; }
button:disabled { opacity: .45; }
a { color: var(--accent); }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.header {
  position: sticky; top: 0; z-index: 3;
  padding: calc(6px + env(safe-area-inset-top)) 8px 7px;
  background: rgba(11, 18, 32, .96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.title-row { display: flex; align-items: center; gap: 6px; }
.title-row h1 { flex: 1; margin: 0; font-size: 17px; letter-spacing: .2px; text-align: center; }
.icon-button { padding: 7px 8px; min-width: 36px; border-radius: 10px; }
.icon-button svg { display: block; margin: 0 auto; }

/* Multi-select pack picker. The .settings-card scope must match the generic
   .settings-card label / .settings-card input rules further down, which otherwise win on
   source order and break the row (label display:block, checkbox width:100% + padding). */
.pack-list { display: grid; gap: 8px; margin: 4px 0 12px; }
.settings-card label.pack-option { display: grid; grid-template-columns: auto 1fr auto; align-items: center;
  gap: 10px; margin: 0; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px;
  cursor: pointer; min-height: 42px; }
.settings-card .pack-option input { width: auto; margin: 0; padding: 0; transform: scale(1.2); }
.pack-name { font-size: 15px; color: var(--text); }
.pack-meta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.meta-list dd.download-total { font-weight: 650; font-variant-numeric: tabular-nums; }
.gps-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
}
.gps-strip > span {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 5px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gps-strip strong { color: var(--text); font-weight: 800; }
.gps-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: -1px; }
.gps-dot.ok { background: #22c55e; }
.gps-dot.bad { background: #ef4444; }
.main { flex: 1; padding: 8px 8px 80px; }
.warning { background: #3f2e04; color: #fde68a; border: 1px solid #92400e; border-radius: 12px; padding: 10px; margin: 8px 0; }
.update-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #052e2b; color: #99f6e4; border: 1px solid #0f766e; border-radius: 12px; padding: 10px; margin: 8px 0; }
.update-banner button { white-space: nowrap; }

/* Migration notice for a retired deployment. Amber so it is clearly not one of the routine
   teal update banners, but not red — nothing here is a hazard. */
.migration-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #2a1e05; color: #fcd34d; border: 1px solid #a16207; border-radius: 12px; padding: 10px; margin: 8px 0; }
.migration-banner button { white-space: nowrap; background: #a16207; border-color: #ca8a04; color: #fffbeb; font-weight: 600; }
.mig-url { display: flex; align-items: center; justify-content: center; gap: 8px; background: #052e2b;
  border: 1px solid #0f766e; color: #5eead4; border-radius: 10px; padding: 10px; font-weight: 700; margin-bottom: 12px; }
.mig-steps { display: grid; gap: 10px; margin-bottom: 12px; }
.mig-step { display: flex; gap: 10px; align-items: flex-start; }
.mig-step-n { flex: none; width: 21px; height: 21px; border-radius: 50%; background: var(--panel-2);
  border: 1px solid var(--line); font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.mig-step-note { color: var(--muted); }
.mig-warn { display: flex; gap: 9px; background: #2a1206; border: 1px solid #9a3412; color: #fdba74;
  border-radius: 10px; padding: 10px; margin-bottom: 12px; line-height: 1.35; }
.mig-warn strong { color: #fed7aa; }
.mig-go { display: block; text-align: center; text-decoration: none; background: #0f766e; border: 1px solid #14b8a6;
  color: #ccfbf1; border-radius: 12px; padding: 10px 12px; font-weight: 700; }
.mig-why { display: block; text-align: center; color: var(--muted); font-size: 14px; padding: 4px; }

/* Floating offline-download progress bar: fixed so it stays put and updates in place while the
   rest of the app (search, list) remains fully usable. */
.offline-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); display: grid; gap: 5px;
  background: rgba(17,24,39,.97); border-top: 1px solid var(--line); backdrop-filter: blur(8px); }
.offline-bar-track { height: 6px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.offline-bar-fill { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .2s ease; }
.offline-bar-label { font-size: 11px; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #030712;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 10px;
  margin: 0 0 8px;
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56,189,248,.14); }
.search-ic { color: var(--muted); font-size: 14px; line-height: 1; }
.search-box input {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text);
  padding: 11px 2px; outline: none;
}
.search-box input::placeholder { color: var(--muted); }
.search-clear {
  border: 0; background: transparent; color: var(--muted); padding: 6px 4px;
  font-size: 15px; border-radius: 8px; min-width: 30px;
}

.field-list {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--panel);
}
.field-list-head,
.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 70px 52px 42px;
  gap: 6px;
  align-items: center;
}
.field-list-head {
  position: static;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 8px 9px;
  border-bottom: 1px solid var(--line);
}
.field-list-head span:not(:first-child) { text-align: right; }
.field-row {
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 9px;
  cursor: pointer;
}
.field-row:last-child { border-bottom: 0; }
.top-picks-divider { height: 4px; background: #64748b; }
.field-row:active { background: rgba(56,189,248,.10); }
.field-main { min-width: 0; }
.field-name {
  display: block;
  font-weight: 800;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.field-sub { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.field-distance,
.field-glide { text-align: right; font-weight: 800; font-size: 14px; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; padding: 4px 7px; border-radius: 999px; border: 1px solid var(--line); font-weight: 900; justify-self: end; }
.badge-a {
  color: #000;
  background: #86efac;
  border-color: transparent;
}
.badge-b {
  color: #000;
  background: #fde047;
  border-color: transparent;
}
.badge-c {
  color: #000;
  background: #f59e0b;
  border-color: transparent;
}
.badge-d {
  color: #000;
  background: #ef4444;
  border-color: transparent;
}
.badge-unknown {
  color: #000;
  background: #9ca3af;
  border-color: transparent;
}

.settings-page { display: grid; gap: 12px; }
.settings-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.settings-head h2 { margin: 0; font-size: 22px; }
.settings-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  display: grid;
  gap: 10px;
}
.settings-card h3 { margin: 0 0 2px; }
.settings-card label { display: block; color: var(--muted); font-size: 12px; margin-bottom: -4px; }
.settings-card input,
.settings-card select {
  width: 100%; border: 1px solid var(--line); background: #030712; color: var(--text);
  border-radius: 10px; padding: 10px;
}
.checkbox-row { display: flex; gap: 10px; align-items: center; min-height: 38px; }
.checkbox-row input { width: auto; transform: scale(1.2); }
.checkbox-row label { margin: 0; color: var(--text); font-size: 15px; }
.settings-card input:disabled { opacity: .55; }
.settings-note { margin: -4px 0 2px; color: var(--muted); font-size: 12px; line-height: 1.35; }

.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.button-row.single { grid-template-columns: 1fr; margin-top: 8px; }
.meta-list { display: grid; gap: 6px; margin: 2px 0 0; }
.meta-list div { display: grid; grid-template-columns: 92px minmax(0,1fr); gap: 8px; border-top: 1px solid var(--line); padding-top: 6px; }
.meta-list dt { color: var(--muted); font-size: 12px; }
.meta-list dd { margin: 0; overflow: hidden; text-overflow: ellipsis; }

/* Lock the page while an overlay is open so scrolling a short bottom-sheet doesn't scroll the
   list behind it. */
body.modal-open { overflow: hidden; }
.detail-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 10; display: flex; align-items: flex-end; overscroll-behavior: contain; }
.detail { width: 100%; max-height: 94vh; overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; background: var(--bg); border-top: 1px solid var(--line); border-radius: 20px 20px 0 0; padding: 14px; }
.detail-title-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 10px; margin: 8px 0 4px; }
.detail h2 { margin: 0; min-width: 0; }
.detail-badge { align-self: start; margin-top: 2px; min-width: 36px; }
.detail-meta { color: var(--muted); margin-bottom: 12px; }
.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 10px 0; }
.detail-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.status-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.detail-card strong { display: block; font-size: 18px; margin-top: 2px; }
.notes { white-space: pre-wrap; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.inline-note { color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin: 8px 0; font-size: 13px; }
.media-grid { display: grid; gap: 12px; margin-top: 12px; }
.media-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px; }
.media-card img { width: 100%; max-height: 70vh; object-fit: contain; border-radius: 10px; background: #000; }
.media-card iframe { width: 100%; height: 70vh; border: 0; border-radius: 10px; background: #fff; }
.caption { color: var(--muted); margin-top: 6px; font-size: 13px; }
.footer-note { color: var(--muted); font-size: 12px; margin: 12px 2px; }

.contribute-btn { width: 100%; }
.contrib-backdrop { z-index: 20; }
.contrib-form { display: grid; gap: 10px; margin-top: 8px; }
.contrib-form > label:not(.checkbox-row) { color: var(--muted); font-size: 12px; margin-bottom: -4px; }
.contrib-form input[type="date"],
.contrib-form input[type="text"],
.contrib-form input[type="number"],
.contrib-form select,
.contrib-form textarea {
  width: 100%; border: 1px solid var(--line); background: #030712; color: var(--text);
  border-radius: 10px; padding: 10px; font: inherit;
}
.contrib-form textarea { resize: vertical; min-height: 76px; }
.contrib-photo-btn { justify-self: start; }
.contrib-photo-list { display: grid; gap: 6px; }
.contrib-photo-list:empty { display: none; }
.contrib-photo-row { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 7px 9px; font-size: 12px; }
.contrib-photo-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.contrib-photo-remove { border: none; background: none; color: var(--muted); font-size: 15px; padding: 2px 6px; cursor: pointer; }
.suggest-field { display: block; width: 100%; margin-top: 10px; border: 1px dashed var(--line); border-radius: 12px; background: none; color: var(--muted); padding: 12px; font-size: 14px; cursor: pointer; }
.nf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: end; }
.nf-grid label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.nf-coords { grid-template-columns: 1fr 1fr auto; }
.nf-runway { grid-template-columns: 1.2fr 1fr 1fr; }
.contrib-geo { border-radius: 10px; padding: 9px 10px; font-size: 13px; border: 1px solid var(--line); }
.contrib-geo.ok { background: #0c2a19; border-color: #14532d; color: #bbf7d0; }
.contrib-geo.warn { background: #2a1f06; border-color: #78350f; color: #fde68a; }
.contrib-geo.inline { display: inline-flex; justify-self: center; }
.contrib-license { align-items: flex-start; }
.contrib-license span { font-size: 13px; color: var(--text); }
.contrib-error { background: #3b0d0d; border: 1px solid #7f1d1d; color: #fecaca; border-radius: 10px; padding: 9px 10px; font-size: 13px; }
.contrib-submit { margin-top: 2px; }
.contrib-done { display: grid; gap: 12px; justify-items: center; text-align: center; padding: 18px 8px; }
.contrib-tick { width: 52px; height: 52px; border-radius: 50%; background: #0c2a19; border: 1px solid #14532d; color: #4ade80; display: flex; align-items: center; justify-content: center; font-size: 26px; }
.contrib-done-title { font-size: 17px; font-weight: 800; }
.contrib-done-body { color: var(--muted); font-size: 13px; max-width: 30ch; }
.contrib-pr { font-weight: 700; }

@media (max-width: 390px) {
  .field-list-head,
  .field-row { grid-template-columns: minmax(0, 1fr) 62px 46px 38px; }
  .field-name { font-size: 13px; }
  .field-distance, .field-glide { font-size: 13px; }
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .button-row { grid-template-columns: 1fr; }
}

.release-list { display: grid; gap: 12px; margin-top: 10px; }
.release-entry { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.release-entry.past { opacity: .75; }
.release-head { display: flex; justify-content: space-between; align-items: baseline; }
.release-head strong { font-size: 16px; }
.release-head span { color: var(--muted); font-size: 12px; }
.release-entry ul { margin: 8px 0 0; padding-left: 18px; }
.release-entry li { margin: 4px 0; font-size: 14px; line-height: 1.45; }
.meta-list a { color: var(--accent); }
