/* ============ ورّاق — التصميم العام ============ */
:root {
  --bg: #0a0e17;
  --bg-2: #0e1422;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-2: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.09);
  --gold: #d9a85c;
  --gold-2: #f0d09a;
  --gold-dim: rgba(217, 168, 92, 0.15);
  --teal: #45c4b0;
  --danger: #e5616c;
  --text: #eef1f8;
  --muted: #97a1b6;
  --radius: 18px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  font-size: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Tajawal', 'Cairo', 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3, h4, .brand-name, button, input, select {
  font-family: 'Cairo', 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
}

/* خلفية متوهجة */
.bg-glow {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(700px 400px at 85% -5%, rgba(217, 168, 92, 0.13), transparent 60%),
    radial-gradient(800px 500px at 10% 20%, rgba(69, 120, 196, 0.12), transparent 60%),
    radial-gradient(600px 600px at 50% 110%, rgba(69, 196, 176, 0.08), transparent 60%),
    var(--bg);
}
.bg-glow::after {
  content: ''; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(to bottom, black 30%, transparent 90%);
}

::selection { background: var(--gold-dim); color: var(--gold-2); }

/* ============ الشريط العلوي ============ */
.nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px clamp(20px, 5vw, 60px);
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(14px);
  background: linear-gradient(to bottom, rgba(10,14,23,0.9), rgba(10,14,23,0.55));
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, var(--gold), #b07f3a);
  display: grid; place-items: center; color: #1a1206;
  box-shadow: 0 6px 20px rgba(217, 168, 92, 0.35);
}
.brand-name { font-size: 1.35rem; font-weight: 800; letter-spacing: 0.5px; }
.brand-tag { font-size: 0.72rem; color: var(--muted); display: block; margin-top: -4px; }
.nav-links { display: flex; gap: 26px; align-items: center; }
.nav-links a {
  color: var(--muted); text-decoration: none; font-size: 0.95rem; font-weight: 500;
  transition: color .2s;
}
.nav-links a:hover { color: var(--gold-2); }

