body.is-gallery {
  --paper: var(--white);
}

body.is-gallery .page {
  padding-top: 18px;
}

.gallery-page {
  max-width: 920px;
}

.gallery-head h1 {
  margin: 0 0 16px;
}

.gallery-logo {
  display: block;
  width: min(450px, 100%);
  height: auto;
}

.gallery-tags {
  margin: 0 0 20px;
  padding: 10px 12px;
  background: var(--white);
  /* Win95 listbox: light from top-left. Gray chrome makes the white highlight visible on yellow paper. */
  border-style: solid;
  border-width: 2px;
  border-color: #808080 #fff #fff #808080;
  box-shadow:
    inset 1px 1px 0 #0a0a0a,
    0 0 0 2px #c0c0c0;
}

.gallery-tag-row {
  margin: 0 0 8px;
  line-height: 1.8;
}

.gallery-tag-row:last-child {
  margin-bottom: 0;
}

.gallery-tag-label {
  margin-right: 10px;
  color: var(--muted);
  font-weight: 700;
}

.gallery-tag {
  margin-right: 12px;
  white-space: nowrap;
}

.gallery-tag.is-current {
  font-weight: 700;
  text-decoration: underline;
}

.gallery-hint {
  color: var(--muted);
}

.gallery-frame {
  margin: 0;
  text-align: center;
}

.gallery-frame img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 85vh;
  object-fit: contain;
  background: var(--white);
  border: 1px solid var(--line-dark);
}

.gallery-frame figcaption {
  display: flex;
  align-items: baseline;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.gallery-like-stat {
  font-variant-numeric: tabular-nums;
}

.gallery-mark {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.gallery-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.gallery-actions form {
  margin: 0;
}

.gallery-actions .ghost-button.is-current {
  cursor: default;
  font-weight: 700;
}

.gallery-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin-top: 16px;
  font-size: 16px;
}

.gallery-pager a {
  font-weight: 700;
}

.gallery-pager .is-disabled {
  color: var(--line);
}

.gallery-count {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 720px) {
  .gallery-tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 0;
  }

  .gallery-tag-label {
    flex: 0 0 100%;
    margin-bottom: 2px;
  }
}

.study-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 20px;
}

.study-tabs .is-current {
  font-weight: 700;
}

.study-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.study-card {
  display: flex;
  flex-direction: column;
  margin: 0;
  background: var(--white);
  border: 1px solid var(--line-dark);
}

.study-open {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: stretch;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: zoom-in;
}

.study-open img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
}

.study-open span {
  display: block;
  padding: 8px 10px 12px;
  font-size: 13px;
}

.study-card form {
  margin: 0;
  padding: 0 10px 10px;
}

.study-lightbox {
  padding: 12px;
  border: 1px solid var(--line-dark);
  background: var(--paper);
  max-width: min(720px, 92vw);
}

.study-lightbox::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.study-lightbox img {
  display: block;
  max-width: min(680px, 88vw);
  max-height: 82vh;
  width: auto;
  height: auto;
  margin: 0 auto;
  background: var(--white);
}
