* {
  box-sizing: border-box;
}

:root {
  --bg: #101216;
  --panel: #191c22;
  --panel-2: #22262e;
  --text: #e8e6e1;
  --muted: #9a978f;
  --accent: #d9a441;
  --danger: #e5645a;
  --accept: #7ac97a;
  --radius: 8px;
}

html {
  /* Reserve the scrollbar gutter — content width must not shift when a
     filter change toggles the scrollbar. */
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

h1 {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 0;
}
h1 a {
  text-decoration: none;
}
h2 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
}

a {
  color: var(--text);
}
.muted {
  color: var(--muted);
  font-weight: 400;
}
.error {
  color: var(--danger);
}

.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 1.25rem 4rem;
}
.center-page {
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 1rem 0 1.25rem;
}
.row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.25rem;
  border-bottom: 1px solid var(--panel-2);
}
.brand {
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  color: var(--accent);
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* inputs & buttons */
input {
  background: var(--panel);
  border: 1px solid var(--panel-2);
  color: var(--text);
  border-radius: var(--radius);
  padding: 0.45rem 0.7rem;
  font-size: 0.95rem;
}
input:focus {
  outline: 1px solid var(--accent);
}
input[type='checkbox'] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}
.btn {
  display: inline-block;
  background: var(--panel-2);
  color: var(--text);
  border: none;
  border-radius: var(--radius);
  padding: 0.45rem 0.9rem;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover {
  filter: brightness(1.15);
}
.btn-primary {
  background: var(--accent);
  color: #1a1408;
  font-weight: 600;
}
.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-ghost {
  background: transparent;
  color: var(--muted);
}

/* login */
.login-card {
  background: var(--panel);
  border-radius: 12px;
  padding: 2.5rem 3rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  color: var(--text);
}

/* album grid */
.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.album-card {
  background: var(--panel);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
}
.album-card:hover .album-cover img {
  filter: brightness(1.08);
}
.album-cover {
  aspect-ratio: 3 / 2;
  background: var(--panel-2);
}
.album-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.album-cover-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted);
}
.album-meta {
  padding: 0.6rem 0.8rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

/* photo grid (Lightroom-style fixed cells) */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 6px;
  margin: 1rem 0;
}
.g-item {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  background: var(--panel);
  content-visibility: auto;
  contain-intrinsic-size: 300px;
}
.g-item img {
  width: 100%;
  height: 100%;
  padding: 8px;
  object-fit: contain;
  display: block;
}
.g-overlay {
  position: absolute;
  bottom: 6px;
  left: 6px;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.2rem 0.55rem;
  font-size: 0.8rem;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 6px;
  color: #ffd97a;
}

/* selection */
.g-check {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.85);
  background: rgba(0, 0, 0, 0.35);
  color: transparent;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s;
}
.g-item:hover .g-check,
.gallery.selecting .g-check,
.g-item.selected .g-check {
  opacity: 1;
}
.g-item.selected .g-check {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1408;
}
.g-item.selected img {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}
.g-item.focused {
  outline: 2px solid var(--text);
  outline-offset: -2px;
}
.select-bar {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--panel);
  border: 1px solid var(--panel-2);
  border-radius: 999px;
  padding: 0.5rem 1rem;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  z-index: 50;
}
.select-count {
  font-size: 0.9rem;
  white-space: nowrap;
}
.select-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
  cursor: pointer;
}

/* upload */
.upload-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  text-align: left;
  max-height: 220px;
  overflow-y: auto;
  cursor: default;
}
.upload-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.2rem 0;
  font-size: 0.85rem;
}
.upload-item.done {
  color: var(--muted);
}
.upload-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
progress {
  width: 160px;
  accent-color: var(--accent);
}

/* fullscreen drag target */
.drop-overlay {
  position: fixed;
  inset: 10px;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(16, 18, 22, 0.82);
  border: 3px dashed var(--accent);
  border-radius: 12px;
  color: var(--accent);
  font-size: 1.4rem;
  pointer-events: none;
}

