/* ===== LUXIE GALLERY — Clean Customer Experience CSS ===== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg-primary: #fafafa;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f5f5f5;
  --text-primary: #171717;
  --text-secondary: #525252;
  --text-muted: #a3a3a3;
  --accent: #2563eb;
  --accent-light: #eff6ff;
  --border: #e5e5e5;
  --border-light: #e5e5e5;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --gap: 2px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --lightbox-action-bar-bottom: 88px;
  --lightbox-action-bar-height: 44px;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
}

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

/* ===== LOADING SCREEN ===== */
.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  gap: 20px;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.loading-screen.hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-light);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* ===== PASSWORD MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  padding: 24px;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-md);
}

.modal-icon { font-size: 48px; margin-bottom: 16px; }
.modal-card h2 { font-size: 1.25rem; font-weight: 600; margin-bottom: 8px; }
.modal-card p { color: var(--text-secondary); font-size: 0.875rem; margin-bottom: 24px; }

#password-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  margin-bottom: 16px;
}

#password-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.btn-primary:hover { background: #1765cc; }
.btn-primary:active { transform: scale(0.98); }
.btn-secondary {
  width: 100%;
  padding: 12px;
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.btn-secondary:hover { background: var(--bg-surface-hover); border-color: #d4d4d4; }
.btn-secondary:active { transform: scale(0.98); }
.error-text { color: #d93025; font-size: 0.8125rem; margin-top: 12px; }

.album-save-modal-overlay {
  background: rgba(15, 23, 42, 0.28);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 99999;
}

.album-save-modal {
  max-width: 420px;
  width: min(420px, calc(100vw - 24px));
  text-align: left;
}

.album-save-modal h2 {
  margin-bottom: 8px;
}

.album-save-modal p {
  margin-bottom: 16px;
}

.album-save-list {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.album-download-scope-list {
  display: grid;
  gap: 10px;
  margin: 0 0 16px;
}

.album-download-scope-choice {
  width: 100%;
  min-height: 64px;
  padding: 12px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  display: grid;
  gap: 4px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

.album-download-scope-choice.is-selected {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.15);
}

.album-download-scope-choice:disabled,
.album-download-scope-choice[aria-disabled="true"] {
  cursor: not-allowed;
  border-color: #fecaca;
  background: #fff7f7;
  color: #991b1b;
  opacity: 1;
}

.album-download-scope-choice:disabled .album-download-scope-choice-detail,
.album-download-scope-choice[aria-disabled="true"] .album-download-scope-choice-detail {
  color: #b91c1c;
}

.album-download-scope-choice:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.24);
  outline-offset: 2px;
}

.album-download-scope-choice-title {
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.35;
}

.album-download-scope-choice-detail {
  color: var(--text-muted);
  font-size: 0.76rem;
  line-height: 1.4;
}

.album-save-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
}

.album-save-row-text {
  min-width: 0;
}

.album-save-row-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  word-break: break-word;
}

.album-save-row-meta {
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.album-save-row-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.album-save-row-badge-photos {
  background: #eff6ff;
  color: #1d4ed8;
}

.album-save-row-badge-zip {
  background: #f5f3ff;
  color: #6d28d9;
}

.album-save-row-badge-videos {
  background: #ecfeff;
  color: #0f766e;
}

.album-save-row-badge-ios-manual {
  background: #fff7ed;
  color: #c2410c;
}

.album-video-download-list {
  display: grid;
  gap: 10px;
  margin: -2px 0 16px;
  max-height: min(320px, 42vh);
  overflow-y: auto;
}

.album-video-download-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
}

.album-video-download-row.is-downloaded {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.album-video-download-text {
  min-width: 0;
}

.album-video-download-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  word-break: break-word;
}

.album-video-download-meta {
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.album-video-download-btn {
  width: auto;
  min-width: 92px;
  padding: 10px 12px;
  justify-self: end;
}

.album-video-safari-note {
  margin: -2px 0 12px;
  padding: 12px 14px;
  border: 1px solid #dbeafe;
  border-radius: var(--radius-sm);
  background: #eff6ff;
  color: #1e3a8a;
}

.album-video-safari-note-title {
  font-size: 0.8125rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.album-video-safari-note ol {
  margin: 0;
  padding-left: 18px;
  font-size: 0.8125rem;
  line-height: 1.5;
}

.album-video-safari-copy-btn {
  margin-bottom: 12px;
}

.album-save-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.album-save-modal.is-photo-share .album-save-actions {
  grid-template-columns: minmax(128px, 0.9fr) minmax(0, 1.1fr);
}

.album-save-modal.is-photo-share .album-save-actions > button {
  padding-inline: 10px;
  white-space: nowrap;
}

@media (max-width: 359px) {
  .album-save-modal.is-photo-share .album-save-actions {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }
}

.album-save-actions[hidden] {
  display: none;
}

.album-save-actions-single {
  grid-template-columns: minmax(0, 1fr);
  width: calc(50% - 5px);
  margin-inline: auto;
}

.album-save-modal.is-passive-progress .album-save-status {
  margin-bottom: 0;
}

.album-save-error {
  margin-bottom: 12px;
}

.album-save-status {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 8px 10px;
  margin-bottom: 16px;
  padding: 12px;
  border-radius: 12px;
  background: #eff6ff;
  color: #1d4ed8;
}

.album-save-status[hidden] {
  display: none;
}

.album-save-status[data-tone="success"] {
  background: #ecfdf5;
  color: #047857;
}

.album-save-modal.is-photo-share .album-save-status[data-tone="success"] {
  margin-bottom: 12px;
  padding-block: 10px;
}

.album-save-status[data-tone="warning"] {
  background: #fff7ed;
  color: #c2410c;
}

.album-save-status[data-tone="error"] {
  background: #fef2f2;
  color: #b91c1c;
}

.album-save-status-icon {
  margin-top: 1px;
  font-size: 20px;
  font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 20;
}

.album-save-status-copy {
  min-width: 0;
}

.album-save-status-title {
  color: currentColor;
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.4;
}

.album-save-status-detail {
  margin-top: 3px;
  color: #334155;
  font-size: 0.75rem;
  font-weight: 450;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.album-save-status-progress-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.album-save-status-progress-row[hidden] {
  display: none;
}

.album-save-status-progress {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.2);
}

.album-save-status-progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: currentColor;
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.album-save-status-progress-value {
  min-width: 3ch;
  color: currentColor;
  font-size: 0.6875rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-align: right;
}

/* ===== ERROR SCREEN ===== */
.error-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  padding: 24px;
  text-align: center;
  gap: 12px;
}

.error-icon { margin-bottom: 8px; color: var(--text-muted); }
.error-icon .material-symbols-outlined { font-size: 48px; }
.error-screen h2 { font-size: 1.25rem; font-weight: 600; }
.error-screen p { color: var(--text-secondary); font-size: 0.875rem; }

/* ===== TOP APP BAR ===== */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.top-bar-title {
  font-size: clamp(1.34rem, 1.2rem + 0.45vw, 1.72rem);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.04em;
  line-height: 1.08;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-rendering: optimizeLegibility;
}

/* ===== BREADCRUMB NAVIGATION (Desktop) ===== */
.breadcrumb-nav {
  display: none; /* hidden on mobile */
  align-items: center;
  gap: 6px;
  font-size: 0.9375rem;
  font-weight: 400;
  color: var(--text-secondary);
  letter-spacing: -0.015em;
  line-height: 1.2;
  min-width: 0;
  overflow: hidden;
}
.breadcrumb-nav.active {
  display: flex;
}
.breadcrumb-item {
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
  text-decoration: none;
  flex-shrink: 0;
}
.breadcrumb-item:hover {
  color: var(--accent);
  background: var(--accent-light);
}
.breadcrumb-item.current {
  color: var(--text-primary);
  font-weight: 600;
  letter-spacing: -0.02em;
  cursor: default;
  pointer-events: none;
}
.breadcrumb-sep {
  color: var(--text-muted);
  font-size: 0.8125rem;
  flex-shrink: 0;
  user-select: none;
  transform: translateY(-0.5px);
}
/* Desktop: show breadcrumb, hide title when breadcrumb active */
@media (min-width: 768px) {
  .breadcrumb-nav.active ~ .top-bar-title,
  .top-bar-left:has(.breadcrumb-nav.active) > .top-bar-title {
    display: none;
  }
  .breadcrumb-nav.active {
    display: flex;
  }
}
/* Mobile: always show title, hide breadcrumb */
@media (max-width: 767px) {
  .breadcrumb-nav {
    display: none !important;
  }
}

/* ===== SEARCH BAR ===== */
.search-container {
  display: flex;
  align-items: center;
  position: relative;
}
.search-input {
  width: 0;
  opacity: 0;
  padding: 0;
  border: none;
  outline: none;
  font-size: 0.875rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text-primary);
  border-radius: 8px;
  transition: width 0.22s ease, opacity 0.22s ease, padding 0.22s ease;
}
.search-container.active .search-input {
  width: 200px;
  opacity: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
}
.search-container.active .search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}
.search-clear {
  width: 32px;
  height: 32px;
}
@media (max-width: 767px) {
  .search-container.active .search-input {
    width: 140px;
  }
  .search-container.active ~ .top-bar-meta {
    display: none;
  }
  .top-bar.search-mode .top-bar-title,
  .top-bar.search-mode #btn-download-current-folder,
  .top-bar.search-mode #btn-share,
  .top-bar.search-mode #btn-login,
  .top-bar.search-mode #user-avatar,
  .top-bar.search-mode .top-bar-meta,
  .top-bar.search-mode #btn-search {
    display: none !important;
  }
  .top-bar.search-mode .top-bar-left {
    flex: 0 0 auto;
    gap: 4px;
  }
  .top-bar.search-mode .top-bar-right {
    flex: 1;
    min-width: 0;
    gap: 0;
    justify-content: flex-end;
  }
  .top-bar.search-mode .search-container {
    flex: 1;
    min-width: 0;
    justify-content: flex-end;
  }
  .top-bar.search-mode .search-container.active .search-input {
    width: 100%;
    min-width: 0;
    flex: 1 1 auto;
  }
}

