:root {
	--bg: #f5f5f5;
	--surface: #ffffff;
	--text: #111827;
	--muted: #6b7280;
	--border: #e5e7eb;
	--primary: #2563eb;
	--danger: #dc2626;
}

* {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	padding: 0;
	background: var(--bg);
	color: var(--text);
	font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic", "Meiryo", sans-serif;
	-webkit-text-size-adjust: 100%;
}

img {
	max-width: 100%;
	display: block;
}

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

button,
input,
select,
textarea {
	font: inherit;
}

.main-content {
	max-width: 760px;
	margin: 0 auto;
	padding: 12px 10px 80px;
}

.page-title {
	margin: 8px 0 12px;
	font-size: 1.1rem;
	font-weight: 700;
}

.header {
	position: sticky;
	top: 0;
	z-index: 100;
	display: flex;
	align-items: center;
	height: 48px;
	padding: 0 8px;
	background: var(--surface);
	border-bottom: 1px solid var(--border);
	transition: transform 0.25s ease;
}

.header-right {
	display: flex;
	align-items: center;
	margin-left: auto;
}

.header--hidden {
	transform: translateY(-100%);
}

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

.menu-toggle-btn,
.search-icon,
.fav-icon,
.menu-close {
	min-width: 44px;
	min-height: 44px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 8px;
	cursor: pointer;
}

.menu-toggle-btn {
	flex-direction: column;
	gap: 4px;
}

.hamburger-line {
	width: 20px;
	height: 2px;
	background: var(--text);
	border-radius: 999px;
}

.header-title {
	position: absolute;
	left: 50%;
	transform: translateX(-50%);
	font-size: 1.1rem;
	font-weight: 700;
	color: var(--text);
	text-decoration: none;
	letter-spacing: 0.01em;
	white-space: nowrap;
	pointer-events: auto;
}

.side-menu {
	position: fixed;
	inset: 0;
	pointer-events: none;
}

.menu-overlay {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.45);
	opacity: 0;
	transition: opacity 0.2s ease;
}

.menu-panel {
	position: absolute;
	left: 0;
	top: 0;
	width: min(82vw, 320px);
	height: 100%;
	background: var(--surface);
	transform: translateX(-100%);
	transition: transform 0.2s ease;
	border-right: 1px solid var(--border);
	overflow-y: auto;
}

.menu-toggle-input:checked ~ .side-menu {
	pointer-events: auto;
}

.menu-toggle-input:checked ~ .side-menu .menu-overlay {
	opacity: 1;
}

.menu-toggle-input:checked ~ .side-menu .menu-panel {
	transform: translateX(0);
}

.menu-header {
	height: 56px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 10px;
	border-bottom: 1px solid var(--border);
	font-weight: 700;
}

.menu-list {
	list-style: none;
	margin: 0;
	padding: 8px 0;
}

.menu-item {
	min-height: 44px;
	padding: 8px 12px;
	display: flex;
	align-items: center;
	gap: 10px;
}

.menu-icon {
	width: 24px;
	text-align: center;
}

.badge {
	margin-left: auto;
	min-width: 20px;
	height: 20px;
	border-radius: 999px;
	background: var(--primary);
	color: #fff;
	font-size: 12px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0 6px;
}

.menu-divider {
	margin: 8px 0;
	border-top: 1px solid var(--border);
}

.menu-section-title {
	padding: 8px 12px;
	font-size: 12px;
	color: var(--muted);
}

.card-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
}

.manga-card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 10px;
	overflow: hidden;
	position: relative;
}

.card-thumb-link {
	display: block;
}

.card-thumbnail {
	width: 100%;
	aspect-ratio: 3 / 4;
	object-fit: cover;
	background: #e5e7eb;
}

.card-info {
	padding: 8px;
}

.card-title {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	line-height: 1.35;
	min-height: 2.7em;
	font-size: 14px;
	font-weight: 600;
}

.card-meta {
	margin-top: 8px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
}

