/*
 * Project:   SWQSL Gallery
 * File:      assets/style.css
 * Version:   1.0.18
 * Revised:   2026-08-11
 *
 * Dark receiver-faceplate styling related to SWLog, but shifted toward QSL
 * green.  Recording panels retain SWLog's blue so the archive's two media
 * types remain visually distinct.
 */

:root {
  --case: #101512;
  --face: #19211d;
  --face-hi: #202a25;
  --well: #0b100d;
  --bezel: #334139;
  --green: #66d987;
  --green-hi: #8beca5;
  --green-dim: #2d7d45;
  --green-dark: #163a22;
  --blue: #8cc6f0;
  --blue-dim: #315f7c;
  --amber: #ffb454;
  --red: #e0705f;
  --text: #dce7df;
  --muted: #94a49a;
  --mono: "Share Tech Mono", "Courier New", monospace;
  --display: "Michroma", "Arial Black", sans-serif;
  --body: "Segoe UI", system-ui, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { color-scheme: dark; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font: 16px/1.55 var(--body);
  background:
    radial-gradient(1000px 480px at 50% -220px, rgba(61, 128, 80, .22), transparent 72%),
    var(--case);
}
button, input, select { font: inherit; }
a { color: var(--green-hi); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--green-hi); outline-offset: 3px; }
img { max-width: 100%; }

.wrap { width: min(1440px, 100%); margin: 0 auto; padding: 0 18px 44px; }

/* -------------------------------------------------------------------------
 * Header / app identity
 * ---------------------------------------------------------------------- */