/* ============ البطل ============ */
.hero {
  text-align: center; padding: clamp(50px, 9vh, 100px) 24px 40px;
  max-width: 900px; margin: 0 auto;
}
.hero-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 18px; border-radius: 999px; font-size: 0.82rem; font-weight: 600;
  background: var(--gold-dim); color: var(--gold-2);
  border: 1px solid rgba(217, 168, 92, 0.3);
  margin-bottom: 26px;
}
.hero h1 {
  font-size: clamp(2.1rem, 5.5vw, 3.6rem); font-weight: 900; line-height: 1.35;
}
.hero h1 .grad {
  background: linear-gradient(120deg, var(--gold-2), var(--gold) 55%, #b07f3a);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p {
  color: var(--muted); font-size: clamp(1rem, 2vw, 1.18rem);
  margin: 20px auto 34px; max-width: 620px; line-height: 1.9;
}
.hero-cta { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

/* ============ الأزرار ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  border: none; cursor: pointer; text-decoration: none;
  font-size: 1rem; font-weight: 700; border-radius: 14px;
  padding: 14px 30px; transition: transform .18s, box-shadow .18s, background .18s;
}
.btn:active { transform: scale(0.97); }
.btn-gold {
  background: linear-gradient(135deg, var(--gold-2), var(--gold) 60%, #b07f3a);
  color: #1c1305;
  box-shadow: 0 8px 28px rgba(217, 168, 92, 0.32);
}
.btn-gold:hover { box-shadow: 0 12px 36px rgba(217, 168, 92, 0.45); transform: translateY(-2px); }
.btn-ghost {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-2); border-color: rgba(255,255,255,0.18); }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none !important; }
.btn-lg { padding: 17px 44px; font-size: 1.1rem; border-radius: 16px; }
.btn-sm { padding: 9px 18px; font-size: .88rem; border-radius: 11px; }

/* ============ بطاقة الإنشاء ============ */
.section { max-width: 1060px; margin: 0 auto; padding: 30px clamp(18px, 4vw, 40px); }
.section-title {
  text-align: center; font-size: clamp(1.5rem, 3.4vw, 2.1rem); font-weight: 800;
  margin-bottom: 8px;
}
.section-sub { text-align: center; color: var(--muted); margin-bottom: 34px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(22px, 4vw, 40px);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.step-label {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 1.02rem; margin: 30px 0 14px;
}
.step-label:first-child { margin-top: 0; }
.step-num {
  width: 28px; height: 28px; border-radius: 9px; flex-shrink: 0;
  display: grid; place-items: center; font-size: .85rem; font-weight: 800;
  background: var(--gold-dim); color: var(--gold-2);
  border: 1px solid rgba(217, 168, 92, 0.3);
}

/* منطقة الإفلات */
.dropzone {
  border: 2px dashed rgba(217, 168, 92, 0.35);
  border-radius: var(--radius);
  padding: clamp(30px, 6vw, 56px) 20px;
  text-align: center; cursor: pointer;
  background: rgba(217, 168, 92, 0.04);
  transition: all .25s;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--gold);
  background: rgba(217, 168, 92, 0.09);
  transform: translateY(-2px);
}
.dropzone .dz-icon {
  width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 18px;
  background: var(--gold-dim); display: grid; place-items: center; color: var(--gold-2);
}
.dropzone h3 { font-size: 1.2rem; font-weight: 700; margin-bottom: 6px; }
.dropzone p { color: var(--muted); font-size: .9rem; }
.dropzone .formats { margin-top: 14px; font-size: .75rem; color: var(--muted); opacity: .8; }

/* معاينة الصور */
.thumbs {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 14px; margin-top: 18px;
}
.thumb {
  position: relative; aspect-ratio: 3/4; border-radius: 12px; overflow: hidden;
  border: 1px solid var(--border); background: #000;
  cursor: grab; transition: transform .15s, box-shadow .15s, opacity .15s;
}
.thumb:active { cursor: grabbing; }
.thumb:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(0,0,0,.5); }
.thumb.dragging { opacity: .35; transform: scale(.95); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.thumb .t-order {
  position: absolute; top: 7px; inset-inline-start: 7px;
  min-width: 24px; height: 24px; padding: 0 6px; border-radius: 8px;
  background: rgba(10, 14, 23, 0.82); backdrop-filter: blur(4px);
  display: grid; place-items: center; font-size: .78rem; font-weight: 700;
  color: var(--gold-2); border: 1px solid rgba(217,168,92,.3);
}
.thumb .t-cover {
  position: absolute; bottom: 7px; inset-inline-start: 7px;
  font-size: .68rem; font-weight: 700; padding: 3px 9px; border-radius: 7px;
  background: linear-gradient(135deg, var(--gold-2), var(--gold)); color: #1c1305;
}
.thumb .t-del {
  position: absolute; top: 7px; inset-inline-end: 7px;
  width: 26px; height: 26px; border-radius: 8px; border: none; cursor: pointer;
  background: rgba(10,14,23,.82); color: #ff8f97; font-size: .95rem;
  display: grid; place-items: center; transition: background .2s;
}
.thumb .t-del:hover { background: var(--danger); color: #fff; }
.thumbs-hint { color: var(--muted); font-size: .8rem; margin-top: 10px; display: flex; align-items: center; gap: 6px; }

/* الحقول */
.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 8px; color: var(--text); }
.field input[type="text"], .field input[type="password"] {
  width: 100%; padding: 14px 18px; border-radius: 13px;
  background: rgba(0,0,0,.28); border: 1px solid var(--border);
  color: var(--text); font-size: 1rem; outline: none; transition: border .2s, box-shadow .2s;
}
.field input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(217, 168, 92, 0.12);
}
.field input::placeholder { color: var(--muted); opacity: .7; }

/* بطاقات الاختيار (الاتجاه / الخصوصية) */
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.choice {
  position: relative; cursor: pointer; border-radius: 14px;
  border: 1.5px solid var(--border); background: rgba(0,0,0,.22);
  padding: 18px 16px; display: flex; align-items: center; gap: 14px;
  transition: all .2s;
}
.choice:hover { border-color: rgba(217,168,92,.4); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice.sel {
  border-color: var(--gold);
  background: rgba(217,168,92,.09);
  box-shadow: 0 0 0 4px rgba(217,168,92,.1);
}
.choice .c-icon {
  width: 46px; height: 46px; border-radius: 12px; flex-shrink: 0;
  background: var(--surface-2); display: grid; place-items: center; color: var(--gold-2);
}
.choice.sel .c-icon { background: var(--gold-dim); }
.choice h4 { font-size: .98rem; font-weight: 700; }
.choice p { font-size: .78rem; color: var(--muted); margin-top: 2px; }

.pass-wrap { overflow: hidden; max-height: 0; transition: max-height .35s ease, margin .35s; margin-top: 0; }
.pass-wrap.open { max-height: 130px; margin-top: 14px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 700px) { .form-row, .choice-grid { grid-template-columns: 1fr; } }

/* شريط تقدم الرفع */
.progress-wrap { display: none; margin-top: 18px; }
.progress-wrap.show { display: block; }
.progress-bar { height: 10px; border-radius: 99px; background: rgba(0,0,0,.35); overflow: hidden; border: 1px solid var(--border); }
.progress-bar i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--gold-2));
  border-radius: 99px; transition: width .2s;
}
.progress-text { font-size: .82rem; color: var(--muted); margin-top: 8px; text-align: center; }

