@import url('https://fonts.googleapis.com/css2?family=Amiri:wght@400;700&family=Cairo:wght@400;600;700&display=swap');

:root {
  --bg: #1b1712;
  --paper: #24201a;
  --ink: #ece4d3;
  --muted: #a89b83;
  --accent: #c9a24b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Cairo', sans-serif;
  direction: rtl;
  min-height: 100vh;
}

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid #3a332661;
  position: sticky;
  top: 0;
  background: rgba(27,23,18,0.92);
  backdrop-filter: blur(6px);
  z-index: 10;
}

.top-bar .brand {
  font-weight: 700;
  color: var(--accent);
  font-size: 1.05rem;
}

.top-bar form { margin: 0; }

.btn {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 6px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
}
.btn:hover { background: var(--accent); color: #1b1712; }

.login-box {
  max-width: 380px;
  margin: 12vh auto;
  background: var(--paper);
  padding: 32px 28px;
  border-radius: 14px;
  border: 1px solid #3a3326;
}

.login-box h1 {
  text-align: center;
  color: var(--accent);
  font-size: 1.3rem;
  margin-bottom: 24px;
}

.login-box input {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 14px;
  border-radius: 8px;
  border: 1px solid #4a4232;
  background: #171310;
  color: var(--ink);
  font-family: inherit;
  font-size: 1rem;
}

.login-box button {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #1b1712;
  font-weight: 700;
  cursor: pointer;
  font-size: 1rem;
}

.error-msg {
  background: #4a2020;
  color: #f0b8b8;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 14px;
  font-size: 0.9rem;
  text-align: center;
}
.info-msg {
  background: #3a3420;
  color: #e8d8a0;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 14px;
  font-size: 0.9rem;
  text-align: center;
}

.chapters-list {
  list-style: none;
  padding: 0;
  margin: 24px 0;
}
.chapters-list li {
  border-bottom: 1px solid #3a332661;
}
.chapters-list a {
  display: flex;
  justify-content: space-between;
  padding: 16px 6px;
  color: var(--ink);
  text-decoration: none;
  font-size: 1.05rem;
}
.chapters-list a:hover { color: var(--accent); }
.chapters-list .num {
  color: var(--muted);
  font-size: 0.85rem;
}

.chapter-title {
  text-align: center;
  color: var(--accent);
  font-family: 'Amiri', serif;
  font-size: 1.8rem;
  margin: 20px 0 30px;
}

.chapter-content {
  position: relative;
  font-family: 'Amiri', serif;
  font-size: 1.25rem;
  line-height: 2.1;
  user-select: none;
  -webkit-user-select: none;
}

.chapter-content p {
  margin: 0 0 1.1em;
}

.watermark {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  overflow: hidden;
  opacity: 0.09;
}
.watermark span {
  position: absolute;
  white-space: nowrap;
  color: var(--accent);
  font-size: 1.1rem;
  transform: rotate(-30deg);
}

.nav-buttons {
  display: flex;
  justify-content: space-between;
  margin-top: 40px;
  gap: 12px;
}
.nav-buttons a {
  flex: 1;
  text-align: center;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #4a4232;
  color: var(--ink);
  text-decoration: none;
}
.nav-buttons a.disabled {
  opacity: 0.3;
  pointer-events: none;
}
.nav-buttons a:hover { border-color: var(--accent); color: var(--accent); }

.blur-guard {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 1.1rem;
  text-align: center;
  padding: 20px;
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.top-actions form { margin: 0; }

/* ---- ملاحظات القارئ ---- */
.para-block {
  margin-bottom: 1.1em;
  scroll-margin-top: 80px;
}
.para-block p { margin: 0 0 8px; }

.note-toggle {
  background: none;
  border: none;
  color: var(--muted);
  font-family: 'Cairo', sans-serif;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 2px 0;
  user-select: auto;
  -webkit-user-select: auto;
}
.note-toggle:hover { color: var(--accent); }

.note-form {
  display: none;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0 4px;
  max-width: 480px;
  user-select: auto;
  -webkit-user-select: auto;
}
.note-form.open { display: flex; }
.note-form textarea {
  font-family: 'Cairo', sans-serif;
  background: #171310;
  color: var(--ink);
  border: 1px solid #4a4232;
  border-radius: 8px;
  padding: 10px;
  min-height: 70px;
  font-size: 0.95rem;
  resize: vertical;
}
.note-form .btn {
  align-self: flex-start;
  font-size: 0.85rem;
  padding: 6px 14px;
}

.my-notes {
  max-width: 480px;
  margin: 6px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.note-item {
  background: #2c2618;
  border-right: 3px solid var(--accent);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: 'Cairo', sans-serif;
  user-select: auto;
  -webkit-user-select: auto;
}
.note-item p { margin: 0 0 6px; color: var(--ink); }
.note-delete-form { margin: 0; }
.note-delete-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0;
}
.note-delete-btn:hover { color: #d98a8a; }

/* ---- صفحة تعليقات القراء (للكاتب/الأدمن) ---- */
.comment-chapter-group { margin-bottom: 32px; }
.comment-chapter-title {
  color: var(--accent);
  font-family: 'Amiri', serif;
  font-size: 1.3rem;
  margin-bottom: 12px;
  border-bottom: 1px solid #3a332661;
  padding-bottom: 8px;
}
.comment-chapter-title a { color: inherit; text-decoration: none; }
.comment-chapter-title a:hover { text-decoration: underline; }

.comment-card {
  background: var(--paper);
  border: 1px solid #3a3326;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.comment-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 8px;
}
.comment-author { color: var(--accent); font-weight: 700; }
.comment-para-preview {
  margin: 0 0 10px;
  padding: 8px 12px;
  border-right: 3px solid #4a4232;
  color: var(--muted);
  font-family: 'Amiri', serif;
  font-size: 0.95rem;
}
.comment-content {
  margin: 0;
  font-size: 1rem;
}

/* ---- لوحة تحكم الأدمن ---- */
.admin-card {
  background: var(--paper);
  border: 1px solid #3a3326;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 24px;
}
.admin-card h3 {
  margin-top: 0;
  color: var(--accent);
  font-size: 1.05rem;
}
.admin-add-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.admin-add-form input,
.admin-add-form select {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #4a4232;
  background: #171310;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.95rem;
  flex: 1;
  min-width: 140px;
}
.btn-solid {
  background: var(--accent);
  color: #1b1712;
  font-weight: 700;
  border: none;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.admin-table th, .admin-table td {
  padding: 10px 8px;
  text-align: right;
  border-bottom: 1px solid #3a332661;
}
.admin-table th { color: var(--muted); font-weight: 600; }

.inline-role-form select {
  background: #171310;
  color: var(--ink);
  border: 1px solid #4a4232;
  border-radius: 6px;
  padding: 4px 8px;
  font-family: inherit;
}
.inline-role-form { margin: 0; }

.btn-danger {
  background: none;
  border: 1px solid #7a3c3c;
  color: #d98a8a;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
}
.btn-danger:hover { background: #7a3c3c; color: #fff; }
