:root {
  --bg: #0c0f17;
  --bg-soft: #141926;
  --bg-card: #1a2030;
  --text: #f3f4f8;
  --muted: #97a0b5;
  --accent: #ffb703;
  --accent-2: #f76c5e;
  --radius: 14px;
  --gap: 14px;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: radial-gradient(1200px 600px at 70% -10%, #1c2740 0%, transparent 60%),
              radial-gradient(900px 500px at 100% 100%, #2a1426 0%, transparent 60%),
              var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px clamp(12px, 4vw, 28px);
  backdrop-filter: blur(10px);
  background: rgba(12, 15, 23, 0.72);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-badge {
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-sub { color: var(--muted); font-size: 12px; letter-spacing: 1.2px; text-transform: uppercase; }

.auth { display: flex; align-items: center; gap: 8px; }
.user-email {
  color: var(--muted);
  font-size: 12px;
  max-width: 30vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 480px) { .user-email { display: none; } }

/* ---------- Buttons ---------- */
.btn {
  --bp: 10px 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: var(--bp);
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  background: var(--bg-soft);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  line-height: 1;
  transition: transform .06s ease, background .15s, border-color .15s;
  user-select: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #1a1206;
}
.btn-ghost { background: transparent; }
.btn-google { background: #fff; color: #1f1f1f; border-color: #fff; }
.btn-google svg { width: 18px; height: 18px; }
/* Signed-in state: pill shows the user's email */
.btn-google.signed-in {
  background: #f6f8fc;
  border-color: #dadce0;
  color: #3c4043;
  cursor: default;
}
.btn-google.signed-in .g-icon {
  background: #fff;
  border-radius: 50%;
  padding: 2px;
}
.btn-google.signed-in .login-label {
  max-width: 36vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
@media (max-width: 480px) {
  .btn-google.signed-in .login-label { max-width: 44vw; }
}

/* ---------- Hero ---------- */
.hero { padding: clamp(20px, 6vw, 44px) clamp(12px, 4vw, 28px) 8px; }
.hero h1 {
  margin: 0;
  font-size: clamp(28px, 7vw, 46px);
  letter-spacing: -0.5px;
}
.hero h1 span {
  display: inline-block;
  font-size: 0.5em;
  color: var(--accent);
  transform: translateY(-4px);
  letter-spacing: 2px;
  text-transform: uppercase;
}
.hero p { margin: 6px 0 0; color: var(--muted); }
.hero p.sign-in-hint { text-align: right; }

/* ---------- Gallery (masonry via columns) ---------- */
.gallery {
  column-gap: var(--gap);
  column-count: 4;
  padding: 18px clamp(12px, 3vw, 24px) 0;
}
@media (max-width: 1100px) { .gallery { column-count: 3; } }
@media (max-width: 760px)  { .gallery { column-count: 2; } }
@media (max-width: 420px)  { .gallery { column-count: 1; } }

.card {
  break-inside: avoid;
  margin: 0 0 var(--gap);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.05);
  cursor: zoom-in;
  position: relative;
}
.card img {
  display: block;
  width: 100%;
  height: auto;
  background: #0a0d15;
}
.card-del {
  position: absolute;
  top: 8px; right: 8px;
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.25);
  background: rgba(0,0,0,.55);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0;
  transition: opacity .12s ease, background .12s;
  z-index: 2;
}
.card:hover .card-del,
.card-del:focus-visible { opacity: 1; }
.card-del:hover { background: #c0392b; }
@media (hover: none) {
  /* Touch devices: always show the × on the user's own photos. */
  .card-del { opacity: 1; }
}
.card .meta {
  padding: 10px 12px 12px;
}
.card .cap { font-size: 14px; }
.card .who {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.card .who .email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }

.sentinel { height: 1px; }
.loading { text-align: center; padding: 24px; color: var(--muted); }
.empty { text-align: center; padding: 60px 24px; color: var(--muted); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #1f2740;
  border: 1px solid rgba(255,255,255,0.14);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 50;
  box-shadow: 0 10px 40px rgba(0,0,0,.4);
}

/* ---------- Upload dialog ---------- */
.dialog {
  border: 1px solid rgba(255,255,255,0.1);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 18px;
  padding: 20px;
  max-width: 460px;
  width: calc(100% - 32px);
  box-shadow: 0 20px 80px rgba(0,0,0,.5);
}
.dialog::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(3px); }
.dialog h2 { margin: 0 0 14px; font-size: 20px; }
.file-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 130px;
  border: 2px dashed rgba(255,255,255,0.18);
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
  padding: 18px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.file-drop:hover { border-color: var(--accent); color: var(--text); }
.file-drop input[type=file] { display: none; }
.file-drop-name { color: var(--accent); font-weight: 600; }
.caption {
  display: block;
  margin-top: 14px;
}
.caption span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.caption input, .file-drop input[type=text] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.14);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

/* ---------- Lightbox ---------- */
.lightbox {
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  max-width: none;
  max-height: none;
  width: 100vw;
  height: 100vh;
}
.lightbox::backdrop { background: rgba(0,0,0,.92); }
.lightbox img {
  max-width: 94vw;
  max-height: 86vh;
  display: block;
  margin: 0 auto;
  border-radius: 8px;
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.lightbox-close {
  position: fixed;
  top: 16px; right: 16px;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(0,0,0,.4);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}
.lightbox-caption {
  color: #d8ddf0;
  text-align: center;
  margin: 12px auto 0;
  max-width: 90vw;
  font-size: 15px;
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 40px 20px 28px;
}