:root {
  color-scheme: light;
  --bg: #f5f2ec;
  --bg-elevated: rgba(255, 255, 255, 0.72);
  --surface: #fffdf9;
  --surface-strong: #ffffff;
  --text: #171916;
  --text-soft: #656860;
  --text-faint: #92958e;
  --line: rgba(30, 34, 29, 0.11);
  --line-strong: rgba(30, 34, 29, 0.18);
  --accent: #345a44;
  --accent-strong: #234b35;
  --accent-soft: #dfe9df;
  --shadow: 0 18px 55px rgba(43, 47, 40, 0.11);
  --shadow-soft: 0 10px 30px rgba(43, 47, 40, 0.08);
  --header-height: 76px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --page-width: 1560px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111311;
  --bg-elevated: rgba(23, 26, 23, 0.72);
  --surface: #191c19;
  --surface-strong: #202420;
  --text: #f1f2ee;
  --text-soft: #b0b5ad;
  --text-faint: #7e857c;
  --line: rgba(238, 243, 235, 0.1);
  --line-strong: rgba(238, 243, 235, 0.18);
  --accent: #9dc6a7;
  --accent-strong: #b9ddbF;
  --accent-soft: #253b2c;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.34);
  --shadow-soft: 0 12px 35px rgba(0, 0, 0, 0.25);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 8% -10%, rgba(124, 163, 135, 0.16), transparent 32rem),
    radial-gradient(circle at 96% 16%, rgba(211, 183, 141, 0.16), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select {
  font: inherit;
}

button,
a,
input,
select {
  -webkit-tap-highlight-color: transparent;
}

button,
a {
  color: inherit;
}

button {
  border: 0;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ambient {
  position: fixed;
  z-index: -1;
  width: 34rem;
  height: 34rem;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(70px);
  opacity: 0.2;
}

.ambient-one {
  top: 16vh;
  left: -20rem;
  background: #8ab69a;
}

.ambient-two {
  right: -21rem;
  bottom: 8vh;
  background: #d8b98b;
}

.site-header {
  position: sticky;
  z-index: 100;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: max(12px, env(safe-area-inset-top)) max(22px, calc((100vw - var(--page-width)) / 2 + 28px)) 12px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-elevated) 90%, transparent);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  color: var(--text);
  font-size: 17px;
  font-weight: 720;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  color: var(--accent-strong);
}

.brand-mark svg {
  width: 23px;
  height: 23px;
}

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

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  cursor: pointer;
  text-decoration: none;
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.button:hover,
.icon-button:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-soft);
}

.button:active,
.icon-button:active {
  transform: translateY(0) scale(0.98);
}

.button:focus-visible,
.icon-button:focus-visible,
.search-box:focus-within,
.album-chip:focus-visible,
.sort-control:focus-within,
footer button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 42%, transparent);
  outline-offset: 3px;
}

.button {
  min-height: 43px;
  gap: 8px;
  padding: 0 16px;
  border-radius: 13px;
  font-size: 14px;
  font-weight: 680;
}

.button svg {
  width: 19px;
  height: 19px;
}

.button-primary {
  border-color: transparent;
  background: var(--accent-strong);
  color: #ffffff;
  box-shadow: 0 9px 24px color-mix(in srgb, var(--accent-strong) 24%, transparent);
}

html[data-theme="dark"] .button-primary {
  color: #142019;
}

.button-primary:hover {
  border-color: transparent;
  background: var(--accent);
}

.icon-button {
  width: 43px;
  height: 43px;
  padding: 0;
  border-radius: 13px;
  background: var(--surface);
  color: var(--text-soft);
}

.icon-button svg {
  width: 20px;
  height: 20px;
}

.icon-button.is-spinning svg {
  animation: spin 0.85s linear infinite;
}

.theme-moon,
html[data-theme="dark"] .theme-sun {
  display: none;
}

html[data-theme="dark"] .theme-moon {
  display: block;
}

main {
  width: min(var(--page-width), calc(100% - 56px));
  margin: 0 auto;
}

.hero {
  display: grid;
  max-width: 840px;
  padding: clamp(72px, 9vw, 126px) 0 clamp(48px, 6vw, 82px);
}

.eyebrow {
  margin: 0 0 18px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.2em;
}

.hero h1 {
  max-width: 760px;
  margin: 0;
  font-family: ui-serif, "Songti SC", "Noto Serif CJK SC", Georgia, serif;
  font-size: clamp(42px, 6.7vw, 88px);
  font-weight: 650;
  letter-spacing: -0.055em;
  line-height: 1.05;
}

