:root {
  --ink: #1c1c1c;
  --muted: #6d6d6d;
  --faint: #9a9a9a;
  --accent: #0b6e4f;
  --accent-soft: #e6f2ee;
  --arabic-bg: #f8f5ec;
  --arabic-border: #d9cfa6;
  --page: #fbfaf7;
  --rule: #e4e0d6;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: Georgia, "Times New Roman", "Iowan Old Style", serif;
  font-size: 18px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 46rem;
  margin: 0 auto;
  padding: 2.5rem 1.4rem 7rem;
}

/* ---------- Kitap başlığı ---------- */

.book-header {
  text-align: center;
  padding: 1.2rem 0 2.2rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 2.4rem;
}

.book-title {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: .01em;
}

.book-author {
  margin: .5rem 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.book-subtitle {
  margin: .9rem 0 0;
  direction: rtl;
  text-align: center;
  font-family: "Amiri", "Scheherazade New", "Traditional Arabic", "Noto Naskh Arabic", "Geeza Pro", serif;
  font-size: 1.25rem;
  color: var(--muted);
}

/* ---------- Bölüm başlığı ---------- */

.section-head { margin-bottom: 2.4rem; }

.section-kicker {
  margin: 0 0 .3rem;
  font-family: -apple-system, "Segoe UI", "Helvetica Neue", sans-serif;
  font-size: .78rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}

.section-head h1 {
  margin: 0;
  font-size: 1.7rem;
  line-height: 1.3;
  font-weight: 700;
}

/* ---------- Gezinme ---------- */

.top-nav {
  display: flex;
  justify-content: space-between;
  gap: .6rem;
  margin: 0 0 2.6rem;
  font-family: -apple-system, "Segoe UI", "Helvetica Neue", sans-serif;
  font-size: .85rem;
}

.top-nav a {
  color: var(--accent);
  text-decoration: none;
  padding: .35rem .7rem;
  border: 1px solid var(--rule);
  border-radius: .4rem;
  background: #fff;
}

.top-nav a:hover { background: var(--accent-soft); border-color: var(--accent); }

.top-nav .spacer { flex: 1; }

/* ---------- Başlık hiyerarşisi ---------- */

h2.chapter-heading {
  font-size: 1.35rem;
  line-height: 1.35;
  margin: 2.4rem 0 1rem;
  padding-bottom: .45rem;
  border-bottom: 2px solid var(--accent);
}

h3.issue-heading {
  font-size: 1.12rem;
  line-height: 1.4;
  margin: 1.9rem 0 .8rem;
  color: var(--accent);
}

/* ---------- Ana metin ---------- */

p.text {
  margin: 0 0 1.1rem;
  text-align: justify;
  hyphens: auto;
}

/* ---------- Arapça alıntılar ---------- */

.quote-group {
  margin: .2rem 0 1.35rem;
}

.arabic-quote {
  background: var(--arabic-bg);
  border-right: 3px solid var(--arabic-border);
  border-radius: .35rem;
  padding: .85rem 1.15rem .95rem;
  margin: .55rem 0;
}

.arabic-quote .kind {
  display: inline-block;
  font-family: -apple-system, "Segoe UI", "Helvetica Neue", sans-serif;
  font-size: .66rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: .08rem .6rem;
  margin-bottom: .45rem;
}

.arabic-quote p {
  margin: 0;
  direction: rtl;
  text-align: right;
  font-family: "Amiri", "Scheherazade New", "Traditional Arabic", "Noto Naskh Arabic", "Geeza Pro", serif;
  font-size: 1.45rem;
  line-height: 2.15;
}

/* ---------- Çevirmen (ajan) notu ---------- */

.agent-note {
  font-style: italic;
  color: #8a6d3b;
}

/* ---------- Editör düzeltmesi ---------- */

.editor-fix {
  color: #1d5fae;
  border-bottom: 1px dotted #1d5fae;
  background: rgba(29, 95, 174, 0.06);
  padding: 0 .08em;
  border-radius: 2px;
}

/* ---------- Açıklama (lejant) ---------- */

.legend {
  margin: 0 0 2.4rem;
  padding: .8rem 1rem;
  border: 1px solid var(--rule);
  border-radius: .45rem;
  background: #fff;
  font-family: -apple-system, "Segoe UI", "Helvetica Neue", sans-serif;
  font-size: .8rem;
  color: var(--muted);
  line-height: 1.6;
}

.legend p { margin: .15rem 0; }

.legend .swatch-agent { font-style: italic; color: #8a6d3b; }

.legend .swatch-editor {
  color: #1d5fae;
  border-bottom: 1px dotted #1d5fae;
}

/* ---------- Altbilgi ---------- */

.colophon {
  margin-top: 3.5rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--rule);
  color: var(--faint);
  font-size: .8rem;
  text-align: center;
}

.colophon a { color: var(--accent); text-decoration: none; }

/* ---------- İçindekiler (index) ---------- */

.toc-list { list-style: none; padding: 0; margin: 0; }

.toc-list li {
  border-bottom: 1px solid var(--rule);
}

.toc-list a {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 1rem .3rem;
  text-decoration: none;
  color: var(--ink);
}

.toc-list a:hover { background: var(--accent-soft); }

.toc-list .toc-no {
  font-family: -apple-system, "Segoe UI", "Helvetica Neue", sans-serif;
  font-size: .8rem;
  color: var(--accent);
  font-weight: 600;
  min-width: 4.5rem;
}

.toc-list .toc-title { flex: 1; }

.toc-list .toc-status {
  font-family: -apple-system, "Segoe UI", "Helvetica Neue", sans-serif;
  font-size: .72rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--faint);
  white-space: nowrap;
}

