.gallery-page {
  min-height: 100dvh;
}

.gallery-page [hidden] {
  display: none !important;
}

.gallery-hero {
  position: relative;
  isolation: isolate;
  display: grid;
  align-items: end;
  min-height: clamp(430px, 50svh, 500px);
  overflow: clip;
  color: #fff9fc;
  background: #201c23;
}

.gallery-hero > img,
.gallery-hero-shade {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-hero > img {
  object-position: center 47%;
}

.gallery-hero-shade {
  z-index: -1;
  background: linear-gradient(90deg, rgba(17, 15, 21, 0.88) 0%, rgba(20, 17, 23, 0.58) 54%, rgba(20, 17, 23, 0.2) 100%);
  box-shadow: inset 0 -150px 100px rgba(17, 14, 19, 0.42);
}

.gallery-hero-content {
  width: min(var(--max-width), calc(100% - 48px));
  margin: 0 auto;
  padding: calc(var(--header-height) + 48px) 0 42px;
}

.gallery-hero-content > p:first-child,
.gallery-section-heading > p,
.gallery-account-copy > p,
.submission-dialog-header p {
  margin: 0 0 10px;
  color: #ffc0d1;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
}

.gallery-hero-content h1 {
  margin: 0;
  color: #fff9fc;
  font-family: "Noto Serif TC", "PMingLiU", serif;
  font-size: clamp(50px, 6vw, 78px);
  line-height: 1.1;
}

.gallery-hero-content > span {
  display: block;
  max-width: 560px;
  margin-top: 20px;
  color: #fff4f7;
  font-size: 20px;
  font-weight: 650;
}

.gallery-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}

.gallery-hero-actions .button {
  min-width: 164px;
  justify-content: center;
}

.gallery-login-note {
  margin: 18px 0 0;
  color: rgba(255, 245, 248, 0.78);
  font-size: 14px;
  font-weight: 650;
}

.gallery-account-section {
  position: relative;
  z-index: 2;
  width: min(var(--max-width), calc(100% - 48px));
  margin: 0 auto;
  padding: 0 0 72px;
}

.gallery-account-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.95fr);
  gap: 24px;
  align-items: center;
  padding: 28px 32px;
  color: var(--ink);
  background: #28242b;
  border: 1px solid #514852;
  border-left: 4px solid var(--rose);
  box-shadow: var(--shadow);
}

.gallery-account-copy h2,
.gallery-section-heading h2 {
  margin: 0;
  color: var(--ink);
  font-family: "Noto Serif TC", "PMingLiU", serif;
  font-size: 34px;
  line-height: 1.24;
}

.gallery-account-copy > span,
.gallery-section-heading > span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 16px;
}

.gallery-account-state {
  min-width: 0;
}

.gallery-account-loading,
.gallery-login-status,
.gallery-status,
.submission-status {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.gallery-login-status {
  min-height: 24px;
  margin: 8px 4px 0;
}

.gallery-account-guest,
.gallery-account-user {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
}

.gallery-account-guest > span {
  max-width: 190px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.gallery-login-button,
.gallery-admin-link,
.gallery-logout-button,
.gallery-refresh-button,
.gallery-load-more,
.dialog-cancel {
  min-height: 42px;
  padding: 9px 14px;
  color: var(--ink);
  background: #211e24;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 14px;
  font-weight: 800;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.gallery-login-button,
.gallery-admin-link {
  color: #fff9fc;
  background: #aa536f;
  border-color: #c97991;
}

.gallery-login-button:hover,
.gallery-login-button:focus-visible,
.gallery-admin-link:hover,
.gallery-admin-link:focus-visible {
  background: #c06682;
}

.gallery-logout-button:hover,
.gallery-logout-button:focus-visible,
.gallery-refresh-button:hover,
.gallery-refresh-button:focus-visible,
.gallery-load-more:hover,
.gallery-load-more:focus-visible,
.dialog-cancel:hover,
.dialog-cancel:focus-visible {
  background: #302a32;
  border-color: #6b5d68;
}

.gallery-account-user img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border: 1px solid #ca9baa;
  border-radius: 50%;
}

.gallery-account-user > div {
  display: grid;
  min-width: 0;
  gap: 2px;
  margin-right: auto;
}

.gallery-account-user strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-account-user span {
  color: var(--muted);
  font-size: 13px;
}

.gallery-guidelines,
.my-submissions-section,
.town-gallery-section {
  box-sizing: border-box;
  width: min(var(--max-width), calc(100% - 48px));
  margin-right: auto;
  margin-left: auto;
  padding-right: 0;
  padding-left: 0;
}

.gallery-guidelines {
  padding-top: 72px;
  padding-bottom: 80px;
  border-top: 1px solid var(--line);
}

.gallery-section-heading {
  max-width: 760px;
}

.gallery-guideline-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 28px;
}

.gallery-guideline-grid article {
  min-height: 214px;
  padding: 26px;
  background: #252229;
  border: 1px solid var(--line);
  border-top: 3px solid #aa536f;
}

.gallery-guideline-grid span {
  display: block;
  color: #f4a9bd;
  font-size: 13px;
  font-weight: 850;
}

.gallery-guideline-grid h3 {
  margin: 18px 0 9px;
  color: var(--ink);
  font-size: 21px;
}

.gallery-guideline-grid p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}