/* activity overlay: uploads + processing, bottom right */
.activity {
  position: fixed;
  right: 1rem;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  width: min(340px, calc(100vw - 2rem));
  background: var(--panel);
  border: 1px solid var(--panel-2);
  border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  z-index: 60;
  font-size: 0.85rem;
}
.activity-head {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: none;
  border: none;
  color: var(--text);
  padding: 0.55rem 0.8rem;
  font-size: 0.85rem;
  cursor: pointer;
}
.activity-clear {
  color: var(--muted);
  padding: 0 0.2rem;
}
.activity-total {
  display: block;
  width: calc(100% - 1.6rem);
  margin: 0 0.8rem 0.5rem;
}
.activity-body {
  border-top: 1px solid var(--panel-2);
  padding: 0.5rem 0.8rem 0.7rem;
  max-height: 40vh;
  overflow-y: auto;
}
.activity-body .upload-list {
  margin: 0.25rem 0 0;
  max-height: none;
}
.activity-body progress {
  width: 110px;
}
.activity-section {
  margin-top: 0.4rem;
  font-size: 0.8rem;
}
.activity-section:first-child {
  margin-top: 0;
}

/* modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(8, 9, 11, 0.7);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 8vh 1rem 1rem;
}
.modal-card {
  background: var(--panel);
  border: 1px solid var(--panel-2);
  border-radius: 12px;
  width: min(760px, 100%);
  max-height: 80vh;
  overflow-y: auto;
  padding: 1rem 1.25rem 1.25rem;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.modal-head h2 {
  margin: 0;
}
.modal-foot {
  margin-top: 1rem;
}
.xmp-source {
  display: flex;
  gap: 0.5rem;
  padding: 0.3rem 0;
  color: var(--text);
}
.btn-disabled {
  opacity: 0.5;
  cursor: default;
}

/* panels */
.panel {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
}
.pending-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.pending-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.25rem 0;
  font-size: 0.9rem;
}