.form-error {
  display: none; margin-top: 14px; padding: 12px 16px; border-radius: 12px;
  background: rgba(229, 97, 108, 0.12); border: 1px solid rgba(229, 97, 108, 0.35);
  color: #ff9aa1; font-size: .9rem; font-weight: 600;
}
.form-error.show { display: block; }

/* ============ نافذة النجاح ============ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(5, 8, 14, 0.78); backdrop-filter: blur(8px);
  display: none; place-items: center; padding: 20px;
}
.modal-overlay.show { display: grid; animation: fadeIn .25s; }
.modal {
  width: min(560px, 100%); background: var(--bg-2);
  border: 1px solid var(--border); border-radius: 22px;
  padding: 40px 34px; text-align: center; box-shadow: var(--shadow);
  animation: popIn .3s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes fadeIn { from { opacity: 0 } }
@keyframes popIn { from { opacity: 0; transform: scale(.9) translateY(16px) } }
.modal .ok-icon {
  width: 74px; height: 74px; margin: 0 auto 20px; border-radius: 50%;
  background: var(--gold-dim); border: 1px solid rgba(217,168,92,.35);
  display: grid; place-items: center; color: var(--gold-2);
}
.modal h3 { font-size: 1.5rem; font-weight: 800; margin-bottom: 8px; }
.modal > p { color: var(--muted); font-size: .92rem; margin-bottom: 22px; }
.link-box {
  display: flex; gap: 10px; margin-bottom: 22px;
  background: rgba(0,0,0,.35); border: 1px solid var(--border);
  border-radius: 13px; padding: 8px 8px 8px 16px; align-items: center;
}
.link-box input {
  flex: 1; background: none; border: none; outline: none; color: var(--gold-2);
  font-size: .92rem; direction: ltr; text-align: left; font-family: monospace;
}
.modal-btns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ============ المميزات ============ */
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
@media (max-width: 800px) { .features { grid-template-columns: 1fr; } }
.feature {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 30px 26px; text-align: center;
  transition: transform .25s, border-color .25s;
}
.feature:hover { transform: translateY(-5px); border-color: rgba(217,168,92,.35); }
.feature .f-icon {
  width: 58px; height: 58px; margin: 0 auto 18px; border-radius: 16px;
  background: var(--gold-dim); display: grid; place-items: center; color: var(--gold-2);
}
.feature h3 { font-size: 1.08rem; font-weight: 700; margin-bottom: 8px; }
.feature p { color: var(--muted); font-size: .88rem; line-height: 1.8; }