.my-submissions-section {
  padding: 36px 0 64px;
  border-top: 1px solid var(--line);
}

.gallery-section-heading-compact,
.gallery-section-heading-with-action {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  max-width: none;
}

.gallery-section-heading-compact > span {
  margin: 0;
  color: #f0a5b9;
  font-size: 14px;
  font-weight: 800;
}

.my-submission-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
  margin-top: 24px;
}

.my-submission-item {
  display: grid;
  grid-template-columns: 94px minmax(0, 1fr);
  gap: 14px;
  min-height: 104px;
  overflow: hidden;
  background: #252229;
  border: 1px solid var(--line);
}

.my-submission-item img {
  width: 94px;
  height: 104px;
  object-fit: cover;
}

.my-submission-copy {
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 10px 12px 10px 0;
}

.my-submission-copy strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.my-submission-copy span,
.my-submission-copy small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.my-submission-copy .submission-state {
  color: #f4a9bd;
  font-size: 13px;
  font-weight: 850;
}

.my-submission-copy .submission-state.approved {
  color: #91cfbe;
}

.my-submission-copy .submission-state.rejected {
  color: #efadba;
}

.town-gallery-section {
  width: min(1440px, calc(100% - 64px));
  padding: 48px 0 76px;
}

.gallery-status {
  min-height: 24px;
  margin-top: 14px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 14px;
}

.gallery-grid.is-pair {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.gallery-grid.is-single {
  grid-template-columns: 1fr;
}

.gallery-card {
  display: grid;
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  background: #252229;
  border: 1px solid var(--line);
  border-radius: 0;
  box-shadow: 0 12px 30px rgba(6, 5, 8, 0.16);
}

.gallery-card-media {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  padding: 0;
  overflow: hidden;
  background: #1b191e;
  border: 0;
}

.gallery-card-media::after {
  position: absolute;
  inset: auto 0 0;
  height: 36%;
  content: "";
  background: linear-gradient(transparent, rgba(12, 10, 14, 0.45));
  pointer-events: none;
}

.gallery-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 260ms ease;
}

.gallery-card:hover .gallery-card-media img,
.gallery-card:focus-within .gallery-card-media img {
  transform: scale(1.035);
}

.gallery-card-copy {
  display: grid;
  gap: 8px;
  padding: 19px 20px 21px;
}

.gallery-card-copy h3 {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-family: "Noto Serif TC", "PMingLiU", serif;
  font-size: 22px;
  line-height: 1.3;
}

.gallery-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  color: #f0a5b9;
  font-size: 13px;
  font-weight: 800;
}

