* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: #0f0f1a;
  color: #e0e0e0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.brand-strip {
  height: 3px;
  background: linear-gradient(to right, #6B8C2A, #4BA8D8, #E8417A, #D4A820);
}

.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 15, 26, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid #2a2a3e;
  padding: 16px 24px;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.header-logo {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-logo img {
  height: 44px;
  width: auto;
  display: block;
}

.header-divider {
  width: 1px;
  height: 56px;
  background: #2a2a3e;
  flex-shrink: 0;
}

.header-titles {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.header-titles .zh {
  font-size: 20px;
  font-weight: 500;
  color: #e8e8e8;
  letter-spacing: 1px;
}

.header-titles .en {
  font-size: 12px;
  color: #888;
  letter-spacing: 0.5px;
}

.header-spacer {
  flex: 1;
}

.count-badge {
  background: #1e1e30;
  border: 1px solid #2a2a3e;
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 12px;
  color: #888;
  white-space: nowrap;
}

.search-box {
  background: #1a1a2e;
  border: 1px solid #2a2a3e;
  border-radius: 8px;
  padding: 7px 14px;
  color: #e0e0e0;
  font-size: 13px;
  width: 240px;
  outline: none;
  transition: border-color 0.2s;
}

.search-box:focus { border-color: #4a9eff; }
.search-box::placeholder { color: #555; }

.sort-select {
  background: #1a1a2e;
  border: 1px solid #2a2a3e;
  border-radius: 8px;
  padding: 7px 12px;
  color: #e0e0e0;
  font-size: 13px;
  cursor: pointer;
  outline: none;
}

.gallery {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 20px;
}

.card {
  background: #1a1a2e;
  border: 1px solid #2a2a3e;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.card:hover {
  transform: translateY(-3px);
  border-color: #4a9eff;
  box-shadow: 0 6px 20px rgba(74, 158, 255, 0.12);
}

.card-img-wrap {
  width: 100%;
  aspect-ratio: 148 / 190;
  background: #252538;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-placeholder {
  color: #555;
  font-size: 12px;
  text-align: center;
  line-height: 1.8;
}

.card-placeholder .icon { font-size: 30px; display: block; margin-bottom: 6px; }

.card.noimg { border-style: dashed; }
.card.noimg:hover { border-color: #7a6ccf; }

.card-info {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-num {
  font-size: 11px;
  color: #888;
  font-family: "SF Mono", "Consolas", "Courier New", monospace;
  letter-spacing: 0.3px;
}

.card-tag {
  font-size: 10px;
  color: #7a6ccf;
  border: 1px solid rgba(122, 108, 207, 0.4);
  border-radius: 3px;
  padding: 1px 6px;
  margin-left: 6px;
}

.card-arrow {
  color: #4a9eff;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.2s;
}

.card:hover .card-arrow { opacity: 1; }

.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 24px;
  color: #555;
  font-size: 14px;
}

.pagination {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px 48px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.page-btn {
  background: #1a1a2e;
  border: 1px solid #2a2a3e;
  border-radius: 6px;
  padding: 7px 13px;
  color: #888;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.page-btn:hover:not(:disabled) {
  border-color: #4a9eff;
  color: #e0e0e0;
}

.page-btn.active {
  background: #4a9eff;
  border-color: #4a9eff;
  color: #fff;
}

.page-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 200;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ccc;
  font-size: 22px;
  cursor: pointer;
  transition: background 0.2s;
  user-select: none;
}

.modal-close:hover { background: rgba(255, 255, 255, 0.18); }

.modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.modal-nav:hover { background: rgba(0, 0, 0, 0.7); }
.modal-nav:active { transform: translateY(-50%) scale(0.9); }
.modal-prev { left: 10px; }
.modal-next { right: 10px; }

.modal-frame-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.modal-frame-scaler {
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  /* width & height set by JS to scaled dimensions */
}

.modal-frame {
  position: absolute;
  top: 0;
  left: 0;
  width: 560px;   /* A5 card design width  148mm ≈ 559px */
  height: 719px;  /* A5 card design height 190mm ≈ 718px, pad to 800 */
  border: none;
  background: #fff;
  transform-origin: top left;
  /* transform: scale() set by JS */
}

.modal-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: #888;
  font-size: 13px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: #4a9eff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.modal-info {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 20px;
  color: #888;
  font-size: 13px;
}

.modal-info a {
  color: #4a9eff;
  text-decoration: none;
  border: 1px solid rgba(74, 158, 255, 0.4);
  border-radius: 4px;
  padding: 4px 14px;
  font-size: 12px;
  transition: background 0.2s;
}

.modal-info a:hover { background: rgba(74, 158, 255, 0.1); }

@media (max-width: 768px) {
  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    padding: 16px;
  }
  .header { padding: 12px 16px; }
  .header-logo { gap: 10px; }
  .header-logo img { height: 32px; }
  .header-divider { height: 36px; }
  .header-titles .zh { font-size: 16px; }
  .header-titles .en { font-size: 10px; }
  .header-inner { gap: 12px; }
  .search-box { width: 100%; }
  .modal-nav { width: 56px; height: 56px; font-size: 36px; }
  .modal-prev { left: 8px; }
  .modal-next { right: 8px; }
}
