/* styles.css — Vehicle Gallery v1.5 */
@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@400;500;600;700&family=Space+Mono:wght@400;700&display=swap');

/* CSS health marker */
:root {
  --bg:        #080b12;
  --bg2:       #0d1220;
  --bg3:       #131927;
  --card:      #111827;
  --card-h:    #161f30;
  --border:    #1e2d45;
  --border2:   #263a55;
  --accent:    #c8a84b;
  --accent2:   #e8c76a;
  --cyan:      #4fc3f7;
  --red:       #ef5350;
  --green:     #66bb6a;
  --text:      #e2e8f0;
  --text2:     #94a3b8;
  --text3:     #64748b;
  --pin:       #f59e0b;
  --shadow:    0 4px 24px rgba(0,0,0,.6);
  --shadow2:   0 2px 8px rgba(0,0,0,.4);
  --r:         6px;
  --r2:        10px;
  --font-ui:   'Rajdhani', 'Segoe UI', sans-serif;
  --font-mono: 'Space Mono', 'Courier New', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  background: var(--bg) !important;
  color: var(--text) !important;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
body.app-ready {}

/* ── SharePoint hardening ─────────────────────────────────────── */
body *, body *::before, body *::after { color: inherit; }
a { color: var(--cyan) !important; text-decoration: none; }
a:hover { color: var(--accent2) !important; text-decoration: underline; }
h1,h2,h3,h4,h5,h6,p,span,label,li,td,th,div { color: inherit; }
select,input,button,textarea { color: var(--text) !important; background-color: var(--bg3) !important; }

/* ── Loading overlay ──────────────────────────────────────────── */
#loadingState {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 20px;
}
#loadingState.hidden { display: none; }
.loading-title {
  font-size: 2rem; font-weight: 700; letter-spacing: .15em;
  color: var(--accent) !important; text-transform: uppercase;
}
.loading-bar-wrap { width: 320px; height: 4px; background: var(--bg3); border-radius: 2px; overflow: hidden; }
.loading-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--cyan)); border-radius: 2px; transition: width .3s; }
.loading-status { color: var(--text2) !important; font-size: .85rem; letter-spacing: .05em; }
.loading-radar-wrap { position: relative; width: 160px; height: 160px; flex-shrink: 0; }
.loading-radar { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; border: 3px solid var(--border2); border-top-color: var(--accent); animation: spin 1s linear infinite; }
.loading-logo { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 124px; height: 124px; border-radius: 50%; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100%{opacity:.5} 50%{opacity:.9} }

/* ── Health banner ────────────────────────────────────────────── */
#healthBanner { background: #7f1d1d; color: #fecaca !important; padding: 10px 20px; font-size: .85rem; font-family: var(--font-mono); display: none; }
#healthBanner.visible { display: block; }

/* ── Header ───────────────────────────────────────────────────── */
#header { position: sticky; top: 0; z-index: 200; background: var(--bg2); border-bottom: 1px solid var(--border); box-shadow: 0 2px 16px rgba(0,0,0,.5); }
.header-top { display: flex; align-items: center; gap: 16px; padding: 10px 20px; border-bottom: 1px solid var(--border); transition: padding .25s ease; }
.header-logo { height: 36px; object-fit: contain; }
.site-logo { width: 124px; height: 124px; flex-shrink: 0; display: block; border-radius: 50%; transition: width .25s ease, height .25s ease, margin .25s ease, opacity .25s ease; }
.header-logo-placeholder { height: 36px; display: flex; align-items: center; font-weight: 700; font-size: 1.1rem; color: var(--accent) !important; letter-spacing: .12em; text-transform: uppercase; }
.header-titles { flex: 1; min-width: 0; }
.header-titles h1 { font-size: 1.4rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent) !important; line-height: 1.1; transition: font-size .25s ease; }
.header-titles p { font-size: .78rem; color: var(--text2) !important; margin-top: 2px; max-height: 40px; overflow: hidden; transition: max-height .2s ease, opacity .2s ease; }
.version-badge { font-size: .7rem; font-weight: 600; letter-spacing: .04em; color: var(--accent) !important; background: var(--bg3); border: 1px solid var(--border2); border-radius: 4px; padding: 1px 7px; vertical-align: middle; text-transform: none; margin-left: 4px; }
.header-titles p a { color: var(--cyan) !important; }

