﻿body {
	margin: 0;
	background: #f5f1e8;
	color: #222;
	font-family: Georgia, "Times New Roman", serif;
}
body[data-theme="dark"] {
  background: #111315;
  color: #e7e2d9;
}
body[data-theme="dark"] .reader-topbar {
  background: #181b1f;
  box-shadow: 0 1px 0 rgba(255,255,255,0.06);
}
body[data-theme="dark"] .reader-sidebar {
  background: #16191d;
  color: #e7e2d9;
}
body[data-theme="dark"] .toc-link {
  color: #ddd6c8;
}
body[data-theme="dark"] .toc-link:hover,
body[data-theme="dark"] .toc-link.active {
  background: rgba(255,255,255,0.08);
}
body[data-theme="dark"] #scrollReader .chapter-content,
body[data-theme="dark"] #flipReader .chapter-content,
body[data-theme="dark"] .book-page {
  background: #1b1f24;
  color: #ebe5da;
  box-shadow: 0 0 20px rgba(0,0,0,0.35);
}
body[data-theme="dark"] .chapter-opening .chapter-label,
body[data-theme="dark"] .chapter-opening .chapter-subtitle,
body[data-theme="dark"] .reader-figure figcaption,
body[data-theme="dark"] .book-page-indicator {
  color: #b8b0a4;
}
body[data-theme="dark"] .chapter-content h1:first-child {
  border-bottom-color: rgba(255,255,255,0.12);
}
body[data-theme="dark"] .btn-outline-secondary {
  color: #e7e2d9;
  border-color: rgba(255,255,255,0.25);
}
body[data-theme="dark"] .btn-outline-secondary:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}
body[data-theme="dark"] .form-select {
  background-color: #1b1f24;
  color: #ebe5da;
  border-color: rgba(255,255,255,0.2);
}
body[data-theme="dark"] .progress {
  background-color: rgba(255,255,255,0.08);
}
body[data-theme="dark"] .open-sidebar-btn,
body[data-theme="dark"] #backToTopBtn {
  background: #1b1f24;
  color: #ebe5da;
  border-color: rgba(255,255,255,0.2);
}
body[data-theme="dark"] .mobile-reader-settings {
  background: #181b1f;
  border-bottom-color: rgba(255,255,255,0.08);
}
body[data-theme="dark"] .mobile-reader-settings .form-label {
  color: #d8d1c5;
}
body[data-theme="dark"] .mobile-reader-settings .form-select {
  background-color: #1b1f24;
  color: #ebe5da;
  border-color: rgba(255,255,255,0.2);
}
@media (max-width: 767.98px) {
  body[data-theme="dark"] .reader-topbar {
    background: #181b1f;
  }
}
body[data-theme="dark"] .reader-search-results {
  background: #172033;
  border-color: rgba(255,255,255,0.08);
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}

body[data-theme="dark"] .reader-search-result {
  border-bottom-color: rgba(255,255,255,0.06);
}

body[data-theme="dark"] .reader-search-result:hover {
  background: rgba(255,255,255,0.05);
}

body[data-theme="dark"] .reader-search-result-section,
body[data-theme="dark"] .reader-search-empty {
  color: #bfc7d4;
}

body[data-theme="dark"] .reader-search-result-snippet {
  color: #dde5f0;
}
p {
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
  -ms-hyphens: auto;
}

