/* ============================================================
   MSFS 2024 — Aircraft Compendium
   Theme: Dark Mode · Aviation Blue · Space Grotesk + JetBrains Mono
   ============================================================ */


body.modal-open,
body.contact-open,
body.image-gallery-open { overflow: hidden; }

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  --bg-base:        #080c14;
  --bg-surface:     #0d1420;
  --bg-elevated:    #111c2e;
  --bg-card:        #0f1929;
  --bg-hover:       #162236;
  --bg-modal:       #0a1220;

  --blue-dim:       #1a3a5c;
  --blue-mid:       #1e5fa8;
  --blue-core:      #2d85e8;
  --blue-bright:    #4fa3f7;
  --blue-glow:      #6bbfff;
  --blue-subtle:    rgba(45, 133, 232, 0.12);
  --blue-border:    rgba(45, 133, 232, 0.25);
  --blue-border-hi: rgba(79, 163, 247, 0.6);

  --text-primary:   #e8f0fe;
  --text-secondary: #8fa5c4;
  --text-muted:     #4a6280;
  --text-accent:    #4fa3f7;

  --border-subtle:  rgba(255,255,255,0.06);
  --border-mid:     rgba(255,255,255,0.1);

  --edition-std:    #2d85e8;
  --edition-dlx:    #9d6fe8;
  --edition-pdlx:   #e8a82d;

  --cockpit-steam:  #e05c3a;
  --cockpit-glass:  #2dce89;
  --cockpit-hybrid: #9d6fe8;

  --radius-sm:      4px;
  --radius-md:      8px;
  --radius-lg:      12px;
  --radius-xl:      16px;

  --shadow-card:    0 4px 24px rgba(0,0,0,0.5);
  --shadow-modal:   0 24px 80px rgba(0,0,0,0.8), 0 0 0 1px rgba(45,133,232,0.2);
  --glow-blue:      0 0 20px rgba(45,133,232,0.3);

  --transition:     all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  background-color: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Background Texture ────────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 10% 0%, rgba(29,83,148,0.15) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 90% 100%, rgba(20,60,110,0.1) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ── Header ────────────────────────────────────────────────── */
#header {
  position: sticky;
  top: 0;
  z-index: 300;
  background: rgba(8,12,20,0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.7rem 0;
  display: grid;
  grid-template-columns: minmax(250px, 1fr) minmax(300px, 560px) minmax(250px, 1fr);
  align-items: center;
  gap: 1rem;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-shrink: 0;
  justify-self: start;
}
.header-brand .brand-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: block;
  flex-shrink: 0;
  object-fit: contain;
  box-shadow: var(--glow-blue);
  background: var(--bg-elevated);
}
.header-brand h1 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-primary);
  line-height: 1.2;
}
.header-brand .brand-sub {
  font-size: 0.7rem;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── App Layout ────────────────────────────────────────────── */
#app {
  position: relative;
  z-index: 1;
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 2.5rem 1.25rem;
}

/* ── Footer ───────────────────────────────────────────────── */
.site-footer {
  margin-top: 1.25rem;
  padding: 0.45rem 0 0;
  border-top: 1px solid var(--border-subtle);
  text-align: center;
  font-size: 0.62rem;
  line-height: 1.45;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.02em;
}
.site-footer .footer-line {
  margin: 0 0 0.2rem;
  color: var(--text-secondary);
}
.site-footer .footer-brand {
  color: var(--text-secondary);
  font-weight: 500;
}
.site-footer .footer-sep {
  margin: 0 0.35rem;
  opacity: 0.55;
}
.site-footer .footer-credit {
  color: var(--text-muted);
}
.footer-link-btn {
  display: inline;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.02em;
  color: var(--blue-bright);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: var(--transition);
}
.footer-link-btn:hover {
  color: var(--blue-glow);
}
.site-footer .footer-disclaimer {
  margin: 0;
  font-size: 0.58rem;
  line-height: 1.4;
  color: var(--text-muted);
  opacity: 0.9;
  max-width: 52rem;
  margin-left: auto;
  margin-right: auto;
}

