#explore, #memoryStars {
  position: absolute;
  inset: 0;
  touch-action: none;
}

#memoryStars { pointer-events: none; }

.memory-star {
  --star-size: .85;
  position: absolute;
  top: 0;
  left: 0;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
  mix-blend-mode: screen;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.memory-star:disabled { pointer-events: none; }

.memory-star:first-child { --star-size: 1.08; }
.memory-star:nth-child(2) { --star-size: .94; }

.memory-star::before, .memory-star::after {
  content: '';
  position: absolute;
  pointer-events: none;
}

.memory-star::before {
  inset: -11px;
  background: radial-gradient(circle closest-side, #f1f9ffed 0%, #c3e1ffb0 9%,
    #9dcbff62 22%, #81b0ff30 41%, #7398fb13 62%, #7294ec06 82%, transparent 100%);
  opacity: .84;
  animation: breathe-memory 4.2s ease-in-out infinite;
  transition: filter 180ms ease;
}

.memory-star:nth-child(2)::before { animation-delay: -1.4s; }
.memory-star:nth-child(3)::before { animation-delay: -2.8s; }

.memory-star::after {
  inset: -10px;
  background:
    radial-gradient(circle at center, #fff 0 1.4px, #f4faff 2.2px, #d8ecffc2 3.2px, #b5d8ff45 5px, transparent 8px),
    radial-gradient(ellipse 21px .92px at center, #fff 0%, #eaf5ffda 16%, #cce4ff82 39%, #b3d4ff30 68%, transparent 100%),
    radial-gradient(ellipse 1.05px 27px at center, #fff 0%, #edf7ffe0 17%, #cbe4ff86 38%, #b2d2ff2b 71%, transparent 100%);
  transform: rotate(-11deg) scale(var(--star-size));
  transition: filter 180ms ease;
}

.memory-star:is(:hover, :focus-visible, :active)::before { filter: brightness(1.35); }
.memory-star:is(:hover, :focus-visible, :active)::after { filter: brightness(1.25); }
.memory-star.introduce::after { animation: announce-memory 1050ms ease-out; }

main:has(#memoryAlbum[open]) .memory-star::before { animation-play-state: paused; }

@keyframes breathe-memory {
  0%, 100% { transform: scale(.94); opacity: .67; }
  50% { transform: scale(1.07); opacity: 1; }
}

@keyframes announce-memory {
  40% { filter: brightness(1.5) drop-shadow(0 0 3px #b5dcffb3); }
}

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.album-control {
  appearance: none;
  min-height: 44px;
  padding: 0 15px;
  border: 1px solid #b99a6f6e;
  border-radius: 24px;
  background: #19151fe8;
  color: #eddfc8;
  cursor: pointer;
  font: 500 13px/1.3 system-ui, sans-serif;
  white-space: nowrap;
}

.album-control:hover:not(:disabled) { background: #342633; border-color: #d2b58a; }
.album-control:disabled { opacity: .48; cursor: default; }
.album-control:focus-visible, .memory-star:focus-visible, .memory-tile:focus-visible {
  outline: 2px solid #f3d6a0;
  outline-offset: 3px;
}

.memory-star:focus-visible { outline-color: #cce8ff; }

#openAlbum { background: #17131ce0; }
#openAlbum:hover { background: #342633; }
#viewHint { max-width: calc(100vw - 24px); width: max-content; text-align: center; }

#lightStar {
  position: absolute;
  top: max(4.5vh, env(safe-area-inset-top));
  right: max(5.6%, env(safe-area-inset-right));
}

#memoryAlbum {
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  border: 0;
  overflow: auto;
  background: transparent;
  color: #f0e4d2;
}

#memoryAlbum[open] { display: grid; }
#memoryAlbum::backdrop { background: #090711a8; }

.album-sheet {
  width: min(100%, 780px, max(360px, 93dvh));
  margin: auto;
  padding: clamp(12px, 2.5vw, 24px);
  border: 1px solid #a7836359;
  border-radius: 18px;
  background: linear-gradient(150deg, #1c1521f5, #100f18f5);
  box-shadow: 0 24px 90px #07040b85;
}

.album-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.album-heading h2 {
  margin: 0;
  font: 400 clamp(21px, 3vw, 29px)/1.2 "Songti SC", SimSun, serif;
  letter-spacing: .12em;
}

.album-icon {
  width: 44px;
  padding: 0;
  font: 400 23px/1 system-ui, sans-serif;
}

.memory-figure { margin: 0; }

#memoryFrame {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 3/2;
  max-height: 62dvh;
  border: 1px solid #ad8a6263;
  border-radius: 9px;
  overflow: hidden;
  background: #0d0c15;
  touch-action: pan-y;
}

#memoryImage, #memoryVideo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#memoryImage {
  user-select: none;
  pointer-events: none;
}

#memoryImageStatus {
  z-index: 1;
  padding: 7px 11px;
  border-radius: 5px;
  background: #15101c;
  color: #eadac3;
  font: 13px/1.4 system-ui, sans-serif;
}

#memoryDetails { margin: 11px 0 9px; }

#memoryDate:not([hidden]) {
  display: block;
  margin-bottom: 4px;
  color: #d3bda2;
  font: 13px/1.4 system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}

#memoryCaption {
  color: #f0dfc6;
  font-size: clamp(15px, 2vw, 19px);
  letter-spacing: .07em;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.memory-navigation { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
#memoryDownloads { display: flex; flex-wrap: wrap; gap: 5px 16px; margin: 3px 0 10px; }
.memory-download { color: #e8d2b3; font: 500 13px/1.4 system-ui, sans-serif; text-underline-offset: 4px; padding-block: 4px; }
#memoryConnection, #memoryFileHint, #memoryDateHint { margin: 0 0 4px; color: #d7c8b7; font: 13px/1.5 system-ui, sans-serif; }
#localMemories { margin-top: 14px; color: #d7c8b7; font: 13px/1.5 system-ui, sans-serif; }
#localMemories summary { cursor: pointer; }
#localMemoryIndex { display: flex; flex-wrap: wrap; gap: 7px; list-style: none; padding: 0; }
#memoryPosition { min-width: 3.1em; text-align: center; font: 13px/1 system-ui, sans-serif; color: #d3bda2; }
.memory-actions { display: flex; gap: 7px; margin-left: auto; }
#memoryEmpty { margin: 8px 0 15px; color: #d7c8b7; }

#memoryIndex {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.memory-tile {
  width: 100%;
  padding: 4px;
  border: 1px solid #a7836366;
  border-radius: 9px;
  background: #130f1a;
  color: #f0dfc6;
  text-align: left;
  cursor: pointer;
}

.memory-tile:hover { border-color: #d5b283; }

.memory-tile img {
  display: block;
  width: 100%;
  aspect-ratio: 3/2;
  border-radius: 5px;
  object-fit: cover;
  background: #0c0a12;
}

.memory-tile span {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  min-height: 42px;
  margin: 6px 4px 0;
  font: 13px/1.35 "Songti SC", SimSun, serif;
  overflow-wrap: anywhere;
}

#memoryFields { display: grid; gap: 9px; min-inline-size: 0; margin: 0; padding: 0; border: 0; }
#editorTitle { padding: 0 0 10px; color: #edddc6; font-size: 18px; }
#memoryFields label { color: #eadac5; font: 500 14px/1.4 system-ui, sans-serif; }
#memoryFields #memoryFilePreview {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: min(29dvh, 184px);
  padding: 9px;
  border: 1px dashed #aa8b74;
  border-radius: 10px;
  background: #0d0c15;
  cursor: pointer;
}
#memoryFilePreview:hover { border-color: #ebce9e; }
#memoryDraftImage, #memoryDraftVideo { width: 100%; height: min(28dvh, 210px); object-fit: contain; }
#memoryFileName { max-width: 100%; overflow-wrap: anywhere; color: #c7b4a6; font-size: 12px; text-align: center; }
.memory-date-field { display: flex; align-items: center; gap: 9px; }
.memory-date-field label { flex: none; }
#memoryNote, #memoryAnswer, #memoryDateInput {
  width: 100%; min-width: 0; padding: 10px; border: 1px solid #a7836380; border-radius: 9px;
  background: #0e0b15; color: #f0e4d2; font: 14px/1.5 system-ui, sans-serif;
}
#memoryDateInput { width: auto; min-width: 0; flex: 1; }
#memoryNote { resize: vertical; min-height: 74px; }
#memoryNote::placeholder { color: #aea097; }
#memoryNote:focus-visible, #memoryFile:focus-visible + #memoryFilePreview, #memoryAnswer:focus-visible, #memoryDateInput:focus-visible {
  outline: 2px solid #f3d6a0; outline-offset: 2px;
}
#memoryVerification:not([hidden]) { display: grid; gap: 12px; }
#memoryVerification label { color: #edddc6; font: 400 18px/1.4 "Songti SC", SimSun, serif; }
.memory-editor-actions { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; justify-content: flex-end; }
#deleteMemory { margin-right: auto; }
.album-control.memory-primary { background: #e2c298; border-color: #e2c298; color: #211623; }
.album-control.memory-primary:hover:not(:disabled) { background: #f1d5aa; color: #211623; }
.memory-danger { color: #ffc4c5; border-color: #c8757a80; }
#memoryEditorError, #memoryVerificationError, #confirmMemoryDeletion p { margin: 0; color: #ffc4c5; font: 13px/1.5 system-ui, sans-serif; }
#confirmMemoryDeletion { padding: 10px; border: 1px solid #c8757a80; border-radius: 9px; }
#confirmMemoryDeletion p { margin-bottom: 8px; }

@media (max-width: 520px) {
  #memoryIndex { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #viewHint { line-height: 1.45; }
  .controls { bottom: max(34px, calc(env(safe-area-inset-bottom) + 28px)); }
}

@media (prefers-reduced-motion: reduce) {
  .memory-star::before, .memory-star.introduce::after { animation: none; }
  .memory-star::before, .memory-star::after { transition: none; }
}
