:root {
  --bg: #0f0f16;
  --surface: #16161f;
  --surface-2: #1e1e2a;
  --text: #f3f1ea;
  --muted: #9a98a6;
  --gold: #d4af37;
  --gold-soft: #e6c75a;
  --border: #2a2a38;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 1.15rem; margin: 0; font-weight: 600; letter-spacing: 0.2px; }
.muted { color: var(--muted); }
.small { font-size: 0.8rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--gold);
  color: #1a1308;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.05s ease;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn:disabled { opacity: 0.6; cursor: default; }

/* ---- Top bar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(15, 15, 22, 0.85);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: 1300px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { color: var(--gold); font-size: 1.4rem; line-height: 1; }
.actions { display: flex; gap: 8px; flex-shrink: 0; }

main { max-width: 1300px; margin: 0 auto; padding: 16px; }
.status { padding: 40px 8px; text-align: center; }

/* ---- Grid ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}
@media (min-width: 700px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
}
.cell {
  position: relative;
  padding: 0;
  border: none;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  background: var(--surface-2);
  cursor: pointer;
}
.cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.cell img.loaded { opacity: 1; }
.cell:hover img { transform: scale(1.04); }

/* ---- Lightbox ---- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(8, 8, 12, 0.96);
  padding: env(safe-area-inset-top) 8px calc(env(safe-area-inset-bottom) + 56px);
}
.lightbox.show { display: flex; }
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
}
.lb-btn {
  position: absolute;
  background: rgba(30, 30, 42, 0.7);
  color: var(--text);
  border: 1px solid var(--border);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lb-btn:hover { background: var(--surface-2); }
.lb-close { top: calc(env(safe-area-inset-top) + 12px); right: 14px; }
.lb-prev { left: 10px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 10px; top: 50%; transform: translateY(-50%); }
.lb-bar {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom) + 12px);
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

/* ---- Login ---- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  text-align: center;
}
.login-mark { color: var(--gold); font-size: 2.4rem; margin-bottom: 8px; }
.login-card h1 { font-size: 1.4rem; margin-bottom: 6px; }
.login-card p { margin: 0 0 20px; font-size: 0.9rem; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card input {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1rem;
  text-align: center;
}
.login-card input:focus {
  outline: none;
  border-color: var(--gold);
}
.error { color: #ff8a8a; font-size: 0.85rem; margin: 4px 0 0; }