/* Search highlight on album cards */
.album-card.search-hidden {
  display: none !important;
}
.grid-item.search-hidden {
  display: none !important;
}
.search-no-results {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-secondary);
  font-size: 0.9375rem;
}
.search-no-results .material-symbols-outlined {
  font-size: 3rem;
  display: block;
  margin-bottom: 0.5rem;
  opacity: 0.4;
}

.top-bar-right {
  flex-shrink: 0;
}

.top-bar-meta {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.icon-btn:hover { background: var(--bg-surface-hover); }
.icon-btn .material-symbols-outlined { font-size: 24px; }

.download-current-folder-btn {
  width: auto;
  min-width: 44px;
  padding: 0 11px;
  gap: 5px;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
}

.download-current-folder-label {
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

#btn-back {
  width: 36px;
  height: 36px;
  margin-left: 2px;
  margin-right: 2px;
  color: #5f5f5f;
}

#btn-back .material-symbols-outlined {
  font-size: 23px;
  font-variation-settings: 'FILL' 0, 'wght' 250, 'GRAD' 0, 'opsz' 24;
  transform: translateX(1.5px);
}

/* ===== ALBUM GRID ===== */
.album-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 16px;
  max-width: 1200px;
  margin: 0 auto;
}

.album-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.22s cubic-bezier(0.22, 0.9, 0.3, 1),
              box-shadow 0.22s cubic-bezier(0.22, 0.9, 0.3, 1),
              border-color var(--transition-fast);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.album-card-actions {
  position: static;
  display: flex;
  align-items: center;
  align-self: end;
  justify-self: end;
  gap: 6px;
  transform: none;
}

.album-card-share-btn,
.album-card-download-btn {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.68);
  backdrop-filter: blur(10px) saturate(1.05);
  color: rgba(64, 64, 64, 0.82);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  transition: background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast), color var(--transition-fast), transform var(--transition-fast), opacity var(--transition-fast);
}

.grid-item-share-btn {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.68);
  backdrop-filter: blur(10px) saturate(1.05);
  color: rgba(64, 64, 64, 0.82);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  transition: background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast), color var(--transition-fast), transform var(--transition-fast), opacity var(--transition-fast);
  z-index: 3;
}

.album-card-share-btn:hover,
.album-card-download-btn:hover,
.grid-item-share-btn:hover {
  background: rgba(255, 255, 255, 0.86);
  border-color: rgba(255, 255, 255, 0.9);
  color: rgba(38, 38, 38, 0.9);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.album-card-share-btn:active,
.album-card-download-btn:active,
.grid-item-share-btn:active {
  transform: scale(0.96);
}

.album-card-share-btn:disabled,
.album-card-download-btn:disabled {
  cursor: wait;
  opacity: 0.55;
}

.album-card-download-btn {
  width: auto;
  min-width: 58px;
  padding: 0 9px;
  gap: 3px;
  background: #eff6ff;
  border-color: #dbeafe;
  color: #1d4ed8;
}

.album-card-download-btn .material-symbols-outlined {
  font-size: 18px;
}

.album-card-download-label {
  font-size: 0.7rem;
  font-weight: 700;
}

.album-card-share-btn .material-symbols-outlined {
  font-size: 18px;
  font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 24;
}

.grid-item-share-btn .material-symbols-outlined {
  font-size: 14.4px;
  font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 24;
}

@keyframes share-button-pop {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(0.9);
  }
  72% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes share-icon-pop {
  0% {
    transform: scale(1) rotate(0deg);
  }
  40% {
    transform: scale(0.82) rotate(-8deg);
  }
  72% {
    transform: scale(1.12) rotate(6deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
  }
}

.share-feedback-active {
  animation: share-button-pop 320ms cubic-bezier(0.22, 0.9, 0.3, 1);
}

.icon-btn.share-feedback-active,
.lightbox-icon-btn.share-feedback-active {
  background: rgba(16, 185, 129, 0.12);
}

.album-card-share-btn.share-feedback-active,
.grid-item-share-btn.share-feedback-active {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(255, 255, 255, 0.95);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
}

.share-feedback-active .material-symbols-outlined {
  animation: share-icon-pop 320ms cubic-bezier(0.22, 0.9, 0.3, 1);
}

.album-card:hover { border-color: #d4d4d4; box-shadow: var(--shadow-sm); }
.album-card:active { transform: scale(0.98); }

.album-card-thumb {
  aspect-ratio: 4/3;
  width: 100%;
  object-fit: cover;
  background: var(--bg-primary);
  transition: transform 0.28s cubic-bezier(0.22, 0.9, 0.3, 1);
}
.album-card-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--surface) 100%);
}
.album-card-placeholder .placeholder-logo {
  width: 48px;
  height: auto;
  opacity: 0.25;
  object-fit: contain;
}