.header-search { display: flex; align-items: center; padding: 6px 20px 8px; border-bottom: 1px solid var(--border); }
.header-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 20px; }
#q { flex: 1; min-width: 180px; max-width: none; background: var(--bg3) !important; border: 1px solid var(--border2); border-radius: var(--r); padding: 7px 12px; font-family: var(--font-ui); font-size: .9rem; color: var(--text) !important; outline: none; transition: border-color .2s; }
#q:focus { border-color: var(--accent); }
#q::placeholder { color: var(--text3) !important; }

.filter-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; flex: 1; }
.pinned-filter { cursor: pointer; }
.pinned-filter input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.pinned-filter input:checked + .pinned-trigger { border-color: var(--accent); color: var(--accent) !important; }

/* ── Multi-select filter dropdowns ───────────────────────────── */
.ms-filter-wrap {
  position: relative; display: inline-block;
}
.ms-trigger {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg3) !important; border: 1px solid var(--border2);
  border-radius: var(--r); padding: 6px 10px;
  font-family: var(--font-ui); font-size: .82rem;
  color: var(--text2) !important; cursor: pointer; outline: none;
  max-width: 180px; min-width: 110px; transition: border-color .2s;
  white-space: nowrap; overflow: hidden;
}
.ms-trigger:hover, .ms-trigger:focus { border-color: var(--accent); }
.ms-filter-wrap.has-selection .ms-trigger { border-color: var(--accent); color: var(--accent) !important; }
.ms-trigger-label { overflow: hidden; text-overflow: ellipsis; flex: 1; text-align: left; }
.ms-arrow { font-size: .7rem; flex-shrink: 0; transition: transform .2s; color: var(--text3) !important; }
.ms-filter-wrap.open .ms-arrow { transform: rotate(180deg); }

.ms-panel {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 300;
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: var(--r2); min-width: 200px; max-width: 280px;
  max-height: 280px; overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,.6);
  display: none;
}
.ms-filter-wrap.open .ms-panel { display: block; }

.ms-option {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; font-size: .82rem; cursor: pointer;
  color: var(--text2) !important; transition: background .12s;
  border-bottom: 1px solid var(--border);
}
.ms-option:last-child { border-bottom: none; }
.ms-option:hover:not(.disabled) { background: var(--bg3); color: var(--text) !important; }
.ms-option.all-opt { color: var(--accent) !important; font-weight: 600; }
.ms-option.all-opt.active { background: rgba(200,168,75,.1); }
.ms-option.checked { color: var(--text) !important; }
.ms-option.disabled { opacity: .4; cursor: default; }
.ms-check { width: 14px; height: 14px; border: 1px solid var(--border2); border-radius: 3px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: .7rem; color: var(--accent) !important; }
.ms-option.checked .ms-check { background: rgba(200,168,75,.2); border-color: var(--accent); }
.ms-val { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-count { font-size: .72rem; color: var(--text3) !important; flex-shrink: 0; font-family: var(--font-mono); }

.header-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 0 20px 10px; }

.btn { display: inline-flex; align-items: center; gap: 5px; padding: 6px 12px; border-radius: var(--r); font-family: var(--font-ui); font-size: .82rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; border: 1px solid transparent; cursor: pointer; transition: all .2s; white-space: nowrap; }
.btn-ghost { background: transparent; border-color: var(--border2); color: var(--text2) !important; }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent) !important; }
.btn-accent { background: var(--accent); color: var(--text) !important; border-color: var(--accent); font-weight: 700; }  /* FR-CMP-BTN-1: light text */
.btn-accent:hover { background: var(--accent2); border-color: var(--accent2); }
.btn-cyan { background: transparent; border-color: var(--cyan); color: var(--cyan) !important; }
.btn-cyan:hover { background: rgba(79,195,247,.12); }

#resultStats { font-size: .8rem; color: var(--text3) !important; font-family: var(--font-mono); white-space: nowrap; padding: 0 4px; }
#filtersActive { font-size: .78rem; color: var(--accent) !important; cursor: pointer; border: 1px solid var(--accent); border-radius: var(--r); padding: 4px 8px; display: none; font-weight: 600; letter-spacing: .04em; }
#filtersActive.visible { display: inline-block; }
#filtersActive:hover { background: rgba(200,168,75,.15); }

/* ── Compare bar ──────────────────────────────────────────────── */
#compareBar { display: none; align-items: center; gap: 10px; background: #0f1e35; border-top: 1px solid var(--border2); padding: 8px 20px; flex-wrap: wrap; }
#compareBar.visible { display: flex; }
#compareBar > span { font-size: .82rem; color: var(--text2) !important; font-weight: 600; letter-spacing: .06em; flex-shrink: 0; }
#compareItems { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }

