/* Book reader shell */
#book-reader {
  --reader-header: 3.25rem;
  --reader-toolbar: auto;
  --reader-bg: #f0eae3;
  --reader-accent: #9e3f2b;
  --reader-paper: #f5f4ee;
}

#book-reader {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  background: var(--reader-bg);
}

.reader-header {
  flex-shrink: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px solid rgba(158, 63, 43, 0.15);
  background: rgba(255, 255, 255, 0.92);
  padding: 0.5rem 0.75rem;
  backdrop-filter: blur(8px);
}

@media (min-width: 768px) {
  .reader-header {
    padding: 0.625rem 1.25rem;
  }
}

.reader-header__title {
  min-width: 0;
  flex: 1;
  font-size: 0.95rem;
  font-weight: 600;
  color: #3f2d24;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reader-back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 0.5rem;
  padding: 0.4rem 0.65rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #6b5348;
  transition: background 0.15s;
}

.reader-back:hover {
  background: #efe6dc;
  color: #3f2d24;
}

.reader-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  padding-bottom: 0.25rem;
}

.reader-stage .book {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reader-stage .flipbook {
  margin: 0 auto;
  max-width: 100%;
}

/* Bottom toolbar */
.reader-toolbar {
  flex-shrink: 0;
  z-index: 30;
  border-top: 1px solid rgba(158, 63, 43, 0.12);
  background: rgba(255, 255, 255, 0.96);
  padding: 0.5rem 0.75rem calc(0.5rem + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 24px rgba(63, 45, 36, 0.08);
  backdrop-filter: blur(8px);
}

.reader-toolbar__inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  max-width: 100%;
  margin: 0 auto;
}

.reader-toolbar__block {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.reader-toolbar__tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.reader-toolbar__divider {
  flex-shrink: 0;
  align-self: stretch;
  width: 1px;
  min-height: 2.25rem;
  margin: 0.15rem 0.875rem;
  background: rgba(158, 63, 43, 0.2);
}

@media (max-width: 1023px) {
  .reader-toolbar__desktop-only {
    display: none;
  }
}

@media (min-width: 1024px) {
  .reader-toolbar__mobile-only {
    display: none;
  }
}

.reader-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: 1px solid #e7ddd2;
  border-radius: 0.5rem;
  background: #fff;
  padding: 0.45rem 0.7rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #4a372f;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}

.reader-btn:hover {
  background: #faf7f3;
  border-color: #d4c4b4;
}

.reader-btn--primary {
  background: var(--reader-accent);
  border-color: var(--reader-accent);
  color: #fff;
}

.reader-btn--primary:hover {
  background: #873528;
  border-color: #873528;
}

.reader-btn--icon {
  padding: 0.5rem;
  min-width: 2.5rem;
}

.reader-btn svg {
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
}

.reader-pager {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border: 1px solid #e7ddd2;
  border-radius: 0.625rem;
  background: #fff;
  padding: 0.25rem;
}

.reader-pager__display {
  min-width: 4.5rem;
  border: 0;
  background: transparent;
  padding: 0.35rem 0.5rem;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 600;
  color: #3f2d24;
}

.reader-pager__total {
  padding: 0 0.35rem;
  font-size: 0.8125rem;
  color: #8b735f;
}

.reader-pager__goto {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 0.25rem;
  padding-left: 0.5rem;
  border-left: 1px solid #efe6dc;
}

.reader-pager__goto input {
  width: 3rem;
  border: 1px solid #e7ddd2;
  border-radius: 0.375rem;
  padding: 0.3rem 0.35rem;
  text-align: center;
  font-size: 0.8125rem;
}

.reader-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: #5c4a40;
}

.reader-toggle input {
  width: 2.25rem;
  height: 1.15rem;
  accent-color: var(--reader-accent);
}

/* Text selection toolbar */
.text-selection-toolbar {
  position: fixed;
  z-index: 50;
  display: none;
  transform: translate(-50%, -110%);
  border: 1px solid #e7ddd2;
  border-radius: 0.625rem;
  background: #fff;
  padding: 0.25rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.text-selection-toolbar .reader-toolbar-actions {
  display: flex;
  gap: 0.25rem;
}

.text-selection-toolbar .reader-btn {
  padding: 0.35rem 0.55rem;
  font-size: 0.75rem;
}

/* Offcanvas panels */
.offcanvas {
  position: fixed;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: #fff;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.15);
  transition: transform 0.3s ease, visibility 0.3s ease;
  visibility: hidden;
  pointer-events: none;
}

.offcanvas.show {
  visibility: visible;
  pointer-events: auto;
}

/* Varsayılan: sağdan açılan panel (kütüphane ana sayfa) */
.offcanvas:not(.offcanvas-start):not(.offcanvas-bottom) {
  top: 0;
  right: 0;
  bottom: 0;
  width: min(100%, 24rem);
  transform: translateX(100%);
}

.offcanvas-end {
  top: 0;
  right: 0;
  bottom: 0;
  width: min(100%, 24rem);
  transform: translateX(100%);
}

.offcanvas-start {
  top: 0;
  left: 0;
  bottom: 0;
  width: min(100%, 22rem);
  transform: translateX(-100%);
}

.offcanvas-bottom {
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 50vh;
  transform: translateY(100%);
}

.offcanvas.show.offcanvas-end,
.offcanvas.show.offcanvas-start,
.offcanvas.show:not(.offcanvas-start):not(.offcanvas-bottom) {
  transform: translateX(0);
}

.offcanvas.show.offcanvas-bottom {
  transform: translateY(0);
}

.offcanvas-backdrop {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.offcanvas-backdrop.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.offcanvas-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px solid #efe6dc;
  padding: 1rem 1.25rem;
}

.offcanvas-title {
  font-size: 1rem;
  font-weight: 600;
  color: #3f2d24;
}

.offcanvas-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
}

.btn-close {
  border: 0;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  color: #9ca3af;
  cursor: pointer;
}

.btn-close:hover {
  color: #4b5563;
}

/* TOC accordion */
.reader-toc .accordion-item {
  border: 1px solid #efe6dc;
  border-radius: 0.5rem;
  margin-bottom: 0.35rem;
  overflow: hidden;
  background: #faf7f3;
}

.reader-toc .accordion-header {
  display: flex;
  align-items: stretch;
}

.reader-toc .accordion-header .toc-link {
  flex: 1;
  min-width: 0;
  padding: 0.65rem 0.75rem;
  text-align: left;
  font-family: '00674', serif;
  font-size: 0.9rem;
  color: #3f2d24;
}

.reader-toc .accordion-button {
  flex-shrink: 0;
  width: 2.5rem;
  border: 0;
  border-left: 1px solid #efe6dc;
  background: #f5efe8;
  cursor: pointer;
}

.reader-toc .accordion-button::after {
  content: '';
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid #8b735f;
  border-bottom: 2px solid #8b735f;
  transform: rotate(45deg);
  transition: transform 0.2s;
}

.reader-toc .accordion-button:not(.collapsed)::after {
  transform: rotate(-135deg);
}

.reader-toc .accordion-collapse {
  display: none;
}

.reader-toc .accordion-collapse.show {
  display: block;
}

.reader-toc .accordion-body {
  padding: 0.35rem 0.5rem 0.65rem 1rem;
  border-top: 1px solid #efe6dc;
}

.reader-toc .toc-leaf {
  display: block;
  width: 100%;
  padding: 0.5rem 0.65rem;
  text-align: left;
  font-family: '00674', serif;
  font-size: 0.875rem;
  color: #9e3f2b;
  border-radius: 0.375rem;
}

.reader-toc .toc-leaf:hover {
  background: #efe6dc;
}

/* Notes list */
.reader-notes .note-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  border: 1px solid #efe6dc;
  border-radius: 0.5rem;
  background: #faf7f3;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  line-height: 1.45;
}

