/* 与 webapps 统一：冷灰底色、白色面板与蓝色强调色。 */
:root {
  color-scheme: light;
  --surface-base: #f6f7f9;
  --surface-panel: #ffffff;
  --surface-stage: #f1f3f6;
  --ink-strong: #182230;
  --muted: #526075;
  --brand: #2563eb;
  --brand-strong: #1d4ed8;
  --border: #e2e6ec;
  --border-active: #b6c9ed;
  --soft: #eff4ff;
  --shadow-panel: 0 1px 3px rgb(16 24 40 / 4%);
  --font-body: Inter, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --content-max: 1160px;
  --gutter: 48px;
  --radius-control: 8px;
  --radius-stage: 16px;
  --radius-card: 10px;
  --radius-dialog: 16px;
  --motion: 180ms cubic-bezier(0.2, 0, 0, 1);
  --card-ratio: 85.6 / 53.98;
  font-family: var(--font-body);
  color: var(--ink-strong);
  background: var(--surface-base);
  font-synthesis: none;
}

*, *::before, *::after { box-sizing: border-box; }
html { scrollbar-gutter: stable; scroll-padding-top: 24px; }
body {
  margin: 0;
  min-height: 100vh;
  font-size: 16px;
  line-height: 1.7;
  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: var(--soft); }
[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: var(--surface-base);
  background: var(--ink-strong);
  transform: translateY(-160%);
}
.skip-link:focus { transform: translateY(0); }

/* 标题、工具栏、画廊和页脚共用同一条对齐线。 */
.main-content, .site-footer {
  width: calc(100% - var(--gutter) - var(--gutter));
  max-width: var(--content-max);
  margin-inline: auto;
}
.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding-block: 64px 36px;
}
.page-heading > div { min-width: 0; }
.panel-label { margin: 0 0 12px; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: 0.14em; }
.page-heading h1 {
  margin: 0;
  font-size: clamp(40px, 5vw, 52px);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.025em;
}
.brand { display: inline-block; min-height: 44px; }
.brand-emphasis { color: var(--brand); }
.page-description { max-width: 34em; margin: 16px 0 0; color: var(--muted); font-size: 16px; line-height: 1.8; }
.gallery-hint { display: flex; flex-shrink: 0; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }

/* 控件自然换行，保留点击区域和完整标签。 */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.search {
  display: flex;
  flex: 1 1 260px;
  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-panel);
  box-shadow: var(--shadow-panel);
  transition: border-color var(--motion), box-shadow var(--motion);
}
.search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--soft); }
.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; background: transparent; font-size: 14px; }
.search input::placeholder { color: var(--muted); opacity: 1; }
.search input:focus { 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-stage);
  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; flex-wrap: wrap; align-items: center; min-width: 0; max-width: 100%; gap: 8px; }
.filter-controls { flex: 1 1 600px; }
.type-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface-panel);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
  white-space: nowrap;
  transition: background-color var(--motion), color var(--motion), border-color var(--motion);
}
.type-button.is-active { border-color: var(--border-active); color: var(--brand-strong); background: var(--soft); }
.count { font-size: 12px; font-variant-numeric: tabular-nums; }
.picker-trigger {
  display: flex;
  flex: 1 1 152px;
  min-width: 0;
  max-width: 100%;
  min-height: 44px;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface-panel);
  text-align: left;
  font-size: 14px;
  line-height: 1.4;
  transition: border-color var(--motion), background-color var(--motion), color var(--motion);
}
.picker-trigger[aria-expanded="true"], .picker-trigger.is-filtered { border-color: var(--border-active); color: var(--brand-strong); background: var(--soft); }
.picker-icon, .option-icon { display: flex; flex: 0 0 20px; height: 20px; align-items: center; justify-content: center; }
.picker-icon svg, .option-icon svg { width: 20px; height: 20px; }
.picker-icon img, .option-icon img { width: 100%; height: 100%; object-fit: contain; }
.picker-label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.chevron { flex-shrink: 0; width: 16px; height: 16px; color: var(--muted); transition: transform var(--motion); }
.picker-trigger[aria-expanded="true"] .chevron { transform: rotate(180deg); }

/* 沿用原有顶层菜单和键盘操作。 */
.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: var(--radius-control);
  color: var(--ink-strong);
  background: var(--surface-panel);
  box-shadow: 0 8px 24px rgb(16 24 40 / 10%);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  overscroll-behavior: contain;
}
.picker-menu:popover-open { animation: surface-enter 180ms ease; }
.picker-option {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  gap: 12px;
  padding: 10px 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); }
.picker-option:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; background: var(--soft); }
.option-icon { flex-basis: 24px; height: 24px; }
.option-label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.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: 44px; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 16px; color: var(--muted); font-size: 14px; }
.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: 14px; }
.text-button span { font-size: 18px; }