.album-card-info {
  position: relative;
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  min-height: 58px;
  padding: 11px 12px 12px;
}

.album-card-info.has-actions {
  padding-right: 12px;
}

.album-card-copy {
  min-width: 0;
}

.album-card-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 3px;
  line-height: 1.18;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.album-card-count {
  font-size: 0.75rem;
  line-height: 1.2;
  color: var(--text-muted);
}

@media (hover: hover) and (pointer: fine) {
  .album-card:hover {
    transform: translateY(-3px);
    border-color: #d4d4d4;
    box-shadow: 0 12px 28px rgba(23, 23, 23, 0.07), 0 3px 10px rgba(23, 23, 23, 0.05);
  }

  .album-card:hover .album-card-thumb {
    transform: scale(1.02);
  }
}

@media (prefers-reduced-motion: reduce) {
  .album-card,
  .album-card-thumb {
    transition: none;
  }

  .album-card:hover,
  .album-card:hover .album-card-thumb {
    transform: none;
  }
}

/* ===== EMPTY STATE & FOOTER ===== */
.empty-state { text-align: center; padding: 80px 24px; }
.empty-icon { font-size: 48px; color: var(--text-muted); margin-bottom: 20px; display: block; opacity: 0.5; }
.empty-state h3 { font-size: 1.125rem; font-weight: 600; margin-bottom: 8px; color: var(--text-secondary); }
.empty-state p { color: var(--text-muted); font-size: 0.875rem; }

.gallery-footer {
  text-align: center;
  padding: 32px 16px calc(var(--safe-bottom) + 32px);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.gallery-footer a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
}

.gallery-footer a:hover { color: var(--accent); }

/* ===== PHOTO GRID — Clean 3 Column ===== */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 24px 16px calc(var(--safe-bottom) + 16px);
  max-width: 1200px;
  margin: 0 auto;
}

.photo-grid-spacer {
  grid-column: 1 / -1;
  width: 100%;
  pointer-events: none;
}

.grid-item {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--bg-primary);
  cursor: pointer;
  border-radius: 8px;
  content-visibility: auto;
  contain-intrinsic-size: 180px 180px;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.grid-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease, opacity 0.3s ease;
  -webkit-touch-callout: none; /* Prevent long-press save (low quality) */
  pointer-events: none; /* Context menu targets div, not img */
}

.grid-item img.loading { opacity: 0; }
.grid-item img.loaded { opacity: 1; }
.grid-item:active img { transform: scale(0.96); }

.grid-item-filename {
  position: absolute;
  left: 50%;
  bottom: 7px;
  max-width: min(72%, calc(100% - 72px));
  transform: translateX(-50%);
  z-index: 2;
  padding: 3px 8px 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.42);
  color: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px) saturate(1.08);
  -webkit-backdrop-filter: blur(8px) saturate(1.08);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.14);
  font-size: clamp(0.56rem, 0.48rem + 0.18vw, 0.68rem);
  font-weight: 560;
  line-height: 1.15;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

/* Shimmer placeholder */
.grid-item::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, var(--bg-primary) 8%, var(--bg-surface) 18%, var(--bg-primary) 33%);
  background-size: 200% 100%;
  animation: shimmer 1.5s linear infinite;
  z-index: 0;
}

.grid-item.loaded::before { display: none; }

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.grid-item.video-placeholder {
  background: #141414;
}

.grid-item.video-placeholder::after {
  content: 'play_circle';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: 'Material Symbols Outlined';
  font-size: 40px;
  color: rgba(255, 255, 255, 0.88);
  z-index: 1;
}

.grid-item-top-row {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 3;
}

/* Video badge */
.grid-item .video-badge {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  color: white;
  font-size: 0.625rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  z-index: 2;
  text-transform: uppercase;
  pointer-events: none;
}

/* Responsive */
@media (min-width: 600px) {
  .photo-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 20px 16px 32px; }
  .album-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; padding: 16px 24px; }
  .top-bar { padding: calc(var(--safe-top) + 16px) 24px 16px; }
}

@media (min-width: 1024px) {
  .photo-grid { grid-template-columns: repeat(6, 1fr); gap: 8px; padding: 20px 20px 48px; }
  .album-grid { grid-template-columns: repeat(4, 1fr); }
  .grid-item:hover img { transform: scale(1.03); }
}

/* ===== LIGHTBOX — Immersive Photo Viewer ===== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: transparent;
  animation: lightbox-in 0.25s ease;
  -webkit-user-select: none;
  user-select: none;
  --lightbox-dismiss-overlay-opacity: 1;
  --lightbox-dismiss-transition-duration: 180ms;
  --lightbox-dismiss-transition-easing: cubic-bezier(0.22, 0.9, 0.3, 1);
}

.lightbox::before {
  content: '';
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: var(--lightbox-dismiss-overlay-opacity, 1);
  pointer-events: none;
  z-index: 0;
  will-change: opacity;
}

.lightbox.lightbox-opening-fallback::before {
  opacity: 0;
}

.lightbox.lightbox-opening-settle::before {
  transition: opacity 120ms ease;
}

@keyframes lightbox-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Main image — fills ALL space above thumbnail strip */
.lightbox-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: calc(88px + var(--safe-bottom)); /* Space for thumbnail strip (64px thumbs + padding + safe area) */
  display: grid;
  grid-template-rows: 100%;
  grid-template-columns: 100%;
  place-items: center;
  touch-action: none;
  overflow: hidden;
  cursor: pointer;
  z-index: 1;
  transform: translate3d(0, 0, 0);
  will-change: transform;
  backface-visibility: hidden;
}

.lightbox.lightbox-dismiss-animating::before {
  transition: opacity var(--lightbox-dismiss-transition-duration, 180ms) linear;
}

.lightbox.lightbox-dismiss-animating .lightbox-container {
  transition: transform var(--lightbox-dismiss-transition-duration, 180ms) var(--lightbox-dismiss-transition-easing, cubic-bezier(0.22, 0.9, 0.3, 1));
}

.lightbox.lightbox-vertical-dismissing .lightbox-header,
.lightbox.lightbox-vertical-dismissing .action-bar,
.lightbox.lightbox-vertical-dismissing .lightbox-nav,
.lightbox.lightbox-vertical-dismissing .thumbnail-strip,
.lightbox.lightbox-vertical-dismissing .exif-panel {
  display: none !important;
}

.lightbox-img {
  /* CSS Grid stacking: both images share same grid cell, centered naturally */
  grid-area: 1 / 1;
  max-width: 100%;
  max-height: 100%;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: default; /* Allow iOS long-press "Save to Photos" */
  transform-origin: center center;
  will-change: transform;
}

.lightbox-img-thumb {
  z-index: 1;
}

.lightbox-swipe-preview {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 1;
  display: none;
  pointer-events: none;
  /* Keep the incoming page above the old owning layer until that layer has
     decoded the same photo; otherwise a fast swipe ends with a visible hard cut. */
  z-index: 2;
  transform-origin: center center;
  will-change: transform;
}

.lightbox-swipe-preview.is-active {
  display: block;
}

