:root {
  color-scheme: light;
  --paper: #f7f6f2;
  --paper-deep: #eceae3;
  --ink: #182a35;
  --muted: #6f7878;
  --line: #d5d7d2;
  --accent: #b64b3a;
  --accent-dark: #873428;
  --panel: #fffefa;
  --shadow: 0 18px 50px rgba(24, 42, 53, 0.14);
  font-family: "Avenir Next", "PingFang SC", "Noto Sans CJK SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.site-header,
.site-footer,
.catalog-heading,
.gallery-shell {
  width: min(100% - 40px, 1480px);
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 88px;
  border-bottom: 1px solid var(--line);
}

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

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--ink);
  color: var(--accent);
  font-family: Georgia, "Songti SC", serif;
  font-size: 17px;
}

.brand strong,
.brand small {
  display: block;
  letter-spacing: 0;
}

.brand strong {
  font-family: Georgia, "Songti SC", serif;
  font-size: 16px;
  font-weight: 500;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.primary-button,
.secondary-button,
.text-button,
.icon-button {
  border: 0;
  background: transparent;
  color: inherit;
}

.primary-button,
.secondary-button {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--ink);
  border-radius: 2px;
  transition: background-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.primary-button {
  color: #fff;
  background: var(--ink);
}

.primary-button:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.secondary-button:hover {
  color: #fff;
  background: var(--ink);
}

.text-button {
  padding: 4px 2px;
  color: var(--muted);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.text-button:hover {
  color: var(--accent);
}

.catalog-heading {
  padding: 82px 0 22px;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}

.catalog-heading-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 380px);
  gap: 30px;
  align-items: end;
}

h1,
h2 {
  margin: 0;
  font-family: Georgia, "Songti SC", serif;
  font-weight: 400;
}

h1 {
  font-size: clamp(48px, 6vw, 86px);
  line-height: 0.94;
}

h1 em {
  color: var(--accent);
  font-size: 0.62em;
  font-weight: 400;
}

h2 {
  font-size: 34px;
}

.catalog-note {
  max-width: 320px;
  margin: 0 0 7px auto;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

.catalog-rule {
  display: flex;
  justify-content: space-between;
  margin-top: 52px;
  padding-top: 11px;
  border-top: 1px solid var(--ink);
  color: var(--muted);
  font-size: 10px;
}

.gallery-shell {
  min-height: 380px;
  padding: 20px 0 88px;
}

.gallery-status {
  padding: 80px 0;
  color: var(--muted);
  text-align: center;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 62px 34px;
}

.artwork {
  min-width: 0;
  margin: 0;
  animation: reveal 500ms ease both;
}

.artwork-button {
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--paper-deep);
  box-shadow: 0 4px 0 rgba(24, 42, 53, 0.05);
}

.artwork-button img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  transition: transform 420ms ease, filter 420ms ease;
}

.artwork-button:hover img {
  filter: contrast(1.04);
  transform: scale(1.025);
}

.artwork figcaption {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 14px;
  color: var(--ink);
  font-family: Georgia, "Songti SC", serif;
  font-size: 17px;
}

.artwork figcaption::before {
  width: 20px;
  height: 1px;
  background: var(--accent);
  content: "";
}

.site-footer {
  display: flex;
  justify-content: space-between;
  padding: 18px 0 28px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
}

dialog {
  border: 0;
}

dialog::backdrop {
  background: rgba(16, 28, 34, 0.58);
  backdrop-filter: blur(4px);
}

.modal {
  width: min(92vw, 660px);
  max-height: 90vh;
  padding: 0;
  overflow: auto;
  border-radius: 4px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.modal-inner {
  padding: 30px;
}

.modal-header,
.admin-toolbar,
.upload-owner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: var(--muted);
  font-size: 30px;
  line-height: 1;
}

.icon-button:hover {
  color: var(--accent);
}

.upload-step,
.admin-login,
.admin-panel {
  margin-top: 34px;
}

.field-label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.inline-field {
  display: flex;
  gap: 10px;
}

input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--ink);
  background: #fff;
  outline: 0;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(182, 75, 58, 0.12);
}

.form-message {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--accent-dark);
  font-size: 13px;
  line-height: 1.5;
}

