:root {
	color-scheme: light dark;
	--bg: #f5f5f5;
	--surface: #fff;
	--surface-alt: #fafafa;
	--surface-hover: #f8f9fb;
	--text: #1a1a1a;
	--text-muted: #444;
	--text-faint: #666;
	--border: #e5e5e5;
	--border-strong: #ccc;
	--border-faint: #eee;
	--accent: #2563eb;
	--accent-text: #fff;
	--error: #dc2626;
	--success: #16a34a;
	--shadow: rgba(0, 0, 0, 0.1);
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #17181a;
		--surface: #212226;
		--surface-alt: #26272b;
		--surface-hover: #2c2d32;
		--text: #e8e8ea;
		--text-muted: #b8b9bd;
		--text-faint: #9a9ba0;
		--border: #34353a;
		--border-strong: #45464c;
		--border-faint: #2c2d32;
		--accent: #3b82f6;
		--accent-text: #fff;
		--error: #f87171;
		--success: #4ade80;
		--shadow: rgba(0, 0, 0, 0.4);
	}
}

/* The [hidden] attribute is a low-priority UA style, so any author rule
   that sets display (e.g. `.pagination { display: flex }`) silently wins
   over it even without a class toggle. Force it to always take effect. */
[hidden] {
	display: none !important;
}

body {
	font-family: system-ui, sans-serif;
	background: var(--bg);
	color: var(--text);
	margin: 0;
	min-height: 100vh;
}

.login-page {
	display: flex;
	min-height: 100vh;
	align-items: center;
	justify-content: center;
	padding: 1rem;
}

.login-form {
	width: 100%;
	max-width: 320px;
}

.login-form {
	background: var(--surface);
	padding: 2rem;
	border-radius: 8px;
	box-shadow: 0 1px 4px var(--shadow);
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.login-form h1 {
	margin: 0 0 1rem;
	text-align: center;
}

.comic-title {
	display: block;
	max-width: 100%;
	height: auto;
	margin: 0 auto 1.5rem;
}

.login-form label {
	font-size: 0.875rem;
	color: var(--text-muted);
}

.login-form input {
	padding: 0.5rem;
	border: 1px solid var(--border-strong);
	border-radius: 4px;
	font-size: 1rem;
	background: var(--surface);
	color: var(--text);
}

.login-form button {
	margin-top: 1rem;
	padding: 0.6rem;
	border: none;
	border-radius: 4px;
	background: var(--accent);
	color: var(--accent-text);
	font-size: 1rem;
	cursor: pointer;
}

.login-form button:disabled {
	opacity: 0.6;
	cursor: default;
}

.error {
	color: var(--error);
	font-size: 0.875rem;
	min-height: 1.2em;
	margin: 0;
}

header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 1rem 1.5rem;
	background: var(--surface);
	border-bottom: 1px solid var(--border);
}

header h1 {
	margin: 0;
	font-size: 1.25rem;
}

header nav,
header .header-actions {
	display: flex;
	gap: 1rem;
	align-items: center;
}

header nav a,
header nav .nav-current,
header .header-actions a,
header .header-actions .nav-current {
	display: inline-flex;
	align-items: center;
	font-size: 0.9rem;
	font-weight: 600;
	padding: 0.4rem 0.8rem;
	border-radius: 4px;
	border: 1px solid transparent;
}

header nav a,
header .header-actions a {
	color: var(--text-muted);
	background: var(--surface);
	border-color: var(--border-strong);
	text-decoration: none;
	transition: background-color 0.15s ease, color 0.15s ease;
}

header nav a:hover,
header .header-actions a:hover {
	background: var(--surface-hover);
	color: var(--text);
}

header nav .nav-current,
header .header-actions .nav-current {
	color: var(--accent-text);
	background: var(--accent);
	border-color: var(--accent);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

header button {
	padding: 0.4rem 0.8rem;
	border: 1px solid var(--border-strong);
	border-radius: 4px;
	background: var(--surface);
	color: var(--text);
	cursor: pointer;
}

main {
	max-width: 1100px;
	margin: 1.5rem auto;
	padding: 0 1.5rem;
}

.empty {
	color: var(--text-faint);
	text-align: center;
	margin-top: 2rem;
}

table {
	width: 100%;
	border-collapse: collapse;
	background: var(--surface);
	box-shadow: 0 1px 4px var(--shadow);
}

th, td {
	text-align: left;
	padding: 0.5rem 0.75rem;
	border-bottom: 1px solid var(--border-faint);
	font-size: 0.9rem;
	vertical-align: middle;
}

th {
	background: var(--surface-alt);
	font-weight: 600;
	color: var(--text-muted);
}

tbody tr {
	cursor: pointer;
}

tbody tr:hover {
	background: var(--surface-hover);
}

tbody tr:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: -2px;
}