.gallery-card-copy p {
  display: -webkit-box;
  margin: 1px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 16px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.gallery-grid.is-single .gallery-card {
  grid-template-columns: minmax(0, 1.8fr) minmax(300px, 0.7fr);
}

.gallery-grid.is-single .gallery-card-media {
  min-height: 400px;
  aspect-ratio: 16 / 9;
}

.gallery-grid.is-single .gallery-card-copy {
  align-content: center;
  padding: clamp(28px, 4vw, 54px);
}

.gallery-grid.is-single .gallery-card-copy h3 {
  font-size: clamp(28px, 3vw, 40px);
}

.gallery-grid.is-single .gallery-card-copy p {
  -webkit-line-clamp: 6;
}

.gallery-grid.has-wide-feature .gallery-card:first-child {
  grid-column: span 2;
  grid-template-columns: minmax(0, 1.45fr) minmax(250px, 0.7fr);
}

.gallery-grid.has-wide-feature .gallery-card:first-child .gallery-card-copy {
  align-content: center;
  padding: 28px;
}

.gallery-grid.has-wide-feature .gallery-card:first-child .gallery-card-copy h3 {
  font-size: 30px;
}

.gallery-empty {
  display: grid;
  place-items: center;
  min-height: 260px;
  padding: 32px;
  color: var(--muted);
  text-align: center;
  background: #252229;
  border: 1px dashed #635963;
}

.gallery-empty strong {
  color: var(--ink);
  font-family: "Noto Serif TC", "PMingLiU", serif;
  font-size: 23px;
}

.gallery-empty span {
  margin-top: 8px;
  font-size: 15px;
}

.gallery-load-more {
  display: block;
  min-width: 180px;
  margin: 26px auto 0;
}

.submission-dialog,
.image-dialog {
  width: min(660px, calc(100% - 32px));
  max-height: min(860px, calc(100dvh - 32px));
  padding: 0;
  overflow: auto;
  color: var(--ink);
  background: #252229;
  border: 1px solid #665a65;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.56);
}

.submission-dialog::backdrop,
.image-dialog::backdrop {
  background: rgba(8, 7, 10, 0.76);
}

.submission-form {
  padding: 30px;
}

.submission-dialog-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
}

.submission-dialog-header h2 {
  margin: 0;
  color: var(--ink);
  font-family: "Noto Serif TC", "PMingLiU", serif;
  font-size: 30px;
}

.dialog-close {
  display: grid;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  place-items: center;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 1px solid #665a65;
  border-radius: 4px;
  font-size: 30px;
  line-height: 1;
}

.dialog-close:hover,
.dialog-close:focus-visible {
  background: #352e36;
}

