:root {
	--bg: #f7f6f3;
	--fg: #1d1c1a;
	--muted: #6f6b64;
	--card: #ffffff;
	--line: #e4e1da;
	--accent: #8a6d3b;
	--tile: #e9e6df;
	color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
	:root {
		--bg: #151413;
		--fg: #ece9e3;
		--muted: #9a958c;
		--card: #1f1e1c;
		--line: #2e2c29;
		--accent: #d2b27a;
		--tile: #262422;
	}
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0;
	background: var(--bg);
	color: var(--fg);
	font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
body.noscroll { overflow: hidden; }
a { color: inherit; text-decoration: none; }

.top {
	position: sticky; top: 0; z-index: 2;
	display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px;
	padding: 14px 16px;
	background: color-mix(in srgb, var(--bg) 92%, transparent);
	backdrop-filter: blur(8px);
	border-bottom: 1px solid var(--line);
}
.crumbs { font-size: 18px; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.crumbs a + a::before { content: "/"; margin: 0 8px; color: var(--muted); font-weight: 400; }
.crumbs a:hover { color: var(--accent); }
.meta { margin: 0; color: var(--muted); font-size: 13px; }

main { padding: 16px; max-width: 1600px; margin: 0 auto; }
.raw { padding-left: 20px; }
.raw a { text-decoration: underline; }
.empty { color: var(--muted); }

.dirs { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-bottom: 20px; }
.dir {
	display: flex; align-items: center; gap: 12px;
	padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--card);
}
.dir:hover { border-color: var(--accent); }
.dir-icon {
	flex: none; width: 26px; height: 20px; border-radius: 3px; background: var(--accent); opacity: .85;
	position: relative;
}
.dir-icon::before { content: ""; position: absolute; left: 0; top: -4px; width: 11px; height: 6px; border-radius: 2px 2px 0 0; background: inherit; }
.dir-name { font-weight: 500; overflow-wrap: anywhere; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 6px; }
@media (max-width: 520px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 3px; } main { padding: 8px; } }
.tile {
	position: relative; display: block; aspect-ratio: 1; overflow: hidden;
	background: var(--tile); border-radius: 4px;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s; }
.tile:hover img { transform: scale(1.03); }
.tile.pending::before {
	content: "Podgląd w przygotowaniu"; position: absolute; inset: 0;
	display: flex; align-items: center; justify-content: center; text-align: center;
	padding: 8px; font-size: 12px; color: var(--muted);
}
.cap {
	position: absolute; left: 0; right: 0; bottom: 0;
	padding: 14px 6px 4px; font-size: 12px; color: #fff;
	background: linear-gradient(transparent, rgba(0,0,0,.55));
	white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
	opacity: 0; transition: opacity .2s;
}
.tile:hover .cap, .tile:focus .cap { opacity: 1; }
@media (hover: none) { .cap { opacity: 1; font-size: 11px; padding-top: 10px; } }

.files { margin-top: 20px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.file { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); }
.file:first-child { border-top: 0; }
.file:hover .file-name { color: var(--accent); }
.file-name { overflow-wrap: anywhere; }
.file-size { color: var(--muted); white-space: nowrap; }

/* Lightbox */
.lb { position: fixed; inset: 0; z-index: 10; background: #0b0b0b; color: #eee; }
.lb[hidden] { display: none; }
.lb-bar {
	position: absolute; top: 0; left: 0; right: 0; z-index: 2;
	display: flex; align-items: center; gap: 12px; padding: 10px 12px;
	background: linear-gradient(rgba(0,0,0,.7), transparent);
}
.lb-count { font-variant-numeric: tabular-nums; color: #bbb; font-size: 13px; white-space: nowrap; }
.lb-name { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-btn {
	font: inherit; font-size: 13px; color: #fff; background: rgba(255,255,255,.12);
	border: 0; border-radius: 6px; padding: 7px 12px; cursor: pointer; white-space: nowrap;
}
.lb-btn:hover { background: rgba(255,255,255,.22); }
.lb-stage { margin: 0; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 52px 8px 8px; }
.lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; transition: opacity .15s; }
.lb-stage img.loading { opacity: .35; }
.lb-spin {
	position: absolute; width: 34px; height: 34px; border-radius: 50%;
	border: 3px solid rgba(255,255,255,.2); border-top-color: #fff; animation: spin .8s linear infinite;
}
.lb-spin[hidden] { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.lb-nav {
	position: absolute; top: 50%; z-index: 2; transform: translateY(-50%);
	width: 48px; height: 72px; border: 0; border-radius: 8px; cursor: pointer;
	font-size: 40px; line-height: 1; color: #fff; background: rgba(255,255,255,.08);
}
.lb-nav:hover { background: rgba(255,255,255,.2); }
.lb-prev { left: 8px; }
.lb-next { right: 8px; }
@media (max-width: 520px) {
	.lb-nav { display: none; }
	.lb-name { display: none; }
}
