:root {
  color-scheme: dark;
  --bg: #14161a;
  --bg-elevated: #1d2025;
  --border: #2c3038;
  --text: #e8e9eb;
  --text-dim: #9a9ea6;
  --accent: #5b8def;
  --accent-hover: #7ba2f2;
  --danger: #e35d5d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

h1, h2 { margin: 0; font-weight: 600; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.55em 1.1em;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover { border-color: var(--accent); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover { background: var(--accent-hover); }

/* ---------- Login ---------- */

body.centered {
  display: flex;
  align-items: center;
  justify-content: center;
}

.lock-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  width: min(320px, 90vw);
  padding: 2rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.lock-form h1, .lock-form h2 { text-align: center; margin-bottom: 0.5rem; }

.lock-form input[type="password"] {
  padding: 0.7em 0.9em;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

.lock-form input[type="password"]:focus {
  outline: none;
  border-color: var(--accent);
}

.error-text {
  color: var(--danger);
  font-size: 0.9rem;
  margin: 0;
  text-align: center;
}

/* ---------- Gallery ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}

.topbar-actions { display: flex; gap: 0.6rem; align-items: center; }

main { padding: 1rem; }

.gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.gallery-item {
  position: relative;
  height: 180px;
  cursor: pointer;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-elevated);
}

.gallery-item img {
  display: block;
  height: 100%;
  width: auto;
}

.gallery-item .video-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  pointer-events: none;
}

.gallery-item .delete-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  line-height: 1;
}

.gallery-item:hover .delete-btn { opacity: 1; }

.empty-state { color: var(--text-dim); text-align: center; margin-top: 3rem; }

/* ---------- Upload progress ---------- */

.upload-progress {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7em 1em;
  font-size: 0.9rem;
  z-index: 30;
}

/* ---------- Lightbox ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.lightbox-content {
  max-width: 92vw;
  max-height: 90vh;
  display: flex;
}

.lightbox-content img,
.lightbox-content video {
  max-width: 92vw;
  max-height: 90vh;
  object-fit: contain;
}

.lightbox-close, .lightbox-nav {
  position: absolute;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #fff;
  cursor: pointer;
  border-radius: 50%;
  font-size: 1.6rem;
  line-height: 1;
}

.lightbox-close {
  top: 1rem;
  right: 1rem;
  width: 44px;
  height: 44px;
}

.lightbox-nav {
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
}

.lightbox-prev { left: 1rem; }
.lightbox-next { right: 1rem; }

/* ---------- Lock overlay ---------- */

.lock-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 11, 13, 0.97);
  backdrop-filter: blur(24px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

body.locked .topbar,
body.locked main {
  filter: blur(20px);
}

/* `display: flex` above wins over the browser's default `[hidden]{display:none}`
   rule (author styles beat user-agent styles regardless of specificity), so
   these need an explicit override to actually hide when JS sets `hidden`. */
.lightbox[hidden],
.lock-overlay[hidden] {
  display: none;
}