/* shares */
.share-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--panel-2);
}
.share-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.share-info .muted {
  font-size: 0.82rem;
}
.share-stats {
  display: inline-flex;
  gap: 0.3rem;
}
.share-feedback {
  margin-top: 0.35rem;
}
.feedback-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
}
.client-fb-btn {
  cursor: pointer;
  font-size: inherit;
  color: var(--text);
}
.client-fb-btn.active {
  border-color: var(--accent);
  background: var(--panel-2);
}
.chip-accept {
  background: color-mix(in srgb, var(--accept) 18%, var(--panel-2));
}
.chip-reject {
  background: color-mix(in srgb, var(--danger) 18%, var(--panel-2));
}
.share-url {
  background: none;
  border: none;
  padding: 0;
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.82rem;
  cursor: pointer;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.share-url:hover {
  color: var(--accent);
}
.share-form {
  display: grid;
  grid-template-columns: max-content minmax(0, 320px);
  gap: 0.6rem 1rem;
  align-items: center;
  margin-top: 1rem;
  border-top: 1px solid var(--panel-2);
  padding-top: 0.9rem;
}
.share-form-title {
  grid-column: 1 / -1;
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0;
}
.share-form .field {
  display: contents;
  font-size: 0.85rem;
}
.share-form-full {
  grid-column: 1 / -1;
  font-size: 0.85rem;
  color: var(--muted);
}
.field-label {
  gap: 0.4rem;
}
.field-label .btn-ghost {
  padding: 0.2rem 0.4rem;
}

/* share (client) page */
.share-head {
  text-align: center;
  padding: 2.5rem 1rem 0.5rem;
}
.share-head h1 {
  font-size: 1.8rem;
  font-weight: 300;
}
.share-head p {
  margin: 0.4rem 0 0;
}

/* lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(8, 9, 11, 0.96);
  z-index: 100;
  display: flex;
  flex-direction: column;
}
.lb-top {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.lb-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
}
.lb-stage {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  /* Swipes are handled in JS; stop the browser from panning/zooming. */
  touch-action: none;
}
.lb-track {
  position: absolute;
  inset: 0;
}
.lb-slide {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3.5rem;
}
.lb-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  cursor: default;
}
.lb-flick {
  z-index: 2;
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 5rem;
  opacity: 0;
  pointer-events: none;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.6);
}
/* Next photo waiting behind a vote drag, before its zoom-in. */
.lb-behind {
  transform: scale(0.22);
  opacity: 0;
}
/* Ghost of a just-voted photo flying off; the vote itself is already saved. */
.lb-ghost {
  z-index: 3;
  pointer-events: none;
}
.lb-exit-up {
  animation: lb-exit-up 0.26s ease-in forwards;
}
.lb-exit-down {
  animation: lb-exit-down 0.26s ease-in forwards;
}
@keyframes lb-exit-up {
  from {
    transform: translateY(var(--dy)) rotate(var(--rot));
  }
  to {
    transform: translateY(-120vh) rotate(var(--rot));
    opacity: 0;
  }
}
@keyframes lb-exit-down {
  from {
    transform: translateY(var(--dy)) rotate(var(--rot));
  }
  to {
    transform: translateY(120vh) rotate(var(--rot));
    opacity: 0;
  }
}
.lb-hidden {
  opacity: 0;
}
/* Whole-modal fade after voting the last photo — the gallery is behind it. */
.lightbox.lb-closing {
  animation: lb-fade-out 0.26s ease forwards;
  pointer-events: none;
}
@keyframes lb-fade-out {
  to {
    opacity: 0;
  }
}
/* The photo taking over after a vote zooms in organically. */
.lb-enter {
  animation: lb-enter 0.26s ease-out;
}
@keyframes lb-enter {
  from {
    transform: scale(0.3);
    opacity: 0.2;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.06);
  border: none;
  color: var(--text);
  font-size: 2rem;
  line-height: 1;
  padding: 0.6rem 0.8rem;
  border-radius: 50%;
  cursor: pointer;
  z-index: 101;
}
.lb-nav:disabled {
  opacity: 0.25;
  cursor: default;
}
.lb-prev {
  left: 0.75rem;
}
.lb-next {
  right: 0.75rem;
}
.lb-footer {
  padding: 0.7rem 1rem 1rem;
}
.client-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}
/* Two rows: things you do (own vote + photo actions), things you read
   (per-client feedback pills). */
.admin-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}
.admin-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}
.client-fb {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--panel);
  border: 1px solid var(--panel-2);
  border-radius: 999px;
  padding: 0.15rem 0.7rem;
}
.client-fb-verdict {
  font-size: 1.1rem;
  line-height: 1;
}
.client-fb-accept {
  border-color: color-mix(in srgb, var(--accept) 60%, transparent);
  background: color-mix(in srgb, var(--accept) 16%, var(--panel));
}
.client-fb-reject {
  border-color: color-mix(in srgb, var(--danger) 60%, transparent);
  background: color-mix(in srgb, var(--danger) 16%, var(--panel));
}
.feedback {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
}
.own-feedback {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

/* stars */
.stars {
  display: inline-flex;
}
.star {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: #4a4a45;
  cursor: pointer;
  padding: 0 0.1rem;
}
.star.filled {
  color: var(--accent);
}
.stars-small .star {
  font-size: 0.95rem;
  cursor: default;
}
.stars-readonly .star {
  cursor: default;
}

/* thumbs (accept / reject) */
.thumbs {
  display: inline-flex;
  gap: 0.15rem;
}
.thumb {
  background: none;
  border: none;
  font-size: 1.35rem;
  line-height: 1;
  padding: 0 0.15rem;
  cursor: pointer;
  filter: grayscale(1);
  opacity: 0.4;
  transition: opacity 0.12s;
}
.thumb:hover:enabled {
  opacity: 0.8;
}
.thumb.active {
  filter: none;
  opacity: 1;
}
.thumb:disabled {
  cursor: default;
}
.thumbs-small .thumb {
  font-size: 0.95rem;
}

/* verdict filter */
.filter-bar {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.9rem;
}
.filter-chip {
  background: var(--panel);
  border: 1px solid var(--panel-2);
  border-radius: 999px;
  color: var(--muted);
  padding: 0.25rem 0.8rem;
  font-size: 0.85rem;
  cursor: pointer;
}
.filter-chip.active {
  background: var(--panel-2);
  color: var(--text);
  border-color: var(--accent);
}
.filter-bar-admin {
  justify-content: flex-start;
  margin: 0 0 0.75rem;
}
.filter-stars {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--panel);
  border: 1px solid var(--panel-2);
  border-radius: 999px;
  padding: 0.1rem 0.7rem;
  font-size: 0.85rem;
}
.filter-stars.active {
  border-color: var(--accent);
}
.filter-stars .star {
  cursor: pointer;
}