/* ── Contact popup (EmailJS) ───────────────────────────────── */
.contact-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 800;
  background: rgba(4, 8, 16, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.contact-overlay.open {
  display: flex;
}
.contact-dialog {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: var(--bg-modal);
  border: 1px solid var(--blue-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal), var(--glow-blue);
  padding: 1.1rem 1.15rem 1rem;
  color: var(--text-primary);
}
.contact-close {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: var(--transition);
}
.contact-close:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}
.contact-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 1.75rem 0.85rem 0;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}
.contact-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.contact-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  text-align: left;
}
.contact-label {
  font-size: 0.68rem;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.contact-opt {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  opacity: 0.85;
}
.contact-input,
.contact-textarea {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.8rem;
  padding: 0.45rem 0.55rem;
  outline: none;
  transition: var(--transition);
}
.contact-textarea {
  resize: vertical;
  min-height: 5.5rem;
}
.contact-input::placeholder,
.contact-textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}
.contact-input:focus,
.contact-textarea:focus {
  border-color: var(--blue-border-hi);
  box-shadow: 0 0 0 2px rgba(45, 133, 232, 0.15);
}
.contact-status {
  margin: 0.15rem 0 0;
  min-height: 1.1rem;
  font-size: 0.72rem;
  font-family: 'JetBrains Mono', monospace;
}
.contact-status-ok {
  color: var(--cockpit-glass);
}
.contact-status-err {
  color: var(--cockpit-steam);
}
.contact-send {
  margin-top: 0.15rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--blue-border-hi);
  border-radius: var(--radius-md);
  background: rgba(45, 133, 232, 0.18);
  color: var(--blue-bright);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: var(--transition);
}
.contact-send:hover:not(:disabled) {
  background: rgba(45, 133, 232, 0.28);
  color: var(--blue-glow);
}
.contact-send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

#main-content {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-top: 0.5rem;
}

.search-wrap {
  position: relative;
  width: 100%;
  min-width: 0;
  grid-column: 2;
  display: flex;
  flex-direction: column;
  gap: 0.36rem;
}

.search-input-wrap {
  position: relative;
}
.search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.85rem;
  pointer-events: none;
}
#search-input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.875rem;
  padding: 0.6rem 0.85rem 0.6rem 2.4rem;
  outline: none;
  transition: var(--transition);
}
#search-input::placeholder { color: var(--text-muted); }
#search-input:focus {
  border-color: var(--blue-border-hi);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(45,133,232,0.1);
}

.career-mode-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

/* Mobile filter tabs + sheets (row hidden on desktop via media query) */
.mobile-filter-tabs-row {
  display: none;
  width: 100%;
}
.mobile-filter-sheets {
  width: 100%;
}
.mobile-filter-sheet {
  width: 100%;
}
.mobile-filter-tab {
  font-family: inherit;
}
.career-mode-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  max-width: 20rem;
  margin: 0 auto;
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  background: rgba(79, 163, 247, 0.08);
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: var(--transition);
}
.career-mode-toggle::after {
  content: '▸';
  font-size: 0.65rem;
  opacity: 0.75;
  transition: transform 0.2s ease;
}
.career-mode-wrap.is-open .career-mode-toggle::after {
  transform: rotate(90deg);
}
.career-mode-toggle:hover {
  border-color: var(--blue-border-hi);
  color: var(--text-primary);
}
.career-mode-toggle.has-filter {
  border-color: rgba(79, 163, 247, 0.55);
  color: var(--blue-bright);
  box-shadow: 0 0 0 1px rgba(45, 133, 232, 0.2) inset;
}

.suitable-filter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
  min-height: 1.55rem;
  justify-content: center;
}

.sf-tag {
  border: 1px solid var(--border-mid);
  background: rgba(79, 163, 247, 0.06);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 0.17rem 0.52rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  cursor: pointer;
  transition: var(--transition);
}
.sf-tag:hover {
  border-color: var(--blue-border-hi);
  color: var(--text-primary);
}
.sf-tag.active {
  color: #dff2ff;
  border-color: rgba(79, 163, 247, 0.85);
  box-shadow: 0 0 0 1px rgba(79, 163, 247, 0.35) inset;
}

