/* variables.css */
:root {
  --bg-body: #000000;
  --bg-card: #111111;
  --bg-card-hover: #1a1a1a;
  --bg-input: #1a1a1a;
  --bg-header: #0d0d0d;
  --bg-sidebar: #0a0a0a;
  --bg-overlay: rgba(0,0,0,0.6);
  --bg-panel: #111111;
  --bg-hover: #1a1a1a;
  --bg-surface: #111111;
  --bg-secondary: #111111;

  --text-primary: #d1d1d6;
  --text-secondary: #8e8e93;
  --text-muted: #555;
  --text-title: #e5e5ea;
  --text-color: #d1d1d6;
  --star-color: #ffcc00;

  --border-color: #222222;
  --scrollbar-thumb: #ffffff;

  --accent: #ffffff;
  --accent-hover: #e5e5ea;
  --accent-text: #000000;
  --discussion-link-color: #b46cff;

  --color-success: #34c759;
  --color-warning: #ffcc00;
  --color-danger: #ff3b30;

  --font-ui: 'Cairo', 'Segoe UI', system-ui, sans-serif;
  --font-reading: 'Noto Naskh Arabic', 'Traditional Arabic', serif;
  --font-logo: 'Arabic Poetry', sans-serif;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --max-width: 1200px;
  --navbar-height: 56px;

  --transition: 0.15s ease;
}

[data-theme="light"] {
  --bg-body: #f2f2f7;
  --bg-card: #fff;
  --bg-card-hover: #f8f8fa;
  --bg-input: #ebebf0;
  --bg-header: #fff;
  --bg-sidebar: #f8f8fa;
  --bg-panel: #fff;
  --bg-hover: #f8f8fa;
  --bg-surface: #fff;
  --bg-secondary: #fff;
  --text-primary: #1c1c1e;
  --text-secondary: #636366;
  --text-muted: #aeaeb2;
  --text-title: #000;
  --text-color: #1c1c1e;
  --star-color: #ff9500;
  --border-color: #d1d1d6;
  --scrollbar-thumb: #111111;
  --accent: #000000;
  --accent-hover: #333333;
  --accent-text: #ffffff;
  --discussion-link-color: #7c3aed;
}