.reader-notes .note-delete {
  flex-shrink: 0;
  border-radius: 9999px;
  background: #fee2e2;
  padding: 0.15rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 600;
  color: #b91c1c;
}

/* Search panel */
.reader-search-input {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.reader-search-input input {
  flex: 1;
  border: 1px solid #e7ddd2;
  border-radius: 0.5rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.875rem;
}

/* Toast */
.reader-toast {
  position: fixed;
  right: 1rem;
  bottom: calc(5.5rem + env(safe-area-inset-bottom));
  z-index: 70;
  display: none;
  max-width: 20rem;
  border: 1px solid #e7ddd2;
  border-radius: 0.75rem;
  background: #fff;
  padding: 0.75rem 1rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}

.reader-toast.show {
  display: block;
}

.reader-toast__title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #3f2d24;
}

.reader-toast__body {
  margin-top: 0.25rem;
  font-size: 0.8125rem;
  color: #6b5348;
}

/* Mean / hasiye bottom sheet content */
.offcanvas-mean-body {
  font-size: 1.05rem;
  line-height: 1.6;
  color: #3f2d24;
}

@media (max-width: 767px) {
  .flipbook .cover h1 {
    font-size: clamp(2rem, 10vw, 3.5rem);
    padding: 0 1rem;
  }
}