.cover-thumb {
	/* width/height set inline from list.js's COVER_THUMB_WIDTH/HEIGHT */
	object-fit: cover;
	border-radius: 2px;
	display: block;
}

.pagination {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 1rem;
	margin-top: 1rem;
}

.pagination button {
	padding: 0.4rem 0.8rem;
	border: 1px solid var(--border-strong);
	border-radius: 4px;
	background: var(--surface);
	color: var(--text);
	cursor: pointer;
}

.pagination button:disabled {
	opacity: 0.5;
	cursor: default;
}

.add-form {
	max-width: 480px;
	margin: 0 auto;
	background: var(--surface);
	padding: 2rem;
	border-radius: 8px;
	box-shadow: 0 1px 4px var(--shadow);
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

.add-form + .add-form {
	margin-top: 1.5rem;
}

.add-form h2 {
	margin: 0;
	font-size: 1.1rem;
}

.field {
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
}

.field label {
	font-size: 0.875rem;
	color: var(--text-muted);
}

.field .hint {
	font-weight: 400;
	color: var(--text-faint);
}

.field input,
.field select,
.field textarea {
	padding: 0.5rem;
	border: 1px solid var(--border-strong);
	border-radius: 4px;
	font-size: 1rem;
	font-family: inherit;
	background: var(--surface);
	color: var(--text);
}

.field textarea {
	resize: vertical;
}

.field-row {
	display: flex;
	gap: 1rem;
}

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

.add-form button[type="submit"] {
	padding: 0.6rem;
	border: none;
	border-radius: 4px;
	background: var(--accent);
	color: var(--accent-text);
	font-size: 1rem;
	cursor: pointer;
}

.add-form button[type="submit"]:disabled {
	opacity: 0.6;
	cursor: default;
}

.success {
	color: var(--success);
	font-size: 0.875rem;
	min-height: 1.2em;
	margin: 0;
}

.back-link {
	display: inline-block;
	margin-bottom: 1rem;
	color: var(--accent);
	text-decoration: none;
	font-size: 0.9rem;
}

.back-link:hover {
	text-decoration: underline;
}

#issue-heading {
	margin: 0 0 1rem;
}

.issue-detail {
	display: flex;
	flex-wrap: wrap;
	gap: 2rem;
	background: var(--surface);
	padding: 1.5rem;
	border-radius: 8px;
	box-shadow: 0 1px 4px var(--shadow);
}

.issue-covers {
	display: flex;
	flex-wrap: wrap;
	gap: 1.5rem;
}

.cover-large-wrap {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.5rem;
}

.cover-large-wrap h3 {
	margin: 0;
	font-size: 0.85rem;
	font-weight: 600;
	color: var(--text-muted);
}

.cover-large {
	max-width: 260px;
	max-height: 380px;
	width: auto;
	height: auto;
	border-radius: 4px;
	box-shadow: 0 1px 4px var(--shadow);
	display: block;
	cursor: pointer;
}

.issue-fields {
	flex: 1;
	min-width: 240px;
	margin: 0;
	display: grid;
	grid-template-columns: auto 1fr;
	align-content: start;
	gap: 0.6rem 1.25rem;
}

.issue-fields dt {
	color: var(--text-muted);
	font-size: 0.85rem;
	font-weight: 600;
	white-space: nowrap;
}

.issue-fields dd {
	margin: 0;
	color: var(--text);
	white-space: pre-wrap;
}

.issue-actions {
	display: flex;
	gap: 0.75rem;
	margin-top: 1.5rem;
}

.issue-actions button {
	padding: 0.5rem 1rem;
	border-radius: 4px;
	font-size: 0.9rem;
	cursor: pointer;
}

.issue-actions button:disabled {
	opacity: 0.6;
	cursor: default;
}

.btn-danger {
	border: 1px solid var(--error);
	background: var(--error);
	color: #fff;
}

.btn-danger:hover {
	opacity: 0.85;
}

.btn-secondary {
	border: 1px solid var(--border-strong);
	background: var(--surface);
	color: var(--text);
}

.btn-secondary:hover {
	background: var(--surface-hover);
}