.submission-intro {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.submission-fields {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

.submission-fields > label:not(.submission-file-field) {
  display: grid;
  gap: 6px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
}

.submission-fields label > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.submission-fields input[type="text"],
.submission-fields textarea {
  width: 100%;
  color: var(--ink);
  background: #1d1b20;
  border: 1px solid #5b515a;
  border-radius: 4px;
  font: inherit;
  font-size: 16px;
}

.submission-fields input[type="text"] {
  min-height: 45px;
  padding: 9px 12px;
}

.submission-fields textarea {
  min-height: 108px;
  padding: 10px 12px;
  resize: vertical;
}

.submission-fields input[type="text"]:focus,
.submission-fields textarea:focus {
  border-color: #e68da5;
  outline: 2px solid rgba(230, 141, 165, 0.2);
}

.submission-file-field {
  position: relative;
  display: block;
  min-height: 198px;
  overflow: hidden;
  cursor: pointer;
  background: #1d1b20;
  border: 1px dashed #796b76;
}

.submission-file-field input {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  cursor: pointer;
  opacity: 0;
}

.submission-preview {
  display: grid;
  width: 100%;
  min-height: 198px;
  place-content: center;
  gap: 7px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
  background-position: center;
  background-size: cover;
}

.submission-preview.has-image {
  color: #fff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.9);
  box-shadow: inset 0 0 0 999px rgba(15, 11, 16, 0.36);
}

.submission-preview b {
  color: var(--ink);
  font-size: 18px;
}

.submission-preview.has-image b,
.submission-preview.has-image small {
  color: #fff;
}

.submission-preview small {
  font-size: 13px;
}

.submission-rules {
  display: flex;
  gap: 10px;
  align-items: start;
  margin-top: 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.submission-rules input {
  width: 18px;
  height: 18px;
  margin: 3px 0 0;
  accent-color: #d86f8d;
}

.submission-rules a {
  color: #f0a5b9;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.submission-status {
  min-height: 24px;
  margin-top: 16px;
}

.submission-status.error,
.gallery-login-status.error,
.gallery-status.error {
  color: #f3a3b3;
}

.submission-status.success,
.gallery-login-status.success {
  color: #9bd8c8;
}

.submission-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.submission-actions .button {
  min-width: 128px;
  justify-content: center;
}

.submission-actions .button:disabled,
.gallery-load-more:disabled,
.gallery-refresh-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.image-dialog {
  width: min(1100px, calc(100% - 32px));
  background: #18161b;
}

.image-dialog > img {
  display: block;
  width: 100%;
  max-height: calc(100dvh - 170px);
  object-fit: contain;
  background: #0f0e12;
}

.image-dialog > div {
  display: grid;
  gap: 3px;
  padding: 15px 18px 18px;
}

.image-dialog > div strong {
  color: #fff9fc;
  font-family: "Noto Serif TC", "PMingLiU", serif;
  font-size: 21px;
}

.image-dialog > div span {
  color: #cbbec5;
  font-size: 14px;
}

.image-dialog-close {
  position: absolute;
  top: 13px;
  right: 13px;
  z-index: 2;
  color: #fff;
  background: rgba(17, 14, 19, 0.72);
}

@media (max-width: 1120px) {
  .gallery-account-shell {
    grid-template-columns: 1fr;
  }

  .gallery-account-user,
  .gallery-account-guest {
    justify-content: flex-start;
  }

  .gallery-account-user > div {
    margin-right: 0;
  }

  .gallery-admin-link {
    margin-left: auto;
  }

  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .gallery-grid.is-single .gallery-card {
    grid-template-columns: minmax(0, 1.45fr) minmax(260px, 0.75fr);
  }

  .gallery-grid.is-single .gallery-card-media {
    min-height: 330px;
  }

  .gallery-grid.has-wide-feature .gallery-card:first-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .gallery-hero {
    min-height: 550px;
  }

  .gallery-hero > img {
    object-position: 62% 50%;
  }

  .gallery-hero-shade {
    background: linear-gradient(90deg, rgba(17, 15, 21, 0.8), rgba(20, 17, 23, 0.4));
  }

  .gallery-hero-content,
  .gallery-account-section,
  .gallery-guidelines,
  .my-submissions-section,
  .town-gallery-section {
    width: min(var(--max-width), calc(100% - 32px));
  }

  .gallery-hero-content {
    padding-top: calc(var(--header-height) + 72px);
    padding-bottom: 60px;
  }

  .gallery-hero-content > span {
    font-size: 17px;
  }

  .gallery-hero-actions .button {
    width: 100%;
  }

  .gallery-account-section {
    padding-bottom: 58px;
  }

  .gallery-account-shell {
    gap: 20px;
    padding: 24px 20px;
  }

  .gallery-account-copy h2,
  .gallery-section-heading h2 {
    font-size: 29px;
  }

  .gallery-account-user {
    align-items: start;
    flex-wrap: wrap;
  }

  .gallery-account-guest {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .gallery-account-guest > span {
    max-width: none;
  }

  .gallery-account-guest .gallery-login-button {
    width: 100%;
    text-align: center;
  }

  .gallery-account-user > div {
    min-width: calc(100% - 62px);
  }

  .gallery-admin-link {
    margin-left: 0;
  }

  .gallery-guidelines {
    padding-top: 58px;
    padding-bottom: 60px;
  }

  .gallery-guideline-grid,
  .gallery-grid {
    grid-template-columns: 1fr;
  }

  .gallery-grid.is-single .gallery-card {
    grid-template-columns: 1fr;
  }

  .gallery-grid.is-single .gallery-card-media {
    min-height: 0;
  }

  .gallery-grid.is-single .gallery-card-copy {
    padding: 20px;
  }

  .gallery-grid.is-single .gallery-card-copy h3 {
    font-size: 24px;
  }

  .gallery-grid.has-wide-feature .gallery-card:first-child {
    grid-template-columns: 1fr;
  }

  .gallery-grid.has-wide-feature .gallery-card:first-child .gallery-card-copy {
    padding: 20px;
  }

  .gallery-grid.has-wide-feature .gallery-card:first-child .gallery-card-copy h3 {
    font-size: 24px;
  }

  .gallery-guideline-grid article {
    min-height: 0;
  }

  .gallery-section-heading-compact,
  .gallery-section-heading-with-action {
    display: grid;
    align-items: start;
  }

  .town-gallery-section .gallery-section-heading-with-action {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
  }

  .gallery-refresh-button {
    justify-self: start;
  }

  .town-gallery-section {
    width: min(var(--max-width), calc(100% - 32px));
    padding-top: 44px;
    padding-bottom: 64px;
  }

  .submission-form {
    padding: 24px 18px;
  }

  .submission-dialog-header h2 {
    font-size: 26px;
  }

  .submission-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .submission-actions .button {
    min-width: 0;
  }
}

@media (orientation: landscape) and (max-height: 560px) and (max-width: 1120px) {
  .gallery-hero {
    min-height: 450px;
  }

  .gallery-hero-content {
    padding-top: calc(var(--header-height) + 40px);
    padding-bottom: 38px;
  }

  .gallery-hero-content h1 {
    font-size: 46px;
  }

  .gallery-account-section {
    padding-bottom: 46px;
  }
}