.cmp-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: 20px; padding: 3px 10px 3px 4px;
  font-size: .78rem; color: var(--text) !important; max-width: 220px;
}
.cmp-chip-thumb {    /* FR-CMP-THUMB-1 */
  width: 28px; height: 28px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0; background: var(--bg2);
  border: 1px solid var(--border2);
}
.cmp-chip-thumb-ph {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: var(--bg2); border: 1px solid var(--border2);
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem;
}
.cmp-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmp-chip-rm { cursor: pointer; color: var(--text3) !important; font-size: .9rem; line-height: 1; flex-shrink: 0; background: none; border: none; padding: 0; font-family: inherit; }
.cmp-chip-rm:hover { color: var(--red) !important; }

/* ── Main grid ────────────────────────────────────────────────── */
#main { padding: 20px; }
.section-notice { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--r2); padding: 16px 20px; margin-bottom: 16px; color: var(--text2) !important; font-size: .88rem; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
#grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }

/* ── Card ─────────────────────────────────────────────────────── */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--r2); overflow: hidden; display: flex; flex-direction: column; transition: border-color .2s, transform .15s, box-shadow .2s; position: relative; }
.card:hover { border-color: var(--border2); box-shadow: var(--shadow); transform: translateY(-2px); }
.card-thumb-wrap { position: relative; height: 160px; overflow: hidden; background: var(--bg3); cursor: pointer; flex-shrink: 0; }
.card-thumb { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease, opacity .3s; }
.card-thumb-b { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .6s; }
.card-thumb-b.show { opacity: 1; }
.card:hover .card-thumb { transform: scale(1.04); }
.card-thumb-wrap::after { content: ''; position: absolute; inset: 0; background: linear-gradient(to top, rgba(8,11,18,.7) 0%, transparent 50%); pointer-events: none; }

/* FR-PIN-ICON-1: distinct pinned vs unpinned state */
.card-pin {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(8,11,18,.7); border: 1px solid var(--border2);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: .9rem; transition: all .2s;
  color: var(--text3) !important; opacity: .6;
}
.card-pin:hover { background: rgba(245,158,11,.2); border-color: var(--pin); color: var(--pin) !important; opacity: 1; }
.card-pin.pinned {
  background: rgba(245,158,11,.3); border-color: var(--pin);
  color: var(--pin) !important; opacity: 1;
  box-shadow: 0 0 8px rgba(245,158,11,.4);
  transform: rotate(-45deg);   /* angled = "stuck in" */
}

