:root {
	--bg: #f6f7f9;
	--surface: #ffffff;
	--border: #e2e5ea;
	--text: #1b1f26;
	--muted: #6b7280;
	--accent: #2563eb;
	--new: #f59e0b;
	--good: #16a34a;
	--avg: #d97706;
	--poor: #dc2626;
	--radius: 8px;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #12151a;
		--surface: #1a1e25;
		--border: #2b313a;
		--text: #e6e8ec;
		--muted: #9aa3af;
		--accent: #60a5fa;
	}
}

* { box-sizing: border-box; }

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: .75rem 1.25rem;
	background: var(--surface);
	border-bottom: 1px solid var(--border);
	position: sticky;
	top: 0;
	z-index: 10;
}

.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.brand span { color: var(--muted); font-weight: 400; margin-left: .4rem; font-size: .85rem; }
.topbar nav { display: flex; gap: 1rem; }

main { padding: 1.25rem; max-width: 1600px; margin: 0 auto; }

footer { padding: 2rem 1.25rem; color: var(--muted); font-size: .85rem; text-align: center; }

.flash {
	padding: .6rem .9rem;
	border-radius: var(--radius);
	margin-bottom: 1rem;
	border: 1px solid var(--border);
	background: var(--surface);
}
.flash.success { border-color: var(--good); }

.toolbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: .75rem;
	margin-bottom: .9rem;
}

.stats { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.muted { color: var(--muted); font-size: .85rem; }
.err { color: var(--poor); }

.badge-new-count {
	background: var(--new);
	color: #111;
	padding: .1rem .5rem;
	border-radius: 999px;
	font-size: .8rem;
	font-weight: 600;
}

.filters {
	display: flex;
	flex-direction: column;
	gap: .6rem;
	padding: .75rem;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	margin-bottom: 1rem;
}

.filter-row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: .5rem;
}

/* category switch: radios painted as one solid control */
.segmented {
	display: inline-flex;
	border: 1px solid var(--border);
	border-radius: 6px;
	overflow: hidden;
	background: var(--bg);
}

.segmented input {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

.segmented label {
	padding: .45rem .9rem;
	cursor: pointer;
	font-size: .9rem;
	color: var(--muted);
	border-right: 1px solid var(--border);
	user-select: none;
	white-space: nowrap;
	transition: background .12s ease, color .12s ease;
}

.segmented label:last-child { border-right: 0; }
.segmented label:hover { background: rgba(127, 127, 127, .12); }

.segmented input:checked + label {
	background: var(--accent);
	color: #fff;
	font-weight: 600;
}

/* keyboard focus must stay visible even though the radio itself is hidden */
.segmented input:focus-visible + label {
	outline: 2px solid var(--accent);
	outline-offset: -2px;
}

.range {
	display: inline-flex;
	align-items: center;
	gap: .3rem;
	padding: .15rem .5rem .15rem .6rem;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: var(--bg);
}

.range-label {
	color: var(--muted);
	font-size: .82rem;
	margin-right: .15rem;
	white-space: nowrap;
}

.range .dash { color: var(--muted); }

.filters .tiny {
	width: 62px;
	padding: .3rem .4rem;
	border: 1px solid var(--border);
	border-radius: 4px;
	background: var(--surface);
	color: var(--text);
	font: inherit;
	font-size: .88rem;
}

.genre-select { max-width: 220px; }

.filters input, .filters select, .filters button {
	padding: .45rem .6rem;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: var(--bg);
	color: var(--text);
	font: inherit;
}

.filters .grow { flex: 1 1 260px; }
.filters .narrow { width: 100px; }
.filters .check { display: flex; align-items: center; gap: .35rem; color: var(--muted); }
.filters button { background: var(--accent); color: #fff; border-color: transparent; cursor: pointer; font-weight: 600; }

.btn-ghost {
	padding: .45rem .7rem;
	border: 1px solid var(--border);
	border-radius: 6px;
	color: var(--muted);
	font-size: .9rem;
}

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }

table.grid { width: 100%; border-collapse: collapse; font-size: .9rem; }

table.grid th {
	text-align: left;
	padding: .6rem .7rem;
	color: var(--muted);
	font-weight: 600;
	font-size: .78rem;
	text-transform: uppercase;
	letter-spacing: .03em;
	border-bottom: 1px solid var(--border);
	white-space: nowrap;
}

table.grid td { padding: .55rem .7rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.grid tbody tr:hover { background: rgba(127, 127, 127, .06); }
table.grid tr.is-new { box-shadow: inset 3px 0 0 var(--new); }

.nowrap { white-space: nowrap; }

.poster-cell { width: 76px; padding: .4rem .5rem .4rem .7rem; }

.poster-cell img {
	width: 68px;
	height: 100px;
	object-fit: cover;
	border-radius: 5px;
	display: block;
	background: var(--border);
	cursor: zoom-in;
	transition: transform .12s ease, box-shadow .12s ease;
}

.poster-cell img:hover {
	transform: scale(1.06);
	box-shadow: 0 4px 14px rgba(0, 0, 0, .35);
}

/* placeholder keeps the row height stable when a poster is missing */
.poster-cell .no-poster {
	width: 68px;
	height: 100px;
	border-radius: 5px;
	background: var(--border);
	display: block;
}

/* full-size poster overlay */
.lightbox {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, .85);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 100;
	cursor: zoom-out;
	padding: 2rem;
}

.lightbox[hidden] { display: none; }

.lightbox img {
	max-width: min(92vw, 700px);
	max-height: 92vh;
	border-radius: 8px;
	box-shadow: 0 10px 40px rgba(0, 0, 0, .6);
}

.lightbox figcaption {
	position: absolute;
	bottom: 1.2rem;
	left: 0;
	right: 0;
	text-align: center;
	color: #fff;
	font-size: .95rem;
	text-shadow: 0 1px 4px rgba(0, 0, 0, .9);
	pointer-events: none;
}

.title-cell { min-width: 260px; }
.title-cell .title { font-weight: 600; color: var(--text); }
.title-cell .orig { display: block; color: var(--muted); font-size: .8rem; }

.badge-new {
	background: var(--new);
	color: #111;
	font-size: .68rem;
	font-weight: 700;
	padding: .05rem .35rem;
	border-radius: 3px;
	margin-left: .4rem;
	text-transform: uppercase;
}

.rating { font-weight: 700; font-size: 1.02rem; }
.rating.good { color: var(--good); }
.rating.avg { color: var(--avg); }
.rating.poor { color: var(--poor); }

/* the whole rating cell links to ČSFD, keeping the colour coding intact */
.csfd-cell { white-space: nowrap; }

.csfd-link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 62px;
	min-height: 38px;
	padding: .3rem .5rem;
	margin: -.25rem -.2rem;
	border-radius: 6px;
	text-decoration: none;
	border: 1px solid transparent;
}