/* Color accents for grouped suitable-for tags */
.sf-tag.sf-cargo.active { background: rgba(232, 168, 45, 0.2); border-color: rgba(232, 168, 45, 0.8); }
.sf-tag.sf-passenger.active { background: rgba(45, 206, 137, 0.2); border-color: rgba(45, 206, 137, 0.8); }
.sf-tag.sf-charter.active { background: rgba(157, 111, 232, 0.22); border-color: rgba(157, 111, 232, 0.88); }
.sf-tag.sf-construction.active { background: rgba(79, 163, 247, 0.22); border-color: rgba(79, 163, 247, 0.88); }
.sf-tag.sf-firefighting.active { background: rgba(224, 92, 58, 0.2); border-color: rgba(224, 92, 58, 0.82); }
.sf-tag.sf-agricultural.active { background: rgba(184, 160, 70, 0.22); border-color: rgba(184, 160, 70, 0.82); }
.sf-tag.sf-medevac.active,
.sf-tag.sf-search-rescue.active { background: rgba(79, 163, 247, 0.22); border-color: rgba(79, 163, 247, 0.9); }


.controls-right {
  width: auto;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  align-items: center;
  justify-items: end;
  gap: 0.72rem 0.55rem;
  grid-column: 3;
  justify-self: end;
  align-self: start;
  padding-top: 0.08rem;
}
.units-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border-mid);
  border-radius: 999px;
  background: rgba(79, 163, 247, 0.04);
}
.units-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 0 0.25rem 0 0.35rem;
}
.units-btn {
  width: 24px;
  height: 20px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: var(--transition);
}
.units-btn:hover {
  color: var(--text-primary);
}
.units-btn.active {
  background: rgba(79, 163, 247, 0.22);
  color: var(--blue-bright);
}
.global-units-toggle {
  grid-column: 2;
  grid-row: 1;
  margin-left: auto;
}
#results-count {
  grid-column: 1;
  grid-row: 2;
}
.btn-reset {
  grid-column: 2;
  grid-row: 2;
}
.global-units-toggle .units-btn {
  width: auto;
  min-width: 54px;
  padding: 0 0.5rem;
}

#results-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}
#results-count strong {
  color: var(--blue-bright);
  font-weight: 500;
}

.btn-reset {
  background: transparent;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.8rem;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.btn-reset .label-mobile { display: none; }
.btn-reset:hover {
  border-color: var(--blue-border);
  color: var(--text-primary);
  background: var(--blue-subtle);
}

/* ── Table Wrapper ─────────────────────────────────────────── */
#table-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

/* Sentinel for mobile infinite scroll (below <table>, inside #table-wrap) */
.table-load-sentinel {
  width: 100%;
  height: 4px;
  margin: 0;
  padding: 0;
  clear: both;
  pointer-events: none;
  opacity: 0;
}

/* ── Table ─────────────────────────────────────────────────── */
#aircraft-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

/* Column widths */
#aircraft-table col.col-id      { width: 62px; }
#aircraft-table col.col-thumb   { width: 165px; }
#aircraft-table col.col-name    { width: 310px; }
#aircraft-table col.col-type    { width: 300px; }
#aircraft-table col.col-specialisations { width: 220px; }
#aircraft-table col.col-edition { width: 88px; }

/* Head — two rows: labels, then filter dropdowns; kept compact (no inner border) */
#aircraft-table thead tr {
  background: var(--bg-elevated);
}
#aircraft-table thead tr.thead-row-filters {
  border-bottom: 1px solid var(--border-subtle);
}

#aircraft-table thead th {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0.28rem 0.5rem;
  line-height: 1.15;
  text-align: left;
  white-space: nowrap;
  user-select: none;
}
#aircraft-table thead th.th-thumb-spacer {
  padding: 0.2rem;
}
#aircraft-table thead th.th-col-label {
  padding-top: 0.22rem;
  padding-bottom: 0.12rem;
  vertical-align: bottom;
}
#aircraft-table thead th[rowspan] {
  vertical-align: top;
  padding-top: 0.3rem;
}
#aircraft-table th.sortable {
  cursor: pointer;
  transition: var(--transition);
}
#aircraft-table th.sortable:hover { color: var(--text-accent); }
#aircraft-table th.sort-asc  { color: var(--blue-bright); }
#aircraft-table th.sort-desc { color: var(--blue-bright); }

