/* System UI font stack: the faces GitHub uses, so text renders like GitHub on every platform. */

:root {
	--bg: #fff;
	--text: #1a1a1a;
	--muted: #767676;
	--tile: #f2f2f2;
	--line: #e6e6e6;
	color-scheme: light;
	--gap: 10px;
	--header: 64px;
	--stage-pad: 32px;
	/* GitHub's stack: the system UI face (Segoe UI on Windows, SF on Apple), Chinese system fonts behind
	   it so Chinese text keeps the same shapes as the Latin text around it. */
	--font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 400 14px/1.5 var(--font);
	-webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

button {
	font: inherit;
	color: inherit;
	background: none;
	border: 0;
	padding: 0;
	cursor: pointer;
}

/* Header */

.header {
	position: sticky;
	top: 0;
	z-index: 10;
	height: var(--header);
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 0 24px;
	background: var(--bg);
}

.brand-title {
	display: block;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.2;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.brand-sub {
	display: block;
	font-size: 12px;
	font-weight: 400;
	color: var(--muted);
}

.icon-btn {
	width: 40px;
	height: 40px;
	display: inline-grid;
	place-items: center;
	color: var(--text);
	opacity: .75;
	transition: opacity .2s;
}

.icon-btn:hover { opacity: 1; }

.icon-btn svg { width: 20px; height: 20px; }

/* Sign-in shortcut in the top-right corner of the public home page. It sits above the first row of albums
   and scrolls away with them: pinned to the viewport it would ride on top of the album cards on a phone. */
.home-login {
	position: absolute;
	top: 14px;
	right: 20px;
	z-index: 11;
	padding: 7px 14px;
	border: 1px solid var(--line);
	background: var(--bg);
	font-size: 14px;
	font-weight: 500;
	line-height: 20px;
	color: var(--text);
	transition: border-color .2s, color .2s;
}

.home-login:hover { border-color: var(--text); }
.home-login.signed-in { color: var(--muted); }

/* Cover */

.cover {
	position: relative;
	height: 100vh;
	height: 100svh;
	color: #fff;
	overflow: hidden;
	background: #111;
}

.cover img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.cover::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(rgba(0, 0, 0, .1), rgba(0, 0, 0, .45));
}

.cover-center {
	position: absolute;
	inset: 0;
	z-index: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 0 16px;
	text-align: center;
}

.cover h1 {
	margin: 0 0 10px;
	font-size: clamp(24px, 3.2vw, 32px);
	font-weight: 600;
	line-height: 1.25;
}

.cover p {
	margin: 0;
	font-size: 14px;
	font-weight: 400;
	opacity: .9;
}

.cover-center .btn-outline { margin-top: 32px; }

.cover-name {
	position: absolute;
	inset: auto 0 32px;
	z-index: 1;
	text-align: center;
	font-size: 12px;
	font-weight: 500;
}

.btn-outline {
	display: inline-block;
	padding: 10px 20px;
	border: 1px solid #fff;
	font-size: 14px;
	font-weight: 500;
	transition: background .25s, color .25s;
}

.btn-outline:hover { background: var(--text); color: var(--bg); }

/* On the full-bleed cover the button sits on a photo, so it inverts against white rather than the page. */
.cover .btn-outline:hover { background: #fff; color: #111; }

/* Way back from an album: top corner of the cover, and the arrow before the title in the sticky header. */
.cover-back {
	position: absolute;
	top: 24px;
	left: 20px;
	z-index: 2;
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 6px 4px;
	font-size: 14px;
	font-weight: 500;
	opacity: .85;
	transition: opacity .2s;
}

.cover-back:hover { opacity: 1; }
.cover-back { text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
.cover-back svg { filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .6)); }
.cover-back svg { width: 16px; height: 16px; }

.header-back {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
	height: 40px;
}

.header-back svg {
	flex: none;
	width: 18px;
	height: 18px;
	margin-left: -4px;
	opacity: .75;
	transition: opacity .2s;
}

.header-back:hover svg { opacity: 1; }

/* Photo rows: each photo takes its width from --r (width / height), so a row fills up and then wraps.
   Left to right, top to bottom, in the order set in the admin: the same reading order as the admin grid. */

.grid {
	--row: 300px;
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	gap: var(--gap);
	padding: 0 16px;
}

/* The last row stays left-aligned instead of its photos being stretched across the whole width. */
.grid::after {
	content: '';
	flex-grow: 1000000;
}

.grid > .tile,
.grid > .tile-wrap {
	flex: var(--r, 1) 1 calc(var(--row) * var(--r, 1));
	min-width: 0;
}

/* A named photo: the figure is the item in the row, the link is the picture inside it. */
.tile-wrap { margin: 0; }

.tile-wrap > .tile { width: 100%; }

.tile {
	position: relative;
	display: block;
	background: var(--tile);
	overflow: hidden;
}

.tile img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	opacity: 0;
	transition: opacity .5s, transform .6s;
}

