:root {
  color: #242823;
  background: #f5f4ef;
  font:
    15px/1.4 system-ui,
    sans-serif;
  --paper: #fffefa;
  --line: #deddd4;
  --green: #265b49;
  --muted: #565e57;
}
* {
  box-sizing: border-box;
}
body,
p,
h1,
h2 {
  margin: 0;
}
button {
  font: inherit;
  cursor: pointer;
  color: inherit;
}
button:disabled {
  cursor: wait;
}
:focus-visible {
  outline: 2px solid #288568;
  outline-offset: 3px;
}
.wrap {
  width: min(100%, 1512px);
  margin-inline: auto;
  padding-inline: clamp(14px, 3vw, 42px);
}
header {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
nav {
  display: flex;
  gap: 5px;
  padding-block: 12px;
  overflow-x: auto;
}
nav button {
  flex: none;
  min-height: 38px;
  padding: 5px clamp(10px, 2vw, 23px);
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  font-weight: 650;
}
nav button:hover {
  background: #e9eee8;
}
nav button[aria-pressed='true'],
.primary {
  background: var(--green);
  color: white;
}
#status {
  margin-block: 14px;
  color: var(--muted);
  font-size: 0.85rem;
}
#status.error {
  color: #992c23;
}
.catalog {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 245px), 1fr));
  gap: 12px;
  align-items: start;
  padding-bottom: 28px;
}
.card {
  overflow: hidden;
  min-width: 0;
  border-radius: 8px;
  background: var(--paper);
  border: 1px solid var(--line);
}
.photo {
  position: relative;
}
.replace,
.add {
  display: grid;
  place-items: center;
  width: 100%;
  border: 0;
  padding: 0;
  aspect-ratio: 3 / 2;
  background: #eae9e0;
}
.replace:hover {
  box-shadow: inset 0 0 0 2px var(--green);
}
.replace:focus-visible,
.add:focus-visible {
  outline-offset: -4px;
}
.replace img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}
.eye {
  position: absolute;
  right: 7px;
  bottom: 7px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 34px;
  padding: 0;
  border: 1px solid #e4e5dc;
  border-radius: 6px;
  color: #222b24;
  background: #fffefa;
}
.eye:hover,
.add:hover {
  background: #e9eee8;
  color: var(--green);
}
.eye svg {
  width: 19px;
  height: 19px;
}
.caption {
  padding: 8px 9px 9px;
  overflow-wrap: anywhere;
}
.caption h2 {
  font-size: 0.88rem;
  line-height: 1.25;
  font-weight: 700;
}
.caption p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.75rem;
}
.add {
  border: 1px dashed #aab3a6;
  border-radius: 8px;
  background: transparent;
  color: var(--green);
  font-weight: 650;
  align-content: center;
  gap: 4px;
}
.add span {
  font-size: 1.45rem;
  line-height: 1;
}
#viewer {
  position: fixed;
  inset: 0;
  margin: auto;
  border: 0;
  border-radius: 9px;
  padding: 0;
  width: min(94vw, 1380px);
  max-width: none;
  height: 88dvh;
  max-height: none;
  background: #101311;
}
#viewer::backdrop {
  background: #101311bf;
}
#viewer img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
#close-viewer {
  position: absolute;
  top: 9px;
  right: 9px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid #fff7;
  border-radius: 6px;
  background: #111e;
  color: white;
  font-size: 1.55rem;
  line-height: 1;
}
.caption a {
  color: inherit;
  text-underline-offset: 2px;
}
.caption a:hover {
  color: var(--green);
}
.caption .source {
  display: inline-block;
  font-size: 0.72rem;
  margin-top: 3px;
  color: var(--green);
}
#add-dialog {
  width: min(400px, 92vw);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 18px;
  background: var(--paper);
  color: inherit;
}
#add-dialog::backdrop {
  background: #1013118c;
}
#add-form,
#add-form label {
  display: grid;
  gap: 5px;
}
#add-form {
  gap: 12px;
}
#add-form h2 {
  font-size: 1.15rem;
}
#add-form label {
  font-size: 0.85rem;
}
#add-form textarea {
  resize: vertical;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 6px;
  font: inherit;
}
#add-error {
  font-size: 0.8rem;
}
#add-error:empty {
  display: none;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}
.form-actions button {
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 6px 12px;
}
.gate {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  justify-items: start;
  gap: 10px;
}
.gate h1 {
  font-size: 1.65rem;
}
.gate button {
  padding: 7px 14px;
  border: 0;
  border-radius: 6px;
}
@media (max-width: 580px) {
  .catalog {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .caption {
    padding: 6px;
  }
  .caption h2 {
    font-size: 0.82rem;
  }
}
