:root {
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --text: #172033;
  --muted: #697386;
  --line: #d8deea;
  --primary: #172033;
  --primary-2: #283651;
  --accent: #af7217;
  --danger: #b42318;

  --a4-width: 210mm;
  --a4-height: 297mm;
  --page-padding-top: 82px;
  --page-padding-x: 78px;
  --page-padding-bottom: 74px;

  --title-font: "Montserrat", Arial, sans-serif;
  --subtitle-font: "Cinzel", Georgia, serif;
  --body-font: "Inter", Arial, sans-serif;
  --title-size: 30px;
  --subtitle-size: 25px;
  --body-size: 20px;
  --body-line-height: 1.4;
  --title-color: #111827;
  --subtitle-color: #111827;
  --body-color: #111827;
  --title-align: center;
  --subtitle-align: center;
  --body-align: justify;
  --title-weight: 800;
  --subtitle-weight: 400;
  --body-weight: 400;
  --title-style: normal;
  --subtitle-style: normal;
  --body-style: normal;
  --title-decoration: none;
  --subtitle-decoration: none;
  --body-decoration: none;
  --content-bg-color: #ffffff;
  --content-bg-image: none;
  --content-bg-opacity: .18;
  --quote-text-color: #344054;
  --quote-border-color: #af7217;
  --quote-background-color: #fff8ef;
  --toc-title-color: #111827;
  --toc-item-color: #111827;
  --toc-title-size: 34px;
  --toc-item-size: 20px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: "Inter", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 20px;
  color: #fff;
  background: linear-gradient(135deg, #111827, #1f2937);
  border-bottom: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 12px 30px rgba(17, 24, 39, .18);
}

.app-topbar strong {
  display: block;
  font-family: "Montserrat", Arial, sans-serif;
  font-size: 16px;
  letter-spacing: -.02em;
}

.app-topbar span {
  display: block;
  margin-top: 2px;
  color: rgba(255,255,255,.72);
  font-size: 12px;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.workspace {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  min-height: calc(100vh - 66px);
}

.sidebar {
  height: calc(100vh - 66px);
  overflow: auto;
  padding: 18px;
  background: #e8edf5;
  border-right: 1px solid var(--line);
}

.panel {
  padding: 16px;
  margin-bottom: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 12px 35px rgba(15, 23, 42, .06);
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -.01em;
  color: #111827;
}

label {
  display: block;
  margin-bottom: 12px;
  font-size: 12px;
  font-weight: 700;
  color: #344054;
}

input,
select {
  width: 100%;
  height: 40px;
  margin-top: 6px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  outline: none;
}

input:focus,
select:focus,
.rich-editor:focus {
  border-color: #6b7280;
  box-shadow: 0 0 0 4px rgba(107, 114, 128, .12);
}

.btn {
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn.primary {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 10px 18px rgba(17, 24, 39, .18);
}

.btn.secondary {
  color: #172033;
  background: #fff;
  border: 1px solid #d5dbe7;
}

.btn.danger {
  color: #fff;
  background: var(--danger);
}

.btn.full {
  width: 100%;
}

.chapter-list {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.chapter-item {
  display: block;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid #dce3ee;
  border-radius: 12px;
  cursor: pointer;
}

.chapter-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(175, 114, 23, .12);
}

.type-settings {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.type-settings fieldset {
  min-width: 0;
  padding: 12px;
  border: 1px solid #dce3ee;
  border-radius: 12px;
}

.type-settings legend {
  padding: 0 6px;
  font-size: 12px;
  font-weight: 800;
}

.control-grid {
  display: grid;
  gap: 8px;
}

.control-grid.three {
  grid-template-columns: .72fr .62fr 1.4fr;
}

.control-grid label {
  min-width: 0;
  margin-bottom: 0;
}

input[type="color"] {
  padding: 4px;
}

input[type="range"] {
  height: auto;
  padding: 0;
}

.style-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.style-toggles button {
  min-height: 30px;
  padding: 0 8px;
  color: #344054;
  background: #fff;
  border: 1px solid #d5dbe7;
  border-radius: 8px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}

.style-toggles button.active {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.panel-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.index-settings {
  display: grid;
  gap: 8px;
}

.index-settings > [data-section-target="index"] {
  width: 100%;
}

.index-color-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px;
  background: #f7f9fc;
  border: 1px solid #dce3ee;
  border-radius: 10px;
}

.index-color-controls label {
  margin: 0;
  color: #475467;
  font-size: 10px;
  font-weight: 800;
}

.index-color-controls input[type="color"] {
  width: 100%;
  height: 34px;
  margin-top: 5px;
}

.index-color-controls input[type="number"] {
  width: 100%;
  height: 34px;
  margin-top: 5px;
}

.section-cover-panel {
  padding: 12px;
  margin: 2px 0 12px;
  background: #f7f9fc;
  border: 1px solid #dce3ee;
  border-radius: 12px;
}

.cover-status {
  margin: -3px 0 9px;
  color: var(--muted);
  font-size: 11px;
}

.chapter-name-editor {
  display: block;
  margin-bottom: 12px;
}

.chapter-name-label {
  display: block;
  margin-bottom: 4px;
  color: #172033;
  font-size: 11px;
  font-weight: 800;
}

.chapter-name-input {
  height: 36px;
  margin-top: 0;
  padding: 0 9px;
  font-size: 13px;
  font-weight: 800;
}

.chapter-details {
  min-width: 0;
}

.chapter-cover-label {
  margin: 0;
  color: #475467;
  font-size: 11px;
  font-weight: 700;
}

.chapter-cover-label input[type="file"] {
  display: block;
  width: 100%;
  height: 34px;
  margin-top: 4px;
  padding: 4px 6px;
  font-size: 10px;
}

.chapter-cover-state {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

.chapter-cover-state.configured {
  color: #16794a;
}

.chapter-typography {
  padding: 12px;
  margin-top: 12px;
  background: #fff;
  border-top: 1px solid #dce3ee;
  border: 1px solid #dce3ee;
  border-radius: 10px;
}

.current-typography-panel {
  margin: 2px 0 12px;
}

.current-typography-panel .chapter-typography {
  margin-top: 0;
  background: #f7f9fc;
  border-color: #dce3ee;
}

.chapter-typography-title {
  margin-bottom: 10px;
  color: #344054;
  font-size: 11px;
  font-weight: 800;
}

.typography-selection-hint {
  margin: -4px 0 9px;
  color: #667085;
  font-size: 9px;
  line-height: 1.35;
}

.chapter-type-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.chapter-type-fields label:first-child {
  grid-column: 1 / -1;
}

.chapter-type-fields label {
  min-width: 0;
  margin: 0;
  color: #475467;
  font-size: 11px;
}

.chapter-type-fields .typography-field {
  min-width: 0;
  color: #475467;
  font-size: 11px;
}

.typography-field-label {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
}

.chapter-type-fields input,
.chapter-type-fields select {
  height: 36px;
  padding: 0 8px;
  font-size: 11px;
}

.chapter-type-fields input[type="color"] {
  padding: 3px;
}

.text-hierarchy-controls {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #dce3ee;
}

.text-hierarchy-title,
.text-hierarchy-subtitle {
  color: #344054;
  font-size: 10px;
  font-weight: 800;
}

.text-hierarchy-hint {
  margin: 4px 0 10px;
  color: #667085;
  font-size: 9px;
  line-height: 1.35;
}

.text-hierarchy-group + .text-hierarchy-group {
  margin-top: 10px;
}

.text-hierarchy-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-top: 5px;
}

.text-hierarchy-fields label:first-child {
  grid-column: 1 / -1;
}

.text-hierarchy-style-field,
.hierarchy-color-field {
  grid-column: 1 / -1;
}

.text-hierarchy-fields label {
  min-width: 0;
  margin: 0;
  color: #475467;
  font-size: 10px;
}

.text-hierarchy-fields input,
.text-hierarchy-fields select {
  height: 34px;
  padding: 0 7px;
  font-size: 10px;
}

.quote-style-controls {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #dce3ee;
}

.quote-style-title,
.quote-style-subtitle {
  color: #344054;
  font-size: 10px;
  font-weight: 800;
}

.quote-style-subtitle {
  margin: 10px 0 6px;
  color: #475467;
  font-size: 9px;
}

.quote-style-hint,
.quote-exception-status {
  margin-top: 4px;
  color: #667085;
  font-size: 9px;
  line-height: 1.35;
}

.quote-color-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.quote-color-field {
  min-width: 0;
  margin: 0;
  color: #475467;
  font-size: 9px;
  font-weight: 700;
}

.quote-color-field input[type="color"] {
  display: block;
  width: 100%;
  height: 34px;
  margin-top: 4px;
  padding: 3px;
}

.color-hex-input {
  width: 100%;
  height: 30px;
  margin-top: 4px;
  padding: 0 6px;
  color: #172033;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 10px;
  text-transform: uppercase;
}

.color-hex-input:focus {
  border-color: var(--primary);
  outline: 2px solid rgba(21, 89, 166, .14);
}

.color-hex-input[aria-invalid="true"] {
  border-color: #b42318;
}

.quote-color-field input:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.quote-exception-reset {
  width: 100%;
  min-height: 32px;
  margin-top: 8px;
  color: #344054;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  cursor: pointer;
  font-size: 9px;
  font-weight: 800;
}

.quote-exception-reset:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.typography-color-control {
  position: relative;
}

.typography-color-control .color-hex-input {
  height: 28px;
}

.typography-color-button {
  display: flex;
  width: 100%;
  height: 36px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 7px;
  color: #344054;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  cursor: pointer;
  font-size: 9px;
  font-weight: 700;
}

.typography-color-button:hover {
  border-color: var(--primary);
}

.typography-color-swatch {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  background: var(--typography-selected-color, #111827);
  border: 1px solid rgba(15, 23, 42, .28);
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .32);
}

.typography-color-picker {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 1px !important;
  height: 1px !important;
  margin: 0 !important;
  padding: 0 !important;
  opacity: 0;
  pointer-events: none;
}

.chapter-typography.showing-selection-format {
  border-color: #91a7c5;
  box-shadow: 0 0 0 2px rgba(46, 76, 115, .08);
}

.chapter-type-toggles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.chapter-type-toggles button {
  min-height: 32px;
  padding: 0 5px;
  color: #344054;
  background: #fff;
  border: 1px solid #d5dbe7;
  border-radius: 7px;
  cursor: pointer;
  font-size: 9px;
  font-weight: 700;
}

.chapter-type-toggles button.active {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.section-shortcuts {
  display: grid;
  gap: 8px;
}

.section-shortcuts > button,
.index-settings > [data-section-target="index"],
.section-shortcut-row > [data-section-target],
.section-config-card > button {
  width: 100%;
  min-height: 38px;
  padding: 0 11px;
  color: #344054;
  text-align: left;
  background: #f7f9fc;
  border: 1px solid #dce3ee;
  border-radius: 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.section-shortcuts > button.active,
.index-settings > [data-section-target="index"].active,
.section-shortcut-row > [data-section-target].active,
.section-config-card > button.active {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.section-shortcut-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.section-shortcut-row > [data-section-target] {
  min-width: 0;
}

.section-visibility-button {
  min-width: 78px;
  padding: 0 8px;
  color: #475467;
  background: #fff;
  border: 1px solid #d5dbe7;
  border-radius: 10px;
  cursor: pointer;
  font-size: 10px;
  font-weight: 800;
}

.section-visibility-button.section-hidden {
  color: #fff;
  background: #8b2f27;
  border-color: #8b2f27;
}

.section-shortcut-row.section-is-hidden > [data-section-target] {
  color: #7b8494;
  text-decoration: line-through;
}

.section-config-card {
  padding: 0;
  overflow: hidden;
  background: #f7f9fc;
  border: 1px solid #dce3ee;
  border-radius: 12px;
}

.section-config-card > .structure-config-panel {
  display: none;
  margin: 0 10px 10px;
}

.section-config-card.active > .structure-config-panel {
  display: grid;
}

.section-config-card > button {
  border: 0;
  border-radius: 0;
}

.section-config-card > .chapter-typography {
  display: none;
  margin: 0 10px 10px;
}

.section-config-card.active > .chapter-typography {
  display: block;
}

.chapter-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding-top: 10px;
  margin-top: 12px;
  border-top: 1px solid #dce3ee;
}

.chapter-actions-label {
  margin-right: auto;
  color: #697386;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.chapter-actions button {
  min-width: 30px;
  height: 30px;
  border: 1px solid #d5dbe7;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  margin: 8px 0 10px;
  background: var(--surface-2);
  border: 1px solid #dce3ee;
  border-radius: 12px;
}

.toolbar button {
  height: 30px;
  padding: 0 9px;
  border: 1px solid #d5dbe7;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.toolbar button.active {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.rich-editor a,
.page-content a {
  color: #1559a6;
  text-decoration: underline;
  text-underline-offset: 2px;
}

#btnDeletePage {
  color: #8b2f27;
  border-color: #e8b9b4;
}

.rich-editor {
  min-height: 320px;
  padding: 18px;
  overflow: auto;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  line-height: var(--body-line-height);
  text-align: var(--body-align);
  -webkit-hyphens: auto;
  hyphens: auto;
  hyphenate-limit-chars: 6 3 3;
  overflow-wrap: normal;
  word-break: normal;
  outline: none;
}

.rich-editor.dark-editing-surface {
  background: #111827;
  border-color: #475569;
}

.rich-editor [data-selected-alignment="true"],
.page [data-selected-alignment="true"] {
  display: block;
  width: 100%;
}

.rich-editor [data-selected-alignment="true"] + br,
.page [data-selected-alignment="true"] + br {
  display: none;
}

::highlight(persistent-editor-selection) {
  color: inherit;
  background: rgba(84, 146, 230, .38);
}

.rich-editor h1,
.rich-editor h2,
.rich-editor h3 {
  margin-top: 0;
}

.rich-editor h1 {
  font-family: var(--title-font);
  color: var(--title-color);
  font-size: var(--title-size);
  font-style: var(--title-style);
  font-weight: var(--title-weight);
  line-height: 1.16;
  letter-spacing: -.04em;
  text-align: var(--title-align);
  text-decoration: var(--title-decoration);
}

.rich-editor h2,
.rich-editor h3 {
  font-family: var(--subtitle-font);
  color: var(--subtitle-color);
  font-size: var(--subtitle-size);
  font-style: var(--subtitle-style);
  font-weight: var(--subtitle-weight);
  line-height: 1.28;
  letter-spacing: .02em;
  text-align: var(--subtitle-align);
  text-decoration: var(--subtitle-decoration);
}

.rich-editor [data-pasted-structure="true"]:not(h1):not(h2):not(h3):not(blockquote),
.page [data-pasted-structure="true"]:not(h1):not(h2):not(h3):not(blockquote) {
  font-family: var(--body-font);
  font-size: var(--body-size);
  line-height: var(--body-line-height);
}

.content-page .page-content h1,
.content-page .page-content h2,
.content-page .page-content h3 {
  line-height: var(--body-line-height);
}

.rich-editor p,
.page p {
  margin: 0;
}

.rich-editor blockquote {
  margin: 18px 0;
  padding: 12px 18px;
  color: var(--quote-text-color);
  border-left: 4px solid var(--quote-border-color);
  background: var(--quote-background-color);
  font-family: "Inter", Arial, sans-serif;
  font-size: 20px;
  font-style: italic;
  font-weight: 700;
}

.rich-editor [data-page-break="true"] {
  position: relative;
  height: 24px;
  margin: 18px 0;
  border-top: 2px dashed #af7217;
  user-select: none;
}

.rich-editor [data-page-break="true"] span {
  position: absolute;
  top: -10px;
  left: 50%;
  padding: 1px 8px;
  color: #80520f;
  background: #fff;
  font-size: 10px;
  font-weight: 800;
  transform: translateX(-50%);
}

.content-page[data-source-key] .page-content {
  cursor: text;
  outline: none;
  background-color: transparent;
  box-shadow: none;
}

.content-page[data-source-key] .page-content:hover,
.content-page[data-source-key].preview-source-active .page-content,
.content-page[data-source-key] .page-content:focus {
  background-color: transparent;
  box-shadow: none;
}

.hidden {
  display: none !important;
}

.preview-area {
  min-width: 0;
  height: calc(100vh - 66px);
  overflow: auto;
  padding: 24px 28px 80px;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  max-width: var(--a4-width);
  margin: 0 auto 20px;
}

.preview-header h1 {
  margin: 0 0 3px;
  font-family: "Montserrat", Arial, sans-serif;
  font-size: 22px;
  letter-spacing: -.03em;
}

.preview-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.preview-hint {
  align-self: center;
  padding: 8px 12px;
  color: #533a13;
  background: #fff4dc;
  border: 1px solid #f2d79b;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.book-preview {
  display: grid;
  gap: 26px;
  justify-content: center;
}

.page {
  position: relative;
  width: var(--a4-width);
  min-height: var(--a4-height);
  overflow: hidden;
  background: #fff;
  box-shadow: 0 18px 55px rgba(15, 23, 42, .22);
  color: #111827;
}

.content-page {
  background: var(--content-bg-color);
  box-shadow: none;
}

.content-background {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image: var(--content-bg-image);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  opacity: var(--content-bg-opacity);
  pointer-events: none;
}

.page-content {
  position: relative;
  z-index: 1;
  padding: var(--page-padding-top) var(--page-padding-x) var(--page-padding-bottom);
  height: var(--a4-height);
  overflow: hidden;
  font-family: var(--body-font);
  color: var(--body-color);
  font-size: var(--body-size);
  font-style: var(--body-style);
  font-weight: var(--body-weight);
  line-height: var(--body-line-height);
  text-align: var(--body-align);
  text-decoration: var(--body-decoration);
  -webkit-hyphens: auto;
  hyphens: auto;
  hyphenate-limit-chars: 6 3 3;
  overflow-wrap: normal;
  word-break: normal;
}

.content-page:not(.toc-page) .page-content h1 {
  margin: 0 0 26px;
  font-family: var(--title-font);
  color: var(--title-color);
  font-size: var(--title-size);
  font-style: var(--title-style);
  font-weight: var(--title-weight);
  line-height: 1.16;
  letter-spacing: -.04em;
  text-align: var(--title-align);
  text-decoration: var(--title-decoration);
}

.content-page:not(.toc-page) .page-content h2 {
  margin: 28px 0 14px;
  font-family: var(--subtitle-font);
  color: var(--subtitle-color);
  font-size: var(--subtitle-size);
  font-style: var(--subtitle-style);
  font-weight: var(--subtitle-weight);
  line-height: 1.28;
  letter-spacing: .02em;
  text-align: var(--subtitle-align);
  text-decoration: var(--subtitle-decoration);
}

.content-page:not(.toc-page) .page-content h3 {
  color: var(--subtitle-color);
  font-family: var(--subtitle-font);
  font-size: var(--subtitle-size);
  font-style: var(--subtitle-style);
  font-weight: var(--subtitle-weight);
  text-align: var(--subtitle-align);
  text-decoration: var(--subtitle-decoration);
}

.page img,
.page svg,
.page video {
  display: block;
  max-width: 100%;
  max-height: calc(var(--a4-height) - var(--page-padding-top) - var(--page-padding-bottom));
  object-fit: contain;
}

.page .force-fit {
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
}

.page ul,
.page ol {
  margin-top: 0;
  margin-bottom: 16px;
  padding-left: 24px;
}

.page blockquote {
  margin: 20px 0;
  padding: 12px 18px;
  color: var(--quote-text-color);
  border-left: 4px solid var(--quote-border-color);
  background: var(--quote-background-color);
  font-family: "Inter", Arial, sans-serif;
  font-size: 20px;
  font-style: italic;
  font-weight: 700;
}

.page-number {
  position: absolute;
  right: 78px;
  bottom: 38px;
  z-index: 3;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
}

.cover-page {
  background: linear-gradient(145deg, #111827, #26364f);
  color: #fff;
}

.section-cover-page {
  color: #fff;
  background: #111827;
}

.section-cover-art {
  position: absolute;
  inset: 0;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

.section-cover-shade {
  display: none;
}

.section-cover-inner {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  height: var(--a4-height);
  padding: 86px 78px;
}

.section-cover-page .section-cover-title {
  max-width: 100%;
  margin: 0;
  color: #fff;
  font-family: var(--title-font);
  font-size: var(--title-size);
  font-style: var(--title-style);
  font-weight: var(--title-weight);
  line-height: 1.12;
  overflow-wrap: anywhere;
  text-align: var(--title-align);
  text-decoration: var(--title-decoration);
  text-shadow: none;
}

.cover-bg {
  position: absolute;
  inset: 0;
  background-position: center;
  background-size: cover;
  opacity: 1;
}

.cover-page::after {
  display: none;
}

.section-cover-panel .visibility-toggle {
  margin-bottom: 8px;
}

.cover-inner {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: var(--a4-height);
  padding: 96px;
  text-align: center;
}

.cover-kicker {
  margin-bottom: 26px;
  font-family: var(--subtitle-font);
  font-size: 16px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #f4c477;
}

.cover-page .cover-title {
  margin: 0;
  font-family: var(--title-font);
  font-size: 58px;
  line-height: 1.05;
  letter-spacing: -.06em;
  color: #fff !important;
  font-style: normal;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

.cover-page .cover-subtitle {
  max-width: 520px;
  margin: 28px auto 0;
  font-family: var(--subtitle-font);
  font-size: 24px;
  line-height: 1.35;
  color: rgba(255,255,255,.88);
  font-style: normal;
  font-weight: 400;
  text-align: center;
  text-decoration: none;
}

.cover-author {
  margin-top: 92px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255,255,255,.78);
}

.toc-title {
  margin-bottom: 34px !important;
  color: var(--toc-title-color) !important;
  font-size: var(--toc-title-size) !important;
}

.toc-list {
  display: grid;
  gap: 13px;
  margin-top: 20px;
}

.toc-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: end;
  color: var(--toc-item-color);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-size: var(--toc-item-size);
  line-height: 1.4;
}

.toc-page .toc-item,
.toc-page .toc-item:link,
.toc-page .toc-item:visited {
  color: var(--toc-item-color);
}

.toc-item:hover .toc-text,
.toc-item:focus .toc-text {
  color: var(--toc-item-color);
  text-decoration: underline;
}

.toc-text {
  font-weight: 700;
}

.toc-dots {
  min-width: 60px;
  height: 1px;
  margin-bottom: 5px;
  border-bottom: 1px dotted var(--toc-item-color);
}

.toc-page {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.pdf-destination {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.back-cover h1 {
  font-size: 38px;
}

.back-cover-footer {
  position: absolute;
  right: 78px;
  bottom: 54px;
  left: 78px;
  z-index: 4;
  color: var(--body-color);
  font-family: var(--body-font);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  text-align: center;
}

.pagination-host {
  position: fixed;
  left: -100000px;
  top: 0;
  width: var(--a4-width);
  visibility: hidden;
  pointer-events: none;
}

.empty-note {
  color: #64748b;
  font-style: italic;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 340px minmax(0, 1fr);
  }

  .preview-area {
    padding-left: 18px;
    padding-right: 18px;
  }

  .book-preview {
    transform: scale(.86);
    transform-origin: top center;
    margin-bottom: -150px;
  }

  .preview-header {
    max-width: 680px;
  }
}

@media (max-width: 900px) {
  .app-topbar,
  .preview-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace {
    display: block;
  }

  .sidebar,
  .preview-area {
    height: auto;
  }

  .book-preview {
    transform: scale(.58);
    transform-origin: top center;
    margin-bottom: -450px;
  }
}

@media print {
  @page {
    size: A4;
    margin: 0;
  }

  html,
  body {
    width: 210mm;
    min-width: 210mm;
    margin: 0 !important;
    padding: 0 !important;
    background: white !important;
  }

  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .app-topbar,
  .sidebar,
  .preview-header {
    display: none !important;
  }

  .workspace {
    display: block !important;
    min-height: 0 !important;
    height: auto !important;
  }

  .preview-area {
    height: auto !important;
    overflow: visible !important;
    padding: 0 !important;
  }

  #bookPreview {
    display: block !important;
    position: absolute;
    inset: 0 auto auto 0;
    width: 210mm !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: none !important;
  }

  .page {
    width: 210mm !important;
    height: 297mm !important;
    min-height: 297mm !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: none !important;
    box-shadow: none !important;
    break-after: page;
    page-break-after: always;
  }

  .page:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  .page-content,
  .cover-inner {
    height: 297mm;
  }

  .book-preview {
    gap: 0 !important;
    margin: 0 !important;
    transform: none !important;
    transform-origin: top left !important;
  }

  .cover-bg,
  .section-cover-art {
    width: 210mm !important;
    height: 297mm !important;
    background-size: cover !important;
  }

  .content-page[data-source-key] .page-content,
  .content-page[data-source-key].preview-source-active .page-content,
  .content-page[data-source-key] .page-content:focus {
    background-color: transparent !important;
    box-shadow: none !important;
  }

  .toc-item {
    pointer-events: auto !important;
  }
}