.card-cat-badge { position: absolute; top: 8px; left: 8px; z-index: 2; font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; background: rgba(8,11,18,.75); border: 1px solid var(--border2); border-radius: 4px; padding: 2px 6px; color: var(--accent) !important; }
.card-body { padding: 12px 14px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.card-title { font-size: 1rem; font-weight: 700; line-height: 1.2; color: var(--text) !important; letter-spacing: .03em; }
.card-nick { font-size: .78rem; color: var(--text3) !important; }
.card-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: .7rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; border-radius: 4px; padding: 2px 7px; border: 1px solid; }
.chip-cat   { border-color: var(--border2); color: var(--text2) !important; }
.chip-sub   { border-color: #2a3d5c; color: var(--cyan) !important; background: rgba(79,195,247,.07); }
.chip-domain-Civil    { border-color: #1a3a2a; color: var(--green) !important; background: rgba(102,187,106,.07); }
.chip-domain-Defence  { border-color: #3a1a1a; color: #ef9a9a !important; background: rgba(239,83,80,.07); }
.chip-domain-Dual-Use { border-color: #3a2e0a; color: var(--accent) !important; background: rgba(200,168,75,.07); }
.card-meta { display: flex; flex-direction: column; gap: 3px; }
.meta-row { display: flex; gap: 6px; font-size: .78rem; }
.meta-label { color: var(--text3) !important; min-width: 80px; flex-shrink: 0; }
.meta-val { color: var(--text2) !important; }
.card-summary { font-size: .82rem; color: var(--text2) !important; line-height: 1.5; position: relative; }
.summary-text { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.summary-text.expanded { -webkit-line-clamp: unset; display: block; }
.summary-fade { position: absolute; bottom: 0; left: 0; right: 0; height: 40px; background: linear-gradient(transparent, var(--card)); pointer-events: none; }
.summary-fade.hidden { display: none; }
.summary-toggle { font-size: .75rem; color: var(--cyan) !important; cursor: pointer; background: none; border: none; padding: 2px 0; font-family: inherit; }
.card-specs { display: none; flex-direction: column; gap: 3px; border-top: 1px solid var(--border); padding-top: 8px; }
.card-specs.open { display: flex; }
.spec-row { display: flex; gap: 6px; font-size: .75rem; }
.spec-label { color: var(--text3) !important; min-width: 76px; flex-shrink: 0; }
.spec-val { color: var(--text) !important; font-family: var(--font-mono); }
.card-footer { display: flex; align-items: center; justify-content: space-between; padding: 8px 14px; border-top: 1px solid var(--border); background: rgba(0,0,0,.2); }
.card-wiki-link { font-size: .75rem; color: var(--cyan) !important; text-transform: uppercase; letter-spacing: .05em; }
.specs-toggle { font-size: .75rem; color: var(--text3) !important; cursor: pointer; background: none; border: none; font-family: inherit; padding: 0; text-transform: uppercase; letter-spacing: .05em; }
.specs-toggle:hover { color: var(--text2) !important; }


/* ── Lightbox ─────────────────────────────────────────────────── */
/* FR-LB-SIZE-1: min 600×400, max 75vw/75vh */
#lightbox {
  position: fixed; inset: 0; z-index: 600;
  background: rgba(0,0,0,.92);
  display: none; align-items: center; justify-content: center;
}
#lightbox.open { display: flex; }

.lb-panel {
  position: relative;
  background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--r2);
  width: min(75vw, 960px); min-width: min(600px, 95vw);
  max-height: 75vh; min-height: 400px;
  display: flex; flex-direction: column;
  box-shadow: 0 16px 60px rgba(0,0,0,.8);
  overflow: hidden;
}

.lb-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
#lbTitle { font-size: 1.05rem; font-weight: 700; color: var(--text) !important; letter-spacing: .04em; }
#lbWiki { font-size: .8rem; color: var(--cyan) !important; margin-left: 10px; }
#lbClose { background: none; border: none; color: var(--text2) !important; font-size: 1.4rem; cursor: pointer; padding: 0 4px; line-height: 1; }
#lbClose:hover { color: var(--text) !important; }

.lb-img-area {
  flex: 1; display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden; min-height: 200px; background: var(--bg3);
}
/* FR-LB-IMG-1: contain, no crop */
#lbImg { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }

/* FR-LB-NAV-1: fixed position arrows that don't shift with image size */
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(8,11,18,.75); border: 1px solid var(--border2);
  color: var(--text2) !important; font-size: 1.4rem;
  cursor: pointer; border-radius: 50%; width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  transition: all .2s; z-index: 2; flex-shrink: 0;
}
.lb-nav:hover { background: var(--bg3); color: var(--text) !important; }
#lbPrev { left: 8px; }
#lbNext { right: 8px; }

/* FR-LB-SUMMARY-1: synopsis below image */
#lbSummary {
  padding: 10px 16px; font-size: .82rem; color: var(--text2) !important;
  line-height: 1.5; border-top: 1px solid var(--border);
  max-height: 80px; overflow-y: auto; flex-shrink: 0;
}

.lb-footer {
  padding: 8px 16px; border-top: 1px solid var(--border); flex-shrink: 0;
  display: flex; flex-direction: column; gap: 6px;
}
#lbCaption { font-size: .78rem; text-align: left; padding: 2px 0; min-height: 1.2em; line-height: 1.4; }
#lbThumbs { display: flex; gap: 6px; overflow-x: auto; padding: 2px; }
/* ── Filter group headers (FR-FILT-GROUP-*) ─────────────────── */
.ms-group-header {
  font-size: .65rem; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--accent) !important;
  padding: 8px 10px 3px; margin-top: 4px;
  border-top: 1px solid var(--border);
  pointer-events: none; user-select: none;
}
.ms-group-header:first-child { margin-top: 0; border-top: none; }

.lb-thumb { width: 52px; height: 38px; object-fit: cover; flex-shrink: 0; border-radius: 4px; cursor: pointer; opacity: .5; border: 2px solid transparent; transition: all .2s; }
.lb-thumb.active { opacity: 1; border-color: var(--accent); }
.lb-thumb:hover { opacity: .85; }

/* ── Lightbox tabs (FR-LB-TAB-*) ─────────────────────────────── */
.lb-panel {
  max-height: 85vh;
}
.lb-header-title { display: flex; align-items: baseline; gap: 0; flex-wrap: wrap; }

.lb-tabs {
  display: flex; flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg3); padding: 0 8px;
}
.lb-tab {
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text2) !important; font-size: .82rem; font-weight: 600;
  padding: 8px 14px; cursor: pointer; letter-spacing: .03em;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}
