/* ==================== Cover Page ==================== */
.cover-page {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 830px;
}

.cover-toolbar {
  justify-content: flex-end;
  padding: 0 10px 12px;
}

.cover-toolbar select {
  padding: 4px 8px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 0.85rem;
  cursor: pointer;
}

.cover-image {
  width: 100%;
  height: 320px;
  margin-bottom: 60px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--color-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
}

.cover-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-image-placeholder {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.cover-title {
  font-family: var(--font-serif);
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 16px;
  color: var(--color-paper-text);
}

.cover-subtitle {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  color: var(--color-text-secondary);
  margin-bottom: 60px;
}

.cover-author {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  color: var(--color-text);
}

/* ==================== Cover Image Wrapper ==================== */
.cover-image-wrapper {
  width: 100%;
  margin-bottom: 40px;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-sidebar);
}

.cover-image-wrapper.small {
  height: 200px;
}

.cover-image-wrapper.medium {
  height: 320px;
}

.cover-image-wrapper.large {
  height: 450px;
}

.cover-image-wrapper.fullwidth {
  width: calc(100% + 180px);
  margin-left: -90px;
  margin-right: -90px;
  height: auto;
  min-height: 320px;
  border-radius: 0;
}

.cover-image-wrapper.fullwidth img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-image-wrapper.fullheight {
  height: 700px;
}

.cover-image-wrapper img {
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
}

.cover-image-fullwidth {
  width: 100%;
  height: auto;
  object-fit: cover;
}

.cover-image-fullheight {
  width: auto;
  height: 100%;
  max-height: 700px;
  object-fit: cover;
}

/* ==================== Copyright Page ==================== */
.copyright-page {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  line-height: 2;
}

.copyright-page h2 {
  font-size: 1.5rem;
  text-align: center;
  margin-bottom: 40px;
  font-weight: 600;
}

.copyright-info {
  margin-top: 200px 0;
}

.copyright-info p {
  margin-bottom: 8px 0;
}

.copyright-info .editable {
  display: inline-block;
  min-width: 200px;
  max-width: 250px;
  padding: 2px 4px;
}

.copyright-bottom {
  margin-top: 120px;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}

/* Remove header from toc and copyright */
.toc-page .paper-header,
.copyright-page .paper-header {
  display: none;
}

/* ==================== Title Page ==================== */
.title-page-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.title-page-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  padding: 8px 16px;
  background: var(--color-paper);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.title-page-toolbar .btn.btn-sm {
  padding: 6px 14px;
  font-size: 0.85rem;
  border-radius: 6px;
  background: var(--color-bg-sidebar);
  color: var(--color-text-secondary);
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.title-page-toolbar .btn.btn-sm.active {
  background: var(--color-primary);
  color: white;
}

.title-page-toolbar .btn.btn-sm:hover:not(.active) {
  background: var(--color-border-light);
}

/* Title page content */
.title-page .title-page-main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ==================== Title Page Horizontal ==================== */
.title-page-horizontal {
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 830px;
}

.title-page-horizontal .title-page-main {
  align-items: center;
  justify-content: flex-start;
  padding-top: 120px;
}

.title-page-horizontal .title-page-title {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  font-weight: 700;
  margin-bottom: 40px;
  text-align: center;
}

.title-page-horizontal .title-page-content {
  font-family: var(--font-serif) !important;
  font-size: 1.2rem !important;
  line-height: 2.2 !important;
  width: 100%;
  min-height: 300px;
}

.title-page-horizontal .title-page-content p {
  text-indent: 2em;
  margin-bottom: 0.8em;
}

.title-page-horizontal h1 {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 24px;
}

.title-page-horizontal .title-author {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: var(--color-text-secondary);
  margin-top: 60px;
}

.title-page-horizontal .title-page-content {
  direction: ltr;
}

/* ==================== Title Page Vertical ==================== */
.title-page-vertical {
  display: flex;
  flex-direction: row-reverse;
  justify-content: center;
  align-items: center;
  height: 100%;
  padding: 40px 50px;
  box-sizing: border-box;
  gap: 40px;
  overflow: hidden;
}

.title-page-vertical .title-page-title {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 700;
  writing-mode: vertical-rl;
  text-orientation: upright;
  letter-spacing: 0.5em;
  flex-shrink: 0;
  margin: 0;
  align-self: center;
  order: 1;
  max-height: 720px;
  overflow: hidden;
}

.title-page-vertical .title-page-content {
  font-family: var(--font-serif) !important;
  font-size: 1.2rem !important;
  line-height: 2.2;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  flex: 0 1 auto;
  max-height: 720px;
  min-height: 200px;
  align-self: center;
  order: 2;
  text-align: left;
  overflow: hidden;
}

.title-page-vertical .title-page-content p {
  margin-left: 1.5em;
  margin-bottom: 0;
  margin-top: 0;
}

/* ==================== Preface Page ==================== */
.preface-page-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preface-settings-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 8px 16px;
  background: var(--color-paper);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  font-size: 0.88rem;
}

