:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --border: #e8e1d8;
  --text: #2b2724;
  --muted: #8a8178;
  --accent: #c2703d;
  --accent-soft: #f6e9df;
  --shadow: 0 1px 3px rgba(43, 39, 36, .08);
  --header-h: 112px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171614;
    --surface: #211f1c;
    --border: #322f2a;
    --text: #ece7e0;
    --muted: #938c83;
    --accent: #e09055;
    --accent-soft: #332520;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", sans-serif;
  -webkit-text-size-adjust: 100%;
}

header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.bar {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 14px 16px 10px;
  max-width: 1600px;
  margin: 0 auto;
}

h1 {
  font-size: 19px;
  margin: 0;
  letter-spacing: .02em;
}

.count {
  font-size: 13px;
  color: var(--muted);
  margin-right: auto;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 13px;
  transition: background .15s, border-color .15s;
}

button:hover { border-color: var(--accent); }

.years {
  display: flex;
  gap: 6px;
  padding: 0 16px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  max-width: 1600px;
  margin: 0 auto;
}

.years::-webkit-scrollbar { display: none; }

.years button {
  flex: 0 0 auto;
  padding: 4px 12px;
}

.years button.on {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

main {
  max-width: 1600px;
  margin: 0 auto;
  padding: 8px 16px 80px;
}

.month {
  margin-bottom: 34px;
  scroll-margin-top: calc(var(--header-h) + 8px);
}

.month > h2 {
  display: flex;
  align-items: baseline;
  gap: 9px;
  font-size: 16px;
  font-weight: 650;
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.month > h2 span {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
}

.daytag {
  position: absolute;
  top: 5px;
  left: 5px;
  z-index: 1;
  font-size: 11px;
  line-height: 1;
  color: #fff;
  background: rgba(20, 18, 16, .62);
  backdrop-filter: blur(3px);
  padding: 4px 7px;
  border-radius: 999px;
  pointer-events: none;
  letter-spacing: .02em;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 5px;
}

.grid figure {
  margin: 0;
  position: relative;
  aspect-ratio: 1;
  background: var(--surface);
  border-radius: 7px;
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: zoom-in;
}

.grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity .25s, transform .25s;
}

.grid img.ready { opacity: 1; }
.grid figure:hover img { transform: scale(1.04); }

@media (min-width: 700px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
}

.empty {
  text-align: center;
  padding: 70px 20px;
  color: var(--muted);
  line-height: 2;
}

.empty code {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 13px;
}

/* ---------- 放大檢視 ---------- */
#box {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #0b0a09;
  display: none;
  touch-action: pan-y;
  --strip-h: 84px;
}

#box.on { display: block; }

#box .stage {
  position: absolute;
  inset: 0 0 var(--strip-h) 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

#box img#boxImg {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 3px;
  user-select: none;
  -webkit-user-drag: none;
  opacity: 0;
  transition: opacity .18s ease;
  box-shadow: 0 10px 50px rgba(0, 0, 0, .7);
}

#box img#boxImg.ready { opacity: 1; }

/* 頂部資訊：浮在照片上，不佔版面 */
#box .hud {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 18px 40px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, .72), transparent);
  pointer-events: none;
  opacity: 1;
  transition: opacity .2s;
}

#box .hud > * { pointer-events: auto; }

#box .meta { min-width: 0; margin-right: auto; }

#box .dt {
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .02em;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .6);
}

#box .al {
  color: #c9c2ba;
  font-size: 12.5px;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .6);
}

#box .acts {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

#box .pos {
  color: #b5aea7;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  margin-right: 2px;
}

#box .acts a, #box .acts button {
  appearance: none;
  border: 0;
  background: rgba(255, 255, 255, .12);
  color: #f2ede7;
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 12.5px;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s;
}

#box .acts a:hover, #box .acts button:hover { background: rgba(255, 255, 255, .26); }
#box .acts button { padding: 6px 11px; font-size: 14px; }

/* 左右切換：整條感應區，箭頭平常很淡 */
#box .nav {
  position: absolute;
  top: 0;
  bottom: var(--strip-h);
  width: 16%;
  min-width: 68px;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 30px;
  line-height: 1;
  display: flex;
  align-items: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity .18s;
  padding: 0;
}

#box .prev { left: 0; justify-content: flex-start; padding-left: 20px; }
#box .next { right: 0; justify-content: flex-end; padding-right: 20px; }
#box:hover .nav { opacity: .55; }
#box .nav:hover { opacity: 1; }
#box .nav span {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(20, 18, 16, .55);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding-bottom: 3px;
}

#box .nav[disabled] { opacity: 0 !important; pointer-events: none; }

/* 底部縮圖條 */
#box .strip {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--strip-h);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  overflow-x: auto;
  overflow-y: hidden;
  background: rgba(0, 0, 0, .55);
  border-top: 1px solid rgba(255, 255, 255, .07);
  scrollbar-width: none;
}

#box .strip::-webkit-scrollbar { display: none; }

#box .strip img {
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 5px;
  cursor: pointer;
  opacity: .42;
  outline: 2px solid transparent;
  outline-offset: 2px;
  transition: opacity .15s, outline-color .15s, transform .15s;
}

#box .strip img:hover { opacity: .8; }

#box .strip img.cur {
  opacity: 1;
  outline-color: #fff;
  transform: scale(1.06);
}

@media (max-width: 640px) {
  #box { --strip-h: 0px; }
  #box .strip { display: none; }
  #box .nav { display: none; }
  #box .hud { padding: 12px 14px 34px; }
  #box .dt { font-size: 14px; }
}

#top {
  position: fixed;
  right: 16px;
  bottom: 18px;
  z-index: 30;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  box-shadow: var(--shadow);
  font-size: 15px;
  display: none;
  place-items: center;
  padding: 0;
}

#top.on { display: grid; }
