/* The Library, albums, a photo, and Settings: ordinary scrolling pages in the page theme. */

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: calc(8px + var(--safe-top)) calc(16px + var(--safe-right)) calc(32px + var(--safe-bottom)) calc(16px + var(--safe-left));
  min-height: 100vh;
  outline: none;
}
.page.has-bar {
  padding-bottom: calc(96px + var(--safe-bottom));
}
.page.drop-target {
  outline: 3px dashed var(--accent);
  outline-offset: -8px;
  border-radius: 16px;
}

.page-head {
  padding: 4px 0 16px;
}
.page-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 52px;
}
.page-head h1 {
  font-size: clamp(1.7rem, 4vw, 2.3rem);
  letter-spacing: -0.02em;
  margin: 6px 0 4px;
  overflow-wrap: anywhere;
}
.page-sub {
  color: var(--muted);
  margin: 0;
}
.page-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.back-btn {
  padding-left: 6px;
  margin-left: -6px;
  color: var(--accent);
}
@media (max-width: 480px) {
  .page-actions .btn span {
    display: none;
  }
  .page-actions .btn {
    padding: 8px 12px;
  }
}

/* ---- Albums ---- */
.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 18px 14px;
}
.album-card {
  display: grid;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
  text-align: left;
  cursor: pointer;
}
.album-cover {
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  color: var(--muted);
  box-shadow: var(--shadow);
}
.album-cover > img,
.album-cover > canvas,
.album-cover > .thumb-missing {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.album-new .album-cover {
  border: 2px dashed var(--line);
  box-shadow: none;
  background: transparent;
  color: var(--accent);
}
.album-card:hover .album-cover {
  filter: brightness(0.95);
}
.album-meta {
  display: grid;
}
.album-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.album-count {
  color: var(--muted);
  font-size: 0.85rem;
}
.album-empty-cover {
  opacity: 0.6;
}

/* ---- Photo grid ---- */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 4px;
}
@media (min-width: 900px) {
  .photo-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}
.photo-tile {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--surface-2);
  border: 0;
  padding: 0;
  display: block;
  cursor: pointer;
  color: inherit;
  border-radius: 4px;
}
.photo-tile .thumb-img,
.photo-tile canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  max-width: none;
}
.thumb-missing {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  text-align: center;
  padding: 6px;
}
.tile-badge {
  position: absolute;
  right: 6px;
  bottom: 6px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
}
.tile-badge-left {
  right: auto;
  left: 6px;
}
.tile-check {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: rgba(0, 0, 0, 0.25);
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}
.photo-tile.picked .tile-check {
  background: var(--accent);
  border-color: #fff;
}
.photo-tile.picked .thumb-img {
  opacity: 0.75;
}
.photo-tile.picked::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 3px solid var(--accent);
  border-radius: 4px;
}
.flag-grid {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.flag-tile {
  aspect-ratio: 3 / 2;
  border-radius: var(--radius-sm);
}
.flag-tile.off canvas {
  opacity: 0.25;
  filter: grayscale(1);
}
.flag-name {
  position: absolute;
  left: 8px;
  top: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
}

.select-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(14px + var(--safe-bottom));
  width: min(900px, calc(100% - 24px));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  z-index: 10;
}
.select-count {
  font-weight: 700;
  margin-right: auto;
  padding-left: 4px;
}
@media (max-width: 600px) {
  .select-bar .btn span {
    display: none;
  }
  .select-bar .btn-ghost span {
    display: inline;
  }
}

/* ---- One photo ---- */
.photo-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  grid-template-rows: auto 1fr;
  gap: 0 24px;
}
.viewer-head {
  grid-column: 1 / -1;
}
.viewer-pos {
  color: var(--muted);
  font-size: 0.9rem;
  margin-left: auto;
}
.viewer {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  min-height: 300px;
  height: calc(100vh - 120px);
  max-height: 900px;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.viewer-media {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}
.viewer-img,
.viewer-video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.viewer.focusing .viewer-media {
  cursor: crosshair;
}
.focus-dot {
  position: absolute;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}
.viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 0;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.viewer-nav.prev {
  left: 10px;
}
.viewer-nav.next {
  right: 10px;
}
.viewer-missing {
  color: #ddd;
  text-align: center;
  padding: 24px;
  max-width: 420px;
  display: grid;
  justify-items: center;
  gap: 8px;
}
.photo-side {
  min-width: 0;
}
.photo-title {
  font-size: 1.3rem;
  overflow-wrap: anywhere;
  margin-top: 8px;
}
.details {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  margin: 0 0 16px;
  font-size: 0.92rem;
}
.details dt {
  color: var(--muted);
}
.details dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.album-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip-add {
  color: var(--accent);
}
.danger-row {
  margin-top: 16px;
}
@media (max-width: 860px) {
  .photo-page {
    grid-template-columns: 1fr;
  }
  .viewer {
    height: 60vh;
  }
}

/* ---- Settings ---- */
.set-nav {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin: 0 -4px 12px;
  scrollbar-width: none;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 2;
  padding-top: calc(6px + var(--safe-top));
}
.set-nav a {
  flex: none;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
}
.set-cards {
  display: grid;
  gap: 16px;
  max-width: 760px;
}
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  scroll-margin-top: 64px;
}
.card h2 {
  font-size: 1.15rem;
}
.set-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 0;
}
.set-line-text {
  display: grid;
  gap: 2px;
  flex: 1 1 200px;
}
.set-line-control {
  flex: 0 1 auto;
  max-width: 100%;
}
.set-line-control select.input {
  min-width: 220px;
}
.city-list {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
  display: grid;
  gap: 4px;
}
.city-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 4px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}
.city-name {
  flex: 1;
  font-weight: 600;
}
.city-actions {
  display: flex;
}
.keys {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
  margin: 0;
  align-items: center;
}
.keys dd {
  margin: 0;
}
.sync-devices {
  list-style: none;
  padding: 0;
  margin: 12px 0;
  display: grid;
  gap: 6px;
}
.sync-devices li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 8px 8px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}
.sync-device-info {
  display: grid;
}
.sync-devices-host {
  margin: 8px 0;
}
