:root {
  --bg: #0c0a0e;
  --bg-elev: #17141a;
  --bg-elev-2: #1f1b23;
  --line: #2a2530;
  --text: #f2ede6;
  --text-dim: #a89fae;
  --accent: #e3b567;
  --accent-dim: #8a6f3e;
  --danger: #d1495b;
  --radius: 10px;
  --sidebar-w: 232px;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  height: 100%;
}

::selection { background: var(--accent-dim); color: var(--text); }

h1, h2 { font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 600; margin: 0; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

/* ---------- Gate ---------- */

.gate {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 20%, #221c28 0%, #0c0a0e 65%);
  z-index: 200;
  padding: 24px;
}

.gate-card {
  width: 100%;
  max-width: 320px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.gate-title {
  font-size: 2.6rem;
  letter-spacing: 0.04em;
  color: var(--accent);
  font-style: italic;
}

.gate-sub {
  margin: -8px 0 6px;
  color: var(--text-dim);
  font-size: 0.85rem;
  letter-spacing: 0.03em;
}

.gate-input {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--text);
  font-size: 1rem;
  text-align: center;
  outline: none;
  transition: border-color 0.15s;
}
.gate-input:focus { border-color: var(--accent-dim); }

.gate-btn {
  background: var(--accent);
  color: #1a1409;
  font-weight: 600;
  border-radius: var(--radius);
  padding: 12px;
  font-size: 0.95rem;
  letter-spacing: 0.03em;
  transition: filter 0.15s, transform 0.1s;
}
.gate-btn:hover { filter: brightness(1.08); }
.gate-btn:active { transform: scale(0.98); }

.gate-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin: 0;
}

/* ---------- App shell ---------- */

.app {
  display: flex;
  min-height: 100vh;
}

.nav-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 60;
  width: 40px;
  height: 40px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 1.1rem;
  color: var(--text);
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-elev);
  border-right: 1px solid var(--line);
  padding: 26px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-style: italic;
  font-size: 1.7rem;
  color: var(--accent);
  padding: 0 10px 22px;
  letter-spacing: 0.03em;
}

.album-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 0.92rem;
  text-align: left;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--bg-elev-2); color: var(--text); }
.nav-item.active { background: var(--bg-elev-2); color: var(--accent); }

.nav-item .n-label { display: flex; align-items: center; gap: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .n-count { font-size: 0.75rem; color: var(--text-dim); opacity: 0.8; }
.nav-item.active .n-count { color: var(--accent); opacity: 1; }
.nav-item .n-star { color: var(--accent); }

.nav-sep {
  height: 1px;
  background: var(--line);
  margin: 10px 4px;
}

.sidebar-footer {
  padding: 10px;
  font-size: 0.75rem;
  color: var(--text-dim);
  border-top: 1px solid var(--line);
  margin-top: 10px;
}

/* ---------- Main ---------- */

.main {
  flex: 1;
  min-width: 0;
  padding: 30px 32px 60px;
}

.topbar {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 20px;
}

.view-title { font-size: 1.9rem; }
.view-count { color: var(--text-dim); font-size: 0.85rem; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 4px;
}

.tile {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 4px;
  background: var(--bg-elev);
  cursor: pointer;
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
  opacity: 0;
  animation: fade-in 0.3s ease forwards;
}

@keyframes fade-in { to { opacity: 1; } }

.tile:hover img { transform: scale(1.06); }

.tile-star {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(12, 10, 14, 0.55);
  backdrop-filter: blur(2px);
  color: #fff;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.15s, transform 0.15s, color 0.15s;
  z-index: 2;
}

.tile:hover .tile-star, .tile-star.is-fav { opacity: 1; transform: scale(1); }
.tile-star.is-fav { color: var(--accent); }

.empty-state { color: var(--text-dim); padding: 40px 0; text-align: center; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 0.85rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: min(90vw, 420px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--danger); color: #f2c9ce; }

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

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(6, 5, 7, 0.94);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox[hidden] { display: none; }
.app[hidden] { display: none; }

.lb-img {
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

.lb-close, .lb-nav, .lb-star {
  position: fixed;
  color: #f2ede6;
  background: rgba(255,255,255,0.06);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.lb-close:hover, .lb-nav:hover, .lb-star:hover { background: rgba(255,255,255,0.14); }

.lb-close { top: 18px; right: 18px; width: 42px; height: 42px; font-size: 1.6rem; }
.lb-star { top: 18px; right: 70px; width: 42px; height: 42px; font-size: 1.3rem; }
.lb-star.is-fav { color: var(--accent); }
.lb-nav { top: 50%; transform: translateY(-50%); width: 50px; height: 50px; font-size: 1.8rem; }
.lb-prev { left: 18px; }
.lb-next { right: 18px; }

.lb-caption {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text-dim);
  font-size: 0.8rem;
  letter-spacing: 0.03em;
}

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .nav-toggle { display: flex; align-items: center; justify-content: center; }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    z-index: 55;
    box-shadow: 20px 0 40px rgba(0,0,0,0.4);
    transition: transform 0.2s ease;
  }
  .sidebar.open { transform: translateX(0); }

  .main { padding: 70px 14px 50px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 3px; }
  .lb-nav { width: 40px; height: 40px; font-size: 1.4rem; }
  .lb-prev { left: 6px; }
  .lb-next { right: 6px; }
  .lb-star { right: 62px; width: 38px; height: 38px; }
  .lb-close { width: 38px; height: 38px; }
}
