:root {
  --bg: #0f0f10;
  --bg-elevated: #18181b;
  --bg-hover: #27272a;
  --fg: #e4e4e7;
  --fg-secondary: #a1a1aa;
  --muted: #71717a;
  --border: #27272a;
  --card: #18181b;
  --shadow: 0 1px 4px rgba(0,0,0,0.4);
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --danger: #ef4444;
  --success: #22c55e;
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK KR", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* The header and the breadcrumb share one sticky wrapper: with infinite
   scroll an album can be dozens of screens tall, and the path back to the
   parent album has to stay reachable without scrolling up first. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
}

header.top {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Also sticky on its own: if a browser still has the previous stylesheet
     cached (assets are max-age=3600) the header keeps its old pinned
     behaviour instead of scrolling away with the new markup. */
  position: sticky;
  top: 0;
  z-index: 10;
}

header.top h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

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

.lang-switch {
  display: flex;
  gap: 4px;
}

.lang-switch button {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--fg-secondary);
}

.lang-switch button:hover {
  background: var(--bg-hover);
}

.lang-switch button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

.breadcrumb {
  padding: 7px 24px;
  font-size: 13px;
  color: var(--muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}

/* The home page has no path: an empty bar would just eat sticky space. */
.breadcrumb:empty { display: none; }

.breadcrumb::-webkit-scrollbar { display: none; }

.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--accent); }

.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}

.album-card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
  cursor: pointer;
  display: block;
  color: inherit;
  border: 1px solid var(--border);
}

.album-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  text-decoration: none;
  border-color: var(--accent);
}

.album-card.folder .cover {
  background:
    linear-gradient(135deg, rgba(59,130,246,0.15), rgba(59,130,246,0.02)),
    var(--bg-hover);
}

.album-card .cover {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--bg-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

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

.album-card .cover .placeholder {
  color: var(--muted);
  font-size: 14px;
}

.album-card .meta {
  padding: 12px 14px;
}

.album-card .meta h3 {
  margin: 0 0 4px 0;
  font-size: 15px;
  font-weight: 600;
  word-break: break-word;
}

.album-card .meta .count {
  font-size: 13px;
  color: var(--muted);
}

.album-card .meta .desc {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}

.photo-grid a {
  display: block;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 6px;
  background: var(--bg-hover);
  position: relative;
}

.photo-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s;
}

.photo-grid a:hover img { transform: scale(1.05); }

/* Page-numbered pager under the photo grid. Real <a href> links (not JS
   handlers) so the page lives in the URL and can be shared/bookmarked, and the
   browser back button works without extra state. */
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 24px 0 8px;
}

.pager[hidden] { display: none; }

.pager a,
.pager .pager-num,
.pager .pager-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-elevated);
  color: var(--fg-secondary);
  font-size: 14px;
  line-height: 1;
  text-decoration: none;
}

.pager a:hover {
  color: var(--fg);
  border-color: var(--accent);
  text-decoration: none;
}

.pager .pager-num.current {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.pager .pager-step.disabled {
  opacity: 0.4;
}

.pager .pager-gap {
  min-width: 18px;
  text-align: center;
  color: var(--muted);
}

/* Back-to-top: shown once the page is taller than one viewport, which on an
   album with hundreds of photos is always. Sits below the lightbox
   (z-index 100000) so it never floats over a zoomed photo. */
.to-top {
  position: fixed;
  right: 20px;
  bottom: 24px;
  z-index: 50;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg-elevated);
  color: var(--fg-secondary);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, transform 0.15s;
}

.to-top[hidden] { display: none; }

.to-top:hover {
  color: var(--fg);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.to-top svg { width: 18px; height: 18px; }

button.primary {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 6px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
}

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

button.secondary {
  background: var(--bg-elevated);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
}

button.secondary:hover { background: var(--bg-hover); }

button.danger {
  background: var(--danger);
  color: #fff;
  border: 0;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
}

.empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--muted);
}

.hint {
  margin-top: 20px;
  padding: 12px 16px;
  background: #1f1d12;
  border-radius: 6px;
  font-size: 13px;
  color: #d4b94a;
  line-height: 1.8;
  border: 1px solid #3a3520;
}

@media (max-width: 600px) {
  main { padding: 12px; }
  .album-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 4px; }
  header.top { padding: 10px 14px; }
  header.top h1 { font-size: 16px; }
  .breadcrumb { padding: 6px 12px; font-size: 12px; }
  .to-top { right: 12px; bottom: 16px; width: 38px; height: 38px; }
  .pager { gap: 4px; padding: 18px 0 8px; }
  .pager a, .pager .pager-num, .pager .pager-step { min-width: 32px; height: 32px; padding: 0 8px; font-size: 13px; }
}