.csfd-link:hover {
	background: rgba(127, 127, 127, .14);
	border-color: var(--border);
	text-decoration: none;
}

.csfd-link:hover .rating { text-decoration: underline; }

/* shown when the film has no rating but is still on ČSFD */
.rating-none {
	color: var(--muted);
	font-size: .8rem;
	font-weight: 600;
}

.csfd-link:hover .rating-none { color: var(--accent); }

.genres { color: var(--muted); font-size: .85rem; max-width: 180px; }

.chip {
	display: inline-block;
	padding: .08rem .4rem;
	border: 1px solid var(--border);
	border-radius: 4px;
	font-size: .72rem;
	color: var(--muted);
	margin-right: .2rem;
}
.chip.dub { border-color: var(--good); color: var(--good); }
.chip.sub { border-color: var(--accent); color: var(--accent); }
.chip.hdr { border-color: var(--new); color: var(--new); }
.chip.count { background: var(--border); }

.links a { margin-right: .5rem; font-size: .85rem; }

.empty { text-align: center; color: var(--muted); padding: 2.5rem; }

.pager {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-wrap: wrap;
	gap: .3rem;
	padding: 1rem .5rem 2rem;
	color: var(--muted);
}

.pager:first-of-type { padding: .25rem .5rem 1rem; }

.pg-numbers { display: inline-flex; gap: .3rem; flex-wrap: wrap; }

.pg {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 38px;
	height: 38px;
	padding: 0 .6rem;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: var(--surface);
	color: var(--text);
	font-size: .9rem;
	text-decoration: none;
}

.pg:hover { background: rgba(127, 127, 127, .12); text-decoration: none; }

.pg.current {
	background: var(--accent);
	border-color: var(--accent);
	color: #fff;
	font-weight: 700;
}

.pg.gap { border-color: transparent; background: transparent; color: var(--muted); min-width: 22px; padding: 0; }
.pg.edge { font-weight: 700; }

.pg-jump {
	display: inline-flex;
	align-items: center;
	gap: .35rem;
	margin-left: .6rem;
	padding-left: .8rem;
	border-left: 1px solid var(--border);
}

.pg-jump input[type=number] {
	width: 72px;
	height: 38px;
	padding: 0 .5rem;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: var(--bg);
	color: var(--text);
	font: inherit;
	font-size: .9rem;
}

.pg-total { font-size: .85rem; white-space: nowrap; }