/* When zoomed in, remove CSS size constraints so browser renders native pixels */
.lightbox-img.zoomed {
  max-width: none;
  max-height: none;
  object-fit: fill; /* Explicit dimensions set by JS, no re-constraining */
}

/* HighRes layer sits on top of thumbnail */
.lightbox-img-highres {
  z-index: 1;
  will-change: transform, opacity;
}

.lightbox-video {
  grid-area: 1 / 1;
  z-index: 2;
  max-width: 100%;
  max-height: 100%;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  outline: none;
  touch-action: manipulation;
}

.lightbox-container.has-video {
  cursor: default;
  touch-action: manipulation;
}

.lightbox.lightbox-video-mode::before {
  background: #000;
}

.lightbox.lightbox-video-mode .action-bar {
  display: none !important;
}

.lightbox.lightbox-video-mode .lightbox-header {
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.78) 0%, rgba(0, 0, 0, 0.34) 56%, transparent 100%);
}

.lightbox.lightbox-video-mode .lightbox-album-name,
.lightbox.lightbox-video-mode .lightbox-counter {
  color: rgba(255, 255, 255, 0.7);
}

.lightbox.lightbox-video-mode .lightbox-photo-name {
  color: #fff;
}

.lightbox.lightbox-video-mode #btn-close,
.lightbox.lightbox-video-mode #btn-lightbox-share,
.lightbox.lightbox-video-mode #btn-download {
  color: #fff;
}

.lightbox.lightbox-video-mode #btn-close:hover,
.lightbox.lightbox-video-mode #btn-lightbox-share:hover,
.lightbox.lightbox-video-mode #btn-download:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* Top bar — auto-hide on tap */
.lightbox-header {
  --lightbox-ui-base-opacity: 1;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 6px) 8px 10px;
  z-index: 20;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.6) 50%, transparent 100%);
  opacity: var(--lightbox-ui-base-opacity, 1);
  transition: opacity var(--transition-normal), transform var(--transition-normal);
  will-change: opacity;
}

.lightbox-header.hidden {
  --lightbox-ui-base-opacity: 0;
  opacity: 0;
  transform: translateY(-20px);
  pointer-events: none;
}

.lightbox-header-left,
.lightbox-header-right {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

/* Absolute center so it stays centered regardless of left/right widths */
.lightbox-header-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: calc(var(--safe-top) + 6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: none;
}

.lightbox-album-name {
  font-size: 0.6875rem;
  color: var(--text-muted);
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  text-align: center;
  letter-spacing: 0.02em;
}

.lightbox-photo-name {
  font-size: 0.8125rem;
  color: var(--text-primary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  text-align: center;
}

.lightbox-counter {
  font-size: 0.6875rem;
  color: var(--text-muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* ===== ACTION BAR — bottom floating controls ===== */
.action-bar {
  --lightbox-ui-base-opacity: 1;
  position: absolute;
  bottom: calc(var(--lightbox-action-bar-bottom) + var(--safe-bottom));
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 15;
  padding: 4px 0;
  pointer-events: none;
  transform: translateY(0);
  opacity: var(--lightbox-ui-base-opacity, 1);
  transition: opacity var(--transition-normal), transform var(--transition-normal);
  will-change: opacity;
}

.action-bar.hidden {
  --lightbox-ui-base-opacity: 0;
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
}

.action-bar > * {
  pointer-events: auto;
  min-width: 0;
}

.lightbox-rating {
  display: flex;
  align-items: center;
  gap: 1px;
  min-height: 36px;
  padding: 4px 10px 4px 8px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  box-sizing: border-box;
}

.rating-star {
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 26px;
}

.rating-star .material-symbols-outlined {
  font-size: 22px;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 22;
  color: #d4d4d4;
}

.rating-star.active .material-symbols-outlined {
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 22;
  color: #404040;
}

.rating-clear {
  margin-right: 4px;
  border-right: 1px solid var(--border);
  padding-right: 8px;
}

.rating-clear .material-symbols-outlined {
  font-size: 20px;
  color: var(--text-muted) !important;
  opacity: 0.6;
}

.rating-star:hover {
  transform: scale(1.15);
}

.rating-star:active {
  transform: scale(0.9);
}

/* ===== FILTER BAR — Photo Mechanic compact style ===== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 4px 5px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.filter-bar-label {
  font-size: 0.675rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0 4px;
  white-space: nowrap;
}

.filter-sync-status {
  display: none;
  align-items: center;
  min-height: 24px;
  padding: 0 6px;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.filter-bar.ratings-loading .filter-sync-status {
  display: inline-flex;
}

.filter-bar.ratings-loading .filter-bar-label,
.filter-bar.ratings-loading .filter-chip,
.filter-bar.ratings-loading .filter-download-btn {
  display: none;
}

.filter-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 4px;
  border-radius: 5px;
  font-size: 0.825rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: none;
  color: var(--text-secondary);
}

.filter-chip:hover {
  background: var(--bg-surface-hover);
}

.filter-chip:active {
  transform: scale(0.9);
}

.filter-chip:not(.active) {
  opacity: 0.3;
  color: #d4d4d4;
}

.filter-download-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-left: 1px solid var(--border);
  margin-left: 4px;
  padding: 0 10px 0 12px;
  height: 24px;
  border-radius: 0 5px 5px 0;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.15s ease, opacity 0.15s ease, transform 0.15s ease;
}

.filter-download-btn-text {
  display: inline;
}

.filter-download-btn-icon {
  display: none;
  font-size: 17px;
  font-variation-settings: 'FILL' 0, 'wght' 450, 'GRAD' 0, 'opsz' 20;
}

.filter-download-btn-count {
  display: none;
}

.filter-download-btn:hover:not(:disabled) {
  color: var(--accent);
}

.filter-download-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.filter-download-btn:disabled {
  opacity: 0.45;
  color: var(--text-muted);
  cursor: not-allowed;
}

/* Grid star badge */
.grid-star-badge {
  position: absolute;
  bottom: 4px;
  left: 4px;
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 0.625rem;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  padding: 2px 5px;
  border-radius: 4px;
  z-index: 2;
  pointer-events: none;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.grid-star-badge .material-symbols-outlined {
  font-size: 10px;
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 20;
}

/* Trash badge for deleted files — matches star badge style */
.grid-trash-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.5);
  padding: 2px 4px;
  border-radius: 4px;
  z-index: 3;
  pointer-events: none;
  line-height: 1;
}

.grid-trash-badge .material-symbols-outlined {
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 20;
}

.thumb-trash-badge {
  position: absolute;
  bottom: 1px;
  right: 2px;
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.6);
  padding: 1px 3px;
  border-radius: 3px;
  pointer-events: none;
  z-index: 3;
  line-height: 1;
}

.thumb-trash-badge .material-symbols-outlined {
  font-size: 10px;
  color: rgba(255,255,255,0.7);
  font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 20;
}

/* ===== MULTI-SELECT (Photo Mechanic style) ===== */
.grid-item.selected {
  outline: 3px solid #1a73e8;
  outline-offset: -3px;
  z-index: 1;
}

.grid-item.selected::after {
  content: '✓';
  position: absolute;
  top: 6px;
  left: 6px;
  width: 22px;
  height: 22px;
  background: #1a73e8;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  z-index: 5;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  pointer-events: none;
}

#selection-bar {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 20px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px 10px 20px;
  background: rgba(20, 20, 20, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 16px;
  color: white;
  font-size: 0.8125rem;
  font-weight: 500;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  z-index: 200;
  animation: selbar-in 0.25s ease;
  user-select: none;
  white-space: nowrap;
}

@keyframes selbar-in {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.sel-count {
  color: rgba(255,255,255,0.9);
  font-variant-numeric: tabular-nums;
}

.sel-divider {
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,0.2);
}

.sel-rate-label {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
}

.sel-rates {
  display: flex;
  gap: 2px;
}

.sel-rate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  color: rgba(255,255,255,0.85);
  transition: background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.sel-rate:hover {
  background: rgba(255,255,255,0.15);
}

.sel-rate:active {
  transform: scale(0.9);
}

.sel-rate[data-r="0"] {
  color: rgba(255,255,255,0.5);
  font-size: 0.875rem;
}

.sel-clear {
  padding: 6px 14px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 10px;
  background: none;
  color: rgba(255,255,255,0.7);
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.sel-clear:hover {
  background: rgba(255,255,255,0.1);
  color: white;
}

@media (max-width: 600px) {
  #selection-bar {
    left: 8px;
    right: 8px;
    transform: none;
    border-radius: 14px;
    gap: 8px;
    padding: 8px 12px 8px 16px;
    font-size: 0.75rem;
    justify-content: space-between;
  }
  @keyframes selbar-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
  }
  .sel-rate-label { display: none; }
  .sel-rate { min-width: 26px; height: 26px; }
}

/* Thumbnail strip: dim filtered-out thumbs */
.thumb-item.filtered-out {
  opacity: 0.15 !important;
  pointer-events: none;
}

/* Thumbnail star badge */
.thumb-star-badge {
  position: absolute;
  bottom: 1px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.5625rem;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  padding: 1px 4px;
  border-radius: 3px;
  pointer-events: none;
  white-space: nowrap;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

@media (min-width: 600px) {
  .lightbox-photo-name { max-width: 300px; font-size: 0.875rem; }
  .lightbox-counter { font-size: 0.75rem; }
}

@media (min-width: 1024px) {
  .lightbox-photo-name { max-width: 500px; font-size: 0.9375rem; }
}

.lightbox-icon-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.lightbox-icon-btn:hover { background: rgba(0, 0, 0, 0.05); }
.lightbox-icon-btn .material-symbols-outlined { font-size: 24px; }

.diagnostic-report-btn {
  position: fixed;
  left: max(14px, env(safe-area-inset-left, 0px));
  bottom: calc(var(--safe-bottom) + 14px);
  z-index: 100010;
  min-width: 44px;
  min-height: 44px;
  padding: 0 13px 0 11px;
  border: 1px solid rgba(23, 23, 23, 0.12);
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.94);
  color: #9f2d24;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.14);
  font: 600 0.75rem/1 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  cursor: pointer;
  opacity: 0.86;
  transition: opacity var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.diagnostic-report-btn .material-symbols-outlined {
  font-size: 21px;
  font-variation-settings: 'FILL' 0, 'wght' 450, 'GRAD' 0, 'opsz' 20;
}

.diagnostic-report-btn:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.3);
  outline-offset: 2px;
  opacity: 1;
}