.th-inner {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.sort-arrow {
  font-size: 0.55rem;
  opacity: 0.4;
  transition: var(--transition);
}
th.sort-asc  .sort-arrow { opacity: 1; }
th.sort-desc .sort-arrow { opacity: 1; }

/* Filter row — full width of column (labels sit on row above) */
.th-filter-cell {
  padding: 0.12rem 0.45rem 0.32rem;
  vertical-align: middle;
}
.header-filter {
  box-sizing: border-box;
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  padding: 0.2rem 1.25rem 0.2rem 0.4rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%234fa3f7' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.45rem center;
}
.header-filter:hover {
  border-color: var(--blue-mid);
  color: var(--text-primary);
}
.header-filter:focus { outline: none; border-color: var(--blue-core); }
.header-filter option { background: var(--bg-surface); }

/* Edition column — minimal width; dropdown follows col width */
#aircraft-table thead tr.thead-row-filters .th-filter-cell:last-child {
  padding-left: 0.3rem;
  padding-right: 0.3rem;
}
#filter-edition {
  font-size: 0.55rem;
  padding: 0.18rem 1.1rem 0.18rem 0.35rem;
}
#aircraft-table td.td-edition {
  padding: 0.55rem 0.28rem;
  text-align: center;
  vertical-align: middle;
}
#aircraft-table td.td-edition .badge-edition {
  white-space: normal;
  justify-content: center;
  text-align: center;
  max-width: 100%;
  font-size: 0.56rem;
  letter-spacing: 0.04em;
  padding: 0.16rem 0.28rem;
  line-height: 1.12;
}

/* Body rows */
#aircraft-table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: var(--transition);
  cursor: pointer;
}
#aircraft-table tbody tr:last-child { border-bottom: none; }
#aircraft-table tbody tr:hover {
  background: var(--bg-hover);
}
#aircraft-table tbody tr:hover .aircraft-name {
  color: var(--blue-glow);
}

#aircraft-table td {
  padding: 0.7rem 1rem;
  vertical-align: middle;
  font-size: 0.875rem;
}

/* Thumbnail cell */
td.td-thumb {
  padding: 0.4rem 0.75rem 0.4rem 1rem;
}
.thumb-img {
  width: 140px;
  height: 88px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  display: block;
  border: 1px solid var(--border-subtle);
}
.thumb-placeholder {
  width: 140px;
  height: 88px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  opacity: 0.35;
}

/* ID cell */
td.td-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

/* Name cell */
.aircraft-name {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: var(--transition);
  letter-spacing: 0.01em;
}

/* Type cell */
td.td-type {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
}

td.td-specialisations {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
  line-height: 1.35;
  vertical-align: middle;
}

/* Cockpit badge */
.badge-cockpit {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-cockpit.steam {
  background: rgba(224,92,58,0.12);
  border-color: rgba(224,92,58,0.3);
  color: #e07a5a;
}
.badge-cockpit.glass {
  background: rgba(45,206,137,0.1);
  border-color: rgba(45,206,137,0.3);
  color: #2dce89;
}
.badge-cockpit.hybrid {
  background: rgba(157,111,232,0.12);
  border-color: rgba(157,111,232,0.3);
  color: #b98eff;
}
.badge-cockpit.unknown {
  background: var(--bg-elevated);
  border-color: var(--border-subtle);
  color: var(--text-muted);
}

/* Edition badge */
.badge-edition {
  display: inline-flex;
  align-items: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-edition.standard {
  background: rgba(45,133,232,0.1);
  border-color: rgba(45,133,232,0.25);
  color: var(--blue-bright);
}
.badge-edition.deluxe {
  background: rgba(157,111,232,0.12);
  border-color: rgba(157,111,232,0.3);
  color: #b98eff;
}
.badge-edition.premium-deluxe {
  background: rgba(230, 122, 34, 0.14);
  border-color: rgba(230, 122, 34, 0.42);
  color: #ff9a3d;
}
.badge-edition.aviator {
  background: rgba(32,200,180,0.1);
  border-color: rgba(32,200,180,0.3);
  color: #20c8b4;
}

.badge-suitable {
  display: inline-flex;
  align-items: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.52rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(232, 168, 45, 0.45);
  background: rgba(232, 168, 45, 0.16);
  color: #f0c765;
  white-space: nowrap;
}

/* Empty state */
#empty-state {
  display: none;
  text-align: center;
  padding: 5rem 2rem;
  color: var(--text-muted);
}
#empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.4; }
#empty-state p { font-size: 0.9rem; }

/* ── Modal ─────────────────────────────────────────────────── */
#modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  align-items: flex-start;
  justify-content: center;
  padding: 0.6rem 2rem 1.2rem;
  animation: fadeIn 0.2s ease;
}
#modal-overlay.open { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

