/* Jost (SIL OFL), self-hosted: a Google Fonts @import blocked page scripts for ~350 ms on phones. */
@font-face { font-family: 'Jost'; src: url(/fonts/jost.woff2) format('woff2'); font-weight: 300 700; font-display: swap; }

:root {
  color-scheme: dark;
  --bg: #171411; --surface: #231e1a; --line: #302821; --hover: #352c25; --active: #3f342b;
  --border: #4b3e33; --field: #5b4b3e; --text: #F1ECE4; --muted: #A39E94; --soft: #C4BFB5; --faint: #8F8A80;
  --green: #d6ad79; --green-hi: #e5bf90; --on-green: #26190c; --orange: #edc498; --warn: #FF8A3D;
  --head: 68px; --row-h: 240px; --pad: 32px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 15px/1.5 'Jost', system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--text); }
a:hover { color: var(--green); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
[hidden] { display: none !important; }

.caps { letter-spacing: .18em; text-transform: uppercase; }
.eyebrow { margin: 0 0 12px; font-size: 12px; font-weight: 500; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.title { margin: 0; font-size: 38px; font-weight: 400; letter-spacing: .18em; line-height: 1.1; text-transform: uppercase; }
.rule { display: block; width: 56px; height: 2px; margin-top: 18px; background: var(--green); }
.muted { color: var(--muted); }

/* Header */
.top { position: sticky; top: 0; z-index: 20; height: var(--head); background: rgba(23,20,17,.88); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1440px; height: 100%; margin: 0 auto; padding: 0 var(--pad); display: flex; align-items: center; gap: 12px; }
.brand { flex-grow: 1; min-width: 0; display: flex; align-items: center; gap: 12px; font-weight: 500; font-size: 14px; letter-spacing: .035em; white-space: normal; text-decoration: none; }
.wrap { max-width: 1440px; margin: 0 auto; padding: 44px var(--pad) 60px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); font-size: 13px; font-weight: 500; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--hover); color: var(--text); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--soft); }
.btn.ghost:hover { background: var(--hover); }
.btn.icon { width: 40px; padding: 0; }
.btn.primary { height: 44px; padding: 0 20px; border: 0; background: var(--green); color: var(--on-green); font-size: 14px; font-weight: 600; }
.btn.primary:hover { background: var(--green-hi); color: var(--on-green); }
.btn.light { height: 44px; border: 0; background: var(--text); color: #141413; font-weight: 600; }
.btn:disabled { opacity: .45; cursor: default; }
.seg { display: flex; gap: 4px; padding: 4px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); }
.seg button { height: 32px; padding: 0 14px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--active); color: var(--text); }
.seg button:not([aria-pressed="true"]):hover { background: var(--hover); }
.seg .n { margin-left: 4px; color: var(--muted); }

