@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap');

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

:root {
  --pink: #ff6b9d;
  --pink-light: #ffa5c8;
  --pink-pale: #fff0f5;
  --orange: #ffb347;
  --red: #ff6b6b;
  --blue: #74b9ff;
  --green: #a8e6cf;
  --purple: #c9b1ff;
  --bg: #fff5f9;
  --surface: #ffffff;
  --card-1: #fff0f5;
  --card-2: #f0f8ff;
  --card-3: #f5fff0;
  --card-4: #fef5ff;
  --card-5: #fff8f0;
  --text: #5a4a5a;
  --text-muted: #b8a0b8;
  --shadow: rgba(255, 107, 157, .15);
}

body {
  font-family: 'Nunito', system-ui, sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 10% 20%, rgba(255,107,157,.06) 0%, transparent 50%),
    radial-gradient(circle at 90% 80%, rgba(116,185,255,.06) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(201,177,255,.05) 0%, transparent 50%);
  color: var(--text);
  min-height: 100vh;
}

/* Top bar */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; gap: .6rem;
  padding: .6rem 1rem;
  background: linear-gradient(135deg, #fff 0%, var(--pink-pale) 100%);
  border-bottom: 3px solid var(--pink-light);
  box-shadow: 0 2px 16px var(--shadow);
  flex-wrap: wrap;
}
.logo-icon {
  width: 34px; height: 34px; border-radius: 50%;
  flex-shrink: 0;
}
#topbar h1 {
  font-size: 1.3rem; font-weight: 800; white-space: nowrap;
  background: linear-gradient(135deg, #9b7ec8, var(--pink), #ffb347);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.filters {
  display: flex; gap: .5rem; flex: 1; justify-content: flex-end;
  align-items: center; flex-wrap: wrap; min-width: 0;
}
.filters select {
  padding: .45rem .8rem; border-radius: 20px;
  border: 2px solid var(--pink-light);
  background: #fff; color: var(--text); font-size: .85rem;
  font-family: inherit; cursor: pointer;
  transition: border-color .2s, box-shadow .2s;
  min-width: 0;
}
.filters select:focus {
  outline: none; border-color: var(--pink);
  box-shadow: 0 0 0 3px rgba(255,107,157,.2);
}

/* Inline SVG icon alignment */
button svg, .date-picker-btn svg { vertical-align: -0.15em; }

