.isdfr,
.isdfr * {
	box-sizing: border-box;
}

.isdfr {
	position: fixed;
	inset: 0;
	z-index: 2147483000;
	display: none;
	grid-template-rows: auto minmax(0, 1fr) auto;
	background: #111827;
	color: #f9fafb;
	font-family: inherit;
}

.isdfr.is-open { display: grid; }

/* WordPress reserves the maximum z-index for its signed-in admin bar. Keep the
 * reader controls immediately below it so both layers remain usable. */
body.admin-bar .isdfr { top: 32px; }

.isdfr-top,
.isdfr-bottom {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
	padding: 9px 14px;
	background: #0b1220;
	box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08);
}

.isdfr-title {
	min-width: 0;
	margin-right: auto;
	overflow: hidden;
	font-size: 15px;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.isdfr-tools {
	display: flex;
	align-items: center;
	gap: 6px;
	min-width: 0;
}

.isdfr button,
.isdfr-login {
	border: 1px solid rgba(255, 255, 255, 0.18);
	border-radius: 9px;
	background: #1f2937;
	color: #fff;
	font: inherit;
	font-weight: 750;
	cursor: pointer;
}

.isdfr button:hover,
.isdfr button:focus-visible,
.isdfr-login:hover,
.isdfr-login:focus-visible {
	border-color: #93c5fd;
	background: #27364b;
	outline: 2px solid transparent;
}

.isdfr button:disabled { opacity: 0.45; cursor: default; }

.isdfr-icon {
	width: 38px;
	height: 38px;
	padding: 0;
	font-size: 19px;
}

.isdfr-text,
.isdfr-audio {
	height: 38px;
	padding: 0 12px;
	font-size: 13px;
	white-space: nowrap;
}

.isdfr-audio {
	border-color: #fbbf24 !important;
	background: #92400e !important;
}

.isdfr-stage {
	position: relative;
	min-height: 0;
	overflow: auto;
	padding: 14px;
	background: #283444;
	text-align: center;
	overscroll-behavior: contain;
}

.isdfr-page {
	display: block;
	width: 100%;
	max-width: none;
	height: auto;
	margin: 0 auto;
	background: #fff;
	box-shadow: 0 14px 36px rgba(0, 0, 0, 0.35);
}

.isdfr-page[hidden],
.isdfr-loading[hidden],
.isdfr-gate[hidden] { display: none; }

.isdfr-loading {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	max-width: calc(100% - 40px);
	padding: 12px 18px;
	border-radius: 12px;
	background: rgba(11, 18, 32, 0.92);
	font-size: 14px;
	line-height: 1.5;
}

.isdfr-loading.is-error { background: #7f1d1d; }

.isdfr-gate {
	width: min(520px, calc(100% - 24px));
	margin: 12vh auto 0;
	padding: 34px 24px;
	border-radius: 18px;
	background: #fff;
	color: #111827;
	box-shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
}

.isdfr-gate h3 { margin: 0 0 10px; font-size: 22px; }
.isdfr-gate p { margin: 0 0 22px; line-height: 1.7; }

.isdfr-login {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	padding: 0 18px;
	background: #1d4ed8;
	text-decoration: none;
}

.isdfr-bottom {
	justify-content: center;
	box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.08);
}

.isdfr-nav {
	min-width: 92px;
	height: 40px;
	padding: 0 14px;
}

.isdfr-indicator {
	min-width: 96px;
	font-variant-numeric: tabular-nums;
	font-weight: 800;
	text-align: center;
}

.isdfr-toc {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	z-index: 2;
	width: min(360px, 88vw);
	padding: 14px;
	transform: translateX(105%);
	transition: transform 0.18s ease-out;
	background: #111827;
	box-shadow: -12px 0 30px rgba(0, 0, 0, 0.35);
	overflow-y: auto;
}

.isdfr-toc.is-open { transform: translateX(0); }

.isdfr-toc-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 14px;
}

.isdfr-toc-grid {
	display: grid;
	grid-template-columns: repeat(5, minmax(0, 1fr));
	gap: 7px;
}

.isdfr-toc-page {
	min-height: 42px;
	padding: 0;
	font-variant-numeric: tabular-nums;
}

.isdfr-toc-page.is-current {
	border-color: #fde68a;
	background: #b45309;
}

@media (max-width: 640px) {
	.isdfr-top { padding: 7px 8px; }
	.isdfr-title { max-width: 31vw; font-size: 13px; }
	.isdfr-tools { overflow-x: auto; scrollbar-width: none; }
	.isdfr-tools::-webkit-scrollbar { display: none; }
	.isdfr-icon { flex: 0 0 34px; width: 34px; height: 34px; }
	.isdfr-text,
	.isdfr-audio { flex: 0 0 auto; height: 34px; padding: 0 9px; font-size: 11px; }
	.isdfr-stage { padding: 6px; }
	.isdfr-bottom { padding: 7px 8px; }
	.isdfr-nav { min-width: 78px; height: 36px; padding: 0 10px; font-size: 13px; }
	.isdfr-indicator { min-width: 78px; font-size: 13px; }
	.isdfr-toc-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 782px) {
	body.admin-bar .isdfr { top: 46px; }
}

@media (prefers-reduced-motion: reduce) {
	.isdfr-toc { transition: none; }
}
