* {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	padding: 0;
}

body {
	background: var(--color-background);
	font-family: var(--font-family-sans);
	color: var(--color-text);
}

:focus 		     			 {outline: none}
:focus-visible   			 {outline: 2px solid var(--color-primary);outline-offset: 2px;}
.close-container 			 {background: var(--color-background-alt);z-index:var(--z-chrome);position: absolute;top:0;right:0;width:72px;height:40px;}
.compact-ui .close-container {height: 39px;}
.close-button 				 {font-family: var(--font-family-sans);position: absolute;z-index: var(--z-chrome);top: 15px;right: 10px;cursor: pointer;color: var(--color-text-muted);width: 20px;height: 20px;border-radius: 10px;text-align: center;}
.close-button::before 		 {content: "";position: absolute;inset: 0;background-color: currentColor;-webkit-mask: url(images/close-button.svg) center / 12px 12px no-repeat;mask: url(images/close-button.svg) center / 12px 12px no-repeat;}
.close-button:hover 		 {background-color: var(--color-error);color: var(--color-background);}

.link-button {
	position: absolute;
	z-index: var(--z-chrome);
	top: 15px;
	right: 40px;
	width: 20px;
	height: 20px;
	border-radius: 10px;
	cursor: pointer;
	color: var(--color-text-muted);
}

.link-button svg {
	width: 14px;
	height: 14px;
	display: block;
	margin: 3px;
}

.link-button:hover {
	color: var(--color-text);
	background-color: var(--color-background-hover);
}

.link-button.unlinked {
	color: var(--color-primary);
}

.one-window .window .link-button {
	display: none;
}

.windows-header {
	background-color: var(--color-toolbar-background);
	border-bottom: 1px solid var(--color-border);
	display: flex;
	align-items: center;
	height: 60px;
	padding-right: 10px;
}

.windows-footer {
	height: 0;
}

.windows-main {
	display: flex;
}

.window {
	overflow: hidden;
	position: relative;
	margin: 0;
	padding: 0;
	border-right: solid 1px var(--color-border);
}

.window-splitter {
	position: absolute;
	top: 60px;
	width: 8px;
	background: transparent;
	cursor: col-resize;
	z-index: var(--z-popover);
	user-select: none;
}

.window-splitter:hover,
.window-splitter.dragging {background: var(--color-primary);opacity: 0.5;}
.compact-ui .window-splitter {display: none;}
.window *::-webkit-scrollbar {width: 24px;height: 24px;}
.window *::-webkit-scrollbar-track {background: var(--color-background-alt);}
.window *::-webkit-scrollbar-thumb {background: var(--color-border);border-radius: 12px;border: 4px solid var(--color-background-alt);}
.window *::-webkit-scrollbar-thumb:hover {background: var(--color-text-muted);}
.window * {scrollbar-width: auto;scrollbar-color: var(--color-border) var(--color-background-alt);}

.window-tab {
	display: none;
	position: absolute;
	top: 14px;
	right: 0;
	width: 82px;
	height: 26px;
	background: transparent;
	border-style: solid;
	border-color: transparent transparent var(--color-border) transparent;
	border-width: 0 11px 21px 11px;
	z-index: var(--z-base);
	cursor: pointer;
}

.window-tab-inner {
	width: 80px;
	height: 25px;
	margin-left: -10px;
	margin-top: 1px;
	background: transparent;
	border-style: solid;
	border-color: transparent transparent var(--color-border) transparent;
	border-width: 0 10px 25px 10px;
}

.window-tab.active {z-index: var(--z-above);border-color: transparent transparent transparent transparent;}
.window-tab.active .window-tab-inner {border-color: transparent transparent var(--color-background-alt) transparent;}

.window-tab-label {
	display: flex;
	height:25px;
	justify-content: center;
	place-items: center;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
	font-size: 11px;
}

.window-tab-icon {
	width: 15px;
	height: 15px;
	flex-shrink: 0;
	margin-right: 5px;
	color: var(--color-primary);
}

.window-tab-icon svg {
	width: 100%;
	height: 100%;
	display: block;
}

.window .window-header {
	margin: 0;
	padding: 10px;
	background: var(--color-background-alt);
	border-bottom: solid 1px var(--color-border);
	height: 50px;
	z-index: var(--z-base);
	font-family: var(--font-family-sans);
	font-size: 12px;
	white-space: nowrap;
	vertical-align: middle;
}

/* Drag a header to reorder windows (no-op with one window or in compact tabs) */
body:not(.one-window):not(.compact-ui) .window .window-header {
	cursor: grab;
}

body.window-reordering,
body.window-reordering * {
	cursor: grabbing !important;
	user-select: none !important;
}

/* While a drag is in progress nothing else should react to the pointer:
   no hover styles, tooltips, or mouseenter focus handlers */
body.window-reordering .window,
body.window-reordering .window-splitter,
body.window-reordering .windows-header {
	pointer-events: none;
}

/* The window being dragged rides above everything: setting a z-index makes
   it one stacking context, so neighbors' chrome (close buttons at --z-chrome,
   panels, splitters at --z-popover) can no longer paint through it */
.window.reordering {
	opacity: 0.75;
	z-index: var(--z-menu);
	box-shadow: var(--shadow-popup);
}

/* Applied while a displaced window slides into its new slot (duration
   mirrored in WindowManager's slideMs) */
