.photo-note {
  margin: 22px 30px 0;
  padding: 13px 15px;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.photo-note strong {
  color: var(--text);
}

.photo-wrap {
  padding-top: 24px;
}

.photo-card .gallery-thumb {
  aspect-ratio: 1 / 1;
}

.photo-card {
  border: 0;
  padding: 0;
  background: transparent;
}

.photo-card:hover .gallery-thumb {
  border-color: var(--accent);
}

.photo-detail-actions {
  display: flex;
  justify-content: flex-end;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--line);
}

.photo-detail-dialog {
  width: min(1040px, calc(100vw - 30px));
}

@media (max-width: 900px) {
  .photo-note {
    margin: 18px 20px 0;
  }
}


.photo-tag-filter {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 16px 30px 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.photo-tag-filter > strong {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--muted);
}

.photo-tag-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.photo-tag-toggle {
  position: relative;
  cursor: pointer;
}

.photo-tag-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.photo-tag-toggle span {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  transition: .15s ease;
}

.photo-tag-toggle input:checked + span {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.photo-card .gallery-thumb {
  position: relative;
}

.photo-card-tag,
.photo-tag-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
}

.photo-card-tag {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 2;
  border: 1px solid rgba(255,255,255,.32);
  box-shadow: 0 3px 12px rgba(0,0,0,.18);
}

.photo-card-tag.photo,
.photo-tag-badge.photo {
  background: rgba(143,119,255,.92);
  color: #fff;
}

.photo-card-tag.drawing,
.photo-tag-badge.drawing {
  background: rgba(255,132,177,.94);
  color: #fff;
}

.photo-detail-meta {
  display: flex;
  align-items: center;
  padding: 12px 18px 0;
}

.photo-upload-tags {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.photo-upload-tags legend {
  grid-column: 1 / -1;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.photo-upload-tag-option {
  position: relative;
  cursor: pointer;
}

.photo-upload-tag-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.photo-upload-tag-option span {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  font-weight: 850;
  transition: .15s ease;
}

.photo-upload-tag-option input:checked + span {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 12%, transparent);
}

@media (max-width: 900px) {
  .photo-tag-filter {
    margin-left: 20px;
    margin-right: 20px;
  }
}

@media (max-width: 560px) {
  .photo-tag-filter {
    align-items: flex-start;
    flex-direction: column;
  }

  .photo-upload-tags {
    grid-template-columns: 1fr;
  }
}


.photo-card-tag.other,
.photo-tag-badge.other {
  background: rgba(105, 115, 132, .94);
  color: #fff;
}


/* Photo archive date and sorting */
.photo-sort-control {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 7px;
}

.photo-sort-control > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.photo-sort-control select {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 30px 0 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
  outline: none;
  cursor: pointer;
}

.photo-sort-control select:focus {
  border-color: var(--accent);
}

.photo-card-date {
  display: block;
  padding: 7px 8px 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-align: left;
}

.photo-detail-meta {
  gap: 8px;
  flex-wrap: wrap;
}

.photo-date-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  line-height: 1;
}

@media (max-width: 700px) {
  .photo-sort-control {
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
  }

  .photo-sort-control select {
    flex: 0 0 auto;
  }
}


/* Photo archive embed mode */
.photo-card-meta {
  display: grid;
  gap: 9px;
  padding: 9px 10px 10px;
}

.photo-card-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.photo-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.photo-embed-card {
  align-self: start;
}

.photo-embed-media {
  width: 100%;
}

.photo-original-link {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--accent);
  font-size: 10px;
  font-weight: 850;
  line-height: 1;
}

.photo-original-link:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

@media (max-width: 700px) {
  .photo-card-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .photo-card-actions .gallery-detail-button {
    width: 100%;
  }
}


.photo-detail-actions {
  gap: 8px;
  flex-wrap: wrap;
}

.photo-detail-actions > .secondary-button,
.photo-detail-actions > .danger-button {
  min-height: 38px;
}


/* Mobile single-column photo archive */
@media (max-width: 680px) {
  #photoGrid.gallery-grid {
    grid-template-columns: 1fr;
    gap: 22px;
  }

  #photoGrid .photo-card {
    width: 100%;
  }

  #photoGrid .photo-card .gallery-thumb {
    aspect-ratio: auto;
    min-height: 0;
    overflow: visible;
    background: var(--surface-2);
  }

  #photoGrid .photo-card .gallery-thumb img {
    width: 100%;
    height: auto;
    max-height: none;
    object-fit: contain;
    transform: none;
  }

  #photoGrid .photo-card:hover .gallery-thumb img {
    transform: none;
  }

  #photoGrid .photo-embed-media {
    min-height: 0;
    padding: 6px;
  }

  #photoGrid .photo-card-meta {
    padding: 10px 4px 2px;
  }

  .gallery-wrap {
    padding-left: 12px;
    padding-right: 12px;
  }
}


/* Photo thumbnail zoom + stable detail dialog position */
.photo-clickable-thumb {
  cursor: zoom-in;
  touch-action: manipulation;
}

.photo-clickable-thumb:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.photo-detail-dialog[open] {
  position: fixed;
  inset: 50% auto auto 50%;
  margin: 0;
  transform: translate(-50%, -50%);
  max-height: calc(100dvh - 30px);
}

@media (max-width: 680px) {
  .photo-detail-dialog[open] {
    width: calc(100vw - 18px);
    max-height: calc(100dvh - 18px);
  }
}