.diagnostic-report-btn:active {
  opacity: 1;
  transform: scale(0.97);
}

.diagnostic-report-btn.is-lightbox {
  bottom: calc(
    var(--safe-bottom)
    + var(--lightbox-action-bar-bottom)
    + var(--lightbox-action-bar-height)
    + 10px
  );
}

.diagnostic-report-btn.is-video-fullscreen {
  top: calc(var(--safe-top) + 64px);
  bottom: auto;
}

.diagnostic-report-btn.is-sending {
  opacity: 1;
  cursor: wait;
}

.diagnostic-report-btn:disabled {
  opacity: 0.62;
}

.diagnostic-report-btn.is-sending .material-symbols-outlined {
  animation: current-photo-download-spin 0.8s linear infinite;
}

@media (hover: hover) {
  .diagnostic-report-btn:hover {
    opacity: 1;
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
  }
}

@media (max-width: 599px) {
  .diagnostic-report-btn {
    width: 44px;
    padding: 0;
  }

  .diagnostic-report-label {
    display: none;
  }
}

#btn-download.is-preparing {
  cursor: wait;
  opacity: 0.72;
}

#btn-download.is-preparing .material-symbols-outlined {
  animation: current-photo-download-spin 0.8s linear infinite;
}

#btn-download.is-ready {
  color: var(--accent);
  background: var(--accent-light);
}

@keyframes current-photo-download-spin {
  to { transform: rotate(1turn); }
}

@media (prefers-reduced-motion: reduce) {
  #btn-download.is-preparing .material-symbols-outlined,
  .diagnostic-report-btn.is-sending .material-symbols-outlined { animation: none; }
}

/* Nav arrows — desktop only */
.lightbox-nav {
  --lightbox-ui-base-opacity: 1;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 72px;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  z-index: 15;
  opacity: var(--lightbox-ui-base-opacity, 1);
  transition: background var(--transition-fast), opacity var(--transition-normal);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: var(--shadow-sm);
  will-change: opacity;
}

.lightbox-prev { left: 8px; }
.lightbox-next { right: 8px; }
.lightbox-nav .material-symbols-outlined { font-size: 32px; }

.lightbox-nav.hidden { --lightbox-ui-base-opacity: 0; opacity: 0; pointer-events: none; }

.lightbox.lightbox-video-mode .lightbox-nav {
  background: rgba(0, 0, 0, 0.42);
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff;
  box-shadow: none;
}

.video-controls {
  --video-preview-width: min(240px, calc(100vw - 40px));
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--safe-bottom) + 94px);
  z-index: 18;
  display: none;
  padding: 0 18px 14px;
  color: #fff;
  opacity: 1;
  transform: translateY(0);
  transition: opacity var(--transition-normal), transform var(--transition-normal);
  will-change: opacity, transform;
}

.lightbox.lightbox-video-mode .video-controls {
  display: block;
}

.video-controls.hidden {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}

.video-seek {
  position: relative;
  width: 100%;
  padding: 16px 0 14px;
  cursor: pointer;
  touch-action: none;
}

.video-seek-track {
  position: relative;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.24);
  overflow: visible;
}

.video-seek-buffer,
.video-seek-progress {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  border-radius: inherit;
  pointer-events: none;
}

.video-seek-buffer {
  background: rgba(255, 255, 255, 0.28);
}

.video-seek-progress {
  background: #fff;
}

.video-seek-handle {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid rgba(0, 0, 0, 0.26);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.26);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.video-seek-preview {
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  width: var(--video-preview-width);
  padding: 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(9, 9, 11, 0.92);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.42);
  pointer-events: none;
  transform: translateX(-50%);
  opacity: 1;
  transition: opacity 0.12s ease;
}

.video-seek-preview.hidden {
  opacity: 0;
}

.video-seek-preview-image {
  display: block;
  width: 100%;
  aspect-ratio: var(--video-preview-image-aspect-ratio, 16 / 9);
  border-radius: 8px;
  object-fit: cover;
  background: #000;
}

.video-seek-preview-time {
  display: block;
  margin-top: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.92);
  text-align: center;
}

.video-controls-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.video-control-btn {
  color: #fff;
  background: rgba(0, 0, 0, 0.34);
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: none;
}