.plate {
  margin: 18px 0 16px;
  border: 1px solid var(--bezel);
  border-radius: 12px;
  background: linear-gradient(180deg, #233029, #18211c 58%, #141b17);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .42), inset 0 1px rgba(255, 255, 255, .05);
  overflow: hidden;
}
.brand { display: flex; align-items: center; gap: 15px; padding: 16px 20px 12px; }
.brand-icon {
  display: block; width: 92px; height: 62px; flex: 0 0 92px;
  border-radius: 10px; overflow: hidden;
  background: #39413d;
  box-shadow: 0 0 0 1px rgba(139, 236, 165, .35), 0 4px 14px rgba(0, 0, 0, .45);
}
.brand-icon img { display: block; width: 100%; height: 100%; object-fit: cover; }
.brand h1 { margin: 0; font: 25px/1.2 var(--display); letter-spacing: .12em; color: #eef7f0; }
.brand h1 a { color: inherit; }
.subtitle { color: var(--muted); margin-top: 4px; letter-spacing: .08em; }
.controls { display: flex; gap: 4px; border-top: 1px solid var(--bezel); padding: 8px 12px; }
.controls a { padding: 8px 13px; border-radius: 6px; color: var(--text); }
.controls a:hover { background: rgba(102, 217, 135, .08); text-decoration: none; }
.controls a.on { color: var(--green-hi); background: #0d130f; box-shadow: inset 0 2px 6px rgba(0, 0, 0, .75); }

/* -------------------------------------------------------------------------
 * Panels, buttons and form controls
 * ---------------------------------------------------------------------- */
.panel {
  border: 1px solid var(--bezel);
  border-radius: 11px;
  background: var(--face);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .28);
  padding: 17px 19px;
  margin-bottom: 16px;
}
.panel h2 {
  margin: 0 0 12px;
  color: #c7d5cb;
  font: 14px/1.3 var(--display);
  letter-spacing: .16em;
  text-transform: uppercase;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 42px; padding: 8px 15px;
  border: 1px solid #45554b; border-radius: 7px;
  background: #202a25; color: var(--text); cursor: pointer;
}
.btn:hover { background: #28352e; text-decoration: none; }
.btn.primary { color: #07110a; background: linear-gradient(#71e394, #4bc876); border-color: #79eba0; font-weight: 700; }
.btn.primary:hover { background: linear-gradient(#83eca2, #5bd184); }
.btn.quiet { background: transparent; color: var(--muted); }
.btn.pdf-link { min-height: 34px; padding: 5px 10px; font-size: 13px; }

input[type=search], select {
  width: 100%; min-height: 43px;
  border: 1px solid #3b4b42; border-radius: 7px;
  padding: 9px 11px;
  color: var(--text); background: var(--well);
}
input:focus, select:focus { border-color: var(--green-dim); outline: none; box-shadow: 0 0 0 3px rgba(102, 217, 135, .12); }
label { color: var(--muted); font-size: 12px; letter-spacing: .09em; text-transform: uppercase; }

/* -------------------------------------------------------------------------
 * Search and filters
 * ---------------------------------------------------------------------- */
.search-panel h2 { color: var(--green-hi); }
.gallery-search { display: grid; gap: 14px; }
.search-main { display: grid; gap: 5px; }
.search-box { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.quick-tabs { display: flex; flex-wrap: wrap; gap: 8px; border-top: 1px solid #2d3932; padding-top: 13px; }
.quick-tab {
  display: inline-flex; gap: 8px; align-items: center;
  border: 1px solid #385044; border-radius: 7px;
  padding: 7px 11px; color: #b9c8bd; background: #111713;
}
.quick-tab span { color: var(--muted); font-family: var(--mono); }
.quick-tab.on { color: var(--green-hi); border-color: var(--green-dim); background: rgba(45, 125, 69, .18); }
.quick-tab:hover { text-decoration: none; border-color: var(--green); }
.filter-grid { display: grid; grid-template-columns: repeat(5, minmax(145px, 1fr)) auto; gap: 10px; align-items: end; }
.filter-grid label { display: grid; gap: 4px; }
.filter-actions { display: flex; gap: 7px; }

.gallery-meta { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 5px 3px 12px; color: var(--muted); }
.gallery-meta strong { color: var(--green-hi); font: 22px var(--mono); }

/* -------------------------------------------------------------------------
 * Totals & Stats
 *
 * These components deliberately stay in the gallery's green palette rather
 * than copying SWLog's amber statistics treatment. The structure is similar
 * to SWLog—large counter cards, a long-term bar chart, and a compact table—
 * while remaining visually part of SWQSL.
 * ---------------------------------------------------------------------- */
.totals-page { display: grid; gap: 0; }
.stats-title-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 18px; margin-bottom: 15px;
}
.stats-title-row h2 { margin-bottom: 5px; color: var(--green-hi); }
.stats-title-row p { margin: 0; color: var(--muted); max-width: 850px; }
.stats-title-row p strong { color: #c9d8ce; font-weight: 600; }
.stats-card-grid {
  display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 14px;
}
.stat-card {
  min-height: 122px; display: grid; place-content: center; gap: 6px;
  text-align: center; border: 1px solid #2d4937; border-radius: 9px;
  background: linear-gradient(180deg, #111713, #090d0b);
  box-shadow: inset 0 1px rgba(255,255,255,.025), 0 5px 14px rgba(0,0,0,.28);
}
.stat-card strong {
  color: var(--green-hi); font: 38px/1 var(--mono); letter-spacing: .05em;
  text-shadow: 0 0 12px rgba(102,217,135,.24);
}
.stat-card span {
  color: #a9bbb0; font: 12px/1.3 var(--display);
  letter-spacing: .13em; text-transform: uppercase;
}
.chart-summary { color: var(--muted); font-size: 13px; white-space: nowrap; padding-top: 3px; }
.year-chart-scroll {
  overflow-x: auto; overflow-y: hidden; padding: 8px 0 2px;
  scrollbar-color: var(--green-dim) #101612; scrollbar-width: thin;
  overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch;
}
.year-chart {
  --year-columns: 1;
  height: 292px; display: grid;
  grid-template-columns: repeat(var(--year-columns), minmax(14px, 1fr));
  align-items: stretch; gap: 3px; padding: 0 8px 2px;
  border-bottom: 1px solid #3a4b40;
  background:
    linear-gradient(to top,
      transparent 24.5%, rgba(109,143,120,.10) 25%, transparent 25.5%,
      transparent 49.5%, rgba(109,143,120,.10) 50%, transparent 50.5%,
      transparent 74.5%, rgba(109,143,120,.10) 75%, transparent 75.5%);
}
.year-column {
  min-width: 0; height: 100%; display: grid;
  grid-template-rows: 24px minmax(0, 1fr) 30px; align-items: end;
}
.year-count {
  min-height: 20px; align-self: end; text-align: center;
  color: var(--green-hi); font: 11px/1 var(--mono);
}
.year-bar-area { height: 100%; display: flex; align-items: flex-end; justify-content: center; }
.year-bar-fill {
  display: block; width: min(75%, 18px); min-height: 5px;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, var(--green-hi), #45b969);
  box-shadow: 0 0 8px rgba(102,217,135,.18);
}
.year-column.is-zero .year-bar-fill { height: 0 !important; min-height: 0; box-shadow: none; }
.year-label {
  align-self: start; padding-top: 7px; min-height: 27px;
  color: var(--muted); font: 10px/1 var(--mono); text-align: center;
  white-space: nowrap;
}
.year-chart-scale {
  display: flex; justify-content: space-between; gap: 14px;
  margin-top: 7px; color: var(--muted); font-size: 12px;
}
.stats-table-wrap { overflow-x: auto; }
.stats-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.stats-table th, .stats-table td {
  padding: 10px 12px; border-bottom: 1px solid #304038; text-align: right;
}
.stats-table thead th {
  color: #a8b9ae; font: 11px/1.3 var(--display);
  letter-spacing: .11em; text-transform: uppercase;
}
.stats-table thead th:first-child, .stats-table tbody th, .stats-table tfoot th { text-align: left; }
.stats-table tbody th { min-width: 260px; color: var(--text); font-weight: 500; }
.stats-table tbody td { color: var(--green-hi); font-family: var(--mono); }
.stats-table tfoot th, .stats-table tfoot td {
  border-top: 2px solid #45604f; border-bottom: 0; color: #d8e6dc; font-weight: 700;
}
.continent-name { display: block; }
.continent-meter {
  display: block; height: 5px; margin-top: 6px; overflow: hidden;
  border-radius: 999px; background: #0b100d;
}
.continent-meter > span {
  display: block; height: 100%; min-width: 2px;
  border-radius: inherit; background: linear-gradient(90deg, #2f8a4a, var(--green));
}

/* -------------------------------------------------------------------------
 * Gallery cards
 * ---------------------------------------------------------------------- */
.qsl-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.qsl-tile {
  display: block; min-width: 0; color: inherit; text-decoration: none;
  border: 1px solid #2e6a40;
  border-radius: 10px;
  background: linear-gradient(180deg, #111a14, #0c120e);
  box-shadow: 0 3px 12px rgba(0, 0, 0, .36), inset 0 0 18px rgba(57, 155, 83, .04);
  overflow: hidden;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.qsl-tile:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--green); box-shadow: 0 7px 22px rgba(0, 0, 0, .48), 0 0 15px rgba(102, 217, 135, .13); }
.qsl-tile.is-unmatched { border-color: #71503d; }
.tile-image {
  position: relative; display: grid; place-items: center;
  height: 440px; padding: 14px;
  background: #080c09; overflow: hidden;
  border-bottom: 1px solid #2e4937;
}
/* Show the complete card/letter, including tall portrait scans.

   An earlier version used width:auto/height:auto plus percentage max-height.
   Some browsers did not resolve that percentage reliably for a replaced image
   inside the grid container: the image was sized from the tile width, became
   taller than the fixed frame, and was then clipped by overflow:hidden.

   Giving the image the frame's explicit content-box dimensions makes
   object-fit:contain authoritative in both directions.  Landscape cards get
   space above/below; portrait cards get space at the sides.  Nothing is cropped. */
.tile-image .tile-scan {
  display: block;
  width: 100% !important;
  height: 100% !important;
  min-width: 0;
  min-height: 0;
  object-fit: contain !important;
  object-position: center center;
}
.tile-image:hover { text-decoration: none; }
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px; padding: 3px 7px;
  font: 12px/1.25 var(--mono); letter-spacing: .05em;
}
.tile-image .badge { position: absolute; top: 8px; z-index: 2; box-shadow: 0 2px 6px rgba(0, 0, 0, .45); }
.tile-image .badge.rec { right: 8px; }
.tile-image .badge.unmatched { right: 8px; top: auto; bottom: 8px; }
.badge.rec { color: #07121a; background: var(--blue); }
.badge.unmatched { color: #fff1e8; background: #8f543e; }
.tile-body { padding: 12px 13px 13px; }
.tile-body h2 { margin: 0 0 4px; color: #edf5ef; font: 600 18px/1.25 var(--body); text-transform: none; letter-spacing: 0; }
.tile-location { color: var(--green); min-height: 1.55em; }
.tile-date { margin-top: 5px; color: var(--muted); font: inherit; }
.tile-frequency { color: var(--muted); font: inherit; }
.tile-sides { margin-top: 7px; padding-top: 7px; border-top: 1px solid #28342d; color: var(--muted); font-size: 13px; }
.document-placeholder {
  width: 100%; height: 100%; display: grid; place-content: center; gap: 5px; text-align: center;
  color: var(--green-hi); background: linear-gradient(145deg, #15241a, #0b100d);
}
.document-placeholder span { font: 28px var(--mono); letter-spacing: .12em; }
.document-placeholder b { color: var(--muted); font-weight: 500; }
.document-placeholder.large { min-height: 400px; }

/* -------------------------------------------------------------------------
 * Pagination
 * ---------------------------------------------------------------------- */
.pager { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; margin: 20px 0 9px; }
.pager a, .pager span { min-width: 38px; min-height: 38px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid #35463b; border-radius: 6px; padding: 5px 10px; }
.pager a { color: var(--text); background: #131a16; }
.pager a:hover { text-decoration: none; border-color: var(--green); }
.pager .current { color: #061008; background: var(--green); border-color: var(--green); font-weight: 700; }
.pager .gap { border-color: transparent; color: var(--muted); }
.per-page { display: flex; justify-content: center; gap: 9px; color: var(--muted); font-size: 14px; }
.per-page strong { color: var(--green-hi); }
.empty-state { text-align: center; padding: 45px 20px; }
.empty-state h2 { color: var(--green-hi); }

/* -------------------------------------------------------------------------
 * QSL detail page
 * ---------------------------------------------------------------------- */
.detail-nav { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.detail-location { color: var(--muted); font-size: 18px; }

.detail-list dt, .detail-remarks span, .archive-key span { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .12em; }

.section-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-title-row > span, .section-title-row > a { color: var(--muted); font-size: 14px; }
.qsl-viewer { border-left: 4px solid var(--green); scroll-margin-top: 12px; }
.qsl-viewer.is-unmatched { border-left-color: var(--red); }
.qsl-viewer-head { display: flex; align-items: end; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.qsl-viewer-head h1 { margin: 0 0 3px; color: #eff8f1; font: 400 26px/1.25 var(--disp); letter-spacing: .06em; }
.qsl-viewer-head > span { color: var(--muted); font-size: 14px; white-space: nowrap; }
.carousel { position: relative; }
.carousel-stage { position: relative; min-height: 820px; display: grid; place-items: center; overflow: hidden; background: #090d0a; border: 1px solid #2b3b31; border-radius: 9px; touch-action: pan-y pinch-zoom; overscroll-behavior-x: contain; }
.carousel-slide { display: none; margin: 0; width: 100%; height: 100%; min-height: 820px; place-items: center; align-content: center; transform: translate3d(0,0,0); }
.carousel-slide.active { display: grid; position: relative; z-index: 1; }
.carousel-slide.swipe-target { display: grid; position: absolute; inset: 0; z-index: 2; }
.carousel-stage.is-swiping .carousel-slide.active,
.carousel-stage.is-swiping .carousel-slide.swipe-target,
.carousel-stage.is-swipe-animating .carousel-slide.active,
.carousel-stage.is-swipe-animating .carousel-slide.swipe-target { will-change: transform; }
.carousel-slide img { display: block; max-width: calc(100% - 70px); max-height: 84vh; object-fit: contain; margin: 22px auto 10px; }
.scan-open { border: 0; padding: 0; background: transparent; cursor: zoom-in; width: 100%; }
.scan-open, .carousel-slide img { -webkit-user-drag: none; user-select: none; }
.carousel-slide figcaption { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; padding: 8px 16px 18px; color: var(--muted); }
.carousel-slide figcaption strong { color: var(--green-hi); }
.carousel-arrow {
  position: absolute; z-index: 3; top: 50%; transform: translateY(-50%);
  width: 44px; height: 64px; border: 1px solid #415348; border-radius: 7px;
  color: var(--green-hi); background: rgba(7, 12, 8, .82); cursor: pointer;
}
.carousel-arrow:hover { background: #16231a; }
.carousel-arrow.prev { left: 12px; }
.carousel-arrow.next { right: 12px; }
.carousel-dots { display: flex; justify-content: center; gap: 7px; padding: 12px 0 0; }
.carousel-dots button { width: 10px; height: 10px; padding: 0; border-radius: 50%; border: 1px solid #587061; background: #1d2a22; cursor: pointer; }
.carousel-dots button.active { background: var(--green); border-color: var(--green); }

.detail-columns { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; }
.logging-panel { border-left: 4px solid var(--green); }
.detail-sidebar { align-self: start; display: grid; gap: 16px; min-width: 0; }
.archive-panel { align-self: start; }
.related-panel { border-left: 4px solid var(--green); }
.related-panel h2 { margin-bottom: 10px; }
.related-links { display: grid; gap: 7px; }
.related-links a {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-width: 0; padding: 10px 11px; border: 1px solid #31513c; border-radius: 7px;
  color: #dff5e5; background: #101a13; text-decoration: none;
}
.related-links a:hover, .related-links a:focus-visible {
  border-color: var(--green); color: #f0fff4; background: #17271c; text-decoration: none;
}
.related-links a span:first-child { min-width: 0; overflow-wrap: anywhere; }
.related-links a span:last-child { color: var(--green-hi); font-size: 22px; line-height: 1; }
.detail-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 0; border: 1px solid #304038; border-radius: 8px; overflow: hidden; background: #304038; }
.detail-list div { background: #111713; padding: 9px 11px; }
.detail-list .wide { grid-column: 1 / -1; }
.detail-list dd { margin: 2px 0 0; }
.response-time { color: var(--muted); font-size: .82em; white-space: nowrap; }
.detail-remarks { margin-top: 12px; border: 1px solid #304038; border-radius: 8px; background: #111713; padding: 11px 12px; }
.detail-receiving-qth { margin-top: 10px; color: var(--muted); font-size: 13px; }
.logbook-link { margin-top: 14px; }
.archive-files { list-style: none; padding: 0; margin: 0; display: grid; gap: 9px; }
.archive-files li { border-bottom: 1px solid #2d3a32; padding-bottom: 8px; }
.archive-files span { display: block; color: var(--green); font-size: 13px; }
.archive-files a { display: block; overflow-wrap: anywhere; font-family: var(--mono); font-size: 13px; }
.archive-key { margin-top: 14px; }
.archive-key code { display: block; margin-top: 4px; padding: 9px; border-radius: 6px; background: #0c110e; color: var(--amber); overflow-wrap: anywhere; }
.notice { border: 1px solid #3b4c42; border-radius: 7px; padding: 11px 12px; color: var(--muted); background: #111713; }
.notice.warning { border-left: 3px solid var(--red); }

/* -------------------------------------------------------------------------
 * Recording panel: deliberately blue, matching SWLog.
 * ---------------------------------------------------------------------- */
.recording-panel {
  --waveform-played: var(--blue);
  --waveform-unplayed: #68737d;
  --waveform-playhead: #eaf6ff;
  --line: #33404d;
  --dim: #8593a1;
  border-left: 4px solid var(--blue);
  background: #1a2026;
}
.recording-panel h2 { color: #c9e7fa; margin-bottom: 0; }
.recording-title-row { justify-content: flex-start; margin-bottom: 12px; }
.panel-title-icon {
  display: inline-grid; place-items: center; width: 32px; height: 32px;
  border: 1px solid #3a4650; border-radius: 7px; color: #91a3b0; background: #171d22;
}
.panel-title-icon:hover { color: #d9e8f2; background: #202a31; text-decoration: none; }
.panel-title-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.recording-list { display: grid; gap: 15px; }
.recording-item { border: 1px solid #303a42; border-radius: 9px; background: #0d1115; padding: 17px; }
.recording-file { color: var(--amber); font: 14px/1.45 var(--mono); overflow-wrap: anywhere; }
.recording-item audio { display: block; width: 100%; margin: 17px 0; }
.recording-item .audiodiv { width: 100%; margin: 17px 0; }
.recording-item .wfp-player { margin: 0; }
.recording-meta { padding: 0; }
.recording-meta h3 { margin: 0; color: #e3f3fd; font-size: 20px; }
.recording-location { color: #9fb3c2; font-size: 17px; }
.recording-facts { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-top: 11px; color: var(--amber); font-size: 16px; }
.recording-secondary { display: flex; flex-wrap: wrap; gap: 8px 32px; margin-top: 7px; color: #9fb3c2; font-size: 16px; }
.recording-meta p { margin: 12px 0 0; padding-top: 12px; border-top: 1px solid #293139; color: #d7e0e6; }
.rec-clock { display: flex; align-items: center; gap: 7px; width: max-content; margin: 12px 0 0; border: 1px solid #1e252b; border-radius: 6px; background: #050709; padding: 5px 10px; font-family: var(--mono); }
.rec-clock strong { color: var(--amber); font-size: 18px; font-weight: 400; letter-spacing: .12em; }
.rec-clock span { color: #b28752; font-size: 11px; letter-spacing: .12em; }
.rec-clock em { color: #8fb6ce; font-style: normal; }
.clock-lamp { width: 8px; height: 8px; border-radius: 50%; background: #4c3a20; box-shadow: 0 0 0 transparent; }
.rec-clock.running .clock-lamp { background: var(--amber); box-shadow: 0 0 8px var(--amber); }

/* -------------------------------------------------------------------------
 * Full-size image lightbox
 *
 * The horizontal track uses native overflow scrolling and CSS scroll snapping.
 * This makes full-size Front / Back / Letter images follow the user's finger
 * smoothly in mobile browsers and installed PWA mode.
 * ---------------------------------------------------------------------- */
.lightbox-text-link { border: 0; padding: 0; color: var(--green-hi); background: transparent; cursor: pointer; }
.lightbox-text-link:hover { text-decoration: underline; }
.lightbox[hidden] { display: none; }
.lightbox {
  position: fixed; z-index: 1000; inset: 0; display: block;
  overflow: hidden; overscroll-behavior: contain;
  background: rgba(0, 0, 0, .94);
}
.lightbox-track {
  position: absolute; inset: 0;
  display: flex; width: 100%; height: 100%;
  overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory; scroll-behavior: smooth;
  overscroll-behavior-x: contain; touch-action: pan-x pinch-zoom;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.lightbox-track::-webkit-scrollbar { display: none; }
.lightbox-slide {
  flex: 0 0 100%; width: 100%; height: 100%; margin: 0;
  display: grid; place-items: center;
  padding: max(64px, calc(env(safe-area-inset-top) + 52px)) 54px
           max(86px, calc(env(safe-area-inset-bottom) + 74px));
  scroll-snap-align: start; scroll-snap-stop: always;
}
.lightbox-slide img {
  display: block; max-width: 100%; max-height: 100%; object-fit: contain;
  user-select: none; -webkit-user-drag: none;
  box-shadow: 0 8px 40px #000;
}
.lightbox-close {
  position: fixed; z-index: 1003; top: max(12px, env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right));
  width: 48px; height: 48px; border: 1px solid #829087; border-radius: 50%;
  color: white; background: rgba(24, 34, 27, .96); font-size: 32px; line-height: 1; cursor: pointer;
  box-shadow: 0 3px 18px rgba(0,0,0,.65);
}
.lightbox-arrow {
  position: fixed; z-index: 1002; top: 50%; transform: translateY(-50%);
  width: 46px; height: 72px; border: 1px solid #68796e; border-radius: 8px;
  color: #fff; background: rgba(16, 24, 19, .82); font-size: 30px; cursor: pointer;
  box-shadow: 0 3px 18px rgba(0,0,0,.55);
}
.lightbox-arrow.prev { left: max(8px, env(safe-area-inset-left)); }
.lightbox-arrow.next { right: max(8px, env(safe-area-inset-right)); }
.lightbox-arrow:hover { background: rgba(34, 54, 41, .96); }
.lightbox-arrow[hidden] { display: none; }
.lightbox-close-bottom {
  position: fixed; z-index: 1003; left: 50%; bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%); min-width: 110px; min-height: 44px; padding: 8px 18px;
  border: 1px solid #829087; border-radius: 22px; color: white; background: rgba(24, 34, 27, .96);
  cursor: pointer; box-shadow: 0 3px 18px rgba(0,0,0,.65);
}
.lightbox-caption {
  position: fixed; z-index: 1002; left: 15px;
  bottom: max(62px, calc(env(safe-area-inset-bottom) + 54px)); right: 15px;
  text-align: center; color: #dce7df; pointer-events: none;
}
body.lightbox-open { overflow: hidden; }

/* -------------------------------------------------------------------------
 * Footer
 * ---------------------------------------------------------------------- */
.site-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 18px; margin-top: 24px; padding: 14px 3px; border-top: 1px solid #2f3c34; color: var(--muted); font-size: 13px; }

/* -------------------------------------------------------------------------
 * Responsive behavior
 * ---------------------------------------------------------------------- */
@media (max-width: 1180px) {
  .filter-grid { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
  .qsl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-card-grid { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
}

@media (max-width: 820px) {
  .wrap { padding: 0 12px 35px; }
  .brand { padding: 14px; }
  .brand-icon { width: 78px; height: 53px; flex-basis: 78px; }
  .brand h1 { font-size: 19px; letter-spacing: .08em; }
  .subtitle { font-size: 13px; }
  .search-box { grid-template-columns: 1fr; }
  /* Phones and small tablets intentionally expose only free-form search.  The
     desktop quick filters, dropdowns and sort controls consume too much room. */
  .desktop-filters { display: none !important; }
  .qsl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
  .tile-image { height: 400px; }
  .gallery-meta { align-items: flex-start; flex-direction: column; }
  .stats-title-row { display: grid; gap: 7px; }
  .chart-summary { white-space: normal; }
  .detail-columns { grid-template-columns: 1fr; }
  .carousel-stage, .carousel-slide { min-height: 560px; }
}

@media (max-width: 540px) {
  body { font-size: 15px; }
  .plate { margin-top: 10px; }
  .brand { gap: 10px; }
  .brand-icon { width: 68px; height: 46px; flex-basis: 68px; border-radius: 8px; }
  .brand h1 { font-size: 16px; }
  .lightbox-slide { padding-left: 10px; padding-right: 10px; }
  .lightbox-arrow { display: none; }
  .controls { overflow-x: auto; }
  .panel { padding: 14px; }
  .stats-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .stat-card { min-height: 102px; }
  .stat-card strong { font-size: 31px; }
  .stat-card span { font-size: 10px; letter-spacing: .09em; }
  .year-chart { height: 250px; }
  .year-chart-scale { font-size: 11px; }
  .stats-table th, .stats-table td { padding: 9px 8px; }
  .stats-table tbody th { min-width: 190px; }
  .qsl-grid { grid-template-columns: 1fr; }
  .tile-image { height: 430px; }
  .detail-nav { display: grid; }
  .qsl-viewer-head { align-items: flex-start; flex-direction: column; }
  .detail-list { grid-template-columns: 1fr; }
  .detail-list .wide { grid-column: auto; }
  .carousel-stage, .carousel-slide { min-height: 440px; }
  .carousel-slide img { max-width: calc(100% - 22px); margin-top: 12px; }
  .carousel-arrow { width: 36px; height: 54px; }
  .carousel-arrow.prev { left: 5px; }
  .carousel-arrow.next { right: 5px; }
  .site-foot { display: grid; }
}

@media print {
  body { background: white; color: black; }
  .plate, .search-panel, .pager, .per-page, .site-foot, .detail-nav, .carousel-arrow, .carousel-dots, .recording-panel { display: none !important; }
  .panel, .qsl-tile { box-shadow: none; border-color: #777; background: white; color: black; }
  .qsl-grid { grid-template-columns: repeat(3, 1fr); }
  a { color: black; }
}