.mobile-reader-settings {
  display: none;
  background: #fff;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}
.mobile-reader-settings.open {
  display: block;
}
.mobile-reader-settings-inner {
  padding: 0.75rem 1rem 1rem;
}
.mobile-reader-settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
@media (max-width: 767.98px) {
  .reader-topbar-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.5rem;
  }
  .reader-topbar-left {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    justify-content: flex-start;
  }
  .reader-topbar-center {
    text-align: center;
    min-width: 0;
  }
  .reader-topbar-center strong {
    display: block;
    font-size: 0.95rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .reader-topbar-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    width: auto;
  }
  .reader-topbar-right .reader-select {
    display: none;
  }
  /* #mobileReaderSettingsBtn { */
    /* display: inline-flex; */
    /* align-items: center; */
    /* justify-content: center; */
    /* min-width: 40px; */
    /* height: 36px; */
    /* padding: 0; */
    /* margin-left: 50; */
    /* white-space: nowrap; */
  /* } */
#mobileReaderSettingsBtn {
  min-width: 40px;
  height: 36px;
  width: 40px;
  padding: 0;
  font-weight: 600;
  margin-left: 50px;
}
  .reader-topbar .btn.btn-outline-secondary.btn-sm {
    padding: 0.35rem 0.65rem;
  }
}
.reader-app {
	display: flex;
	height: 100vh;
}
.reader-sidebar {
	width: 300px;
	background: #fcfbf7;
	overflow-y: auto;
	transition: margin-left 0.25s ease;
}
.reader-sidebar.collapsed {
	margin-left: -300px;
}
.reader-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.reader-topbar {
	background: #fff;
	position: sticky;
	top: 0;
	z-index: 10;
	box-shadow: 0 1px 0 rgba(0,0,0,0.06);
}
.reader-viewport {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}
.reader-pane {
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem 1rem 2rem;
  box-sizing: border-box;
}
#scrollReader .chapter-content {
	max-width: 900px;
	margin: 0 auto;
	background: #fffdf8;
	padding: 1rem;
	box-shadow: 0 0 20px rgba(0,0,0,0.06);
	border-radius: 10px;
}
#scrollReader h1, #scrollReader h2, #scrollReader h3 {
	font-family: Arial, Helvetica, sans-serif;
	margin-top: 1.75rem;
}
.toc-link {
	display: block;
	padding: 0.45rem 0.25rem;
	color: #333;
	text-decoration: none;
	border-radius: 6px;
}
.toc-link:hover, .toc-link.active {
	background: #e9ecef;
}
@media (max-width: 991px)
{
.reader-sidebar {
	position: fixed;
	top: 0;
	left: 0;
	bottom: 0;
	z-index: 999;
	box-shadow: 0 0 20px rgba(0,0,0,0.15);
}
}
.open-sidebar-btn {
	position: fixed;
	top: 90px;
	left: 12px;
	z-index: 1100;
	box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}
.chapter-content h1:first-child {
	font-size: 2.2rem;
	margin-top: 0;
	margin-bottom: 1.5rem;
	padding-bottom: 0.75rem;
	border-bottom: 1px solid #ddd;
	letter-spacing: 0.01em;
}
.chapter-opening {
/* min-height: 70vh; */
  	display: flex;
	flex-direction: column;
	justify-content: center;
	padding: 1rem 0 1rem;
}
.chapter-opening .chapter-label {
	font-family: Arial, Helvetica, sans-serif;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	font-size: 0.8rem;
	color: #777;
	margin-bottom: 1rem;
}
.chapter-opening .chapter-title {
	font-size: 2.6rem;
	line-height: 1.2;
	margin-bottom: 1rem;
}
.chapter-opening .chapter-subtitle {
	font-size: 1.15rem;
	color: #555;
	max-width: 42rem;
}
.reader-figure {
	margin: 2rem auto;
	text-align: center;
}
.reader-figure figcaption {
	margin-top: 0.75rem;
	font-size: 0.95rem;
	color: #666;
}
.footnote-ref {
	text-decoration: none;
	font-size: 0.8em;
	vertical-align: super;
}
.reader-loading #readerSidebar {
	transition: none !important;
}
.reader-loading #openSidebarBtn {
	transition: none !important;
}
.reader-topbar-row {
	display: grid;
	grid-template-columns: auto 1fr auto;
	align-items: center;
	gap: 1rem;
}
.reader-topbar-left, .reader-topbar-right {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}
.reader-topbar-center {
	text-align: center;
	min-width: 0;
}
.reader-topbar-center strong {
	display: block;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.reader-select {
	min-width: 140px;
	width: auto;
}
@media (max-width: 991px)
{
.reader-topbar-row {
	grid-template-columns: 1fr;
	align-items: stretch;
}
.reader-topbar-left, .reader-topbar-right, .reader-topbar-center {
	justify-content: center;
	text-align: center;
}
.reader-topbar-right {
	flex-wrap: wrap;
}
.reader-select {
	min-width: 120px;
}
}
.chapter-content {
	opacity: 1;
	transform: translateY(0);
	transition: opacity 0.28s ease, transform 0.28s ease;
}
.chapter-loading .chapter-content {
	opacity: 0;
	transform: translateY(10px);
}
/* #scrollReader .chapter-content h2, #scrollReader .chapter-content h3 { */
	/* scroll-margin-top: 110px; */
/* } */
#backToTopBtn {
	position: fixed;
	bottom: 24px;
	right: 24px;
	z-index: 1050;
	display: none;
	box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}