.video-control-btn:hover {
  background: rgba(0, 0, 0, 0.52);
}

.video-time {
  min-width: 96px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.96);
  font-variant-numeric: tabular-nums;
}

.video-controls-spacer {
  flex: 1 1 auto;
}

@media (min-width: 768px) {
  .lightbox-nav { display: flex; }
  .lightbox-nav:hover { background: rgba(255, 255, 255, 0.9); }
  .lightbox.lightbox-video-mode .lightbox-nav:hover { background: rgba(0, 0, 0, 0.62); }
}

/* ===== THUMBNAIL STRIP ===== */
.thumbnail-strip {
  --lightbox-ui-base-opacity: 1;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 15;
  background: linear-gradient(0deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.8) 50%, transparent 100%);
  padding: 10px 0 calc(var(--safe-bottom) + 10px);
  opacity: var(--lightbox-ui-base-opacity, 1);
  transition: opacity var(--transition-normal);
  will-change: opacity;
}

.lightbox.lightbox-video-mode .thumbnail-strip {
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.84) 0%, rgba(0, 0, 0, 0.46) 56%, transparent 100%);
}

.lightbox.video-fullscreen-active .lightbox-container {
  bottom: 0;
}

.lightbox.video-fullscreen-active .thumbnail-strip {
  display: none !important;
}

.lightbox.video-fullscreen-active .video-controls {
  bottom: calc(var(--safe-bottom) + 18px);
}

.thumbnail-strip.hidden {
  --lightbox-ui-base-opacity: 0;
  opacity: 0;
  pointer-events: none;
}

.thumbnail-strip-inner {
  --thumb-item-size: 64px;
  --thumb-item-gap: 3px;
  --thumb-strip-padding-inline: 12px;
  display: flex;
  gap: var(--thumb-item-gap);
  padding: 0 var(--thumb-strip-padding-inline);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  /* 'safe center' falls back to 'start' when content overflows.
     Chrome/Chromium with plain 'center' pushes overflow into unreachable negative scroll. */
  justify-content: safe center;
}

.thumbnail-strip-inner.is-virtualized {
  justify-content: flex-start;
}

.thumbnail-strip-inner::-webkit-scrollbar { display: none; }

.thumb-spacer {
  flex: 0 0 auto;
  height: 1px;
  pointer-events: none;
}

.thumb-item {
  position: relative;
  flex-shrink: 0;
  width: var(--thumb-item-size);
  height: var(--thumb-item-size);
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color var(--transition-fast), opacity var(--transition-fast), box-shadow var(--transition-fast);
  opacity: 1;
  background: var(--bg-primary);
}

.thumb-item:hover { opacity: 1; }

.thumb-item.video-placeholder {
  background: #141414;
}

.thumb-item.video-placeholder::after {
  content: 'play_circle';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: 'Material Symbols Outlined';
  font-size: 28px;
  color: rgba(255, 255, 255, 0.88);
  z-index: 1;
}

.thumb-item.active {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.thumb-item.selected {
  border-color: #22c55e;
  outline: 2px solid #22c55e;
  outline-offset: -2px;
}

.thumb-item.selected.active {
  border-color: var(--accent);
  outline: 3px solid #22c55e;
  outline-offset: 0px;
}

.thumb-item.selected::after {
  content: '✓';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #22c55e;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  z-index: 5;
  pointer-events: none;
}

@media (max-width: 767px) {
  .video-controls {
    bottom: calc(var(--safe-bottom) + 86px);
    padding: 0 12px 10px;
  }

  .video-time {
    min-width: 82px;
    font-size: 0.8125rem;
  }

  .video-seek-preview {
    width: min(200px, calc(100vw - 28px));
  }
}

.thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  -webkit-touch-callout: none; /* Prevent long-press save (low quality) */
}

/* Desktop: larger thumbnails */
@media (min-width: 768px) {
  .lightbox-container { bottom: calc(104px + var(--safe-bottom)); } /* 80px thumbs + padding + safe area */
  .thumbnail-strip-inner { --thumb-item-size: 80px; --thumb-item-gap: 4px; }
  .thumb-item { border-radius: 5px; }
  .thumb-star-badge { font-size: 0.75rem; padding: 2px 6px; border-radius: 4px; bottom: 2px; }
}

/* ===== EXIF INFO PANEL ===== */
.exif-panel {
  --lightbox-ui-base-opacity: 0;
  position: absolute;
  bottom: calc(130px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  z-index: 18;
  min-width: 160px;
  max-width: min(320px, calc(100vw - 24px));
  padding: 6px 10px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  opacity: var(--lightbox-ui-base-opacity, 1);
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
  will-change: opacity;
}

.exif-panel.open {
  --lightbox-ui-base-opacity: 1;
  opacity: var(--lightbox-ui-base-opacity, 1);
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.exif-row {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 1px 0;
  font-size: 0.6875rem;
  color: var(--text-primary);
  font-weight: 400;
  line-height: 1.3;
  white-space: nowrap;
}

.exif-row.exif-camera {
  font-weight: 600;
  font-size: 0.75rem;
}

.exif-row.exif-lens {
  color: var(--text-secondary);
  font-size: 0.625rem;
}

.exif-icon {
  flex-shrink: 0;
  width: 14px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.exif-icon .material-symbols-outlined {
  font-size: 14px;
  color: #737373;
  font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 20;
}

/* Info button active state */
.lightbox-icon-btn.active {
  background: var(--accent-light);
  color: var(--accent);
}

/* Desktop: center bottom controls above larger thumbnails */
@media (min-width: 768px) {
  :root {
    --lightbox-action-bar-bottom: 118px;
  }

  .action-bar {
    left: 50%;
    right: auto;
    justify-content: center;
    padding: 4px 12px;
    transform: translateX(-50%);
  }

  .action-bar.hidden {
    transform: translateX(-50%) translateY(-10px);
  }

  .exif-panel {
    bottom: calc(160px + var(--safe-bottom));
  }
}

@media (max-width: 767px) {
  .action-bar {
    left: 6px;
    right: 6px;
    align-items: stretch;
    justify-content: center;
    gap: 4px;
  }

  .lightbox-rating {
    flex: 0 0 auto;
    min-width: 0;
    min-height: 36px;
    justify-content: flex-start;
    gap: 0;
    padding: 4px 9px 4px 6px;
    box-sizing: border-box;
  }

  .rating-star {
    min-width: 26px;
    min-height: 26px;
  }

  .rating-clear {
    margin-right: 2px;
    padding-right: 6px;
  }

  .filter-bar-label {
    display: none;
  }

  .filter-bar {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 36px;
    padding: 4px 6px;
    box-sizing: border-box;
  }

  .filter-chip {
    flex: 1 1 0;
    min-width: 24px;
    height: 24px;
    padding: 0 4px;
    font-size: 0.8125rem;
  }

  .filter-download-btn {
    flex: 0 0 38px;
    width: 38px;
    min-width: 38px;
    min-height: 24px;
    margin-left: 2px;
    padding: 0;
    border-radius: 0 6px 6px 0;
  }

  .filter-download-btn-text {
    display: none;
  }

  .filter-download-btn-icon,
  .filter-download-btn-count {
    display: flex;
  }

  .filter-download-btn-count {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 17px;
    height: 17px;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--text-primary);
    color: #fff;
    font-size: 0.625rem;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.16);
  }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 0; height: 0; }

/* ===== TOP BAR RIGHT ===== */
.top-bar-right {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ===== TOAST NOTIFICATION ===== */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(24px) scale(0.95);
  background: #171717;
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  letter-spacing: -0.01em;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
  z-index: 99999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              visibility 0.35s;
  pointer-events: none;
  width: fit-content;
  max-width: min(560px, calc(100vw - 24px));
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.toast.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0) scale(1);
}
.toast .toast-icon {
  display: flex;
  align-items: center;
  margin-top: 1px;
}
.toast .toast-icon .material-symbols-outlined {
  font-size: 18px;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
}
.toast.toast-success .toast-icon .material-symbols-outlined {
  color: #4ade80;
}
.toast.toast-info .toast-icon .material-symbols-outlined {
  color: #60a5fa;
}
.toast.toast-warning .toast-icon .material-symbols-outlined {
  color: #fbbf24;
}
.toast.toast-error .toast-icon .material-symbols-outlined {
  color: #f87171;
}