/* base.css */
/* الخطوط الأساسية محلية حتى لا تنتظر الصفحة اتصالًا خارجيًا قبل الرسم. */
/* خطوط القراءة الإضافية — تُطلب فقط عندما يختارها القارئ من الإعدادات. */
@font-face {
  font-family: 'Amiri'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/fonts/amiri-arabic.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
  font-family: 'Scheherazade New'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/fonts/scheherazade-new-arabic.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
  font-family: 'Cairo'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url('/fonts/cairo-arabic.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
  font-family: 'Cairo'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url('/fonts/cairo-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-024F, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Cairo'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url('/fonts/cairo-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Noto Naskh Arabic'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url('/fonts/naskh-arabic.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
  font-family: 'Noto Naskh Arabic'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url('/fonts/naskh-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-024F, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Noto Naskh Arabic'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url('/fonts/naskh-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Nunito Sans'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url('/fonts/nunito-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Arabic Poetry';
  src: url('/fonts/ArabicPoetry.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
}
@font-face {
  font-family: 'fnt_a7c1e4';
  src: url('/fonts/r-a7c1e4.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'fnt_d9b284';
  src: url('/fonts/r-d9b284.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'fnt_f3e8a1';
  src: url('/fonts/r-f3e8a1.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { direction: rtl; scroll-behavior: smooth; }

body {
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-body);
  min-height: 100vh;
  max-width: 100%;
  overflow-x: hidden;
}

a { color: var(--text-primary); text-decoration: none; }
a:hover { color: var(--accent); }
img { max-width: 100%; height: auto; display: block; }
/* picture لا يغيّر شكل العنصر؛ يحتفظ بنفس مساحة الصورة مع السماح للمتصفح
   باختيار AVIF/WebP المناسب قبل تنزيل الأصل. */
.responsive-picture { display: block; width: 100%; }
h1,h2,h3,h4,h5,h6 { font-weight: 700; color: var(--text-title); line-height: 1.3; }
input, select, textarea, button { font-family: inherit; font-size: inherit; outline: none; }
input, select, textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-primary);
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
button { cursor: pointer; border: none; background: transparent; }
::selection { background: var(--accent); color: var(--accent-text); }

/* حقول الكتابة: عرض كامل وتمدد تلقائي مع إبقاء مساحة مريحة على الهاتف. */
textarea.auto-grow-textarea {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: clamp(128px, 24dvh, 240px);
  max-height: min(58dvh, 420px);
  padding: 12px 14px;
  line-height: 1.75;
  resize: vertical;
  overflow-y: hidden;
  field-sizing: content;
}
@supports not (height: 1dvh) {
  textarea.auto-grow-textarea {
    min-height: clamp(128px, 24vh, 240px);
    max-height: min(58vh, 420px);
  }
}

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg-body); }
* { scrollbar-color: var(--scrollbar-thumb) var(--bg-body); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 99px; }

.container { max-width: var(--max-width); margin: 0 auto; padding: 0 16px; }

.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0%{background-position:200% 0}100%{background-position:-200% 0} }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(80px);
  padding: 10px 20px; border-radius: 6px; font-size: 13px; font-weight: 600; z-index: 10000;
  transition: transform 0.3s ease;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--color-success); color: #fff; }
.toast.error { background: var(--color-danger); color: #fff; }

/* ═══ فئات مساعدة (Utilities) ═══ */
.d-flex { display: flex; }
.gap-1 { gap: 8px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }

/* layout.css */
/* ═══ NAVBAR — بسيط مثل NovelFire ═══ */
.navbar {
  position: relative; z-index: 1000;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  height: var(--navbar-height);
}
.navbar .container { display: flex; align-items: center; height: 100%; gap: 12px; }
.navbar-logo a { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.site-logo { height: 42px; width: auto; object-fit: contain; }
[data-theme="dark"] .site-logo { filter: invert(1) brightness(2); }
.navbar-links { display: flex; align-items: center; gap: 0; margin-right: 20px; }
.navbar-links a { padding: 8px 16px; font-size: 15px; font-weight: 500; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }
.navbar-links a:hover, .navbar-links a.active { color: var(--accent); }
.mobile-search { display: none; }

.navbar-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-card); border: 1px solid var(--border-color); 
  border-radius: 24px;
  padding: 0 14px; margin-right: auto; flex: 0 1 240px;
  transition: all 0.3s ease;
}
.navbar-search:focus-within { 
  border-color: var(--accent); 
  flex-basis: 300px;
  background: var(--bg-input);
}
.navbar-search input { 
  border: none; background: none; padding: 8px 0; width: 100%; font-size: 14px; color: var(--text-primary); outline: none;
}
.navbar-search svg {
  color: var(--text-muted); min-width: 16px;
}
.navbar-search button:hover { color: var(--accent); }

.theme-toggle {
  width: 40px; height: 36px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--text-secondary); border: 1px solid var(--border-color); background: var(--bg-input);
}
.theme-toggle:hover { color: var(--text-primary); }
.theme-toggle-mobile { display: none; }
.navbar-menu-btn { display: none; font-size: 20px; color: var(--text-primary); padding: 4px; }
.user-nav-menu { display: flex; align-items: center; gap: 6px; margin-inline-start: 8px; }
.user-login-btn,
.user-logout-btn,
.user-chip {
  height: 36px; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--border-color); background: var(--bg-input); color: var(--text-secondary);
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; white-space: nowrap;
}
.user-login-btn { padding: 0 12px; }
.user-login-btn:hover,
.user-logout-btn:hover { color: var(--text-primary); border-color: var(--accent); }
.user-chip { max-width: 180px; padding: 0 8px; color: var(--text-primary); cursor: pointer; text-decoration: none; }
.user-avatar { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.user-avatar-fallback { background: var(--accent); }
.user-name { overflow: hidden; text-overflow: ellipsis; }
.user-logout-btn { width: 36px; flex-shrink: 0; }

/* ═══ الأقسام — نظيف ═══ */
.section { margin-bottom: 32px; }
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border-color);
}
.section-title { font-size: 15px; font-weight: 700; color: var(--accent); }
.section-link { font-size: 12px; color: var(--text-secondary); }
.section-link:hover { color: var(--accent); }

/* ═══ شبكة الروايات ═══ */
.novels-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 14px; }

/* ═══ MAIN ═══ */
main { min-height: calc(100vh - var(--navbar-height) - 60px); padding: 24px 0; }

/* ═══ FOOTER ═══ */
.footer { text-align: center; padding: 30px 0 20px; color: var(--text-muted); font-size: 12px; border-top: 1px solid var(--border-color); margin-top: 40px; }
.footer-content { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.footer-social { display: flex; gap: 24px; }
.footer-social a { color: var(--text-secondary); transition: color 0.3s ease, transform 0.3s ease; display: flex; }
.footer-social a:hover { color: var(--accent); transform: translateY(-3px); }
.legal-footer .legal-footer-layout { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 16px; direction: ltr; }
.legal-footer-content { grid-column: 2; grid-row: 1; direction: rtl; }

/* ═══ تفاصيل الرواية ═══ */
.novel-detail { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px; margin-bottom: 32px; }
.novel-detail > *,
.novel-detail .info-side,
.novel-detail .cover-side { min-width: 0; }
.cover-side img { width: 100%; border-radius: var(--radius-sm); }
.cover-side > .responsive-picture { width: 100%; }
.novel-title { min-width: 0; font-size: 1.3rem; margin-bottom: 12px; overflow-wrap: anywhere; }
.novel-meta { 
  display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; 
}
.meta-item { display: flex; align-items: center; justify-content: flex-start; gap: 6px; min-width: 0; font-size: 15px; }
.meta-label { color: var(--text-secondary); flex: 0 0 auto; font-weight: bold; }
.meta-item > span:not(.meta-label),
.meta-item > a { min-width: 0; overflow-wrap: anywhere; }
.meta-item > span:not(.meta-label) { color: var(--text-primary); font-weight: 600; }
.meta-item > span.meta-value-highlight { color: var(--accent); font-weight: 800; }
.meta-status-row { gap: 8px; flex-wrap: wrap; }
.meta-label-inline { margin-inline-start: 10px; }
.meta-item a { color: var(--accent); font-weight: 600; }
.meta-item a:hover { text-decoration: underline; }
.user-rating-panel {
  display: flex; flex-direction: column; align-items: stretch; gap: 8px; margin: -4px 0 16px;
  min-height: 34px; color: var(--text-primary);
}
.user-rating-row { display: flex; align-items: center; gap: 10px; }
.user-rating-label { color: var(--text-secondary); min-width: 80px; font-size: 14px; font-weight: 700; }
.user-rating-stars { display: inline-flex; align-items: center; gap: 2px; direction: ltr; }
.user-rating-star {
  width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; color: var(--text-muted); cursor: pointer;
  font-size: 22px; line-height: 1; padding: 0; transition: color 0.15s ease, transform 0.15s ease;
}
.user-rating-star:hover,
.user-rating-star.active { color: var(--accent); }
.user-rating-star:hover { transform: translateY(-1px); }
.user-rating-panel.is-saving .user-rating-star,
.user-rating-panel.is-saving .user-rating-clear { pointer-events: none; opacity: 0.55; }
.user-rating-panel.is-disabled .user-rating-star { color: var(--text-muted); }
.user-rating-clear {
  width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  background: rgba(128, 128, 128, 0.08); color: var(--text-secondary); cursor: pointer;
  font-size: 18px; line-height: 1; padding: 0;
}
.user-rating-clear:hover { color: var(--text-primary); border-color: var(--text-secondary); }
.user-rating-clear.hidden { display: none; }
.user-review-text {
  width: 100%; min-height: 86px; resize: vertical; border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); background: var(--bg-input); color: var(--text-primary);
  padding: 10px 12px; font: inherit; font-size: 14px; line-height: 1.7;
}
.user-review-text:focus { outline: none; border-color: var(--accent); }
.user-review-save {
  align-self: flex-start; min-height: 34px; display: inline-flex; align-items: center; justify-content: center;
  padding: 0 14px; border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); background: var(--bg-card); color: var(--text-primary);
  cursor: pointer; font: inherit; font-size: 13px; font-weight: 700;
}
.user-review-save:hover { border-color: var(--accent); color: var(--accent); }
.user-rating-panel.is-saving .user-review-text,
.user-rating-panel.is-saving .user-review-save { pointer-events: none; opacity: 0.55; }
.discussion-container { padding: 16px 0; }
.discussion-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.comment-open-btn {
  width: 34px; min-width: 34px; min-height: 34px; height: 34px; padding: 0;
  gap: 0; font-size: 0; line-height: 1; font-weight: 700;
}
.comment-open-btn svg { width: 17px; height: 17px; flex: 0 0 auto; }
.comment-open-btn:hover,
.comment-open-btn:focus-visible { color: var(--accent); border-color: var(--accent); }
.review-open-btn {
  width: 34px; min-width: 34px; min-height: 34px; height: 34px; padding: 0;
  gap: 0; color: var(--text-secondary); font-size: 0; line-height: 1; font-weight: 700;
}
.review-open-btn svg { width: 17px; height: 17px; flex: 0 0 auto; }
.review-open-btn:hover,
.review-open-btn:focus-visible { color: var(--accent); border-color: var(--accent); }
.discussion-sort-control {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--text-muted); font-size: 12px; font-weight: 700;
}
.comment-sort-control {
  position: relative; width: 34px; min-width: 34px; height: 34px; min-height: 34px;
  align-items: center; justify-content: center; gap: 0; padding: 0;
  border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  color: var(--text-secondary); background: transparent; cursor: pointer;
  font-size: 0;
}
.comment-sort-control:hover,
.comment-sort-control:focus-within { color: var(--accent); border-color: var(--accent); }
.comment-sort-icon { display: inline-flex; pointer-events: none; }
.comment-sort-icon svg { display: block; width: 17px; height: 17px; }
.comment-sort-control select {
  position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0;
  margin: 0; padding: 0; opacity: 0; border: 0; background: transparent;
  cursor: pointer; appearance: none; -webkit-appearance: none;
}
.review-sort-control {
  position: relative; width: 34px; min-width: 34px; height: 34px; min-height: 34px;
  align-items: center; justify-content: center; gap: 0; padding: 0;
  border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  color: var(--text-secondary); background: transparent; cursor: pointer;
  font-size: 0;
}
.review-sort-control:hover,
.review-sort-control:focus-within { color: var(--accent); border-color: var(--accent); }
.review-sort-icon { display: inline-flex; pointer-events: none; }
.review-sort-icon svg { display: block; width: 17px; height: 17px; }
.review-sort-control select {
  position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0;
  margin: 0; padding: 0; opacity: 0; border: 0; background: transparent;
  cursor: pointer; appearance: none; -webkit-appearance: none;
}
.discussion-sort-control select {
  width: 100px; min-width: 100px; max-width: 100%; min-height: 34px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); background: transparent; color: var(--text-primary); font-weight: bold;
  padding: 0 6px; font: inherit; font-size: 13px; cursor: pointer; outline: none;
}
.comment-sort-control select,
.review-sort-control select {
  width: 100%;
  min-width: 0;
  max-width: none;
}
.discussion-sort-control select option {
  color: var(--text-primary);
  background: var(--bg-card);
}
.comment-form {
  display: flex; flex-direction: column; gap: 10px; padding: 14px;
  background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  margin-bottom: 16px;
}
.comment-form.hidden { display: none; }
.comment-form.is-disabled { opacity: 0.72; }
.discussion-input {
  width: 100%; min-height: 86px; resize: vertical; border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); background: var(--bg-input); color: var(--text-primary);
  padding: 10px 12px; font: inherit; font-size: 14px; line-height: 1.7;
}
.discussion-input:focus { outline: none; border-color: var(--accent); }
.discussion-form-footer,
.reviews-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.discussion-actions { display: flex; align-items: center; gap: 8px; }
.discussion-actions .hidden { display: none !important; }
.discussion-hint { color: var(--text-muted); font-size: 12px; }
.discussion-list { display: flex; flex-direction: column; gap: 8px; }
.tabs-body,
.tab-panel,
.discussion-container,
.chapters-comments-section { min-width: 0; max-width: 100%; }
.review-section { margin-top: 18px; }
.review-source-tabs {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-top: 14px; padding: 6px; background: var(--bg-card);
  border: 1px solid var(--border-color); border-radius: var(--radius-sm);
}
.review-source-tab {
  padding: 6px 12px; border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-secondary); font-size: 12px; font-weight: 700;
}
.review-source-tab:hover { color: var(--text-primary); border-color: var(--border-color); }
.review-source-tab.active { background: var(--bg-input); color: var(--text-primary); border-color: var(--border-color); }
.review-source-panel { display: none; }
.review-source-panel.active { display: block; }
.review-section-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--border-color);
}
.review-section-heading { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.review-section-controls-slot { display: inline-flex; align-items: center; flex: 0 0 auto; }
.review-section-controls { display: inline-flex; align-items: center; gap: 8px; }
.review-section-head h3 { margin: 0; font-size: 15px; color: var(--text-primary); }
.discussion-item {
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px; background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
}
.discussion-avatar {
  width: 32px; height: 32px; border-radius: 50%; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-input); color: var(--text-secondary); font-weight: 700;
  flex-shrink: 0;
}
.discussion-avatar img { width: 100%; height: 100%; object-fit: cover; }
.discussion-body { min-width: 0; }
.discussion-head { display: flex; flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.discussion-head-user { display: flex; align-items: center; gap: 8px; margin-right: -4px; }
.discussion-head-user-details { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.discussion-head strong { font-size: 13px; color: var(--text-primary); line-height: 1.2; }
.review-head { align-items: center; }
.review-head-user { flex: 1 1 auto; min-width: 0; align-items: center; }
.review-head-user strong {
  min-width: 0; overflow-wrap: anywhere; word-break: break-word; white-space: normal; line-height: 18px;
}
.review-head-meta {
  display: flex; align-items: center; justify-content: flex-start; gap: 8px;
  flex: 0 0 auto; min-width: max-content; flex-wrap: nowrap; white-space: nowrap;
}
.review-head-meta > * { flex: 0 0 auto; }
.review-head-meta .discussion-time { white-space: nowrap; }
.discussion-time { font-size: 11px; color: var(--text-muted); line-height: 1.2; white-space: nowrap; }
.discussion-body { word-break: break-word; overflow-wrap: break-word; }
.discussion-body p { margin: 0; white-space: pre-wrap; line-height: 1.75; font-size: 14px; color: var(--text-primary); }
.discussion-link {
  display: inline-flex; align-items: center; gap: 4px;
  max-width: 100%;
  color: var(--discussion-link-color) !important;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--discussion-link-color) 68%, transparent);
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
  direction: ltr;
  unicode-bidi: isolate;
}
.discussion-link:hover,
.discussion-link:focus-visible { color: color-mix(in srgb, var(--discussion-link-color) 82%, white) !important; }
.discussion-link-favicon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; flex: 0 0 14px;
  color: currentColor;
}
.discussion-link-favicon > [data-discussion-favicon],
.discussion-link-favicon > [data-discussion-favicon-fallback] {
  display: block; width: 14px; height: 14px;
}
.discussion-link-favicon > [data-discussion-favicon] {
  background-position: center; background-repeat: no-repeat; background-size: contain;
}
.discussion-link-favicon > [data-discussion-favicon-fallback] { display: block; }
.discussion-link-favicon[data-favicon-loaded="true"] > [data-discussion-favicon-fallback] { display: none; }
.discussion-link-label {
  min-width: 0;
  max-width: min(62vw, 420px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.discussion-link-confirm-modal { max-width: 560px; width: min(560px, 100%); }
.discussion-link-confirm-body { gap: 12px; }
.discussion-link-confirm-message { margin: 0; color: var(--text-secondary); line-height: 1.7; }
.discussion-link-confirm-url {
  display: flex; align-items: flex-start; gap: 10px; width: 100%;
  padding: 12px; border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  background: var(--bg-card); text-align: left; overflow-wrap: anywhere;
}
.discussion-link-confirm-favicon { display: inline-flex; flex: 0 0 18px; width: 18px; height: 18px; margin-top: 2px; }
.discussion-link-confirm-favicon .discussion-link-favicon,
.discussion-link-confirm-favicon .discussion-link-favicon > [data-discussion-favicon],
.discussion-link-confirm-favicon .discussion-link-favicon > [data-discussion-favicon-fallback] {
  width: 18px; height: 18px;
}
.discussion-link-confirm-url-text {
  min-width: 0; color: var(--discussion-link-color); line-height: 1.55; word-break: break-all;
}
.discussion-video-toggle {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: fit-content; margin: 10px auto 0; padding: 6px 12px;
  border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  background: var(--bg-input); color: var(--text-secondary); cursor: pointer;
  font: inherit; font-size: 12px; font-weight: 700; line-height: 1.35;
}
.discussion-video-toggle:hover,
.discussion-video-toggle:focus-visible { border-color: var(--accent); color: var(--accent); }
.comment-actions,
.account-item-actions { position: relative; }
.discussion-video-toggle-in-actions {
  position: absolute; top: 50%; left: 50%; inset-inline-start: auto;
  width: auto; margin: 0; transform: translate(-50%, -50%);
}
.discussion-video-embed {
  width: min(100%, 640px); aspect-ratio: 16 / 9; margin: 12px auto 0;
  overflow: hidden; border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  background: #000;
}
.discussion-video-embed iframe { display: block; width: 100%; height: 100%; border: 0; }
.review-text-ltr { text-align: left; direction: ltr; unicode-bidi: plaintext; }
.review-text-rtl { text-align: right; direction: rtl; unicode-bidi: plaintext; }
.review-translation-text { margin-top: 10px !important; padding-top: 10px; border-top: 1px solid var(--border-color); }
.comment-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.comment-actions .left-actions { display: flex; align-items: center; gap: 8px; }
.comment-actions .left-actions .review-translation-model { flex: 0 1 auto; }
.comment-actions .right-actions { display: flex; align-items: center; gap: 12px; }
.comment-icon-btn {
  display: inline-flex; align-items: center; gap: 4px;
  min-width: 24px; min-height: 24px; padding: 2px;
  border: 0; background: transparent; color: var(--text-muted);
  border-radius: 0; cursor: pointer; font: inherit; line-height: 1;
}
.comment-icon-btn svg {
  width: 17px; height: 17px; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.comment-icon-btn[data-reaction-value="1"].active svg,
.comment-icon-btn[data-reaction-value="-1"].active svg { fill: currentColor; }
.comment-icon-btn:hover,
.comment-icon-btn.active { color: var(--accent); }
.comment-icon-btn.danger:hover { color: var(--color-danger); }
.dummy-react-btn { display: none; }
.comment-action-count { font-size: 11px; color: currentColor; line-height: 1; }
.review-line { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.source-badge.spoiler {
  color: var(--text-secondary);
}
.review-spoiler-box {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: transparent;
  padding: 0;
  height: 74px;
  max-height: 74px;
}
.review-spoiler-box.revealed {
  overflow: visible;
  height: auto;
  max-height: none;
}
.review-spoiler-content {
  padding: 10px 12px;
  opacity: 0.18;
  filter: blur(2px);
  pointer-events: none;
  height: 74px;
  max-height: 74px;
  overflow: hidden;
  transition: opacity 0.16s ease, filter 0.16s ease;
}
.review-spoiler-box.revealed .review-spoiler-content {
  opacity: 1;
  filter: none;
  pointer-events: auto;
  height: auto;
  max-height: none;
  overflow: visible;
}
.review-spoiler-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  background: rgba(16, 16, 18, 0.58);
  backdrop-filter: saturate(0.8);
}
.review-spoiler-box.revealed .review-spoiler-overlay {
  display: none;
}
.btn.review-spoiler-reveal {
  max-width: 100%;
  border-color: var(--border-color);
  background: var(--bg-input);
  color: var(--text-primary);
  white-space: normal;
  line-height: 1.6;
}
.review-stars { direction: ltr; color: var(--accent); letter-spacing: 0; font-size: 13px; }
.source-badge {
  display: inline-flex; align-items: center; height: 18px; padding: 1px 4px; border-radius: var(--radius-sm);
  font-size: 9px; line-height: 14px; color: var(--text-secondary); background: var(--bg-input); border: 1px solid var(--border-color);
}
.source-badge.local { color: var(--accent); }
.source-site-badge { direction: ltr; gap: 4px; }
.source-badge-logo { display: block; flex: 0 0 auto; width: 13px; height: 13px; object-fit: contain; }
.source-badge-icon { display: inline-flex; flex: 0 0 auto; width: 13px; height: 13px; color: var(--source-color, currentColor); }
.source-badge-icon svg { display: block; width: 100%; height: 100%; }
.source-badge-label { unicode-bidi: plaintext; }
.source-novelfire { --source-color: #ff6a3d; --source-logo-inner: #fff3ed; }
.source-novelupdates { --source-color: #6c63ff; --source-logo-inner: #f1efff; }
.source-external { --source-color: #94a3b8; --source-logo-inner: #f8fafc; }
.review-translation-model {
  --provider-color: var(--text-secondary);
  display: inline-flex; align-items: center; direction: ltr; gap: 4px;
  max-width: min(42vw, 260px); height: 18px; padding: 1px 4px; border-radius: var(--radius-sm);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 9px; line-height: 14px; color: var(--text-secondary);
  background: color-mix(in srgb, var(--accent) 9%, var(--bg-input));
  border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--border-color));
}
.review-translation-model.provider-openai { --provider-color: #fff; }
[data-theme="light"] .review-translation-model.provider-openai { --provider-color: #000; }
.review-translation-model.provider-codex { --provider-color: #fff; }
.review-translation-model.provider-anthropic { --provider-color: #d97757; }
.review-translation-model.provider-google { --provider-color: #8e75b2; }
.review-translation-model.provider-mimo { --provider-color: #ff6900; }
.review-translation-model.provider-deepseek { --provider-color: #5786fe; }
.review-translation-model.provider-mistral { --provider-color: #fa520f; }
.review-translation-model.provider-meta { --provider-color: #0467df; }
.review-translation-model.provider-xai { --provider-color: #e5e7eb; }
.review-translation-model.provider-qwen { --provider-color: #6950ef; }
.review-translation-model.provider-cohere { --provider-color: #ff4f4f; }
.review-translation-model.provider-microsoft { --provider-color: #00a4ef; }
.review-translation-model.provider-perplexity { --provider-color: #1fb8cd; }
.review-translation-model.provider-amazon { --provider-color: #ff9900; }
.review-translation-model.provider-openrouter { --provider-color: #94a3b8; }
.review-translation-model.provider-generic { --provider-color: #a855f7; }
.translation-provider-icon { display: inline-flex; flex: 0 0 auto; width: 13px; height: 13px; color: var(--provider-color); }
.translation-provider-icon svg { display: block; width: 100%; height: 100%; }
.translation-model-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; unicode-bidi: plaintext; }
.loading-state,
.empty-state.compact { padding: 22px; text-align: center; color: var(--text-muted); font-size: 13px; }
.auto-load-sentinel {
  min-height: 18px; padding: 10px; text-align: center;
  color: var(--text-muted); font-size: 12px;
}
.auto-load-sentinel.hidden { display: none; }
.novel-synopsis { color: var(--text-primary); line-height: 1.65; font-size: 14.5px; }
.synopsis-line { display: block; margin-bottom: 4px; }
/* الأسطر الفارغة في وصف الرواية تمثل فواصل الفقرات التي أدخلها الكاتب. */
.synopsis-gap { display: block; height: 0.85em; }
.cover-placeholder {
  width: 100%; aspect-ratio: 3/4; background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem; color: var(--text-muted); font-weight: 700;
}

/* ═══ Breadcrumb ═══ */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); margin-bottom: 16px; }
.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .current { color: var(--text-primary); }

/* ═══ لوحة التحكم ═══ */
.admin-layout { display: flex; min-height: calc(100vh - var(--navbar-height)); }
.admin-sidebar {
  width: 220px; background: var(--bg-sidebar); border-left: 1px solid var(--border-color);
  padding: 16px 0; flex-shrink: 0; position: sticky; top: 0;
  height: 100vh; overflow-y: auto;
}
.sidebar-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); padding: 0 14px; margin-bottom: 6px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 1px; }
.sidebar-link { display: flex; align-items: center; gap: 8px; padding: 9px 14px; font-size: 13px; color: var(--text-secondary); }

/* ═══ التقويم ═══ */
.schedule-tabs {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 12px;
  margin-bottom: 24px;
  justify-content: center;
}
.schedule-tabs::-webkit-scrollbar { height: 4px; }
.schedule-tabs::-webkit-scrollbar-track { background: transparent; }
.schedule-tabs::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; }

.schedule-tab {
  padding: 10px 24px;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: 30px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.3s ease;
}
.schedule-tab:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}
.schedule-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

@media (max-width: 768px) {
  .schedule-tabs {
    flex-wrap: nowrap;
    justify-content: space-between;
    gap: 2px;
    padding-bottom: 0;
    width: 100%;
  }
  .schedule-tab {
    padding: 8px 1px;
    font-size: 13px;
    font-weight: 700;
    flex: 1;
    text-align: center;
    border-radius: 8px;
  }
}
.sidebar-link:hover { color: var(--text-primary); background: var(--bg-card); }
.sidebar-link.active { color: var(--accent); background: var(--bg-card); border-right: 2px solid var(--accent); }
.admin-content { flex: 1; padding: 24px; min-width: 0; }
.admin-page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.admin-page-title { font-size: 1.1rem; }

/* ═══ الإحصائيات ═══ */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat-card {
  display: flex; align-items: center; gap: 12px; padding: 16px; background: var(--bg-card);
  border: 1px solid var(--border-color); border-radius: var(--radius-sm);
}
.stat-icon { font-size: 1.5rem; }
.stat-value { font-size: 1.3rem; font-weight: 700; color: var(--text-title); }
.stat-label { font-size: 11px; color: var(--text-secondary); }

/* ═══ إضافات الصفحة الرئيسية (Hero + Layout) ═══ */
.home-layout {
  display: block;
  width: 100%;
}

/* ═══ الواجهة البارزة (Hero Section) ═══ */
.hero-section {
  margin: 20px 0 40px;
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  display: flex;
  min-height: 320px;
}
.hero-bg {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background-size: cover; background-position: center;
  filter: blur(30px); opacity: 0.15; z-index: 1;
}
.hero-content-inner {
  position: relative; z-index: 2;
  display: flex; gap: 24px; padding: 30px; width: 100%; align-items: center;
}
.hero-content-inner > .responsive-picture { width: auto; flex: 0 0 auto; }
.hero-cover {
  width: 180px; aspect-ratio: 3/4; object-fit: cover; border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3); flex-shrink: 0;
  border: 1px solid var(--border-color);
}
.hero-info { display: flex; flex-direction: column; gap: 12px; }
.hero-title { font-size: 28px; font-weight: bold; color: var(--text-title); margin: 0; line-height: 1.3; }
.hero-synopsis { font-size: 15px; color: var(--text-secondary); line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.hero-meta { display: flex; gap: 12px; color: var(--text-muted); font-size: 14px; }
.hero-btn { margin-top: 10px; align-self: flex-start; padding: 10px 24px; font-size: 16px; font-weight: bold; background: var(--accent); color: var(--accent-text); border-radius: var(--radius-sm); text-decoration: none; transition: opacity 0.2s; }
.hero-btn:hover { opacity: 0.9; }

@media (max-width: 768px) {
  .hero-section { min-height: auto; margin-bottom: 20px; }
  .hero-content-inner { flex-direction: row; text-align: start; padding: 16px; gap: 12px; align-items: flex-start; }
  .hero-cover { width: 80px; }
  .hero-title { font-size: 18px; }
  .hero-synopsis { font-size: 13px; -webkit-line-clamp: 2; margin: 4px 0; }
  .hero-meta { font-size: 12px; gap: 8px; }
  .hero-btn { padding: 6px 14px; font-size: 13px; margin-top: 4px; align-self: flex-start; }
}

/* ═══ قائمة المراتب (Leaderboard) ═══ */
.leaderboard-widget {
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  position: sticky;
  top: 80px;
}
.widget-title {
  font-size: 18px; font-weight: bold; color: var(--text-title);
  margin: 0 0 20px 0; padding-bottom: 10px; border-bottom: 1px dashed var(--border-color);
}
.leaderboard-item {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px; text-decoration: none;
  transition: transform 0.2s ease;
}
.leaderboard-item:hover { transform: translateX(-4px); }
.leaderboard-item:last-child { margin-bottom: 0; }
.leaderboard-rank {
  font-size: 20px; font-weight: bold; color: var(--text-muted); min-width: 24px; text-align: center;
}
.leaderboard-item:nth-child(1) .leaderboard-rank { color: #ffd700; }
.leaderboard-item:nth-child(2) .leaderboard-rank { color: #c0c0c0; }
.leaderboard-item:nth-child(3) .leaderboard-rank { color: #cd7f32; }
.leaderboard-cover {
  width: 48px; height: 64px; border-radius: var(--radius-sm); object-fit: cover; flex-shrink: 0; border: 1px solid var(--border-color);
}
.leaderboard-info { flex: 1; min-width: 0; }
.leaderboard-title { font-size: 14px; font-weight: bold; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px; }
.leaderboard-views { font-size: 12px; color: var(--text-muted); }

/* ═══ تأثيرات Hover للبطاقات ═══ */
.novel-card { transition: transform 0.2s ease, box-shadow 0.2s ease; }
.novel-card:hover { transform: translateY(-4px); }

/* ═══ قائمة التحديثات الكلاسيكية (Feed List) ═══ */
.feed-header {
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border-color);
}
.feed-title {
  font-size: 20px;
  font-weight: bold;
  color: var(--text-title);
  margin: 0;
}
.feed-list {
  display: flex;
  flex-direction: column;
}
.feed-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px;
  border-bottom: 1px dashed var(--border-color);
  text-decoration: none;
  transition: background 0.2s ease;
}
.feed-item:hover {
  background: var(--bg-input);
}
.feed-item:last-child {
  border-bottom: none;
}
.feed-cover {
  width: 40px;
  height: 56px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}
.feed-cover-link {
  display: block;
  flex: 0 0 auto;
  line-height: 0;
  border-radius: 4px;
  text-decoration: none;
}
.feed-cover-link > .responsive-picture { width: 100%; height: 100%; }
.feed-cover-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.feed-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.feed-novel-title {
  font-size: 15px;
  font-weight: bold;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.feed-chapter {
  font-size: 13px;
  color: var(--text-secondary);
}
.feed-time {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* components.css */
/* ═══ بطاقة الرواية — بسيطة مثل NovelFire ═══ */
.novel-card { position: relative; }
.novel-card a { display: block; color: inherit; }
.novel-card:hover .card-title { color: var(--accent); }

.cover-wrap {
  position: relative; aspect-ratio: 3/4.3; overflow: hidden;
  border-radius: var(--radius-sm); background: var(--bg-card); margin: 0;
}
.cover-wrap::after {
  content: ''; position: absolute; bottom: 0; left: 0; width: 100%; height: 60%;
  background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0) 100%);
  z-index: 1; pointer-events: none;
}
.cover-wrap img { width: 100%; height: 100%; object-fit: cover; }
.cover-wrap > .responsive-picture { height: 100%; }

.cover-wrap .cover-placeholder {
  width: 100%; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px;
  padding: 12px 8px; text-align: center; border-radius: 0;
  aspect-ratio: unset; border: none;
}
.cover-placeholder .ph-title { font-size: 13px; font-weight: 700; color: rgba(255,255,255,0.85); line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.cover-placeholder .ph-author { font-size: 10px; color: rgba(255,255,255,0.4); }

.cover-badge {
  position: absolute; top: 6px; right: 6px; z-index: 3;
  padding: 1px 6px; border-radius: 3px; font-size: 10px; font-weight: 600;
  background: var(--color-success); color: #fff;
}

.card-title {
  position: absolute; bottom: 8px; left: 8px; right: 8px; z-index: 2;
  font-size: 12.5px; font-weight: 600; color: #fff; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; overflow-wrap: anywhere; margin: 0; text-shadow: 0 1px 3px rgba(0,0,0,0.9);
}

/* ضبط اتجاه اسم الرواية داخل بطاقة الصفحة الرئيسية فقط عند الحاجة */
.card-title[dir] {
  unicode-bidi: plaintext;
}

.card-meta { font-size: 11px; color: var(--text-muted); margin-top: 6px; text-align: center; }

/* ═══ الأزرار ═══ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 16px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer;
}
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover { opacity: 0.9; }
.btn-secondary { background: var(--bg-input); color: var(--text-primary); border-color: var(--border-color); }
.btn-secondary:hover { border-color: var(--accent); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-ghost { background: none; color: var(--text-secondary); border-color: var(--border-color); }
.btn-lg { padding: 10px 24px; font-size: 14px; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.novel-action-btn {
  min-height: 36px; padding: 7px 16px; color: var(--text-primary); font-size: 13.5px; font-weight: 700;
  line-height: 1.2; white-space: nowrap;
}
.novel-action-btn svg { flex-shrink: 0; }
.continue-reading-btn { flex-direction: row; gap: 6px; }
.reading-action-main { font-size: 13.5px; font-weight: 700; }
.reading-action-sub { font-size: 11px; font-weight: 600; opacity: 0.8; }

/* ═══ الشارات ═══ */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 3px; font-size: 11px; font-weight: 600; }
.badge-success { background: rgba(52,199,89,0.15); color: var(--color-success); }
.badge-warning { background: rgba(255,204,0,0.15); color: var(--color-warning); }
.badge-ghost { background: rgba(128,128,128,0.12); color: var(--text-muted); border: 1px solid var(--border-color); }

/* ═══ التصنيفات ═══ */
.genres-bar { display: flex; gap: 6px; flex-wrap: wrap; padding: 12px; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-sm); margin-bottom: 16px; }
.genre-tag { padding: 4px 12px; border-radius: var(--radius-sm); font-size: 12px; background: var(--bg-input); color: var(--text-secondary); border: 1px solid transparent; cursor: pointer; }
.genre-tag:hover { color: var(--accent); border-color: var(--border-color); }
.genre-tag.active { background: var(--accent); color: var(--accent-text); }

/* تاقات الرواية */
.novel-tag {
  padding: 4px 12px; border-radius: 99px; font-size: 11px;
  background: var(--bg-input); color: var(--text-secondary);
  border: 1px solid var(--border-color); cursor: default;
  transition: all 0.15s ease;
}
.novel-tag:hover { color: var(--text-primary); border-color: var(--accent); }

/* أسماء بديلة */
.alt-names {
  font-size: 13.5px; color: var(--text-secondary); line-height: 1.6;
  margin: -4px 0 8px; font-style: italic; font-weight: 500;
}

/* ═══ الفلاتر ═══ */
.filters-bar { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; padding: 10px; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-sm); }
.filter-group { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.filter-group label { color: var(--text-muted); font-weight: 500; white-space: nowrap; }
.filter-group select { padding: 5px 10px; font-size: 12px; border-radius: var(--radius-sm); }

/* ═══ قائمة الفصول ═══ */
.chapters-list { border: 1px solid var(--border-color); border-radius: var(--radius-sm); overflow: hidden; }
.chapters-scroll-region {
  /* نطاق التصفح يعرض عشرة صفوف ونصفًا، ليظهر جزء واضح من الفصل التالي. */
  max-height: 441px;
  overflow-y: scroll;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
  -webkit-overflow-scrolling: touch;
}
.chapters-scroll-region::-webkit-scrollbar { width: 6px; }
.chapters-scroll-region::-webkit-scrollbar-track { background: transparent; }
.chapters-scroll-region::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 999px;
}
.chapters-scroll-region:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 768px) {
  .chapters-scroll-region { max-height: 441px; }
}
.chapter-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; border-bottom: 1px solid var(--border-color);
}
.chapter-item:last-child { border-bottom: none; }
.chapter-item:hover { background: var(--bg-card-hover); }
.chapter-item a { font-size: 13px; }
.chapter-item a:hover { color: var(--accent); }
.chapters-scroll-region .chapter-title {
  min-width: 0; flex: 1 1 auto; white-space: normal;
  overflow-wrap: anywhere; word-break: break-word; line-height: 1.6;
}
.chapter-meta {
  display: inline-flex; align-items: center; justify-content: flex-start; gap: 8px;
  flex: 0 0 auto; min-width: 0;
}
.chapter-date { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.chapter-read-state {
  display: inline-flex; align-items: center; white-space: nowrap;
  padding: 2px 7px; border: 1px solid color-mix(in srgb, var(--accent) 60%, transparent);
  border-radius: 999px; color: var(--accent); background: var(--bg-input);
  font-size: 10px; font-weight: 700;
}
.chapter-item.is-last-read {
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-card));
  box-shadow: inset -3px 0 var(--accent);
}
.chapter-item.is-last-read .chapter-title { color: var(--accent); font-weight: 700; }

/* ═══ بطاقات جدول الفصول ═══ */
.schedule-content .novels-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.schedule-card {
  display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 12px;
  padding: 12px; background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}
.schedule-cover {
  display: block; aspect-ratio: 3/4; overflow: hidden; border-radius: var(--radius-sm);
  background: var(--bg-input);
}
.schedule-cover img { width: 100%; height: 100%; object-fit: cover; }
.schedule-cover > .responsive-picture { height: 100%; }
.schedule-card-body { min-width: 0; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.schedule-novel-title { color: var(--text-primary); font-size: 13px; font-weight: 800; line-height: 1.45; }
.schedule-chapter-title { color: var(--text-secondary); font-size: 12px; line-height: 1.5; }
.schedule-author { color: var(--text-muted); font-size: 11px; }
.schedule-time { display: flex; align-items: center; gap: 8px; color: var(--accent); font-size: 12px; font-weight: 700; }
.schedule-disabled-action { opacity: 0.75; cursor: default; pointer-events: none; }

/* ═══ أدوات إدارة الفصول ═══ */
.time-preset-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.admin-checkbox-row {
  display: flex; align-items: center; gap: 8px; margin: 8px 0 14px;
  color: var(--text-secondary); font-size: 13px;
}
.chapter-image-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.admin-chapter-preview {
  max-height: 70vh; overflow: auto; padding: 14px; border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); background: var(--bg-body); color: var(--text-primary);
  font-family: var(--font-reading); line-height: 1.9; font-size: 17px;
}
.admin-chapter-preview p { margin-bottom: 1em; }
.admin-chapter-preview .chapter-image-block { margin: 24px 0; text-align: center; }
.admin-chapter-preview .chapter-image-block img {
  max-width: 100%; max-height: 70vh; border-radius: 6px; border: 1px solid var(--border-color);
}
.admin-chapter-preview .chapter-image-block figcaption { margin-top: 8px; color: var(--text-muted); font-size: 12px; }

/* ═══ ترقيم الصفحات ═══ */
.pagination { display: flex; align-items: center; justify-content: center; gap: 3px; margin-top: 24px; }
.pagination button, .pagination a {
  min-width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 500;
  color: var(--text-secondary); background: var(--bg-card); border: 1px solid var(--border-color);
  text-decoration: none;
}
.pagination button:hover:not(.disabled):not(.active), .pagination a:hover:not(.disabled):not(.active) { color: var(--accent); border-color: var(--accent); }
.pagination button.active, .pagination a.active { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.pagination button.disabled, .pagination a.disabled { opacity: 0.3; pointer-events: none; }

/* ═══ حالة فارغة ═══ */
.empty-state { text-align: center; padding: 40px 16px; color: var(--text-secondary); }

/* صفحات المؤلفين والتصنيفات والوسوم */
.taxonomy-header { margin-bottom: 24px; }
.taxonomy-header h1 { margin: 0 0 8px; font-size: clamp(1.35rem, 2.5vw, 1.8rem); }
.taxonomy-header p { margin: 0; color: var(--text-secondary); line-height: 1.8; }
.novel-related-section[data-ssr-hidden="true"] { display: none; }
.novel-related-section { margin-top: 8px; }
.novel-related-section .section-header { margin-bottom: 16px; }
.novel-taxonomy-links { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.novel-taxonomy-group { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.novel-taxonomy-group .genre-tag { cursor: pointer; }
.novel-taxonomy-label { color: var(--text-muted); font-size: 12px; font-weight: 600; }
.novel-taxonomy-group a { text-decoration: none; }

/* ═══ جداول الإدارة ═══ */
.admin-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.admin-toolbar .search-input { width: 100%; max-width: 360px; padding: 8px 14px; }
.admin-inline-setting { display: inline-flex; align-items: center; gap: 8px; color: var(--text-secondary); font-size: 12px; font-weight: 700; white-space: nowrap; }
.admin-inline-setting select { min-width: 110px; }
.admin-table-wrap { overflow-x: auto; border: 1px solid var(--border-color); border-radius: var(--radius-sm); }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th { text-align: right; padding: 10px 14px; background: var(--bg-card); color: var(--text-muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border-color); }
.admin-table td { padding: 10px 14px; border-bottom: 1px solid var(--border-color); }
.admin-table tr:hover td { background: var(--bg-card-hover); }
.admin-table .actions { display: flex; gap: 4px; }
.admin-check-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px;
}
.admin-check-grid label {
  min-height: 38px; display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); background: var(--bg-card);
  color: var(--text-secondary); font-size: 13px;
}
.admin-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.task-title { display: block; color: var(--text-primary); margin-bottom: 4px; }
.task-details-preview {
  max-width: 520px; color: var(--text-muted); font-size: 12px; line-height: 1.55;
  white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* ═══ Modal ═══ */
.modal-overlay { position: fixed; inset: 0; background: var(--bg-overlay); z-index: 5000; display: none; align-items: center; justify-content: center; padding: 16px; }
.modal-overlay.open { display: flex; }
.modal { background: var(--bg-panel); border: 1px solid var(--border-color); border-radius: var(--radius-md); width: 100%; max-height: 90vh; display: flex; flex-direction: column; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px; border-bottom: 1px solid var(--border-color); flex-shrink: 0; }
.modal-header h2 { font-size: 1rem; }
.modal-close { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; font-size: 16px; color: var(--text-muted); }
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 16px; overflow-y: auto; flex: 1; }
.modal-footer { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 16px; border-top: 1px solid var(--border-color); flex-shrink: 0; }

/* ═══ نماذج ═══ */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.form-group input, .form-group select, .form-group textarea { width: 100%; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ═══ منطقة السحب ═══ */
.drop-zone { border: 2px dashed var(--border-color); border-radius: var(--radius-sm); padding: 32px 16px; text-align: center; color: var(--text-muted); cursor: pointer; }
.drop-zone:hover, .drop-zone.dragover { border-color: var(--accent); color: var(--accent); }

/* ═══ روابط المصادر الخارجية ═══ */
.ext-links { display: flex; gap: 8px; flex-wrap: wrap; }
.ext-link {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 0; align-self: auto;
  font-size: 13px; font-weight: 500; color: var(--text-secondary);
  text-decoration: none; transition: all 0.15s ease;
  border-bottom: 1px dashed var(--text-muted);
}
.ext-link:hover {
  color: var(--accent); border-color: var(--accent);
}
.ext-icon { font-size: 13px; }
.ext-link-nu .ext-icon { font-size: 11px; letter-spacing: -0.5px; }
.ext-link .source-link-logo {
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 14px; width: 14px; height: 14px;
}
.ext-link .source-link-logo img {
  display: block; width: 14px; height: 14px; object-fit: contain;
}

/* ═══ بانر آخر خبر ═══ */
.novel-news-banner {
  padding: 12px 16px; margin-bottom: 20px;
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); border-right: 3px solid var(--text-muted);
}
.news-title { font-size: 14px; font-weight: 700; color: var(--text-title); margin-bottom: 4px; }
.news-content { font-size: 13px; color: var(--text-secondary); line-height: 1.6; }
.news-date { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

/* ═══ نظام التبويبات ═══ */
.novel-tabs { margin-top: 8px; }
.tabs-header {
  display: flex; gap: 0; border-bottom: 1px solid var(--border-color);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.tab-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; font-size: 13px; font-weight: 600;
  color: var(--text-secondary); background: none; border: none;
  border-bottom: 2px solid transparent; cursor: pointer;
  white-space: nowrap; transition: color 0.15s, border-color 0.15s;
}
.tab-icon { display: block; flex: 0 0 16px; width: 16px; height: 16px; color: currentColor; }
.novel-tabs .tab-btn { padding-inline: 14px; }
@media (max-width: 768px) {
  .novel-tabs .tab-btn { padding-inline: 10px; }
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--text-title); border-bottom-color: var(--accent); }
.tab-panel { display: none; padding: 16px 0; }
.tab-panel.active { display: block; }
/* يبقى محدد نطاق الفصول في منتصف المسافة بين التبويبات والقائمة،
   بدل أن تدفعه مسافة الحشو العلوية إلى الأسفل. */
.tab-panel[data-tab="chapters"] { padding-top: 0; }

.chapters-comments-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
  scroll-margin-top: calc(var(--navbar-height) + 16px);
}
.chapters-comments-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}
.chapters-comments-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
.chapters-comments-title {
  margin: 0;
  color: var(--text-title);
  font-size: 17px;
  line-height: 1.4;
}

/* ═══ القاموس ═══ */
.glossary-section-title { font-size: 14px; font-weight: 700; margin-bottom: 12px; color: var(--text-title); }
.glossary-section-title:not(:first-child) { margin-top: 24px; }
.glossary-filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.glossary-filter {
  padding: 4px 12px; font-size: 12px; border-radius: var(--radius-sm);
  background: var(--bg-input); border: 1px solid var(--border-color);
  color: var(--text-secondary); cursor: pointer;
}
.glossary-filter:hover { color: var(--text-primary); }
.glossary-filter.active { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.glossary-table-wrapper { overflow-x: auto; border: 1px solid var(--border-color); border-radius: var(--radius-sm); }
.glossary-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.glossary-table th {
  text-align: right; padding: 8px 12px; background: var(--bg-card);
  color: var(--text-muted); font-weight: 600; font-size: 11px;
  border-bottom: 1px solid var(--border-color);
}
.glossary-table td { padding: 8px 12px; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
.glossary-table tr:last-child td { border-bottom: none; }
.glossary-table tr:hover td { background: var(--bg-card-hover); }
.glossary-img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; vertical-align: middle; margin-left: 6px; }
.term-type-badge {
  display: inline-block; padding: 2px 10px; font-size: 10px; font-weight: 700;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 4px; color: var(--text-primary); letter-spacing: 0.3px;
}

/* ═══ الويكي ═══ */
.wiki-content { font-size: 14px; line-height: 1.8; color: var(--text-primary); }
.wiki-content h2 { font-size: 16px; font-weight: 700; margin: 16px 0 8px; color: var(--text-title); }
.wiki-content h3 { font-size: 14px; font-weight: 700; margin: 12px 0 6px; color: var(--text-title); }
.wiki-content p { margin-bottom: 10px; }

/* ═══ التغريدات ═══ */
.embeds-list { display: flex; flex-direction: column; gap: 16px; }
.embed-item { max-width: 550px; }
.embed-profile-link {
  display: flex; align-items: center; gap: 12px; padding: 14px 18px;
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: 8px; text-decoration: none; transition: all 0.15s ease;
}
.embed-profile-link:hover { border-color: var(--text-muted); background: var(--bg-card-hover); }
.embed-profile-icon {
  font-size: 20px; font-weight: 900; color: var(--text-primary);
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.05); border-radius: 50%;
}
.embed-profile-handle { font-size: 14px; font-weight: 700; color: var(--text-primary); flex: 1; }
.embed-profile-action { font-size: 12px; color: var(--text-muted); }



/* ═══ تحذير الحرق (Spoiler Wall) ═══ */
.spoiler-wall {
  display: flex; align-items: center; justify-content: center;
  padding: 48px 20px; text-align: center;
}
.spoiler-wall.revealed { display: none; }
.spoiler-wall.revealed + .spoiler-content { display: block; }
.spoiler-content { display: none; }
.spoiler-warning {
  max-width: 400px;
}
.spoiler-icon {
  font-size: 40px; margin-bottom: 12px; opacity: 0.6;
}
.spoiler-title {
  font-size: 16px; font-weight: 700; color: var(--text-title); margin-bottom: 8px;
}
.spoiler-desc {
  font-size: 13px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 16px;
}
.spoiler-btn {
  padding: 8px 24px; font-size: 13px;
}

/* ═══ رابط المؤلف ═══ */
.author-link {
  color: var(--text-primary); font-weight: 600;
  border-bottom: 1px dashed var(--text-muted);
  transition: color 0.15s, border-color 0.15s;
}
.author-link:hover { color: var(--accent); border-color: var(--accent); }

/* ═══ تحميل التغريدات ═══ */
.embed-loading {
  padding: 24px 16px; text-align: center; font-size: 13px;
  color: var(--text-muted); background: var(--bg-card);
  border: 1px solid var(--border-color); border-radius: 8px;
}
.embed-timeline { max-width: 550px; }

/* ═══ صفحات حساب المستخدم العامة: المكتبة وسجل القراءة ═══ */
.account-page-header {
  display: flex; flex-direction: column; gap: 6px;
  margin: 4px 0 18px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}
.account-page-header h1 { font-size: 1.25rem; color: var(--text-title); margin: 0; }
.account-page-header p { color: var(--text-secondary); font-size: 13px; margin: 0; line-height: 1.7; }
.account-page-title { margin: 4px 0 18px; font-size: 1.25rem; color: var(--text-title); }
.account-root { min-height: 260px; }
.account-toolbar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.account-filter {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 34px; padding: 0 12px;
  border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  background: var(--bg-card); color: var(--text-secondary);
  font-size: 12px; font-weight: 700; cursor: pointer;
}
.account-filter span {
  min-width: 22px; height: 20px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px; background: var(--bg-input); color: var(--text-muted);
  font-size: 11px;
}
.account-filter:hover,
.account-filter.active {
  color: var(--text-primary); border-color: var(--accent);
}
.account-list {
  display: flex; flex-direction: column; gap: 10px;
}
.account-item {
  display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 12px;
  padding: 12px; border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); background: var(--bg-card);
  position: relative;
}
.account-cover {
  width: 74px; aspect-ratio: 3 / 4; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); background: var(--bg-input);
  color: var(--text-muted); font-size: 24px; font-weight: 800;
}
.account-cover img { width: 100%; height: 100%; object-fit: cover; }
.account-cover > .responsive-picture { width: 100%; height: 100%; }
.account-item-body { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.account-item-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px;
}
.account-item-title {
  min-width: 0; color: var(--text-primary); font-size: 15px; font-weight: 800;
  line-height: 1.5; overflow-wrap: anywhere;
}
.account-item-title:hover { color: var(--accent); }
.account-status {
  flex-shrink: 0; min-height: 24px; padding: 3px 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); border: 1px solid var(--border-color);
  color: var(--text-secondary); background: var(--bg-input);
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.account-item-meta {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px;
  color: var(--text-muted); font-size: 12px; line-height: 1.7;
}
.account-actions {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.account-actions .btn {
  min-height: 32px; display: inline-flex; align-items: center; justify-content: center;
  padding: 0 12px; font-size: 12px; font-weight: 700;
}
.account-progress {
  height: 6px; overflow: hidden; border-radius: 999px;
  background: var(--bg-input); border: 1px solid var(--border-color);
}
.account-progress span {
  display: block; height: 100%; background: var(--accent);
}
.account-empty {
  padding: 36px 16px; min-height: 180px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  text-align: center; border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); background: var(--bg-card);
}
.account-empty h2 { margin: 0; color: var(--text-primary); font-size: 17px; }
.account-empty p { margin: 0; color: var(--text-secondary); max-width: 520px; line-height: 1.8; font-size: 13px; }
.library-toggle-btn.is-active {
  border-color: var(--accent); color: var(--accent) !important;
}
.library-toggle-btn:disabled {
  opacity: 0.65; cursor: wait;
}
.library-choice-modal { max-width: 480px; }
.library-choice-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px;
}
.library-choice-option {
  min-height: 54px; padding: 10px 12px;
  border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  background: var(--bg-card); color: var(--text-primary);
  text-align: center; cursor: pointer;
}
.library-choice-option:hover,
.library-choice-option.active {
  border-color: var(--accent); color: var(--accent); background: var(--bg-input);
}
.rating-score { font-weight: 800; color: inherit; }

/* ═══ التعليقات والبلاغات داخل صفحة الرواية ═══ */
.comment-replies {
  margin-top: 16px;
  background: var(--bg-card); 
  
  /* حواف البطاقة من اليمين والأعلى والأسفل فقط (اليسار مفتوح) */
  border: 1px solid var(--border-color);
  border-left: none; 
  
  /* زوايا دائرية من اليمين فقط (بما أن اتجاه الموقع من اليمين لليسار، ستظهر على اليمين) */
  /* الترتيب: أعلى-يسار، أعلى-يمين، أسفل-يمين، أسفل-يسار */
  border-radius: 0 var(--radius-lg) 0 0;
  
  /* امتداد البطاقة لليسار لتتجاوز بادينغ الأب (12px) وتلتصق بالحافة */
  margin-right: 20px; /* مسافة بادئة من اليمين لتمييز الردود عن التعليق الأساسي */
  margin-left: -12px; 
  
  /* تمت إزالة البادينغ من الحاوية لكي تمتد خطوط الفواصل للأطراف */
  padding: 0;
  
  display: flex; flex-direction: column; gap: 0;
}
.toggle-replies-btn:hover {
  background-color: var(--bg-hover) !important;
}
.comment-reply-item {
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
  background: transparent !important;
  border: none !important;
  /* إضافة البادينغ داخل كل رد ليكون الخط الفاصل متصلاً للأطراف */
  padding: 12px 16px 12px 28px !important;
  border-radius: 0 !important;
}
.comment-reply-item:not(:last-child) {
  border-bottom: 1px solid var(--border-color) !important;
  margin-bottom: 0 !important;
}
.comment-reply-item .discussion-avatar {
  width: 32px !important;
  height: 32px !important;
  border-radius: 50% !important;
  background: var(--bg-input);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0 !important;
}
.discussion-demo-note {
  padding: 10px 12px; border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm); color: var(--text-muted);
  font-size: 12px; background: var(--bg-card);
}
.react-comment-btn.active { color: var(--accent); }
.tags-note {
  margin: 0 20px 4px; color: var(--text-secondary);
  font-size: 13px; line-height: 1.8;
}
.report-choice-modal { max-width: 460px; }
.report-reasons {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.report-reasons label {
  min-height: 38px; display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); background: var(--bg-card);
  color: var(--text-secondary); font-size: 13px; cursor: pointer;
}
.report-reasons label:hover { color: var(--text-primary); border-color: var(--accent); }

/* ═══ نظام الزخارف الموسمية: طبقات خام قابلة للتصميم لاحقًا ═══ */
#celebration-decor {
  position: fixed; inset: 0; pointer-events: none; z-index: 900;
}
.celebration-strip,
.celebration-side,
.celebration-background,
.celebration-particles {
  position: fixed; pointer-events: none;
}
.celebration-strip-header { top: 0; left: 0; right: 0; height: 48px; }
.celebration-strip-footer { bottom: 0; left: 0; right: 0; height: 36px; }
.celebration-side-start { top: 0; bottom: 0; right: 0; width: 42px; }
.celebration-side-end { top: 0; bottom: 0; left: 0; width: 42px; }
.celebration-background { inset: 0; opacity: 0.18; }
.celebration-particles { inset: 0; overflow: hidden; }
body.celebration-theme-winter .celebration-particles {
  background-image:
    radial-gradient(circle, rgba(255,255,255,0.9) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(255,255,255,0.55) 0 1px, transparent 1.5px);
  background-size: 42px 42px, 74px 74px;
  animation: celebrationSnow 18s linear infinite;
}
body[data-celebration-intensity="low"] .celebration-particles { opacity: 0.35; }
body[data-celebration-intensity="medium"] .celebration-particles { opacity: 0.55; }
body[data-celebration-intensity="high"] .celebration-particles { opacity: 0.85; }
@keyframes celebrationSnow {
  from { background-position: 0 0, 0 0; }
  to { background-position: 0 260px, 0 420px; }
}

/* ═══ ثيم رمضان (Ramadan Theme) ═══ */
body.celebration-theme-ramadan .celebration-strip-header {
  background: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.5), transparent);
  height: 2px;
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
}
body.celebration-theme-ramadan .celebration-strip-footer {
  background: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.2), transparent);
  height: 1px;
}
body.celebration-theme-ramadan .celebration-side-start::before,
body.celebration-theme-ramadan .celebration-side-end::before {
  content: '';
  position: absolute;
  top: 0;
  width: 1px;
  height: 150px;
  background: linear-gradient(to bottom, rgba(212, 175, 55, 0.6) 0%, rgba(212, 175, 55, 0.1) 100%);
}
body.celebration-theme-ramadan .celebration-side-start::after,
body.celebration-theme-ramadan .celebration-side-end::after {
  content: '';
  position: absolute;
  top: 150px;
  width: 12px;
  height: 12px;
  background: transparent;
  border: 1px solid rgba(212, 175, 55, 0.8);
  border-radius: 2px;
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.4), inset 0 0 6px rgba(212, 175, 55, 0.2);
  transform: rotate(45deg);
}
body.celebration-theme-ramadan .celebration-side-start::before { right: 20px; }
body.celebration-theme-ramadan .celebration-side-start::after { right: 14px; }
body.celebration-theme-ramadan .celebration-side-end::before { left: 20px; }
body.celebration-theme-ramadan .celebration-side-end::after { left: 14px; }