/* Custom date picker */
.date-picker { position: relative; }
.date-picker-btn {
  padding: .45rem .8rem; border-radius: 20px;
  border: 2px solid var(--pink-light);
  background: #fff; color: var(--text); font-size: .85rem;
  font-family: inherit; cursor: pointer; white-space: nowrap;
  transition: border-color .2s, box-shadow .2s;
}
.date-picker-btn:hover { border-color: var(--pink); }
.date-picker-btn.active {
  border-color: var(--pink); background: var(--pink-pale);
}
.date-dropdown {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 150;
  background: #fff; border-radius: 16px; padding: .8rem;
  border: 2px solid var(--pink-light);
  box-shadow: 0 8px 30px var(--shadow);
  width: 260px;
}
.dd-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .5rem;
}
.dd-header span {
  font-weight: 800; font-size: .9rem;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.dd-nav {
  width: 30px; height: 30px; border-radius: 50%; border: none;
  background: var(--pink-pale); color: var(--pink);
  font-size: 1.1rem; font-weight: 800; cursor: pointer;
  transition: background .2s;
}
.dd-nav:hover { background: var(--pink-light); color: #fff; }
.dd-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  text-align: center; font-size: .7rem; font-weight: 700;
  color: var(--text-muted); margin-bottom: .3rem;
}
.dd-days {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px;
}
.dd-days button {
  aspect-ratio: 1; border: none; border-radius: 50%;
  background: transparent; color: var(--text); font-size: .78rem;
  font-family: inherit; font-weight: 600; cursor: pointer;
  transition: all .15s;
}
.dd-days button:hover { background: var(--pink-pale); }
.dd-days button.today { border: 2px solid var(--pink-light); }
.dd-days button.selected {
  background: linear-gradient(135deg, var(--pink), var(--purple));
  color: #fff;
}
.dd-days button.has-cat::after {
  content: ""; display: block; width: 4px; height: 4px;
  background: var(--pink); border-radius: 50%;
  margin: -2px auto 0;
}
.dd-days button.selected.has-cat::after { background: #fff; }
.dd-days button.other-month { color: var(--text-muted); opacity: .4; }
.dd-clear {
  display: block; width: 100%; margin-top: .5rem; padding: .4rem;
  border: none; border-radius: 20px;
  background: var(--pink-pale); color: var(--pink);
  font-family: inherit; font-size: .8rem; font-weight: 700;
  cursor: pointer; transition: background .2s;
}
.dd-clear:hover { background: var(--pink-light); color: #fff; }

/* GitHub link */
.github-link {
  color: var(--pink); flex-shrink: 0;
  transition: color .2s, transform .2s;
  display: flex; align-items: center;
}
.github-link:hover { color: var(--purple); transform: scale(1.15) rotate(-8deg); }

/* Timeline sidebar */
#timeline {
  position: fixed; top: 56px; right: 0; bottom: 0; width: 130px; z-index: 90;
  background: linear-gradient(180deg, #fff 0%, var(--pink-pale) 100%);
  border-left: 2px solid var(--pink-light);
  overflow-y: auto; padding: .8rem 0;
  transition: transform .3s ease;
}
#timeline::-webkit-scrollbar { width: 4px; }
#timeline::-webkit-scrollbar-thumb { background: var(--pink-light); border-radius: 4px; }

#timeline-toggle {
  display: none; position: fixed; bottom: 1.2rem; right: 1.2rem; z-index: 91;
  width: 48px; height: 48px; border-radius: 50%; border: none;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  color: #fff; font-size: 1.3rem; cursor: pointer;
  box-shadow: 0 4px 15px rgba(255,107,157,.35);
  transition: transform .2s;
}
#timeline-toggle:hover { transform: scale(1.1); }

#timeline-list a {
  display: block; padding: .3rem .8rem; color: var(--text-muted);
  text-decoration: none; font-size: .8rem; font-weight: 600;
  border-right: 3px solid transparent;
  transition: all .2s;
}
#timeline-list a:hover {
  color: var(--pink); background: rgba(255,107,157,.08);
  border-right-color: var(--pink);
}
#timeline-list .year {
  font-weight: 800; color: var(--purple); margin-top: .6rem;
  padding: .2rem .8rem; font-size: .85rem;
}

/* Gallery masonry */
.masonry {
  margin-top: 60px; margin-right: 130px; padding: 1.2rem;
  column-count: 3; column-gap: 1.2rem;
}

/* Candy color rotation for cards */
.card {
  break-inside: avoid; margin-bottom: 1.2rem;
  border-radius: 16px; overflow: hidden;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
  border: 2px solid transparent;
}
.card:nth-child(5n+1) { background: var(--card-1); border-color: rgba(255,107,157,.2); }
.card:nth-child(5n+2) { background: var(--card-2); border-color: rgba(116,185,255,.2); }
.card:nth-child(5n+3) { background: var(--card-3); border-color: rgba(168,230,207,.25); }
.card:nth-child(5n+4) { background: var(--card-4); border-color: rgba(201,177,255,.25); }
.card:nth-child(5n+5) { background: var(--card-5); border-color: rgba(255,179,71,.2); }