.toc-list .toc-status.ready { color: var(--accent); }

@media (max-width: 560px) {
  body { font-size: 17px; }
  main { padding: 1.8rem 1rem 5rem; }
  .arabic-quote p { font-size: 1.3rem; }
  .toc-list a { flex-wrap: wrap; }
}

/* A5 paged reading view; scoped so the untouched chapter 8 stays as-is. */
body.a5-layout {
  background: #e8e5df;
  color: #211e1a;
  font-size: 10.5pt;
  line-height: 1.55;
}

.a5-layout main {
  width: auto;
  max-width: none;
  margin: 0;
  padding: 0;
}

.a5-layout .book-header {
  margin: 0 0 8mm;
  padding: 7mm 0 0;
  border: 0;
}

.a5-layout .book-title {
  color: #342c23;
  font-size: 15pt;
  text-transform: uppercase;
}

.a5-layout .book-author,
.a5-layout .book-subtitle,
.a5-layout .section-kicker,
.a5-layout .top-nav,
.a5-layout .legend {
  display: none;
}

.a5-layout .section-head {
  margin: 0 0 8mm;
}

.a5-layout .section-head h1 {
  color: #725b43;
  font-size: 12pt;
  line-height: 1.35;
  text-align: center;
}

.a5-layout h2.chapter-heading {
  margin: 7mm 0 3mm;
  padding: 0;
  border: 0;
  color: #725b43;
  font-size: 11.5pt;
  line-height: 1.35;
  break-after: avoid;
}

.a5-layout h3.issue-heading {
  margin: 5mm 0 2mm;
  color: #725b43;
  font-size: 10.5pt;
  break-after: avoid;
}

.a5-layout p.text {
  margin: 0 0 3mm;
  text-align: justify;
  orphans: 2;
  widows: 2;
}

.a5-layout .quote-group {
  margin: 1mm 0 4mm;
}

.a5-layout .arabic-quote {
  margin: 2mm 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  break-inside: avoid;
}

.a5-layout .arabic-quote .kind {
  display: none;
}

.a5-layout .arabic-quote p {
  color: #665849;
  font-size: 12pt;
  line-height: 1.8;
}

.a5-layout .colophon {
  margin-top: 6mm;
  padding-top: 2mm;
  border: 0;
  font-size: 8pt;
}

.a5-layout .pagedjs_pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8mm;
  min-height: 100vh;
  padding: 20mm 0 10mm;
  background: #e8e5df;
}

.a5-layout .pagedjs_page {
  flex: none;
  background: #fff;
  box-shadow: 0 2mm 8mm rgb(35 29 22 / 18%);
}

.reader-toolbar {
  position: fixed;
  z-index: 10000;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  min-height: 48px;
  padding: .35rem .7rem;
  border-bottom: 1px solid #d6d0c6;
  background: rgb(251 250 247 / 97%);
  box-shadow: 0 1px 5px rgb(35 29 22 / 12%);
  color: #342c23;
  font: 500 .78rem/1.2 -apple-system, "Segoe UI", sans-serif;
}

.reader-toolbar a,
.reader-toolbar button,
.reader-toolbar summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: .35rem .55rem;
  border: 1px solid #d6d0c6;
  border-radius: 3px;
  background: #fff;
  color: inherit;
  font: inherit;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.reader-toolbar a:hover,
.reader-toolbar button:hover,
.reader-toolbar summary:hover {
  border-color: #725b43;
  background: #f3efe9;
}

.reader-toolbar button[aria-pressed="true"] {
  border-color: #725b43;
  background: #eee7dc;
  color: #5d4429;
}

.reader-bookmarks {
  position: relative;
}

.reader-bookmarks summary {
  list-style: none;
}

.reader-bookmarks summary::-webkit-details-marker {
  display: none;
}

.reader-bookmarks ul {
  position: absolute;
  top: calc(100% + .4rem);
  right: 0;
  width: min(340px, calc(100vw - 24px));
  max-height: 55vh;
  overflow: auto;
  margin: 0;
  padding: .35rem;
  border: 1px solid #d6d0c6;
  background: #fff;
  box-shadow: 0 3px 12px rgb(35 29 22 / 16%);
  list-style: none;
}

.reader-bookmarks li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .3rem;
  border-bottom: 1px solid #eee9e1;
}

.reader-bookmarks li:last-child {
  border-bottom: 0;
}

.reader-bookmarks li a {
  justify-content: flex-start;
  overflow: hidden;
  border: 0;
  text-overflow: ellipsis;
  white-space: normal;
}

.reader-bookmarks li button {
  min-height: 26px;
  padding: .2rem .35rem;
  color: #6d6255;
}

@media screen and (max-width: 560px) {
  .reader-toolbar {
    justify-content: space-between;
    gap: .2rem;
    padding: .3rem .35rem;
    font-size: .68rem;
  }

  .reader-toolbar a,
  .reader-toolbar button,
  .reader-toolbar summary {
    min-height: 30px;
    padding: .3rem .38rem;
  }
}

@media print {
  .reader-toolbar { display: none; }
  body.a5-layout { background: #fff; }
  .a5-layout .pagedjs_pages { gap: 0; padding: 0; }
  .a5-layout .pagedjs_page { box-shadow: none; }
}
