:root {
  color-scheme: dark;
  --bg: #17191b;
  --surface: #202326;
  --surface-raised: #272a2d;
  --ink: #eeeeeb;
  --muted: #969b9d;
  --line: #34383b;
  --accent: #d6ddd7;
  --accent-ink: #1b211e;
  --danger: #e0a4a0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
}

body.viewer-open {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button,
a,
summary,
label {
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

.topbar {
  height: 68px;
  padding: 0 clamp(18px, 4vw, 60px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .17em;
  text-decoration: none;
}

.brand-mark {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #aab9ae;
  box-shadow: 0 0 12px #aab9ae55;
}

.button {
  min-height: 40px;
  padding: 0 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
  transition:
    background .18s ease,
    border-color .18s ease,
    color .18s ease;
}

.button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.button-primary {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

.button-primary:hover:not(:disabled) {
  background: #eef2ee;
  border-color: #eef2ee;
}

.button-quiet {
  color: var(--ink);
  background: transparent;
  border-color: var(--line);
}

.button-quiet:hover:not(:disabled) {
  background: var(--surface-raised);
  border-color: #555b5e;
}

/* Login */

.login-panel {
  width: min(430px, calc(100% - 36px));
  margin: 12vh auto;
  padding: clamp(24px, 5vw, 40px);
  background: var(--surface);
  border: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .17em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(36px, 6vw, 58px);
  font-weight: 400;
  letter-spacing: -.035em;
}

h2 {
  margin-bottom: 6px;
  font-size: 17px;
  font-weight: 600;
}

.intro,
.panel-copy > p:last-child,
.panel-description {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

form {
  display: grid;
  gap: 10px;
  margin-top: 26px;
}

form label {
  margin-top: 8px;
  color: #c4c8c6;
  font-size: 11px;
  font-weight: 650;
}

input[type="email"],
input[type="password"] {
  width: 100%;
  min-height: 43px;
  padding: 11px 12px;
  color: var(--ink);
  background: #17191b;
  border: 1px solid var(--line);
  border-radius: 3px;
  outline: none;
}

input[type="email"]:focus,
input[type="password"]:focus {
  border-color: #8e9a91;
  box-shadow: 0 0 0 2px #8e9a9126;
}

.login-panel form .button {
  margin-top: 12px;
}

.status {
  min-height: 18px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

/* Gallery header */

.gallery-heading {
  min-height: 225px;
  padding: 52px clamp(18px, 4vw, 60px) 36px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
}

.gallery-heading h1 {
  margin-bottom: 4px;
}

.gallery-heading .status {
  margin-top: 8px;
}

#refresh {
  margin-bottom: 8px;
}

/* Admin upload panel */

.upload-panel {
  margin: 0 clamp(18px, 4vw, 60px) 24px;
  padding: 20px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.panel-copy {
  flex: 1 1 230px;
}

.panel-copy .eyebrow {
  margin-bottom: 8px;
}

.panel-copy > p:last-child {
  margin-bottom: 0;
}

.upload-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.folder-button {
  position: relative;
  overflow: hidden;
}

.folder-button input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.upload-status {
  flex-basis: 100%;
  margin-top: -6px;
}

/* Viewer account management */

.users-panel {
  margin: 0 clamp(18px, 4vw, 60px) 24px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.users-panel details {
  padding: 15px 18px;
}

.users-panel summary {
  color: #cdd1ce;
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}

.users-content {
  padding-top: 16px;
}

.panel-description {
  margin-bottom: 0;
}

.user-form {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) auto;
  align-items: end;
  gap: 10px;
  margin: 14px 0 0;
}

.user-form label {
  grid-row: 1;
}

.user-form input {
  grid-row: 2;
}

.user-form button {
  grid-column: 3;
  grid-row: 2;
  white-space: nowrap;
}

.user-list {
  margin-top: 12px;
}

.user-row {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  color: #c4c8c6;
  font-size: 12px;
}

.user-row .button {
  min-height: 34px;
  color: var(--danger);
}

/* Edge-to-edge photo grid */

.photo-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
}

.photo-tile {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  color: var(--ink);
  background: #202326;
  border: 0;
  border-radius: 0;
  cursor: pointer;
}

.photo-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition:
    transform .45s cubic-bezier(.2, .7, .2, 1),
    opacity .25s ease;
}

.photo-tile::after {
  position: absolute;
  inset: 35% 0 0;
  content: "";
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(transparent, #000a);
  transition: opacity .2s ease;
}

.photo-tile:hover img,
.photo-tile:focus-visible img {
  transform: scale(1.035);
}

.photo-tile:hover::after,
.photo-tile:focus-visible::after {
  opacity: 1;
}

.photo-tile:focus-visible {
  z-index: 1;
  outline: 2px solid #d6ddd7;
  outline-offset: -3px;
}

.tile-name {
  position: absolute;
  z-index: 1;
  right: 14px;
  bottom: 12px;
  left: 14px;
  overflow: hidden;
  color: white;
  font-size: 11px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(4px);
  transition:
    opacity .2s ease,
    transform .2s ease;
}

.photo-tile:hover .tile-name,
.photo-tile:focus-visible .tile-name {
  opacity: 1;
  transform: translateY(0);
}

.empty-state {
  margin: 0;
  padding: 90px 20px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* Lightbox: image fits inside the viewport */

.lightbox {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: block;
  overflow: hidden;
  padding: 0;
  background: rgb(13 14 15 / 97%);
}

.lightbox-close {
  position: absolute;
  z-index: 10;
  top: 16px;
  right: 22px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: rgb(32 35 38 / 85%);
  border: 1px solid #ffffff2a;
  border-radius: 50%;
  cursor: pointer;
  font-size: 28px;
  line-height: 1;
}

.lightbox-close:hover,
.lightbox-arrow:hover:not(:disabled) {
  background: #ffffff20;
}

.lightbox-stage {
  position: absolute;
  inset: 58px 72px 82px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
}

.lightbox-stage img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 20px 80px #0008;
}

.lightbox-arrow {
  position: absolute;
  z-index: 5;
  top: 50%;
  width: 48px;
  height: 56px;
  padding: 0;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: rgb(32 35 38 / 85%);
  border: 1px solid rgb(255 255 255 / 30%);
  border-radius: 4px;
  cursor: pointer;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 38px;
  line-height: 1;
  opacity: 1;
  visibility: visible;
  transform: translateY(-50%);
}

.lightbox-arrow:disabled {
  opacity: .45;
  cursor: default;
}

.lightbox-prev {
  left: 14px;
}

.lightbox-next {
  right: 14px;
}

.lightbox-footer {
  position: absolute;
  z-index: 5;
  right: 22px;
  bottom: 0;
  left: 22px;
  min-height: 68px;
  padding: 10px 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.lightbox-name {
  max-width: min(70vw, 700px);
  margin: 0 0 4px;
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lightbox-counter {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .08em;
}

/* Responsive layouts */

@media (max-width: 1000px) {
  .photo-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 650px) {
  .topbar {
    height: 60px;
  }

  .gallery-heading {
    min-height: 190px;
    padding-top: 38px;
    padding-bottom: 28px;
  }

  .photo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .upload-panel {
    margin-right: 12px;
    margin-left: 12px;
    padding: 16px;
  }

  .users-panel {
    margin-right: 12px;
    margin-left: 12px;
  }

  .upload-actions {
    width: 100%;
  }

  .upload-actions .button {
    flex: 1;
  }

  .user-form {
    grid-template-columns: 1fr;
  }

  .user-form label,
  .user-form input,
  .user-form button {
    grid-column: 1;
    grid-row: auto;
  }

  .lightbox-stage {
    inset: 58px 48px 82px;
  }

  .lightbox-prev {
    left: 5px;
  }

  .lightbox-next {
    right: 5px;
  }

  .lightbox-arrow {
    width: 38px;
    height: 48px;
  }

  .lightbox-footer {
    right: 12px;
    left: 12px;
  }

  .lightbox-close {
    top: 10px;
    right: 12px;
  }
}

@media (max-width: 380px) {
  .photo-grid {
    grid-template-columns: 1fr;
  }
}



/* Admin photo selection and bulk-delete controls */

.selection-toolbar {
  min-height: 56px;
  margin: 0;
  padding: 10px clamp(18px, 4vw, 60px);
  display: flex;
  align-items: center;
  gap: 18px;
  background: #202326;
  border-top: 1px solid #34383b;
  border-bottom: 1px solid #34383b;
}

.select-all-label {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #cdd1ce;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.select-all-checkbox,
.photo-select input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: #d6ddd7;
  cursor: pointer;
}

.selection-count {
  color: #969b9d;
  font-size: 12px;
}

.selection-status {
  margin-left: auto;
  color: #b8c2ba;
  font-size: 12px;
}

.button-delete {
  min-height: 36px;
  color: #f0c4c0;
  background: transparent;
  border: 1px solid #76504e;
}

.button-delete:hover:not(:disabled) {
  color: #fff;
  background: #704441;
  border-color: #9a625d;
}

.button-delete:disabled {
  opacity: .4;
  cursor: not-allowed;
}

/* Each tile contains a separate open button and admin checkbox. */
.photo-tile {
  padding: 0;
  border: 0;
}

.photo-open {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  overflow: hidden;
  color: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.photo-open img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-select {
  position: absolute;
  z-index: 3;
  top: 12px;
  left: 12px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: rgb(15 17 18 / 78%);
  border: 1px solid rgb(255 255 255 / 35%);
  border-radius: 4px;
  cursor: pointer;
  opacity: .82;
  transition: opacity .18s ease, background .18s ease;
}

.photo-tile:hover .photo-select,
.photo-tile:focus-within .photo-select,
.photo-tile.is-selected .photo-select {
  opacity: 1;
}

.photo-tile.is-selected {
  outline: 3px solid #d6ddd7;
  outline-offset: -3px;
  z-index: 2;
}

.photo-tile.is-selected .photo-select {
  background: #384c43;
}

@media (max-width: 650px) {
  .selection-toolbar {
    padding: 10px 12px;
    flex-wrap: wrap;
    gap: 12px;
  }

  .selection-status {
    flex-basis: 100%;
    margin-left: 0;
  }
}