:root {
	--bg: #0e0e0f;
	--surface: #18181a;
	--surface-2: #222225;
	--line: #2e2e32;
	--text: #f2f1ee;
	--muted: #9b9a96;
	--accent: #e8c27a;
	--danger: #e0685c;
	--radius: 10px;
	--gap: 6px;
	color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
	font: 15px/1.5 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	-webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
.wrap { max-width: 1400px; margin: 0 auto; padding: 0 16px; }

/* ---------- Header ---------- */
.site-header { padding: 40px 0 24px; }
.site-header h1 {
	font-family: ui-serif, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
	font-weight: 400; font-size: clamp(28px, 5vw, 48px); line-height: 1.1; margin: 0 0 6px; letter-spacing: -0.01em;
}
.site-header .meta { color: var(--muted); margin: 0; }
.site-header .desc { max-width: 680px; margin: 12px 0 0; color: #cfcdc8; white-space: pre-line; }
.notice { color: var(--muted); padding: 60px 0; text-align: center; }

/* ---------- Home: gallery cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; padding-bottom: 60px; }
.card { text-decoration: none; display: block; }
.card .cover { aspect-ratio: 3 / 2; background: var(--surface); border-radius: var(--radius); overflow: hidden; display: grid; place-items: center; color: var(--muted); }
.card .cover img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s; }
.card:hover .cover img { transform: scale(1.02); }
.card h2 { font-size: 17px; font-weight: 500; margin: 10px 0 0; }
.card p { color: var(--muted); margin: 0; font-size: 14px; }

/* ---------- Justified photo grid ---------- */
.grid { display: flex; flex-wrap: wrap; gap: var(--gap); padding-bottom: 60px; }
.grid::after { content: ""; flex-grow: 999999; }
.tile { position: relative; background: var(--surface); overflow: hidden; border-radius: 3px; cursor: zoom-in; }
.tile i { display: block; }
.tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .3s; }
.tile img.loaded { opacity: 1; }
.tile .tile-save {
	position: absolute; right: 6px; bottom: 6px; width: 34px; height: 34px; border-radius: 50%;
	background: rgba(0,0,0,.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
	border: 0; display: grid; place-items: center; cursor: pointer; opacity: 0; transition: opacity .2s;
}
.tile:hover .tile-save, .tile .tile-save:focus-visible { opacity: 1; }
@media (hover: none) { .tile .tile-save { opacity: .9; width: 30px; height: 30px; } }

/* ---------- Lightbox ---------- */
.lightbox { position: fixed; inset: 0; background: #000; z-index: 50; display: none; flex-direction: column; touch-action: none; }
.lightbox.open { display: flex; }
.lb-stage { flex: 1; min-height: 0; position: relative; overflow: hidden; }
/* Fill the stage and letterbox inside it, so tall and wide photos both fit whole on any screen. */
.lb-stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-select: none; }
.lb-top, .lb-bottom { display: flex; align-items: center; gap: 10px; padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); }
.lb-bottom { padding-bottom: max(14px, env(safe-area-inset-bottom)); justify-content: center; flex-wrap: wrap; }
.lb-count { color: var(--muted); font-size: 14px; flex: 1; }
.icon-btn { background: transparent; border: 0; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: rgba(255,255,255,.08); }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(0,0,0,.35); }
.lb-prev { left: 12px; } .lb-next { right: 12px; }
@media (hover: none) { .lb-nav { display: none; } }

.save-btn {
	display: inline-flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 22px;
	border-radius: 999px; border: 0; background: var(--text); color: #111; font-weight: 600; font-size: 16px; cursor: pointer;
	text-decoration: none;
}
.save-btn:disabled { opacity: .7; cursor: progress; }
.save-btn.pulse { animation: pulse 1s ease 2; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(242,241,238,.15); } }
.save-sub { width: 100%; text-align: center; color: var(--muted); font-size: 12.5px; }

.tip {
	position: sticky; bottom: 0; margin: 0 -16px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
	background: rgba(24,24,26,.94); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
	border-top: 1px solid var(--line); font-size: 14px; display: flex; gap: 10px; align-items: center;
}
.tip span { flex: 1; color: #d6d4cf; }
.tip button { background: none; border: 0; color: var(--muted); padding: 6px; cursor: pointer; }

/* ---------- Lock form ---------- */
.lock { max-width: 360px; margin: 40px auto; text-align: center; }
.lock input { width: 100%; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); margin: 14px 0 10px; }
.lock .save-btn { width: 100%; justify-content: center; }
.err { color: var(--danger); min-height: 1.5em; margin: 6px 0 0; font-size: 14px; }

.toast {
	position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 80;
	background: var(--surface-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 999px; font-size: 14px;
	opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 1; }

/* Phone turned sideways (short screens): float the controls over the photo so it gets the full height. */
@media (max-height: 500px) {
	.lb-top, .lb-bottom { position: absolute; left: 0; right: 0; z-index: 2; }
	.lb-top { top: 0; padding-top: 6px; background: linear-gradient(rgba(0,0,0,.55), transparent); }
	.lb-bottom {
		bottom: 0; justify-content: flex-end; padding: 8px max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom));
		background: linear-gradient(transparent, rgba(0,0,0,.55));
	}
	.save-sub { display: none; }
	.save-btn { min-height: 40px; padding: 0 16px; font-size: 14px; }
}
