:root {
  color-scheme: light;
  --ink: #000;
  --muted: #8e8e93;
  --bar: rgba(255, 255, 255, 0.86);
  --line: rgba(60, 60, 67, 0.16);
  --fill: #f2f2f7;
  --blue: #007aff;
  --bar-h: calc(52px + env(safe-area-inset-top));
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: #fff;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.35;
}

button, a { font: inherit; color: inherit; }

button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}

img { display: block; max-width: 100%; }

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: #000;
  color: #fff;
  padding: 8px 12px;
  z-index: 30;
}

.skip:focus { top: 12px; }

.loading, .empty {
  margin: 0;
  padding: 28vh 24px 24px;
  text-align: center;
  color: var(--muted);
}

.empty h1 {
  margin: 0 0 8px;
  color: #000;
  font-size: 28px;
  letter-spacing: -0.03em;
}

.empty p { margin: 0 auto; max-width: 28rem; }

.bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--bar-h);
  padding: env(safe-area-inset-top) 16px 0;
  background: var(--bar);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--line);
}

.bar-title, .back {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.02em;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.back { color: var(--blue); font-weight: 500; }

.bar-folder {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.segment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-width: 168px;
  padding: 2px;
  border-radius: 9px;
  background: var(--fill);
}

.segment button {
  min-height: 32px;
  border-radius: 7px;
  color: #000;
  font-size: 13px;
  font-weight: 600;
}

.segment button[aria-selected="true"] {
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
}

.intro {
  padding: 14px 16px 10px;
}

.brand {
  margin: 0 0 2px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.brand a { text-decoration: none; }

.brand a:hover { color: #000; }

.intro h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-weight: 700;
}

.note {
  margin: 0;
  padding: 0 16px 8px;
  color: var(--muted);
  font-size: 13px;
}

.section h2 {
  position: sticky;
  top: var(--bar-h);
  z-index: 2;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 16px 16px 8px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  font-size: 22px;
  letter-spacing: -0.03em;
}

.section h2 span, .count {
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px;
  background: #fff;
}

.thumb {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--fill);
  -webkit-tap-highlight-color: transparent;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
}

.thumb:active img { opacity: 0.72; }

.thumb:focus-visible,
.album-card:focus-visible,
.bar-title:focus-visible,
.back:focus-visible,
.segment button:focus-visible,
.icon-btn:focus-visible,
.nav:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}

.thumb.is-broken::after {
  content: "Can’t show";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

.thumb.is-broken img { visibility: hidden; }

.albums {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px 14px;
  padding: 8px 16px calc(28px + env(safe-area-inset-bottom));
}

.album-card { text-align: left; }

.cover {
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 8px;
  background: var(--fill);
}

.cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.album-card strong {
  display: block;
  margin-top: 7px;
  font-size: 16px;
  font-weight: 600;
}

.album-card .count { display: block; margin-top: 1px; font-size: 13px; }

.retry {
  margin-top: 16px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 10px;
  background: var(--fill);
  font-weight: 600;
}

.viewer {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: #000;
  color: #fff;
  color-scheme: dark;
  touch-action: none;
}

.viewer[hidden] { display: none !important; }

.stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.stage img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
}

.stage img.is-loading { opacity: 0.35; }

.viewer-bar, .viewer-caption {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  pointer-events: none;
}

.viewer-bar {
  top: 0;
  padding-top: calc(8px + env(safe-area-inset-top));
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.55), transparent);
}

.viewer-caption {
  bottom: 0;
  display: block;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(0, 0, 0, 0.55), transparent);
  text-align: center;
}

.viewer-caption p { margin: 0; }

.viewer-caption #viewer-title {
  font-size: 16px;
  font-weight: 600;
}

.viewer-caption #viewer-sub {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
}

.viewer-count {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.bar-side { width: 44px; }

.icon-btn, .nav { pointer-events: auto; }

.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: #fff;
  border-radius: 999px;
}

.nav {
  position: absolute;
  top: 50%;
  z-index: 3;
  width: 44px;
  height: 72px;
  margin-top: -36px;
  display: grid;
  place-items: center;
  color: #fff;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.16);
}

.nav:disabled { opacity: 0.28; }

.nav.prev { left: max(8px, env(safe-area-inset-left)); }
.nav.next { right: max(8px, env(safe-area-inset-right)); }

html.is-viewing,
html.is-viewing body { background: #000; }

@media (min-width: 700px) {
  .intro, .note, .section h2 { padding-left: 28px; padding-right: 28px; }
  .bar { padding-left: 28px; padding-right: 28px; }
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .albums {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    padding-left: 28px;
    padding-right: 28px;
  }
}

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

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

@media (max-width: 699px) {
  .nav { width: 34px; height: 56px; margin-top: -28px; background: rgba(255, 255, 255, 0.1); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
