:root {
	--bg: #f7f4ee;
	--surface: #ffffff;
	--surface-2: #efeae0;
	--text: #26221c;
	--muted: #6f675b;
	--line: #e0d9cb;
	--accent: #a83b2a;
	--accent-text: #ffffff;
	--shadow: 0 1px 3px rgba(60, 45, 20, 0.12);
	--reader-size: 19px;
	--reader-width: 720px;
	--reader-font: Georgia, "Iowan Old Style", "Times New Roman", serif;
	--ui-font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--bg: #15130f;
		--surface: #1f1c17;
		--surface-2: #2a261f;
		--text: #e8e2d6;
		--muted: #a59c8c;
		--line: #363027;
		--accent: #e2725b;
		--accent-text: #1a0f0b;
		--shadow: none;
	}
}

:root[data-theme="dark"] {
	--bg: #15130f;
	--surface: #1f1c17;
	--surface-2: #2a261f;
	--text: #e8e2d6;
	--muted: #a59c8c;
	--line: #363027;
	--accent: #e2725b;
	--accent-text: #1a0f0b;
	--shadow: none;
}

*,
*::before,
*::after {
	box-sizing: border-box;
}

html {
	-webkit-text-size-adjust: 100%;
}

[hidden] {
	display: none !important;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 16px/1.55 var(--ui-font);
}

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

a:hover {
	text-decoration: underline;
}

img {
	max-width: 100%;
	height: auto;
}

h1,
h2,
h3 {
	line-height: 1.2;
	font-family: var(--reader-font);
}

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

.screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

.wrap {
	width: min(1140px, 100%);
	margin: 0 auto;
	padding: 0 16px;
}

/* Header */

.site-header {
	position: sticky;
	top: 0;
	z-index: 20;
	background: var(--surface);
	border-bottom: 1px solid var(--line);
}

.site-header .wrap {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 20px;
	min-height: 60px;
	padding-block: 8px;
}

.site-title {
	margin: 0;
	font: 700 22px/1.2 var(--reader-font);
}

.site-title a {
	color: var(--text);
}

.site-nav ul {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 16px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.site-nav a {
	color: var(--muted);
	font-weight: 500;
}

.header-tools {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-left: auto;
}

.search-form {
	display: flex;
}

.search-form input {
	width: 160px;
	padding: 6px 10px;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: var(--bg);
	color: var(--text);
	font: inherit;
}

.icon-button {
	padding: 6px 10px;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: var(--surface);
	color: var(--text);
	font: inherit;
	cursor: pointer;
}

/* Layout */

.site-main {
	padding-block: 28px 56px;
}

.section-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 16px;
	margin: 0 0 14px;
	padding-bottom: 8px;
	border-bottom: 2px solid var(--line);
}

.section-head h2,
.section-head h1 {
	margin: 0;
	font-size: 24px;
}

.home-layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 320px;
	gap: 36px;
	align-items: start;
}

.empty-state {
	padding: 40px 20px;
	border: 1px dashed var(--line);
	border-radius: 8px;
	color: var(--muted);
	text-align: center;
}

/* Covers */

.cover {
	display: block;
	aspect-ratio: 2 / 3;
	overflow: hidden;
	border-radius: 6px;
	background: var(--surface-2);
	box-shadow: var(--shadow);
}

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

.cover-placeholder {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 100%;
	padding: 12px;
	color: var(--muted);
	font: 600 15px/1.3 var(--reader-font);
	text-align: center;
}

/* Recently updated */

.update-list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
	gap: 14px;
}

.update-card {
	display: grid;
	grid-template-columns: 84px minmax(0, 1fr);
	gap: 14px;
	padding: 12px;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: var(--surface);
}

.update-card h3 {
	margin: 0 0 6px;
	font-size: 17px;
}

.update-card h3 a {
	color: var(--text);
}

.chapter-links {
	margin: 0;
	padding: 0;
	list-style: none;
	font-size: 14px;
}

.chapter-links li {
	display: flex;
	justify-content: space-between;
	gap: 10px;
	padding: 3px 0;
}

.chapter-links a {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.time {
	flex: none;
	color: var(--muted);
	font-size: 12px;
}

/* Latest list */

.release-list {
	margin: 0;
	padding: 0;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: var(--surface);
	list-style: none;
}

.release-list li {
	padding: 10px 12px;
	border-top: 1px solid var(--line);
}

.release-list li:first-child {
	border-top: 0;
}

.release-list .novel-name {
	display: block;
	color: var(--muted);
	font-size: 13px;
}

.release-list .chapter-name {
	display: block;
	font-weight: 500;
}

/* Novel grid */

.novel-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
	gap: 20px;
}

.novel-card h2 {
	margin: 8px 0 2px;
	font-size: 16px;
}

.novel-card h2 a {
	color: var(--text);
}

.novel-card p {
	margin: 0;
	color: var(--muted);
	font-size: 13px;
}

