/* Shared visual tokens from ThaneJoss/webapps. */
:root {
  color-scheme: light;
  --surface-base: #f6f7f9;
  --surface: #fff;
  --ink-strong: #182230;
  --muted: #526075;
  --brand: #2563eb;
  --brand-strong: #1d4ed8;
  --border: #e2e6ec;
  --soft: #eff4ff;
  --app-header-height: 72px;
  --radius-control: 8px;
  --radius-panel: 16px;
  --motion-duration-fast: 120ms;
  --motion-duration-standard: 180ms;
  --motion-duration-panel: 280ms;
  --motion-ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --motion-ease-emphasized: cubic-bezier(0.22, 1, 0.36, 1);
  --card-ratio: 85.6 / 53.98;
  font-family: Inter, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink-strong);
  background: var(--surface-base);
  font-synthesis: none;
}

*, *::before, *::after { box-sizing: border-box; }
html {
  scrollbar-gutter: stable;
  scroll-padding-top: calc(var(--app-header-height) + 20px);
}
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; border: 0; }
a { color: inherit; text-decoration: none; }
:where(a, button, input, [tabindex]):focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 3px;
}
svg, img { display: block; }
button svg, .search > svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
::selection { background: #dce8ff; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-control);
  color: #fff;
  background: var(--ink-strong);
  transform: translateY(-160%);
}
.skip-link:focus { transform: translateY(0); }

/* Independent gallery branding with the shared 72px header and 1152px width. */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.header-content, .main-content {
  width: calc(100% - 96px);
  max-width: 1152px;
  margin-inline: auto;
}
.header-content {
  display: flex;
  min-height: var(--app-header-height);
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: inline-flex;
  min-height: 44px;
  flex-shrink: 0;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 650;
}
.brand-mark { width: 36px; height: 36px; }
.main-content { padding-block: 40px 56px; }
.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
  animation: content-enter var(--motion-duration-panel) var(--motion-ease-emphasized) both;
}
.panel-label {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
}
.page-heading h1 {
  margin: 0;
  font-size: clamp(32px, 4vw, 40px);
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -0.025em;
}
.page-heading h1 span { color: var(--brand); }
.page-description { margin: 14px 0 0; color: var(--muted); font-size: 14px; line-height: 1.8; }
.gallery-hint {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 8px;
  padding-bottom: 3px;
  color: var(--muted);
  font-size: 13px;
}

/* Every filter stays visible; narrow layouts wrap instead of scrolling. */
.filters {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  background: var(--surface);
  box-shadow: 0 1px 3px #1018280a;
}
.search {
  display: flex;
  min-width: 0;
  height: 44px;
  align-items: center;
  gap: 10px;
  padding-inline: 12px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface-base);
  transition: border-color var(--motion-duration-standard), box-shadow var(--motion-duration-standard);
}
.search:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--soft);
  background: var(--surface);
}
.search > svg { flex-shrink: 0; width: 18px; height: 18px; color: var(--muted); }
.search input {
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 14px;
}
.search input::placeholder { color: var(--muted); opacity: 1; }
.search input:focus-visible { outline: none; }
.search input::-webkit-search-cancel-button { display: none; }
.search-shortcut {
  display: grid;
  flex-shrink: 0;
  width: 23px;
  height: 25px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  background: var(--surface);
  font: inherit;
  font-size: 12px;
}
.search:focus-within .search-shortcut,
.search:has(.clear-search:not([hidden])) .search-shortcut { display: none; }
.clear-search {
  display: grid;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  place-items: center;
  margin-right: -8px;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--muted);
}
.clear-search svg { width: 18px; height: 18px; }
.filter-controls, .type-filters { display: flex; align-items: center; min-width: 0; }
.filter-controls { gap: 12px; }
.type-filters { flex-shrink: 0; gap: 2px; }
.type-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 10px;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color var(--motion-duration-standard), color var(--motion-duration-standard);
}
.type-button.is-active { color: var(--brand-strong); background: var(--soft); font-weight: 600; }
.count { font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; }
.picker-trigger {
  display: flex;
  width: 156px;
  min-width: 0;
  min-height: 44px;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  text-align: left;
  transition: border-color var(--motion-duration-standard), background-color var(--motion-duration-standard);
}
#network-trigger { width: 172px; }
.picker-trigger[aria-expanded="true"], .picker-trigger.is-filtered {
  border-color: #b6c9ed;
  color: var(--brand-strong);
  background: var(--soft);
}
.picker-icon, .option-icon {
  display: flex;
  flex: 0 0 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
}
.picker-icon svg, .option-icon svg { width: 21px; height: 21px; }
.picker-icon img, .option-icon img { width: 100%; height: 100%; object-fit: contain; }
.picker-label { flex: 1; min-width: 0; overflow: hidden; font-size: 14px; white-space: nowrap; text-overflow: ellipsis; }
.chevron {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  color: var(--muted);
  transition: transform var(--motion-duration-standard);
}
.picker-trigger[aria-expanded="true"] .chevron { transform: rotate(180deg); }