.window.window-slide {
	transition: translate 0.18s cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* Applied to the dragged window on drop: it snaps into its slot with a
   little spring while the lift fades, riding above its neighbors until it
   lands (duration mirrored in WindowManager's snapMs) */
.window.window-snap {
	z-index: var(--z-menu);
	transition:
		translate 0.32s cubic-bezier(0.34, 1.56, 0.64, 1),
		opacity 0.32s ease,
		box-shadow 0.32s ease;
}

.window-title {
	display: block;
	font-size: 18px;
	margin: 5px 0 5px 10px;
}

.app-input,
.app-list {
	border: solid 1px var(--color-border);
	padding: 7px 6px 6px 10px;
	background: var(--color-background);
	margin: 0 5px 0 0;
	color: var(--color-text-muted);
	appearance: none;
	height: 30px;
	border-radius: 0;
	display: inline-block;
	vertical-align: top;
}

.app-list.app-list-image {
	width: 50px;
	padding: 2px;
}
.app-list.app-list-image img {
	width: 100%;
	height: 100%;
}

.app-input:hover,
.app-list:hover {
	border-color: var(--color-border);
}

.app-input {
	padding-top: 5px;
	min-width: 140px;
}

.app-list {
	padding-right: 20px;
	cursor: pointer;
	border-radius: 0;
	position: relative;
}
.app-list::after {
	content: '';
	position: absolute;
	right: 4px;
	top: 50%;
	translate: 0 -50%;
	width: 10px;
	height: 6px;
	background-color: currentColor;
	mask-image: url(images/arrow-down.svg);
	mask-size: contain;
	mask-repeat: no-repeat;
	opacity: 0.6;
}

.header-icon {
	margin: 3px;
	width: 24px;
	height: 24px;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	vertical-align: top;
}
.header-icon svg {
	width: 20px;
	height: 20px;
	margin: 2px;
}

.text-chooser-header .header-icon {
	float: left;
}

.header-icon:hover {
	border: 1px solid var(--color-border);
	border-radius: 20px;
}

.window .window-header .header-button {
	padding: 8px 4px 6px 4px;
	background: transparent;
	border-radius: 5px;
	cursor: pointer;
	color: var(--color-primary);
	border: 0;
	font-size: 12px;
	display: inline-block;
}

.one-window .window .close-button {
	display: none;
}

	.compact-ui .window-tab {
		display: block;
		top: 40px;
	}


	.compact-ui .windows-main {
		display: block;
	}
	.compact-ui .windows-main .window {
		z-index: var(--z-base);
		position: absolute;
		top: 66px;
	}
	.compact-ui .windows-main .window.active {
		z-index: var(--z-above);
	}
	.compact-ui .window .window-header .app-input {
		width: 90px;
		min-width: 120px;
		padding: 5px;
		height: 25px;

	}

	.compact-ui .window .window-header .app-list {
		padding: 5px  20px 5px 5px;
		height: 25px;
	}

	.compact-ui .window .window-header {
		height: 40px;
		padding: 7px;
	}
	.compact-ui .window .close-button {
		top: 10px;
	}
	.compact-ui .window .link-button {
		top: 10px;
	}
	.compact-ui .windows-header {height: 40px;}
	.compact-ui .header-icon {margin-top: 1px;}

	 .compact-ui.app-mobile-fullscreen .windows-header {
		 height: 50px;
	 }

	.compact-ui.app-mobile-fullscreen  .windows-main .window {
		top: 76px;
	}

	.compact-ui.app-mobile-fullscreen .window-tab {
		top: 50px;
	}

	.compact-ui.app-mobile-fullscreen #main-menu-dropdown {
		top: 40px;
	}

.window .window-main {
	margin: 0;
	background: var(--color-background);
	border-bottom: solid 1px var(--color-border);
	border-right: solid 1px var(--color-border);
	height: 70px;
	overflow: auto;
}

.window .window-footer {
	font: 10px Helvetica;
	height: 30px;
	padding: 8px;
	background: var(--color-background-alt);
	border-top: solid 1px var(--color-border);
}


.window-overlay {
	position: absolute;
	top: 50px;
	right: 10px;
	width: 300px;
	height: 300px;
	padding: 25px 25px 0;
	background: var(--color-background);
	border: solid 1px var(--color-border);
	box-shadow: var(--shadow-popup);
	display: none;
	z-index: var(--z-overlay);
	overflow: auto;
}

#about h1 {
	font-size: 18pt;
	margin-top: 0;
}

#about a {
	color: var(--color-primary);
}

.loading-indicator {
	min-height: 70px;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 10px;
	color: var(--color-text-muted);
}

.loading-indicator::after {
	content: '';
	width: 28px;
	height: 28px;
	border: 3px solid var(--color-border);
	border-top-color: var(--color-primary);
	border-radius: 50%;
	animation: spin 0.8s linear infinite;
}

.loading-message {
	order: -1;
	font-size: 0.95em;
	color: var(--color-text-muted);
	text-align: center;
}

.chapter-unavailable {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	padding: 40px 20px;
	text-align: center;
	color: var(--color-text-muted);
}

.chapter-unavailable-message {
	margin: 0;
	font-size: 1.05em;
}

.chapter-unavailable-link {
	color: var(--color-primary);
	text-decoration: underline;
	cursor: pointer;
}

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

.modal-overlay {
	background: oklch(0 0 0 / 0.5);
	position: absolute;
	z-index: var(--z-chrome);
	top: 0;
	left: 0;
	display: none;
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}
}
