:root{
  --ink:#1F1B16;
  --parchment:#F1E7D0;
  --parchment-deep:#E7D9B8;
  --card:#FBF5E6;
  --gold:#B8863B;
  --gold-light:#D9B876;
  --maroon:#6E1F1F;
  --line: rgba(31,27,22,0.18);
}
*{margin:0;padding:0;box-sizing:border-box;}
body{
  background:var(--parchment);
  color:var(--ink);
  font-family:'Tajawal', sans-serif;
  font-weight:500;
  min-height:100vh;
  -webkit-font-smoothing:antialiased;
}
p, li, td, span{ font-weight:500; }
h1,h2,h3,h4,h5,strong,b{ font-weight:900; }
a{color:inherit; text-decoration:none;}
button{font-family:inherit; cursor:pointer;}

/* ===== Header ===== */
.site-header{ background:rgba(241,231,208,0.96); border-bottom:1px solid var(--line); position:sticky; top:0; z-index:60; }
.header-inner{ max-width:1200px; margin:0 auto; padding:14px 28px; display:flex; align-items:center; justify-content:space-between; }
.brand{ font-family:'Aref Ruqaa', serif; font-size:1.35rem; color:var(--maroon); display:flex; align-items:center; gap:10px; }
.brand .mark{ width:30px;height:30px;border:2px solid var(--gold);border-radius:50%; display:flex;align-items:center;justify-content:center;font-size:.6rem;font-weight:900; background:var(--parchment-deep); }
.top-nav{display:flex; gap:22px; font-size:.92rem; font-weight:500;}
.top-nav a.active{color:var(--maroon); font-weight:700;}
.top-nav a:hover{color:var(--maroon);}