.spinner {
  display: inline-block;
  width: 2rem;
  height: 2rem;
  border: 3px solid #e7ddd2;
  border-top-color: #9e3f2b;
  border-radius: 50%;
  animation: reader-spin 0.7s linear infinite;
}

@keyframes reader-spin {
  to { transform: rotate(360deg); }
}

/* ── Library index (kutuphane/kitaplar) ── */
.library-page {
  height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
  background: linear-gradient(180deg, #ebe3d8 0%, #f0eae3 12rem, #f0eae3 100%);
  -webkit-overflow-scrolling: touch;
}

.library-hero {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(158, 63, 43, 0.1);
  background: rgba(240, 234, 227, 0.92);
  backdrop-filter: blur(12px);
}

.library-hero__inner {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.25rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

@media (min-width: 768px) {
  .library-hero__inner {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
    padding: 1.75rem 1.5rem 1.25rem;
  }
}

.library-hero__eyebrow {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9e3f2b;
}

.library-hero__title {
  margin-top: 0.25rem;
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 700;
  line-height: 1.15;
  color: #3f2d24;
}

.library-hero__meta {
  margin-top: 0.35rem;
  font-size: 0.875rem;
  color: #8a7264;
}

.library-search {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}

@media (min-width: 768px) {
  .library-search {
    max-width: 26rem;
    flex-shrink: 0;
  }
}

.library-search__field {
  position: relative;
  flex: 1;
  min-width: 0;
}

.library-search__icon {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  width: 1.125rem;
  height: 1.125rem;
  transform: translateY(-50%);
  color: #a08b7d;
  pointer-events: none;
}

.library-search__input {
  width: 100%;
  border: 1px solid rgba(158, 63, 43, 0.15);
  border-radius: 0.75rem;
  background: #fff;
  padding: 0.625rem 0.875rem 0.625rem 2.5rem;
  font-size: 0.9375rem;
  color: #3f2d24;
  box-shadow: 0 1px 2px rgba(63, 45, 36, 0.06);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.library-search__input::placeholder {
  color: #b5a498;
}

.library-search__input:focus {
  outline: none;
  border-color: rgba(158, 63, 43, 0.4);
  box-shadow: 0 0 0 3px rgba(158, 63, 43, 0.12);
}

.library-search__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.75rem;
  border: none;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}

.library-search__btn:active {
  transform: scale(0.96);
}

.library-search__btn--primary {
  background: #9e3f2b;
  color: #fff;
  box-shadow: 0 2px 8px rgba(158, 63, 43, 0.3);
}

.library-search__btn--primary:hover {
  background: #8a3625;
}

.library-search__btn--secondary {
  background: #fff;
  color: #6b5348;
  border: 1px solid rgba(158, 63, 43, 0.15);
}

.library-search__btn--secondary:hover {
  background: #faf7f4;
}

.library-shelves {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0.5rem 0 3rem;
}

.library-shelf {
  margin-bottom: 2rem;
}

.library-shelf__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1rem 0.75rem;
}

@media (min-width: 768px) {
  .library-shelf__header {
    padding: 0 1.5rem 0.875rem;
  }
}

.library-shelf__title-wrap {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
}

.library-shelf__title {
  font-size: 1.125rem;
  font-weight: 700;
  color: #3f2d24;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (min-width: 768px) {
  .library-shelf__title {
    font-size: 1.25rem;
  }
}

.library-shelf__count {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 0.4rem;
  border-radius: 9999px;
  background: rgba(158, 63, 43, 0.1);
  font-size: 0.75rem;
  font-weight: 600;
  color: #9e3f2b;
}

.library-shelf__nav {
  display: none;
  gap: 0.375rem;
  flex-shrink: 0;
}

@media (min-width: 768px) {
  .library-shelf__nav {
    display: flex;
  }
}

.library-shelf__arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid rgba(158, 63, 43, 0.15);
  border-radius: 9999px;
  background: #fff;
  color: #6b5348;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.library-shelf__arrow svg {
  width: 1rem;
  height: 1rem;
}

