/* 图档预览页 */
.topnav nav a.on {
  color: var(--gold);
  background: rgba(255, 193, 7, 0.14);
}

.gal-hub {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(2, 1fr);
  max-width: 760px;
  margin: 0 auto;
}

@media (max-width: 700px) {
  .gal-hub { grid-template-columns: 1fr; max-width: 400px; }
}

.gal-hub-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.65rem;
  padding: 1.8rem 1.2rem 1.5rem;
  background: linear-gradient(165deg, #463628 0%, #2f251c 100%);
  border: var(--chunk);
  border-radius: var(--radius);
  box-shadow: 0 6px 0 #1a120c;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

a.gal-hub-card:hover {
  color: inherit;
  transform: translateY(-3px);
  box-shadow: 0 9px 0 #1a120c;
  border-color: rgba(255, 193, 7, 0.45);
}

.gal-hub-card h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.55rem;
  color: var(--gold-soft);
}

.gal-hub-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.gal-hub-badge {
  margin-top: 0.35rem;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--lava) 0%, var(--lava-deep) 100%);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
}

.section-head code {
  color: var(--gold-soft);
  background: rgba(0, 0, 0, 0.25);
  padding: 0.1em 0.35em;
  border-radius: 4px;
  font-size: 0.9em;
}

.gallery-page .hero {
  min-height: auto;
  padding: 3.5rem 0 2rem;
}

.gallery-page .hero-inner {
  padding-bottom: 1.5rem;
}

/* 图鉴列表加宽，桌面可排满 10 列（150×10 + 间距） */
.gallery-page .section {
  width: min(1680px, calc(100% - 1.5rem));
  max-width: none;
}

.gal-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem 1.25rem;
  margin-bottom: 1.25rem;
  padding: 0.9rem 1.1rem;
  background: linear-gradient(165deg, #463628 0%, #2f251c 100%);
  border: var(--chunk);
  border-radius: var(--radius);
  box-shadow: 0 4px 0 #1a120c;
}

.gal-search {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 1 1 240px;
  color: var(--muted);
  font-size: 0.92rem;
}

.gal-search input {
  flex: 1;
  min-width: 0;
  padding: 0.55rem 0.8rem;
  border-radius: 10px;
  border: 2px solid rgba(255, 220, 170, 0.2);
  background: rgba(0, 0, 0, 0.28);
  color: var(--ink);
  font: inherit;
}

.gal-search input:focus {
  outline: none;
  border-color: rgba(255, 193, 7, 0.55);
}

.gal-meta {
  margin: 0;
  color: var(--gold-soft);
  font-size: 0.9rem;
  white-space: nowrap;
}

.gal-grid {
  display: grid;
  grid-template-columns: repeat(10, 150px);
  justify-content: center;
  gap: 0.55rem 0.65rem;
}

.gal-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  width: 150px;
  padding: 0.35rem;
  background: linear-gradient(165deg, #463628 0%, #2f251c 100%);
  border: var(--chunk);
  border-radius: var(--radius-sm);
  box-shadow: 0 3px 0 #1a120c;
  cursor: pointer;
  color: inherit;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.gal-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 193, 7, 0.4);
  color: inherit;
}

/* 固定预览框 150×200：图片按原图像素 1:1 显示，不缩放、不拉伸 */
.gal-thumb {
  width: 150px;
  height: 200px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  overflow: hidden;
}

.gal-thumb img {
  display: block;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  object-fit: none;
  image-rendering: pixelated;
}

.gal-name {
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
  word-break: break-all;
  line-height: 1.3;
}

.gal-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.18);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.gal-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

.gal-pager button {
  padding: 0.45rem 1rem;
  border-radius: 10px;
  border: 2px solid rgba(255, 220, 170, 0.25);
  background: #3a2e24;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.gal-pager button:hover:not(:disabled) {
  border-color: var(--gold);
  color: var(--gold);
}

.gal-pager button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.gal-pager span {
  color: var(--muted);
  font-size: 0.92rem;
  min-width: 5em;
  text-align: center;
}

.gal-hint {
  margin-top: 1.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.55;
}

.gal-hint code {
  color: var(--gold-soft);
  background: rgba(0, 0, 0, 0.25);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

/* lightbox */
.gal-lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.5rem;
  padding: 1.5rem;
  background: rgba(8, 6, 4, 0.88);
  backdrop-filter: blur(4px);
}

.gal-lightbox[hidden] {
  display: none !important;
}

.gal-lb-figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  max-height: 90vh;
}

.gal-lb-figure img {
  max-width: min(92vw, 720px);
  max-height: 78vh;
  width: auto;
  height: auto;
  object-fit: contain;
  image-rendering: auto;
  background: rgba(0, 0, 0, 0.35);
  border: 3px solid rgba(255, 220, 170, 0.25);
  border-radius: 12px;
}

.gal-lb-figure figcaption {
  color: var(--gold-soft);
  font-size: 0.95rem;
}

.gal-lb-close {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  width: 2.4rem;
  height: 2.4rem;
  border: none;
  border-radius: 50%;
  background: rgba(255, 87, 34, 0.85);
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.gal-lb-nav {
  width: 2.8rem;
  height: 2.8rem;
  border-radius: 50%;
  border: 2px solid rgba(255, 220, 170, 0.35);
  background: rgba(58, 46, 36, 0.9);
  color: var(--ink);
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
}

.gal-lb-nav:hover {
  border-color: var(--gold);
  color: var(--gold);
}

/* 桌面默认 10 列；变窄逐步减少 */
@media (max-width: 1600px) {
  .gal-grid { grid-template-columns: repeat(8, 150px); }
}
@media (max-width: 1280px) {
  .gal-grid { grid-template-columns: repeat(6, 150px); }
}
@media (max-width: 980px) {
  .gal-grid { grid-template-columns: repeat(4, 150px); }
}
@media (max-width: 700px) {
  .gal-grid { grid-template-columns: repeat(3, 150px); }
}
@media (max-width: 520px) {
  .gal-grid { grid-template-columns: repeat(2, 150px); }
}

@media (max-width: 640px) {
  .gal-lightbox {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto 1fr;
    justify-items: center;
  }
  .gal-lb-nav.prev { order: 2; }
  .gal-lb-figure { order: 1; }
  .gal-lb-nav.next { order: 3; }
}
