* {
  box-sizing: border-box;
}

:root {
  --bg: #ffffff;
  --nav-bg: #f1f1f1;
  --text: #111111;
  --muted: #6b6b6b;
  --border: #d9d9d9;
  --pill-active: #111111;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

/* ---- top nav ---- */
.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--nav-bg);
  padding: 18px 32px;
  gap: 24px;
  flex-wrap: wrap;
}

.nav-left {
  display: flex;
  gap: 28px;
}

.nav-link {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--text);
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}

.nav-link:hover {
  text-decoration: underline;
}

.nav-muted {
  color: var(--muted);
}

/* ---- title ---- */
.site-title {
  text-align: center;
  font-size: clamp(42px, 7vw, 72px);
  font-weight: 400;
  margin: 56px 0 32px;
  letter-spacing: -0.01em;
}

/* ---- recommender ---- */
.recommender-bar {
  position: relative;
  display: flex;
  justify-content: center;
  z-index: 30;
}

.recommender-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  background: #fff;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 12px 12px;
  padding: 7px 20px 8px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.05);
}

.recommender-toggle:hover {
  color: var(--text);
  background: #fafafa;
}

.recommender-toggle .chevron {
  display: inline-block;
  font-size: 10px;
  transition: transform 0.2s ease;
}

.recommender-toggle.open .chevron {
  transform: rotate(180deg);
}

.recommender-panel {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: min(92vw, 560px);
  margin-top: 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.16);
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  pointer-events: none;
  transition: max-height 0.3s ease, opacity 0.2s ease;
}

.recommender-panel.open {
  max-height: 900px;
  opacity: 1;
  pointer-events: auto;
}

.recommender-panel-inner {
  padding: 22px 24px 26px;
  text-align: center;
}

.recommender-sub {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 14px;
}

.mood-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 20px;
}

.mood-pill {
  border: 1px solid #333;
  background: #fff;
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}

.mood-pill:hover {
  background: #f0f0f0;
}

.mood-pill.active {
  background: var(--pill-active);
  color: #fff;
  border-color: var(--pill-active);
}

.recommender-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 8px;
}

.btn-recommend, .btn-shuffle {
  border: 1px solid #333;
  border-radius: 999px;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.btn-recommend {
  background: #111;
  color: #fff;
}

.btn-recommend:hover {
  background: #333;
}

.btn-shuffle {
  background: #fff;
  color: var(--text);
}

.btn-shuffle:hover {
  background: #f0f0f0;
}

.hidden {
  display: none !important;
}

.recommend-result {
  margin-top: 20px;
}

.recommend-card {
  display: flex;
  gap: 20px;
  align-items: center;
  text-align: left;
  border: 1px solid #eee;
  border-radius: 12px;
  padding: 16px;
  animation: recommend-in 0.25s ease;
  cursor: pointer;
}

.recommend-card:hover {
  border-color: #ccc;
}

.recommend-card img {
  width: 160px;
  height: 160px;
  object-fit: cover;
  object-position: top;
  border-radius: 8px;
  border: 1px solid #eee;
  flex-shrink: 0;
}

.recommend-card-body h3 {
  margin: 0 0 6px;
  font-size: 20px;
}

.recommend-card-body .recommend-meta {
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 8px;
}

.recommend-card-body p.recommend-snippet {
  font-size: 14px;
  line-height: 1.6;
  margin: 0;
}

.recommend-card-body .recommend-moods {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

@keyframes recommend-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.recommend-empty {
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 560px) {
  .recommend-card {
    flex-direction: column;
  }
  .recommend-card img {
    width: 100%;
    height: auto;
    max-height: 240px;
  }
}

/* ---- controls ---- */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 32px 64px;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pill {
  border: 1px solid #333;
  background: #fff;
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}

.pill:hover {
  background: #f0f0f0;
}

.pill.active {
  background: var(--pill-active);
  color: #fff;
  border-color: var(--pill-active);
}

.search-box {
  padding: 8px 14px;
  border: 1px solid #333;
  border-radius: 999px;
  font-size: 14px;
  min-width: 220px;
  font-family: inherit;
}

.result-count {
  color: var(--muted);
  font-size: 13px;
  margin: 12px 0 24px;
}

/* ---- gallery (masonry via CSS columns) ---- */
.gallery {
  column-count: 4;
  column-gap: 28px;
}

@media (max-width: 1100px) {
  .gallery { column-count: 3; }
}
@media (max-width: 800px) {
  .gallery { column-count: 2; }
}
@media (max-width: 520px) {
  .gallery { column-count: 1; }
}

.card {
  break-inside: avoid;
  margin-bottom: 28px;
  cursor: zoom-in;
  display: block;
}

.card img {
  width: 100%;
  display: block;
  border: 1px solid #eee;
  border-radius: 2px;
}

.card.hidden {
  display: none;
}

/* ---- lightbox ---- */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 40px;
}

.lightbox.open {
  display: flex;
}

.lightbox-content {
  display: flex;
  gap: 32px;
  max-width: 1200px;
  max-height: 100%;
  align-items: flex-start;
}

.lightbox img {
  max-width: 60vw;
  max-height: 90vh;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  flex-shrink: 1;
  min-width: 0;
  object-fit: contain;
}

.lightbox-desc {
  background: #fff;
  border-radius: 8px;
  padding: 28px;
  width: 340px;
  max-height: 90vh;
  overflow-y: auto;
  flex-shrink: 0;
}

.lightbox-desc h2 {
  margin: 0 0 8px;
  font-size: 22px;
}

.lightbox-desc .lightbox-meta {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 16px;
  line-height: 1.6;
}

.lightbox-desc p:not(.lightbox-meta) {
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-line;
}

@media (max-width: 800px) {
  .lightbox-content {
    flex-direction: column;
    overflow-y: auto;
    max-height: 90vh;
  }
  .lightbox img {
    max-width: 100%;
  }
  .lightbox-desc {
    width: auto;
    max-height: none;
  }
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 32px;
  background: none;
  border: none;
  color: #fff;
  font-size: 36px;
  cursor: pointer;
  line-height: 1;
}

/* ---- modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: #fff;
  border-radius: 8px;
  max-width: 480px;
  width: 100%;
  padding: 32px;
  position: relative;
  line-height: 1.6;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
}

.modal h2 {
  margin-top: 0;
}