#modal {
  position: relative;
  background: var(--bg-modal);
  border: 1px solid var(--blue-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 1020px;
  max-height: 92vh;
  overflow-y: auto;
  animation: slideUp 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  scrollbar-width: thin;
  scrollbar-color: var(--blue-dim) transparent;
}
#modal::-webkit-scrollbar { width: 5px; }
#modal::-webkit-scrollbar-track { background: transparent; }
#modal::-webkit-scrollbar-thumb { background: var(--blue-dim); border-radius: 9px; }

.modal-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 1.15rem 2rem 0.75rem;
  border-bottom: none;
  gap: 1rem;
  background: var(--bg-modal);
}
.modal-header-left {
  flex: 1;
  padding-right: 0;
  position: relative;
}
.modal-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--blue-core);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
}
.modal-id-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.35rem;
}
.modal-id-row .modal-id {
  margin-bottom: 0;
}
.modal-icao {
  display: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #2dce89;
}
.modal-icao.show {
  display: inline-flex;
}
.modal-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--text-primary);
  margin-bottom: 0.6rem;
}
.modal-badges-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding-right: 100px;
  min-height: 24px;
}
.modal-badges { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.modal-cost-badge {
  display: none;
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.26rem 0.62rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(45, 206, 137, 0.45);
  background: rgba(45, 206, 137, 0.15);
  color: #72e7b5;
  white-space: nowrap;
}
.modal-cost-badge.show {
  display: inline-flex;
}

.modal-close {
  position: absolute;
  top: 0.55rem;
  right: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: var(--transition);
  flex-shrink: 0;
}
.modal-units-toggle {
  position: absolute;
  top: 0.55rem;
  right: 50px;
  z-index: 2;
}
.modal-units-toggle .modal-units-btn {
  width: 20px;
  height: 18px;
  font-size: 0.58rem;
  padding: 0;
}
.modal-close:hover {
  border-color: var(--blue-border);
  color: var(--text-primary);
  background: var(--bg-hover);
}

.modal-edge-nav {
  position: fixed;
  width: 18px;
  height: 120px;
  border: none;
  background: transparent;
  color: rgba(143, 165, 196, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 3;
  transition: var(--transition);
}
.modal-edge-nav.prev {
  border-radius: 0 8px 8px 0;
  background: linear-gradient(90deg, rgba(45, 133, 232, 0.12), rgba(45, 133, 232, 0));
}
.modal-edge-nav.next {
  border-radius: 8px 0 0 8px;
  background: linear-gradient(270deg, rgba(45, 133, 232, 0.12), rgba(45, 133, 232, 0));
}
.modal-edge-nav span {
  font-size: 0.8rem;
  line-height: 1;
}
.modal-edge-nav:hover {
  color: var(--blue-glow);
  width: 24px;
}
.modal-edge-nav:disabled {
  opacity: 0.18;
  cursor: not-allowed;
}

/* Modal images */
.modal-images {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
  padding: 0.8rem 2rem 0.75rem;
  border-bottom: none;
}
.modal-img-block { display: flex; flex-direction: column; gap: 0.5rem; }
.modal-img-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.modal-img-frame {
  aspect-ratio: 16/9;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.modal-img-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.modal-img-frame:has(> img) {
  cursor: zoom-in;
}
.modal-img-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
  opacity: 0.5;
}
.modal-img-placeholder .ph-icon { font-size: 2rem; }
.modal-img-placeholder .ph-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.05em;
}

/* Fullscreen image gallery (exterior / cockpit) over modal */
.image-gallery-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 750;
  background: rgba(0, 0, 0, 0.92);
  align-items: center;
  justify-content: center;
  padding: 3rem 2.5rem 2.5rem;
}
.image-gallery-overlay.open {
  display: flex;
}
.image-gallery-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  max-width: min(96vw, 1320px);
  max-height: 90vh;
}
.image-gallery-img {
  max-width: 100%;
  max-height: calc(90vh - 3.5rem);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 48px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(79, 163, 247, 0.2);
}
.image-gallery-caption {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  text-align: center;
  max-width: 56rem;
  line-height: 1.4;
}
.gallery-edge-nav {
  position: fixed;
  z-index: 751;
}

