/*
 * القارئ الذكي. الصفحات تملأ الشاشة، والشريطان زجاجٌ يظهر بلمسة ويختفي
 * بالتمرير. لا شيء عائم فوق الصفحات وأنت تقرأ.
 */

.v35.rd {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: #000;
  color: var(--text-1);
  overflow: hidden;
  /* بلا تكبير المتصفح: إصبعان أو لمستان لا تكبّران الواجهة بالخطأ.
     التكبير (إن فُعّل) طبقة خاصة فوق الصفحة، لا تكبير المتصفح */
  touch-action: pan-x pan-y;
  -webkit-user-select: none;
  user-select: none;
}

.v35 .rd-scroll {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  touch-action: pan-y;
  scrollbar-width: none;
  /* ما فوقك يتحمّل ويكبر فلا تقفز الصفحة تحت إصبعك */
  overflow-anchor: auto;
}
.v35 .rd-scroll::-webkit-scrollbar {
  display: none;
}

.v35 .rd-page {
  position: relative;
  width: 100%;
  max-width: 820px;
  margin: 0 auto var(--rd-gap, 0);
  aspect-ratio: 0.68;
  background: #0b0a0f;
  content-visibility: auto;
  contain-intrinsic-size: auto 900px;
}
.v35 .rd-page > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  animation: v35-fade 180ms var(--ease);
}
.v35 .rd-page .skeleton {
  background: linear-gradient(100deg, #0d0c12 30%, #16141d 50%, #0d0c12 70%);
  background-size: 300% 100%;
}

/* صفحة لم تتحمّل: سببها في مكانها وزرّ إعادة لها وحدها */
.v35 .rd-page--error {
  aspect-ratio: 0.9;
}
.v35 .rd-page-error {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  padding: 24px;
  text-align: center;
  color: var(--text-2);
}
.v35 .rd-page-error > .icon {
  width: 30px;
  height: 30px;
  color: var(--text-4);
}
.v35 .rd-page-error small {
  color: var(--text-3);
  font-size: var(--fs-caption);
  max-width: 260px;
}
.v35 .rd-page-error .btn {
  margin-top: 8px;
  min-height: 40px;
}

.v35 .rd-loading,
.v35 .rd-error {
  min-height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  padding: 32px 24px;
  text-align: center;
  color: var(--text-3);
  font-size: var(--fs-meta);
}
.v35 .rd-error h3 {
  margin: 0;
  color: var(--text-1);
  font-size: var(--fs-title-sm);
}
.v35 .rd-error p {
  margin: 0;
  max-width: 300px;
  line-height: 1.7;
}
.v35 .rd-error .empty-art {
  color: var(--warning);
}
.v35 .rd-error-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}
.v35 .rd-spinner {
  width: 28px;
  height: 28px;
  border-radius: 99px;
  border: 2.5px solid var(--surface-3);
  border-top-color: var(--accent-text);
  animation: rd-spin 0.8s linear infinite;
}
@keyframes rd-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── الفصول متتالية في تمريرٍ واحد: القطعة لا تصنع صندوقًا ── */
.v35 .rd-chapter {
  display: contents;
}