.card-chapter,
.fav-btn {
	min-width: 44px;
	min-height: 44px;
	border-radius: 8px;
}

.card-chapter {
	flex: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0 8px;
	background: #f3f4f6;
	font-size: 13px;
}

.fav-btn {
	width: 44px;
	border: 1px solid var(--border);
	background: #fff;
	font-size: 20px;
	color: #d97706;
}

.fav-btn.active {
	background: #fffbeb;
}

.card-time-badge {
	position: absolute;
	top: 6px;
	left: 6px;
	z-index: 10;
	font-size: 0.65rem;
	padding: 2px 6px;
	border-radius: 4px;
	font-weight: 600;
	pointer-events: none;
	background: rgba(0, 0, 0, 0.6);
	color: white;
	backdrop-filter: blur(2px);
	box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.pagination {
	margin-top: 14px;
	display: flex;
	justify-content: center;
	gap: 6px;
}

.page-btn {
	width: 40px;
	height: 40px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: 1px solid var(--border);
	border-radius: 8px;
	background: var(--surface);
}

.page-current {
	background: var(--primary);
	border-color: var(--primary);
	color: #fff;
}

.page-btn.disabled {
	color: #9ca3af;
}

.detail-layout {
	display: grid;
	grid-template-columns: 120px 1fr;
	gap: 12px;
	margin-bottom: 12px;
}

.detail-header {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin-bottom: 10px;
}

.detail-cover {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
}

.detail-cover img {
	width: 60%;
	max-width: 220px;
	aspect-ratio: 3 / 4;
	object-fit: cover;
	border-radius: 8px;
}

.detail-title {
	font-size: 1rem;
	font-weight: 700;
	text-align: center;
	margin: 0;
}

.detail-subtitle {
	font-size: 0.85rem;
	color: var(--muted);
	text-align: center;
	margin: 0;
}

.detail-info {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	flex: 1;
	min-width: 0;
}

.genre-tags {
	display: flex;
	gap: 6px;
	flex-wrap: wrap;
}

.genre-tag {
	padding: 4px 10px;
	border-radius: 999px;
	background: #eef2ff;
	font-size: 12px;
}

.synopsis {
	padding: 10px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 8px;
	line-height: 1.55;
}

.chapter-list {
	margin: 12px 0 0;
	padding: 0;
	list-style: none;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 8px;
	overflow: hidden;
}

.chapter-item {
	min-height: 44px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px;
	border-bottom: 1px solid var(--border);
}

.chapter-item:last-child {
	border-bottom: none;
}

.chapter-reader {
	margin: 0 -10px;
	background: #111;
}

.chapter-image {
	width: 100%;
	height: auto;
	display: block;
	margin: 0;
}

.chapter-nav {
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 12px 10px;
	border-top: 1px solid var(--border);
	margin-top: 12px;
	background: var(--surface);
}

.chapter-nav-row {
	display: flex;
	align-items: center;
	gap: 8px;
}

.chapter-nav-btn {
	flex: 1;
	min-height: 44px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: 1px solid var(--border);
	border-radius: 8px;
	background: var(--primary);
	color: #fff;
	font-size: 0.9rem;
	font-weight: 600;
	text-decoration: none;
	transition: opacity 0.15s;
	cursor: pointer;
}

.chapter-nav-btn:active {
	opacity: 0.8;
}

.chapter-nav-btn.disabled {
	background: #e5e7eb;
	color: #9ca3af;
	border-color: #d1d5db;
	pointer-events: none;
	cursor: default;
}

.chapter-nav-select {
	flex: 1.2;
	position: relative;
}

.chapter-nav-select .chapter-select {
	width: 100%;
	min-height: 44px;
	padding: 0 28px 0 12px;
	border: 1px solid var(--border);
	border-radius: 8px;
	background: var(--surface);
	color: var(--text);
	font-size: 0.9rem;
	font-weight: 600;
	text-align: center;
	appearance: none;
	-webkit-appearance: none;
	cursor: pointer;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 10px center;
}

.chapter-nav-current {
	flex: 1.2;
	min-height: 44px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: 1px solid var(--border);
	border-radius: 8px;
	background: var(--surface);
	font-size: 0.9rem;
	font-weight: 600;
}

.chapter-nav-title {
	text-align: center;
	width: 100%;
}

.chapter-nav-title a {
	font-size: 0.85rem;
	color: var(--muted);
	text-decoration: none;
}

.search-form {
	display: flex;
	gap: 8px;
	margin-bottom: 12px;
}

.search-input {
	flex: 1;
	min-height: 44px;
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 0 10px;
	background: #fff;
}

.search-btn {
	min-width: 88px;
	min-height: 44px;
	border: none;
	border-radius: 8px;
	background: var(--primary);
	color: #fff;
}

.history-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.history-item {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 10px;
	margin-bottom: 8px;
}

.download-progress {
	width: 100%;
	height: 10px;
	border-radius: 999px;
	overflow: hidden;
	background: #e5e7eb;
}

.download-progress-bar {
	height: 100%;
	background: var(--primary);
	width: 0;
}

.empty-state,
.error-state {
	margin: 24px 0;
	text-align: center;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 20px 12px;
}

.error-state {
	border-color: #fecaca;
	color: var(--danger);
}

.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.text-center {
	text-align: center;
}

.mt-8 {
	margin-top: 8px;
}

.mt-12 {
	margin-top: 12px;
}

.mb-8 {
	margin-bottom: 8px;
}

.mb-12 {
	margin-bottom: 12px;
}

/* Search */
.search-bar {
	margin: 16px 0;
}

.search-bar form {
	display: flex;
	gap: 8px;
}

.search-input {
	flex: 1;
	padding: 10px 14px;
	border: 1px solid #ddd;
	border-radius: 8px;
	font-size: 16px;
	-webkit-appearance: none;
}

.search-input:focus {
	outline: none;
	border-color: #4a90d9;
}

.search-btn {
	padding: 10px 16px;
	background: #4a90d9;
	color: #fff;
	border: none;
	border-radius: 8px;
	font-size: 16px;
	cursor: pointer;
	min-width: 44px;
	min-height: 44px;
}

.search-result-count {
	font-size: 0.85rem;
	color: #666;
	margin: 12px 0 8px;
}

/* History */
.section-header {
	font-size: 0.9rem;
	font-weight: 600;
	color: #333;
	margin: 16px 0 8px;
	padding-bottom: 4px;
	border-bottom: 1px solid #eee;
}

.continue-list,
.history-list {
	margin-bottom: 16px;
}

.continue-item,
.history-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px;
	border-bottom: 1px solid #f0f0f0;
	text-decoration: none;
	color: inherit;
	min-height: 44px;
}

.continue-item:active,
.history-item:active {
	background: #f5f5f5;
}

.continue-info,
.history-info {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-width: 0;
}

.continue-title,
.history-title {
	font-size: 0.9rem;
	font-weight: 500;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.continue-chapter,
.history-chapter {
	font-size: 0.8rem;
	color: #666;
	margin-top: 2px;
}

.continue-arrow {
	font-size: 1.1rem;
	color: #4a90d9;
	margin-left: 8px;
}

.history-meta {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	flex-shrink: 0;
	margin-left: 8px;
}

.history-site {
	font-size: 0.7rem;
	color: #999;
	text-transform: uppercase;
}

.history-time {
	font-size: 0.7rem;
	color: #999;
	margin-top: 2px;
}

/* Site Badge Configuration */
.site-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 10;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: 600;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    backdrop-filter: blur(2px);
    box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.site-badge--klz9 {
    background: rgba(59, 130, 246, 0.85); /* #3b82f6 */
    color: white;
}

.site-badge--spoilerplus {
    background: rgba(34, 197, 94, 0.85); /* #22c55e */
    color: white;
}