/* Modal specs */
.modal-body { padding: 0.55rem 2rem 0.5rem; }

.specs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.9rem;
}
.spec-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.58rem 0.85rem;
  transition: var(--transition);
}
.spec-item:hover { border-color: var(--blue-border); }
.spec-card { padding: 0.55rem 0.72rem 0.62rem; }
.spec-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}
.spec-rows {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}
.spec-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  border-top: 1px solid rgba(255,255,255,0.04);
  padding-top: 0.24rem;
}
.spec-row:first-child {
  border-top: none;
  padding-top: 0;
}
.spec-row-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  color: var(--text-secondary);
}
.spec-row-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-primary);
  text-align: right;
}
.spec-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
}
.spec-value.highlight { color: var(--blue-bright); }
.spec-value.na { color: var(--text-muted); font-style: italic; font-size: 0.78rem; }
.spec-unit {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 0.2rem;
}

.modal-section-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0.34rem 0 0.24rem;
  padding-bottom: 0;
  border-bottom: none;
}
.modal-body .modal-section-title:first-child {
  margin-top: 0;
}

.instrumentation-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.62rem 0.8rem;
  font-family: 'JetBrains Mono', monospace;
}

.suitable-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.suitable-tag {
  background: var(--blue-subtle);
  border: 1px solid var(--blue-border);
  border-radius: var(--radius-sm);
  color: var(--blue-bright);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  padding: 0.25rem 0.6rem;
  letter-spacing: 0.03em;
}

.modal-footer {
  position: sticky;
  bottom: 0;
  z-index: 2;
  background: var(--bg-modal);
  border-top: 1px solid var(--border-subtle);
  padding: 0.2rem 2rem 0.24rem;
}

.modal-links {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}
.modal-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--bg-elevated);
  border: 1px solid var(--blue-border);
  border-radius: var(--radius-md);
  color: var(--blue-bright);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.2rem 0.48rem;
  text-decoration: none;
  transition: var(--transition);
}
.modal-link:hover {
  background: var(--blue-subtle);
  border-color: var(--blue-border-hi);
  color: var(--blue-glow);
  transform: translateY(-1px);
}

/* ── Scrollbar (global) ────────────────────────────────────── */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--bg-elevated) transparent;
}
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 9px; }
::-webkit-scrollbar-thumb:hover { background: var(--blue-dim); }

/* ── Animations ────────────────────────────────────────────── */
@keyframes rowIn {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}
.row-animate {
  animation: rowIn 0.18s ease forwards;
}

