*,
*::before,
*::after {
  box-sizing: border-box;
}
:where(.grid, .flex) > * {
  min-width: 0;
}
:where(img, svg, video, canvas, iframe) {
  max-width: 100%;
  height: auto;
}

:root {
  --accent: #5b9dff;
  --accent-2: #8ab4ff;
  --bg-0: #0a0b0d;
  --bg-1: #121316;
  --bg-2: #1a1c20;
  --line: rgba(255, 255, 255, 0.08);
}
html,
body {
  background: var(--bg-0);
  color: #e9eaed;
}
body {
  font-family:
    -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Inter, Roboto, sans-serif;
  overflow-x: hidden;
}
::selection {
  background: var(--accent);
  color: #06121f;
}

.screen {
  min-height: 100vh;
}
.hidden-screen {
  display: none !important;
}

/* ---------- Login ---------- */
#screen-login {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-0);
  overflow: hidden;
}
#screen-login::before {
  content: '';
  position: absolute;
  inset: -10%;
  background:
    radial-gradient(circle at 18% 20%, rgba(91, 157, 255, 0.28), transparent 40%),
    radial-gradient(circle at 82% 15%, rgba(138, 180, 255, 0.2), transparent 45%),
    radial-gradient(circle at 50% 90%, rgba(43, 95, 217, 0.25), transparent 50%);
  filter: blur(60px);
}
.login-scrim {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at center,
    rgba(10, 11, 13, 0.35) 0%,
    rgba(10, 11, 13, 0.75) 65%,
    rgba(10, 11, 13, 0.94) 100%
  );
}
.login-card {
  position: relative;
  z-index: 2;
  width: min(400px, 92vw);
  background: rgba(20, 22, 26, 0.72);
  border: 1px solid var(--line);
  backdrop-filter: blur(20px);
  border-radius: 24px;
  padding: 2.5rem 2rem;
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.02) inset;
}
.brand-mark {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(155deg, var(--accent), #2b5fd9);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(91, 157, 255, 0.35);
}
.login-shake {
  animation: shake 0.4s;
}
@keyframes shake {
  10%,
  90% {
    transform: translateX(-1px);
  }
  20%,
  80% {
    transform: translateX(2px);
  }
  30%,
  50%,
  70% {
    transform: translateX(-4px);
  }
  40%,
  60% {
    transform: translateX(4px);
  }
}
.nas-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: #9aa1ad;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  padding: 4px 10px;
  border-radius: 999px;
}

/* ---------- Gallery ---------- */
#screen-gallery {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg-0);
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 20px;
  background: rgba(10, 11, 13, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.people-rail {
  position: sticky;
  top: 53px;
  z-index: 20;
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  overflow-x: auto;
  background: linear-gradient(180deg, rgba(10, 11, 13, 0.9), rgba(10, 11, 13, 0.75));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
}
.people-rail::-webkit-scrollbar {
  height: 6px;
}
.people-rail::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 99px;
}

.chip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 6px;
  border-radius: 999px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: #c7cad0;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  white-space: nowrap;
}
.chip:hover {
  border-color: rgba(91, 157, 255, 0.4);
  color: #fff;
  transform: translateY(-1px);
}
.chip.active {
  background: linear-gradient(155deg, var(--accent), #2b5fd9);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 18px rgba(91, 157, 255, 0.35);
}
.avatar-initial {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(155deg, var(--accent-2), #3a63b8);
  flex: 0 0 auto;
}
.chip .count {
  font-size: 11px;
  opacity: 0.75;
}
.chip.chip-all {
  padding-left: 14px;
}

.gallery-scroll {
  flex: 1;
  padding: 18px 20px 80px;
}
.month-heading {
  font-size: 15px;
  font-weight: 600;
  color: #eef0f3;
  margin: 26px 2px 10px;
  letter-spacing: 0.01em;
}
.month-heading:first-of-type {
  margin-top: 4px;
}
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 4px;
}
.photo-tile {
  position: relative;
  aspect-ratio: 1/1;
  overflow: hidden;
  border-radius: 8px;
  cursor: pointer;
  background: var(--bg-2);
}
.photo-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition:
    transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1),
    filter 0.35s;
}
.photo-tile:hover img {
  transform: scale(1.06);
}
.photo-tile .tile-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 60%, rgba(0, 0, 0, 0.55) 100%);
  opacity: 0;
  transition: opacity 0.2s;
}
.photo-tile:hover .tile-scrim {
  opacity: 1;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 90px 20px;
  color: #7d838f;
  text-align: center;
  gap: 10px;
}

