:root {
	--ar-bg: #d9d2c8;
	--ar-panel: #141f25;
	--ar-panel-2: #1e3039;
	--ar-accent: #c45b3e;
	--ar-text: #f6f1ea;
	--ar-muted: rgba(246, 241, 234, 0.65);
}

body.afrane-reader-body {
	margin: 0;
	min-height: 100vh;
	background:
		radial-gradient(ellipse at top, rgba(255, 255, 255, 0.35), transparent 50%),
		linear-gradient(180deg, #e8e1d6 0%, var(--ar-bg) 100%);
	color: var(--ar-text);
	font-family: "DM Sans", system-ui, sans-serif;
}

.afrane-reader-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.85rem 1.25rem;
	background: linear-gradient(90deg, var(--ar-panel), var(--ar-panel-2));
	border-bottom: 1px solid rgba(255, 255, 255, 0.08);
	flex-wrap: wrap;
	position: sticky;
	top: 0;
	z-index: 20;
	box-shadow: 0 10px 30px rgba(20, 31, 37, 0.25);
}

.afrane-reader-header__left {
	display: flex;
	align-items: center;
	gap: 1rem;
	min-width: 0;
	flex: 1;
}

.afrane-reader-back {
	color: var(--ar-text);
	text-decoration: none;
	font-weight: 600;
	font-size: 0.92rem;
	white-space: nowrap;
	opacity: 0.9;
}

.afrane-reader-back:hover {
	opacity: 1;
	color: #fff;
}

.afrane-reader-title-wrap {
	min-width: 0;
}

.afrane-reader-badge {
	display: inline-block;
	margin-bottom: 0.2rem;
	padding: 0.15rem 0.55rem;
	border-radius: 999px;
	background: rgba(196, 91, 62, 0.2);
	color: #ffd4c6;
	font-size: 0.68rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.afrane-reader-header h1 {
	margin: 0;
	font-family: "Source Serif 4", Georgia, serif;
	font-size: clamp(0.95rem, 2vw, 1.15rem);
	font-weight: 600;
	color: rgba(246, 241, 234, 0.92);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.afrane-reader-controls {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	flex-wrap: wrap;
}

.afrane-reader-controls button {
	background: rgba(255, 255, 255, 0.08);
	border: 1px solid rgba(255, 255, 255, 0.12);
	color: #fff;
	min-width: 38px;
	height: 38px;
	cursor: pointer;
	border-radius: 8px;
	font-size: 1.1rem;
	font-weight: 600;
	transition: background 0.15s ease, transform 0.15s ease;
}

.afrane-reader-controls button:hover {
	background: rgba(255, 255, 255, 0.16);
	transform: translateY(-1px);
}

.afrane-reader-controls button:disabled {
	opacity: 0.35;
	cursor: default;
	transform: none;
}

#afrane-page-info {
	min-width: 4.5rem;
	text-align: center;
	font-variant-numeric: tabular-nums;
	font-size: 0.85rem;
	font-weight: 600;
	color: var(--ar-muted);
}

.afrane-zoom-field {
	display: inline-flex;
	align-items: center;
	gap: 0.15rem;
	padding: 0 0.35rem;
	height: 38px;
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.08);
	border: 1px solid rgba(255, 255, 255, 0.12);
	color: var(--ar-muted);
	font-size: 0.85rem;
	font-weight: 600;
}

.afrane-zoom-field input.afrane-zoom-info {
	width: 3.1rem;
	height: 100%;
	margin: 0;
	padding: 0;
	border: none;
	background: transparent;
	color: #fff;
	font: inherit;
	font-variant-numeric: tabular-nums;
	text-align: right;
	box-shadow: none;
	-moz-appearance: textfield;
	appearance: textfield;
}

.afrane-zoom-field input.afrane-zoom-info::-webkit-outer-spin-button,
.afrane-zoom-field input.afrane-zoom-info::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

.afrane-zoom-field input.afrane-zoom-info:focus {
	outline: none;
	color: #fff;
}

.afrane-reader-download {
	margin-left: 0.35rem;
	padding: 0 0.9rem !important;
	min-width: auto !important;
	font-size: 0.8rem !important;
	background: var(--ar-accent) !important;
	border-color: transparent !important;
}

.afrane-reader-main {
	position: relative;
	display: block;
	overflow: auto;
	min-height: calc(100vh - 70px);
	padding: 1.5rem 1rem 3rem;
	text-align: center;
	-webkit-overflow-scrolling: touch;
}

.afrane-reader-stage {
	position: relative;
	z-index: 1;
	display: inline-block;
	width: max-content;
	max-width: none;
	margin: 0 auto;
	text-align: left;
	vertical-align: top;
}

#afrane-pdf-canvas {
	display: block;
	width: auto;
	max-width: none;
	height: auto;
	border-radius: 4px;
	box-shadow:
		0 2px 4px rgba(20, 31, 37, 0.08),
		0 24px 48px rgba(20, 31, 37, 0.22);
	background: #fff;
}

.afrane-reader-loading {
	position: absolute;
	inset: 0;
	z-index: 5;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.85rem;
	background:
		radial-gradient(circle at 50% 40%, rgba(255, 253, 248, 0.55), transparent 55%),
		rgba(217, 210, 200, 0.92);
	backdrop-filter: blur(2px);
	transition: opacity 0.35s ease, visibility 0.35s ease;
}

.afrane-reader-loading.is-done {
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
}

.afrane-reader-loading.is-error {
	background: rgba(217, 210, 200, 0.96);
}

.afrane-reader-loading p {
	margin: 0;
	font-family: "Source Serif 4", Georgia, serif;
	font-size: 1.25rem;
	font-weight: 600;
	color: #1c2b33;
}

.afrane-reader-loading__hint {
	font-size: 0.88rem;
	color: rgba(28, 43, 51, 0.6);
}

.afrane-reader-spinner {
	width: 48px;
	height: 48px;
	border-radius: 50%;
	border: 3px solid rgba(28, 43, 51, 0.12);
	border-top-color: var(--ar-accent);
	animation: afrane-spin 0.8s linear infinite;
}

.afrane-reader-loading.is-error .afrane-reader-spinner {
	display: none;
}

@keyframes afrane-spin {
	to { transform: rotate(360deg); }
}

@media (max-width: 720px) {
	.afrane-reader-header {
		padding: 0.75rem;
	}

	.afrane-reader-download {
		width: 100%;
		margin-left: 0 !important;
	}
}