.card:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 8px 25px var(--shadow);
}
/* Card image wrapper for badge overlay */
.card-img-wrap { position: relative; }
.card-img-wrap img { width: 100%; display: block; border-radius: 14px 14px 0 0; }
.like-badge {
  position: absolute; top: .5rem; right: .5rem;
  display: inline-flex; align-items: center; gap: .2rem;
  background: rgba(0,0,0,.55); backdrop-filter: blur(4px);
  color: var(--pink-light); padding: .2rem .55rem;
  border-radius: 20px; font-size: .7rem; font-weight: 700;
  pointer-events: none;
}
.like-badge svg { width: 12px; height: 12px; fill: var(--pink-light); stroke: var(--pink-light); }
.card-info { padding: .6rem .8rem; font-size: .78rem; }
.card-info .time { color: var(--text-muted); font-weight: 600; }
.card-info .model {
  display: inline-block; margin-top: .3rem; padding: .15rem .55rem;
  border-radius: 20px; font-size: .7rem; font-weight: 700;
  color: #fff;
}
/* Rotate model tag colors */
.card:nth-child(5n+1) .model { background: linear-gradient(135deg, var(--pink), var(--red)); }
.card:nth-child(5n+2) .model { background: linear-gradient(135deg, var(--blue), var(--purple)); }
.card:nth-child(5n+3) .model { background: linear-gradient(135deg, var(--green), #6bcfa8); }
.card:nth-child(5n+4) .model { background: linear-gradient(135deg, var(--purple), var(--pink)); }
.card:nth-child(5n+5) .model { background: linear-gradient(135deg, var(--orange), var(--red)); }

/* Month separator */
.month-sep {
  column-span: all; padding: .5rem 0; font-size: .95rem;
  font-weight: 800; letter-spacing: .02em;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  border-bottom: 2px dashed var(--pink-light);
  margin-bottom: .8rem;
}
.month-sep::before { content: "🌸 "; -webkit-text-fill-color: initial; }

/* End / scroll sentinel */
#end-msg {
  text-align: center; padding: 2.5rem; font-size: 1rem;
  color: var(--text-muted); font-weight: 700;
  margin-right: 130px;
}
#end-msg.loading { visibility: hidden; height: 1px; padding: 0; }
.hidden { display: none !important; }

/* Lightbox */
#lightbox {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(90, 74, 90, .8);
  backdrop-filter: blur(8px);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 1rem 0;
}
#lb-close {
  position: absolute; top: 1rem; right: 1.2rem;
  background: none; border: none; color: #fff; font-size: 2.2rem; cursor: pointer;
  text-shadow: 0 2px 8px rgba(0,0,0,.3);
  transition: transform .2s; z-index: 1;
}
#lb-close:hover { transform: scale(1.2) rotate(90deg); }

/* Info line above image */
#lb-info {
  color: rgba(255,255,255,.8); font-size: .8rem;
  font-weight: 600; text-shadow: 0 1px 4px rgba(0,0,0,.3);
  text-align: center; margin-bottom: .4rem;
}

/* Image wrapper - contains overlay elements */
#lb-img-wrap {
  position: relative; max-width: 90vw;
  border-radius: 16px; overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,.3);
  flex-shrink: 0;
}
#lb-img {
  display: block; max-width: 90vw; max-height: 75vh;
}

/* Action buttons on image bottom-right */
#lb-img-actions {
  position: absolute;
  bottom: .5rem; right: .5rem;
  display: flex; gap: .35rem;
}
#lb-like-btn, #lb-download-btn, #lb-copy-btn {
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,.3);
  color: #fff; padding: .3rem .7rem;
  border-radius: 20px; font-family: inherit;
  font-size: .72rem; font-weight: 600;
  cursor: pointer; transition: background .2s, color .2s;
  white-space: nowrap;
}
#lb-like-btn:hover, #lb-download-btn:hover, #lb-copy-btn:hover {
  background: rgba(0,0,0,.85);
}
#lb-like-btn { color: var(--pink-light); }
#lb-like-btn svg { fill: var(--pink-light); stroke: var(--pink-light); }
#lb-like-btn:hover { color: var(--pink); }
#lb-like-btn:hover svg { fill: var(--pink); stroke: var(--pink); }

/* Details area below image - scrollable */
#lb-details {
  max-width: 600px; width: 90vw;
  max-height: 20vh;
  overflow-y: auto;
  margin-top: .5rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.3) transparent;
}
#lb-details::-webkit-scrollbar { width: 4px; }
#lb-details::-webkit-scrollbar-thumb { background: rgba(255,255,255,.3); border-radius: 4px; }

