.gallery-view {
  padding: 1rem;
  max-width: 1600px;
  margin: 0 auto;
}
.gallery-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.gallery-header h1 {
  margin: 0;
  font-size: 1.35rem;
}
.gallery-storage-bar {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  font-size: 0.88rem;
  line-height: 1.45;
}
.gallery-storage-bar--cloud {
  border-color: #bbf7d0;
  background: #f0fdf4;
}
.gallery-storage-bar--setup {
  border-color: #fde68a;
  background: #fffbeb;
}
.gallery-storage-bar--local {
  border-color: #e2e8f0;
  background: #f8fafc;
}
.gallery-storage-badge {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}
.gallery-storage-badge--cloud {
  background: #16a34a;
  color: #fff;
}
.gallery-storage-badge--setup {
  background: #d97706;
  color: #fff;
}
.gallery-storage-badge--local {
  background: #64748b;
  color: #fff;
}
.gallery-storage-text {
  flex: 1 1 240px;
  color: #334155;
}
.gallery-storage-counts {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.8rem;
  color: #64748b;
}
.gallery-storage-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  align-items: center;
}
.gallery-sync-badge {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  pointer-events: none;
}
.gallery-sync-badge--synced {
  background: rgba(22, 163, 74, 0.9);
}
.gallery-sync-badge--pending {
  background: rgba(217, 119, 6, 0.9);
}
.gallery-sync-badge--error {
  background: rgba(220, 38, 38, 0.9);
}
.gallery-sync-badge--local_only {
  background: rgba(100, 116, 139, 0.9);
}
.gallery-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
}
.gallery-filter-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.gallery-visit-filters {
  margin-bottom: 1rem;
  padding: 0.75rem 0.85rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}
.gallery-visit-filters-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.55rem;
}
.gallery-visit-filter-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.gallery-visit-filter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.gallery-visit-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  font-size: 0.82rem;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  cursor: pointer;
  user-select: none;
}
.gallery-visit-chip:has(input:checked) {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1e3a8a;
}
.gallery-visit-chip input {
  accent-color: #2563eb;
  cursor: pointer;
}
.tag-chip {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  border: 1px solid #cbd5e1;
  background: #fff;
  cursor: pointer;
}
.tag-chip.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}
.tag-chip.muted-chip {
  color: #64748b;
}
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.gallery-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
}
.gallery-card.saving {
  opacity: 0.75;
}
.gallery-card.saved-flash {
  box-shadow: 0 0 0 2px #22c55e;
}
.gallery-slideshow-details.saved-flash {
  box-shadow: inset 0 0 0 2px #22c55e;
}
.gallery-thumb {
  position: relative;
  aspect-ratio: 4/3;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
}
.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.15s ease;
}
.gallery-thumb:hover img {
  transform: scale(1.03);
}
.gallery-body {
  padding: 0.65rem 0.75rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  flex: 1;
}
.gallery-meta {
  font-size: 0.78rem;
  color: #64748b;
  line-height: 1.35;
}
.gallery-body label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #475569;
}
.gallery-body textarea {
  min-height: 72px;
  font-size: 0.88rem;
  resize: vertical;
}
.gallery-body input[type="text"],
.gallery-body input[type="date"] {
  font-size: 0.88rem;
}
.gallery-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  min-height: 1.25rem;
}
.gallery-tag-list .tag-chip {
  cursor: default;
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
}
.gallery-card-actions {
  display: flex;
  gap: 0.35rem;
  margin-top: auto;
  padding-top: 0.35rem;
}
.gallery-empty {
  background: #fff;
  border-radius: 8px;
  padding: 2rem;
  text-align: center;
  color: #64748b;
}
.gallery-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  min-height: min(70vh, 520px);
  padding: 2rem 1rem;
  color: #475569;
}
.gallery-loading-spinner {
  width: 2.25rem;
  height: 2.25rem;
  border: 3px solid #cbd5e1;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: gallery-loading-spin 0.75s linear infinite;
}
.gallery-loading-message {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 500;
}
@keyframes gallery-loading-spin {
  to { transform: rotate(360deg); }
}

/* Slideshow dialog */
.gallery-slideshow:not([open]) {
  display: none !important;
}
.gallery-slideshow {
  border: none;
  border-radius: 10px;
  padding: 0 !important;
  margin: 0;
  width: min(96vw, 1440px);
  max-width: none !important;
  height: min(96vh, calc(100vh - 2rem));
  max-height: min(96vh, calc(100vh - 2rem));
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.gallery-slideshow[open] {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.gallery-slideshow::backdrop {
  background: rgba(15, 23, 42, 0.65);
}
.gallery-slideshow-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  flex-shrink: 0;
}
/* Slideshow toolbar uses global .btn styles */
.gallery-slideshow-counter {
  font-size: 0.88rem;
  color: #475569;
  font-weight: 600;
  white-space: nowrap;
}
.gallery-slideshow-zoom-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
  margin-right: 0.5rem;
}
.gallery-slideshow-zoom-level {
  min-width: 3.25rem;
  text-align: center;
  font-size: 0.82rem;
  color: #475569;
  font-weight: 600;
}
.gallery-slideshow-body {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}
.gallery-slideshow-stage {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.65fr);
  min-width: 0;
  min-height: 0;
  height: 100%;
}
.gallery-slideshow-image-wrap {
  background: #0f172a;
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.gallery-slideshow-viewport {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  cursor: zoom-in;
}
.gallery-slideshow-viewport.is-zoomed {
  cursor: grab;
}
.gallery-slideshow-viewport.is-zoomed:active {
  cursor: grabbing;
}
.gallery-slideshow-viewport img {
  display: block;
  max-width: none;
  max-height: none;
  width: auto;
  height: auto;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}
.gallery-slideshow-details {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  overflow-y: auto;
  border-left: 1px solid #e2e8f0;
  background: #fff;
  min-height: 0;
  height: 100%;
}
.gallery-slideshow-meta {
  font-size: 0.82rem;
  color: #64748b;
  line-height: 1.4;
  margin-bottom: 0.25rem;
  word-break: break-word;
}
.gallery-slideshow-details label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #475569;
}
.gallery-slideshow-details textarea {
  min-height: 88px;
  font-size: 0.9rem;
  resize: vertical;
}
.gallery-slideshow-details input[type="text"],
.gallery-slideshow-details input[type="date"] {
  font-size: 0.9rem;
}
.gallery-slideshow-actions {
  display: flex;
  gap: 0.35rem;
  margin-top: auto;
  padding-top: 0.5rem;
  flex-shrink: 0;
}
.gallery-slideshow-nav {
  align-self: stretch;
  width: 2.5rem;
  border: none;
  background: #f1f5f9;
  color: #334155;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease;
}
.gallery-slideshow-nav:hover:not(:disabled) {
  background: #e2e8f0;
}
.gallery-slideshow-nav:disabled {
  opacity: 0.35;
  cursor: default;
}
.gallery-slideshow-nav.prev {
  border-right: 1px solid #e2e8f0;
}
.gallery-slideshow-nav.next {
  border-left: 1px solid #e2e8f0;
}
@media (max-width: 860px) {
  .gallery-slideshow[open] {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 98vw;
    height: min(98vh, calc(100vh - 1rem));
    max-height: min(98vh, calc(100vh - 1rem));
  }
  .gallery-slideshow-stage {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(45vh, 1fr) auto;
    overflow: hidden;
  }
  .gallery-slideshow-details {
    border-left: none;
    border-top: 1px solid #e2e8f0;
    max-height: 38vh;
  }
}