/* Popovers stay in the top layer, including on narrow screens. */
.picker-menu {
  position: fixed;
  inset: auto;
  z-index: 50;
  max-width: calc(100vw - 24px);
  max-height: min(440px, 70dvh);
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--ink-strong);
  background: var(--surface);
  box-shadow: 0 12px 32px #18223014, 0 2px 6px #18223008;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
  overscroll-behavior: contain;
}
.picker-menu:popover-open { animation: content-enter var(--motion-duration-fast) var(--motion-ease-standard); }
.picker-option {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-control);
  color: var(--muted);
  background: transparent;
  text-align: left;
  font-size: 14px;
  line-height: 1.5;
}
.picker-option[aria-selected="true"] { color: var(--brand-strong); background: var(--soft); font-weight: 600; }
.picker-option:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; background: var(--soft); }
.option-icon { flex-basis: 27px; height: 25px; }
.option-label { flex: 1; }
.option-check { flex-shrink: 0; width: 16px; height: 16px; visibility: hidden; }
.picker-option[aria-selected="true"] .option-check { visibility: visible; }
.results-note {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 13px;
}
.results-note p { min-width: 0; margin: 0; overflow-wrap: anywhere; }
.text-button {
  display: inline-flex;
  flex-shrink: 0;
  min-height: 44px;
  align-items: center;
  gap: 6px;
  padding: 8px 0 8px 8px;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--brand-strong);
  font-size: 13px;
}
.text-button span { font-size: 18px; }

.gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  scroll-margin-top: calc(var(--app-header-height) + 20px);
}
.gallery-card {
  min-width: 0;
  animation: content-enter var(--motion-duration-panel) var(--motion-ease-emphasized) both;
  animation-delay: calc(var(--index, 0) * 35ms);
}
.card-button {
  display: block;
  width: 100%;
  height: 100%;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  background: var(--surface);
  box-shadow: 0 1px 3px #1018280a;
  text-align: left;
  transition: border-color var(--motion-duration-standard), box-shadow var(--motion-duration-standard);
}
.card-art {
  display: block;
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: var(--card-ratio);
  border-radius: 10px;
  background: #e4edf9;
  box-shadow: 0 2px 5px #18223012;
  transition: transform var(--motion-duration-standard) var(--motion-ease-standard);
}
/* Each card loads its own image, keeping the ID-1 ratio without stretching. */
.card-art img {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  object-fit: cover;
  object-position: left center;
  user-select: none;
  pointer-events: none;
}
.image-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  color: var(--muted);
  background: var(--surface-base);
  font-size: 14px;
}
.card-caption {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 14px;
}
.card-name { font-size: 15px; font-weight: 500; line-height: 1.6; }
.card-bank { display: flex; flex-shrink: 0; align-items: center; justify-content: center; width: 28px; height: 28px; }
.bank-logo { flex-shrink: 0; width: 25px; height: 25px; object-fit: contain; }
.bank-logo-fallback { display: grid; place-items: center; color: var(--muted); }
.bank-logo-fallback svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.data-status { padding: 64px 20px; text-align: center; }
.data-status h2 { margin: 0 0 12px; font-size: 20px; }
.data-status p { margin: 0 auto 24px; max-width: 640px; color: var(--muted); overflow-wrap: anywhere; }
.data-status .primary-button { display: inline-flex; align-items: center; justify-content: center; }
.empty-state { padding: 64px 20px 88px; text-align: center; }
.empty-state > svg {
  width: 56px;
  height: 56px;
  margin: 0 auto 20px;
  fill: var(--soft);
  stroke: #526f9e;
  stroke-width: 2;
  stroke-linecap: round;
}
.empty-state h2 { margin: 0 0 8px; font-size: 20px; font-weight: 600; }
.empty-state p { margin: 0 0 24px; color: var(--muted); font-size: 14px; }
.primary-button {
  min-height: 44px;
  padding: 10px 20px;
  border-radius: var(--radius-control);
  color: #fff;
  background: var(--brand);
  font-size: 14px;
  font-weight: 500;
  transition: background-color var(--motion-duration-standard);
}
.no-script { margin: 60px 0; text-align: center; }