/* Prompt text always hidden (copy button reads from it) */
#lb-prompt-text { display: none !important; }

/* Tab bar */
#lb-tab-bar {
  display: flex; gap: .3rem;
  justify-content: center;
  margin-bottom: .4rem;
}
#lb-tab-bar button {
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .2);
  color: rgba(255, 255, 255, .6);
  padding: .25rem .7rem;
  border-radius: 20px;
  font-family: inherit;
  font-size: .72rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, color .2s;
}
#lb-tab-bar button:hover {
  background: rgba(255, 255, 255, .22);
  color: rgba(255, 255, 255, .9);
}
#lb-tab-bar button.active {
  background: rgba(255, 255, 255, .25);
  color: #fff;
  border-color: rgba(255, 255, 255, .4);
}

/* Tab panels */
.lb-panel {
  border-radius: 12px;
  padding: .5rem .8rem;
  border: 1px solid rgba(255, 255, 255, .2);
}

/* Story panel */
#lb-story {
  background: linear-gradient(135deg, rgba(201, 177, 255, .4), rgba(255, 107, 157, .3));
}
#lb-story-text {
  color: #fff; font-size: .85rem; line-height: 1.5;
  text-align: center; margin: 0;
}

/* Idea panel */
#lb-idea {
  background: linear-gradient(135deg, rgba(72, 187, 176, .4), rgba(116, 185, 255, .3));
}
#lb-idea-text {
  color: #fff; font-size: .8rem; font-style: italic;
  line-height: 1.5; text-align: center; margin: 0;
}

/* News panel */
#lb-news {
  background: linear-gradient(135deg, rgba(71, 150, 255, .3), rgba(100, 180, 255, .2));
}
#lb-news-list {
  display: flex; flex-wrap: wrap; gap: .3rem;
}
.news-tag {
  display: inline-block; padding: .15rem .5rem;
  border-radius: 20px; color: #fff;
  font-size: .68rem; font-weight: 600;
  background: linear-gradient(135deg, rgba(71, 179, 255, .7), rgba(71, 130, 255, .6));
}

/* Constraints panel */
#lb-avoid {
  background: linear-gradient(135deg, rgba(255, 179, 71, .3), rgba(255, 140, 60, .2));
}
#lb-avoid-list {
  display: flex; flex-wrap: wrap; gap: .3rem;
}
.avoid-tag {
  display: inline-block; padding: .15rem .5rem;
  border-radius: 20px; color: #fff;
  font-size: .68rem; font-weight: 600;
  background: linear-gradient(135deg, rgba(255, 179, 71, .7), rgba(255, 107, 71, .6));
  white-space: nowrap;
}

/* Responsive */
@media (max-width: 1024px) {
  .masonry { column-count: 2; margin-right: 0; }
  #end-msg { margin-right: 0; }
  #timeline { transform: translateX(100%); }
  #timeline.open { transform: translateX(0); }
  #timeline-toggle { display: block; }
}
@media (max-width: 600px) {
  .masonry { column-count: 1; padding: .8rem; margin-top: 100px; }
  #topbar { gap: .4rem; padding: .5rem .6rem; }
  #topbar h1 { font-size: 1.1rem; }
  .logo-icon { width: 28px; height: 28px; }
  .filters { flex: 1 1 100%; order: 1; justify-content: flex-start; gap: .4rem; }
  .filters select { font-size: .78rem; padding: .35rem .5rem; }
  .date-picker-btn { font-size: .78rem; padding: .35rem .5rem; }
  .date-dropdown { width: calc(100vw - 1.2rem); max-width: 280px; right: auto; left: 0; }
  .github-link { margin-left: auto; }
  /* Lightbox mobile */
  #lightbox { justify-content: safe center; padding: 2.5rem 0 1rem; overflow-y: auto; }
  #lb-img-wrap { border-radius: 0; overflow: visible; box-shadow: none; }
  #lb-img { max-height: 45vh; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.3); }
  #lb-img-actions { position: static; justify-content: center; margin-top: .5rem; }
  #lb-details { max-height: none; }
}