.lb-tab:hover { color: var(--text) !important; }
.lb-tab.active { color: var(--accent) !important; border-bottom-color: var(--accent); }

.lb-tab-pane { display: none; flex: 1; overflow-y: auto; min-height: 0; flex-direction: column; }
.lb-tab-pane.active { display: flex; }

/* Gallery tab inherits original layout */
#lbTabGallery { flex-direction: column; }
#lbTabGallery .lb-img-area { flex: 1; min-height: 180px; }

/* ── Specs tab ────────────────────────────────────────────────── */
#lbTabSpecs { padding: 0; overflow-y: auto; }
#lbSpecsBody { padding: 16px; display: flex; flex-direction: column; gap: 16px; }

.spec-group { }
.spec-group-title {
  font-size: .7rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text3) !important; margin-bottom: 8px;
  padding-bottom: 4px; border-bottom: 1px solid var(--border);
}
.spec-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 2px 24px;
}
.spec-row {
  display: grid; grid-template-columns: minmax(80px, auto) 1fr;
  gap: 0 10px; align-items: baseline; padding: 3px 0;
  border-bottom: 1px solid var(--border);
}
.spec-row-long { grid-column: 1 / -1; }
.spec-row-long .spec-label { white-space: normal; }
.spec-label { font-size: .73rem; color: var(--text3) !important; white-space: nowrap; font-weight: 600; }
.spec-value { font-size: .82rem; color: var(--text) !important; word-break: break-word; }
.spec-value.long { white-space: pre-wrap; font-size: .78rem; color: var(--text2) !important; line-height: 1.5; }

/* ── News tab ─────────────────────────────────────────────────── */
#lbTabNews  { padding: 0; overflow-y: auto; flex-direction: column; }
#lbNewsBody { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }

.news-source-label {
  font-size: .68rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--text3) !important; margin-bottom: 4px;
}
.news-item {
  background: var(--bg3); border: 1px solid var(--border); border-radius: var(--r1);
  padding: 10px 12px; display: flex; flex-direction: column; gap: 4px;
  transition: border-color .15s;
}
.news-item:hover { border-color: var(--accent); }
.news-item.expanded { border-color: var(--accent); }
.news-item-title {
  background: none; border: none; padding: 0; text-align: left; cursor: pointer;
  font-size: .85rem; font-weight: 600; color: var(--cyan) !important; line-height: 1.35;
  font-family: inherit;
}
.news-item-title:hover { text-decoration: underline; }
.news-item-pane { display: none; flex-direction: column; gap: 6px; margin-top: 4px; }
.news-item.expanded .news-item-pane { display: flex; }
.news-item-read {
  font-size: .8rem; font-weight: 600; color: var(--accent) !important;
  text-decoration: none; align-self: flex-start;
}
.news-item-read:hover { text-decoration: underline; }
.news-item-meta { font-size: .72rem; color: var(--text3) !important; }
.news-item-desc { font-size: .78rem; color: var(--text2) !important; line-height: 1.45; }
.news-empty { font-size: .82rem; color: var(--text3) !important; padding: 8px 0; }

/* ── NASA Media tab ───────────────────────────────────────────── */
#lbTabMedia  { padding: 0; overflow-y: auto; flex-direction: column; }
#lbMediaBody { padding: 14px 16px; }

.nasa-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px;
}
.nasa-thumb {
  position: relative; border-radius: var(--r1); overflow: hidden;
  background: var(--bg3); border: 1px solid var(--border);
  aspect-ratio: 16/9; cursor: pointer; transition: border-color .15s;
}
.nasa-thumb:hover { border-color: var(--accent); }
.nasa-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nasa-thumb-label {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,.72); font-size: .65rem; color: #fff;
  padding: 3px 5px; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nasa-type-badge {
  position: absolute; top: 4px; right: 4px;
  background: var(--accent); color: #000; font-size: .6rem; font-weight: 700;
  padding: 1px 4px; border-radius: 3px;
}

/* Loading / error states */
.lb-loading { font-size: .82rem; color: var(--text3) !important; padding: 24px 0; text-align: center; }
.lb-error   { font-size: .82rem; color: #e05; padding: 12px 0; }

/* ── Compare modal ────────────────────────────────────────────── */
/* ── Compare modal ────────────────────────────────────────────── */
#compareModal { position: fixed; inset: 0; z-index: 700; background: rgba(0,0,0,.88); display: none; align-items: center; justify-content: center; padding: 24px; }
#compareModal.open { display: flex; }
.compare-panel {
  background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--r2);
  width: 100%; max-width: 80vw;   /* FR-CMP-WIDTH-1: 80% */
  max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.compare-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.compare-header h2 { font-size: 1.1rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent) !important; }
