* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #111;
  color: #eee;
  min-height: 100vh;
}

/* ── Screens ────────────────────────────────── */
.screen { display: none; }
.screen.active { display: block; }

/* ── Login ──────────────────────────────────── */
.login-box {
  max-width: 360px;
  margin: 15vh auto 0;
  padding: 2rem;
  text-align: center;
}
.login-box h1 { font-size: 1.8rem; margin-bottom: 0.5rem; }
.login-box p  { color: #aaa; margin-bottom: 1.5rem; font-size: 0.95rem; }

.input-group {
  display: flex;
  border: 1px solid #444;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1rem;
}
.prefix {
  background: #222;
  padding: 0.75rem 0.8rem;
  color: #aaa;
  border-right: 1px solid #444;
  font-size: 1rem;
}
.input-group input, #code-input {
  width: 100%;
  background: #1a1a1a;
  color: #eee;
  border: none;
  padding: 0.75rem;
  font-size: 1.1rem;
  outline: none;
}
#code-input {
  border: 1px solid #444;
  border-radius: 8px;
  text-align: center;
  letter-spacing: 0.4em;
  margin-bottom: 1rem;
  display: block;
}
button {
  width: 100%;
  padding: 0.8rem;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  margin-bottom: 0.75rem;
}
button:disabled { opacity: 0.5; }
button:active   { background: #1d4ed8; }
.login-box a { color: #888; font-size: 0.9rem; }
.error { color: #f87171; font-size: 0.9rem; margin-top: 0.5rem; min-height: 1.2rem; }

/* ── Gallery header ─────────────────────────── */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: #1a1a1a;
  position: sticky;
  top: 0;
  z-index: 10;
}
header h1  { font-size: 1.2rem; }
.btn-logout {
  width: auto;
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  background: #333;
  margin: 0;
}

/* ── Bucket bar ─────────────────────────────── */
.bucket-bar {
  display: flex;
  overflow-x: auto;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: #161616;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  position: sticky;
  top: 48px;
  z-index: 9;
}
.bucket-bar::-webkit-scrollbar { display: none; }
.bucket-bar button {
  flex-shrink: 0;
  width: auto;
  padding: 0.4rem 0.9rem;
  background: #2a2a2a;
  font-size: 0.8rem;
  margin: 0;
  border-radius: 20px;
  white-space: nowrap;
}
.bucket-bar button.active { background: #2563eb; }

/* ── Month bar ──────────────────────────────── */
.month-bar {
  display: flex;
  overflow-x: auto;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: #141414;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  position: sticky;
  top: 94px;
  z-index: 8;
}
.month-bar::-webkit-scrollbar { display: none; }
.month-bar button {
  flex-shrink: 0;
  width: auto;
  padding: 0.35rem 0.8rem;
  background: #222;
  font-size: 0.78rem;
  margin: 0;
  border-radius: 20px;
  white-space: nowrap;
}
.month-bar button.active { background: #2563eb; }
.hidden { display: none !important; }

/* ── Grid ───────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 2px;
}
@media (min-width: 600px)  { .grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 900px)  { .grid { grid-template-columns: repeat(6, 1fr); } }

.cell {
  aspect-ratio: 1;
  overflow: hidden;
  background: #1a1a1a;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.video-thumb {
  font-size: 2.5rem;
  color: #fff;
  opacity: 0.8;
}
.cell span {
  position: absolute;
  bottom: 4px;
  left: 4px;
  right: 4px;
  font-size: 0.6rem;
  color: #ccc;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.loading { text-align: center; padding: 2rem; color: #888; }
.empty   { text-align: center; padding: 2rem; color: #555; grid-column: 1/-1; }

/* ── Lightbox ───────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.lb-content {
  max-width: 100vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lb-content img, .lb-content video {
  max-width: 100vw;
  max-height: 88vh;
  object-fit: contain;
}
.lb-caption {
  position: absolute;
  bottom: 1rem;
  color: #888;
  font-size: 0.8rem;
  text-align: center;
  width: 100%;
  padding: 0 4rem;
}
.lb-close {
  position: absolute;
  top: 1rem; right: 1rem;
  width: auto;
  background: transparent;
  font-size: 1.5rem;
  color: #fff;
  padding: 0.5rem;
  margin: 0;
  line-height: 1;
}
.lb-prev, .lb-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: auto;
  background: rgba(0,0,0,0.5);
  font-size: 1.5rem;
  padding: 1rem 0.75rem;
  margin: 0;
}
.lb-prev { left: 0; }
.lb-next { right: 0; }
.lb-filename {
  color: #aaa;
  font-size: 0.8rem;
  margin-bottom: 0.2rem;
}
.lb-url {
  color: #666;
  font-size: 0.7rem;
  word-break: break-all;
  margin-bottom: 0.3rem;
  font-family: monospace;
}
.lb-copy-link {
  width: auto;
  background: rgba(255,255,255,0.15);
  font-size: 0.8rem;
  padding: 0.3rem 0.7rem;
  margin: 0.5rem 0 0;
  border-radius: 20px;
}