/* Novel page */

.novel-hero {
	display: grid;
	grid-template-columns: 220px minmax(0, 1fr);
	gap: 28px;
	margin-bottom: 32px;
}

.novel-hero h1 {
	margin: 0 0 4px;
	font-size: 34px;
}

.original-title {
	margin: 0 0 12px;
	color: var(--muted);
}

.novel-facts {
	display: grid;
	grid-template-columns: max-content 1fr;
	gap: 2px 14px;
	margin: 0 0 16px;
	font-size: 14px;
}

.novel-facts dt {
	color: var(--muted);
}

.novel-facts dd {
	margin: 0;
}

.tags {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-bottom: 16px;
}

.tags a {
	padding: 2px 10px;
	border-radius: 999px;
	background: var(--surface-2);
	color: var(--text);
	font-size: 13px;
}

.button {
	display: inline-block;
	padding: 9px 18px;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: var(--surface);
	color: var(--text);
	font-weight: 600;
}

.button:hover {
	text-decoration: none;
	border-color: var(--accent);
}

.button-primary {
	border-color: var(--accent);
	background: var(--accent);
	color: var(--accent-text);
}

.button[aria-disabled="true"] {
	opacity: 0.45;
	pointer-events: none;
}

.novel-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 20px;
}

.synopsis {
	max-width: 70ch;
}

.chapter-tools {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 12px;
}

.chapter-tools input {
	flex: 1 1 200px;
	padding: 8px 12px;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: var(--surface);
	color: var(--text);
	font: inherit;
}

.chapter-list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
	gap: 0 24px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.chapter-list li {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	padding: 9px 4px;
	border-bottom: 1px solid var(--line);
}

.chapter-list a {
	min-width: 0;
	overflow: hidden;
	color: var(--text);
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* Reader */

.progress {
	position: fixed;
	top: 0;
	left: 0;
	z-index: 40;
	width: 0;
	height: 3px;
	background: var(--accent);
}

.reader {
	width: min(var(--reader-width), 100%);
	margin: 0 auto;
}

.crumbs {
	margin-bottom: 8px;
	color: var(--muted);
	font-size: 14px;
}

.reader-title {
	margin: 0 0 18px;
	font-size: 30px;
}

.chapter-nav {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	gap: 8px;
	margin: 18px 0;
}

.chapter-nav .button {
	text-align: center;
}

.reader-settings {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin-bottom: 8px;
	color: var(--muted);
	font-size: 14px;
}

.reader-settings select {
	padding: 5px;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: var(--surface);
	color: var(--text);
	font: inherit;
}

.reader-text {
	font-family: var(--reader-font);
	font-size: var(--reader-size);
	line-height: 1.75;
	overflow-wrap: break-word;
}

.reader-text p {
	margin: 0 0 1.1em;
}

.ai-note {
	margin: 24px 0 0;
	color: var(--muted);
	font-size: 13px;
}

.entry {
	max-width: 760px;
	margin: 0 auto;
}

.entry h1 {
	margin-top: 0;
	font-size: 34px;
}

.pagination {
	margin-top: 28px;
	text-align: center;
}

.pagination .page-numbers {
	display: inline-block;
	padding: 4px 10px;
}

.pagination .current {
	border-radius: 6px;
	background: var(--accent);
	color: var(--accent-text);
}

/* Footer */

.site-footer {
	padding-block: 32px;
	border-top: 1px solid var(--line);
	background: var(--surface);
	color: var(--muted);
	font-size: 14px;
}

.footer-grid {
	display: grid;
	grid-template-columns: minmax(0, 2fr) 1fr 1fr;
	gap: 28px;
}

.site-footer h2 {
	margin: 0 0 8px;
	color: var(--text);
	font: 700 14px var(--ui-font);
}

.site-footer ul {
	margin: 0;
	padding: 0;
	list-style: none;
}

.site-footer li {
	padding: 2px 0;
}

.site-footer a {
	color: var(--muted);
}

.site-footer a:hover {
	color: var(--accent);
}

.footer-note {
	margin: 0;
}

.copyright {
	margin: 24px 0 0;
	padding-top: 16px;
	border-top: 1px solid var(--line);
	font-size: 13px;
}

@media (max-width: 900px) {
	.home-layout,
	.footer-grid {
		grid-template-columns: 1fr;
	}
}

@media (max-width: 640px) {
	.novel-hero {
		grid-template-columns: 1fr;
	}

	.novel-hero .cover {
		width: min(200px, 60%);
		margin: 0 auto;
	}

	.novel-hero h1 {
		font-size: 28px;
	}

	.header-tools {
		width: 100%;
		margin-left: 0;
	}

	.search-form,
	.search-form input {
		flex: 1;
		width: 100%;
	}

	.update-list,
	.chapter-list {
		grid-template-columns: minmax(0, 1fr);
	}

	.reader-title {
		font-size: 25px;
	}
}
