* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f6f7f9;
  color: #202124;
  min-height: 100vh;
}

header {
  text-align: center;
  padding: 40px 20px 20px;
  background: #fff;
  border-bottom: 1px solid #e8eaed;
}
header h1 {
  font-size: 42px;
  font-weight: 300;
  letter-spacing: 1px;
  margin-bottom: 20px;
  color: #202124;
}
.add-album {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  background: #f1f3f4;
  padding: 6px 6px 6px 16px;
  border-radius: 24px;
  width: min(420px, 90%);
}
.add-album input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 15px;
  padding: 8px 0;
  outline: none;
  color: #202124;
}
.add-album button {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: #1a73e8;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  transition: background .2s;
}
.add-album button:hover { background: #1557b0; }

#albums-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}
.album-card {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  transition: transform .15s, box-shadow .15s;
}
.album-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
}
.album-card .preview {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.album-card .empty {
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e8eaed, #dadce0);
  font-size: 72px;
  color: #5f6368;
}
.album-card .title {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 24px 12px 12px;
  background: linear-gradient(transparent, rgba(0,0,0,.65));
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0,0,0,.4);
}

.album-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  background: #fff;
  border-bottom: 1px solid #e8eaed;
  flex-wrap: wrap;
}
.album-header h2 {
  font-size: 22px;
  font-weight: 400;
  flex: 1;
  min-width: 150px;
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid #dadce0;
  background: #fff;
  color: #202124;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s;
}
.btn:hover { background: #f1f3f4; }
.btn.primary { background: #1a73e8; color: #fff; border-color: #1a73e8; }
.btn.primary:hover { background: #1557b0; }
.btn.danger { background: #fff; color: #d93025; border-color: #f28b82; }
.btn.danger:hover { background: #fce8e6; }

#photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  padding: 16px;
  max-width: 1600px;
  margin: 0 auto;
}
.photo-item {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  background: #e8eaed;
}
.photo-item img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}
.photo-item .check {
  position: absolute;
  top: 8px; left: 8px;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: rgba(0,0,0,.3);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  user-select: none;
}
body.select-mode .photo-item .check { display: flex; }
body.select-mode .photo-item img { cursor: pointer; }
.photo-item .check.checked {
  background: #1a73e8;
  border-color: #1a73e8;
}
.photo-item .check.checked::after { content: "✓"; }

#selection-bar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #323232;
  color: #fff;
  padding: 10px 16px;
  border-radius: 24px;
  display: flex;
  gap: 10px;
  align-items: center;
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
  z-index: 100;
}
#selection-bar .btn {
  background: transparent;
  color: #fff;
  border-color: #5f6368;
}
#selection-bar .btn:hover { background: rgba(255,255,255,.1); }
#selection-bar .btn.danger { color: #f28b82; border-color: #f28b82; }
#selection-bar .btn.danger:hover { background: rgba(217,48,37,.2); }
#selection-count { font-size: 14px; padding: 0 8px; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #5f6368;
  font-size: 16px;
}

#lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.92);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: zoom-out;
}
#lightbox.open { display: flex; }
#lightbox img {
  max-width: 95%;
  max-height: 95%;
  object-fit: contain;
}

@media (max-width: 600px) {
  header h1 { font-size: 32px; }
  #albums-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 12px; }
  #photos-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 4px; padding: 8px; }
  .album-header { padding: 12px; }
  .album-header h2 { font-size: 18px; }
}