@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;600;700&family=Source+Serif+4:opsz,wght@8..60,500;8..60,700&display=swap');
:root{
  --bg:#0a1628; --ink:#f2efe6; --muted:#9aa8bc; --line:#243247;
  --panel:#122033; --accent:#c9a227; --accent2:#d4af37; --warn:#fbbf24;
  --warn-bg:#3a2e12; --ok:#86efac; --ok-bg:#14532d; --radius:14px;
  --font:"Source Serif 4",Georgia,"Times New Roman",serif;
  --sans:"DM Sans",system-ui,-apple-system,"Segoe UI",sans-serif;
  --bubble-in:#1a2a40; --bubble-out:#1e4d3a; --thread:#0d1b2d;
}
*{box-sizing:border-box}
body{margin:0;font-family:var(--sans);background:
  radial-gradient(900px 420px at 0% 0%, #152a4a 0%, transparent 55%),
  radial-gradient(700px 380px at 100% 10%, #2a2210 0%, transparent 50%),
  var(--bg);color:var(--ink);line-height:1.55;min-height:100vh}
a{color:var(--accent2);text-decoration:none}
a:hover{text-decoration:underline}
.top{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:14px 18px;border-bottom:1px solid var(--line);background:rgba(10,22,40,.92);backdrop-filter:blur(8px);position:sticky;top:0;z-index:5;flex-wrap:wrap}
.brand{font-family:var(--font);font-size:1.25rem;font-weight:700;color:var(--ink);text-decoration:none;display:inline-flex;align-items:center;gap:10px}
.brand-logo{width:40px;height:40px;border-radius:12px;object-fit:cover;background:#0a1628;border:1px solid var(--line);flex-shrink:0}
.top nav{display:flex;gap:6px;flex-wrap:wrap}
.top nav a{padding:7px 12px;border-radius:999px;color:var(--muted);font-size:.92rem}
.top nav a:hover,.top nav a.is-active{background:#1a2a40;color:var(--ink);text-decoration:none}
.wrap{max-width:1100px;margin:0 auto;padding:20px 16px 40px}
.wrap.messenger-shell{max-width:1200px;padding-top:12px;display:flex;flex-direction:column;min-height:calc(100vh - 100px)}
.foot{text-align:center;color:var(--muted);font-size:.85rem;padding:24px 16px 36px;border-top:1px solid var(--line)}
h1{font-family:var(--font);font-size:clamp(1.6rem,3vw,2.1rem);margin:0 0 6px;line-height:1.2}
h2{font-family:var(--font);font-size:1.2rem;margin:0}
.lede{color:var(--muted);max-width:42rem;margin:0 0 18px}
.muted{color:var(--muted)}
.panel{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);padding:18px;margin:16px 0}
.flash{padding:12px 14px;border-radius:10px;margin:0 0 16px}
.flash-ok{background:var(--ok-bg);color:var(--ok);border:1px solid #166534}
.flash-err{background:#450a0a;color:#fecaca;border:1px solid #7f1d1d}
.btn-ghost{appearance:none;border:1px solid var(--line);background:transparent;color:var(--ink);font:inherit;padding:8px 14px;border-radius:10px;cursor:pointer}
.btn-ghost:hover{background:#1a2a40}
.hub-cta{display:inline-block;background:var(--accent);color:#0a1628;border-radius:999px;padding:10px 18px;font-weight:700;text-decoration:none;border:0;cursor:pointer;font:inherit}
.hub-cta:hover{text-decoration:none;filter:brightness(1.06)}
.hub-cta.secondary{background:transparent;color:var(--ink);border:1px solid var(--line)}
.auth-form{display:flex;flex-direction:column;gap:12px;max-width:420px}
.auth-form label{display:flex;flex-direction:column;gap:6px;font-size:.9rem;font-weight:600}
.auth-form input{font:inherit;font-weight:400;padding:10px 12px;border:1px solid var(--line);border-radius:10px;background:#0d1b2d;color:var(--ink)}
.auth-form button{font:inherit;font-weight:700;padding:10px 16px;border-radius:10px;cursor:pointer;border:0;background:var(--accent);color:#0a1628}
.install-steps{margin:0;padding-left:1.2rem}
.install-steps li{margin:8px 0}

.dm-layout{display:grid;grid-template-columns:minmax(220px,300px) minmax(0,1fr);gap:14px;align-items:stretch;flex:1;min-height:0;height:calc(100vh - 210px);max-height:calc(100vh - 210px);overflow:hidden}
.dm-layout--with-friends{grid-template-columns:minmax(220px,320px) minmax(0,1fr)}
.dm-layout--with-friends.is-friends-focus .dm-window.is-empty{display:flex}
.dm-people,.dm-friends{padding:14px 12px;margin:0;background:var(--panel);border:1px solid var(--line);border-radius:var(--radius);overflow-x:hidden;overflow-y:auto;min-height:0;height:100%;max-height:none;-webkit-overflow-scrolling:touch}
.dm-people-title{margin:0 0 12px;font-size:1.05rem}
.dm-friends-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:10px}
.dm-friends-head .dm-people-title{margin:0}
.dm-friends-search{width:100%;box-sizing:border-box;font:inherit;padding:8px 10px;border:1px solid var(--line);border-radius:10px;background:#0d1b2d;color:var(--ink);margin-bottom:8px}
.dm-name-list{list-style:none;padding:0;margin:0}
.dm-name-list li{border-bottom:1px solid var(--line)}
.dm-name-list li:last-child{border-bottom:0}
.dm-name-row{display:flex;justify-content:space-between;align-items:center;gap:10px;padding:12px 8px;color:inherit;text-decoration:none;border-radius:8px}
.dm-name-row:hover{background:#1a2a40;text-decoration:none}
.dm-name-row.is-active{background:#1e334d;box-shadow:inset 3px 0 0 var(--accent)}
.dm-name-row.has-unread{background:rgba(61,214,140,.12);box-shadow:inset 3px 0 0 var(--accent)}
.dm-name-row.has-unread .dm-name{font-weight:800}
.dm-name-row.has-unread .dm-preview{color:var(--ink);font-weight:600}
.dm-kind-tag{display:inline-block;font-size:.68rem;font-weight:700;padding:1px 6px;border-radius:6px;background:#1e334d;color:var(--accent2);vertical-align:middle;margin-left:4px}
.dm-profile-switch{margin:0 0 14px}
.dm-profile-switch label{display:flex;flex-wrap:wrap;align-items:center;gap:8px;font-weight:600}
.dm-profile-switch select{min-width:220px;max-width:100%;padding:8px 10px;border-radius:10px;border:1px solid var(--line);background:var(--panel);color:inherit;font:inherit}
.dm-name{font-weight:650;font-size:1rem}
.dm-name-meta{display:flex;align-items:center;gap:8px;flex-shrink:0;font-size:.82rem}
.dm-badge{background:var(--accent);color:#0a1628;font-size:.72rem;font-weight:700;min-width:1.25em;padding:2px 7px;border-radius:999px;text-align:center}
.dm-window{display:flex;flex-direction:column;min-height:0;height:100%;border:1px solid var(--line);border-radius:var(--radius);background:var(--panel);overflow:hidden}
.dm-window.is-empty{justify-content:center;align-items:center}
.dm-window-placeholder{padding:28px;text-align:center}
.dm-window-head{display:flex;flex-direction:column;gap:4px;padding:12px 16px;border-bottom:1px solid var(--line);background:#0f1c2e;flex-shrink:0}
.dm-window-head h2{margin:0;font-size:1.1rem}
.dm-back{display:none;font-size:.9rem;color:var(--accent2);text-decoration:none;width:fit-content}
.dm-back:hover{text-decoration:underline}
.chat-thread{
  flex:1 1 auto;overflow-x:hidden;overflow-y:auto;padding:14px 12px;min-height:0;-webkit-overflow-scrolling:touch;background:
    linear-gradient(180deg, rgba(10,22,40,.35), rgba(10,22,40,.55)),
    var(--thread)
}
.chat-thread--empty{display:flex;align-items:center;justify-content:center}
.chat-row{display:flex;flex-direction:column;gap:.12rem;margin:.35rem 0;max-width:100%}
.chat-row.inbound{align-items:flex-start}
.chat-row.outbound{align-items:flex-end}
.chat-meta{font-size:.7rem;color:var(--muted);padding:0 .25rem}
.chat-bubble{
  max-width:min(78%,420px);padding:9px 12px;border-radius:14px;font-size:.95rem;line-height:1.4;
  box-shadow:0 1px 1px rgba(0,0,0,.18);word-wrap:break-word
}
.chat-bubble.inbound{background:var(--bubble-in);color:var(--ink);border-bottom-left-radius:5px}
.chat-bubble.outbound{background:var(--bubble-out);color:#e8fff4;border-bottom-right-radius:5px}
.dm-compose{display:flex;flex-direction:column;gap:8px;padding:12px;border-top:1px solid var(--line);background:#0f1c2e;flex-shrink:0}
.dm-compose-row{display:flex;gap:10px;align-items:flex-end;width:100%}
.dm-compose textarea{flex:1;border:1px solid var(--line);border-radius:12px;padding:10px 12px;font:inherit;resize:vertical;min-height:44px;max-height:140px;background:#0d1b2d;color:var(--ink)}
.dm-compose-row > button[type=submit]{border:0;background:var(--accent);color:#0a1628;border-radius:12px;padding:11px 18px;font-weight:700;cursor:pointer}
.dm-compose-row > button[type=submit]:hover{filter:brightness(1.05)}
.dm-attach-btn{border:1px solid var(--line);background:#152536;color:var(--accent);border-radius:12px;width:44px;height:44px;font-size:1.35rem;line-height:1;cursor:pointer;flex-shrink:0}
.dm-attach-btn:hover{background:#1a2a40}
.dm-file-input{position:absolute;width:1px;height:1px;opacity:0;pointer-events:none}
.dm-attach-preview{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px 10px;border:1px dashed var(--line);border-radius:10px;background:#0d1b2d;font-size:.9rem}
.dm-attach-clear{border:0;background:transparent;color:var(--muted);cursor:pointer;font:inherit}
.dm-name-stack{display:flex;flex-direction:column;gap:2px;min-width:0}
.dm-preview{font-size:.78rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:160px}
.chat-text{margin-top:4px}
.dm-attach{margin:0 0 6px}
.dm-attach-img{display:block;border-radius:10px;overflow:hidden}
.dm-attach-img img{display:block;max-width:100%;max-height:280px;object-fit:cover}
.dm-attach-doc{display:inline-block;padding:8px 10px;border-radius:10px;background:rgba(0,0,0,.2);color:inherit;text-decoration:none;font-weight:600}
.dm-attach-card{display:flex;flex-direction:column;gap:4px;padding:10px;border-radius:10px;background:rgba(0,0,0,.18);color:inherit;text-decoration:none}
.dm-attach-card strong{font-size:.95rem}
.dm-attach-card span{font-size:.85rem;opacity:.9}
.dm-attach-ref{flex-direction:row;align-items:center;gap:10px}
.dm-attach-ref img{width:64px;height:64px;object-fit:cover;border-radius:8px;flex-shrink:0;background:#111}
.dm-attach-ref-text{display:flex;flex-direction:column;gap:2px;min-width:0}
.dm-attach-ref-text em{font-style:normal;font-size:.72rem;text-transform:uppercase;letter-spacing:.04em;opacity:.75}
.dm-sheet{border:0;padding:0;border-radius:16px;background:var(--panel);color:var(--ink);width:min(420px,94vw);max-height:85vh;box-shadow:0 20px 50px rgba(0,0,0,.45)}
.dm-sheet::backdrop{background:rgba(0,0,0,.55)}
.dm-sheet-inner{padding:14px 16px 18px;display:flex;flex-direction:column;gap:12px}
.dm-sheet-head{display:flex;align-items:center;justify-content:space-between;gap:10px}
.dm-sheet-head h3{margin:0;font-size:1.1rem}
.dm-sheet-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.dm-sheet-grid button{border:1px solid var(--line);background:#0d1b2d;color:var(--ink);border-radius:12px;padding:14px 10px;font:inherit;font-weight:600;cursor:pointer;text-align:left}
.dm-sheet-grid button:hover{border-color:var(--accent);background:#152536}
.dm-sheet-inner label{display:flex;flex-direction:column;gap:6px;font-size:.9rem;font-weight:600}
.dm-sheet-inner input[type=search],.dm-sheet-inner input:not([type=hidden]){font:inherit;font-weight:400;padding:10px 12px;border:1px solid var(--line);border-radius:10px;background:#0d1b2d;color:var(--ink)}
.dm-pick-list{display:flex;flex-direction:column;gap:6px;max-height:50vh;overflow:auto}
.dm-pick-item{display:grid;grid-template-columns:52px 1fr;gap:10px;align-items:center;border:1px solid var(--line);background:#0d1b2d;color:inherit;border-radius:10px;padding:8px;text-align:left;cursor:pointer;font:inherit}
.dm-pick-item:hover{border-color:var(--accent)}
.dm-pick-item img,.dm-pick-ph{width:52px;height:52px;border-radius:8px;object-fit:cover;background:#1a2a40}
.dm-pick-item strong{display:block;font-size:.92rem;line-height:1.25}
.dm-pick-item small{display:block;color:var(--muted);font-size:.78rem;margin-top:2px}
.dm-speak-as{display:flex;flex-direction:column;gap:4px;font-size:.85rem;color:var(--muted)}
.dm-speak-as select{font:inherit;padding:8px 10px;border-radius:10px;border:1px solid var(--line);background:#0d1b2d;color:var(--ink)}
.dm-attach-expired{padding:8px 10px;border-radius:10px;background:rgba(0,0,0,.18);font-size:.88rem}

/* Quran verse beside logo */
.brand-cluster{display:inline-flex;align-items:center;gap:10px;flex-wrap:nowrap;max-width:min(100%,640px)}
.brand-verse{min-width:0;flex:1;line-height:1.25;padding-left:8px;border-left:1px solid var(--line)}
.brand-verse-ar{margin:0;font-size:clamp(.68rem,1.5vw,.9rem);font-family:"Amiri","Scheherazade New","Noto Naskh Arabic",serif;color:var(--ink)}
.brand-verse-tr{margin:2px 0 0;font-size:clamp(.62rem,1.2vw,.75rem);color:var(--muted)}
.brand-verse-ref{margin:2px 0 0;font-size:.6rem;color:var(--muted);opacity:.85}
@media (max-width:720px){
  .brand-verse-tr,.brand-verse-ref{display:none}
  .brand-verse-ar{font-size:.68rem}
}

@media (max-width:980px){
  .dm-layout--with-friends{grid-template-columns:minmax(180px,1fr) minmax(0,1fr)}
}
@media (max-width:760px){
  .dm-layout,.dm-layout--with-friends{grid-template-columns:1fr;height:auto;max-height:none;overflow:visible}
  .dm-layout.is-open .dm-people,
  .dm-layout.is-open .dm-friends{display:none}
  .dm-layout:not(.is-open) .dm-window{display:none}
  .dm-layout.is-friends-focus:not(.is-open) .dm-people{display:none}
  .dm-layout.is-friends-focus:not(.is-open) .dm-friends{display:block}
  .dm-layout:not(.is-friends-focus):not(.is-open) .dm-friends{display:none}
  .dm-people,.dm-friends{height:auto;max-height:50vh}
  .dm-back{display:inline-block}
  .dm-window,.dm-window.is-empty{min-height:70vh;height:auto}
}