.hero-copy {
  max-width: 670px;
  margin: 27px 0 0;
  color: var(--text-soft);
  font-size: clamp(16px, 1.6vw, 19px);
  line-height: 1.8;
}

.hero-stats {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
  color: var(--text-soft);
  font-size: 14px;
}

.hero-stats strong {
  color: var(--text);
  font-size: 17px;
}

.stat-divider {
  width: 1px;
  height: 17px;
  background: var(--line-strong);
}

.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-left: 4px;
  color: var(--text-faint);
}

.sync-status i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d6a24b;
  box-shadow: 0 0 0 4px rgba(214, 162, 75, 0.13);
}

.sync-status.is-ready i {
  background: #4f9b67;
  box-shadow: 0 0 0 4px rgba(79, 155, 103, 0.13);
}

.sync-status.is-error i {
  background: #c85f59;
  box-shadow: 0 0 0 4px rgba(200, 95, 89, 0.13);
}

.toolbar {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(220px, 330px) minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(20px) saturate(135%);
  -webkit-backdrop-filter: blur(20px) saturate(135%);
}

.search-box {
  display: flex;
  align-items: center;
  height: 46px;
  gap: 10px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  color: var(--text-faint);
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.search-box svg {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
}

.search-box input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.search-box input::placeholder {
  color: var(--text-faint);
}

.search-box kbd {
  min-width: 24px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-bottom-color: var(--line-strong);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text-faint);
  font-family: inherit;
  font-size: 12px;
  text-align: center;
}

.album-chips {
  display: flex;
  min-width: 0;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.album-chips::-webkit-scrollbar {
  display: none;
}

.album-chip {
  min-height: 38px;
  flex: 0 0 auto;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
  transition: color 180ms ease, background 180ms ease, border-color 180ms ease;
}

.album-chip:hover {
  color: var(--text);
  background: var(--surface);
}

.album-chip.is-active {
  border-color: color-mix(in srgb, var(--accent) 22%, transparent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.sort-control {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 126px;
  height: 43px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  color: var(--text-soft);
}

.sort-control select {
  width: 100%;
  height: 100%;
  padding: 0 35px 0 13px;
  appearance: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
}

.sort-control svg {
  position: absolute;
  right: 10px;
  width: 18px;
  height: 18px;
  pointer-events: none;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 245px), 1fr));
  grid-auto-rows: 8px;
  gap: 18px;
  min-height: 20vh;
}

.photo-card {
  position: relative;
  display: block;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(33, 37, 32, 0.055);
  color: inherit;
  text-decoration: none;
  transform: translateY(12px);
  opacity: 0;
  animation: card-in 560ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
  transition: transform 240ms ease, box-shadow 240ms ease, border-color 240ms ease;
}

.photo-card:hover {
  z-index: 2;
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
  transform: translateY(-4px);
}

.photo-card:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 48%, transparent);
  outline-offset: 4px;
}

.photo-frame {
  position: relative;
  overflow: hidden;
  aspect-ratio: var(--photo-ratio, 4 / 3);
  background:
    linear-gradient(110deg, transparent 25%, color-mix(in srgb, var(--surface-strong) 72%, transparent) 42%, transparent 58%) 0 0 / 240% 100%,
    color-mix(in srgb, var(--line) 55%, var(--surface));
}

.photo-frame::after {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  background: linear-gradient(to top, rgba(8, 10, 8, 0.25), transparent 42%);
  opacity: 0;
  transition: opacity 240ms ease;
}

.photo-card:hover .photo-frame::after {
  opacity: 1;
}

.photo-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.015);
  transition: opacity 420ms ease, transform 650ms cubic-bezier(0.22, 1, 0.36, 1);
}

.photo-frame img.is-loaded {
  opacity: 1;
}

.photo-card:hover .photo-frame img {
  transform: scale(1.045);
}

.photo-open-hint {
  position: absolute;
  z-index: 2;
  right: 12px;
  bottom: 12px;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 12px;
  background: rgba(10, 12, 10, 0.42);
  color: #fff;
  opacity: 0;
  transform: translateY(6px);
  backdrop-filter: blur(8px);
  transition: opacity 220ms ease, transform 220ms ease;
}

.photo-open-hint svg {
  width: 18px;
  height: 18px;
}

.photo-card:hover .photo-open-hint,
.photo-card:focus-visible .photo-open-hint {
  opacity: 1;
  transform: translateY(0);
}

