*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-bg: #faf8f5;
  --color-surface: #ffffff;
  --color-text: #2c2c2c;
  --color-text-secondary: #666;
  --color-accent: #8b6914;
  --color-accent-light: #f5eedd;
  --color-border: #e8e4de;
  --color-overlay: rgba(0, 0, 0, 0.85);
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-hover: 0 6px 20px rgba(0,0,0,0.12);
  --font: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif;
  --transition: 0.2s ease;
}

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.header {
  text-align: center;
  padding: 2rem 1rem 1rem;
  background: linear-gradient(135deg, #f5eedd 0%, #e8dcc8 100%);
  border-bottom: 1px solid var(--color-border);
}
.header__title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-accent);
  letter-spacing: 0.05em;
}
.header__subtitle {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  margin-top: 0.25rem;
}

/* Tabs */
.tabs {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}
.tabs__btn {
  padding: 0.5rem 1.25rem;
  border: 1.5px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-size: 0.95rem;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  min-height: 44px;
}
.tabs__btn:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}
.tabs__btn--active {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}

/* Gallery Grid */
.gallery {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  padding: 1.25rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* Card */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}
.card:active {
  transform: translateY(0);
}
.card__img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--color-accent-light);
}
.card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}
.card:hover .card__img {
  transform: scale(1.03);
}
.card__badge {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
}
.card__badge--dharma { background: #8b6914; }
.card__badge--health { background: #3a7d5c; }
.card__count {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  color: #fff;
  background: rgba(0,0,0,0.55);
}

.card__body {
  padding: 0.85rem 1rem;
}
.card__title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 0.35rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card__desc {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--color-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}
.lightbox[hidden] { display: none; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.lightbox__content {
  max-width: 900px;
  max-height: 90vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.lightbox__img {
  max-width: 100%;
  max-height: 65vh;
  object-fit: contain;
  border-radius: var(--radius);
  background: #000;
}
.lightbox__info {
  text-align: center;
  margin-top: 1rem;
  color: #fff;
  max-width: 600px;
}
.lightbox__title {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}
.lightbox__counter {
  display: inline-block;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(255,255,255,0.25);
  margin-bottom: 0.35rem;
}
.lightbox__counter[hidden] { display: none; }
.lightbox__category {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(255,255,255,0.2);
  margin-bottom: 0.5rem;
}
.lightbox__desc {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.8);
  line-height: 1.5;
}

.lightbox__close,
.lightbox__prev,
.lightbox__next {
  position: fixed;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  z-index: 101;
  transition: opacity var(--transition);
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox__close:hover,
.lightbox__prev:hover,
.lightbox__next:hover {
  opacity: 0.7;
}
.lightbox__close {
  top: 1rem;
  right: 1rem;
  font-size: 2rem;
}
.lightbox__prev {
  left: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 3rem;
}
.lightbox__next {
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 3rem;
}

/* Footer */
.footer {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--color-text-secondary);
  font-size: 0.8rem;
  border-top: 1px solid var(--color-border);
}

/* Empty state */
.gallery__empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1rem;
  color: var(--color-text-secondary);
  font-size: 1rem;
}

/* Mobile */
@media (max-width: 640px) {
  .header__title { font-size: 1.25rem; }
  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
    padding: 0.75rem;
  }
  .card__body { padding: 0.6rem 0.75rem; }
  .card__title { font-size: 0.9rem; }
  .card__desc { font-size: 0.8rem; -webkit-line-clamp: 1; }
  .lightbox__prev { left: 0.25rem; font-size: 2.5rem; }
  .lightbox__next { right: 0.25rem; font-size: 2.5rem; }
}