.toast-message {
  min-width: 0;
  white-space: pre-line;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

/* ===== SYNC STATUS ===== */
.sync-status-widget {
  position: fixed;
  right: max(18px, env(safe-area-inset-right, 0px));
  bottom: calc(var(--safe-bottom) + 18px);
  z-index: 9000;
  width: 420px;
  max-width: calc(100vw - 36px);
  padding: 12px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text-primary);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.10);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s ease;
}

.sync-status-widget.is-compact {
  width: min(560px, calc(100vw - 36px));
  max-width: calc(100vw - 36px);
  padding: 12px;
}

.sync-status-widget.is-expanded {
  width: min(1500px, calc(100vw - 36px));
}

.sync-status-widget.is-icon {
  width: 46px;
  height: 46px;
  max-width: 46px;
  padding: 5px;
  border-radius: 999px;
}

.sync-status-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sync-status-widget.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.sync-status-icon {
  width: 30px;
  height: 30px;
  border: 0;
  padding: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: #f4f4f5;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.sync-status-icon:hover {
  background: #ececee;
  color: var(--text-primary);
}

.sync-status-icon .material-symbols-outlined {
  font-size: 18px;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
}

.sync-status-widget[data-phase="running"] .sync-status-icon .material-symbols-outlined {
  animation: sync-status-spin 1.2s linear infinite;
}

.sync-status-widget[data-phase="running"] .sync-status-icon,
.sync-status-widget[data-phase="queued"] .sync-status-icon,
.sync-status-widget[data-phase="waiting"] .sync-status-icon {
  background: #f5f5f5;
  color: #444;
}

.sync-status-widget[data-phase="done"] .sync-status-icon {
  background: #f3f6f3;
  color: #3f7a4b;
}

.sync-status-copy {
  min-width: 0;
  flex: 1 1 auto;
}

.sync-status-mode-button {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--text-secondary);
  background: transparent;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.sync-status-mode-button:hover {
  background: #f4f4f5;
  color: var(--text-primary);
}

.sync-status-mode-button .material-symbols-outlined {
  font-size: 18px;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
}

.sync-status-widget.is-icon .sync-status-main {
  justify-content: center;
  gap: 0;
}

.sync-status-widget.is-icon .sync-status-icon {
  width: 34px;
  height: 34px;
}

.sync-status-widget.is-icon .sync-status-copy,
.sync-status-widget.is-icon .sync-status-mode-button,
.sync-status-widget.is-icon .sync-status-rows,
.sync-status-widget.is-icon .sync-status-expanded-panel {
  display: none;
}

.sync-status-mode-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  width: 168px;
  padding: 6px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.14);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.sync-status-mode-menu[hidden] {
  display: none;
}

.sync-status-mode-menu button {
  width: 100%;
  min-height: 34px;
  border: 0;
  border-radius: 7px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  color: var(--text-secondary);
  background: transparent;
  cursor: pointer;
  font-size: 0.78125rem;
  line-height: 1.2;
  font-weight: 600;
  text-align: left;
}

.sync-status-mode-menu button:hover,
.sync-status-mode-menu button.is-selected {
  color: var(--text-primary);
  background: #f4f4f5;
}

.sync-status-mode-menu button.is-selected {
  box-shadow: inset 3px 0 0 #3f7a4b;
}

.sync-status-mode-menu .material-symbols-outlined {
  font-size: 18px;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
}

.sync-status-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.sync-status-title {
  font-size: 0.8125rem;
  line-height: 1.25;
  font-weight: 600;
  color: var(--text-primary);
}

.sync-status-time {
  flex: 0 0 auto;
  font-size: 0.6875rem;
  line-height: 1.2;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.sync-status-rows {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid rgba(0, 0, 0, 0.07);
  display: grid;
  gap: 6px;
}

.sync-status-widget.is-compact .sync-status-time {
  display: none;
}

.sync-status-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  font-size: 0.71875rem;
  line-height: 1.35;
}

.sync-status-row[hidden] {
  display: none;
}

.sync-status-row span {
  color: var(--text-muted);
  font-weight: 500;
}

.sync-status-row-value {
  min-width: 0;
  color: var(--text-secondary);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sync-status-row[data-sync-row="target"] .sync-status-row-value {
  overflow-x: auto;
  overflow-y: hidden;
  text-overflow: clip;
  scrollbar-width: thin;
}

.sync-status-row[data-sync-row="target"] .sync-status-row-value::-webkit-scrollbar {
  height: 4px;
}

.sync-status-row[data-sync-row="target"] {
  align-items: start;
}

.sync-status-row[data-sync-row="target"] .sync-status-row-value {
  max-height: min(20vh, 132px);
  overflow: auto;
  white-space: pre;
  line-height: 1.45;
}

.sync-status-widget.is-expanded .sync-status-row[data-sync-row="target"] .sync-status-row-value {
  max-height: min(26vh, 220px);
  overflow: auto;
  white-space: pre;
  line-height: 1.45;
}

.sync-status-expanded-panel {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.07);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.sync-status-widget.is-compact .sync-status-expanded-panel {
  display: none;
}

.derivative-builder-control {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.56);
}

.derivative-builder-control[hidden] {
  display: none;
}

.derivative-builder-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.derivative-builder-copy strong {
  color: var(--text-primary);
  font-size: 0.75rem;
  line-height: 1.25;
}

.derivative-builder-copy span {
  color: var(--text-muted);
  font-size: 0.6875rem;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.derivative-builder-control[data-health="healthy"] .derivative-builder-copy span {
  color: #387a55;
}

.derivative-builder-modes {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 3px;
  padding: 3px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.055);
}

.derivative-builder-modes button {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.6875rem;
  font-weight: 650;
  line-height: 1.2;
  padding: 6px 8px;
}

.derivative-builder-modes button.is-selected {
  background: #fff;
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.derivative-builder-modes button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.sync-status-job-column {
  min-width: 0;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.48);
  overflow: hidden;
}

.sync-status-job-column-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.sync-status-job-column-head h3 {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.25;
  font-weight: 650;
  color: var(--text-primary);
}

.sync-status-job-column-head span {
  flex: 0 0 auto;
  font-size: 0.6875rem;
  line-height: 1.2;
  color: var(--text-muted);
}

.sync-status-job-list {
  max-height: min(68vh, 760px);
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 3px 0;
}

.sync-status-job-row {
  display: block;
  min-width: 100%;
  width: max-content;
  padding: 6px 10px;
}

