* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #111;
  color: #eee;
}

.flashes {
  background: #b33;
  color: #fff;
  margin: 0;
  padding: 0.75rem 1rem;
  list-style: none;
}

/* --- login --- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 260px;
}
.login-form input, .login-form button {
  padding: 0.5rem;
  font-size: 1rem;
}

/* --- main nav --- */
.mainnav {
  display: flex;
  gap: 1rem;
  padding: 0.5rem 1rem;
  background: #1a1a1a;
  font-size: 0.9rem;
}
.mainnav a { color: #aaa; text-decoration: none; }
.mainnav a:hover { color: #fff; }

/* --- topbar --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  position: sticky;
  top: 0;
  background: #111;
  z-index: 10;
}
.filters { display: flex; gap: 0.5rem; align-items: center; }

/* --- full-page dropzone: sits behind content until dragging --- */
.dropzone {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(30, 120, 220, 0.35);
  border: 4px dashed #4a9eff;
  pointer-events: none;
}
.dropzone.active { display: flex; }
.dropzone-hint { font-size: 1.5rem; }

/* --- upload queue --- */
.upload-queue {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  width: 300px;
  max-height: 50vh;
  overflow-y: auto;
  background: #1c1c1c;
  border-radius: 8px;
  padding: 0.5rem;
  z-index: 500;
}
.upload-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid #333;
  font-size: 0.85rem;
}
.upload-item progress { width: 100%; }

/* --- share target result --- */
.share-result { padding: 1.5rem; max-width: 500px; }
.share-result ul { padding-left: 1.2rem; }
.share-result a { color: #4a9eff; }

/* --- file explorer --- */
.breadcrumbs {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  color: #aaa;
}
.breadcrumbs a { color: #4a9eff; text-decoration: none; }
.breadcrumbs span.sep { margin: 0 0.35rem; }

.file-list {
  padding: 0 1rem 2rem;
  display: flex;
  flex-direction: column;
}
.file-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.25rem;
  border-bottom: 1px solid #222;
}
.file-row .icon { width: 1.5rem; text-align: center; }
.file-row .name {
  flex: 1;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-row .name.dir { font-weight: 600; }
.file-row .size { color: #888; font-size: 0.85rem; width: 5rem; text-align: right; }
.file-row .actions { display: flex; gap: 0.35rem; }
.file-row .actions button {
  background: none;
  border: 1px solid #444;
  color: #ccc;
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
  cursor: pointer;
  font-size: 0.8rem;
}
.file-row .actions button:hover { background: #333; }

.row-check {
  display: none;
  width: 18px;
  height: 18px;
  min-width: 18px;
  border-radius: 4px;
  border: 2px solid #666;
}
.file-list.select-mode .row-check { display: block; }
.file-list.select-mode .actions { display: none; }
.file-row.selected { background: #1a2a44; }
.file-row.selected .row-check {
  background: #2a5db0;
  border-color: #2a5db0;
  position: relative;
}
.file-row.selected .row-check::after {
  content: "\2713";
  color: #fff;
  font-size: 0.7rem;
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- grid --- */
.grid { padding: 0 1rem 2rem; }
.month-group h2 {
  font-weight: 500;
  font-size: 1rem;
  color: #aaa;
  margin: 1.5rem 0 0.5rem;
}
.month-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 4px;
}
.thumb {
  aspect-ratio: 1;
  object-fit: cover;
  width: 100%;
  cursor: pointer;
  background: #222;
  display: block;
}
.thumb-wrap { position: relative; }
.thumb-check {
  display: none;
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: rgba(0, 0, 0, 0.45);
}
.grid.select-mode .thumb-check { display: block; }
.thumb-wrap.selected .thumb-check {
  background: #2a5db0;
  border-color: #2a5db0;
}
.thumb-wrap.selected .thumb-check::after {
  content: "\2713";
  color: #fff;
  font-size: 0.85rem;
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.thumb-wrap.selected .thumb {
  outline: 3px solid #2a5db0;
  outline-offset: -3px;
}

/* --- bulk action bar --- */
.bulk-bar {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #1c1c1c;
  border: 1px solid #333;
  border-radius: 999px;
  padding: 0.6rem 1rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}
.bulk-count { color: #aaa; font-size: 0.9rem; }
.bulk-bar button {
  background: #2a2a2a;
  border: 1px solid #444;
  color: #eee;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.85rem;
}
.bulk-bar button:hover { background: #333; }
.bulk-bar button.bulk-danger { background: #6b1f1f; border-color: #8a2c2c; }
.bulk-bar button.bulk-danger:hover { background: #7c2424; }
.bulk-bar .album-panel-up {
  bottom: calc(100% + 0.5rem);
  top: auto;
  left: 50%;
  right: auto;
  transform: translateX(-50%);
}

#select-mode-toggle.active { background: #2a5db0; border-color: #2a5db0; color: #fff; }

/* --- lightbox: own stacking context, above everything else --- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
}
/* [hidden] and .lightbox both have specificity (0,1,0); without this the
   later author rule's `display: flex` wins over the UA's `display: none`,
   so the hidden attribute alone does nothing here. */
.lightbox[hidden] {
  display: none;
}
.lightbox img, .lightbox video {
  max-width: 90vw;
  max-height: 90vh;
}
.lightbox-close, .lightbox-delete, .lightbox-album, .lightbox-prev, .lightbox-next {
  position: absolute;
  background: none;
  border: none;
  color: #fff;
  font-size: 2.5rem;
  cursor: pointer;
  z-index: 2001;
}
.lightbox-close { top: 1rem; right: 1.5rem; }
.lightbox-delete { top: 1rem; right: 4.5rem; font-size: 1.6rem; }
.lightbox-album { top: 1rem; right: 7.5rem; font-size: 1.6rem; }
.lightbox-prev { left: 1rem; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 1rem; top: 50%; transform: translateY(-50%); }

/* --- add-to-album panel (lightbox) --- */
.album-panel {
  position: absolute;
  top: 4.5rem;
  right: 1.5rem;
  z-index: 2002;
  width: 240px;
  background: #1c1c1c;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 0.75rem;
  font-size: 0.9rem;
}
.album-panel-header { color: #aaa; margin-bottom: 0.5rem; }
.album-panel-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 0.5rem;
}
.album-panel-item {
  text-align: left;
  background: #222;
  border: none;
  color: #eee;
  padding: 0.4rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
}
.album-panel-item:hover { background: #2c2c2c; }
.album-panel-empty { color: #666; }
.album-panel-new { display: flex; gap: 0.35rem; border-top: 1px solid #333; padding-top: 0.5rem; }
.album-panel-new input {
  flex: 1;
  min-width: 0;
  background: #111;
  border: 1px solid #333;
  color: #eee;
  padding: 0.3rem 0.4rem;
  border-radius: 4px;
}
.album-panel-new button {
  background: #2a5db0;
  border: none;
  color: #fff;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
}

/* --- albums grid --- */
.album-grid {
  padding: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}
.album-card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  color: inherit;
  text-decoration: none;
}
.album-cover {
  aspect-ratio: 1;
  background: #1c1c1c;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  font-size: 0.85rem;
}
.album-cover img { width: 100%; height: 100%; object-fit: cover; }
.album-cover-empty { border: 1px dashed #333; }
.album-meta { display: flex; flex-direction: column; }
.album-name { font-weight: 500; }
.album-count { font-size: 0.8rem; color: #888; }

.album-card-new {
  border: 1px dashed #444;
  border-radius: 8px;
  padding: 0.75rem;
  justify-content: center;
}
.album-name-input, .album-name-input-inline {
  background: #111;
  border: 1px solid #333;
  color: #eee;
  padding: 0.4rem;
  border-radius: 4px;
  font-size: 1rem;
}
.album-name-input-inline {
  font-size: inherit;
  font-weight: inherit;
  padding: 0.1rem 0.3rem;
}
.album-card-new-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.album-card-new-actions button {
  background: #222;
  border: 1px solid #444;
  color: #eee;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
}

.album-back { color: #4a9eff; text-decoration: none; margin-right: 0.5rem; }