/* ── الحدّ بين فصلين: شريطٌ واحد بارتفاعه، لا شاشة سوداء ── */
.v35 .rd-end {
  display: grid;
  justify-items: center;
  gap: 10px;
  margin: 0 auto;
  max-width: 820px;
  padding: 28px 20px 30px;
  text-align: center;
  background: linear-gradient(180deg, #000 0%, var(--bg) 40%, var(--bg) 60%, #000 100%);
  border-block: 1px solid var(--line);
}
.v35 .rd-end-done {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: var(--fs-meta);
  color: var(--text-3);
}
.v35 .rd-end-done .icon {
  color: var(--success);
}
.v35 .rd-end-next {
  display: grid;
  justify-items: center;
  gap: 2px;
  min-width: 200px;
  padding: 12px 28px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--surface-1);
  color: var(--text-1);
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.v35 .rd-end-kicker {
  font-size: var(--fs-caption);
  color: var(--text-3);
}
.v35 .rd-end-no {
  font-size: 28px;
  line-height: 1.15;
  font-weight: 780;
}
.v35 .rd-end-name {
  max-width: 260px;
  font-size: var(--fs-meta);
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.v35 .rd-end-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: var(--fs-caption);
  color: var(--text-3);
}
.v35 .rd-end-state--error {
  color: var(--warning);
}
.v35 .rd-spinner--sm {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-width: 2px;
}
.v35 .rd-end-next:active {
  background: var(--surface-2);
  border-color: var(--accent-line);
}
.v35 .rd-end--last {
  padding: 40px 20px calc(72px + var(--safe-bottom));
  border-bottom: 0;
  background: var(--bg);
}
.v35 .rd-end-last {
  font-size: var(--fs-title-sm);
  font-weight: 700;
  color: var(--text-1);
}
.v35 .rd-end-sub {
  font-size: var(--fs-meta);
  color: var(--text-3);
}
.v35 .rd-end-back {
  margin-top: 6px;
}

/* ── صفحة صفحة (مانجا): أفقي من اليمين، كل صفحة الشاشة كلها ── */
.v35.rd[data-mode='paged'] .rd-scroll {
  display: flex;
  direction: rtl;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  touch-action: pan-x;
}
.v35.rd[data-mode='paged'] .rd-page,
.v35.rd[data-mode='paged'] .rd-end,
.v35.rd[data-mode='paged'] .rd-loading,
.v35.rd[data-mode='paged'] .rd-error {
  flex: 0 0 100%;
  width: 100%;
  max-width: none;
  height: 100%;
  margin: 0;
  aspect-ratio: auto !important;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  content-visibility: visible;
  background: #000;
}
.v35.rd[data-mode='paged'] .rd-end {
  align-content: center;
  padding-bottom: 40px;
}
.v35.rd[data-mode='paged'][data-fit='width'] .rd-page {
  overflow-y: auto;
  touch-action: pan-y pan-x;
}
.v35.rd[data-mode='paged'][data-fit='width'] .rd-page > img {
  height: auto;
  min-height: 100%;
  object-fit: contain;
}

/* ── الشريطان ── */
.v35 .rd-top,
.v35 .rd-bottom {
  position: absolute;
  z-index: 5;
  inset-inline: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  padding-inline: 6px;
  background: rgba(10, 9, 14, 0.78);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  transition: transform var(--dur) var(--ease-out), opacity var(--dur) var(--ease);
  opacity: 0;
  pointer-events: none;
}
.v35 .rd-top {
  top: 0;
  min-height: calc(var(--top-h) + var(--safe-top));
  padding-top: var(--safe-top);
  transform: translateY(-100%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06);
}
.v35 .rd-bottom {
  bottom: 0;
  min-height: calc(60px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  transform: translateY(100%);
  box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.06);
}
.v35.rd--chrome .rd-top,
.v35.rd--chrome .rd-bottom {
  transform: none;
  opacity: 1;
  pointer-events: auto;
}
.v35 .rd-titles {
  flex: 1;
  min-width: 0;
  display: grid;
  padding: 0 6px;
  line-height: 1.3;
}
.v35 .rd-titles--chapters {
  border: 0;
  background: transparent;
  color: inherit;
  text-align: start;
  cursor: pointer;
  padding-block: 7px;
  border-radius: 8px;
}
.v35 .rd-titles--chapters:active { background: var(--surface-2); }
.v35 .rd-chapter-sheet { max-height: min(80vh, 740px); display: flex; flex-direction: column; }
.v35 .rd-chapter-sheet__head { display: flex; justify-content: space-between; align-items: baseline; padding: 6px 4px 14px; }
.v35 .rd-chapter-sheet__head span { color: var(--text-3); font-variant-numeric: tabular-nums; }
.v35 .rd-chapter-sheet__list { overflow: auto; overscroll-behavior: contain; min-height: 0; scrollbar-width: thin; }
.v35 .rd-chapter-choice { width: 100%; min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--text-1); padding: 11px 14px; text-align: start; cursor: pointer; }
.v35 .rd-chapter-choice.is-current { background: var(--accent-soft); color: var(--accent-text); border-radius: 10px; }
.v35 .rd-chapter-choice__number { font-weight: 650; flex: none; }
.v35 .rd-chapter-choice__title { color: var(--text-3); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.v35 .rd-titles strong {
  font-size: var(--fs-body);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.v35 .rd-titles span {
  font-size: var(--fs-caption);
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.v35 .rd-camera .icon {
  color: var(--text-1);
}
.v35 .rd-progress {
  flex: 1;
  display: grid;
  gap: 6px;
  padding: 0 8px;
  font-size: var(--fs-caption);
  color: var(--text-2);
  text-align: center;
}
.v35 .rd-progress span {
  direction: ltr;
}
.v35 .rd-progress .progress-bar {
  height: 3px;
  background: rgba(255, 255, 255, 0.12);
}

/* ── فريم ── */
.v35 .rd-top--frame {
  gap: 8px;
}
.v35 .rd-frame-next {
  min-height: 38px;
  padding: 0 16px;
  margin-inline-end: 6px;
  font-size: var(--fs-meta);
}
.v35.rd--frame .rd-page {
  cursor: pointer;
}
.v35.rd--frame .rd-page::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  transition: background var(--dur-fast) var(--ease);
  pointer-events: none;
}
.v35.rd--frame .rd-page--picked::after {
  background: transparent;
  box-shadow: inset 0 0 0 3px var(--accent);
}
.v35.rd--frame .rd-page--picked::before {
  content: attr(data-order);
  position: absolute;
  z-index: 2;
  top: 12px;
  inset-inline-start: 12px;
  width: 30px;
  height: 30px;
  border-radius: 99px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 750;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}
.v35 .rd-tray {
  position: absolute;
  z-index: 5;
  inset-inline: 0;
  bottom: 0;
  padding: 10px 12px calc(10px + var(--safe-bottom));
  background: rgba(10, 9, 14, 0.86);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.06);
}
.v35 .rd-tray p {
  margin: 8px 0 0;
  text-align: center;
  font-size: var(--fs-caption);
  color: var(--text-3);
}
.v35 .rd-tray-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  min-height: 72px;
}
.v35 .rd-thumb {
  position: relative;
  flex: none;
  width: 50px;
  height: 72px;
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--surface-2);
  box-shadow: 0 0 0 2px var(--accent);
}
.v35 .rd-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}
.v35 .rd-thumb span {
  position: absolute;
  top: 3px;
  inset-inline-start: 3px;
  min-width: 18px;
  height: 18px;
  border-radius: 99px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.v35 .rd-send-preview {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 12px calc(var(--gutter) * -1) 10px;
  padding: 0 var(--gutter);
}
.v35 .rd-send-page {
  flex: none;
  width: 92px;
  aspect-ratio: 0.68;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface-2);
}
.v35 .rd-send-page img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}
.v35 .rd-send-note {
  width: 100%;
  min-height: 0;
  padding: 12px 14px;
  margin-bottom: 6px;
  resize: none;
}
.v35 .rd-send-head {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 0 -6px 10px;
}
.v35 .rd-send-head p {
  margin-top: 2px;
}
.v35 .rd-send-go {
  margin-top: 16px;
}
.v35 .rd-everyone {
  background: var(--accent-soft);
  color: var(--accent-text);
}