/* ---------- Detail overlay ---------- */
#screen-detail {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(6, 7, 9, 0.97);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
#screen-detail.open {
  opacity: 1;
  pointer-events: auto;
}
.detail-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  flex: 0 0 auto;
  gap: 10px;
}
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  color: #e9eaed;
  cursor: pointer;
  transition: background 0.15s;
  flex: 0 0 auto;
}
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.topbar-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 14px 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  color: #c7cad0;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
  white-space: nowrap;
  text-decoration: none;
}
.topbar-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}
.detail-body {
  flex: 1;
  display: flex;
  min-height: 0;
}
.detail-stage {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 70px 24px;
  min-width: 0;
}
.detail-stage img {
  max-width: 100%;
  max-height: calc(100vh - 160px);
  border-radius: 6px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transform: scale(0.985);
  transition:
    opacity 0.25s ease,
    transform 0.25s ease;
}
.detail-stage img.show {
  opacity: 1;
  transform: none;
}
.nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #e9eaed;
  cursor: pointer;
  transition: background 0.15s;
}
.nav-arrow:hover {
  background: rgba(255, 255, 255, 0.16);
}
.nav-arrow.prev {
  left: 16px;
}
.nav-arrow.next {
  right: 16px;
}

.detail-panel {
  width: 320px;
  flex: 0 0 320px;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  padding: 6px 22px 30px;
}
@media (max-width: 860px) {
  .detail-body {
    flex-direction: column;
  }
  .detail-panel {
    width: 100%;
    flex: 0 0 auto;
    border-left: none;
    border-top: 1px solid var(--line);
  }
  .detail-stage {
    padding: 0 16px 12px;
  }
  .nav-arrow {
    display: none;
  }
}
.detail-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #7d838f;
  margin: 20px 0 10px;
}
.meta-row {
  display: flex;
  gap: 10px;
  font-size: 13.5px;
  color: #c7cad0;
  padding: 3px 0;
  line-height: 1.5;
}
.meta-row svg {
  flex: 0 0 auto;
  margin-top: 2px;
  color: #7d838f;
}
.person-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}
.person-row span {
  font-size: 13.5px;
  color: #e9eaed;
}

#screen-albums {
  position: fixed;
  inset: 0;
  z-index: 110;
  background: var(--bg-0);
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
#screen-albums.open {
  opacity: 1;
  pointer-events: auto;
}
.album-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border-radius: 14px;
  background: var(--bg-1);
  border: 1px solid var(--line);
}
.album-icon {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-2);
  color: #7d838f;
}
.album-row .album-name {
  font-size: 14px;
  font-weight: 600;
  color: #e9eaed;
}
.album-row .album-meta {
  font-size: 12px;
  color: #7d838f;
  margin-top: 2px;
}
.album-toggle {
  margin-left: auto;
  flex: 0 0 auto;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid var(--line);
}
.album-toggle .knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e9eaed;
  transition: transform 0.18s ease;
}
.album-toggle.on {
  background: linear-gradient(155deg, var(--accent), #2b5fd9);
  border-color: transparent;
}
.album-toggle.on .knob {
  transform: translateX(18px);
}
.album-row.excluded .album-icon {
  filter: grayscale(0.6) brightness(0.6);
}

.toast-wrap {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.toast-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(24, 26, 30, 0.95);
  border: 1px solid var(--line);
  color: #e9eaed;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13.5px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.25s ease;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
