@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@500;600;700;800&display=swap');
:root{--bg:#0b1020;--panel:#111a2e;--panel2:#17233b;--line:#263550;--text:#f4f7ff;--muted:#93a3bd;--accent:#8b7cff;--accent2:#6b5ce7;--green:#43d6a0;--danger:#f16d7a}
*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--text);font-family:'DM Sans',sans-serif;min-height:100vh}button,input{font:inherit}button{cursor:pointer;border:0;color:inherit}.hidden{display:none!important}.muted{color:var(--muted)}.fine{font-size:11px;line-height:1.6;color:#8191aa}.eyebrow{font-size:10px;letter-spacing:2px;font-weight:700;color:#a99fff;margin:0 0 9px}.brand-mark{width:48px;height:48px;border-radius:16px;background:linear-gradient(135deg,#a59aff,#6555dc);display:grid;place-items:center;font:800 24px Manrope;box-shadow:0 8px 24px #7564ef44;margin:0 auto 22px;object-fit:contain}.brand-mark.small{width:34px;height:34px;border-radius:11px;font-size:18px;margin:0}
.auth-wrap{min-height:100vh;display:grid;place-items:center;padding:24px;background:radial-gradient(ellipse at 50% 0%,#292455 0,transparent 55%)}.auth-card{width:min(100%,420px);padding:38px;background:#111a2eef;border:1px solid var(--line);border-radius:24px;box-shadow:0 24px 80px #0005}.auth-card h1{text-align:center;font:800 28px Manrope;margin:0}.auth-card h1 span{color:#a99fff}.auth-card>.muted{text-align:center;margin:10px 0 26px}.tabs{display:flex;padding:4px;background:#0c1425;border-radius:12px;margin-bottom:22px}.tab{flex:1;padding:11px;border-radius:9px;background:transparent;color:var(--muted)}.tab.active{background:#263452;color:white}
label{display:block;font-size:12px;color:#c1cbe0;margin:14px 0}input{width:100%;margin-top:8px;padding:13px 14px;border:1px solid #2c3b59;border-radius:10px;background:#0b1426;color:white;outline:none}input:focus{border-color:var(--accent);box-shadow:0 0 0 3px #8b7cff22}input::placeholder{color:#63738f}.primary{background:linear-gradient(135deg,#9487ff,#6858e5);padding:12px 17px;border-radius:10px;font-weight:700;box-shadow:0 7px 18px #6d5de533}.primary:hover{filter:brightness(1.08)}.full{width:100%;margin-top:10px}.secondary{background:#263550;border:1px solid #344663;padding:10px 13px;border-radius:10px}.message{font-size:12px;color:#ffb7be;min-height:16px}
.app{height:100vh;display:grid;grid-template-columns:300px 1fr;max-width:1600px;margin:auto}.sidebar{background:#0f182a;border-right:1px solid var(--line);padding:24px 17px;display:flex;flex-direction:column;min-height:0}.side-brand{display:flex;align-items:center;gap:11px;font:800 19px Manrope;margin:0 8px 30px}.my-profile{display:flex;align-items:center;gap:11px;padding:12px;background:#17233a;border:1px solid #273854;border-radius:14px}.avatar{width:40px;height:40px;flex:none;border-radius:14px;background:linear-gradient(135deg,#8b7cff,#3e9dba);display:grid;place-items:center;font-weight:800;color:white}.profile-text{min-width:0;flex:1}.profile-text strong,.chat-title strong{display:block;font-size:13px}.profile-text small,.chat-title small{font-size:11px;color:var(--muted)}.icon-btn{background:transparent;color:#aab8ce;font-size:18px;padding:6px}.side-heading{display:flex;justify-content:space-between;align-items:center;font-size:10px;letter-spacing:1.4px;font-weight:700;color:#8292ac;margin:27px 8px 12px}.text-btn{background:none;color:#a99fff;font-size:12px;font-weight:700;letter-spacing:0}.friends-list{overflow:auto;flex:1}.friend-item{width:100%;display:flex;align-items:center;gap:10px;padding:11px 9px;border-radius:12px;background:transparent;text-align:left}.friend-item:hover,.friend-item.selected{background:#1c2a45}.friend-item .avatar{width:37px;height:37px;border-radius:12px}.friend-item strong{font-size:13px;display:block}.friend-item small{font-size:11px;color:var(--muted)}.side-bottom{margin-top:12px}.side-bottom .fine{padding:0 5px}.pad{padding:10px;font-size:12px}
.chat-panel{display:flex;flex-direction:column;min-width:0;background:radial-gradient(ellipse at 80% 0%,#1a2340 0,transparent 45%),#0d1526}.chat-header{height:80px;border-bottom:1px solid var(--line);display:flex;align-items:center;gap:12px;padding:0 28px}.chat-title{flex:1}.empty-state{margin:auto;text-align:center;padding:25px}.empty-icon{font-size:42px;color:#a99fff}.empty-state h2{font:700 23px Manrope;margin:12px 0 8px}.empty-state p{font-size:13px;color:var(--muted);margin:0 0 20px}.messages{flex:1;overflow:auto;padding:25px max(24px,calc((100% - 850px)/2));display:flex;flex-direction:column;gap:12px}.bubble-row{display:flex}.bubble-row.mine{justify-content:flex-end}.bubble{max-width:min(72%,520px);padding:11px 14px;border-radius:16px;background:#1c2a45;font-size:13px;line-height:1.5;overflow-wrap:anywhere}.mine .bubble{background:#6558cf;border-bottom-right-radius:5px}.bubble-row:not(.mine) .bubble{border-bottom-left-radius:5px}.bubble time{display:block;font-size:9px;color:#c2c9ddaa;margin-top:5px;text-align:right}.composer{display:flex;gap:10px;padding:17px max(24px,calc((100% - 850px)/2));border-top:1px solid var(--line)}.composer input{margin:0;flex:1}.send-btn{width:48px}.modal{background:#121d32;color:var(--text);border:1px solid #34435e;border-radius:20px;padding:25px;width:min(92vw,430px);box-shadow:0 25px 90px #0009}.modal::backdrop{background:#050914c9;backdrop-filter:blur(5px)}.modal-top{display:flex;justify-content:space-between;align-items:flex-start}.modal h2{font:800 23px Manrope;margin:0 0 14px}.result-area{margin:15px 0;max-height:260px;overflow:auto}.result-row{display:flex;align-items:center;gap:10px;padding:11px 0;border-bottom:1px solid var(--line)}.result-row .grow{flex:1}.result-row strong{font-size:13px}.result-row small{display:block;color:var(--muted);font-size:11px}.result-row button{font-size:11px}.toast{position:fixed;bottom:22px;left:50%;transform:translate(-50%,20px);background:#263550;border:1px solid #405174;padding:12px 18px;border-radius:12px;font-size:12px;opacity:0;pointer-events:none;transition:.2s;z-index:10}.toast.show{opacity:1;transform:translate(-50%,0)}
@media(max-width:700px){.app{grid-template-columns:1fr;grid-template-rows:220px 1fr}.sidebar{padding:12px 14px;border-right:0;border-bottom:1px solid var(--line)}.side-brand{margin:0 4px 10px}.my-profile{padding:7px 10px}.side-heading{margin:12px 5px 5px}.friends-list{display:flex;gap:5px;overflow-x:auto;overflow-y:hidden;flex:none}.friend-item{min-width:125px;padding:7px}.side-bottom{display:none}.chat-header{height:66px;padding:0 15px}.messages{padding:18px 14px}.composer{padding:12px}.auth-card{padding:28px 22px}}
/* Updated Connect features */
.avatar{overflow:hidden}.avatar img{width:100%;height:100%;object-fit:cover}.group-heading{margin-top:18px}.groups-list{flex:0 0 auto;max-height:180px}.setting-row{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:13px 0;border-bottom:1px solid var(--line);font-size:13px}.setting-row small{display:block;color:var(--muted);font-size:11px;margin-top:4px;line-height:1.4}.check{width:19px;height:19px;margin:0;accent-color:#8b7cff;flex:none}.check-row{display:flex;align-items:center;gap:10px;padding:10px 4px;border-bottom:1px solid var(--line);margin:0}.check-row input{width:17px;height:17px;margin:0;accent-color:#8b7cff}.check-row span{font-size:13px}.check-row small{color:var(--muted);font-size:11px}.small-note{font-size:12px}.sender-name{display:block;font-weight:700;color:#c5bcff;font-size:10px;margin-bottom:4px}.modal form label input[type=url]{margin-top:8px}
@media(max-width:700px){.app{grid-template-rows:minmax(250px,42vh) 1fr}.groups-list{max-height:60px}.side-bottom{display:block}.side-bottom .fine{display:none}.side-bottom button{width:auto;margin-right:6px}.sidebar{overflow:hidden}.friends-list{min-height:45px}.group-heading{margin-top:7px}.my-profile{min-height:54px}}
/* Connect additions */
.avatar{overflow:hidden}.avatar img{width:100%;height:100%;object-fit:cover}.group-heading{margin-top:18px}.groups-list{flex:0 0 auto;max-height:180px}.setting-row{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:13px 0;border-bottom:1px solid var(--line);font-size:13px}.setting-row small{display:block;color:var(--muted);font-size:11px;margin-top:4px;line-height:1.4}.check{width:19px;height:19px;margin:0;accent-color:#8b7cff;flex:none}.check-row{display:flex;align-items:center;gap:10px;padding:10px 4px;border-bottom:1px solid var(--line);margin:0}.check-row input{width:17px;height:17px;margin:0;accent-color:#8b7cff}.check-row span{font-size:13px}.check-row small{color:var(--muted);font-size:11px}.small-note{font-size:12px}.sender-name{display:block;font-weight:700;color:#c5bcff;font-size:10px;margin-bottom:4px}
@media(max-width:700px){.app{grid-template-rows:minmax(250px,42vh) 1fr}.groups-list{max-height:60px}.side-bottom{display:block}.side-bottom .fine{display:none}.side-bottom button{width:auto;margin-right:6px}.sidebar{overflow:hidden}.friends-list{min-height:45px}.group-heading{margin-top:7px}.my-profile{min-height:54px}}

/* Fixed-height side panel: keep the sidebar tied to the viewport, not chat content. */
html,body{height:100%;min-height:0}
body{overflow:hidden}
.app{height:100vh;height:100dvh;min-height:0;overflow:hidden;grid-template-rows:minmax(0,1fr)}
.sidebar{height:100%;min-height:0;max-height:100%;overflow:hidden}
.friends-list{min-height:0;max-height:100%;overflow-y:auto;overscroll-behavior:contain}
.groups-list{min-height:0;overflow-y:auto;overscroll-behavior:contain}
.chat-panel{height:100%;min-height:0;overflow:hidden}
.messages{min-height:0;overscroll-behavior:contain}
@media(max-width:700px){
  body{overflow:hidden}
  .app{height:100vh;height:100dvh;min-height:0;grid-template-rows:minmax(250px,42vh) minmax(0,1fr)}
  .sidebar{height:auto;max-height:none;min-height:0;overflow:hidden}
  .friends-list{min-height:45px;max-height:none;overflow-x:auto;overflow-y:hidden}
  .groups-list{max-height:60px;overflow-y:auto}
  .chat-panel{height:auto;min-height:0}
}

/* Chat photo/video attachments */
.attach-btn{width:44px;min-width:44px;padding:8px 0;font-size:22px;line-height:1}
.chat-media{display:block;width:min(100%,420px);max-height:360px;object-fit:contain;border-radius:10px;margin:4px 0 8px;background:#080d18}
.media-loading,.media-unavailable{font-size:11px;color:#c1cbe0;padding:8px 0}
.bubble:has(.chat-media){min-width:180px}
@media(max-width:700px){.chat-media{max-width:min(72vw,360px);max-height:280px}}

/* Unread-message indicator in the conversation list. */
.friend-item{position:relative}
.friend-item.has-unread::after{content:"";width:10px;height:10px;min-width:10px;border-radius:50%;background:#ef4444;box-shadow:0 0 0 2px #0f182a;margin-left:auto;align-self:center}

.group-members-heading{font-size:13px;margin:18px 0 6px;color:var(--muted)}.group-members-list{max-height:320px}.group-member-row{display:flex;align-items:center;gap:12px;padding:10px 2px;border-bottom:1px solid var(--line)}.group-member-avatar{width:38px;height:38px;flex:none;border-radius:50%;display:grid;place-items:center;background:#293957;color:var(--text);font-size:13px;font-weight:700}.group-member-row .grow{min-width:0}.group-member-row strong{display:block;font-size:13px}.group-member-row small{display:block;color:var(--muted);font-size:11px;margin-top:3px}.danger{background:#a9364d;color:white;border:1px solid #c94a62;border-radius:10px;padding:11px 15px;font-weight:700;cursor:pointer}.danger:hover{background:#bf3e58}

/* Make the chat Options control clearly visible in the chat header. */
.chat-header .chat-options-button{
  display:none;
  flex:0 0 auto;
  align-items:center;
  justify-content:center;
  min-width:88px;
  min-height:40px;
  margin-left:8px;
  padding:10px 16px;
  border:1px solid #52658a;
  border-radius:10px;
  background:#344765;
  color:#fff;
  font-size:13px;
  font-weight:700;
  position:relative;
  z-index:2;
}
.chat-header .chat-options-button:hover{background:#40577b}

/* Keep Direct Messages usable even when the group list gets long. */
@media (min-width:701px){
  .sidebar{display:flex;flex-direction:column;min-height:0;}
  #friendsList.friends-list{
    flex:1 1 0%;
    min-height:120px;
    max-height:none;
    overflow-y:auto;
    overflow-x:hidden;
  }
  #groupsList.groups-list{
    flex:0 1 150px;
    min-height:48px;
    max-height:150px;
    overflow-y:auto;
    overflow-x:hidden;
  }
  .group-heading{flex:0 0 auto;}
  .side-bottom{flex:0 0 auto;}
}

/* Group options: rename and add friends */
.group-rename-form{display:flex;align-items:end;gap:10px;margin:12px 0 16px}
.group-rename-form label{flex:1;min-width:0}
.group-rename-form input{width:100%;margin-top:6px}
.group-rename-form button{flex:none;white-space:nowrap}
.group-add-friends{max-height:190px;overflow:auto;margin:6px 0 12px}
.group-add-row{display:flex;align-items:center;gap:10px;padding:8px 2px}
.group-add-avatar{width:32px;height:32px;flex:none}
.group-add-row small{color:var(--muted);margin-left:4px}
.group-leave-button{margin-top:14px}
@media(max-width:480px){.group-rename-form{align-items:stretch;flex-direction:column}.group-rename-form button{width:100%}}


/* Responsive login/signup sizing: keep the auth card within the visible screen. */
.auth-wrap{
  min-height:100vh;
  min-height:100svh;
  height:100vh;
  height:100dvh;
  padding:clamp(8px,2vh,24px) 16px;
  overflow-y:auto;
  align-items:center;
}
.auth-card{
  padding:clamp(18px,3.5vh,38px);
  max-height:100%;
  overflow-y:auto;
}
.auth-card .brand-mark{margin-bottom:clamp(8px,1.8vh,22px)}
.auth-card>.muted{margin:8px 0 clamp(12px,2vh,26px)}
.auth-card .tabs{margin-bottom:clamp(10px,1.8vh,22px)}
.auth-card label{margin:clamp(8px,1.4vh,14px) 0}
.auth-card input{padding:clamp(10px,1.4vh,13px) 14px}
.auth-card .fine{margin:12px 0 0}
@media(max-height:700px){
  .auth-wrap{padding-top:8px;padding-bottom:8px}
  .auth-card{padding:16px 22px}
  .auth-card .brand-mark{width:38px;height:38px;border-radius:12px;font-size:20px;margin-bottom:7px}
  .auth-card .eyebrow{margin-bottom:5px}
  .auth-card h1{font-size:24px}
  .auth-card>.muted{margin:5px 0 10px}
  .auth-card .tabs{margin-bottom:9px}
  .auth-card label{margin:7px 0}
  .auth-card input{margin-top:5px;padding:9px 12px}
  .auth-card .full{margin-top:7px}
  .auth-card .fine{margin-top:8px;line-height:1.4}
}
