:root {
  --lapis: #14306B;
  --night: #1F1712;
  --gold: #B8822A;
  --gold-light: #E0B050;
  --paper: #F5EEDF;
  --line: #DCCDAE;
  --muted: #5A4A3A;
  --sadu: #7A1F1F;
  --danger: #A32020;
}
* { box-sizing: border-box; }
html { font-size: 17px; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--night);
  font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif;
  line-height: 1.8;
}
a { color: var(--lapis); }
h1, h2, h3, .brand-name { font-family: 'Reem Kufi', sans-serif; color: var(--lapis); line-height: 1.4; }
h1 { font-size: 1.7rem; margin: 0 0 .5rem; }
h2 { font-size: 1.3rem; margin: 0 0 .5rem; }
.loading { text-align: center; padding: 4rem 1rem; color: var(--muted); }
.wrap { max-width: 860px; margin: 0 auto; padding: 1.25rem 1rem 4rem; }
.muted { color: var(--muted); font-size: .92rem; }

/* الشريط العلوي */
.topbar { background: var(--lapis); color: #fff; }
.topbar-in { max-width: 860px; margin: 0 auto; padding: .6rem 1rem; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; }
.brand { display: flex; align-items: center; gap: .5rem; text-decoration: none; color: #fff; margin-inline-end: auto; }
.brand img { width: 40px; height: 40px; }
.brand-name { color: #fff; font-size: 1.5rem; font-weight: 700; }
.nav { display: flex; flex-wrap: wrap; gap: .25rem; }
.nav a, .nav button {
  color: #fff; background: none; border: 0; font: inherit; cursor: pointer; text-decoration: none;
  padding: .55rem .8rem; border-radius: 10px; min-height: 44px; display: inline-flex; align-items: center;
}
.nav a:hover, .nav button:hover, .nav a.on { background: rgba(255,255,255,.16); }

/* البطاقات والنماذج */
.card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 1.25rem; margin-bottom: 1rem; }
label { display: block; font-weight: 600; margin: .9rem 0 .25rem; }
input[type=text], input[type=number], select, textarea {
  width: 100%; font: inherit; color: inherit; background: #fff;
  border: 1px solid #9AA6BD; border-radius: 10px; padding: .6rem .75rem; min-height: 46px;
}
textarea { min-height: 220px; resize: vertical; }
textarea.short { min-height: 90px; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid var(--gold-light); outline-offset: 2px; }
.btn {
  font: inherit; font-weight: 600; cursor: pointer; border: 0; border-radius: 12px;
  background: var(--lapis); color: #fff; padding: .7rem 1.4rem; min-height: 46px;
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem; text-decoration: none;
}
.btn:hover { background: var(--night); }
.btn[disabled] { opacity: .6; cursor: wait; }
.btn.ghost { background: #fff; color: var(--lapis); border: 1px solid var(--lapis); }
.btn.ghost:hover { background: var(--paper); }
.btn.danger { background: #fff; color: var(--danger); border: 1px solid var(--danger); }
.row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-top: 1rem; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 1rem; }
.check { display: flex; gap: .6rem; align-items: flex-start; font-weight: 400; }
.check input { width: 22px; height: 22px; margin-top: .3rem; flex: none; }
.msg { padding: .7rem 1rem; border-radius: 10px; margin-top: 1rem; background: #FDF3F3; color: var(--danger); border: 1px solid #E5B9B9; }
.msg.ok { background: #EEF6EE; color: #1E5B2A; border-color: #B7D8BD; }

/* صفحة الدخول */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.login .card { max-width: 440px; width: 100%; text-align: center; padding: 2.25rem 1.5rem; }
.login img { width: 150px; height: 150px; }
.login .name { font-family: 'Reem Kufi', sans-serif; font-weight: 700; font-size: 3.4rem; color: var(--lapis); line-height: 1.2; }
.login .latin { letter-spacing: .45em; font-weight: 600; color: var(--lapis); font-size: .9rem; }
.login .tag { color: var(--muted); margin: .75rem 0 1.5rem; }

/* الحكايات */
.story-card { display: flex; gap: 1rem; text-decoration: none; color: inherit; }
.story-card:hover { border-color: var(--lapis); }
.story-card img, .ph {
  width: 96px; height: 120px; object-fit: cover; border-radius: 12px; flex: none; background: var(--paper);
  border: 1px solid var(--line); display: flex; align-items: center; justify-content: center;
}
.ph img { width: 56px; height: 56px; border: 0; opacity: .55; }
.story-card h2 { margin: 0; }
.excerpt { margin: .35rem 0 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.badge { display: inline-block; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 0 .7rem; font-size: .85rem; color: var(--lapis); margin-inline-end: .35rem; }
.story-photo { max-width: 100%; max-height: 420px; border-radius: 14px; border: 1px solid var(--line); display: block; margin: 0 auto 1rem; }
.story-text { white-space: pre-wrap; font-size: 1.05rem; }
.comment { border-top: 1px solid var(--line); padding: .8rem 0; }
.comment p { margin: .15rem 0 0; white-space: pre-wrap; }
.preview { max-width: 180px; border-radius: 12px; margin-top: .6rem; display: block; }

/* الإحصاءات */
.stat-row { display: flex; align-items: center; gap: .75rem; padding: .35rem 0; }
.stat-row .city { width: 38%; }
.stat-row .bar { height: 14px; background: var(--lapis); border-radius: 7px; min-width: 6px; }
.big { font-family: 'Reem Kufi', sans-serif; font-size: 2.2rem; color: var(--lapis); line-height: 1.2; }

/* ===== الطابع العربي الإسلامي: سدو، نجمة ثمانية، أقواس ===== */
body {
  background-color: var(--paper);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cg fill='none' stroke='%23B8822A' stroke-opacity='.2' stroke-width='1.2'%3E%3Crect x='24' y='24' width='32' height='32'/%3E%3Crect x='24' y='24' width='32' height='32' transform='rotate(45 40 40)'/%3E%3C/g%3E%3C/svg%3E");
}
.sadu {
  height: 24px;
  background:
    linear-gradient(135deg, var(--sadu) 25%, transparent 25%) -12px 0 / 24px 24px,
    linear-gradient(225deg, var(--sadu) 25%, transparent 25%) -12px 0 / 24px 24px,
    linear-gradient(315deg, #1F1712 25%, transparent 25%) 0 0 / 24px 24px,
    linear-gradient(45deg, #1F1712 25%, transparent 25%) 0 0 / 24px 24px,
    #FBF6EA;
  border-top: 3px solid var(--gold);
  border-bottom: 3px solid var(--gold);
}
.topbar { background: var(--lapis); }
.card { background: #FFFDF8; border: 1px solid var(--line); box-shadow: inset 0 0 0 4px #FFFDF8, inset 0 0 0 5px rgba(184,130,42,.45); }
h1 { border-bottom: 2px solid var(--gold); padding-bottom: .35rem; display: inline-block; }
.basmala { font-family: 'Aref Ruqaa', 'Amiri', serif; font-size: 1.5rem; color: var(--sadu); margin: 0 0 1rem; }
.ayah { font-family: 'Amiri', serif; font-size: 1.35rem; line-height: 2; color: var(--night); margin: 1rem 0 .25rem; }
.ayah-ref { color: var(--muted); font-size: .9rem; margin: 0 0 1.25rem; }
.login .tag { font-family: 'Aref Ruqaa', 'Amiri', serif; font-size: 1.25rem; color: var(--sadu); }
.login .card { border-radius: 220px 220px 16px 16px; padding-top: 3rem; }
.story-card img, .ph, .story-photo { border-radius: 999px 999px 10px 10px; border: 2px solid var(--gold); }
.story-text { font-family: 'Amiri', serif; font-size: 1.25rem; line-height: 2.1; }
.badge { background: #FBF6EA; border-color: var(--gold); color: var(--sadu); }
.btn { background: var(--sadu); }
.btn:hover { background: #5C1515; }
.btn.ghost { color: var(--sadu); border-color: var(--sadu); background: #FFFDF8; }
.btn.ghost:hover { background: #FBF6EA; }
.lead { font-family: 'Aref Ruqaa', 'Amiri', serif; font-size: 1.2rem; color: var(--sadu); margin: 0 0 1rem; }
.foot { text-align: center; padding: 1.5rem 1rem 2.5rem; }
.foot .ayah { font-size: 1.15rem; margin: 1rem 0 0; }

/* ===== إضافات النسخة الثانية ===== */
.count { background: var(--gold-light); color: #1F1712; border-radius: 999px; padding: 0 .5rem; margin-inline-start: .4rem; font-size: .8rem; font-weight: 600; }
.search { display: flex; gap: .5rem; margin-bottom: 1rem; }
.search input { flex: 1; min-width: 0; }
.row.center { justify-content: center; }
.btn.small { min-height: 38px; padding: .2rem .9rem; font-size: .9rem; margin-top: .4rem; }
.unread a { font-weight: 600; }
.terms ul { padding-inline-start: 1.25rem; margin: 0 0 1rem; }
.terms h2 { margin-top: 1.25rem; }
.tree { list-style: none; margin: 1rem 0 0; padding: 0; border-inline-start: 3px solid var(--lapis); }
.tree li { position: relative; padding: .45rem 1.25rem .45rem 0; margin-inline-start: 0; }
.tree li::before { content: ""; position: absolute; inset-inline-start: -9px; top: 1rem; width: 15px; height: 15px; border-radius: 50%; background: var(--gold); border: 2px solid #FFFDF8; }
.tree li.me::before { background: var(--sadu); width: 19px; height: 19px; inset-inline-start: -11px; }
.tree .node { font-family: 'Reem Kufi', sans-serif; font-size: 1.15rem; color: var(--lapis); font-weight: 700; }
.leaf { display: block; margin-top: .2rem; }
.map { height: 380px; border-radius: 12px; border: 1px solid var(--line); direction: ltr; }
