:root {
  color-scheme: light;
  --background: #f8f7f2;
  --surface: #fffefa;
  --text: #222923;
  --muted: #536259;
  --line: #d9dfd5;
  --accent: #21654d;
  --placeholder: #e8ece4;
  font-family: system-ui, sans-serif;
  background: var(--background);
  color: var(--text);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #171d19;
  --surface: #202922;
  --text: #f2f5ed;
  --muted: #b6c4b9;
  --line: #3a4840;
  --accent: #a4dfbd;
  --placeholder: #2a372f;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled {
  cursor: default;
  opacity: .45;
}
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}
ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.container {
  width: min(100% - 2rem, 70rem);
  margin-inline: auto;
}
.masthead {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: .7rem;
  min-height: 3.75rem;
  font-weight: 650;
}
.brand-mark {
  display: inline-block;
  width: 1.15rem;
  height: 1rem;
  border: 2px solid var(--accent);
  border-radius: .2rem;
  box-shadow: .22rem -.22rem 0 -.07rem var(--surface), .25rem -.25rem 0 0 var(--accent);
}
main { padding-block: clamp(1.5rem, 5vw, 3.75rem) 3rem; }
.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
h1 {
  font-family: Georgia, serif;
  font-size: clamp(2.25rem, 7vw, 4rem);
  font-weight: 400;
  line-height: 1.05;
  margin: 0;
  overflow-wrap: anywhere;
}
input[type="search"] {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: .65rem;
  min-height: 2.75rem;
  padding: .55rem .85rem;
  width: min(17rem, 100%);
}
input::placeholder { color: var(--muted); }
.album-grid, .photo-grid {
  display: grid;
  gap: clamp(.65rem, 2vw, 1.25rem);
}
.album-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr)); }
.photo-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 9rem), 1fr)); }
.card {
  display: block;
  width: 100%;
  padding: 0;
  text-align: left;
  background: var(--surface);
  color: inherit;
  border: 1px solid var(--line);
  border-radius: .8rem;
  overflow: hidden;
}
.card:hover { border-color: var(--accent); }
.tile {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  background: var(--placeholder);
  color: var(--muted);
}
.album-grid .tile { aspect-ratio: 4 / 3; }
.tile img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.tile-fallback {
  padding: .5rem;
  text-align: center;
  font-size: .875rem;
}
.album-card-text {
  display: grid;
  gap: .3rem;
  padding: .8rem .9rem 1rem;
  overflow-wrap: anywhere;
}
.photo-card-text {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: .5rem .65rem;
  font-size: .875rem;
}
.caption, .album-path {
  color: var(--muted);
  font-size: .875rem;
  margin: .6rem 0 1.1rem;
}
.album-card-text .caption { margin: 0; }
.status {
  padding: .9rem 1rem;
  margin: 0 0 1rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: .65rem;
  background: var(--surface);
}
.button, .back-button {
  min-height: 2.75rem;
  padding: .5rem .8rem;
  border-radius: .55rem;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}
.button:not(:disabled):hover, .back-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.back-button { margin-bottom: 1.4rem; }
.more {
  display: block;
  margin: 1.5rem auto 0;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

dialog {
  width: min(calc(100% - 1rem), 65rem);
  max-width: none;
  max-height: calc(100dvh - 1rem);
  padding: 0;
  border: 1px solid #3b4640;
  border-radius: .9rem;
  background: #151a17;
  color: #fff;
}
dialog::backdrop { background: rgb(8 12 10 / .82); }
dialog .button {
  background: #252e28;
  border-color: #536359;
  color: #fff;
}
dialog .button:not(:disabled):hover { color: #c1e8cf; }
dialog :focus-visible { outline-color: #c1e8cf; }
.viewer-header, .viewer-footer {
  padding: .65rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  justify-content: space-between;
}
.viewer-header p {
  margin: 0;
  overflow-wrap: anywhere;
}
.viewer-image {
  min-height: min(45dvh, 18rem);
  display: grid;
  place-items: center;
  padding-inline: .65rem;
}
.viewer-image img {
  width: 100%;
  max-height: min(70dvh, calc(100dvh - 10rem));
  object-fit: contain;
}
.viewer-image p { text-align: center; }
.viewer-footer { font-size: .875rem; }
.viewer-footer .button { padding-inline: .55rem; }

@media (max-width: 30rem) {
  .album-grid, .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-heading label, input[type="search"] { width: 100%; }
}