/* fitDialog() also accounts for wrapped captions and browser zoom. */
.card-dialog {
  --dialog-padding: 16px;
  position: fixed;
  width: min(820px, calc(100vw - 32px), calc((100dvh - 160px) * 85.6 / 53.98 + 32px));
  max-width: none;
  max-height: none;
  margin: auto;
  padding: var(--dialog-padding);
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-panel);
  color: var(--ink-strong);
  background: var(--surface);
  box-shadow: 0 24px 80px #18223033;
}
.card-dialog::backdrop { background: #18223080; backdrop-filter: blur(4px); }
.card-dialog[open] { animation: content-enter var(--motion-duration-standard) var(--motion-ease-emphasized); }
.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  padding: 8px;
  border-radius: var(--radius-control);
  color: var(--ink-strong);
  background: #fffffff2;
  box-shadow: 0 2px 8px #18223014;
}
.icon-button svg { width: 20px; height: 20px; }
.dialog-close { position: absolute; top: calc(var(--dialog-padding) + 8px); right: calc(var(--dialog-padding) + 8px); z-index: 2; }
.dialog-close:focus-visible { outline-offset: 2px; }
.detail-art .card-art { box-shadow: none; }
.detail-information {
  display: flex;
  min-height: 32px;
  align-items: center;
  gap: 12px;
  margin: 16px 2px 0;
}
.detail-information h2 { flex: 1; min-width: 0; margin: 0; font-size: 18px; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
.detail-bank { display: flex; flex-shrink: 0; align-items: center; }
.detail-type { flex-shrink: 0; padding: 4px 8px; border-radius: 6px; color: var(--muted); background: #f1f3f6; font-size: 12px; white-space: nowrap; }
body:has(.card-dialog[open]) { overflow: hidden; }
@keyframes content-enter {
  from { opacity: 0; transform: translate3d(0, 8px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

@media (hover: hover) and (pointer: fine) {
  .type-button:hover, .picker-option:hover, .clear-search:hover { color: var(--brand-strong); background: var(--soft); }
  .picker-trigger:hover { border-color: #b6c9ed; }
  .card-button:hover { border-color: #b6c9ed; box-shadow: 0 4px 16px #1822300a; }
  .card-button:hover .card-art { transform: translateY(-2px); }
  .primary-button:hover { background: var(--brand-strong); }
  .text-button:hover { text-decoration: underline; text-underline-offset: 3px; }
  .icon-button:hover { background: var(--surface); }
}
@media (max-width: 1100px) {
  .filters { grid-template-columns: 1fr; gap: 12px; }
  .filter-controls { justify-content: space-between; }
  .type-filters { margin-right: auto; }
}
@media (max-width: 1023px) {
  .header-content, .main-content { width: calc(100% - 64px); }
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gallery-hint { display: none; }
}
@media (max-width: 639px) {
  .header-content, .main-content { width: calc(100% - 48px); }
  .main-content { padding-block: 28px 32px; }
  .page-heading { margin-bottom: 24px; }
  .filters { gap: 12px; padding: 12px; }
  .search input { font-size: 16px; }
  .search-shortcut { display: none; }
  .filter-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 8px; }
  .type-filters { grid-column: 1 / -1; justify-content: space-between; width: 100%; margin: 0; }
  .type-button { flex: 1; }
  .picker-trigger, #network-trigger { width: 100%; gap: 6px; padding-inline: 10px; }
  .gallery { grid-template-columns: 1fr; gap: 20px; }
  .card-button { padding: 14px; }
  .card-dialog { --dialog-padding: 12px; }
  .detail-information { gap: 8px; margin-top: 12px; }
  .detail-information h2 { font-size: 16px; }
  .detail-bank .bank-logo { width: 22px; height: 22px; }
  .empty-state { padding: 40px 12px 64px; }
}
@media (max-width: 374px) {
  .header-content, .main-content { width: calc(100% - 32px); }
}
@media (max-width: 400px) {
  .picker-trigger:not(.is-filtered) .picker-icon { display: none; }
}
@media (max-height: 420px) {
  .card-dialog { --dialog-padding: 10px; }
  .detail-information { gap: 8px; margin-top: 8px; }
  .detail-information h2 { font-size: 15px; line-height: 1.4; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .card-button:hover .card-art { transform: none; }
}