/* ── التكبير: طبقة فوق الصفحة، لا تكبير المتصفح ── */
.v35 .rd-zoom {
  position: absolute;
  inset: 0;
  z-index: 8;
  background: #000;
  display: grid;
  place-items: center;
  overflow: hidden;
  touch-action: none;
}
.v35 .rd-zoom img {
  max-width: 100%;
  max-height: 100%;
  transform-origin: center;
  will-change: transform;
}

.v35 .rd-toast {
  bottom: calc(24px + var(--safe-bottom));
}
.v35.rd--chrome .rd-toast {
  bottom: calc(76px + var(--safe-bottom));
}

/* ── الإعدادات ── */
.v35 .rd-setting {
  margin-top: 16px;
}
.v35 .rd-setting-label {
  margin-bottom: 8px;
  font-size: var(--fs-meta);
  font-weight: 650;
  color: var(--text-2);
}
.v35 .rd-seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: var(--r-md);
  background: var(--surface-1);
  box-shadow: inset 0 0 0 1px var(--line);
}
.v35 .rd-seg-item {
  flex: 1;
  min-height: 40px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: var(--fs-meta);
  font-weight: 600;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.v35 .rd-seg-item[aria-checked='true'] {
  background: var(--surface-3);
  color: var(--text-1);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.v35 .rd-setting-hint {
  margin-top: 10px !important;
  font-size: var(--fs-caption) !important;
}
.v35 .rd-switch-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-body);
}
.v35 .rd-switch-row > div,
.v35 .rd-switch-row > span {
  flex: 1;
  min-width: 0;
}
.v35 .rd-switch-row small {
  display: block;
  color: var(--text-3);
  font-size: var(--fs-caption);
}

/* ── الترجمة العربية: الصفحة المترجمة صورة من عامل الترجمة، تبدّل الأصل ──
   لا طبقة فوق الصفحة ولا رسم على الجوال (انظر reader-translate.js) */
.v35 .rd-page > img.rd-page--translated { transition: opacity var(--dur, 160ms) var(--ease, ease); }

/* «نجهّز الفصل بالعربي»: فوق الصفحات، لا يحجب الشريط */
.v35 .rd-tl-gate {
  position: absolute; inset: 0; z-index: 30;
  display: grid; place-items: center; padding: 24px;
  background: rgba(5, 4, 10, 0.72);
  backdrop-filter: blur(6px);
}
.v35 .rd-tl-card {
  width: min(320px, 100%);
  display: flex; flex-direction: column; gap: 12px;
  padding: 22px 20px;
  border-radius: 20px;
  background: var(--surface-2, #16131f);
  box-shadow: inset 0 0 0 1px rgba(143, 92, 255, 0.35);
  text-align: center;
}
.v35 .rd-tl-card strong { font-size: 17px; }
.v35 .rd-tl-line { color: var(--text-2, #bab6c6); font-size: 13px; }

/* ── زرّ الترجمة: واضح في الشريط، وعائم في الزاوية أثناء القراءة ── */
.v35 .rd-tl-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  margin-inline: 2px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-2);
  font: inherit;
  font-size: var(--fs-caption);
  font-weight: 700;
  cursor: pointer;
}
.v35 .rd-tl-btn[aria-pressed='true'] {
  border-color: transparent;
  background: var(--accent, #7c5cff);
  color: #fff;
}
.v35 .rd-tl-btn[hidden] { display: none; }
/* الشريط السفلي ظاهر: الزر فوقه لا تحته */
/* زر الترجمة العائم جزءٌ من الشريط: يظهر معه ويختفي معه، لا فوق الصفحة وأنت تقرأ */