/* transient action feedback (keyboard votes that navigate away) */
.action-flash {
  position: fixed;
  top: 3rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 110;
  background: var(--panel);
  border: 1px solid var(--panel-2);
  border-radius: 999px;
  padding: 0.35rem 1rem;
  font-size: 0.9rem;
  white-space: nowrap;
  pointer-events: none;
  animation: flash-fade 1.4s ease forwards;
}
@keyframes flash-fade {
  0% {
    opacity: 0;
    transform: translate(-50%, -6px);
  }
  8%,
  70% {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, 0);
  }
}

/* lightbox shortcut help */
.lb-help {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 9, 11, 0.6);
  z-index: 102;
}
.lb-help-card {
  background: var(--panel);
  border: 1px solid var(--panel-2);
  border-radius: 12px;
  padding: 1.1rem 1.5rem 1.25rem;
  min-width: 280px;
  cursor: default;
}
.lb-help-card h3 {
  font-size: 0.95rem;
  margin: 0 0 0.6rem;
}
.lb-help-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.18rem 0;
  font-size: 0.88rem;
}
kbd {
  background: var(--panel-2);
  border-radius: 4px;
  padding: 0.08rem 0.45rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  white-space: nowrap;
}

/* tags */
.tag-editor {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.tag-editor input {
  width: 110px;
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--panel-2);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  font-size: 0.82rem;
}
.chip button {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.95rem;
  padding: 0;
}

/* Touch devices: no hover — selection checkmarks must always be visible,
   and the overlay nav arrows give way to swiping. */
@media (hover: none) {
  .g-check {
    opacity: 1;
  }
  .lb-nav {
    display: none;
  }
  /* No visible arrows to keep clear of — give the photo the width. */
  .lb-slide {
    padding: 0 0.75rem;
  }
}

@media (max-width: 700px) {
  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
  .lb-slide {
    padding: 0 0.5rem;
  }
  .login-card {
    padding: 2rem 1.5rem;
    margin: 0 1rem;
  }
  .share-head {
    padding: 1.25rem 0.75rem 0.25rem;
  }
  .lb-footer {
    padding: 0.5rem 0.6rem calc(0.8rem + env(safe-area-inset-bottom));
  }
  .client-footer {
    gap: 0.8rem;
  }
  /* Finger-sized vote and rating targets in the client lightbox. */
  .client-footer .thumb {
    font-size: 1.7rem;
  }
  .client-footer .star {
    font-size: 1.8rem;
  }
  .select-bar {
    flex-wrap: wrap;
    justify-content: center;
    max-width: calc(100vw - 1.5rem);
    padding: 0.5rem 0.75rem;
    bottom: calc(0.75rem + env(safe-area-inset-bottom));
  }
  /* Share rows: info and controls stack instead of fighting for one line. */
  .share-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding: 0.75rem 0;
  }
  .share-row .row {
    flex-wrap: wrap;
    row-gap: 0.5rem;
  }
  .share-form {
    grid-template-columns: 1fr;
  }
  .share-form .field {
    display: block;
  }
  .share-form .field > input {
    width: 100%;
    margin-top: 0.2rem;
  }
}