.tile img.loaded { opacity: 1; }

/* A named photo: the name under the picture, the picture itself still the link. */
.tile-wrap { margin: 0; }

.tile-title {
	margin-top: 6px;
	color: var(--text);
	font-size: 12px;
	line-height: 1.4;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	cursor: pointer;
}

.tile-actions {
	position: absolute;
	right: 8px;
	bottom: 8px;
	opacity: 0;
	transition: opacity .2s;
}

.tile-actions .icon-btn {
	width: 34px;
	height: 34px;
	color: #fff;
	opacity: .9;
	filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .5));
}

@media (hover: hover) {
	.tile:hover img.loaded { transform: scale(1.015); }
	.tile:hover .tile-actions { opacity: 1; }
	.tile::after {
		content: "";
		position: absolute;
		inset: 0;
		background: linear-gradient(transparent 70%, rgba(0, 0, 0, .25));
		opacity: 0;
		transition: opacity .2s;
		pointer-events: none;
	}
	.tile:hover::after { opacity: 1; }
}

/* Album list (home) */

.albums {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
	gap: 48px 24px;
	max-width: 1400px;
	margin: 0 auto;
	padding: 0 24px;
}

.album-card .tile { aspect-ratio: 3 / 2; }

.album-card h2 {
	margin: 18px 0 4px;
	font-size: 16px;
	font-weight: 600;
}

.album-card span {
	color: var(--muted);
	font-size: 12px;
	font-weight: 400;
}

/* Home and private folders */

.collection { padding-top: 72px; }

.folder-name svg {
	width: 16px;
	height: 16px;
	flex: none;
}

.notice {
	min-height: 70vh;
	display: grid;
	place-content: center;
	padding: 0 16px;
	text-align: center;
}

.notice h1 {
	margin: 0 0 12px;
	font-size: 24px;
	font-weight: 600;
}

.notice p {
	margin: 0;
	color: var(--muted);
	font-size: 14px;
}

/* Admin mock */

.admin {
	max-width: 860px;
	margin: 0 auto;
	padding: 24px 24px 0;
}

.admin-note {
	margin: 0 0 32px;
	padding: 10px 14px;
	border: 1px solid var(--line);
	color: var(--muted);
	font-size: 14px;
}

.admin-h {
	margin: 40px 0 16px;
	font-size: 16px;
	font-weight: 600;
}

.folder-list {
	margin: 0;
	padding: 0;
	list-style: none;
	border-top: 1px solid var(--line);
}

.folder-row {
	display: grid;
	grid-template-columns: 180px 1fr auto;
	align-items: center;
	gap: 16px;
	padding: 14px 0;
	border-bottom: 1px solid var(--line);
	transition: background 1.5s;
}