.preface-settings-bar select {
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-sidebar);
  font-size: 0.85rem;
}

.preface-page h2 {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 40px;
}

.preface-page.preface-top-none {
  padding-top: 40px;
}

.preface-page.preface-top-third {
  padding-top: 280px;
}

.preface-page.preface-top-half {
  padding-top: 420px;
}

.preface-page .book-text p {
  text-indent: 2em;
}

/* ==================== TOC Page ==================== */
.toc-page-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.toc-settings-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 8px 16px;
  background: var(--color-paper);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  font-size: 0.88rem;
}

.toc-settings-bar select {
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-sidebar);
  font-size: 0.85rem;
}

.toc-page h2 {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 40px;
}

/* TOC top spacing */
.toc-page.toc-top-none {
  padding-top: 80px;
}

.toc-page.toc-top-third {
  padding-top: 280px;
}

.toc-page.toc-top-half {
  padding-top: 420px;
}

.toc-chapter {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 600;
  padding: 10px 0;
  padding-left: 0;
  border-bottom: 1px dashed var(--color-border-light);
  display: flex;
  justify-content: space-between;
}

.toc-section {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  padding: 6px 0 6px 48px !important;
  color: var(--color-text-secondary);
  display: flex;
  justify-content: space-between;
}

.toc-appendix-title {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--color-text-muted);
}

.toc-page-num {
  margin-left: auto;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.toc-chapter, .toc-section {
  cursor: pointer;
}

.toc-chapter:hover, .toc-section:hover {
  color: var(--color-primary);
}

/* TOC item styles */
.toc-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px dashed var(--color-border-light);
  cursor: pointer;
  transition: color 0.15s ease;
}

.toc-item:hover {
  color: var(--color-primary);
}

.toc-title {
  flex: 1;
}

.toc-page-number {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-left: 16px;
}

.toc-chapter .toc-title,
.toc-section .toc-title {
  margin-left: 0.5em;
}

/* ==================== Chapter Page ==================== */
.chapter-page {
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding-top: 280px;
  min-height: 830px;
  box-sizing: border-box;
}

.chapter-header {
  margin-bottom: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.chapter-number {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  color: var(--color-text-muted);
  margin-bottom: 25px;
  letter-spacing: 0.3em;
  opacity: 0.7;
  font-weight: 600;
}

.chapter-title {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  font-weight: 700;
  margin-bottom: 0;
  text-align: center;
  letter-spacing: 0.3em;
}

.chapter-title-line {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.5em;
  margin-bottom: 40px;
}

.chapter-title-line .chapter-num {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--color-text);
}

.chapter-title-line .chapter-name {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  font-weight: 700;
}

.chapter-summary {
  font-family: var(--font-kaiti);
  font-size: 1.3rem;
  color: var(--color-text-secondary);
  line-height: 1.9;
  max-width: 500px;
  margin: 0 auto;
  text-align: left;
  padding: 16px 24px;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  min-height: auto;
  height: auto;
  flex-shrink: 0;
}
/* 需求6：章摘要默认首行缩进（中文排版规范） */
.chapter-summary p,
.chapter-summary {
  text-indent: 2em;
}
/* 续段不缩进（跨段连续时第二行起回到正常） */
.chapter-summary p:not(:first-child) {
  text-indent: 2em;
  font-size: inherit !important;
}
.chapter-summary p:first-child {
  font-size: inherit !important;
}



/* ==================== Section Page ==================== */
.section-page {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 2;
  display: flex;
  flex-direction: column;
  min-height: 830px;
  box-sizing: border-box;
}

.section-page .section-abstract {
  flex-shrink: 0;
}

.section-page .book-text {
  flex: 1;
  min-height: 200px;
  position: relative;
}

.section-page .book-text.overflow {
  overflow: visible;
}

.section-title {
  font-family: 'HYLongSong', '汉仪长宋简', 'Noto Serif SC', 'SimSun', serif;
  font-size: 1.8rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 30px;
}

.section-title-line {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.5em;
  margin-bottom: 30px;
}

.section-title-line .section-num {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--color-text);
}

.section-title-line .section-name {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  font-weight: 700;
}

.section-abstract {
  font-family: var(--font-kaiti);
  font-size: 1.3rem;
  color: var(--color-text-secondary);
  padding: 16px 24px;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  margin: 0 1em;
  margin-bottom: 30px;
  line-height: 1.9;
}



/* ==================== Appendix Page ==================== */
.appendix-page {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 2;
}

.appendix-title {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 30px;
}

/* ==================== Fixed Font for Title, Preface, Chapter, Section ==================== */
.title-page-content,
.preface-page .book-text p,
.chapter-page .book-text p,
.section-page .book-text p {
  font-family: var(--font-serif) !important;
  font-size: 1.3rem !important;
}
