:root {
  color-scheme: light dark;
  --bg: #f6f6f4;
  --surface: #ffffff;
  --text: #1c1d21;
  --muted: #6b6e76;
  --border: #e2e2de;
  --accent: #e4572e;
  --accent-text: #ffffff;
  --like: #e0245e;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 16px rgb(0 0 0 / 6%);
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.45;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171a;
    --surface: #212226;
    --text: #ececec;
    --muted: #9a9ca3;
    --border: #33353a;
    --accent: #ff7a50;
    --accent-text: #16171a;
    --like: #ff4d7d;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 4px 16px rgb(0 0 0 / 30%);
  }
}

* { box-sizing: border-box; }
html { background: var(--bg); color: var(--text); }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; line-height: 1.2; }
h2 { font-size: 1.05rem; margin: 1.5rem 0 .75rem; }
.muted { color: var(--muted); margin: 0; }
[hidden] { display: none !important; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1rem; padding: .6rem clamp(.75rem, 3vw, 2rem);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .5rem; color: var(--text); text-decoration: none; font-weight: 650; white-space: nowrap; }
.brand svg { color: var(--accent); }
.search { position: relative; flex: 1; max-width: 32rem; margin-left: auto; }
.suggestions {
  position: absolute; left: 0; right: 0; top: calc(100% + .35rem); z-index: 20; margin: 0; padding: .35rem;
  list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.suggestions li {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  padding: .45rem .7rem; border-radius: 6px; cursor: pointer;
}
.suggestions li:hover, .suggestions li[aria-selected="true"] { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.suggestions small { color: var(--muted); white-space: nowrap; }
.search input {
  width: 100%; padding: .6rem .9rem; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; outline: none;
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
@media (max-width: 560px) { .brand span { display: none; } }

main { flex: 1; width: 100%; max-width: 1600px; margin: 0 auto; padding: 1.25rem clamp(.75rem, 3vw, 2rem) 2rem; }
.foot {
  position: sticky; bottom: 0; z-index: 10;
  display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: .25rem 1rem;
  padding: .45rem clamp(.75rem, 3vw, 2rem); color: var(--muted); font-size: .8rem; text-align: center;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-top: 1px solid var(--border);
}
.foot p { margin: 0; }
.foot .donate { font-size: .9rem; }
@media (max-width: 40rem) { .foot .credit { display: none; } }
.foot .donate a { font-weight: 600; text-decoration: none; }
.foot .donate a:hover { text-decoration: underline; }
.fallback img { max-width: 100%; height: auto; }

/* Gallery */
.toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar select, .btn {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: .45rem .9rem; cursor: pointer;
}
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 45vw), 1fr)); gap: .5rem; }
.tile {
  position: relative; display: block; aspect-ratio: 3 / 2; overflow: hidden; border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s ease; }
.tile:hover img, .tile:focus-visible img { transform: scale(1.04); }
.tile-meta {
  position: absolute; inset: auto 0 0 0; display: flex; gap: .5rem; justify-content: space-between;
  padding: 1.2rem .55rem .35rem; font-size: .75rem; color: #fff;
  background: linear-gradient(transparent, rgb(0 0 0 / 55%)); opacity: .9;
}
.tile-likes { color: #ffd0dc; }
.sentinel { height: 1px; }
.message { padding: 3rem 0; text-align: center; }

/* Photo view */
.photo-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.btn { display: inline-flex; align-items: center; gap: .4rem; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn svg { width: 1.15em; height: 1.15em; }
.btn-ghost { background: transparent; border-color: transparent; padding-left: 0; }
.gallery-back { margin-bottom: .5rem; }
.stage { position: relative; display: flex; justify-content: center; }
.frame {
  position: relative; width: min(100%, calc((100svh - 11rem) * var(--ratio)));
  background: var(--surface) center / cover no-repeat; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.frame img { display: block; width: 100%; height: auto; }
.face { position: absolute; border: 2px solid transparent; border-radius: 6px; transition: border-color .2s; }
.stage:hover .face { border-color: rgb(255 255 255 / 55%); }
.face:hover, .face:focus-visible { border-color: var(--accent) !important; }
.stage-nav {
  position: absolute; top: 50%; translate: 0 -50%; display: grid; place-items: center;
  width: 2.75rem; height: 2.75rem; border-radius: 50%; color: #fff; background: rgb(0 0 0 / 40%);
}
.stage-nav svg { width: 1.75rem; height: 1.75rem; }
.stage-nav.prev { left: .5rem; }
.stage-nav.next { right: .5rem; }
.stage-nav:hover { background: rgb(0 0 0 / 65%); }
.photo-bar { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-top: 1rem; }
.photo-info h1 { font-size: 1.25rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.chip {
  padding: .2rem .65rem; border-radius: 999px; font-size: .85rem; text-decoration: none;
  background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--text);
}
.chip-maybe { background: transparent; border: 1px dashed var(--border); }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.like[aria-pressed="true"] { color: var(--like); border-color: var(--like); }
.share { position: relative; }
.share summary { list-style: none; }
.share summary::-webkit-details-marker { display: none; }
.menu {
  position: absolute; right: 0; top: calc(100% + .35rem); z-index: 5; min-width: 11rem; padding: .35rem;
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.menu-item {
  font: inherit; text-align: left; color: var(--text); text-decoration: none; background: none; border: 0;
  padding: .45rem .7rem; border-radius: 6px; cursor: pointer;
}
.menu-item:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.strip-row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(170px, 1fr); gap: .5rem; overflow-x: auto; padding-bottom: .5rem; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
