/* تواصل العائلة — تصميم كبير الخط وواضح لكبار السن والأطفال */
:root{
  --green:#0b7a5a; --green-d:#075c43; --bg:#f3f1ec; --card:#fff; --ink:#1d1d1b;
  --muted:#6b6b66; --mine:#d7f2e4; --red:#d62828; --blue:#1d4ed8;
  --fs:22px;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;height:100%;background:var(--bg);color:var(--ink);
  font-family:"Noto Kufi Arabic","Segoe UI",Tahoma,system-ui,sans-serif;font-size:var(--fs);line-height:1.5}
button,input,textarea,a.big{font:inherit}
.hidden{display:none!important}
.screen{min-height:100%;display:flex;flex-direction:column}

/* -------- البداية -------- */
#welcome{align-items:center;justify-content:center;padding:24px;text-align:center;gap:10px}
.logo{font-size:80px}
h1{margin:0;font-size:36px;color:var(--green)}
.sub{margin:0 0 16px;color:var(--muted)}
.stack{display:flex;flex-direction:column;gap:14px;width:100%;max-width:440px}
.card{background:var(--card);padding:20px;border-radius:20px;box-shadow:0 2px 10px #0001;text-align:right}
label{display:flex;flex-direction:column;gap:6px;font-weight:bold}
input,textarea{border:2px solid #ccc;border-radius:14px;padding:14px;font-size:24px;width:100%;background:#fff}
input:focus,textarea:focus{outline:none;border-color:var(--green)}
.big{display:block;width:100%;min-height:64px;border:0;border-radius:18px;background:var(--green);
  color:#fff;font-size:24px;font-weight:bold;cursor:pointer;padding:12px;text-decoration:none;text-align:center}
.big:active{transform:scale(.98)}
.big.alt{background:#fff;color:var(--green);border:3px solid var(--green)}
.big.outline{background:transparent;color:var(--green);border:3px solid var(--green)}
.big.red{background:var(--red)}
.link{background:none;border:0;color:var(--muted);text-decoration:underline;font-size:20px}
.err{color:var(--red);font-weight:bold;min-height:1.5em}

/* -------- الرأس والأزرار -------- */
.top{display:flex;align-items:center;gap:10px;padding:10px 14px;background:var(--green);color:#fff;
  position:sticky;top:0;z-index:5;padding-top:max(10px,env(safe-area-inset-top))}
.title{flex:1}
#famName{font-size:26px;font-weight:bold}
#onlineCount{opacity:.9;font-size:16px}
.dot{width:16px;height:16px;border-radius:50%;background:#aaa;flex:none;border:2px solid #fff}
.dot.on{background:#4ade80}
.icon{background:none;border:0;font-size:30px;min-width:52px;min-height:52px;cursor:pointer;border-radius:14px}
.top .icon{color:#fff}
.actions{display:grid;grid-template-columns:repeat(4,1fr);gap:8px;padding:10px;background:#fff;
  box-shadow:0 2px 6px #0001}
.actions button{border:0;border-radius:18px;background:#eef6f2;padding:10px 4px;display:flex;
  flex-direction:column;align-items:center;gap:2px;cursor:pointer;min-height:88px;font-weight:bold;color:var(--ink)}
.actions b{font-size:36px;line-height:1.1}
.actions span{font-size:18px}
.actions .sos{background:var(--red);color:#fff}
.actions .active{background:var(--blue);color:#fff}
.bar{background:#fff7d6;padding:10px 14px;font-size:18px;display:flex;align-items:center;gap:10px;justify-content:space-between}
.bar.warn{background:#ffe2e2}
.bar button{border:0;background:var(--green);color:#fff;border-radius:12px;padding:8px 16px;font-size:18px;font-weight:bold}
#locBar .bar{background:#e3ecff}
#locBar a{color:var(--blue);font-weight:bold}

/* -------- الرسائل -------- */
#msgs{flex:1;overflow-y:auto;padding:12px 10px 120px;display:flex;flex-direction:column;gap:10px}
.msg{max-width:86%;background:#fff;border-radius:18px;padding:10px 14px;box-shadow:0 1px 3px #0002;
  align-self:flex-start;word-wrap:break-word;white-space:pre-wrap}
.msg.mine{background:var(--mine);align-self:flex-end}
.msg .who{font-weight:bold;color:var(--green);font-size:18px}
.msg .time{font-size:14px;color:var(--muted);text-align:left;margin-top:2px}
.msg.pending{opacity:.6}
.msg img,.msg video{max-width:100%;border-radius:12px;display:block;margin-top:6px;max-height:60vh}
.msg audio{width:260px;max-width:100%;margin-top:6px}
.msg .file{display:inline-block;margin-top:6px;padding:10px 14px;border-radius:12px;background:#eef;color:var(--blue);font-weight:bold}
.msg.system{align-self:center;background:#e7e4dc;box-shadow:none;font-size:17px;color:#444;text-align:center}
.msg.emergency{background:var(--red);color:#fff;align-self:stretch;max-width:100%}
.msg.emergency .who,.msg.emergency .time{color:#fff}
.msg.emergency a{color:#fff;font-weight:bold}
.day{align-self:center;font-size:15px;color:var(--muted);background:#fff;border-radius:10px;padding:2px 12px}

/* -------- الكتابة -------- */
.compose{position:fixed;bottom:0;left:0;right:0;display:flex;align-items:flex-end;gap:6px;padding:8px;
  background:#fff;box-shadow:0 -2px 8px #0002;padding-bottom:max(8px,env(safe-area-inset-bottom))}
.compose textarea{flex:1;resize:none;max-height:140px;font-size:22px;padding:12px}
.compose .send{background:var(--green);color:#fff;transform:scaleX(-1)}
.compose .rec{background:var(--red);color:#fff}
.recbar{position:fixed;bottom:84px;left:8px;right:8px;background:#fff;border:3px solid var(--red);
  border-radius:16px;padding:10px;font-weight:bold;display:flex;justify-content:space-between;align-items:center}
.recbar button{border:0;background:#eee;border-radius:10px;padding:6px 14px;font-size:18px}

/* -------- النافذة المنبثقة -------- */
.modal{position:fixed;inset:0;background:#0008;z-index:20;display:flex;align-items:flex-end;justify-content:center}
.sheet{background:#fff;width:100%;max-width:560px;max-height:90vh;overflow:auto;border-radius:24px 24px 0 0;
  padding:20px;display:flex;flex-direction:column;gap:14px;padding-bottom:max(20px,env(safe-area-inset-bottom))}
.sheet h2{margin:0;color:var(--green)}
.person{display:flex;align-items:center;gap:10px;padding:12px;border-radius:16px;background:#f5f5f2;width:100%;
  border:0;font-size:22px;text-align:right;cursor:pointer}
.person .name{flex:1;font-weight:bold}
.person .st{font-size:16px;color:var(--muted)}
.person .st.on{color:#16a34a}
.person .del{background:var(--red);color:#fff;border:0;border-radius:12px;padding:8px 14px;font-size:18px}
.code{font-size:44px;font-weight:bold;letter-spacing:4px;text-align:center;direction:ltr;background:#eef6f2;
  border-radius:16px;padding:12px;color:var(--green-d);user-select:all}
.row{display:flex;gap:10px}.row>*{flex:1}

/* -------- المكالمة -------- */
.call{position:fixed;inset:0;background:#111;z-index:30;color:#fff}
#remoteVideo{width:100%;height:100%;object-fit:cover;background:#111}
#localVideo{position:absolute;top:90px;left:14px;width:30%;max-width:160px;border-radius:14px;border:3px solid #fff;background:#333}
.callTop{position:absolute;top:0;left:0;right:0;padding:24px;text-align:center;background:linear-gradient(#000a,#0000)}
#callName{font-size:34px;font-weight:bold}
#callState{font-size:22px;opacity:.9}
.callBtns{position:absolute;bottom:40px;left:0;right:0;display:flex;justify-content:center;gap:22px}
.round{width:80px;height:80px;border-radius:50%;border:0;font-size:34px;background:#fff3;color:#fff;cursor:pointer}
.round.green{background:#16a34a;animation:pulse 1s infinite}
.round.red{background:var(--red)}
.round.off{background:#fff;color:#000}
@keyframes pulse{50%{transform:scale(1.12)}}

/* -------- الطوارئ -------- */
.sosview{position:fixed;inset:0;z-index:40;background:var(--red);color:#fff;display:flex;flex-direction:column;
  align-items:center;justify-content:center;gap:16px;padding:24px;text-align:center}
.sosIcon{font-size:110px;animation:pulse .8s infinite}
.sosview h2{font-size:34px;margin:0}
.sosview p{font-size:24px;margin:0}
.big.white{background:#fff;color:var(--red);max-width:440px}
.big.white.outline{background:transparent;color:#fff;border:3px solid #fff}
#sosCount{font-size:90px;font-weight:bold}

.toast{position:fixed;top:90px;left:50%;transform:translateX(-50%);background:#222;color:#fff;padding:12px 20px;
  border-radius:14px;z-index:50;font-size:20px;max-width:90%;text-align:center}