/* زخرفة إسلامية هندسية شفافة جداً في الخلفية (مشربية/Lattice) */
body.celebration-theme-ramadan .celebration-background {
  background-image: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg stroke='%23d4af37' stroke-width='1' fill='none' opacity='0.7'%3E%3Ccircle cx='0' cy='0' r='20'/%3E%3Ccircle cx='40' cy='0' r='20'/%3E%3Ccircle cx='0' cy='40' r='20'/%3E%3Ccircle cx='40' cy='40' r='20'/%3E%3Ccircle cx='20' cy='20' r='20'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 40px 40px;
}

body[data-celebration-intensity="low"].celebration-theme-ramadan .celebration-background { opacity: 0.05 !important; }
body[data-celebration-intensity="medium"].celebration-theme-ramadan .celebration-background { opacity: 0.2 !important; }
body[data-celebration-intensity="high"].celebration-theme-ramadan .celebration-background { opacity: 0.5 !important; }

/* زخرفة الأزرار وحقول البحث/الإدخال */
body.celebration-theme-ramadan .btn,
body.celebration-theme-ramadan button,
body.celebration-theme-ramadan input,
body.celebration-theme-ramadan select,
body.celebration-theme-ramadan textarea,
body.celebration-theme-ramadan .user-chip {
  background-image: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg stroke='%23d4af37' stroke-width='1' fill='none' opacity='0.2'%3E%3Ccircle cx='0' cy='0' r='20'/%3E%3Ccircle cx='40' cy='0' r='20'/%3E%3Ccircle cx='0' cy='40' r='20'/%3E%3Ccircle cx='40' cy='40' r='20'/%3E%3Ccircle cx='20' cy='20' r='20'/%3E%3C/g%3E%3C/svg%3E") !important;
  background-size: 30px 30px !important;
}