.compare-toolbar { display: flex; gap: 8px; align-items: center; }
.compare-body { flex: 1; overflow: auto; }
#cmpGrid { display: grid; min-width: max-content; width: 100%; }
.cmp-cell { padding: 8px 12px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); font-size: .82rem; color: var(--text) !important; background: var(--bg2); min-width: 180px; }
.cmp-cell:last-child { border-right: none; }
.cmp-field-cell { color: var(--text3) !important; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; background: var(--bg3) !important; position: sticky; left: 0; z-index: 2; border-right: 2px solid var(--border2) !important; }
.cmp-header-cell { font-weight: 700; color: var(--accent) !important; font-size: .88rem; letter-spacing: .04em; background: var(--bg3) !important; position: sticky; top: 0; z-index: 3; text-align: center; }
.cmp-header-cell.cmp-field-cell { z-index: 4; }
/* FR-CMP-IMG-1: doubled height, contain, no crop */
.cmp-img { width: 100%; height: 160px; object-fit: contain; border-radius: 4px; display: block; background: var(--bg3); }
.cmp-row:hover .cmp-cell { background: var(--card-h); }
.cmp-row:hover .cmp-field-cell, .cmp-row:hover .cmp-header-cell { background: var(--bg3) !important; }

/* ── Charts modal ─────────────────────────────────────────────── */
#chartModal { position: fixed; inset: 0; z-index: 700; background: rgba(0,0,0,.88); display: none; align-items: center; justify-content: center; padding: 12px; }
#chartModal.open { display: flex; }
.chart-panel { background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--r2); width: min(96vw, 1600px); max-width: 96vw; height: 90vh; max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.chart-header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.chart-header h2 { font-size: 1rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent) !important; flex: 1; }
#chartPreset { flex: 1 1 240px; max-width: 360px; }
.chart-toolbar { display: flex; gap: 6px; flex-shrink: 0; }
.chart-body {
  flex: 1;
  min-height: 0;   /* critical: lets flex child shrink below content size so it fills exactly */
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
#chartCanvas { display: block; max-width: 100%; max-height: 100%; }
#chartStats { position: absolute; top: 8px; right: 12px; font-size: .72rem; color: var(--text3) !important; font-family: var(--font-mono); }
#chartTooltip { position: fixed; z-index: 800; background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--r2); padding: 10px 12px; box-shadow: var(--shadow); display: none; min-width: 180px; }
#chartTooltip.show { display: block; }
#chartTooltip.pinned { cursor: move; border-color: var(--accent); }
#chartTipImg { width: 100%; height: 80px; object-fit: contain; border-radius: 4px; margin-bottom: 8px; display: block; background: var(--bg3); }
#chartTipTitle { font-weight: 700; font-size: .88rem; color: var(--text) !important; margin-bottom: 4px; }
#chartTipXY { font-size: .78rem; color: var(--text2) !important; font-family: var(--font-mono); margin-bottom: 8px; }
.tip-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.tip-btn { font-size: .72rem; padding: 3px 8px; border-radius: 4px; background: var(--bg3); border: 1px solid var(--border2); color: var(--text2) !important; cursor: pointer; font-family: inherit; }
.tip-btn:hover { border-color: var(--accent); color: var(--accent) !important; }

/* ── Placeholder images ───────────────────────────────────────── */
.img-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: var(--bg3); color: var(--text3) !important; font-size: 2.5rem; user-select: none; }

/* ── Empty / load-more ────────────────────────────────────────── */
#emptyState { grid-column: 1/-1; text-align: center; padding: 60px 20px; color: var(--text3) !important; font-size: 1.1rem; letter-spacing: .05em; }
#loadMoreWrap { grid-column: 1/-1; display: flex; justify-content: center; padding: 20px; display: none; }
#loadMoreWrap.visible { display: flex; }

/* ── Ad cards (native in-feed) ────────────────────────────────── */
.ad-card { min-height: 200px; position: relative; overflow: hidden; cursor: default; }
.ad-card:hover { transform: none; box-shadow: none; }
.ad-card-label { position: absolute; top: 8px; left: 8px; z-index: 2; background: rgba(8,11,18,.75); color: var(--text3) !important; font-size: .62rem; letter-spacing: .1em; text-transform: uppercase; padding: 2px 6px; border-radius: 3px; pointer-events: none; }
.ad-card .adsbygoogle { display: block; width: 100%; min-height: 200px; }
.ad-card-placeholder { display: flex; align-items: center; justify-content: center; min-height: 200px; color: var(--text3) !important; font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; }
.ad-card-close { position: absolute; top: 8px; right: 8px; z-index: 3; background: rgba(8,11,18,.7); border: 1px solid var(--border2); border-radius: 50%; width: 24px; height: 24px; cursor: pointer; color: var(--text2) !important; font-size: .75rem; display: flex; align-items: center; justify-content: center; transition: background .15s; }
.ad-card-close:hover { background: rgba(8,11,18,.95); color: var(--text) !important; }