.library-shelf__arrow:hover {
  background: #9e3f2b;
  border-color: #9e3f2b;
  color: #fff;
}

.library-shelf__track {
  position: relative;
}

.library-shelf__track::before,
.library-shelf__track::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0.5rem;
  width: 1.5rem;
  z-index: 2;
  pointer-events: none;
}

.library-shelf__track::before {
  left: 0;
  background: linear-gradient(90deg, #f0eae3 30%, transparent);
}

.library-shelf__track::after {
  right: 0;
  background: linear-gradient(270deg, #f0eae3 30%, transparent);
}

.library-shelf__scroll {
  display: flex;
  gap: 0.875rem;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-padding-left: 1rem;
  padding: 0.25rem 1rem 0.75rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(158, 63, 43, 0.25) transparent;
}

@media (min-width: 768px) {
  .library-shelf__scroll {
    scroll-padding-left: 1.5rem;
    padding: 0.25rem 1.5rem 0.75rem;
    gap: 1rem;
  }
}

.library-shelf__scroll::-webkit-scrollbar {
  height: 5px;
}

.library-shelf__scroll::-webkit-scrollbar-track {
  background: transparent;
}

.library-shelf__scroll::-webkit-scrollbar-thumb {
  border-radius: 9999px;
  background: rgba(158, 63, 43, 0.2);
}

.library-book-card {
  flex: 0 0 auto;
  width: 7.5rem;
  scroll-snap-align: start;
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s ease;
}

@media (min-width: 640px) {
  .library-book-card {
    width: 8.5rem;
  }
}

@media (min-width: 1024px) {
  .library-book-card {
    width: 9.25rem;
  }
}

.library-book-card:hover {
  transform: translateY(-4px);
}

.library-book-card__cover {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: 0.625rem;
  overflow: hidden;
  background: #e7ddd2;
  box-shadow:
    0 4px 6px -1px rgba(63, 45, 36, 0.12),
    0 2px 4px -2px rgba(63, 45, 36, 0.08);
  transition: box-shadow 0.2s ease;
}

.library-book-card:hover .library-book-card__cover {
  box-shadow:
    0 12px 24px -4px rgba(63, 45, 36, 0.18),
    0 4px 8px -2px rgba(63, 45, 36, 0.1);
}

.library-book-card__cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.library-book-card__name {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.35;
  color: #4a382f;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (min-width: 640px) {
  .library-book-card__name {
    font-size: 0.8125rem;
  }
}

.library-toast {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 50;
  max-width: 20rem;
  padding: 1rem;
  border-radius: 0.75rem;
  border: 1px solid #e2e8f0;
  background: #fff;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  opacity: 0;
  visibility: hidden;
  transform: translateY(0.5rem);
  transition: opacity 0.3s, transform 0.3s, visibility 0.3s;
}

.library-toast.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
