:root {
  --yellow-50: #fffdf0;
  --yellow-100: #fff7c7;
  --yellow-200: #ffe981;
  --yellow-300: #ffd83d;
  --yellow-400: #ffc91a;
  --blue-700: #173b8c;
  --blue-800: #102c6d;
  --ink: #1f2430;
  --muted: #687080;
  --line: rgba(23, 59, 140, 0.15);
  --white: #ffffff;
  --shadow: 0 18px 54px rgba(87, 67, 4, 0.12);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  color: var(--ink);
  background: var(--yellow-50);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 8%, rgba(255, 216, 61, 0.48), transparent 26rem),
    linear-gradient(180deg, #fff9d6 0, #fffdf4 34rem, #fffaf0 100%);
}

button, input { font: inherit; }
button { cursor: pointer; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(24px, calc((100vw - 1160px) / 2));
  background: rgba(255, 250, 216, 0.9);
  border-bottom: 1px solid rgba(23, 59, 140, 0.1);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--blue-800);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px 6px 14px 6px;
  color: white;
  background: var(--blue-700);
  font-size: 15px;
  font-weight: 900;
  letter-spacing: -0.04em;
  transform: rotate(-3deg);
  box-shadow: 5px 5px 0 var(--yellow-300);
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 18px; letter-spacing: 0.12em; }
.brand small { margin-top: 2px; color: #7d6b27; font-size: 12px; }
.topbar-note { color: #7d6b27; font-size: 13px; }

.page-shell {
  width: min(1160px, calc(100% - 36px));
  margin: 38px auto 80px;
}

.search-panel {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(420px, 1.1fr);
  align-items: center;
  gap: 50px;
  min-height: 310px;
  padding: 48px 54px;
  border: 2px solid var(--blue-700);
  border-radius: 34px 12px 34px 12px;
  color: var(--blue-800);
  background:
    linear-gradient(120deg, rgba(255,255,255,0.5), transparent 48%),
    var(--yellow-300);
  box-shadow: var(--shadow);
}

.search-panel::before,
.search-panel::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.search-panel::before {
  width: 250px;
  height: 250px;
  right: -88px;
  top: -116px;
  border: 34px solid rgba(255,255,255,0.42);
  border-radius: 50%;
}

.search-panel::after {
  width: 150px;
  height: 44px;
  left: -24px;
  bottom: 20px;
  background: repeating-linear-gradient(90deg, rgba(23,59,140,.12) 0 12px, transparent 12px 23px);
  transform: rotate(-8deg);
}

.search-copy, .query-form { position: relative; z-index: 1; }
.eyebrow, .section-kicker {
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 1.4;
  font-weight: 900;
  letter-spacing: 0.18em;
  color: var(--blue-700);
}

.search-copy h1 {
  max-width: 500px;
  margin: 0;
  font-size: clamp(34px, 4.2vw, 58px);
  line-height: 1.08;
  letter-spacing: -0.045em;
}

.search-copy > p:last-child {
  max-width: 460px;
  margin: 20px 0 0;
  color: rgba(16, 44, 109, 0.78);
  font-size: 16px;
  line-height: 1.75;
}

.query-form {
  padding: 28px;
  border: 1px solid rgba(23, 59, 140, 0.16);
  border-radius: 24px 8px 24px 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 38px rgba(93, 69, 0, 0.1);
}

.query-form label {
  display: block;
  margin-bottom: 10px;
  color: var(--blue-800);
  font-size: 15px;
  font-weight: 800;
}

.input-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }

.input-row input {
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border: 1.5px solid #d7dbea;
  border-radius: 12px;
  outline: none;
  color: var(--ink);
  background: white;
  font-size: 16px;
  transition: border-color .18s ease, box-shadow .18s ease;
}

.input-row input:focus {
  border-color: var(--blue-700);
  box-shadow: 0 0 0 4px rgba(23, 59, 140, 0.12);
}

.primary-button, .download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  color: white;
  background: var(--blue-700);
  font-weight: 800;
  box-shadow: 0 9px 0 var(--blue-800);
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

.primary-button { min-height: 52px; padding: 0 22px; border-radius: 12px; }
.primary-button svg, .download-button svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.primary-button:hover, .download-button:hover { background: #2149a0; transform: translateY(-1px); }
.primary-button:active, .download-button:active { transform: translateY(5px); box-shadow: 0 4px 0 var(--blue-800); }
.primary-button:disabled, .download-button:disabled { opacity: .62; cursor: wait; transform: none; }

.form-hint, .query-status { margin: 12px 0 0; font-size: 13px; line-height: 1.5; }
.form-hint { color: var(--muted); }
.query-status { min-height: 20px; color: #b13a17; font-weight: 700; }

.empty-state {
  display: grid;
  grid-template-columns: 260px 1fr;
  align-items: center;
  gap: 52px;
  margin-top: 24px;
  padding: 36px 54px;
  border: 1px solid var(--line);
  border-radius: 14px 30px 14px 30px;
  background: rgba(255,255,255,.7);
}

.empty-state h2 { margin: 0 0 10px; color: var(--blue-800); font-size: 24px; }
.empty-state p { max-width: 680px; margin: 0; color: var(--muted); line-height: 1.8; }
.empty-art { position: relative; height: 170px; }
.mini-card {
  position: absolute;
  width: 90px;
  height: 142px;
  border: 5px solid white;
  border-radius: 16px;
  box-shadow: 0 12px 28px rgba(30, 42, 72, .16);
}
.card-a { left: 10px; top: 20px; background: #90c9ff; transform: rotate(-10deg); }
.card-b { left: 82px; top: 4px; background: var(--yellow-300); transform: rotate(2deg); }
.card-c { left: 156px; top: 21px; display: grid; place-items: center; color: white; background: var(--blue-700); font-size: 48px; font-weight: 900; transform: rotate(10deg); }

.result-view { margin-top: 38px; }
.result-heading, .summary-card-head, .gallery-heading, .download-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.result-heading h2, .summary-card h3, .download-panel h3, .gallery-heading h3 { margin: 0; color: var(--blue-800); }
.result-heading h2 { font-size: 28px; }
.text-button { border: 0; padding: 9px 2px; color: var(--blue-700); background: transparent; font-weight: 800; border-bottom: 2px solid currentColor; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-top: 20px;
}
.metric-card {
  min-height: 128px;
  padding: 22px;
  border: 1px solid rgba(23, 59, 140, .13);
  border-radius: 18px 6px 18px 6px;
  background: white;
  box-shadow: 0 10px 30px rgba(77, 64, 14, .06);
}
.metric-card.primary { color: white; background: var(--blue-700); }
.metric-label { display: block; margin-bottom: 14px; color: var(--muted); font-size: 13px; font-weight: 700; }
.metric-card.primary .metric-label { color: rgba(255,255,255,.72); }
.metric-value { font-size: 32px; line-height: 1; font-weight: 900; letter-spacing: -.04em; }
.metric-value small { margin-left: 4px; font-size: 14px; font-weight: 700; letter-spacing: 0; }
.metric-note { margin: 9px 0 0; color: var(--muted); font-size: 12px; }
.metric-card.primary .metric-note { color: rgba(255,255,255,.72); }

.summary-card {
  margin-top: 22px;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 24px 8px 24px 8px;
  background: white;
  box-shadow: 0 12px 36px rgba(79, 65, 7, .07);
}
.count-badge { padding: 8px 12px; border-radius: 999px; color: var(--blue-800); background: var(--yellow-100); font-size: 13px; font-weight: 800; }
.summary-sections { margin-top: 22px; border-top: 1px solid #edf0f6; }
.summary-section { display: grid; grid-template-columns: 168px 1fr; gap: 26px; padding: 22px 0; border-bottom: 1px solid #edf0f6; }
.summary-section:last-child { padding-bottom: 0; border-bottom: 0; }
.summary-label { color: var(--blue-800); font-size: 15px; font-weight: 900; }
.summary-copy { color: #3f4756; font-size: 14px; line-height: 1.9; }
.summary-copy p { margin: 0 0 9px; }
.summary-copy p:last-child { margin-bottom: 0; }
.category-line strong { display: inline-block; min-width: 66px; color: var(--ink); }
.detail-chip { display: inline-block; margin: 3px 8px 3px 0; padding: 4px 9px; border-radius: 8px; color: #384253; background: #f5f6f9; line-height: 1.5; }
.detail-chip.special { color: var(--blue-800); background: var(--yellow-100); }
.empty-copy { color: #9299a7; }
.success-copy { color: #1c6a45; font-weight: 800; }
.warning-copy { color: #9b5a00; }

.download-panel {
  position: relative;
  overflow: hidden;
  margin-top: 22px;
  padding: 30px;
  border: 2px solid var(--blue-700);
  border-radius: 8px 24px 8px 24px;
  background: var(--yellow-300);
}
.download-panel > * { position: relative; z-index: 1; }
.download-panel p { margin: 8px 0 0; color: rgba(16,44,109,.76); }
.download-actions { display: grid; justify-items: center; gap: 10px; }
.download-button { min-height: 56px; padding: 0 24px; border-radius: 12px; white-space: nowrap; }
.download-fallback { color: var(--blue-800); font-size: 13px; font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }

.gallery-heading { margin-top: 44px; }
.gallery-heading > p { margin: 0; color: var(--muted); font-size: 13px; }
.gallery-groups { display: grid; gap: 18px; margin-top: 18px; }
.gallery-group { padding: 24px; border: 1px solid var(--line); border-radius: 20px 7px 20px 7px; background: rgba(255,255,255,.82); }
.gallery-group-title { display: flex; align-items: baseline; gap: 10px; margin-bottom: 16px; }
.gallery-group-title h4 { margin: 0; color: var(--blue-800); font-size: 18px; }
.gallery-group-title span { color: var(--muted); font-size: 12px; }
.card-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; }
.collectible {
  position: relative;
  min-width: 0;
  padding: 8px 8px 11px;
  border: 1px solid rgba(23,59,140,.1);
  border-radius: 15px;
  background: white;
  box-shadow: 0 6px 18px rgba(28, 42, 72, .07);
}
.collectible-image {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border-radius: 10px;
  background: linear-gradient(145deg, #fffbe4, #f5f7fb);
}
.collectible-image img { width: 100%; height: 100%; object-fit: contain; display: block; }
.collectible-count { position: absolute; top: 14px; right: 14px; min-width: 30px; padding: 4px 7px; border: 2px solid white; border-radius: 999px; color: white; background: var(--blue-700); font-size: 12px; font-weight: 900; text-align: center; box-shadow: 0 4px 12px rgba(16,44,109,.28); }
.collectible-label { display: block; overflow: hidden; margin-top: 9px; color: #303747; font-size: 13px; line-height: 1.45; font-weight: 700; text-align: center; text-overflow: ellipsis; white-space: nowrap; }

.site-footer { padding: 26px 20px 40px; color: #8c7d43; font-size: 12px; letter-spacing: .08em; text-align: center; }
.toast { position: fixed; left: 50%; bottom: 30px; z-index: 20; max-width: min(90vw, 440px); padding: 13px 18px; border-radius: 12px; color: white; background: #27324a; box-shadow: 0 12px 34px rgba(0,0,0,.22); font-size: 14px; transform: translateX(-50%); }

@media (max-width: 980px) {
  .search-panel { grid-template-columns: 1fr; gap: 28px; padding: 42px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .card-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .topbar { height: 66px; padding: 0 18px; }
  .topbar-note { display: none; }
  .page-shell { width: min(100% - 24px, 1160px); margin-top: 18px; }
  .search-panel { min-height: 0; padding: 30px 20px; border-radius: 24px 8px 24px 8px; }
  .search-copy h1 { font-size: 36px; }
  .search-copy > p:last-child { margin-top: 14px; font-size: 15px; }
  .query-form { padding: 18px; }
  .input-row { grid-template-columns: 1fr; }
  .primary-button { width: 100%; }
  .empty-state { grid-template-columns: 1fr; gap: 20px; padding: 28px 22px; }
  .empty-art { height: 140px; transform: scale(.84); transform-origin: left center; }
  .result-heading { align-items: flex-start; }
  .result-heading h2 { font-size: 23px; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric-card { min-height: 112px; padding: 18px 15px; }
  .metric-value { font-size: 27px; }
  .summary-card { padding: 22px 18px; }
  .summary-card-head { align-items: flex-start; }
  .summary-section { grid-template-columns: 1fr; gap: 8px; padding: 18px 0; }
  .download-panel { align-items: stretch; flex-direction: column; padding: 24px 20px; }
  .download-actions { width: 100%; }
  .download-button { width: 100%; }
  .download-fallback { text-align: center; }
  .gallery-heading { align-items: flex-start; flex-direction: column; gap: 8px; }
  .gallery-group { padding: 16px 12px; }
  .card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
  .collectible { padding: 5px 5px 9px; border-radius: 12px; }
  .collectible-image { border-radius: 8px; }
  .collectible-count { top: 9px; right: 9px; }
  .collectible-label { font-size: 12px; }
}

@media (max-width: 390px) {
  .metric-grid { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}