/* ===== Toolbar ===== */
.tree-toolbar{ background:var(--parchment-deep); border-bottom:1px solid var(--line); position:sticky; top:57px; z-index:55; }
.toolbar-inner{ max-width:1200px; margin:0 auto; padding:12px 28px; display:flex; align-items:center; justify-content:space-between; gap:20px; flex-wrap:wrap; }
.search-box{position:relative; flex:1; max-width:520px; min-width:220px;}
.search-box input{ width:100%; padding:10px 16px; border-radius:20px; border:1px solid var(--line); background:var(--card); font-family:'Tajawal', sans-serif; font-size:.92rem; }
.search-box input:focus{outline:none; border-color:var(--gold);}
.search-results{ position:absolute; top:110%; right:0; left:0; background:var(--card); border:1px solid var(--gold); border-radius:10px; max-height:360px; overflow-y:auto; display:none; z-index:70; box-shadow:0 14px 30px rgba(31,27,22,.15); }
.search-results.show{display:block;}
.search-group-title{ font-size:.75rem; font-weight:700; color:var(--maroon); padding:10px 16px 4px; }
.search-item{ padding:9px 16px; font-size:.87rem; border-top:1px solid var(--line); cursor:pointer; display:flex; justify-content:space-between; gap:10px; }
.search-item:hover{background:var(--parchment-deep);}
.search-item small{color:#7a6f5c;}
.search-empty{padding:16px; font-size:.85rem; color:#7a6f5c; text-align:center;}

.font-controls{display:flex; align-items:center; gap:6px; background:var(--card); border:1px solid var(--line); border-radius:20px; padding:4px 6px;}
.font-controls button{ width:28px;height:28px;border-radius:50%;border:1px solid var(--line); background:var(--parchment); font-size:.9rem; font-weight:700; color:var(--maroon); }
.font-controls button:hover{background:var(--gold-light);}

/* ===== Tree container (YFull-style vertical/indented) ===== */
.tree-wrap{ max-width:1200px; margin:0 auto; padding:26px 28px 100px; font-size:.92rem; }
.tree-loading{font-family:'Amiri', serif; font-size:1.05rem; color:#7a6f5c; padding:30px;}

.node{ position:relative; margin-bottom:2px; }
.node-row{
  display:flex; align-items:center; gap:8px; flex-wrap:wrap;
  padding:5px 8px; border-radius:6px; transition:background .15s;
}
.node-row:hover{ background:rgba(184,134,59,.08); }

.node-toggle{
  width:18px; height:18px; border-radius:4px; border:1px solid var(--line);
  background:var(--card); font-size:.7rem; font-weight:900; color:var(--maroon);
  display:flex; align-items:center; justify-content:center; flex-shrink:0;
}
.node-toggle.leaf{ visibility:hidden; }

.branch-badge{
  display:inline-flex; align-items:center; font-family:'Tajawal', sans-serif; font-weight:700;
  font-size:.86rem; padding:3px 10px; border-radius:5px; color:#fff; cursor:pointer;
  white-space:nowrap;
}
.branch-badge.status-proposed{ opacity:.75; border:1px dashed rgba(255,255,255,.6); }
.branch-badge.status-ancient{ filter:saturate(.6);}
.branch-badge.status-hidden{ opacity:.4; }
.branch-badge.root-highlight{ box-shadow:0 0 0 2px var(--gold), 0 0 0 4px rgba(184,134,59,.3); }

.snp-meta{ color:#6b6152; font-size:.82rem; }
.snp-count-tag{ background:var(--parchment-deep); border-radius:4px; padding:1px 7px; font-size:.78rem; color:var(--maroon); font-weight:700; }
.formed-info{ color:#7a6f5c; font-size:.8rem; background:var(--card); border:1px solid var(--line); border-radius:12px; padding:2px 10px; }
.info-btn{ background:var(--card); border:1px solid var(--line); border-radius:12px; padding:2px 10px; font-size:.78rem; color:var(--maroon); font-weight:700; }
.info-btn:hover{ background:var(--gold-light); }
.sample-count-badge{ font-size:.78rem; color:var(--maroon); font-weight:700; background:var(--parchment-deep); border-radius:10px; padding:1px 8px; }

/* الأبناء والعينات: مسافة بادئة + خط عمودي متصل (نمط YFull) */
.children-list, .samples-list{
  margin-inline-start:9px;
  padding-inline-start:18px;
  border-inline-start:1.5px dashed var(--line);
}

.sample-row{
  display:flex; align-items:center; gap:8px; padding:3px 8px; font-size:.85rem;
  color:#4a4136; cursor:pointer; border-radius:5px; flex-wrap:wrap;
}
.sample-row:hover{ background:rgba(184,134,59,.08); }
.sample-row .sample-icon{ opacity:.6; }
.sample-row .sample-id{ font-style:italic; color:var(--maroon); font-weight:600; }
.sample-row .flag{ font-size:1rem; }
.sample-row .sample-country{ color:#6b6152; }
.sample-row .sample-new{ background:#fbe4e4; color:#B23A3A; font-size:.7rem; font-weight:700; border-radius:8px; padding:0 7px; }

.samples-pager{ display:flex; gap:10px; align-items:center; font-size:.78rem; margin:4px 0 4px 27px; }
.samples-pager button{ background:var(--card); border:1px solid var(--line); border-radius:6px; padding:2px 10px; }

/* ===== Modal (تفاصيل فرع / عينة) ===== */
.modal-overlay{ position:fixed; inset:0; background:rgba(31,27,22,.55); z-index:100; display:flex; align-items:center; justify-content:center; }
.modal-overlay.hidden{display:none;}
.modal-box{ background:var(--card); border-radius:12px; padding:34px; max-width:460px; width:90%; position:relative; border:1px solid var(--gold); max-height:85vh; overflow-y:auto; }
.modal-close{position:absolute; top:12px; left:14px; background:none; border:none; font-size:1.4rem; color:var(--maroon);}
.modal-box h3{font-family:'Amiri', serif; font-size:1.3rem; margin-bottom:16px; color:var(--maroon);}
.modal-row{display:flex; justify-content:space-between; gap:14px; padding:8px 0; border-bottom:1px dotted var(--line); font-size:.9rem;}
.modal-row span:first-child{color:#7a6f5c; flex-shrink:0;}
.modal-row span:last-child{font-weight:700; text-align:left;}
.modal-notes{ margin-top:14px; font-size:.85rem; color:#4a4136; line-height:1.8; white-space:pre-line; }

/* ===== Legend ===== */
.tree-legend{ position:fixed; bottom:16px; left:16px; background:var(--card); border:1px solid var(--line); border-radius:10px; padding:10px 14px; font-size:.78rem; display:flex; gap:12px; flex-wrap:wrap; max-width:260px; z-index:50; box-shadow:0 6px 16px rgba(31,27,22,.1); }
.legend-item{display:flex; align-items:center; gap:6px;}
.legend-dot{width:10px;height:10px;border-radius:50%;}

@media(max-width:700px){
  .tree-wrap{font-size:.85rem; padding:16px 12px 80px;}
  .toolbar-inner{flex-direction:column; align-items:stretch; gap:10px;}
}