#scrollReader .chapter-content h2,
#scrollReader .chapter-content h3 {
  scroll-margin-top: 32px;
}
@media (max-width: 767.98px) {
  .reader-topbar .container-fluid {
    padding-top: 0.75rem !important;
    padding-bottom: 0.75rem !important;
  }
  .reader-topbar-row {
    gap: 0.5rem;
  }
  .reader-topbar-left {
    justify-content: center;
    gap: 0.5rem;
  }
  .reader-topbar-center strong {
    font-size: 1rem;
    line-height: 1.25;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
  }
  .reader-topbar-right {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
  }
  .reader-select {
    min-width: 0;
    width: 100%;
    font-size: 0.95rem;
  }
  #modeSelect {
    grid-column: 1 / -1;
    max-width: 240px;
    justify-self: center;
  }
  .reader-topbar .btn.btn-outline-secondary.btn-sm {
    padding: 0.4rem 0.75rem;
  }
  .progress {
    margin-top: 0.75rem !important;
  }
}
@media (max-width: 767.98px) {
  .open-sidebar-btn {
    top: 85px;
    left: 10px;
    padding: 0.45rem 0.65rem;
  }
}
.popover {
  max-width: 320px;
  font-family: Georgia, "Times New Roman", serif;
}
.footnote-pop {
  font-size: 0.95rem;
  line-height: 1.45;
}
.footnote-ref {
  cursor: pointer;
  font-weight: 600;
}

.chapter-sections {
  margin: 1.5rem 0 2rem;
  padding-left: 0;
  list-style: none;
}

.chapter-sections li {
  margin-bottom: 0.35rem;
}

.chapter-sections a {
  text-decoration: none;
  border-bottom: 1px dotted rgba(0,0,0,0.3);
}

.chapter-sections a:hover {
  border-bottom: 1px solid rgba(0,0,0,0.6);
}
.chapter-section-link {
  display: block;
  padding: 0.12rem 0;
  line-height: 1.5;
  color: #0d6efd;
  text-decoration: underline;
}

.chapter-section-link:hover {
  text-decoration: none;
}

#sectionContainer {
  margin: 1.25rem 0 2rem;
}

#sectionContainer .text-muted {
  margin-bottom: 0.5rem !important;
}

.reader-search-results {
  max-height: 320px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
}

.reader-search-result {
  display: block;
  padding: 0.65rem 0.75rem;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}

.reader-search-result:last-child {
  border-bottom: none;
}

.reader-search-result:hover {
  background: rgba(0,0,0,0.03);
}

.reader-search-result-title {
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 0.2rem;
}

.reader-search-result-section {
  font-size: 0.84rem;
  color: #666;
  margin-bottom: 0.2rem;
}

.reader-search-result-snippet {
  font-size: 0.83rem;
  color: #444;
  line-height: 1.35;
}

.reader-search-empty {
  padding: 0.75rem;
  font-size: 0.9rem;
  color: #666;
}