/* =========================
   TOP BAR
========================= */
.reader-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
  background: rgba(250, 250, 250, 0.92);
  border-bottom: 1px solid #e8e8e8;
}

.reader-topbar-inner {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
}

.reader-left { display:flex; align-items:center; gap:10px; min-width: 220px; }
.reader-brand { text-decoration:none; font-weight:700; }
.reader-sep { opacity: .5; }
.reader-booktitle { font-weight:600; opacity:.85; }

.reader-mid {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  flex: 1;
}

.reader-search {
  display: flex;
  gap: 8px;
  align-items: center;
}

.reader-search input {
  width: min(420px, 45vw);
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 10px;
}

.reader-search button {
  padding: 8px 12px;
  border: 1px solid #ddd;
  background: white;
  border-radius: 10px;
  cursor: pointer;
}

.reader-chapterpicker select {
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 10px;
  max-width: min(420px, 35vw);
}

.reader-search-all {
  text-decoration: none;
  font-size: 13px;
  opacity: .75;
  border: 1px solid #ddd;
  padding: 7px 10px;
  border-radius: 10px;
  background: white;
}

.reader-right { display:flex; gap:10px; align-items:center; min-width: 220px; justify-content:flex-end; }

.reader-navbtn {
  text-decoration: none;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 10px;
  background: white;
}

.reader-navbtn.disabled {
  opacity: .35;
  pointer-events: none;
}


/* =========================
   LAYOUT (FIXED VIEWPORT)
========================= */
.reader-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;

  height: calc(100vh - 60px); /* tilpass toppbar */
  overflow: hidden;
}


/* =========================
   SIDEBAR
========================= */
.reader-toc {
  position: sticky;
  top: 0;
  height: 100%;
  overflow-y: auto;

  padding: 16px;
  border: 1px solid #eee;
  border-radius: 12px;
  background: #fff;
}

.book-title { font-weight: 700; margin-bottom: 12px; }

.toc-group { margin-bottom: 6px; }

.toc-item {
  display:block;
  padding:8px 10px;
  border-radius:10px;
  color: inherit;
  text-decoration:none;
  transition: background-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.toc-item:hover {
  background: #f3f4f6;
}

.toc-item.active {
  background: #f3f4f6;
  font-weight: 600;
}

.toc-item.is-current {
  background: #eef4ff;
  color: #1e3a8a;
  border-left: 3px solid #4f46e5;
  #padding-left: calc(10px - 3px);
  #font-weight: 700;
}

.toc-level-2.is-current,
.toc-level-3.is-current {
  #font-weight: 700;
  opacity: 1;
}

.toc-level-1 { font-weight: 700; }

.toc-level-2 {
  padding-left: 18px;
  font-size: 14px;
  opacity: .92;
}

.toc-level-3 {
  padding-left: 34px;
  font-size: 13px;
  opacity: .78;
}

.toc-number {
  font-weight: 600;
  opacity: .85;
  margin-right: 6px;
}

.toc-text {
  opacity: .95;
}


/* =========================
   READER PANEL
========================= */
.reader-page {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;

  border: 1px solid #eee;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(0,0,0,0.04);
}


/* HEADER (STICKY INSIDE PANEL) */
.reader-header {
  flex: 0 0 auto;

  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 16px;

  padding: 16px 20px;
  border-bottom: 1px solid #eee;

  position: sticky;
  top: 0;
  background: #fff;
  z-index: 5;
}

.chapter-title {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
}

.reader-nav { display:flex; gap: 10px; }

.btn {
  display:inline-block;
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  text-decoration:none;
  color: inherit;
  background: #fff;
}

.btn.disabled {
  opacity: .4;
  pointer-events: none;
}


/* =========================
   SCROLLABLE CONTENT
========================= */
.chapter-content {
  flex: 1;
  overflow-y: auto;

  padding: 24px;
  scroll-behavior: smooth;
}

.chapter-content p {
  line-height: 1.7;
  font-size: 18px;
  margin: 0 0 14px;
}


/* =========================
   HEADINGS
========================= */
.reader-h2 {
  margin-top: 28px;
  margin-bottom: 10px;
  font-size: 24px;
}

.reader-h3 {
  margin-top: 22px;
  margin-bottom: 8px;
  font-size: 20px;
}

.reader-h4 {
  margin-top: 18px;
  margin-bottom: 8px;
  font-size: 18px;
}

/* viktig for anchor scroll */
.reader-h2,
.reader-h3,
.reader-h4 {
  scroll-margin-top: 16px;
}


/* =========================
   CONTENT BLOCKS
========================= */
.blk[dir="rtl"] {
  direction: rtl;
  text-align: right;
  font-size: 20px;
  line-height: 1.9;
}

.tbl-wrap {
  overflow-x: auto;
  margin: 14px 0 18px;
}

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
}

.tbl td {
  border: 1px solid #e6e6e6;
  padding: 10px;
}

.img {
  margin: 18px 0;
}

.img img {
  max-width: 100%;
  border-radius: 14px;
  border: 1px solid #eee;
}

.img figcaption {
  font-size: 13px;
  opacity: .7;
  margin-top: 8px;
}

.paper-chapterno {
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: .6;
  margin-bottom: 6px;
}