/* Album headings */
.hero { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 20px 24px; margin-bottom: 20px; }
.hero > div:first-child { flex-grow: 1; }
.sec { margin-bottom: 36px; }
.sec-head { position: sticky; top: var(--head); z-index: 10; display: flex; align-items: center; gap: 16px; margin: 0 calc(-1 * var(--pad)) 12px; padding: 14px var(--pad); background: rgba(23,20,17,.9); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.sec-head > div { flex-grow: 1; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; }
.sec-head h2 { margin: 0; font-size: 16px; font-weight: 500; overflow-wrap: anywhere; min-width: 0; }
.sec-head span { font-size: 13px; color: var(--muted); }

/* Justified rows: keeps photos in order left to right, each at its own aspect ratio */
.rows { display: flex; flex-wrap: wrap; gap: 8px; }
.rows::after { content: ""; flex-grow: 1e4; }
.tile { position: relative; flex: var(--ar) 1 calc(var(--ar) * var(--row-h)); border-radius: 5px; overflow: hidden; background: var(--surface); }
.tile .open { display: block; width: 100%; padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.tile img { display: block; width: 100%; height: auto; aspect-ratio: var(--ar); object-fit: cover; }
.tile .pick { position: absolute; top: 2px; left: 2px; display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: transparent; }
.dot { display: block; width: 22px; height: 22px; border-radius: 50%; border: 2px solid rgba(255,255,255,.9); background: rgba(0,0,0,.25); box-shadow: 0 0 4px rgba(0,0,0,.5); }
.tile.on::after { content: ""; position: absolute; inset: 0; border-radius: 5px; box-shadow: inset 0 0 0 3px var(--green); pointer-events: none; }
.tile.on .dot, .v-sel[aria-pressed="true"] .dot { border: 0; width: 26px; height: 26px; background: var(--green) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230B160B' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center/14px no-repeat; }
.tile .meta { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; gap: 8px; padding: 28px 10px 8px; background: linear-gradient(to top, rgba(0,0,0,.7), transparent); font-size: 12px; opacity: 0; transition: opacity .2s; pointer-events: none; }
.tile:hover .meta { opacity: 1; }
.empty { padding: 80px 0; text-align: center; color: var(--muted); }

/* Bottom selection bar */
.bar { position: fixed; left: 50%; bottom: 20px; z-index: 30; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 24px); display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px; border-radius: 16px; background: rgba(35,30,26,.94); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid var(--border); box-shadow: 0 20px 50px rgba(0,0,0,.55); }
.bar .count { display: flex; flex-direction: column; padding: 0 8px; line-height: 1.3; }
.bar .count small { color: var(--muted); font-size: 12px; }
.bar .note { flex-basis: 100%; margin: 0; text-align: center; font-size: 12px; color: var(--faint); }

.toast { position: fixed; top: 80px; left: 50%; transform: translateX(-50%); z-index: 60; max-width: calc(100vw - 24px); display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 12px; background: var(--text); color: #141413; font-size: 14px; box-shadow: 0 16px 40px rgba(0,0,0,.5); }
.toast a { color: #141413; font-weight: 600; }

/* Viewer */
.viewer { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: #0A0B0A; color: var(--text); }
.viewer[open] { display: flex; flex-direction: column; }
.viewer::backdrop { background: #0A0B0A; }
.v-top { display: flex; align-items: center; gap: 6px; padding: calc(10px + env(safe-area-inset-top)) 12px 10px 16px; }
.v-meta { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.v-title { font-size: 13px; font-weight: 500; letter-spacing: .2em; text-transform: uppercase; }
.v-count { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v-actions { display: flex; gap: 6px; }
.v-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 44px; height: 44px; padding: 0 10px; border: 0; border-radius: 10px; background: transparent; color: var(--text); font-size: 13px; font-weight: 500; }
.v-btn:hover { background: rgba(255,255,255,.1); }
.v-sel .dot { width: 20px; height: 20px; }
.v-sel[aria-pressed="true"] { background: rgba(76,175,79,.16); }
.v-stage { position: relative; flex-grow: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 72px; touch-action: pan-y; }
.v-img { width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-select: none; }
.v-note { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); margin: 0; padding: 6px 12px; border-radius: 999px; background: rgba(23,20,17,.8); font-size: 13px; color: var(--soft); }
.v-prev, .v-next { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; background: rgba(255,255,255,.06); }
.v-prev { left: 12px; } .v-next { right: 12px; }
.v-strip { display: flex; gap: 6px; padding: 12px 16px 4px; overflow-x: auto; justify-content: safe center; scrollbar-width: none; }
.v-strip button { flex: none; width: 60px; height: 42px; padding: 0; border: 2px solid transparent; border-radius: 5px; overflow: hidden; background: var(--surface); opacity: .5; }
.v-strip button[aria-current="true"] { border-color: var(--green); opacity: 1; }
.v-strip img { display: block; width: 100%; height: 100%; object-fit: cover; }
.v-hint { margin: 0; padding: 4px 16px calc(12px + env(safe-area-inset-bottom)); text-align: center; font-size: 12px; color: var(--faint); }

/* Forms */
.card { display: flex; flex-direction: column; gap: 16px; padding: 24px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.step { display: flex; align-items: center; gap: 12px; }
.step h2 { margin: 0; flex-grow: 1; font-size: 14px; font-weight: 500; letter-spacing: .2em; text-transform: uppercase; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: 13px; color: var(--soft); }
.input { height: 46px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--field); background: #0E100E; font-size: 16px; }
.input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(76,175,79,.22); }

@media (max-width: 720px) {
  :root { --pad: 16px; --row-h: 130px; --head: 60px; }
  .title { font-size: 26px; }
  .wrap { padding-top: 28px; }
  .brand { font-size: 14px; letter-spacing: .02em; line-height: 1.15; }
  .top .seg button { padding: 0 9px; }
  .top .seg .n, .top .txt { display: none; }
  .top .btn { padding: 0 10px; }
  .rows { gap: 4px; }
  .v-stage { padding: 0; }
  .v-prev, .v-next, .v-hint { display: none; }
  .bar { left: 8px; right: 8px; bottom: 8px; transform: none; width: auto; max-width: none; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  /* Phones: count on its own line, then Clear and Save together; Save shrinks (with an ellipsis) instead of wrapping. */
  .bar .count { flex-basis: 100%; flex-direction: row; justify-content: space-between; align-items: baseline; padding: 0 4px; }
  .bar .btn { padding: 0 12px; }
  .bar .btn.primary { flex: 1 1 0; min-width: 0; }
  .bar .btn.primary .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
