:root {
  --bg: #0e0e12;
  --card: #17171f;
  --text: #e8e8ee;
  --muted: #9a9ab0;
  --accent: #5865f2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

header {
  padding: 14px 20px;
  border-bottom: 1px solid #22222c;
  position: sticky;
  top: 0;
  background: rgba(14, 14, 18, 0.85);
  backdrop-filter: blur(8px);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
header h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 1px;
  text-transform: lowercase;
  display: flex;
  align-items: center;
  gap: 9px;
}
header h1 .dlogo {
  width: 26px;
  height: 26px;
  fill: #5865f2;          /* Discord blurple */
  flex: none;
}
header .user {
  color: var(--muted);
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
}
header .user .pfp {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid #33333f;
  flex: none;
}
header .user a, header .login-link { color: var(--accent); text-decoration: none; }
header .user a:hover, header .login-link:hover { text-decoration: underline; }

.login-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 96px 20px;
  color: var(--muted);
  text-align: center;
}
.login-btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 600;
}
.login-btn:hover { filter: brightness(1.1); }

/* JS masonry (web/static/gallery.js): a flex row of equal-width columns, each a
   vertical stack of cards. Centered with side gutters so it isn't edge-to-edge. */
.gallery {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  max-width: 1700px;
  margin: 0 auto;
  padding: 16px 24px;
}
.gallery .col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Each image sits in a framed card; very tall images are capped + cropped so a
   single image can't blow out a column. */
.card {
  display: block;
  border-radius: 12px;
  overflow: hidden;
  background: var(--card);
  border: 1px solid #262631;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.5);
}
.card a { display: block; }
.card img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 30rem;
  object-fit: cover;
}

/* image wrapper so the info icon can overlay the picture's bottom-right corner */
.media { position: relative; }
.media .info {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.12s ease, background 0.12s ease;
}
.media .info:hover { opacity: 1; background: rgba(0, 0, 0, 0.78); }
.media .info .ico { display: block; }

/* the reaction banner at the bottom of each card */
.reacts {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 8px;
}
.react {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 2px 8px;
  cursor: pointer;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.4;
}
.react:hover { background: #20202b; }
.react.mine {
  background: rgba(88, 101, 242, 0.18);
  border-color: var(--accent);
  color: var(--text);
}
.react .c { font-size: 12px; min-width: 4px; }
/* the add-reaction button: "+" + smiley, pinned left (first child of the bar) */
.react.add { gap: 3px; padding: 2px 8px; }
.react.add .plus { font-weight: 700; font-size: 14px; }
.react.add .ico { display: block; }

.emoji { display: inline-flex; align-items: center; line-height: 1; }
.emoji .ce { width: 18px; height: 18px; object-fit: contain; display: block; }

/* palette picker popover */
.picker {
  position: absolute;
  bottom: 100%;            /* default: open upward, above the bar */
  left: 8px;
  margin-bottom: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 240px;
  max-height: 240px;
  overflow-y: auto;        /* a large palette scrolls instead of overflowing */
  padding: 6px;
  background: #1c1c26;
  border: 1px solid #33333f;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 20;
}
/* When opening upward would clip the top of the viewport (card near the top of
   the page), gallery.js adds .down to flip the popover below the bar instead. */
.picker.down {
  top: 100%;
  bottom: auto;
  margin-top: 4px;
  margin-bottom: 0;
}
.pick {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  font-size: 18px;
  line-height: 1;
}
.pick:hover { background: #2a2a36; }
.pick .ce { width: 22px; height: 22px; }

.status {
  text-align: center;
  color: var(--muted);
  padding: 16px;
  font-size: 14px;
}

/* info modal (opened by a card's info icon) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.75);
}
.modal-backdrop[hidden] { display: none; }
.modal {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow: auto;
  background: var(--card);
  border: 1px solid #2c2c38;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.modal-img {
  width: 100%;
  max-height: 50vh;
  object-fit: contain;
  background: #000;
  border-radius: 14px 14px 0 0;
}
.modal-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}
.modal-close:hover { background: rgba(0, 0, 0, 0.8); }
.modal-info { display: flex; flex-direction: column; gap: 14px; padding: 14px 16px 18px; }
.mi-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}
.mi-copy {
  background: transparent;
  border: 1px solid #33333f;
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 11px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
  cursor: pointer;
}
.mi-copy:hover { background: #20202b; color: var(--text); }
.mi-prompt {
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.mi-meta { font-size: 13px; color: var(--muted); }
.mi-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  background: #20202b;
  border: 1px solid #2f2f3b;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 13px;
}

@media (max-width: 600px) { .gallery { padding: 10px 12px; } }