.folder-row.fresh { background: #eef6ee; }

.folder-name {
	display: flex;
	align-items: center;
	gap: 8px;
	font-weight: 500;
}

.folder-meta {
	display: block;
	color: var(--muted);
	font-size: 12px;
}

.row-actions {
	display: flex;
	gap: 6px;
	flex-wrap: wrap;
}

.field {
	width: 100%;
	padding: 9px 12px;
	border: 1px solid var(--line);
	background: var(--tile);
	color: var(--text);
	font: inherit;
	font-size: 14px;
}

.field:focus { outline: 1px solid var(--muted); }

.link-field { color: var(--muted); font-size: 14px; }

.btn-small {
	padding: 7px 12px;
	border: 1px solid var(--line);
	font-size: 12px;
	font-weight: 500;
	white-space: nowrap;
}

.btn-small:hover { border-color: var(--text); }
.btn-small.danger { color: #c0392b; }

.cover-picker { grid-column: 1 / -1; }

.cover-picker summary {
	display: flex;
	align-items: center;
	gap: 12px;
	cursor: pointer;
	list-style: none;
}

.cover-picker summary::-webkit-details-marker { display: none; }

.cover-picker summary img {
	width: 72px;
	height: 48px;
	object-fit: cover;
	background: var(--tile);
}

.cover-picker summary span {
	color: var(--muted);
	font-size: 12px;
	font-weight: 400;
}

.cover-picker summary small {
	font-size: 12px;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.cover-picker[open] summary small { visibility: hidden; }

.cover-thumbs {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
	gap: 6px;
	margin-top: 12px;
}

.cover-thumb {
	aspect-ratio: 1;
	background: var(--tile);
	outline: 2px solid transparent;
	outline-offset: 2px;
	opacity: .65;
	transition: opacity .15s;
}

.cover-thumb:hover { opacity: 1; }
.cover-thumb.selected { outline-color: var(--text); opacity: 1; }

.cover-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.label {
	margin-top: 8px;
	color: var(--muted);
	font-size: 12px;
	font-weight: 500;
}

.admin-hint {
	margin: 4px 0 12px;
	color: var(--muted);
	font-size: 12px;
}

select.field { appearance: auto; }

.inline-form {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 0 0 16px;
}

.inline-form .field { width: auto; flex: 1 1 180px; }
.folder-list + .inline-form { margin-top: 32px; }

.link-btn {
	font-size: inherit;
	text-decoration: underline;
	text-underline-offset: 3px;
	cursor: pointer;
}

.link-btn:hover { color: var(--text); }
.link-btn:disabled { text-decoration: none; cursor: default; }

.list-search {
	max-width: 420px;
	margin-bottom: 12px;
}

.album-row[hidden] { display: none; }
.inline-form .btn-small { padding: 9px 16px; }

.album-form {
	display: grid;
	gap: 8px;
	max-width: 420px;
}

.album-form .row-actions { margin-top: 12px; }

/* The album address: the fixed /a/ prefix, then the editable part. */
.slug-field {
	display: flex;
	align-items: center;
	gap: 8px;
}

.slug-field .field {
	flex: 1;
	min-width: 0;
}

.slug-field span {
	color: var(--muted);
	font-size: 14px;
	white-space: nowrap;
}

.album-row {
	display: grid;
	grid-template-columns: 20px 72px 1fr auto;
	align-items: center;
	gap: 16px;
	padding: 10px 0;
	border-bottom: 1px solid var(--line);
}

.album-thumb {
	display: block;
	width: 72px;
	height: 48px;
	background: var(--tile);
}

.album-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.dropzone {
	display: grid;
	place-items: center;
	gap: 6px;
	padding: 36px 16px;
	border: 1px dashed var(--muted);
	text-align: center;
	cursor: pointer;
	transition: background .15s;
}

.dropzone.over,
.dropzone:hover { background: var(--tile); }
.dropzone input { display: none; }

.dropzone span {
	font-size: 14px;
	font-weight: 500;
}

.dropzone small { color: var(--muted); font-size: 12px; }

/* Justified rows: every photo keeps its shape (--r = width / height, set per cell). Each cell starts at the
   row height and grows in proportion to its width, so a row fills the line and its photos stay equally tall.
   The spacer after the last cell takes the leftover space, so the last row is not stretched. */
.photo-grid {
	--row: 170px;
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	gap: 8px;
}

.photo-grid[data-size="s"] { --row: 110px; }
.photo-grid[data-size="l"] { --row: 260px; }

.photo-grid::after {
	content: '';
	flex-grow: 1000000;
}

.photo-cell {
	position: relative;
	flex: var(--r, 1) 1 calc(var(--row) * var(--r, 1));
	min-width: 0;
	aspect-ratio: var(--r, 1);
	background: var(--tile);
	outline: 2px solid transparent;
	outline-offset: 2px;
	cursor: zoom-in;
}

/* Small rows have no room for the buttons: a tap on the photo opens it, select mode deletes and moves. */
.photo-grid[data-size="s"] .photo-actions { display: none; }
/* ...and the cover badge moves to the bottom, where it cannot cover the drag handle of a narrow portrait photo. */
.photo-grid[data-size="s"] .cover-badge { top: auto; bottom: 4px; left: 4px; right: auto; }

.size-switch { white-space: nowrap; }
.size-switch .link-btn { margin-left: 4px; }
.size-switch .link-btn.active { color: var(--text); text-decoration: none; font-weight: 600; }

.photo-cell.selected { outline-color: var(--text); }
/* The photo that is already the cover gets no "set as cover" button. */
.photo-cell.selected [data-cover] { display: none; }

.photo-cell img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.photo-actions {
	position: absolute;
	inset: auto 0 0;
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 4px;
	padding: 6px;
	background: linear-gradient(transparent, rgba(0, 0, 0, .7));
}

.photo-actions .btn-small {
	padding: 4px 8px;
	border-color: rgba(255, 255, 255, .3);
	background: rgba(0, 0, 0, .4);
}

.login {
	display: grid;
	gap: 12px;
	width: min(320px, 100%);
}

.login h1 { margin-bottom: 12px; }
.login .btn-outline { border-color: var(--text); }
.login-error { min-height: 1.5em; color: #c0392b; font-size: 12px; }

.toast {
	position: fixed;
	left: 50%;
	bottom: 24px;
	z-index: 100;
	transform: translateX(-50%);
	padding: 10px 18px;
	background: var(--text);
	color: var(--bg);
	font-size: 14px;
}

.footer {
	padding: 72px 16px 48px;
	text-align: center;
	color: var(--muted);
	font-size: 12px;
	font-weight: 400;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 14px;
}

.footer-repo {
	display: inline-grid;
	place-items: center;
	width: 28px;
	height: 28px;
	opacity: .7;
	transition: opacity .2s;
}

.footer-repo:hover { opacity: 1; color: var(--text); }
.footer-repo svg { width: 16px; height: 16px; }

/* Lightbox */

.lightbox {
	position: fixed;
	inset: 0;
	z-index: 50;
	display: grid;
	grid-template-rows: var(--header) 1fr;
	background: var(--bg);
	opacity: 0;
	visibility: hidden;
	transition: opacity .25s, visibility .25s;
}

.lightbox.open { opacity: 1; visibility: visible; }

.lightbox-bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 16px 0 24px;
}

.lightbox-count {
	color: var(--muted);
	font-size: 12px;
	font-weight: 500;
}

.lightbox-stage {
	position: relative;
	min-height: 0;
	display: grid;
	place-items: center;
	padding: 0 72px var(--stage-pad);
	overflow: hidden;
	/* The viewer handles pinch, pan and swipe itself. */
	touch-action: none;
}

.lightbox-stage img {
	max-width: 100%;
	max-height: calc(100vh - var(--header) - var(--stage-pad));
	max-height: calc(100dvh - var(--header) - var(--stage-pad));
	object-fit: contain;
	transform-origin: center;
	cursor: zoom-in;
	user-select: none;
	-webkit-user-drag: none;
	transition: opacity .2s;
}

.lightbox-stage img.zoom-anim { transition: opacity .2s, transform .25s ease; }
.lightbox-stage.zoomed img { cursor: grab; }
.lightbox-stage img.fading { opacity: 0; }

.lightbox-nav {
	position: absolute;
	z-index: 1;
	top: 0;
	bottom: 32px;
	width: 72px;
	display: grid;
	place-items: center;
	opacity: .55;
	transition: opacity .2s;
}

.lightbox-nav:hover { opacity: 1; }
.lightbox-nav svg { width: 28px; height: 28px; }
.lightbox-nav.prev { left: 0; }

/* The photo's own name, when the admin gave it one; slideshows stay clean. */
.lightbox-caption {
	position: absolute;
	left: 80px;
	right: 80px;
	bottom: 8px;
	color: var(--muted);
	font-size: 14px;
	text-align: center;
	pointer-events: none;
}

.lightbox-caption[hidden] { display: none; }
.lightbox.slideshow .lightbox-caption { display: none; }

.lightbox-nav.next { right: 0; }
.lightbox-nav[hidden] { display: none; }

.download-label {
	margin-left: 4px;
	font-size: 12px;
	font-weight: 500;
}

.download-btn {
	display: inline-flex;
	align-items: center;
	height: 40px;
	padding: 0 12px;
	opacity: .75;
	transition: opacity .2s;
}

.download-btn:hover { opacity: 1; }
.download-btn svg { width: 18px; height: 18px; }

@media (max-width: 700px) {
	:root { --gap: 6px; --header: 56px; --stage-pad: 16px; }
	.header { padding: 0 8px 0 16px; }
	.cover-back { top: 14px; left: 10px; }
	/* Phones: aim for two photos a row, so --row is about half the screen. */
	.grid { --row: 170px; padding: 0 6px; }
	.albums {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		padding-left: 14px;
		padding-right: 14px;
		gap: 26px 12px;
	}
	.album-card h2 {
		margin: 10px 0 2px;
		font-size: 14px;
		font-weight: 600;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}
	.album-card span { font-size: 12px; }
	/* Narrow tiles: two lines instead of cutting a long file name like IMG_20260207_121759. */
	.tile-title {
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
		overflow: hidden;
		white-space: normal;
	}
	.collection { padding-top: 62px; }
	/* A smaller sign-in pill, and the album list starts below it instead of under it. */
	.home-login { top: 12px; right: 14px; padding: 6px 12px; }
	.lightbox-bar { padding: 0 8px 0 16px; }
	.lightbox-stage { padding: 0 0 var(--stage-pad); }
	.lightbox-nav { display: none; }
	.lightbox-caption { left: 12px; right: 12px; }
	.download-label { display: none; }
	.folder-row { grid-template-columns: 1fr; gap: 10px; }
	.album-thumb { width: 56px; height: 40px; }
	.admin { padding: 16px 16px 0; }
}

/* Client favourites */

.fav-filter,
.header-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	height: 34px;
	padding: 0 12px;
	border: 1px solid var(--line);
	font-size: 14px;
	font-weight: 500;
	transition: border-color .2s, opacity .2s;
}

.fav-filter:hover,
.header-btn:hover { border-color: #c8c8c8; }

.fav-filter[hidden] { display: none; }
.fav-filter svg,
.header-btn svg { width: 16px; height: 16px; }
.fav-filter.active { border-color: var(--text); }
.fav-filter.active svg,
.fav-btn.on svg,
.tile.is-fav .tile-fav svg { fill: currentColor; }

/* A picked photo shows its heart in the grid even without hovering. */
.tile.is-fav .tile-actions { opacity: 1; }
.tile.is-fav .tile-actions [data-download] { display: none; }

@media (hover: hover) {
	.tile.is-fav:hover .tile-actions [data-download] { display: inline-grid; }
}

.modal {
	position: fixed;
	inset: 0;
	z-index: 200;
	display: grid;
	place-items: center;
	padding: 16px;
	background: rgba(0, 0, 0, .6);
}

.modal-box {
	display: grid;
	gap: 12px;
	width: min(360px, 100%);
	padding: 24px;
	background: var(--bg);
	border: 1px solid var(--line);
}

.modal-box h2 {
	margin: 0;
	font-size: 16px;
	font-weight: 600;
}

.modal-box p { margin: 0; color: var(--muted); font-size: 14px; }
.modal-box .row-actions { justify-content: flex-end; }
.btn-small.primary { border-color: var(--text); }

.notice .login p { margin: 0 0 4px; }

/* Admin: drag to reorder, folder settings, favourites list */

.drag-handle {
	display: inline-grid;
	place-items: center;
	width: 20px;
	height: 32px;
	color: var(--muted);
	cursor: grab;
	touch-action: none;
}

.drag-handle svg { width: 16px; height: 16px; }
.drag-handle:hover { color: var(--text); }
.dragging { opacity: .5; }


.photo-cell .drag-handle {
	position: absolute;
	top: 4px;
	left: 4px;
	width: 26px;
	height: 26px;
	background: rgba(0, 0, 0, .5);
	color: #fff;
}

.check {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 4px 0 8px;
	color: var(--muted);
	font-size: 14px;
	cursor: pointer;
}

.check input { accent-color: var(--text); }

.folder-settings {
	grid-column: 1 / -1;
	display: flex;
	flex-wrap: wrap;
	gap: 8px 24px;
	color: var(--muted);
	font-size: 14px;
}

.setting {
	display: inline-flex;
	align-items: center;
	gap: 8px;
}

.setting b { color: var(--text); font-weight: 500; }
.date-field { width: auto; padding: 4px 8px; font-size: 14px; color-scheme: dark; }

.password-form { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.password-form[hidden] { display: none; }
.password-form .field { width: auto; flex: 1 1 220px; max-width: 320px; margin: 0; }
.password-form .check { margin: 0; }

.favorites { grid-column: 1 / -1; }

.favorites summary {
	display: flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
	list-style: none;
	font-size: 14px;
}

.favorites summary::-webkit-details-marker { display: none; }
.favorites summary svg { width: 14px; height: 14px; }
.favorites summary small { text-decoration: underline; text-underline-offset: 3px; color: var(--muted); }
.favorites[open] summary small { visibility: hidden; }
.fav-list { margin-top: 12px; color: var(--muted); font-size: 12px; }

.fav-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
	gap: 10px;
	margin-bottom: 12px;
}

.fav-grid figure { margin: 0; }
.fav-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--tile); }
.fav-grid figcaption { margin-top: 4px; font-size: 12px; color: var(--text); overflow-wrap: anywhere; }
.fav-grid small { color: var(--muted); }

@media (max-width: 700px) {
	.album-row { grid-template-columns: 20px 56px 1fr; }
	.album-row .row-actions { grid-column: 3; }
}

/* Album editor: cover row, cover label on the grid, photo preview */

.album-cover { margin-bottom: 20px; }

.cover-count {
	color: var(--muted);
	font-size: 12px;
	font-style: normal;
}

.cover-badge {
	position: absolute;
	top: 4px;
	right: 4px;
	display: none;
	padding: 3px 7px;
	background: var(--text);
	color: var(--bg);
	font-size: 12px;
	font-weight: 600;
}

.photo-cell.selected .cover-badge { display: block; }

/* The photo's own name on the grid, next to the drag handle and clear of the cover badge.
   Every tile shows one now, so it stays until the name is changed. */
.title-badge {
	position: absolute;
	top: 4px;
	left: 34px;
	max-width: calc(100% - 78px);
	padding: 3px 7px;
	background: rgba(0, 0, 0, .55);
	color: #fff;
	font-size: 12px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	cursor: default;
}

.modal.preview {
	place-items: center;
	padding: 24px 56px;
	background: rgba(0, 0, 0, .9);
	cursor: zoom-out;
}

.preview figure {
	display: grid;
	justify-items: center;
	gap: 10px;
	margin: 0;
}

.preview img {
	max-width: 100%;
	max-height: calc(100vh - 100px);
	max-height: calc(100dvh - 100px);
	object-fit: contain;
}

.preview figcaption {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 12px;
	color: var(--muted);
	font-size: 14px;
}

.preview-title { color: #fff; font-size: 16px; font-weight: 600; }

.preview figcaption .btn-small {
	border-color: rgba(255, 255, 255, .4);
	background: transparent;
	color: #fff;
}

.preview-nav {
	position: fixed;
	top: 50%;
	width: 48px;
	height: 64px;
	margin-top: -32px;
	color: var(--text);
	font-size: 40px;
	line-height: 1;
	opacity: .6;
	cursor: pointer;
}

.preview-nav:hover { opacity: 1; }
.preview-nav.prev { left: 4px; }
.preview-nav.next { right: 4px; }

@media (max-width: 700px) {
	.modal.preview { padding: 16px 8px; }
	.cover-count { display: block; width: 100%; }
}

.cover-picker summary { flex-wrap: wrap; }

/* Slideshow: full-bleed photo, slow fades, controls only on mouse move, no cursor. */

.lightbox.slideshow {
	--header: 0px;
	--stage-pad: 0px;
	grid-template-rows: 1fr;
	cursor: none;
}

.lightbox.slideshow .lightbox-stage { padding: 0; }
.lightbox.slideshow .lightbox-stage img { transition: opacity .9s ease; cursor: none; }
.lightbox.slideshow .lightbox-nav { display: none; }

.lightbox.slideshow .lightbox-bar {
	position: absolute;
	inset: 0 0 auto;
	z-index: 2;
	height: 64px;
	background: linear-gradient(rgba(0, 0, 0, .55), transparent);
	opacity: 0;
	transition: opacity .3s;
	pointer-events: none;
}

.lightbox.slideshow.show-ui { cursor: default; }
.lightbox.slideshow.show-ui .lightbox-bar { opacity: 1; pointer-events: auto; }

/* Album editor: select photos to move or delete */

.select-bar {
	position: sticky;
	top: var(--header);
	z-index: 5;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 12px;
	margin: 0 0 12px;
	padding: 10px 12px;
	border: 1px solid var(--line);
	background: var(--bg);
	font-size: 14px;
}

.select-bar[hidden] { display: none; }
.select-bar #select-count { margin-right: auto; }
.select-bar select.field { width: auto; min-width: 180px; }
.photo-grid.selecting .photo-actions,
.photo-grid.selecting .cover-badge { display: none; }
.photo-grid.selecting .photo-cell { cursor: pointer; }
.photo-grid.selecting .photo-cell img { transition: opacity .15s; }
.photo-grid.selecting .photo-cell:not(.picked) img { opacity: .6; }
/* In select mode only the picked photos are outlined, not the cover. */
.photo-grid.selecting .photo-cell.selected:not(.picked) { outline-color: transparent; }
.photo-cell.picked { outline-color: var(--text); }

.photo-cell.picked::after {
	content: '✓';
	position: absolute;
	top: 6px;
	right: 6px;
	display: grid;
	place-items: center;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: var(--text);
	color: var(--bg);
	font-size: 13px;
	font-weight: 700;
}

/* Trash */

.trash-row .album-thumb img { opacity: .7; }

.trash-photos {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
	gap: 8px;
	margin-top: 12px;
}

.trash-photos figure {
	position: relative;
	margin: 0;
	aspect-ratio: 1;
	background: var(--tile);
}

.trash-photos img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: .7; }

.trash-photos .btn-small {
	position: absolute;
	inset: auto 6px 6px;
	padding: 4px 6px;
	background: rgba(0, 0, 0, .55);
	border-color: rgba(255, 255, 255, .3);
}

/* QR code */

.qr-box { width: min(420px, 100%); text-align: center; }
.qr-code { display: flex; justify-content: center; background: #fff; line-height: 0; }
.qr-code svg { width: min(100%, 50vh); height: auto; }
.qr-url { word-break: break-all; font-size: 12px; }

/* Album header: favourites filter, slideshow, share and "Download all" side by side */

.header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.dl-all:disabled { opacity: .7; cursor: progress; }

/* Narrow phones: icon-only buttons, so the header keeps fitting next to the album title. */
@media (max-width: 520px) {
	.header-btn-label,
	#dl-all-label { display: none; }
	.header-actions .header-btn { width: 34px; padding: 0; justify-content: center; }
	.header-actions { gap: 6px; }
}

/* Slideshow options: only shown while it plays */

.slide-only { display: none; }
.lightbox.slideshow .slide-only { display: inline-flex; }
.slide-speed { font-size: 12px; font-weight: 600; min-width: 2.5em; }
.slide-only.on { opacity: 1; }
.slide-only.on svg { stroke-width: 2.2; }

.slide-qr {
	position: absolute;
	right: 24px;
	bottom: 24px;
	z-index: 3;
	display: grid;
	gap: 6px;
	width: 148px;
	padding: 10px 10px 8px;
	background: #fff;
	color: #111;
	text-align: center;
	font-size: 12px;
	font-weight: 600;
}

.slide-qr[hidden] { display: none; }
.slide-qr svg { width: 100%; height: auto; display: block; }

/* Admin: folder rows (no drag handle: folders are listed newest first), cover chooser album list */

.album-row.no-grip { grid-template-columns: 72px 1fr auto; }
.folder-row.link-row { grid-template-columns: 1fr auto; }
.cover-album { max-width: 420px; margin: 12px 0 0; }
.cover-chosen:empty { display: none; }

@media (max-width: 700px) {
	.album-row.no-grip { grid-template-columns: 56px 1fr; }
	.album-row.no-grip .row-actions { grid-column: 2; }
	.folder-row.link-row { grid-template-columns: 1fr; }
}