.pg-jump button {
	height: 38px;
	padding: 0 .8rem;
	border: 0;
	border-radius: 6px;
	background: var(--accent);
	color: #fff;
	font: inherit;
	font-weight: 600;
	font-size: .9rem;
	cursor: pointer;
}

@media (max-width: 720px) {
	.pg-jump { margin-left: 0; padding-left: 0; border-left: 0; width: 100%; justify-content: center; margin-top: .5rem; }
}

.back { display: inline-block; margin-bottom: 1rem; color: var(--muted); }

.detail {
	display: flex;
	gap: 1.5rem;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 1.25rem;
	margin-bottom: 1.5rem;
	flex-wrap: wrap;
}

.detail aside img { width: 200px; border-radius: 6px; display: block; cursor: zoom-in; }
.detail-body { flex: 1 1 320px; }
.detail-body h1 { margin: 0 0 .2rem; font-size: 1.5rem; }
.orig-big { margin: 0 0 .75rem; color: var(--muted); }

.meta { display: flex; flex-wrap: wrap; gap: .9rem; color: var(--muted); margin-bottom: .75rem; font-size: .9rem; }
.ext-links { display: flex; gap: .75rem; margin-bottom: 1rem; }

.credits { margin: 0 0 1rem; }
.credits div { display: flex; gap: .6rem; margin-bottom: .35rem; font-size: .9rem; }
.credits dt { color: var(--muted); min-width: 60px; }
.credits dd { margin: 0; }

.plot { line-height: 1.65; }

.release-name { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .78rem; color: var(--muted); max-width: 420px; word-break: break-all; }

h2 { font-size: 1.1rem; margin: 1.5rem 0 .75rem; }

.signin {
	max-width: 360px;
	margin: 4rem auto;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 1.75rem;
}

.signin h1 { margin: 0 0 1.25rem; font-size: 1.25rem; text-align: center; }
.signin table { width: 100%; }
.signin th { text-align: left; font-weight: 500; color: var(--muted); padding: .4rem 0; font-size: .9rem; }
.signin td { padding: .3rem 0; }

.signin input[type=text], .signin input[type=password] {
	width: 100%;
	padding: .5rem .6rem;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: var(--bg);
	color: var(--text);
	font: inherit;
}

.signin input[type=submit] {
	width: 100%;
	margin-top: .75rem;
	padding: .55rem;
	background: var(--accent);
	color: #fff;
	border: 0;
	border-radius: 6px;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

.signin .error { color: var(--poor); font-size: .9rem; padding: .5rem 0; }

@media (max-width: 720px) {
	main { padding: .75rem; }
	.filters .grow { flex-basis: 100%; }
	.detail aside img { width: 130px; }
}

/* ownership + pairing tags, shared by both views */
.tag {
	display: inline-block;
	padding: .12rem .45rem;
	border-radius: 4px;
	font-size: .74rem;
	font-weight: 600;
	border: 1px solid var(--border);
	color: var(--muted);
	text-decoration: none;
	white-space: nowrap;
}

.tag.have { border-color: var(--good); color: var(--good); }
.tag.paired { border-color: var(--good); color: var(--good); }
.tag.gone { border-color: var(--muted); color: var(--muted); text-decoration: line-through; }
.tag.none { border-color: transparent; }
a.tag:hover { background: rgba(127, 127, 127, .14); text-decoration: none; }

/* a row whose file is no longer on disk */
table.grid tr.is-gone { opacity: .55; }
table.grid tr.is-gone .title { text-decoration: line-through; }

.title-cell .path {
	display: block;
	color: var(--muted);
	font-size: .72rem;
	font-family: ui-monospace, Consolas, monospace;
	margin-top: .1rem;
}

.topbar nav a.active {
	color: var(--text);
	font-weight: 700;
	border-bottom: 2px solid var(--accent);
	padding-bottom: .15rem;
}

.topbar nav a.logout { color: var(--muted); font-size: .9rem; }

/* main section switch, sits next to the logo */
.topbar-left { display: flex; align-items: center; gap: 1.1rem; }

.switch {
	display: inline-flex;
	border: 1px solid var(--border);
	border-radius: 8px;
	overflow: hidden;
	background: var(--bg);
}

.switch a {
	padding: .45rem 1.1rem;
	font-size: .95rem;
	font-weight: 600;
	color: var(--muted);
	text-decoration: none;
	border-right: 1px solid var(--border);
	transition: background .12s ease, color .12s ease;
}

.switch a:last-child { border-right: 0; }
.switch a:hover { background: rgba(127, 127, 127, .12); text-decoration: none; }

.switch a.active {
	background: var(--accent);
	color: #fff;
	border-bottom: 0;
	padding-bottom: .45rem;
}