/* استثناء التعليقات والمراجعات من الزخارف لضمان وضوح القراءة والكتابة */
body.celebration-theme-ramadan .comment-form textarea,
body.celebration-theme-ramadan .comment-icon-btn,
body.celebration-theme-ramadan .comment-item button,
body.celebration-theme-ramadan .comment-replies button,
body.celebration-theme-ramadan .review-card button {
  background-image: none !important;
}

/* رفع صناديق التعليقات والمراجعات فوق طبقة الزخارف لمنع تداخل الزخرفة مع نصوص التعليقات */
body.celebration-theme-ramadan .discussion-container,
body.celebration-theme-ramadan .discussion-item,
body.celebration-theme-ramadan .comment-form {
  position: relative;
  z-index: 910;
}

/* ═══ صفحة الملف الشخصي ═══ */
.profile-root { display: flex; flex-direction: column; gap: 16px; }
.profile-hero {
  display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; gap: 14px;
  align-items: center; padding: 16px; border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); background: var(--bg-card);
  margin-bottom: 16px;
}
.profile-avatar {
  width: 76px; height: 76px; border-radius: 50%; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-input); color: var(--text-primary);
  font-size: 28px; font-weight: 800;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-avatar-input {
  display: none;
}
.profile-account-actions {
  margin-right: auto; display: flex; flex-direction: column; align-items: stretch; gap: 2px;
}
.profile-avatar-change-btn {
  min-height: 28px; padding: 2px 4px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: 12px; font-weight: 700; transition: color 0.2s, background 0.2s;
}
.profile-avatar-change-btn:hover,
.profile-avatar-change-btn:focus-visible {
  color: var(--accent); background: var(--bg-input); outline: none;
}
.profile-avatar-change-btn:disabled { opacity: 0.6; cursor: wait; }
.profile-avatar-status { min-height: 0; margin: 0; color: var(--text-secondary); font-size: 12px; }
.profile-avatar-status:empty { display: none; }
.profile-avatar-status.is-error { color: var(--danger, #d76a6a); }
.profile-main { min-width: 0; }
.profile-main h2 { margin: 0 0 6px; color: var(--text-title); font-size: 1.25rem; }
.profile-main p { margin: 0; color: var(--text-secondary); line-height: 1.7; font-size: 13px; overflow-wrap: anywhere; }
.profile-badge {
  min-height: 34px; display: inline-flex; align-items: center; justify-content: center;
  padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-color);
  background: var(--bg-input); color: var(--text-secondary); font-size: 12px; font-weight: 700;
}
.profile-stats-grid {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px;
}
.profile-stat {
  min-height: 74px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 1px solid var(--border-color); border-radius: var(--radius-sm); background: var(--bg-card);
}
.profile-stat strong { color: var(--text-primary); font-size: 18px; }
.profile-stat span { color: var(--text-muted); font-size: 11px; text-align: center; }
.profile-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px;
}
.profile-panel {
  min-height: 210px; border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); background: var(--bg-card); padding: 14px;
}
.profile-panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding-bottom: 8px; margin-bottom: 10px; border-bottom: 1px solid var(--border-color);
}
.profile-panel-head h2 { margin: 0; color: var(--text-primary); font-size: 15px; }
.profile-panel-head a { color: var(--accent); font-size: 12px; font-weight: 700; }
.profile-mini-list { display: flex; flex-direction: column; gap: 6px; }
.profile-mini-list a {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 38px; padding: 7px 0; border-bottom: 1px solid var(--border-color);
}
.profile-mini-list a:last-child { border-bottom: 0; }
.profile-mini-list span {
  min-width: 0; color: var(--text-primary); font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.profile-mini-list small {
  flex-shrink: 0; color: var(--text-muted); font-size: 11px; max-width: 45%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.profile-empty {
  min-height: 120px; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 13px; text-align: center;
}

/* responsive.css */
/* ═══ تابلت ═══ */
@media (max-width: 1024px) {
  .novels-grid { grid-template-columns: repeat(4, 1fr); }
  .admin-sidebar { width: 180px; }
  .novel-detail { grid-template-columns: 160px minmax(0, 1fr); }
}

/* ═══ موبايل أفقي / تابلت صغير ═══ */
@media (max-width: 768px) {
  /* لا تسمح لعناصر الصفحة بتوسيع عرض المستند خارج الشاشة. */
  html, body { max-width: 100%; overflow-x: hidden; }

  /* تبويب المراجعات: اترك مسافة صغيرة بين التبويبات ومصادر المراجعات. */
  .tab-panel[data-tab="reviews"] {
    padding-top: 0;
  }
  .tab-panel[data-tab="reviews"] .reviews-container {
    padding-top: 0;
  }
  .tab-panel[data-tab="reviews"] .review-source-tabs {
    margin-top: 8px;
    flex-wrap: nowrap;
    overflow-x: hidden;
    overflow-y: hidden;
    gap: 4px;
    padding: 4px;
  }
  .tab-panel[data-tab="reviews"] .review-source-tab {
    flex: 1 1 auto;
    min-width: 0;
    padding: 6px 5px;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* قرّب شريط تبويبات الرواية من الحافة اليمنى مع إبقاء هامش أيسر آمن. */
  .novel-tabs .tabs-header { margin-inline-start: -8px; }

  .novels-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }

  /* الهيدر */
  .site-logo { height: 34px; transform: translateY(5px); }
  .navbar-links {
    position: fixed; top: 0; bottom: 0; left: -280px; width: 280px; right: auto;
    background: var(--bg-panel); border-right: 1px solid var(--border-color); border-bottom: none; border-left: none;
    flex-direction: column; padding: 80px 16px 24px; z-index: 9999;
    box-shadow: 4px 0 20px rgba(0,0,0,0.5);
    transition: left 0.3s ease;
    display: flex; gap: 8px;
  }
  .navbar-links.open { left: 0; }
  
  /* زخرفة القائمة الجانبية للهاتف بثيم رمضان */
  body.celebration-theme-ramadan .navbar-links::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    background-image: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg stroke='%23d4af37' stroke-width='1.5' fill='none'%3E%3Ccircle cx='0' cy='0' r='20'/%3E%3Ccircle cx='40' cy='0' r='20'/%3E%3Ccircle cx='0' cy='40' r='20'/%3E%3Ccircle cx='40' cy='40' r='20'/%3E%3Ccircle cx='20' cy='20' r='20'/%3E%3C/g%3E%3C/svg%3E");
    background-size: 40px 40px;
  }
  body[data-celebration-intensity="low"].celebration-theme-ramadan .navbar-links::before { opacity: 0.05; }
  body[data-celebration-intensity="medium"].celebration-theme-ramadan .navbar-links::before { opacity: 0.1; }
  body[data-celebration-intensity="high"].celebration-theme-ramadan .navbar-links::before { opacity: 0.5; }
  
  .navbar-links a { 
    display: flex; align-items: center; gap: 12px;
    padding: 16px 20px; font-size: 1.15rem; color: var(--text-title); border-radius: var(--radius-md);
    transition: background 0.2s, color 0.2s; width: 100%; font-weight: 500;
  }
  .navbar-links a:hover { background: var(--bg-input); color: var(--accent); }
  .navbar-links .theme-toggle { margin-top: auto; margin-right: auto; margin-left: 0; margin-bottom: 10px; width: 44px; height: 40px; border-radius: var(--radius-md); background: var(--bg-input); border: 1px solid var(--border-color); }
  .mobile-search { display: block; width: 100%; margin-bottom: 16px; position: relative; }
  .mobile-search input { width: 100%; background: var(--bg-input); border: 1px solid var(--border-color); color: var(--text-title); padding: 8px 36px 8px 16px; border-radius: 99px; font-size: 0.95rem; }
  .mobile-search svg { position: absolute; inset-inline-start: 12px; inset-block-start: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
  .navbar-menu-btn { display: block; margin-right: auto; position: relative; z-index: 100000; }
  .navbar-search { display: none; }
  #theme-toggle { display: none; }
  .theme-toggle-mobile { display: flex !important; margin-top: auto; margin-right: auto; margin-left: 0; margin-bottom: 10px; }
  .user-nav-menu { width: auto; margin: 0 4px; display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
  .user-login-btn { width: auto; height: 40px; padding: 0 10px; justify-content: center; }
  .user-chip { max-width: 120px; height: 40px; justify-content: flex-start; }
  .user-logout-btn { width: 40px; height: 40px; }

  /* الحساب يظهر داخل القائمة الجانبية بدل ازدحام الشريط العلوي. */
  .navbar-links .mobile-user-menu { width: 100%; margin: 0 0 4px; }
  .navbar-links .mobile-user-menu .user-nav-menu {
    width: 100%; margin: 0; flex: 0 0 auto;
  }
  .navbar-links .mobile-user-menu .user-login-btn,
  .navbar-links .mobile-user-menu .user-chip {
    width: 100%; max-width: none; height: 44px; justify-content: flex-start; padding: 0 16px;
  }
  .navbar-links .mobile-user-menu .user-chip {
    font-size: 13px; font-weight: 600; color: var(--text-primary); text-decoration: none;
  }
  .navbar-links .mobile-user-menu .user-login-btn span { display: inline; }

  /* لوحة التحكم */
  .admin-layout { flex-direction: column; }
  .admin-sidebar {
    width: 100%; position: static; height: auto;
    border-left: none; border-bottom: 1px solid var(--border-color); padding: 8px 0;
  }
  .sidebar-nav { flex-direction: row; overflow-x: auto; gap: 2px; padding: 0 12px; }
  .sidebar-link { white-space: nowrap; border-right: none !important; padding: 6px 12px; font-size: 12px; }
  .sidebar-title { display: none; }

  /* ═══ أزرار الرواية والمكتبة ═══ */
  .novel-action-btn { min-height: 36px; font-size: 12px !important; }
  .reading-action-main { font-size: 12px !important; }
  .reading-action-sub { font-size: 10px !important; }
  .novel-action-btn .bookmark-icon { width: 18px !important; height: 18px !important; }
  .library-btn-text { transform: translateX(5px); }

  /* ═══ قائمة الروايات بصفحة الإدارة ═══ */
  .novels-table { font-size: 13px; }
  .novels-table th, .novels-table td { padding: 8px; }

  /* تفاصيل الرواية */
  .novel-detail { grid-template-columns: 130px minmax(0, 1fr); gap: 14px; }
  .novel-title { font-size: 1.1rem; }
  .user-rating-panel { gap: 8px; margin-bottom: 14px; }
  .user-rating-label { min-width: 62px; font-size: 12px; }
  .user-rating-star,
  .user-rating-clear { width: 25px; height: 25px; }
  .user-review-text { min-height: 76px; font-size: 13px; }
  .user-review-save { width: 100%; justify-content: center; }

  /* فلاتر */
  .filters-bar { flex-direction: column; align-items: stretch; gap: 8px; }
  .form-row { grid-template-columns: 1fr; }
  .account-item { grid-template-columns: 62px minmax(0, 1fr); padding: 10px; }
  .account-cover { width: 62px; }
  .account-item-head { flex-direction: column; gap: 6px; }
  .account-actions .btn { flex: none; width: auto; }
  .profile-hero { grid-template-columns: 58px minmax(0, 1fr); }
  .profile-avatar { width: 58px; height: 58px; font-size: 22px; }
  .profile-badge { grid-column: 1 / -1; justify-content: flex-start; }
  .profile-stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .profile-grid { grid-template-columns: 1fr; }
  .report-reasons { grid-template-columns: 1fr; }

  /* القارئ */
  .reader-container { padding: 4px 14px 60px; }
  .reader-content { font-size: var(--reader-font-size, 16px); line-height: var(--reader-line-height, 1.7); }
  .chapter-title { font-size: 1rem; }
}

/* ═══ موبايل صغير ═══ */
@media (max-width: 480px) {
  .novels-grid { grid-template-columns: repeat(auto-fill, minmax(85px, 1fr)); gap: 8px; }
  .card-title { font-size: 11px; }

  /* الهيدر */
  .navbar-logo a { font-size: 2.2rem; transform: translateY(-8px); }
  .theme-toggle { width: 34px; height: 36px; font-size: 14px; }
  .navbar-links .theme-toggle { height: 36px; }
  .user-login-btn { width: 36px; height: 36px; padding: 0; }
  .user-login-btn span { display: none; }
  .user-chip { max-width: 92px; height: 36px; }
  .user-logout-btn { width: 36px; height: 36px; }

  /* تفاصيل الرواية */
  .novel-detail { grid-template-columns: 100px minmax(0, 1fr); gap: 10px; }
  .novel-title { font-size: 1rem; margin-bottom: 8px; }
  .meta-item { font-size: 12px; }
  .novel-synopsis { font-size: 13px; line-height: 1.8; }
  .account-toolbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .account-filter { justify-content: space-between; padding: 0 10px; }
  .account-page-header h1 { font-size: 1.1rem; }
  .profile-stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile-mini-list a { flex-direction: column; align-items: flex-start; gap: 2px; }
  .profile-mini-list small { max-width: 100%; }

  /* لوحة التحكم */
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-page-header { flex-direction: column; align-items: flex-start; gap: 8px; }

  /* القارئ */
  .reader-container { padding: 4px 12px 50px; }
  .reader-content { font-size: var(--reader-font-size, 15px); line-height: var(--reader-line-height, 1.7); }
  .reader-header { margin-bottom: 12px; padding-bottom: 10px; }
  .chapter-title { font-size: 0.95rem; }
  .toolbar-nav-btn { padding: 6px 14px; font-size: 13px; }
  .settings-content { padding: 12px; }
  .setting-label { font-size: 12px; }

  /* التعليقات والمراجعات (دمج الصناديق) */
  .discussion-list {
    gap: 0 !important;
    /* تمتد البطاقة حتى حواف مساحة المحتوى كما في التصميم الأصلي. */
    margin-left: -12px;
    margin-right: -12px;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    border-radius: 0;
    overflow: hidden;
  }
  .discussion-item:not(.comment-reply-item) {
    border-radius: 0 !important;
    border: none !important;
    border-bottom: 3px solid var(--border-color) !important;
  }
  .discussion-item:not(.comment-reply-item):last-child {
    border-bottom: none !important;
  }
  
  /* تمديد بطاقة الردود لتلائم الجوال */
  .comment-replies {
    margin-right: 16px; /* بادئة بسيطة في الجوال */
    padding: 0;
    margin-left: -12px; /* تمديد الردود حتى حافة مساحة المحتوى */
  }
  .comment-reply-item {
    padding-right: 16px !important;
    padding-left: 16px !important;
  }
}

/* ═══ موبايل صغير جداً ═══ */
@media (max-width: 360px) {
  .novels-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .navbar-logo a { font-size: 1.8rem; transform: translateY(-6px); }
  .novel-detail { grid-template-columns: 90px minmax(0, 1fr); gap: 8px; }
  .toolbar-nav-btn { padding: 6px 10px; font-size: 12px; }
}

/* home.css */
/*
 * الصفحة الرئيسية
 *
 * هذه الأنماط مقصورة على .home-page حتى لا تغيّر تخطيط صفحات القراءة
 * والروايات والإدارة. التصميم يقدّم المحتوى مباشرة من SSR، بلا سلايدر أو
 * مساحات محجوزة تتبدّل بعد وصول JavaScript.
 */
.home-page .home-main {
  min-height: calc(100vh - var(--navbar-height));
  padding-block: clamp(20px, 3.5vw, 42px) clamp(42px, 6vw, 76px);
}

.home-page .home-container {
  max-width: 1120px;
}

.home-page .home-section {
  margin-block-end: clamp(34px, 5vw, 58px);
}

.home-page .home-section:last-of-type {
  margin-block-end: 0;
}

.home-page .home-section-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-block-end: 10px;
  padding-block-end: 0;
}

.home-page .home-eyebrow {
  margin-block-end: 3px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
}

.home-page .home-section-title {
  margin: 0;
  color: var(--text-title);
  font-size: clamp(1.15rem, 2vw, 1.42rem);
  line-height: 1.35;
}

.home-page .home-section-link {
  flex: 0 0 auto;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.home-page .home-section-link:hover,
.home-page .home-section-link:focus-visible {
  color: var(--accent);
}

/* متابعة القراءة */
.home-page .home-continue {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 22px;
  align-items: center;
  margin-block-end: clamp(30px, 4.5vw, 52px);
  padding: clamp(16px, 3vw, 24px);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-inline-start: 3px solid var(--accent);
  border-radius: var(--radius-md);
}

.home-page .home-continue-main {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.home-page .home-continue-cover,
.home-page .home-continue-cover-placeholder {
  display: block;
  width: 68px;
  height: 91px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--bg-input);
}

.home-page .home-continue-cover-placeholder {
  display: grid;
  place-items: center;
  padding: 7px;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  overflow-wrap: anywhere;
}

.home-page .home-continue-copy {
  min-width: 0;
}

.home-page .home-continue-title {
  margin-block: 2px 4px;
  color: var(--text-title);
  font-size: clamp(1rem, 2.2vw, 1.22rem);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.home-page .home-continue-chapter {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.55;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-page .home-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-block-start: 10px;
}

.home-page .home-progress-track {
  flex: 1 1 auto;
  height: 5px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--bg-input);
}

.home-page .home-progress-value {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.home-page .home-progress-label {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: 10px;
  direction: ltr;
}

.home-page .home-continue-action {
  min-width: 94px;
  min-height: 44px;
  padding: 9px 15px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-text);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

.home-page .home-continue-action:hover,
.home-page .home-continue-action:focus-visible {
  opacity: .86;
}

/* آخر التحديثات */
.home-page .home-updates-list {
  display: grid;
  align-items: start;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(10px, 1.8vw, 18px);
}

.home-page .home-update-item {
  min-width: 0;
}

.home-page .home-update-visual {
  position: relative;
  overflow: hidden;
  aspect-ratio: 3 / 4;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
}

.home-page .home-update-cover-link,
.home-page .home-update-cover,
.home-page .home-update-cover-placeholder {
  display: block;
}

.home-page .home-update-cover-link {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: var(--bg-input);
}

.home-page .home-update-cover-link .responsive-picture {
  display: block;
  width: 100%;
  height: 100%;
}

.home-page .home-update-cover,
.home-page .home-update-cover-placeholder {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.home-page .home-update-cover,
.home-page .home-update-cover-placeholder {
  border: 0;
}

.home-page .home-update-cover-placeholder {
  display: grid;
  place-items: center;
  padding: 12px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
  text-align: center;
  overflow-wrap: anywhere;
}

.home-page .home-update-cover-link:hover,
.home-page .home-update-cover-link:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.home-page .home-update-chapters {
  position: static;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
  margin: 0;
  padding: 0;
  background: none;
  color: #fff;
}

.home-page .home-update-overlay {
  position: absolute;
  inset-inline: 0;
  inset-block-end: 0;
  z-index: 1;
  min-width: 0;
  padding: 30px 8px 7px;
  background: linear-gradient(to top, rgba(0, 0, 0, .78), rgba(0, 0, 0, .42) 72%, transparent);
}

.home-page .home-update-title {
  display: -webkit-box;
  overflow: hidden;
  min-width: 0;
  margin: 0 0 5px;
  color: #fff;
  font-size: 13px;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .8);
}

.home-page .home-update-title a {
  color: inherit;
}

.home-page .home-update-title a:hover,
.home-page .home-update-title a:focus-visible {
  color: var(--accent);
}

.home-page .home-update-chapter {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-block: 5px;
  border-block-end: 0;
  color: #fff;
  line-height: 1.35;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .75);
}

.home-page .home-update-chapter:hover,
.home-page .home-update-chapter:focus-visible {
  border-radius: 2px;
  background: rgba(255, 255, 255, .12);
  color: #fff;
}

.home-page .home-update-chapter-number {
  flex: 0 0 auto;
  overflow: hidden;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-page .home-update-chapter-date {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  color: rgba(255, 255, 255, .75);
  font-size: 9px;
  text-overflow: ellipsis;
  text-align: start;
  white-space: nowrap;
}

/* الروايات المميزة */
.home-page .home-featured-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: clamp(10px, 1.8vw, 18px);
}

.home-page .home-featured-card {
  min-width: 0;
}

.home-page .home-featured-cover-link {
  display: block;
  overflow: hidden;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
}

.home-page .home-featured-cover,
.home-page .home-featured-cover-placeholder {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
}

.home-page .home-featured-cover-placeholder {
  display: grid;
  place-items: center;
  padding: 12px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
  text-align: center;
  overflow-wrap: anywhere;
}

.home-page .home-featured-cover-link:hover,
.home-page .home-featured-cover-link:focus-visible {
  border-color: var(--accent);
}

.home-page .home-featured-title {
  display: -webkit-box;
  overflow: hidden;
  margin-block-start: 8px;
  color: var(--text-title);
  font-size: 12px;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.home-page .home-featured-title a:hover,
.home-page .home-featured-title a:focus-visible {
  color: var(--accent);
}

.home-page .home-featured-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-block-start: 4px;
  color: var(--text-muted);
  font-size: 10px;
}

.home-page .home-featured-status {
  color: var(--color-success);
}

/* الأكثر قراءة */
.home-page .home-popular-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: clamp(18px, 4vw, 54px);
  border-block-start: 1px solid var(--border-color);
}

.home-page .home-popular-row {
  display: grid;
  grid-template-columns: 30px 50px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
  min-width: 0;
  padding-block: 12px;
  border-block-end: 1px solid var(--border-color);
}

.home-page .home-popular-row:hover,
.home-page .home-popular-row:focus-visible {
  background: var(--bg-card-hover);
}

.home-page .home-popular-rank {
  color: var(--text-muted);
  font-size: 18px;
  font-weight: 800;
  text-align: center;
  direction: ltr;
}

.home-page .home-popular-cover,
.home-page .home-popular-cover-placeholder {
  display: block;
  width: 50px;
  height: 67px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--bg-input);
}

.home-page .home-popular-cover-placeholder {
  display: grid;
  place-items: center;
  padding: 4px;
  color: var(--text-muted);
  font-size: 8px;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  overflow-wrap: anywhere;
}

.home-page .home-popular-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.home-page .home-popular-title {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-title);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.home-page .home-popular-title:hover,
.home-page .home-popular-title:focus-visible {
  color: var(--accent);
}

.home-page .home-popular-meta {
  color: var(--text-muted);
  font-size: 10px;
}

/* التصفح والفلاتر */
.home-page .home-browse {
  padding: clamp(16px, 3vw, 24px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
}

.home-page .home-browse .home-section-header {
  margin-block-end: 18px;
}

.home-page .home-browse-search {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding-inline: 13px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
}

.home-page .home-browse-search:focus-within {
  border-color: var(--accent);
}

.home-page .home-browse-search > svg {
  flex: 0 0 auto;
  color: var(--text-muted);
}

.home-page .home-browse-search input {
  min-width: 0;
  flex: 1 1 auto;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-primary);
}

.home-page .home-browse-search input:focus {
  border: 0;
}

.home-page .home-search-submit {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 5px 13px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 800;
}

.home-page .home-filter-links,
.home-page .home-genres {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-block-start: 14px;
}

.home-page .home-filter-links a,
.home-page .home-genre-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 5px 11px;
  border: 1px solid var(--border-color);
  border-radius: 99px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
}