/* ── Bottom ad banner (dismissable) ──────────────────────────── */
#adBanner { position: fixed; bottom: 0; left: 0; right: 0; z-index: 190; background: var(--bg2); border-top: 1px solid var(--border); display: none; align-items: center; justify-content: center; padding: 4px 40px 4px 4px; height: 100px; overflow: hidden; }
#adBanner.visible { display: flex; }
#adBanner .adsbygoogle { height: 90px; max-height: 90px; width: 100%; max-width: 728px; }
.ad-banner-close { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: var(--bg3); border: 1px solid var(--border2); border-radius: 50%; width: 26px; height: 26px; cursor: pointer; color: var(--text2) !important; font-size: .85rem; display: none; align-items: center; justify-content: center; flex-shrink: 0; }
.ad-banner-close.visible { display: flex; }
#main { padding-bottom: 116px; }

/* ── Responsive ───────────────────────────────────────────────── */
.header-toggle-btn { display: none; }

/* ── Wikipedia attribution footer ────────────────────────────── */
#wikiAttrib { text-align: center; padding: 18px 20px; font-size: .75rem; color: var(--text2) !important; border-top: 1px solid var(--border); margin-top: 24px; }
#wikiAttrib a { color: var(--cyan) !important; }

/* ── Lightbox attribution ─────────────────────────────────────── */
.lb-attrib { display: block; font-size: .72rem; color: var(--text2) !important; padding: 4px 20px 0; text-decoration: underline; }

