#preview-view {
  display: none;
  flex: 1;
  overflow: hidden;
  background: #f4f1eb;
  position: relative;
  transition: padding-right 0.25s;
}

#preview-view.active {
  display: flex;
  flex-direction: column;
}

#pv-content {
  flex: 1;
  overflow-y: auto;
  padding: 6px 60px 60px 60px;
  transition: padding-right 0.25s;
  --font-scale: 1;
}

#preview-view.nav-open #pv-content {
  padding-right: 260px;
}

.pv-cover {
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 12px;
  position: relative;
}

#pv-content > div {
  direction: rtl;
}

#pv-content mark.sh {
  background: rgba(196, 149, 74, 0.3);
  border-radius: 2px;
  padding: 0 1px;
}

#pv-nav-wrap {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 15;
  pointer-events: none;
}

#pv-nav-wrap.nav-open {
  pointer-events: auto;
}

#pv-nav {
  width: 200px;
  max-height: calc(100vh - 32px);
  background: #fff;
  border: 1px solid #e0ddd6;
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.07);
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

#pv-nav.closed {
  transform: translateX(240px);
  pointer-events: none;
}

#pv-nav-toggle {
  position: fixed;
  top: 36px;
  right: 216px;
  width: 20px;
  height: 40px;
  background: #fff;
  border: 1px solid #ddd;
  border-right: none;
  border-radius: 8px 0 0 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #666;
  z-index: 21;
  pointer-events: auto;
  transition: right 0.25s ease;
}

#pv-nav-toggle:hover {
  color: #c4954a;
}

#pv-nav-toggle.closed {
  right: 0;
  border: 1px solid #ddd;
  border-right: none;
  border-radius: 8px 0 0 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

#pv-nav-inner {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  direction: rtl;
  scrollbar-width: none;
}
#pv-nav-inner::-webkit-scrollbar {
  display: none;
}

#pv-nav-title {
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #b5b0a5;
  margin-bottom: 8px;
  font-family: 'IBM Plex Mono', monospace;
  direction: ltr;
}

.toc-section {
  margin-bottom: 4px;
}

.toc-section.collapsed > div:not(.toc-sep) {
  display: none;
}

.toc-sep {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 10px;
  margin: 3px 0;
  cursor: pointer;
  position: relative;
  user-select: none;
}

.toc-sep::before {
  content: '';
  position: absolute;
  left: 4px;
  right: 4px;
  top: 50%;
  height: 1px;
  background: #e0ddd6;
}

.toc-sep-arrow {
  position: relative;
  z-index: 1;
  font-size: 7px;
  color: #bbb;
  background: #fff;
  padding: 0 6px;
  transition: transform 0.15s;
}

.toc-s1, .toc-s2, .toc-s3 {
  padding: 4px 6px;
  border-radius: 3px;
  cursor: pointer;
  font-family: 'Amiri', serif;
  color: #6a6560;
  direction: rtl;
  text-align: right;
  line-height: 1.5;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
  font-size: 13px;
}

.toc-s1:hover, .toc-s2:hover, .toc-s3:hover {
  background: #f4f1eb;
  color: #3a3530;
}

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

.toc-s2 {
  border: 1px solid #e8e4dd;
  background: #faf8f4;
  border-radius: 10px;
}

.toc-s3 {
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: #ddd;
}

.toc-s1.active, .toc-s2.active, .toc-s3.active {
  background: var(--accentbg);
  border-color: var(--accent);
  color: var(--accent);
}

.toc-cover {
  padding: 6px 8px;
  font-size: 11px;
  color: #888;
  cursor: pointer;
  border-radius: 4px;
  margin-bottom: 2px;
}

.toc-cover:hover {
  background: #f4f1eb;
}

.toc-cover.active {
  color: var(--accent);
  font-weight: 600;
}

.toc-other {
  padding: 3px 6px;
  font-size: 11px;
  color: #999;
  cursor: pointer;
  border-radius: 3px;
}

.toc-other:hover {
  background: #f4f1eb;
}

.toc-search-hidden {
  display: none !important;
}

@media (max-width: 768px) {
  #pv-content {
    padding: 24px 24px 60px 24px;
  }
  #preview-view.nav-open #pv-content {
    padding-right: 24px;
  }
}

.pv-page {
  width: 100%;
  min-height: 400px;
}

.pv-page > div {
  direction: rtl;
}

.pv-break {
  text-align: center;
  color: var(--text3);
  font-size: 11px;
  padding: 8px 0;
  font-family: 'Amiri', serif;
}