/* ============ كتبي ============ */
.my-books { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.my-book {
  display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px; transition: all .2s;
}
.my-book:hover { border-color: rgba(217,168,92,.4); transform: translateY(-2px); }
.my-book .mb-icon {
  width: 44px; height: 44px; border-radius: 11px; flex-shrink: 0;
  background: var(--gold-dim); display: grid; place-items: center; color: var(--gold-2);
}
.my-book h4 { font-size: .95rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.my-book p { font-size: .75rem; color: var(--muted); margin-top: 3px; display: flex; gap: 8px; }
.my-book .lock-tag { color: var(--gold-2); }
.empty-note { color: var(--muted); text-align: center; padding: 26px; font-size: .9rem; }

/* ============ التذييل ============ */
.footer {
  margin-top: 70px; border-top: 1px solid var(--border);
  padding: 34px 24px 28px; text-align: center;
  background: linear-gradient(to top, rgba(217,168,92,.05), transparent);
}
.footer .dev {
  display: inline-flex; align-items: center; gap: 9px;
  font-size: .92rem; color: var(--muted);
}
.footer .dev b { color: var(--gold-2); font-weight: 700; }
.footer small { display: block; margin-top: 10px; color: var(--muted); opacity: .65; font-size: .75rem; }

/* ============ صفحة العرض (flipbook) ============ */
.viewer-body {
  height: 100vh; height: 100dvh; overflow: hidden;
  display: flex; flex-direction: column; background: #05070d;
  touch-action: manipulation;
}

.v-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 20px 12px; gap: 14px; z-index: 30;
  background: rgba(8, 11, 19, 0.75); backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  transition: transform .3s ease;
}
.v-bottom {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 22px calc(14px + env(safe-area-inset-bottom)); z-index: 30;
  background: rgba(8, 11, 19, 0.75); backdrop-filter: blur(14px);
  border-top: 1px solid rgba(255,255,255,0.07);
  transition: transform .3s ease;
}
/* وضع القراءة الغامرة — لمسة تُخفي الأشرطة */
body.ui-hidden .v-topbar { transform: translateY(-110%); }
body.ui-hidden .v-bottom { transform: translateY(110%); }
body.ui-hidden .nav-arrow { opacity: 0; pointer-events: none; }
.nav-arrow { transition: opacity .3s, background .2s, color .2s; }
.v-title { font-weight: 700; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 10px; }
.v-title .v-brand { color: var(--gold-2); font-size: .8rem; font-weight: 600; opacity: .85; }
.v-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 11px; border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.05); color: var(--text); cursor: pointer;
  display: grid; place-items: center; transition: all .2s;
}
.icon-btn:hover { background: rgba(217,168,92,.15); border-color: rgba(217,168,92,.4); color: var(--gold-2); }

.stage {
  flex: 1; position: relative; display: flex; align-items: center; justify-content: center;
  overflow: hidden; min-height: 0;
  background:
    radial-gradient(900px 500px at 50% 0%, rgba(217,168,92,.06), transparent 60%),
    radial-gradient(700px 500px at 50% 110%, rgba(69,120,196,.07), transparent 60%);
}
.flip-holder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.flip-holder.mirrored { transform: scaleX(-1); }
.flip-holder.mirrored .pg-content { transform: scaleX(-1); }

.pg {
  background: #14100a;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 6px 30px rgba(0,0,0,.35);
}
.pg-content { position: absolute; inset: 0; overflow: hidden; border-radius: 14px; }
.pg-bg {
  position: absolute; inset: -40px; background-size: cover; background-position: center;
  filter: blur(28px) brightness(.45); transform: scale(1.1);
}
.pg-content img {
  position: relative; width: 100%; height: 100%; object-fit: contain; display: block;
}
.pg-num {
  position: absolute; bottom: 10px; inset-inline-start: 12px; z-index: 5;
  font-size: .7rem; padding: 2px 10px; border-radius: 7px;
  background: rgba(0,0,0,.55); color: rgba(255,255,255,.75); font-weight: 600;
}