.home-page .home-filter-links a:hover,
.home-page .home-filter-links a:focus-visible,
.home-page .home-genre-link:hover,
.home-page .home-genre-link:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}
.home-page .home-genre-link { cursor: pointer; text-decoration: none; }

.home-page .home-ad-slot {
  margin-block: 24px 0;
}

.home-page .home-ad-slot .ad-slot-frame {
  min-height: 90px;
}

.home-page .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* القائمة الجانبية في الصفحة الرئيسية: روابط حقيقية، لا حساب فقط. */
.home-page .navbar-links .sidebar-group {
  display: contents;
}

.home-page .navbar-links .sidebar-group-title,
.home-page .navbar-links .sidebar-only-link {
  display: none;
}

.home-page .footer-links {
  display: flex;
  gap: 16px;
  margin-block-end: 8px;
}

.home-page .footer-links a {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
}

.home-page .footer-links a:hover,
.home-page .footer-links a:focus-visible {
  color: var(--accent);
}

@media (max-width: 768px) {
  .home-page .home-main {
    padding-block-start: 18px;
  }

  .home-page .home-continue {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .home-page .home-continue-action {
    width: 100%;
  }

  .home-page .home-section-header {
    align-items: end;
  }

  .home-page .home-updates-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px 8px;
  }

  .home-page .home-featured-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px 9px;
  }

  .home-page .home-popular-list {
    grid-template-columns: 1fr;
  }

  /* توسيع القائمة يجعل الحساب والروابط قابلة للاستخدام دون ازدحام. */
  .home-page .navbar-links {
    align-items: stretch;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .home-page .navbar-links .sidebar-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
  }

  .home-page .navbar-links .sidebar-group-title {
    display: block;
    padding: 11px 20px 3px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 800;
  }

  .home-page .navbar-links .sidebar-only-link {
    display: flex;
  }

  .home-page .navbar-links .sidebar-group a {
    min-height: 44px;
  }
}

@media (max-width: 480px) {
  .home-page .home-container {
    padding-inline: 13px;
  }

  .home-page .home-section-header {
    gap: 10px;
  }

  .home-page .home-section-link {
    font-size: 11px;
  }

  .home-page .home-featured-grid {
    gap: 12px 7px;
  }

  .home-page .home-updates-list {
    margin-inline: -13px;
    gap: 12px 8px;
  }

  .home-page .home-featured-title {
    font-size: 11px;
  }
}

@media (max-width: 360px) {
  .home-page .home-updates-list {
    gap: 10px 6px;
  }

  .home-page .home-featured-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

}

@media (prefers-reduced-motion: reduce) {
  .home-page *,
  .home-page *::before,
  .home-page *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}