/* 4:3 的展台承托原比例卡面，条目外层保持开放。 */
.gallery { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 40px 32px; scroll-margin-top: 24px; }
.gallery-card { min-width: 0; }
.card-button { display: block; width: 100%; padding: 0; border: 0; border-radius: var(--radius-stage); background: transparent; text-align: left; }
.card-art {
  --art-padding: 24px;
  display: block;
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  container-type: size;
  border-radius: var(--radius-stage);
  background: var(--surface-panel);
  box-shadow: inset 0 0 0 1px var(--border), var(--shadow-panel);
  transition: box-shadow var(--motion);
}
/* 根据原图比例收紧图片元素，让圆角贴合卡面边缘。 */
.card-art img {
  --image-ratio: calc(var(--card-ratio));
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(calc(100cqw - 2 * var(--art-padding)), calc((100cqh - 2 * var(--art-padding)) * var(--image-ratio)));
  height: auto;
  translate: -50% -50%;
  border-radius: var(--radius-card);
  object-fit: contain;
  object-position: center;
  filter: drop-shadow(0 4px 6px rgb(16 24 40 / 8%));
  transition: transform var(--motion), filter var(--motion);
  user-select: none;
  pointer-events: none;
}
.image-fallback { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; color: var(--muted); font-size: 14px; }
.card-caption { display: block; margin-top: 14px; }
.card-name { display: block; font-size: 17px; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
/* 保留全角标点宽度，让长卡名在行尾完整换行。 */
.card-name, .detail-information h2 { text-spacing-trim: space-all; }
.card-meta { display: block; margin-top: 4px; color: var(--muted); font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }
.bank-logo { flex-shrink: 0; width: 20px; height: 20px; object-fit: contain; }
.bank-logo-fallback { display: grid; place-items: center; color: var(--muted); }
.bank-logo-fallback svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.data-status, .empty-state { padding: 48px 16px; text-align: center; }
.data-status h2, .empty-state h2 { margin: 0 0 8px; font-size: 22px; font-weight: 500; }
.data-status p, .empty-state p { margin: 0 auto 24px; max-width: 34em; color: var(--muted); overflow-wrap: anywhere; }
.empty-state > svg { width: 48px; height: 48px; margin: 0 auto 24px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.primary-button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; padding: 10px 16px; border: 1px solid var(--brand); border-radius: var(--radius-control); color: var(--surface-panel); background: var(--brand); font-size: 14px; transition: background-color var(--motion), border-color var(--motion); }
.no-script { margin: 48px 0; text-align: center; }
.site-footer { margin-top: 64px; padding-block: 24px 32px; border-top: 1px solid var(--border); color: var(--muted); font-size: 14px; }
.site-footer p { margin: 0; }

/* 面板内容单独滚动，关闭按钮始终位于可见区域。 */
.card-dialog {
  --dialog-padding: 24px;
  position: fixed;
  width: min(960px, calc(var(--dialog-viewport-width, 100vw) - 24px));
  max-width: calc(100% - 24px);
  max-height: calc(var(--dialog-viewport-height, 100dvh) - 24px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-dialog);
  color: var(--ink-strong);
  background: var(--surface-panel);
  box-shadow: 0 24px 64px rgb(16 24 40 / 18%);
}
.card-dialog::backdrop { background: rgb(16 24 40 / 64%); }
.card-dialog[open] { display: flex; flex-direction: column; animation: surface-enter var(--motion); }
.dialog-toolbar { display: flex; flex-shrink: 0; justify-content: flex-end; padding: 8px 8px 0; }
.icon-button { display: grid; width: 44px; height: 44px; place-items: center; padding: 8px; border-radius: var(--radius-control); color: var(--ink-strong); background: transparent; }
.icon-button svg { width: 20px; height: 20px; }
.dialog-close:focus-visible { outline-offset: -2px; }
.dialog-content { min-height: 0; padding: 0 var(--dialog-padding) var(--dialog-padding); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.detail-art { --radius-card: 16px; }
.detail-art .card-art { aspect-ratio: var(--card-ratio); max-height: calc(var(--dialog-viewport-height, 100dvh) * 0.6); background: var(--surface-stage); box-shadow: inset 0 0 0 1px var(--border); }
.detail-information { margin-top: 16px; }
.detail-information h2 { margin: 0; font-size: 22px; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 8px; color: var(--muted); font-size: 14px; }
.detail-bank { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.detail-bank > span { overflow-wrap: anywhere; }
.detail-type { overflow-wrap: anywhere; }
.detail-type::before { content: "·"; margin-right: 8px; }
body:has(.card-dialog[open]) { overflow: hidden; }
@keyframes surface-enter { from { opacity: 0; } to { opacity: 1; } }

@media (hover: hover) and (pointer: fine) {
  .type-button:hover, .picker-option:hover, .clear-search:hover, .icon-button:hover { color: var(--brand-strong); background: var(--soft); }
  .type-button:hover, .picker-trigger:hover { border-color: var(--border-active); }
  .picker-trigger:hover { color: var(--brand-strong); background: var(--soft); }
  .card-button:hover .card-art { box-shadow: inset 0 0 0 1px var(--border-active), var(--shadow-panel); }
  .card-button:hover .card-art img { transform: translateY(-3px); filter: drop-shadow(0 8px 10px rgb(16 24 40 / 12%)); }
  .primary-button:hover { border-color: var(--brand-strong); background: var(--brand-strong); }
  .text-button:hover { text-decoration: underline; text-underline-offset: 3px; }
}
@media (min-width: 600px) and (max-width: 1023px) {
  :root { --gutter: 32px; }
  .search { flex-basis: 100%; }
  .filter-controls { width: 100%; }
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 36px 24px; }
}
@media (max-width: 1023px) { .gallery-hint { display: none; } }
@media (max-width: 767px) { .type-filters { flex-basis: 100%; } }
@media (max-width: 599px) {
  :root { --gutter: 20px; }
  .page-heading { padding-block: 36px 24px; }
  .page-heading h1 { font-size: 36px; }
  .panel-label { margin-bottom: 8px; }
  .page-description { margin-top: 12px; font-size: 15px; }
  .search { flex-basis: 100%; width: 100%; }
  .search input { font-size: 16px; }
  .search-shortcut { display: none; }
  .filter-controls, .type-filters { width: 100%; }
  .type-button { flex: 1; }
  .gallery { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .card-art { --art-padding: 20px; }
  .card-name { font-size: 16px; }
  .site-footer { margin-top: 48px; }
  .card-dialog { --dialog-padding: 16px; }
  .detail-information h2 { font-size: 20px; }
  .data-status, .empty-state { padding: 32px 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .card-button:hover .card-art img { transform: none; }
}