.upload-owner {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.upload-owner span {
  color: var(--muted);
}

.upload-owner strong {
  margin-right: auto;
  font-size: 17px;
}

.dropzone {
  display: grid;
  min-height: 190px;
  margin-top: 18px;
  place-items: center;
  align-content: center;
  gap: 7px;
  border: 1px dashed #9ca4a3;
  background: #f8f8f5;
  text-align: center;
  transition: border-color 180ms ease, background-color 180ms ease;
}

.dropzone:hover,
.dropzone.is-dragging {
  border-color: var(--accent);
  background: #fdf8f5;
}

.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.dropzone-symbol {
  color: var(--accent);
  font-size: 38px;
  line-height: 1;
}

.dropzone small,
.replacement-note {
  color: var(--muted);
  font-size: 12px;
}

.upload-preview {
  margin: 18px 0 0;
  padding: 10px;
  border: 1px solid var(--line);
  background: #fff;
}

.upload-preview img {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: contain;
}

.file-selection {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #fff;
}

.file-selection strong,
.file-selection span {
  display: block;
}

.file-selection strong {
  margin-bottom: 6px;
  font-size: 13px;
}

.file-selection span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.replacement-note {
  margin: 14px 0 0;
  padding-left: 11px;
  border-left: 2px solid var(--accent);
  line-height: 1.7;
}

.submit-upload {
  width: 100%;
  margin-top: 4px;
}

.lightbox {
  width: 100vw;
  max-width: none;
  height: 100vh;
  max-height: none;
  margin: 0;
  padding: 0;
  color: #fff;
  background: rgba(13, 25, 31, 0.96);
}

.lightbox figure {
  display: grid;
  height: 100%;
  margin: 0;
  place-items: center;
  align-content: center;
  gap: 14px;
  padding: 54px 90px;
}

.lightbox img {
  max-width: 100%;
  max-height: calc(100vh - 116px);
  object-fit: contain;
}

.lightbox figcaption {
  font-family: Georgia, "Songti SC", serif;
  font-size: 18px;
}

.lightbox-close,
.lightbox-arrow {
  position: fixed;
  z-index: 2;
  border: 0;
  color: #fff;
  background: transparent;
}

.lightbox-close {
  top: 18px;
  right: 25px;
  font-size: 38px;
}

.lightbox-arrow {
  top: 50%;
  padding: 12px;
  font-size: 30px;
  transform: translateY(-50%);
}

.lightbox-prev {
  left: 18px;
}

.lightbox-next {
  right: 18px;
}

.admin-modal {
  width: min(94vw, 940px);
}

.add-member {
  width: min(100%, 420px);
}

.member-list {
  margin-top: 18px;
  border-top: 1px solid var(--line);
}

.member-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto;
  gap: 18px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.member-main {
  display: flex;
  gap: 12px;
  align-items: center;
}

.member-thumb {
  width: 54px;
  height: 70px;
  border: 1px solid var(--line);
  object-fit: cover;
}

.member-placeholder {
  display: grid;
  width: 54px;
  height: 70px;
  place-items: center;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.member-meta strong,
.member-meta small {
  display: block;
}

.member-meta small {
  margin-top: 5px;
  color: var(--muted);
}

.member-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: end;
}

.danger-button {
  color: var(--accent-dark);
}

.history-list {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 12px;
  padding-top: 8px;
}

.material-list {
  grid-column: 1 / -1;
  display: grid;
  gap: 6px;
  padding-top: 8px;
}

.material-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 12px;
  text-decoration: none;
}

.material-item:hover {
  border-color: var(--accent);
}

.material-item span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.material-item span:last-child {
  color: var(--muted);
}

.history-item {
  position: relative;
  padding: 0;
  border: 1px solid var(--line);
  background: transparent;
}

.history-item img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
}

.history-item span {
  display: block;
  padding: 6px 4px;
  color: var(--muted);
  font-size: 10px;
}

.history-item.is-current {
  border-color: var(--accent);
}

.is-hidden {
  display: none !important;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 1180px) {
  .gallery-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .site-header,
  .site-footer,
  .catalog-heading,
  .gallery-shell {
    width: min(100% - 28px, 640px);
  }

  .site-header {
    min-height: 74px;
  }

  .brand small,
  .header-actions .text-button {
    display: none;
  }

  .catalog-heading {
    padding-top: 54px;
  }

  .catalog-heading-row {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 52px;
  }

  .catalog-note {
    margin: 0;
  }

  .catalog-rule {
    margin-top: 32px;
  }

  .gallery-grid {
    grid-template-columns: 1fr;
    gap: 46px;
  }

  .gallery-shell {
    padding-bottom: 58px;
  }

  .modal-inner {
    padding: 22px;
  }

  .lightbox figure {
    padding: 64px 20px 90px;
  }

  .lightbox-arrow {
    top: auto;
    bottom: 20px;
  }

  .lightbox-prev {
    left: calc(50% - 68px);
  }

  .lightbox-next {
    right: calc(50% - 68px);
  }

  .admin-toolbar {
    display: block;
  }

  .admin-toolbar > .text-button {
    margin-top: 14px;
  }

  .member-row {
    grid-template-columns: 1fr;
  }

  .member-actions {
    justify-content: start;
  }
}