/* أسهم التنقل */
.nav-arrow {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 20;
  width: 52px; height: 52px; border-radius: 50%; border: 1px solid rgba(255,255,255,.12);
  background: rgba(10, 14, 23, 0.72); backdrop-filter: blur(8px); color: var(--text);
  cursor: pointer; display: grid; place-items: center; transition: all .2s;
}
.nav-arrow:hover { background: var(--gold); color: #1c1305; border-color: var(--gold); }
.nav-arrow.next { inset-inline-end: 18px; }
.nav-arrow.prev { inset-inline-start: 18px; }
.nav-arrow[disabled] { opacity: .25; pointer-events: none; }
@media (max-width: 640px) {
  .nav-arrow { width: 44px; height: 44px; }
  .nav-arrow.next { inset-inline-end: 8px; }
  .nav-arrow.prev { inset-inline-start: 8px; }
}

/* شريط الحالة السفلي */
.v-progress { flex: 1; height: 6px; border-radius: 99px; background: rgba(255,255,255,.08); cursor: pointer; position: relative; }
.v-progress i {
  position: absolute; inset-inline-start: 0; top: 0; bottom: 0; border-radius: 99px;
  background: linear-gradient(90deg, var(--gold), var(--gold-2)); width: 0%;
  transition: width .35s ease;
}
.v-counter { font-size: .85rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
.v-counter b { color: var(--gold-2); }
.v-credit { font-size: .72rem; color: var(--muted); opacity: .8; white-space: nowrap; }
.v-credit b { color: var(--gold-2); opacity: .9; }
@media (max-width: 640px) { .v-credit { display: none; } }

/* شاشة القفل والتحميل */
.v-overlay {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background:
    radial-gradient(700px 400px at 85% -5%, rgba(217,168,92,.12), transparent 60%),
    radial-gradient(800px 500px at 10% 20%, rgba(69,120,196,.1), transparent 60%),
    var(--bg);
  padding: 20px;
}
.v-card {
  width: min(440px, 100%); text-align: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 24px; padding: 44px 34px; backdrop-filter: blur(12px);
  box-shadow: var(--shadow); animation: popIn .35s cubic-bezier(.2,.9,.3,1.15);
}
.v-card .lock-icon {
  width: 72px; height: 72px; margin: 0 auto 20px; border-radius: 20px;
  background: var(--gold-dim); border: 1px solid rgba(217,168,92,.3);
  display: grid; place-items: center; color: var(--gold-2);
}
.v-card h2 { font-size: 1.4rem; font-weight: 800; margin-bottom: 8px; }
.v-card .sub { color: var(--muted); font-size: .88rem; margin-bottom: 24px; line-height: 1.7; }
.v-card input {
  width: 100%; padding: 15px 18px; border-radius: 13px; text-align: center;
  background: rgba(0,0,0,.3); border: 1px solid var(--border);
  color: var(--text); font-size: 1.05rem; outline: none; margin-bottom: 14px;
  letter-spacing: 2px; transition: all .2s;
}
.v-card input:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(217,168,92,.12); }
.v-card .err { color: #ff9aa1; font-size: .82rem; min-height: 20px; margin-bottom: 8px; font-weight: 600; }
.v-card.shake { animation: shake .4s; }
@keyframes shake {
  0%,100% { transform: translateX(0) } 20% { transform: translateX(-9px) }
  40% { transform: translateX(9px) } 60% { transform: translateX(-6px) } 80% { transform: translateX(6px) }
}

/* تحميل */
.spinner {
  width: 54px; height: 54px; margin: 0 auto 18px; border-radius: 50%;
  border: 3px solid rgba(217,168,92,.18); border-top-color: var(--gold);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }
.loading-text { color: var(--muted); font-size: .9rem; }

/* توست */
.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--bg-2); border: 1px solid rgba(217,168,92,.4); color: var(--text);
  padding: 12px 24px; border-radius: 13px; font-size: .9rem; font-weight: 600;
  z-index: 300; opacity: 0; transition: all .3s; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 9px;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); }

.hidden { display: none !important; }