/* ── Narrow screens & touch (table + header + Career Mode) ─── */
@media (max-width: 900px) {
  #app {
    padding: 0 0.85rem 1rem;
  }
  #header {
    grid-template-columns: 1fr;
    justify-items: stretch;
    gap: 0.55rem;
    padding: 0.5rem 0;
  }
  .header-brand {
    justify-self: center;
    text-align: center;
  }
  .header-brand h1 {
    font-size: 0.95rem;
  }
  .search-wrap {
    grid-column: 1;
    width: 100%;
  }
  .controls-right {
    display: flex;
    grid-column: 1;
    justify-self: stretch;
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
  }
  .global-units-toggle {
    order: 3;
    margin-left: auto;
  }
  .global-units-toggle .units-label {
    display: none;
  }
  .global-units-toggle .units-btn {
    width: 24px;
    min-width: 24px;
    padding: 0;
    font-size: 0.62rem;
  }
  .global-units-toggle #units-metric-btn::after { content: 'M'; }
  .global-units-toggle #units-imperial-btn::after { content: 'I'; }
  .global-units-toggle #units-metric-btn,
  .global-units-toggle #units-imperial-btn {
    font-size: 0;
    letter-spacing: 0;
  }
  .btn-reset .label-desktop { display: none; }
  .btn-reset .label-mobile { display: inline; }
  #results-count {
    font-size: 0.68rem;
    white-space: normal;
    text-align: left;
    flex: 1;
    min-width: 0;
  }
  #results-count .results-more-hint {
    display: block;
    margin-top: 0.2rem;
    color: var(--text-muted);
    font-weight: 400;
    font-size: 0.62rem;
    line-height: 1.35;
  }

  /* Modal: edition, cockpit, suitable-for badges + cost — desktop only */
  .modal-badges-row {
    display: none !important;
  }
  .modal-title {
    margin-bottom: 0.4rem;
  }

  .career-mode-toggle {
    display: none !important;
  }

  /* One row: Career | Type | Specialisation; only one tag panel open below */
  .career-mode-wrap {
    align-items: stretch;
    max-width: 100%;
  }
  .mobile-filter-tabs-row {
    display: flex;
    flex-direction: row;
    width: 100%;
    gap: 6px;
    justify-content: stretch;
    margin-bottom: 0.15rem;
  }
  .mobile-filter-tab {
    flex: 1 1 0;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.45rem 0.28rem;
    border: 1px solid var(--border-mid);
    border-radius: var(--radius-md);
    background: rgba(79, 163, 247, 0.08);
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.58rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-filter-tab::after {
    content: none;
  }
  .mobile-filter-tab:hover {
    border-color: var(--blue-border-hi);
    color: var(--text-primary);
  }
  .mobile-filter-tab.is-active-tab {
    border-color: rgba(79, 163, 247, 0.75);
    color: var(--blue-bright);
    background: rgba(79, 163, 247, 0.14);
    box-shadow: 0 0 0 1px rgba(45, 133, 232, 0.22) inset;
  }
  .mobile-filter-tab.has-filter:not(.is-active-tab) {
    border-color: rgba(79, 163, 247, 0.45);
    color: var(--blue-bright);
  }

  .mobile-filter-sheets {
    width: 100%;
  }
  .mobile-filter-sheet {
    display: none;
    width: 100%;
    max-height: min(48vh, 20rem);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.2rem;
  }
  .mobile-filter-sheet .suitable-filter-tags {
    display: flex;
    max-height: none;
  }
  .mobile-filter-sheet.is-open {
    display: block !important;
  }

  .mobile-filter-tags {
    justify-content: flex-start;
    margin-top: 0.12rem;
  }
  .mobile-filter-tags .sf-tag {
    text-align: center;
    max-width: 100%;
    white-space: normal;
    line-height: 1.25;
  }

  /* Off-screen: Type & Specialisation <select> on mobile (still synced for desktop moves) */
  .mobile-selects-host {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    pointer-events: none;
  }

  /* Type & Spec filters are in header accordion; collapse empty th (no display:none — keeps column grid). */
  #aircraft-table thead .th-filter-type,
  #aircraft-table thead .th-filter-specialisation {
    visibility: collapse;
    width: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden;
    border: none;
    line-height: 0;
    font-size: 0;
  }

  .thumb-img,
  .thumb-placeholder {
    width: 92px;
    height: 58px;
  }
  td.td-thumb {
    padding: 0.35rem 0.45rem 0.35rem 0.6rem;
    vertical-align: middle;
  }
  #aircraft-table td {
    padding: 0.45rem 0.6rem;
    font-size: 0.82rem;
  }
  .aircraft-name {
    font-size: 0.82rem;
    line-height: 1.35;
  }
  #aircraft-table td.td-edition .badge-edition {
    font-size: 0.52rem;
    padding: 0.12rem 0.22rem;
  }

  /*
   * Mobile list: keep real table rows (never flex/grid tr — breaks WebKit width).
   * Fixed layout + collapsed cols + thumb width lets the name column take the rest.
   */
  #aircraft-table {
    table-layout: fixed;
    width: 100%;
  }

  /*
   * Portrait: thumb + name only.
   * Never use display:none on <td> here — it drops cells from the table grid while <colgroup>
   * still has 6 columns; Chromium then maps thumb/name into wrong slots (no image + narrow text).
   * Use visibility:collapse on cells + cols so columns stay aligned.
   */
  @media (orientation: portrait) {
    #aircraft-table col.col-id,
    #aircraft-table col.col-type,
    #aircraft-table col.col-specialisations,
    #aircraft-table col.col-edition {
      visibility: collapse;
      width: 0 !important;
      max-width: 0 !important;
    }
    #aircraft-table col.col-thumb {
      width: 28%;
    }
    #aircraft-table col.col-name {
      width: 72%;
    }
    #aircraft-table thead .th-id,
    #aircraft-table thead .th-col-type,
    #aircraft-table thead .th-col-specialisations,
    #aircraft-table thead .th-col-edition,
    #aircraft-table thead .th-filter-edition {
      visibility: collapse;
      width: 0 !important;
      padding: 0 !important;
      overflow: hidden;
      border: none;
    }
    #aircraft-table tbody .td-id,
    #aircraft-table tbody .td-type,
    #aircraft-table tbody .td-specialisations,
    #aircraft-table tbody .td-edition {
      visibility: collapse;
      padding: 0 !important;
      border: none;
      font-size: 0;
      line-height: 0;
    }
    #aircraft-table tbody .td-thumb,
    #aircraft-table tbody .td-name {
      visibility: visible;
    }
    #aircraft-table tbody tr .td-name {
      width: auto;
    }
    #aircraft-table .thumb-img,
    #aircraft-table .thumb-placeholder {
      max-width: 100%;
    }
    #aircraft-table .aircraft-name {
      display: block;
      white-space: normal;
      word-break: normal;
      overflow-wrap: break-word;
    }
  }

  /* Landscape: thumb + name + edition */
  @media (orientation: landscape) {
    #aircraft-table col.col-id,
    #aircraft-table col.col-type,
    #aircraft-table col.col-specialisations {
      visibility: collapse;
      width: 0 !important;
      max-width: 0 !important;
    }
    #aircraft-table col.col-thumb {
      width: 26%;
    }
    #aircraft-table col.col-name {
      width: 54%;
    }
    #aircraft-table col.col-edition {
      width: 20%;
    }
    #aircraft-table thead .th-id,
    #aircraft-table thead .th-col-type,
    #aircraft-table thead .th-col-specialisations {
      visibility: collapse;
      width: 0 !important;
      padding: 0 !important;
      overflow: hidden;
      border: none;
    }
    #aircraft-table tbody .td-id,
    #aircraft-table tbody .td-type,
    #aircraft-table tbody .td-specialisations {
      visibility: collapse;
      padding: 0 !important;
      border: none;
      font-size: 0;
      line-height: 0;
    }
    #aircraft-table tbody .td-thumb,
    #aircraft-table tbody .td-name,
    #aircraft-table tbody .td-edition {
      visibility: visible;
    }
    #aircraft-table tbody tr .td-name {
      width: auto;
    }
    #aircraft-table .thumb-img,
    #aircraft-table .thumb-placeholder {
      max-width: 100%;
    }
    #aircraft-table .aircraft-name {
      display: block;
      white-space: normal;
      word-break: normal;
      overflow-wrap: break-word;
    }
  }
}

@media (min-width: 901px) {
  .career-mode-toggle {
    display: none !important;
  }
  .mobile-filter-tabs-row {
    display: none !important;
  }
  .career-mode-wrap .suitable-filter-tags,
  #mobile-sheet-career .suitable-filter-tags {
    display: flex !important;
  }
  #mobile-sheet-career {
    display: block !important;
    max-height: none !important;
    overflow: visible !important;
    padding-bottom: 0 !important;
  }
  #mobile-sheet-career[hidden] {
    display: block !important;
  }
  #mobile-sheet-type,
  #mobile-sheet-spec {
    display: none !important;
  }
  .mobile-selects-host {
    display: none !important;
  }
}
