:root {
  color-scheme: dark;
  --canvas: #20272d;
  --surface: #29343d;
  --text: #f6f8fa;
  --secondary: #b9c5ce;
  --line: #46535e;
  --blue: #66aaff;
  --amber: #ffc13b;
  --image-stage: radial-gradient(ellipse at 50% 35%, #34434f 0%, #293640 58%, #222c34 100%);
  font: 16px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--canvas);
  color: var(--text);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 0; min-height: 100svh; display: flex; flex-direction: column; }
main { flex: 1; }
a { color: inherit; text-underline-offset: 4px; }
button, input, select { font: inherit; }
button, select, summary { cursor: pointer; }
button { color: inherit; }
button:disabled { opacity: .5; cursor: default; }
input, select { min-width: 0; color: var(--text); background: var(--canvas); border: 1px solid var(--line); border-radius: 4px; padding: 10px 12px; }
input::placeholder { color: var(--secondary); opacity: .85; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 4px; }
::selection { background: var(--amber); color: var(--canvas); }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(2rem, 3.5vw, 2.75rem); line-height: 1.15; letter-spacing: -.035em; font-weight: 650; }
h2 { font-size: 1.4rem; line-height: 1.25; font-weight: 600; letter-spacing: -.02em; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; left: 16px; top: -100px; z-index: 20; padding: 12px; background: var(--amber); color: var(--canvas); }
.skip-link:focus { top: 12px; }
.sample-banner { background: #354451; color: #e1ebf5; text-align: center; padding: 5px 16px; font-size: .75rem; position: relative; z-index: 5; }
.page-width { width: min(1480px, 100%); margin-inline: auto; padding-inline: 40px; }
.site-header { width: 100%; padding: 25px max(40px, calc((100vw - 1400px) / 2)); display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); }
.wordmark { text-decoration: none; font-size: 1.5rem; font-weight: 650; letter-spacing: -.04em; white-space: nowrap; }
.site-header nav { display: flex; gap: 30px; }
.site-header nav a { text-decoration: none; color: var(--secondary); font-size: .9rem; padding: 8px 0; border-bottom: 2px solid transparent; }
.site-header nav a:hover { color: var(--text); }
.site-header nav a[aria-current] { color: var(--text); border-color: var(--amber); }
.site-footer { margin-top: 48px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 20px; padding: 22px max(40px, calc((100vw - 1400px) / 2)); font-size: .8rem; color: var(--secondary); }
.button { display: inline-flex; gap: 8px; align-items: center; justify-content: center; padding: 10px 15px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--text); text-decoration: none; font-size: .875rem; line-height: 1.4; font-weight: 500; }
.button:hover { border-color: var(--secondary); }
.button--blue { background: #2e6398; border-color: #75a8d9; color: #fff; }
.button--blue:hover { background: #3671ad; }
.button--amber { background: var(--amber); border-color: var(--amber); color: #20272d; }
.button--amber:hover { background: #ffd16c; border-color: #ffd16c; }
.text-link { color: var(--blue); font-size: .875rem; }
.text-button { background: none; border: 0; padding: 8px 2px; color: var(--secondary); text-decoration: underline; text-underline-offset: 4px; font-size: .875rem; }
.icon-button { background: none; border: 0; width: 42px; height: 42px; flex-shrink: 0; font-size: 1.75rem; line-height: 1; border-radius: 4px; }
.icon-button:hover { background: var(--canvas); }

/* The preview is in the HTML. The sharp layer is revealed only after decode(). */
.media { position: relative; display: block; overflow: hidden; width: 100%; height: 100%; isolation: isolate; }
.media__preview, .media__full { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; }
.media__preview { filter: blur(14px); transform: scale(1.08); opacity: 1; transition: opacity 180ms ease; pointer-events: none; }
.media__full { opacity: 0; transition: opacity 180ms ease; }
.media--ready .media__full { opacity: 1; }
.media--ready .media__preview { opacity: 0; }
.media--contain .media__preview, .media--contain .media__full { inset: 8%; width: 84%; height: 84%; object-fit: contain; }
.media--missing { background: #e8edf0; }
.media__empty { position: absolute; inset: 0; display: grid; place-content: center; padding: 14px; text-align: center; font-size: .8rem; color: #4b5a66; }
.media__failure { position: absolute; bottom: 12px; left: 12px; right: 12px; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 7px; background: rgba(20,29,36,.9); color: white; font-size: .75rem; }
.media__retry { border: 0; background: none; color: #b7d8ff; text-decoration: underline; }

.page-home .site-header { position: absolute; top: 0; left: 0; z-index: 3; border: 0; background: linear-gradient(rgba(10,19,27,.68), transparent); padding-block: 28px 36px; }
.page-home:has(.sample-banner) .site-header { top: 28px; }
.page-home .site-header nav a { color: #eef3f7; }
.home-main { min-height: 100svh; position: relative; isolation: isolate; display: grid; place-items: center; }
.slideshow, .slide { position: absolute; inset: 0; }
.slideshow { z-index: -2; }
.slide { opacity: 0; transition: opacity 1.5s ease; }
.slide--visible { opacity: 1; }
.home-main::after { position: absolute; inset: 0; content: ''; background: rgba(12,20,27,.43); z-index: -1; }
.home-content { text-align: center; padding: 140px 24px; }
.home-content h1 { font-size: clamp(2.75rem, 6vw, 5rem); font-weight: 650; letter-spacing: -.055em; }
.home-actions { display: flex; justify-content: center; gap: 16px; margin-top: 32px; flex-wrap: wrap; }
.home-actions .button { padding: 13px 22px; font-size: 1rem; }
.page-home .site-footer { display: none; }

.collection-banner { position: relative; isolation: isolate; padding-block: 48px; overflow: hidden; }
.banner-photo { position: absolute; inset: 0; z-index: -2; }
.banner-photo .media__full, .banner-photo .media__preview { object-position: center 45%; }
.collection-banner::after { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, rgba(16,24,30,.93), rgba(16,24,30,.65) 45%, rgba(16,24,30,.12)); }
.collection-banner p { color: #e1e8ef; margin-top: 12px; }
.collection-page { padding-top: 28px; }
.collection-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.search-field { flex: 1 1 240px; }
.search-field input { width: 100%; background: var(--surface); }
.compact-field { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--secondary); }
.compact-field select { font-size: .875rem; padding: 9px 22px 9px 4px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; max-width: 180px; }
#item-type { max-width: 190px; }
#filter-count:not(:empty) { background: var(--canvas); padding: 0 5px; border-radius: 3px; }
.view-toggle { display: flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; font-size: .8rem; }
.view-toggle a { text-decoration: none; padding: 10px; color: var(--secondary); }
.view-toggle a[aria-current] { background: var(--surface); color: var(--text); }
.collection-secondary { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-top: 16px; color: var(--secondary); font-size: .75rem; }
.collection-secondary>div { display: flex; align-items: center; gap: 20px; }
.collection-secondary select { padding-block: 5px; font-size: .75rem; }
.actions-menu { position: relative; }
.actions-menu>summary { padding: 7px 0; font-size: .8rem; }
.actions-menu>div { position: absolute; z-index: 4; top: 100%; right: 0; width: 230px; padding: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; box-shadow: 0 10px 35px #10182066; }
.actions-menu a, .actions-menu button { display: block; width: 100%; padding: 10px; text-decoration: none; text-align: left; font-size: .8rem; border: 0; background: none; }
.actions-menu a:hover, .actions-menu button:hover { background: var(--canvas); }
#results[aria-busy=true] { opacity: .65; }
.results-meta { display: flex; align-items: start; justify-content: space-between; gap: 20px; margin: 25px 0 22px; }
.results-count { font-size: .9rem; }
.results-count>span { color: var(--secondary); font-size: .75rem; margin-left: 16px; }
.collection-overview { max-width: 560px; text-align: right; font-size: .8rem; color: var(--secondary); }
.collection-overview summary { padding: 2px 0; }
.collection-overview dl { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; text-align: left; margin: 15px 0; padding: 15px 0; border-block: 1px solid var(--line); }
.collection-overview dd { margin: 4px 0 0; color: var(--text); font-size: 1.2rem; }
.collection-overview p { max-width: 64ch; text-align: left; font-size: .75rem; }
.filter-chips { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 22px; }
.filter-chip { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; font-size: .75rem; border: 1px solid var(--line); padding: 5px 10px; border-radius: 4px; }
.filter-chip:hover { border-color: var(--blue); }
.filter-chip span { font-size: 1.1rem; line-height: 1; }
.set-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 32px 24px; }
.set-card { position: relative; isolation: isolate; overflow: hidden; text-decoration: none; display: flex; flex-direction: column; min-width: 0; border-radius: 12px; background: var(--image-stage); }
/* One continuous image-colored backdrop covers both the photo and its labels. */
.set-card::before { content: ''; position: absolute; inset: -32px; z-index: -2; background-image: var(--card-preview, none); background-position: center; background-size: cover; filter: blur(28px) brightness(.4) saturate(.8); opacity: .6; pointer-events: none; }
.set-image { position: relative; aspect-ratio: 4/3; overflow: hidden; flex-shrink: 0; }
.set-card .media { background: transparent; }
.detail-media .media, .collection-table td:first-child .media { background: var(--image-stage); }
/* Contained images outside the grid retain the same dark ambient treatment. */
.detail-media .media__preview, .collection-table .media__preview {
  inset: 0; width: 100%; height: 100%; object-fit: cover;
  filter: blur(28px) brightness(.4) saturate(.8); transform: scale(1.18); opacity: .6;
}
.detail-media .media--ready .media__preview,
.collection-table .media--ready .media__preview { opacity: .6; }
.set-image .media__empty, .detail-media .media__empty, .collection-table .media__empty { color: var(--secondary); }
.quantity { position: absolute; right: 10px; bottom: 10px; background: var(--canvas); padding: 3px 7px; color: white; font-size: .75rem; border-radius: 3px; }
.set-copy { position: relative; isolation: isolate; padding: 12px 14px 16px; flex: 1; }
/* Anchor the falloff to the text boundary, including cards with wrapped names. */
.set-copy::before { content: ''; position: absolute; inset: -20px 0 0; z-index: -1; background: linear-gradient(180deg, rgba(12,19,25,0), rgba(12,19,25,.7) 28px, rgba(12,19,25,.82) 70px, rgba(12,19,25,.88)); pointer-events: none; }
.set-copy h2 { font-size: 1.05rem; letter-spacing: -.015em; line-height: 1.3; font-weight: 550; }
.set-card:hover h2 { text-decoration: underline; text-underline-offset: 4px; }
.set-identity, .set-stats { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 14px; font-size: .75rem; color: var(--secondary); margin-top: 6px; }
.set-stats { margin-top: 4px; }
.table-scroll { overflow-x: auto; }
.collection-table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.collection-table td, .collection-table th { padding: 13px 12px; border-bottom: 1px solid var(--line); text-align: left; }
.collection-table thead th { font-weight: 500; color: var(--secondary); white-space: nowrap; }
.collection-table th[scope=row] { min-width: 170px; font-weight: 550; }
.collection-table a { text-decoration: none; }
.collection-table a:hover { text-decoration: underline; }
.collection-table td:first-child { width: 90px; padding-left: 0; }
.collection-table td:first-child .media { width: 76px; height: 68px; background: var(--image-stage); }
.collection-table .media__empty { padding: 4px; }
.collection-table td:nth-last-child(-n+5) { font-variant-numeric: tabular-nums; }
.pagination { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 9px; margin-top: 40px; font-size: .85rem; }
.pagination a { padding: 8px 12px; text-decoration: none; border-radius: 4px; }
.pagination a[aria-current] { background: var(--amber); color: var(--canvas); }
.empty-state { padding-block: 70px; text-align: center; }
.empty-state p { margin: 16px auto 24px; color: var(--secondary); max-width: 64ch; }
.empty-state .button { margin: 4px; }
.inline-error { border-left: 3px solid #f5a69e; padding: 10px 15px; background: #422e32; color: #ffe5e1; font-size: .875rem; margin: 20px 0; }

.page-intro { display: flex; justify-content: space-between; align-items: end; gap: 20px; padding-block: 42px 32px; }
.gallery { display: flex; flex-wrap: wrap; align-items: start; gap: 16px; }
.gallery::after { content: ''; flex-grow: 999; flex-basis: 220px; }
.gallery-photo { display: block; flex-grow: var(--ratio); flex-basis: calc(220px * var(--ratio)); aspect-ratio: var(--ratio); min-width: 0; overflow: hidden; border-radius: 3px; background: var(--surface); }
.gallery-photo:hover { outline: 2px solid var(--blue); outline-offset: 3px; }
.gallery-photo .media { aspect-ratio: var(--image-ratio); }

dialog { color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 5px; padding: 24px; max-height: 92dvh; }
dialog::backdrop { background: rgba(8,15,22,.78); }
body:has(dialog[open]) { overflow: hidden; }
.viewer { width: min(1000px, calc(100% - 48px)); }
.viewer-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.viewer-header>span { color: var(--secondary); font-size: .875rem; }
.viewer-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-top: 22px; color: var(--secondary); font-size: .8rem; }
.viewer-footer>div { display: flex; align-items: center; gap: 16px; }
.detail-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
.detail-media { height: 420px; background: var(--image-stage); }
.detail-copy h2 { font-size: 1.8rem; }
#set-number-display { color: var(--secondary); font-size: .875rem; display: block; margin-top: 7px; }
#set-specs { font-size: .875rem; margin-top: 22px; }
#set-specs>div { display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); padding: 9px 0; }
#set-specs dt { color: var(--secondary); }
#set-specs dd { margin: 0; font-variant-numeric: tabular-nums; text-align: right; }
#set-notes { white-space: pre-wrap; overflow-wrap: anywhere; margin: 18px 0; font-size: .875rem; color: var(--secondary); }
.filter-dialog { width: min(460px, 100%); max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0 0 0 auto; border-radius: 0; inset: 0 0 0 auto; border-block: 0; border-right: 0; padding: 28px; }
.form-guidance { color: var(--secondary); font-size: .875rem; margin-bottom: 24px; }
.filter-dialog label { display: block; font-size: .875rem; margin: 15px 0 6px; }
.filter-dialog input, .filter-dialog select { display: block; width: 100%; }
.helper { font-size: .75rem; color: var(--secondary); margin: 0 0 8px; }
.filter-dialog fieldset { border: 0; margin: 24px 0 0; padding: 0; }
.filter-dialog legend { padding: 0; font-size: .95rem; font-weight: 550; margin-bottom: 4px; }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-pair label { margin-top: 6px; }
.filter-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding-block: 20px 8px; margin-top: 24px; border-top: 1px solid var(--line); background: var(--surface); }
.filter-actions>button:first-child { margin-right: auto; }
.photo-viewer { width: min(1480px, calc(100% - 48px)); }
.photo-viewer[open] { display: flex; flex-direction: column; height: min(92dvh, 1080px); }
.photo-viewer .photo-stage { flex: 1; min-height: 100px; height: auto; }
.photo-viewer h2 { font-size: 1rem; font-weight: 500; }
.photo-stage { height: min(72vh, 900px); min-height: 180px; background: #152029; overflow: hidden; cursor: zoom-in; }
.photo-stage img { user-select: none; -webkit-user-drag: none; }
.photo-stage .media--contain .media__full, .photo-stage .media--contain .media__preview { inset: 0; width: 100%; height: 100%; }
.photo-stage.is-zoomed { overflow: auto; cursor: zoom-out; }
.photo-stage.is-panning { cursor: grabbing; }
.photo-stage.zoom-pending { cursor: progress; }
.photo-stage.is-zoomed .media__full { object-fit: fill; }
.photo-help, .photo-status { color: var(--secondary); font-size: .8rem; margin-top: 10px; }
.photo-status { color: var(--blue); }
.toast { position: fixed; z-index: 12; right: 24px; bottom: 24px; max-width: min(420px, calc(100% - 48px)); border: 1px solid var(--line); background: var(--surface); padding: 14px 18px; border-radius: 4px; font-size: .875rem; box-shadow: 0 8px 30px #10182066; }

@media (max-width: 1250px) {
  .set-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .search-field { flex-basis: 300px; }
  .collection-toolbar { gap: 12px; }
}
@media (max-width: 800px) {
  .page-width { padding-inline: 24px; }
  .site-header, .site-footer { padding-inline: 24px; }
  .site-header nav { gap: 20px; }
  .wordmark { font-size: 1.3rem; }
  .search-field { flex-basis: 100%; }
  .collection-toolbar .compact-field { flex: 1; }
  .compact-field select { max-width: 150px; }
  .set-grid { gap: 26px 16px; }
  .set-copy h2 { font-size: .95rem; }
  .results-meta { flex-wrap: wrap; }
  .collection-overview { text-align: left; }
  .detail-columns { gap: 22px; }
  .detail-media { height: 340px; }
}
@media (max-width: 600px) {
  .page-width { padding-inline: 16px; }
  .site-header { padding: 19px 16px 14px; flex-wrap: wrap; gap: 10px; }
  .site-header nav { gap: 24px; }
  .site-header nav a { font-size: .85rem; }
  .site-footer { padding: 20px 16px; font-size: .7rem; flex-wrap: wrap; }
  .page-home .site-header { padding: 22px 16px; }
  .page-home .wordmark { width: 100%; }
  .page-home:has(.sample-banner) .site-header { top: 46px; }
  .home-content h1 { font-size: clamp(2.5rem, 10vw, 4rem); }
  .home-actions { flex-direction: column; align-items: center; gap: 14px; }
  .collection-banner { padding-block: 35px; }
  .collection-banner p { font-size: .875rem; }
  .collection-page { padding-top: 20px; }
  .collection-toolbar { gap: 12px 10px; }
  .collection-toolbar input { font-size: 16px; }
  .collection-toolbar .compact-field { flex-basis: calc(50% - 10px); display: flex; flex-direction: column; align-items: start; gap: 2px; }
  .collection-toolbar .compact-field select { max-width: 100%; width: 100%; font-size: .85rem; }
  .collection-toolbar #open-filters { margin-right: auto; padding-inline: 10px; }
  .view-toggle a { padding-inline: 8px; }
  .collection-toolbar label:has(#sort) { order: 4; flex: 1 1 90px; }
  .collection-toolbar .view-toggle { order: 5; }
  .collection-secondary { margin-top: 18px; }
  .collection-secondary>div { gap: 12px; }
  .results-meta { margin-block: 20px; gap: 14px; }
  .results-count>span { margin-left: 10px; }
  .collection-overview dl { grid-template-columns: repeat(2, 1fr); }
  .set-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 26px 14px; }
  .set-copy { padding: 10px 12px 14px; }
  .set-copy h2 { font-size: 1rem; }
  .set-identity, .set-stats { font-size: .75rem; gap: 2px 10px; }
  .page-intro { padding-block: 30px 24px; align-items: start; flex-direction: column; gap: 12px; }
  .gallery { gap: 12px; }
  .gallery-photo { flex-basis: calc(160px * var(--ratio)); }
  dialog { padding: 18px; }
  .viewer { width: calc(100% - 24px); }
  .detail-columns { grid-template-columns: 1fr; gap: 22px; }
  .detail-media { height: 230px; }
  .detail-copy h2 { font-size: 1.4rem; }
  .filter-dialog { padding: 22px 18px; }
  .filter-dialog h2 { font-size: 1.25rem; }
  .filter-dialog input, .filter-dialog select { font-size: 16px; }
  .field-pair { gap: 10px; }
  .viewer-footer { gap: 10px; }
  .empty-state { padding-block: 48px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
@media (pointer: coarse) {
  .button, .view-toggle a, .site-header nav a, .actions-menu>summary, .pagination a { min-height: 44px; display: inline-flex; align-items: center; }
  .compact-field select { min-height: 44px; }
  .media__retry { min-height: 44px; }
}