/* ============ المصادقة ============ */
.user-chip {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 6px 5px 14px; font-weight: 700; font-size: .9rem;
}
.u-avatar {
  width: 30px; height: 30px; border-radius: 50%; order: -1;
  background: linear-gradient(135deg, var(--gold-2), var(--gold));
  color: #1c1305; display: grid; place-items: center; font-weight: 800; font-size: .85rem;
}
.u-logout {
  width: 30px; height: 30px; border-radius: 50%; border: none; cursor: pointer;
  background: transparent; color: var(--muted); display: grid; place-items: center;
  transition: all .2s;
}
.u-logout:hover { background: rgba(229,97,108,.15); color: #ff8f97; }

.auth-tabs {
  display: flex; gap: 6px; margin-bottom: 24px;
  background: rgba(0,0,0,.3); border-radius: 13px; padding: 5px;
}
.auth-tab {
  flex: 1; padding: 11px; border: none; border-radius: 10px; cursor: pointer;
  background: transparent; color: var(--muted); font-weight: 700; font-size: .95rem;
  transition: all .2s;
}
.auth-tab.sel { background: var(--gold-dim); color: var(--gold-2); }

.guest-hint {
  margin-top: 20px; font-size: .8rem; color: var(--muted); line-height: 1.7;
  padding: 11px 14px; border-radius: 11px;
  background: rgba(217,168,92,.07); border: 1px dashed rgba(217,168,92,.3);
}

.notice-card {
  display: flex; align-items: center; gap: 18px;
  background: rgba(217,168,92,.06); border: 1px dashed rgba(217,168,92,.35);
  border-radius: var(--radius); padding: 20px 24px; margin-bottom: 22px;
}
.notice-card .n-icon {
  width: 50px; height: 50px; border-radius: 14px; flex-shrink: 0;
  background: var(--gold-dim); display: grid; place-items: center; color: var(--gold-2);
}
.notice-card h4 { font-size: 1rem; font-weight: 700; margin-bottom: 4px; }
.notice-card p { color: var(--muted); font-size: .85rem; line-height: 1.7; }
.notice-card .btn { flex-shrink: 0; margin-inline-start: auto; }
@media (max-width: 640px) { .notice-card { flex-direction: column; text-align: center; } }

/* فيديو في المعاينة والكتاب */
.thumb video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.thumb .t-video {
  position: absolute; bottom: 7px; inset-inline-end: 7px;
  font-size: .68rem; font-weight: 700; padding: 3px 9px; border-radius: 7px;
  background: rgba(10,14,23,.85); color: var(--gold-2);
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid rgba(217,168,92,.3);
}
.pg-video {
  position: relative; width: 100%; height: 100%; object-fit: contain;
  background: #000; display: block;
}

/* عداد القراءة والمؤقت في العارض */
.v-views {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .8rem; font-weight: 600; color: var(--muted);
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.09);
  border-radius: 999px; padding: 4px 12px;
}
.v-views svg { color: var(--gold-2); }
.v-timer {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: .82rem; font-weight: 700; color: var(--gold-2);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
@media (max-width: 640px) { .v-views { display: none; } }

/* ============ خيارات متقدمة ============ */
.select-input {
  width: 100%; padding: 14px 18px; border-radius: 13px;
  background: rgba(0,0,0,.28); border: 1px solid var(--border);
  color: var(--text); font-size: 1rem; outline: none; cursor: pointer;
}
.select-input:focus { border-color: var(--gold); }
.select-input option { background: var(--bg-2); }

.music-picker {
  display: flex; align-items: center; gap: 12px; cursor: pointer;
  padding: 14px 18px; border-radius: 13px;
  background: rgba(0,0,0,.28); border: 1.5px dashed var(--border);
  color: var(--muted); font-size: .92rem; transition: all .2s;
}
.music-picker:hover { border-color: rgba(217,168,92,.4); }
.music-picker.picked { border-color: var(--gold); border-style: solid; color: var(--gold-2); }
.music-picker svg { flex-shrink: 0; }

.url-row { display: flex; gap: 10px; }
.url-row input {
  flex: 1; padding: 13px 16px; border-radius: 13px;
  background: rgba(0,0,0,.28); border: 1px solid var(--border);
  color: var(--text); font-size: .92rem; outline: none; font-family: monospace;
}
.url-row input:focus { border-color: var(--gold); }
.url-list { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.url-item {
  display: flex; align-items: center; gap: 10px;
  background: rgba(0,0,0,.28); border: 1px solid var(--border);
  border-radius: 11px; padding: 9px 12px; font-size: .8rem;
}
.url-item span {
  flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--gold-2); font-family: monospace;
}

/* QR والتضمين */
.share-extra {
  display: flex; gap: 18px; align-items: center; margin-bottom: 22px;
  text-align: right;
}
.qr-img {
  width: 110px; height: 110px; border-radius: 14px; flex-shrink: 0;
  border: 1px solid rgba(217,168,92,.35); padding: 6px; background: #f5e9d0;
}
.embed-box { flex: 1; min-width: 0; }
.embed-box label { font-size: .8rem; color: var(--muted); display: block; margin-bottom: 7px; text-align: right; }
.embed-box input { font-size: .72rem; }
@media (max-width: 520px) { .share-extra { flex-direction: column; } }

/* ============ لوحة التعليقات ============ */
.comments-panel {
  position: fixed; top: 0; bottom: 0; inset-inline-start: -380px;
  width: min(360px, 92vw); z-index: 90;
  background: rgba(12, 16, 26, 0.97); backdrop-filter: blur(16px);
  border-inline-end: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: inset-inline-start .35s cubic-bezier(.2,.8,.3,1);
  box-shadow: 20px 0 60px rgba(0,0,0,.4);
}
.comments-panel.open { inset-inline-start: 0; }
.cp-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.cp-head h3 { font-size: 1.05rem; font-weight: 800; }
.cp-list { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.cp-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 13px; padding: 12px 14px;
}
.cp-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.cp-meta b { color: var(--gold-2); font-size: .85rem; }
.cp-meta span { color: var(--muted); font-size: .72rem; }
.cp-item p { font-size: .88rem; line-height: 1.7; color: var(--text); word-break: break-word; }
.cp-empty { color: var(--muted); text-align: center; padding: 30px 10px; font-size: .85rem; }
.cp-form { padding: 14px 16px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 9px; }
.cp-form input, .cp-form textarea {
  padding: 11px 14px; border-radius: 11px; resize: none;
  background: rgba(0,0,0,.3); border: 1px solid var(--border);
  color: var(--text); font-size: .88rem; outline: none; font-family: inherit;
}
.cp-form input:focus, .cp-form textarea:focus { border-color: var(--gold); }

.icon-btn.on { background: var(--gold); color: #1c1305; border-color: var(--gold); }

/* ---------- معالج التثبيت ---------- */
.setup-checks { display: flex; flex-direction: column; gap: 10px; margin-bottom: 26px; }
.setup-check {
  display: flex; align-items: center; gap: 12px;
  background: rgba(0,0,0,.25); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 16px; font-size: .9rem;
}
.setup-check b { margin-inline-start: auto; color: var(--muted); font-size: .8rem; font-weight: 500; }
.chk-icon {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 800; font-size: .85rem;
  background: var(--surface); color: var(--muted); border: 1px solid var(--border);
}
.setup-check.ok .chk-icon { background: rgba(46,204,113,.15); color: #2ecc71; border-color: rgba(46,204,113,.4); }
.setup-check.bad .chk-icon { background: rgba(231,76,60,.15); color: #e74c3c; border-color: rgba(231,76,60,.4); }
.setup-btns { display: flex; gap: 12px; justify-content: flex-end; margin-top: 8px; }
.setup-ok {
  display: none; margin: 12px 0; padding: 12px 16px; border-radius: 12px; font-size: .88rem;
  background: rgba(46,204,113,.1); color: #2ecc71; border: 1px solid rgba(46,204,113,.35);
}
.setup-ok.show { display: block; }
.setup-hint { margin-top: 16px; color: var(--muted); font-size: .8rem; text-align: center; }
.setup-hint code { background: rgba(0,0,0,.35); padding: 2px 8px; border-radius: 6px; font-size: .78rem; }
