:root {
  color-scheme: light dark;
  font-family: system-ui, sans-serif;
}

body {
  margin: 0;
}

.nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #8884;
}

.nav .brand {
  font-weight: bold;
  margin-right: auto;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem;
}

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.5rem;
  margin: 1rem 0;
}

.thumb {
  display: block;
  position: relative;
}

.thumb.selected {
  outline: 3px solid #2a8f4d;
  outline-offset: -3px;
  border-radius: 4px;
}

.thumb-checkbox {
  position: absolute;
  top: 0.4rem;
  left: 0.4rem;
  z-index: 1;
  width: 1.1rem;
  height: 1.1rem;
}

.progressive-thumb {
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  background: linear-gradient(100deg, #8883 30%, #8886 50%, #8883 70%);
  background-size: 200% 100%;
  animation: thumb-shimmer 1.4s ease-in-out infinite;
}

.progressive-thumb.loaded {
  animation: none;
  background: none;
}

.progressive-thumb-img {
  display: block;
  width: 100%;
  height: 160px;
  object-fit: cover;
  opacity: 0;
  filter: blur(8px);
  transition: opacity 0.3s ease, filter 0.3s ease;
}

.progressive-thumb.loaded .progressive-thumb-img {
  opacity: 1;
  filter: blur(0);
}

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

.gallery-toolbar {
  display: flex;
  justify-content: flex-end;
  margin: 0.5rem 0;
}

.select-mode-toggle {
  background: none;
  border: 1px solid #8884;
  border-radius: 4px;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
}

.bulk-tag-bar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.5rem 0;
  padding: 0.75rem;
  border: 1px solid #8884;
  border-radius: 6px;
  background: rgba(128, 128, 128, 0.08);
}

.bulk-tag-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: bold;
}

.bulk-tag-busy {
  font-weight: normal;
  opacity: 0.7;
}

.bulk-tag-status {
  margin: 0;
  opacity: 0.8;
  font-size: 0.9rem;
}

.bulk-tag-rows {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.bulk-tag-bar .tag-input {
  background: Field;
  color: FieldText;
  border: 1px solid GrayText;
}

.bulk-tag-bar .tag-input::placeholder {
  color: GrayText;
}

.bulk-tag-bar .tag-suggestions {
  top: 100%;
  bottom: auto;
  margin-top: 0.25rem;
  margin-bottom: 0;
  background: Canvas;
  color: CanvasText;
  border: 1px solid GrayText;
}

.bulk-tag-bar .tag-suggestion {
  color: CanvasText;
}

.gallery-sentinel {
  min-height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
}

.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-viewer .viewer-loading {
  color: #fff;
}

.full-image {
  max-width: 100vw;
  max-height: 100vh;
  object-fit: contain;
  display: block;
}

.viewer-controls {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.viewer-controls.hidden {
  opacity: 0;
}

.viewer-controls > * {
  pointer-events: auto;
}

.viewer-top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(rgba(0, 0, 0, 0.65), transparent);
  color: #fff;
}

.viewer-back {
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
}

.viewer-meta {
  flex: 1;
  font-size: 0.85rem;
  opacity: 0.85;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer-delete {
  white-space: nowrap;
}

.viewer-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  border: none;
  font-size: 2rem;
  line-height: 1;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
}

.viewer-nav-btn.prev {
  left: 1rem;
}

.viewer-nav-btn.next {
  right: 1rem;
}

.viewer-nav-btn:disabled {
  opacity: 0.15;
  cursor: default;
}

.viewer-tag-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.75rem 1rem;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
  color: #fff;
}

.tag-editor {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.tag-dimension {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  position: relative;
}

.tag-dimension-label {
  font-size: 0.75rem;
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  padding: 0.15rem 0.3rem 0.15rem 0.6rem;
  font-size: 0.85rem;
}

.tag-chip-remove {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0.1rem 0.3rem;
}

.tag-input-row {
  position: relative;
}

.tag-input {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  color: #fff;
  padding: 0.2rem 0.5rem;
  font-size: 0.85rem;
}

.tag-input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

.tag-suggestions {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 0.25rem;
  background: #222;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  max-height: 10rem;
  overflow-y: auto;
  min-width: 8rem;
  z-index: 1;
}

.tag-suggestion {
  background: none;
  border: none;
  color: #fff;
  text-align: left;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  font-size: 0.85rem;
}

.tag-suggestion:hover {
  background: rgba(255, 255, 255, 0.15);
}

.filter-panel {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 1rem 0;
  padding: 0.75rem;
  border: 1px solid #8884;
  border-radius: 6px;
}

.filter-dimension {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  position: relative;
}

.filter-dimension-label {
  font-size: 0.75rem;
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  min-width: 4.5rem;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.filter-chip {
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  font-size: 0.85rem;
  cursor: pointer;
  border: 1px solid;
}

.filter-chip.include {
  border-color: #2a8f4d;
  color: #2a8f4d;
  background: rgba(42, 143, 77, 0.12);
}

.filter-chip.exclude {
  border-color: #c0392b;
  color: #c0392b;
  background: rgba(192, 57, 43, 0.12);
  text-decoration: line-through;
}

.filter-chip-off {
  border-color: GrayText;
  color: GrayText;
  background: none;
  font-style: italic;
}

.filter-date-range {
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter-unknown-date {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
}

.filter-clear {
  align-self: flex-start;
  background: none;
  border: 1px solid #8884;
  border-radius: 4px;
  padding: 0.25rem 0.6rem;
  font-size: 0.85rem;
  cursor: pointer;
}

/* The filter panel sits on the page's normal background (not the dark
   image-viewer overlay .tag-input/.tag-suggestions were designed for), so
   its inputs/popover use CSS system colors to stay legible in both
   light and dark themes instead of the viewer's translucent-white styling. */
.filter-panel .tag-input {
  background: Field;
  color: FieldText;
  border: 1px solid GrayText;
}

.filter-panel .tag-input::placeholder {
  color: GrayText;
}

.filter-panel .tag-suggestions {
  top: 100%;
  bottom: auto;
  margin-bottom: 0;
  margin-top: 0.25rem;
  background: Canvas;
  color: CanvasText;
  border: 1px solid GrayText;
}

.filter-panel .tag-suggestion {
  color: CanvasText;
}

.filter-panel .tag-suggestion:hover {
  background: rgba(128, 128, 128, 0.2);
}

.person-create-dialog {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

.date-editor {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.date-display {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.error {
  color: #c00;
}

table {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: 1rem;
}

th,
td {
  text-align: left;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid #8884;
}
