:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #5c5c5c;
  --line: #e6e6e6;
  --green: #06C755;
  --tile: #f2f2f2;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body {
  font-family: "Sarabun", "Noto Sans Thai", "Leelawadee UI", system-ui, sans-serif;
  font-size: 20px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--green); color: #fff;
  padding: 14px 16px calc(14px) 16px;
  padding-top: calc(14px + env(safe-area-inset-top));
}
.top h1 { margin: 0; font-size: 24px; font-weight: 700; }
main { padding: 0 12px 40px; max-width: 1100px; margin: 0 auto; }
.status { text-align: center; color: var(--muted); padding: 28px 8px; font-size: 22px; }
.status.big { color: var(--fg); }

.year {
  font-size: 30px; font-weight: 800; margin: 26px 4px 4px;
  border-bottom: 3px solid var(--green); padding-bottom: 4px;
}
.group-title { font-size: 21px; font-weight: 700; margin: 18px 4px 2px; }
.group-sub { font-size: 17px; color: var(--muted); margin: 0 4px 10px; }

.grid {
  display: grid; gap: 6px;
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 600px) { .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); } }

.tile {
  position: relative; border: 0; padding: 0; margin: 0;
  aspect-ratio: 1 / 1; background: var(--tile);
  border-radius: 10px; overflow: hidden; cursor: pointer;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .play {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 46px; color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,.6);
  pointer-events: none;
}
.tile .play.novid { background: #333; }

.viewer {
  position: fixed; inset: 0; z-index: 20; background: #000; color: #fff;
  display: flex; flex-direction: column;
}
.viewer[hidden] { display: none; }
.viewer-stage {
  flex: 1; display: grid; place-items: center; overflow: hidden;
  touch-action: pan-y pinch-zoom;
  padding-top: env(safe-area-inset-top);
}
.viewer-stage img, .viewer-stage video { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-info { text-align: center; font-size: 17px; color: #ddd; padding: 6px 12px; }
.viewer-bar {
  display: flex; gap: 10px; padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
}
.btn {
  flex: 1; font: inherit; font-size: 21px; font-weight: 700;
  padding: 16px 10px; border-radius: 14px; border: 0; cursor: pointer;
}
.btn.close { background: #3a3a3a; color: #fff; flex: 0 0 34%; }
.btn.save { background: var(--green); color: #fff; }
.btn:disabled { opacity: .6; }
.nav {
  position: absolute; top: 42%; transform: translateY(-50%);
  width: 56px; height: 84px; border: 0; border-radius: 12px;
  background: rgba(255,255,255,.18); color: #fff; font-size: 46px; line-height: 1;
  cursor: pointer;
}
.nav.prev { left: 8px; }
.nav.next { right: 8px; }
.nav[hidden] { display: none; }
