:root {
  color-scheme: dark;
  --bg: #17191b;
  --surface: #202326;
  --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;
  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;
}
.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; }
.button-quiet { color: var(--ink); background: transparent; border-color: var(--line); }
.button-quiet:hover:not(:disabled) { background: var(--raised); border-color: #555b5e; }

.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: 400 clamp(36px, 6vw, 58px)/1.05 Georgia, "Times New Roman", serif;
  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: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-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; }

.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; }
.file-button { position: relative; overflow: hidden; }
.file-button input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.upload-status { flex-basis: 100%; margin-top: -6px; }

.users-panel {
  margin: 0 clamp(18px, 4vw, 60px) 20px;
  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; }

.selection-toolbar {
  min-height: 56px;
  padding: 10px clamp(18px, 4vw, 60px);
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--surface);
  border-block: 1px solid var(--line);
}
.select-all-label {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #cdd1ce;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}
.select-all-label input, .photo-select input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.selection-count, .selection-status { color: var(--muted); font-size: 12px; }
.selection-status { margin-left: auto; }
.button-delete { color: #f0c4c0; background: transparent; border-color: #76504e; }
.button-delete:hover:not(:disabled) { color: white; background: #704441; }

.photo-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
}
.photo-tile {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #202326;
}
.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%;
  display: block;
  object-fit: cover;
  transition: transform .45s cubic-bezier(.2, .7, .2, 1);
}
.photo-tile:hover img, .photo-tile:focus-within img { transform: scale(1.035); }
.photo-tile:focus-within { outline: 2px solid var(--accent); outline-offset: -3px; }
.photo-open::after {
  position: absolute;
  inset: 35% 0 0;
  content: "";
  pointer-events: none;
  background: linear-gradient(transparent, #000a);
  opacity: 0;
  transition: opacity .2s ease;
}
.photo-tile:hover .photo-open::after, .photo-tile:focus-within .photo-open::after { opacity: 1; }
.tile-name {
  position: absolute;
  right: 14px;
  bottom: 12px;
  left: 14px;
  overflow: hidden;
  color: white;
  font-size: 11px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0;
}
.photo-tile:hover .tile-name, .photo-tile:focus-within .tile-name { opacity: 1; }
.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;
}
.photo-tile.is-selected { outline: 3px solid var(--accent); outline-offset: -3px; z-index: 2; }
.empty-state { margin: 0; padding: 90px 20px; color: var(--muted); font-size: 13px; text-align: center; }

.lightbox {
  position: fixed;
  z-index: 1000;
  inset: 0;
  overflow: hidden;
  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: #202326dd;
  border: 1px solid #ffffff2a;
  border-radius: 50%;
  cursor: pointer;
  font-size: 28px;
}
.lightbox-stage {
  position: absolute;
  inset: 58px 72px 82px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-stage img {
  display: block;
  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;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: #202326dd;
  border: 1px solid #ffffff4d;
  border-radius: 4px;
  cursor: pointer;
  font: 38px Georgia, serif;
  transform: translateY(-50%);
}
.lightbox-arrow:disabled { opacity: .45; cursor: default; }
.lightbox-prev { left: 14px; }
.lightbox-next { right: 14px; }
.lightbox-footer {
  position: absolute;
  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(55vw, 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; }
.lightbox-actions { display: flex; gap: 8px; }

@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-inline: 12px; padding: 16px; }
  .users-panel { margin-inline: 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; }
  .selection-toolbar { padding: 10px 12px; flex-wrap: wrap; gap: 12px; }
  .selection-status { flex-basis: 100%; margin-left: 0; }
  .lightbox-stage { inset: 58px 48px 100px; }
  .lightbox-prev { left: 5px; }
  .lightbox-next { right: 5px; }
  .lightbox-arrow { width: 38px; height: 48px; }
  .lightbox-footer { right: 12px; left: 12px; flex-wrap: wrap; }
  .lightbox-close { top: 10px; right: 12px; }
}
@media (max-width: 430px) {
  .lightbox-actions { width: 100%; justify-content: flex-end; }
  .lightbox-footer { gap: 4px; }
}
@media (max-width: 380px) {
  .photo-grid { grid-template-columns: 1fr; }
}