:root {
  color-scheme: light;
  --bg: #f6f4f1;
  --text: #24211e;
  --muted: #6d6760;
  --line: #d7d1c9;
  --panel: #fffefa;
  --accent: #146c6c;
  --accent-dark: #0d4d4d;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 22px;
  background: rgba(255, 254, 250, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: 0;
}

p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

input {
  width: min(360px, 45vw);
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--text);
  font: inherit;
}

input[type="search"],
input[type="password"] {
  font-size: 16px;
}

button,
a {
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--text);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
a:hover {
  border-color: var(--accent);
}

button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

main {
  padding: 18px;
}

.selection-bar {
  position: sticky;
  bottom: 12px;
  z-index: 4;
  width: min(680px, calc(100% - 24px));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 14px auto 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 254, 250, 0.96);
  box-shadow: 0 10px 30px rgba(36, 33, 30, 0.16);
  backdrop-filter: blur(12px);
}

.selection-bar strong {
  min-width: 92px;
  font-size: 14px;
}

.load-more {
  width: min(360px, 100%);
  margin: 14px auto 0;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  cursor: default;
}

.filter-drawer {
  width: min(520px, calc(100vw - 24px));
  max-height: min(760px, calc(100vh - 24px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}

.filter-drawer::backdrop {
  background: rgba(0, 0, 0, 0.36);
}

.filter-shell {
  max-height: inherit;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.filter-shell header,
.filter-shell footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.filter-shell footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.filter-shell > input {
  width: auto;
  margin: 12px 14px;
}

.inline-close {
  position: static;
  flex: 0 0 auto;
  width: 40px;
  color: var(--text);
  background: white;
  border-color: var(--line);
}

.filter-people {
  min-height: 160px;
  display: grid;
  align-content: start;
  gap: 6px;
  overflow: auto;
  padding: 0 14px 14px;
}

.filter-person {
  height: auto;
  min-height: 64px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  grid-template-rows: 1fr 1fr;
  gap: 1px 10px;
  justify-content: start;
  padding: 7px;
  text-align: left;
}

.filter-person::after {
  content: "";
  grid-column: 3;
  grid-row: 1 / span 2;
  align-self: center;
  width: 20px;
  height: 20px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: white;
}

.filter-person.selected {
  border-color: var(--accent);
  background: rgba(20, 108, 108, 0.08);
}

.filter-person.selected::after {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: inset 0 0 0 4px white;
}

.filter-person img {
  grid-row: 1 / span 2;
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  background: #e6e0d8;
}

.filter-person span {
  align-self: end;
  overflow: hidden;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-person small {
  align-self: start;
  color: var(--muted);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-head > div {
  min-width: 0;
}

#reviewMode {
  flex: 0 0 auto;
}

h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.15;
  letter-spacing: 0;
}

.people-panel {
  margin-bottom: 18px;
}

.people-grid {
  display: block;
}

.guest-people {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}

.guest-person {
  height: auto;
  min-height: 76px;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  grid-template-rows: 1fr 1fr;
  gap: 2px 10px;
  justify-content: start;
  padding: 8px;
  text-align: left;
}

.guest-person img {
  grid-row: 1 / span 2;
  width: 58px;
  height: 58px;
  border-radius: 6px;
  object-fit: cover;
  background: #e6e0d8;
}

.guest-person span {
  align-self: end;
  overflow: hidden;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.guest-person small {
  align-self: start;
  color: var(--muted);
}

.person-review {
  max-width: 980px;
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.review-main {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.primary-face {
  width: 180px;
  height: 180px;
  border-radius: 7px;
  object-fit: cover;
  background: #e6e0d8;
}

.review-details {
  min-width: 0;
}

h3 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 22px;
  line-height: 1.15;
  letter-spacing: 0;
}

.face-samples {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 3px;
  min-height: 28px;
}

.face-samples img {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 4px;
  object-fit: cover;
  background: #e6e0d8;
}

.review-samples {
  grid-template-columns: repeat(12, minmax(36px, 1fr));
  max-width: 640px;
  margin-top: 12px;
}

.review-actions,
.review-edit {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.review-edit {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
}

.person-review input,
.person-review select,
.person-review button {
  width: 100%;
}

.photo-review {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  grid-template-areas:
    "image tags"
    "controls tags";
  gap: 12px;
  align-items: start;
}

.photo-review-image {
  grid-area: image;
  width: 100%;
  max-height: calc(100vh - 230px);
  object-fit: contain;
  border-radius: 8px;
  background: #111;
}

.photo-review-controls {
  grid-area: controls;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 0.8fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.photo-jump-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.photo-jump-form input {
  width: 100%;
  text-align: center;
}

.photo-tag-panel {
  grid-area: tags;
  display: grid;
  gap: 8px;
}

.photo-tag-panel input {
  width: 100%;
}

.create-tag-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.create-tag-form input {
  width: 100%;
}

.photo-tag-summary {
  margin: 0;
  padding: 9px 10px;
  border: 1px solid rgba(20, 108, 108, 0.24);
  border-radius: 7px;
  background: rgba(20, 108, 108, 0.08);
  color: var(--accent-dark);
  font-weight: 650;
}

.photo-tag-list {
  max-height: calc(100vh - 260px);
  display: grid;
  align-content: start;
  gap: 6px;
  overflow: auto;
}

.photo-tag-divider {
  padding: 8px 2px 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.photo-tag-person {
  height: auto;
  min-height: 62px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  grid-template-rows: 1fr 1fr;
  gap: 1px 10px;
  justify-content: start;
  padding: 7px;
  text-align: left;
}

.photo-tag-person::after {
  content: "";
  grid-column: 3;
  grid-row: 1 / span 2;
  align-self: center;
  width: 20px;
  height: 20px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: white;
}

.photo-tag-person.selected {
  border-color: var(--accent);
  background: rgba(20, 108, 108, 0.08);
}

.photo-tag-person.selected::after {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: inset 0 0 0 4px white;
}

.photo-tag-person img {
  grid-row: 1 / span 2;
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  background: #e6e0d8;
}

.photo-tag-person span {
  align-self: end;
  overflow: hidden;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-tag-person small {
  align-self: start;
  color: var(--muted);
}

select {
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--text);
  font: inherit;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.tile {
  position: relative;
  height: auto;
  padding: 0;
  overflow: hidden;
  aspect-ratio: 1;
  border: 0;
  border-radius: 7px;
  background: #e6e0d8;
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 160ms ease;
}

.tile:hover img {
  transform: scale(1.03);
}

.tile.selected {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

.tile .photo-number {
  position: absolute;
  left: 7px;
  bottom: 7px;
  min-width: 32px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 7px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.58);
  color: white;
  font-size: 12px;
  line-height: 1;
}

.select-check {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 26px;
  height: 26px;
  display: none;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.86);
  color: transparent;
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
}

.grid.selecting .select-check,
.tile.selected .select-check {
  display: inline-flex;
}

.tile.selected .select-check {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.lightbox {
  width: min(1200px, calc(100vw - 28px));
  height: min(860px, calc(100vh - 28px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: #111;
  color: white;
}

.lightbox::backdrop {
  background: rgba(0, 0, 0, 0.75);
}

.lightbox img {
  width: 100%;
  height: calc(100% - 58px);
  object-fit: contain;
  display: block;
}

.lightbox footer {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.lightbox footer a {
  flex: 0 0 auto;
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

#caption {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button,
.nav-button {
  position: absolute;
  z-index: 2;
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(0, 0, 0, 0.55);
  color: white;
}

.icon-button {
  top: 12px;
  right: 12px;
  width: 42px;
  padding: 0;
  font-size: 28px;
}

.nav-button {
  top: 50%;
  width: 46px;
  padding: 0;
  transform: translateY(-50%);
  font-size: 42px;
}

.nav-button:disabled {
  opacity: 0.25;
  cursor: default;
}

.prev {
  left: 12px;
}

.next {
  right: 12px;
}

.login-page {
  --login-ivory: #f0ebe3;
  --login-ivory-dark: #e4ddd3;
  --login-charcoal: #3d3535;
  --login-muted: #5a5050;
  --login-blush: #d4a5a5;
  --login-blush-light: #f5e6e0;
  --login-blush-dark: #c08e8e;
  --login-gold: #c9a96e;
  min-height: 100vh;
  display: grid;
  place-items: center;
  min-width: 0;
  position: relative;
  overflow: hidden;
  padding: 26px 18px;
  background:
    radial-gradient(circle at 18% 16%, rgba(212, 165, 165, 0.18), transparent 28%),
    radial-gradient(circle at 82% 78%, rgba(201, 169, 110, 0.14), transparent 30%),
    linear-gradient(135deg, rgba(240, 235, 227, 0.96), rgba(228, 221, 211, 0.48) 50%, rgba(240, 235, 227, 0.96));
  color: var(--login-charcoal);
  font-family: "Cormorant Garamond", Georgia, "Times New Roman", serif;
}

.login-shell {
  position: relative;
  z-index: 1;
  min-width: 0;
  width: min(430px, 100%);
  padding: 28px 28px 30px;
  border: 1px solid rgba(201, 169, 110, 0.34);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.42);
  box-shadow: 0 22px 70px rgba(61, 53, 53, 0.14);
  text-align: center;
  backdrop-filter: blur(10px);
  overflow: hidden;
}

.login-floral {
  position: fixed;
  width: 210px;
  height: 210px;
  opacity: 0.16;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(ellipse at center, var(--login-blush), transparent 70%);
}

.login-floral-top-left {
  top: -42px;
  left: -42px;
  border-radius: 0 100% 0 0;
}

.login-floral-top-right {
  top: -42px;
  right: -42px;
  border-radius: 100% 0 0 0;
}

.login-floral-bottom-left {
  bottom: -42px;
  left: -42px;
  border-radius: 0 0 0 100%;
}

.login-floral-bottom-right {
  right: -42px;
  bottom: -42px;
  border-radius: 0 0 100% 0;
}

.login-ornament {
  margin: 0 0 14px;
  color: var(--login-gold);
  font-size: 18px;
  letter-spacing: 0.45em;
  opacity: 0.72;
}

.login-medallion {
  width: min(210px, 64vw);
  aspect-ratio: 1;
  display: block;
  margin: 0 auto 18px;
  border: 4px solid var(--login-blush);
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
  box-shadow:
    0 4px 22px rgba(92, 74, 58, 0.17),
    0 0 0 9px rgba(255, 255, 255, 0.34);
}

.login-kicker {
  max-width: 100%;
  margin: 0;
  color: var(--login-charcoal);
  font-family: "Great Vibes", cursive;
  font-size: clamp(40px, 10vw, 58px);
  line-height: 1.05;
  white-space: nowrap;
}

.login-shell h1 {
  margin-top: 8px;
  color: var(--login-muted);
  font-family: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: 0.28em;
  line-height: 1.35;
  text-transform: uppercase;
}

.login-copy {
  max-width: 320px;
  margin: 15px auto 0;
  color: var(--login-muted);
  font-size: 21px;
  font-style: italic;
  font-weight: 300;
  line-height: 1.55;
}

.login-form {
  display: grid;
  gap: 12px;
  margin-top: 24px;
}

.login-form input,
.login-form button {
  width: 100%;
}

.login-form input {
  height: 52px;
  border-color: var(--login-ivory-dark);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.68);
  color: var(--login-charcoal);
  font-family: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  font-size: 21px;
  text-align: center;
  outline: none;
  transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.login-form input::placeholder {
  color: rgba(90, 80, 80, 0.58);
  font-style: italic;
}

.login-form input:focus {
  border-color: var(--login-blush);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 3px rgba(212, 165, 165, 0.16);
}

.login-form button {
  height: 52px;
  border: 0;
  border-radius: 6px;
  background: var(--login-charcoal);
  color: white;
  font-family: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  transition: background 180ms ease, transform 120ms ease;
}

.login-form button:hover {
  background: var(--login-muted);
}

.login-form button:active {
  transform: scale(0.985);
}

.login-error {
  margin-top: 14px;
  color: #8b3a3a;
  font-size: 17px;
  font-style: italic;
}

@media (max-width: 720px) {
  .topbar {
    position: static;
    display: grid;
    gap: 8px;
    padding: 10px;
  }

  .tools {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-areas:
      "photos filters select logout"
      "search search search clear";
    gap: 8px;
  }

  h1 {
    font-size: 19px;
  }

  p {
    font-size: 13px;
  }

  button,
  a,
  input,
  select {
    min-height: 42px;
  }

  input {
    width: 100%;
  }

  #showPhotos {
    grid-area: photos;
  }

  #openFilters {
    grid-area: filters;
  }

  #toggleSelect {
    grid-area: select;
  }

  #showReview:not([hidden]) {
    grid-area: review;
  }

  .tools:has(#showReview:not([hidden])) {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-template-areas:
      "photos filters select review logout"
      "search search search search clear";
  }

  .tools input {
    grid-area: search;
  }

  #clear {
    grid-area: clear;
  }

  .tools a {
    grid-area: logout;
  }

  main {
    padding: 8px;
  }

  .selection-bar {
    bottom: 8px;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto minmax(0, 1.4fr);
    margin-top: 10px;
    padding: 8px;
  }

  .filter-drawer {
    width: 100vw;
    max-width: 100vw;
    max-height: min(82dvh, 720px);
    margin: auto 0 0;
    border-radius: 12px 12px 0 0;
  }

  .filter-shell header,
  .filter-shell footer {
    padding: 10px;
  }

  .filter-shell > input {
    margin: 10px;
  }

  .filter-people {
    padding: 0 10px 10px;
  }

  .panel-head {
    display: grid;
    gap: 8px;
  }

  .review-main,
  .review-actions,
  .review-edit,
  .photo-review,
  .photo-review-controls {
    grid-template-columns: 1fr;
  }

  .photo-review {
    grid-template-areas:
      "image"
      "controls"
      "tags";
  }

  .photo-review-image {
    max-height: 62vh;
  }

  .photo-tag-list {
    max-height: 48vh;
  }

  .photo-jump-form {
    grid-template-columns: minmax(0, 1fr) auto;
  }

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

  .primary-face {
    width: min(220px, 100%);
    height: auto;
    aspect-ratio: 1;
  }

  .review-samples {
    grid-template-columns: repeat(6, minmax(34px, 1fr));
  }

  .guest-people {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .guest-person {
    min-height: 68px;
    padding: 7px;
  }

  .guest-person img {
    width: 52px;
    height: 52px;
  }

  .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
  }

  .tile {
    border-radius: 5px;
  }

  .tile .photo-number {
    left: 5px;
    bottom: 5px;
    min-width: 26px;
    height: 20px;
    padding: 0 5px;
    font-size: 11px;
  }

  .select-check {
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
  }

  .lightbox {
    width: 100vw;
    height: 100dvh;
    max-width: 100vw;
    max-height: 100dvh;
    border-radius: 0;
  }

  .lightbox img {
    height: calc(100% - 74px);
  }

  .lightbox footer {
    height: 74px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 8px 10px;
  }

  .lightbox footer a {
    height: 38px;
    padding: 0 10px;
    font-size: 13px;
  }

  #caption {
    font-size: 13px;
  }

  .icon-button {
    top: 8px;
    right: 8px;
    width: 40px;
    height: 40px;
  }

  .nav-button {
    width: 40px;
    height: 48px;
    font-size: 34px;
  }

  .prev {
    left: 8px;
  }

  .next {
    right: 8px;
  }

  .login-page {
    padding: 18px;
  }

  .login-shell {
    width: min(calc(100vw - 36px), 354px);
    padding: 24px 20px 26px;
  }

  .login-medallion {
    width: min(178px, 58vw);
    margin-bottom: 16px;
  }

  .login-kicker {
    font-size: clamp(34px, 9.2vw, 38px);
    line-height: 1.08;
  }

  .login-shell h1 {
    font-size: 15px;
    letter-spacing: 0.22em;
  }

  .login-copy {
    font-size: 19px;
  }

  .login-form input,
  .login-form button {
    height: 50px;
  }
}