.photo-meta {
  display: grid;
  gap: 5px;
  padding: 14px 15px 15px;
}

.photo-title {
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 680;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-subtitle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--text-faint);
  font-size: 12px;
}

.photo-album {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-date {
  flex: 0 0 auto;
}

.state-card {
  display: grid;
  min-height: 310px;
  margin: 36px 0 80px;
  padding: 54px 24px;
  place-items: center;
  align-content: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 68%, transparent);
  color: var(--text-soft);
  text-align: center;
}

.state-card h2 {
  margin: 18px 0 8px;
  color: var(--text);
  font-family: ui-serif, "Songti SC", Georgia, serif;
  font-size: 25px;
}

.state-card p {
  max-width: 540px;
  margin: 0 0 24px;
  line-height: 1.75;
}

.state-card code {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.loader {
  width: 38px;
  height: 38px;
  border: 3px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

.empty-icon {
  width: 74px;
  color: var(--accent);
  opacity: 0.84;
}

.empty-icon svg {
  display: block;
  width: 100%;
}

.load-sentinel {
  height: 1px;
}

footer {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 100px;
  padding: 28px;
  color: var(--text-faint);
  font-size: 13px;
}

footer button {
  padding: 2px 0;
  border-bottom: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
}

.toast {
  position: fixed;
  z-index: 10000;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 14px;
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.pswp {
  --pswp-bg: rgba(9, 11, 9, 0.96);
  --pswp-placeholder-bg: #171a17;
}

.pswp__button {
  transition: opacity 180ms ease, transform 180ms ease;
}

.pswp__button:hover {
  transform: scale(1.05);
}

.pswp__custom-caption {
  position: absolute;
  z-index: 10;
  bottom: max(22px, env(safe-area-inset-bottom));
  left: 50%;
  display: grid;
  min-width: min(520px, calc(100vw - 36px));
  max-width: min(760px, calc(100vw - 36px));
  gap: 5px;
  padding: 12px 18px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background: rgba(13, 15, 13, 0.58);
  color: #fff;
  text-align: center;
  transform: translateX(-50%);
  backdrop-filter: blur(14px);
  pointer-events: none;
}

.pswp__custom-caption strong {
  overflow: hidden;
  font-size: 15px;
  font-weight: 680;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pswp__custom-caption span {
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
}

@keyframes card-in {
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 980px) {
  .toolbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .album-chips {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

@media (max-width: 720px) {
  :root {
    --header-height: 68px;
  }

  .site-header {
    padding-right: 16px;
    padding-left: 16px;
  }

  .brand {
    font-size: 15px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .header-actions {
    gap: 7px;
  }

  .header-actions .button {
    width: 42px;
    padding: 0;
  }

  .header-actions .button span {
    display: none;
  }

  .icon-button,
  .header-actions .button {
    width: 40px;
    height: 40px;
    min-height: 40px;
    border-radius: 12px;
  }

  main {
    width: min(100% - 28px, var(--page-width));
  }

  .hero {
    padding-top: 62px;
    padding-bottom: 42px;
  }

  .hero h1 {
    font-size: clamp(42px, 13.4vw, 68px);
  }

  .hero-copy {
    margin-top: 21px;
    font-size: 15px;
  }

  .hero-stats {
    margin-top: 24px;
  }

  .sync-status {
    width: 100%;
    margin: 2px 0 0;
  }

  .toolbar {
    grid-template-columns: minmax(0, 1fr) 44px;
    gap: 10px;
    margin-bottom: 16px;
    padding: 10px;
    border-radius: 16px;
  }

  .sort-control {
    min-width: 44px;
    width: 44px;
  }

  .sort-control select {
    position: absolute;
    inset: 0;
    padding: 0;
    opacity: 0;
  }

  .sort-control svg {
    right: 12px;
  }

  .album-chips {
    margin: 0 -2px;
  }

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

  .photo-card {
    border-radius: 14px;
  }

  .photo-meta {
    padding: 11px 11px 12px;
  }

  .photo-title {
    font-size: 13px;
  }

  .photo-subtitle {
    font-size: 11px;
  }

  .photo-date {
    display: none;
  }

  .photo-open-hint {
    right: 8px;
    bottom: 8px;
    width: 32px;
    height: 32px;
    opacity: 0.9;
    transform: none;
  }

  .state-card {
    min-height: 280px;
    margin-top: 22px;
    padding: 38px 20px;
  }
}

@media (max-width: 390px) {
  .gallery {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .photo-date {
    display: block;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