.sync-status-job-row + .sync-status-job-row {
  border-top: 1px solid rgba(0, 0, 0, 0.035);
}

.sync-status-job-group {
  display: block;
  min-width: 100%;
  width: max-content;
}

.sync-status-job-group-title {
  white-space: nowrap;
  font-weight: 650;
}

.sync-status-job-more {
  color: var(--text-muted);
  font-style: italic;
}

.sync-status-job-line {
  min-width: max-content;
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
  color: var(--text-primary);
  font-size: 0.71875rem;
  line-height: 1.35;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.sync-status-empty {
  padding: 12px 10px;
  color: var(--text-muted);
  font-size: 0.71875rem;
  line-height: 1.35;
}

@keyframes sync-status-spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 767px) {
  .sync-status-widget {
    display: none !important;
  }
}

/* ===== USER AVATAR (Auth) ===== */
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  cursor: pointer;
  border: 2px solid var(--accent);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.user-avatar:hover {
  transform: scale(1.1);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}
#btn-login .material-symbols-outlined {
  font-size: 26px;
}

/* ===== LOGIN WALL (Access Gate) ===== */
.login-wall {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.4s ease;
}
.login-wall.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.login-wall-content {
  text-align: center;
  padding: 48px 40px;
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 24px;
  border: 1px solid rgba(255,255,255,0.1);
  max-width: 400px;
  width: 90vw;
  box-shadow: 0 24px 80px rgba(0,0,0,0.4);
  animation: loginWallFadeIn 0.6s ease;
}
@keyframes loginWallFadeIn {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.login-wall-logo-img {
  width: 120px;
  height: auto;
  margin-bottom: 16px;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.3));
  animation: loginLogoFloat 3s ease-in-out infinite;
}
@keyframes loginLogoFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.login-wall-title {
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 28px;
  color: #fff;
  letter-spacing: 4px;
  margin: 0 0 8px;
}
.login-wall-subtitle {
  color: rgba(255,255,255,0.6);
  font-size: 14px;
  margin: 0 0 32px;
  line-height: 1.5;
}
.login-wall-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 32px;
  background: #fff;
  color: #333;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
.login-wall-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.login-wall-btn:active {
  transform: translateY(0);
}
.login-wall-hint {
  color: rgba(255,255,255,0.35);
  font-size: 12px;
  margin: 24px 0 0;
}

/* ===== HOME LOGO BUTTON ===== */
.home-logo-btn {
  padding: 5px 8px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.home-logo-btn:hover {
  transform: translateY(-1px);
  background: rgba(0, 0, 0, 0.08);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.home-logo-btn:active {
  transform: translateY(0);
  box-shadow: none;
}
.home-logo-img {
  height: 28px;
  width: auto;
  display: block;
  opacity: 0.84;
  filter: saturate(0.92) contrast(0.94);
}

/* ===== CUSTOM COVER CONTEXT MENU ===== */
.cover-context-menu {
  position: fixed;
  z-index: 99998;
  min-width: 200px;
  max-width: min(320px, calc(100vw - 16px));
  max-height: min(calc(100dvh - 16px), 72vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
  padding: 4px;
  animation: cover-menu-in 0.15s ease;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.cover-context-heading {
  padding: 8px 14px 6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
}

@keyframes cover-menu-in {
  from { opacity: 0; transform: scale(0.95) translateY(-4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.cover-context-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: transparent;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-primary);
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.12s ease;
  text-align: left;
  white-space: normal;
  line-height: 1.35;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.cover-longpress-active,
.cover-longpress-active * {
  -webkit-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none !important;
}

.cover-context-item:hover {
  background: var(--accent-light);
  color: var(--accent);
}

.cover-context-item:disabled {
  opacity: 0.62;
  cursor: wait;
  background: transparent;
  color: var(--text-secondary);
}

.cover-context-item:active {
  transform: scale(0.98);
}

/* Custom cover badge on album card */
.cover-custom-badge {
  background: rgba(255, 255, 255, 0.55);
  color: #404040;
  padding: 4px;
  border-radius: 6px;
  z-index: 2;
  line-height: 1;
  pointer-events: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.cover-custom-badge .material-symbols-outlined {
  font-size: 16px;
  display: block;
}

/* album-card needs relative for badge positioning */
.album-card {
  position: relative;
}

/* ===== MOBILE GALLERY COMPOSITION ===== */
@media (max-width: 599px) {
  .top-bar {
    flex-wrap: wrap;
    gap: 2px 0;
    padding: calc(var(--safe-top) + 2px) 10px 4px;
  }

  .top-bar-left {
    flex: 1 0 100%;
    flex-basis: 100%;
    gap: 4px;
  }

  /* Keep Home in its original leading position: LUX → Back → album title. */
  .top-bar-left:has(#btn-back:not([style*="display: none"])) .home-logo-btn {
    order: 0;
    flex: 0 0 44px;
  }

  .top-bar-right {
    width: 100%;
    flex: 1 0 100%;
    justify-content: flex-end;
    gap: 2px;
    min-width: 0;
  }

  .top-bar-title {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 1.1rem;
    line-height: 1.12;
  }

  .home-logo-btn,
  #btn-back,
  #btn-search,
  #btn-share,
  #btn-login {
    width: 44px;
    height: 44px;
  }

  .home-logo-btn {
    padding: 6px 8px;
    border-radius: 12px;
  }

  .home-logo-img {
    height: 26px;
  }

  #btn-back {
    margin: 0;
  }

  #btn-back .material-symbols-outlined {
    font-size: 24px;
    transform: none;
  }

  .search-container {
    flex: 0 0 auto;
  }

  .top-bar-meta {
    margin-right: auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.8125rem;
  }

  .download-current-folder-btn {
    height: 44px;
    padding: 0 10px;
    gap: 4px;
  }

  .top-bar.search-mode {
    flex-wrap: nowrap;
    gap: 6px;
  }

  .top-bar.search-mode .top-bar-left {
    flex: 0 0 auto;
  }

  .top-bar.search-mode .top-bar-right {
    width: auto;
    flex: 1 1 auto;
  }

  .album-grid {
    gap: 10px;
    padding: 12px;
  }

  .album-card-info {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    align-items: start;
    gap: 8px;
    min-height: 104px;
    padding: 10px 12px 11px;
  }

  .album-card-info.has-actions {
    padding-right: 12px;
  }

  .album-card-title {
    margin-bottom: 4px;
    line-height: 1.25;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow-wrap: break-word;
  }

  .album-card-actions {
    width: auto;
    align-self: end;
    justify-self: start;
    gap: 6px;
  }

  .album-card-share-btn,
  .album-card-download-btn {
    position: relative;
    height: 38px;
    min-height: 0;
    border-radius: 9px;
  }

  .album-card-share-btn::after,
  .album-card-download-btn::after {
    content: '';
    position: absolute;
    inset: -3px;
  }

  .album-card-download-btn {
    flex: 0 0 auto;
    min-width: 68px;
    padding: 0 9px;
  }

  .album-card-share-btn {
    flex: 0 0 38px;
    width: 38px;
  }

  .album-card-download-label {
    font-size: 0.75rem;
  }

  .album-card-info .cover-custom-badge {
    position: absolute;
    top: 8px;
    right: 8px;
  }
}

@media (max-width: 359px) {
  .top-bar-meta {
    display: none;
  }
}