@media (hover: none) and (pointer: coarse) {
  /* Fixed header — only header-top visible; filters live in bottom sheet */
  #header { position: fixed; left: 0; right: 0; top: 0; z-index: 410; }
  .site-logo { width: 56px; height: 56px; }
  .header-toggle-btn { display: inline-flex; }
  /* Two-row header: logo+title on row1, stats+toggle on row2 */
  .header-top { flex-wrap: wrap; padding: 8px 14px 4px; gap: 4px 12px; align-items: center; }
  .header-titles h1 { font-size: 1.0rem; }
  .header-titles p { display: none; }
  #headerTopActions { flex-basis: 100%; padding: 0 0 4px; }

  /* Compact action row */
  .header-actions { padding: 4px 14px 6px; gap: 4px; }
  .header-actions .btn { font-size: .75rem; padding: 5px 9px; min-height: 36px; }

  /* Mini (swipe-collapsed) single-line state */
  #header.hdr-mini .site-logo { width: 0; height: 0; margin: 0; opacity: 0; }
  #header.hdr-mini .header-titles p { max-height: 0; opacity: 0; }
  #header.hdr-mini .header-titles h1 { font-size: 1.0rem; }
  #header.hdr-mini .header-top { padding: 6px 12px; flex-wrap: nowrap; }
  #header.hdr-mini #headerTopActions { flex-basis: auto; padding: 0; }
  #header.hdr-mini .header-actions { display: none; }

  /* ── Filter bottom sheet ─────────────────────────────────────── */
  .header-controls {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--bg2);
    border-top: 2px solid var(--border2);
    box-shadow: 0 -4px 32px rgba(0,0,0,.6);
    z-index: 400;
    max-height: 72vh; overflow-y: auto;
    transform: translateY(100%);
    transition: transform .3s ease;
    padding: 16px 14px 24px;
    display: flex; flex-direction: column; gap: 6px;
  }
  .header-controls.sheet-open { transform: translateY(0); }
  #filterBdp {
    display: none; position: fixed; inset: 0; z-index: 399;
    background: rgba(0,0,0,.5);
  }
  #filterBdp.visible { display: block; touch-action: none; }

  /* Search row on mobile */
  .header-search { padding: 4px 14px 6px; border-bottom: none; }
  #q { min-width: 0; }
  #resultStats { display: none; }
  #header.hdr-mini .header-search { display: none; }
  .filter-row { flex-direction: column; flex-wrap: nowrap; overflow: visible; gap: 4px; width: 100%; padding-bottom: 0; }
  .ms-filter-wrap { flex-shrink: unset; width: 100%; }
  .ms-trigger { max-width: none; min-width: 0; width: 100%; min-height: 44px; }
  .pinned-filter { width: 100%; }
  #clear { width: 100%; min-height: 44px; }

  /* ── 44px tap targets ───────────────────────────────────────── */
  .card-pin { width: 44px; height: 44px; }
  .cmp-chip-rm { min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; }
  .btn { min-height: 44px; }
  .header-actions .btn { min-height: 36px; }

  /* ── Compare bar — fixed above ad banner ────────────────────── */
  #compareBar {
    position: fixed; bottom: 54px; left: 0; right: 0;
    flex-direction: column; gap: 8px; padding: 10px 14px;
    z-index: 350; border-top: 1px solid var(--border2);
  }
  #compareItems { justify-content: flex-start; }

  /* Compact cards */
  .card-chips, .card-meta, .card-summary, .card-footer { display: none !important; }
  .card-specs { display: none !important; }
  .card-body { padding: 8px 10px; gap: 3px; }
  .card-title { font-size: .82rem; }
  .card-nick  { font-size: .72rem; }

  /* Grid & modals */
  #main { padding: 12px; padding-top: 182px; padding-bottom: 160px; }
  #grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .chart-panel { width: 96vw; max-width: 96vw; height: 90vh; max-height: 90vh; }
  .compare-panel { max-width: 98vw; }
  .lb-panel { min-width: 95vw; width: 95vw; }

  /* Ad banner */
  #adBanner { height: 54px; }
  #adBanner .adsbygoogle { height: 50px; max-height: 50px; max-width: 100%; }
}
/* ── Mobile landscape: keep compact header when phone is rotated ── */
@media (hover: none) and (pointer: coarse) and (orientation: landscape) {
  #header { position: fixed; left: 0; right: 0; top: 0; z-index: 410; }
  .site-logo { width: 44px; height: 44px; }
  .header-titles h1 { font-size: 1.05rem; }
  .header-titles p { display: none; }
  .header-toggle-btn { display: inline-flex; }
  .header-actions { padding: 3px 14px 4px; gap: 4px; }
  .header-actions .btn { font-size: .72rem; padding: 4px 8px; min-height: 32px; }
  #header.hdr-mini .site-logo { width: 0; height: 0; margin: 0; opacity: 0; }
  #header.hdr-mini .header-titles h1 { font-size: .9rem; }
  #header.hdr-mini .header-top { padding: 4px 12px; }
  #header.hdr-mini .header-actions { display: none; }
  .header-search { display: none; }
  .header-controls {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--bg2); border-top: 2px solid var(--border2);
    box-shadow: 0 -4px 32px rgba(0,0,0,.6);
    z-index: 400; max-height: 80vh; overflow-y: auto;
    transform: translateY(100%); transition: transform .3s ease;
    padding: 12px 14px 16px; display: flex; flex-direction: column; gap: 5px;
  }
  .header-controls.sheet-open { transform: translateY(0); }
  #filterBdp { display: none; position: fixed; inset: 0; z-index: 399; background: rgba(0,0,0,.5); }
  #filterBdp.visible { display: block; }
  /* Compact cards — same as portrait mobile */
  .card-chips, .card-meta, .card-summary, .card-footer { display: none !important; }
  .card-specs { display: none !important; }
  .card-body { padding: 8px 10px; gap: 3px; }
  .card-title { font-size: .82rem; }
  .card-nick  { font-size: .72rem; }
  /* 4-column card grid in landscape */
  #grid { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  #main { padding: 10px; padding-top: 90px; padding-bottom: 68px; }
  .lb-panel { min-width: 95vw; width: 95vw; }
  #adBanner { height: 46px; }
  #adBanner .adsbygoogle { height: 44px; max-height: 44px; }
}

/* ── Scrollbar ────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ── Print (FR-PRINT-IMG-1) ───────────────────────────────────── */
@media print {
  #header, #lightbox, #compareModal, #chartModal, #loadingState { display: none !important; }
  body { background: #fff !important; color: #000 !important; }
  .card { break-inside: avoid; border: 1px solid #ccc; background: #fff !important; }
  .card-title, .card-nick, .meta-label, .meta-val, .spec-label, .spec-val, .card-cat-badge { color: #000 !important; }
  #main { padding: 0; }
  /* Ensure images print — hide gradient overlay that renders as white box in print */
  .card-thumb-wrap::after { display: none; }
  .card-thumb-wrap { height: 140px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .card-thumb { display: block !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .summary-text { -webkit-line-clamp: unset; display: block; }
  .summary-fade { display: none; }
}
