:root {
  color-scheme: light dark;
  --bg: #fafafa;
  --fg: #1a1a1a;
  --muted: #6b6b6b;
  --card-bg: #ffffff;
  --card-border: #e5e5e5;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --fg: #f2f2f2;
    --muted: #9a9a9a;
    --card-bg: #1c1c1c;
    --card-border: #2e2e2e;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ---- Password gate ---- */

#gate {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  gap: 1rem;
  text-align: center;
}

#gate h1 {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0;
}

#gate-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  max-width: 18rem;
}

#gate-password {
  padding: 0.75rem 0.9rem;
  border-radius: 0.7rem;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  color: var(--fg);
  font-size: 1rem;
  text-align: center;
}

#gate-submit {
  padding: 0.75rem 0.9rem;
  border-radius: 0.7rem;
  border: none;
  background: var(--fg);
  color: var(--bg);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

#gate-submit:active {
  opacity: 0.85;
}

#gate-error {
  color: #d64545;
  font-size: 0.85rem;
  min-height: 1.1rem;
}

#gate-back {
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: none;
  margin-top: 0.5rem;
}

/* ---- Full-screen viewer ---- */

#viewer {
  position: fixed;
  inset: 0;
  background: #000;
  display: none;
}

#viewer.active {
  display: block;
}

#viewer-image-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#viewer-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.viewer-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  border: none;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

#viewer-prev {
  left: 0.75rem;
}

#viewer-next {
  right: 0.75rem;
}

#viewer-close {
  position: absolute;
  top: env(safe-area-inset-top, 0.75rem);
  right: 0.75rem;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  border: none;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
}

#viewer-counter {
  position: absolute;
  bottom: env(safe-area-inset-bottom, 0.75rem);
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  background: rgba(0, 0, 0, 0.35);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
}

@media (max-width: 600px) {
  .viewer-btn {
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1.2rem;
  }
}
