*{margin:0;padding:0;box-sizing:border-box}
:root{--blue:#0866ff;--bg:#f0f2f5;--card:#fff;--border:#dddfe2;--text:#050505;--muted:#65676b;--hover:#f2f2f2}
body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;background:var(--bg);color:var(--text)}
a{color:inherit;text-decoration:none}
.hidden{display:none !important}
.card{background:var(--card);border-radius:8px;box-shadow:0 1px 2px rgba(0,0,0,.12);overflow:hidden}
.btn-primary{background:var(--blue);color:#fff;border:none;border-radius:8px;padding:10px;font-weight:600;cursor:pointer;width:100%}
.btn-primary:disabled{background:#e4e6eb;color:#bcc0c4;cursor:not-allowed}
.btn-green{background:#42b72a;color:#fff;border:none;border-radius:8px;padding:12px 18px;font-weight:700;font-size:17px;cursor:pointer}
.btn-green:hover{background:#36a420}
.btn-secondary{background:#e4e6eb;border:none;border-radius:8px;padding:8px 12px;font-weight:600;cursor:pointer}
.btn-danger{background:#f02849;color:#fff;border:none;border-radius:8px;padding:8px 12px;font-weight:600;cursor:pointer}
.btn-danger:hover{background:#d92544}
.btn-secondary.full{width:100%}
.muted{color:var(--muted);font-size:14px}
.tiny{font-size:11px;color:var(--muted);margin:8px 0}

/* Login */
#loginScreen{min-height:100vh;display:flex;align-items:center;justify-content:center;gap:60px;padding:40px 20px;background:var(--bg)}
#loginScreen.hidden{display:none !important}
.login-left{max-width:500px}
.login-left h1{color:var(--blue);font-size:60px;font-weight:800;letter-spacing:-2px}
.login-left p{font-size:28px;line-height:1.2;margin-top:10px}
.login-features{display:flex;flex-direction:column;gap:8px;margin-top:20px;color:var(--muted)}
.login-card{width:400px;padding:16px;display:flex;flex-direction:column;gap:12px;text-align:center}
.login-card input{padding:14px;border:1px solid var(--border);border-radius:8px;font-size:17px;outline:none}
.login-card input:focus{border-color:var(--blue)}
.login-card hr{border:none;border-top:1px solid var(--border);margin:8px 0}
.login-card small{font-size:12px;color:var(--muted)}
.demo-hint{background:#fff4cc;padding:8px;border-radius:8px;font-size:12px;color:#7a6200}
.register-box{max-width:432px;padding:0}
.register-box .modal-head{padding:16px;border-bottom:1px solid var(--border)}
.register-box input, .register-box select{padding:11px;border:1px solid var(--border);border-radius:8px;background:var(--bg);width:100%;font-size:15px}
.reg-row{display:flex;gap:10px;padding:0 16px}
.reg-row label{flex:1;background:var(--bg);border:1px solid var(--border);border-radius:8px;padding:8px;display:flex;align-items:center;gap:6px;font-size:13px}
#regEmail,#regPass{margin:0 16px;width:calc(100% - 32px)}
.register-box small{padding:0 16px;font-size:12px;color:var(--muted);margin-top:6px;display:block}

/* Topbar */
.topbar{position:sticky;top:0;z-index:100;display:flex;align-items:center;justify-content:space-between;background:#fff;box-shadow:0 1px 2px rgba(0,0,0,.1);padding:6px 16px;gap:16px}
.topbar-left{display:flex;align-items:center;gap:10px;flex:1}
.logo{width:40px;height:40px;background:var(--blue);color:#fff;display:grid;place-items:center;font-size:28px;font-weight:800;border-radius:50%;cursor:pointer}
.search-box{background:var(--bg);border-radius:999px;display:flex;align-items:center;gap:8px;padding:9px 14px;min-width:240px;max-width:320px;flex:1}
.search-box i{color:var(--muted)}
.search-box input{border:none;background:transparent;outline:none;font-size:15px;width:100%}
.topbar-center{display:flex;gap:4px;flex:1;justify-content:center;max-width:590px}
.nav-icon{flex:1;max-width:111px;display:grid;place-items:center;padding:10px 0;border-radius:8px;color:var(--muted);cursor:pointer;border-bottom:3px solid transparent;position:relative}
.nav-icon i{font-size:22px}
.nav-icon:hover{background:var(--hover)}
.nav-icon.active{color:var(--blue);border-bottom-color:var(--blue);border-radius:0}
.nav-badge{position:absolute;top:2px;right:22px;background:#e41e3f;color:#fff;font-size:11px;padding:1px 5px;border-radius:999px;font-weight:700}
.topbar-right{display:flex;align-items:center;gap:8px;flex:1;justify-content:flex-end}
.circle-btn{width:40px;height:40px;border-radius:50%;border:none;background:#e4e6eb;display:grid;place-items:center;font-size:18px;cursor:pointer;position:relative}
.circle-btn:hover{background:#d8dadf}
.badge{position:absolute;top:-4px;right:-4px;background:#e41e3f;color:#fff;font-size:11px;padding:2px 6px;border-radius:999px;font-weight:700}
.avatar{width:40px;height:40px;border-radius:50%;object-fit:cover}
.avatar-sm{width:36px;height:36px;border-radius:50%;object-fit:cover}
.avatar-sm.rounded{border-radius:8px}

/* Dropdowns */
.dropdown{position:fixed;top:56px;right:16px;width:360px;max-height:80vh;overflow-y:auto;background:var(--card);border-radius:12px;box-shadow:0 8px 30px rgba(0,0,0,.2);z-index:150;padding:8px}
.dropdown-head{display:flex;justify-content:space-between;align-items:center;padding:12px;font-size:18px;font-weight:700}
.dropdown-tabs{display:flex;gap:8px;padding:0 12px 8px}
.dropdown-tabs span{padding:6px 12px;border-radius:999px;background:var(--bg);font-size:14px;font-weight:600;cursor:pointer}
.dropdown-tabs span.active{background:#e7f3ff;color:var(--blue)}
.notif-item{display:flex;gap:10px;padding:8px 12px;border-radius:8px;cursor:pointer;align-items:center}
.notif-item:hover{background:var(--hover)}
.notif-item img{width:56px;height:56px;border-radius:50%;object-fit:cover}
.notif-item .dot{width:8px;height:8px;background:var(--blue);border-radius:50%}
.profile-drop-card{display:flex;gap:12px;padding:12px;align-items:center;cursor:pointer;box-shadow:0 1px 2px rgba(0,0,0,.1);margin:4px}
.profile-drop-card small{color:var(--muted)}
.drop-item{display:flex;align-items:center;gap:12px;padding:10px;border-radius:8px;cursor:pointer;font-weight:500}
.drop-item:hover{background:var(--hover)}
.drop-item i:first-child{width:36px;height:36px;border-radius:50%;display:grid;place-items:center}
.ml{margin-left:auto;color:var(--muted)}

/* Layout */
.layout{display:grid;grid-template-columns:280px 1fr 280px;gap:16px;max-width:1920px;margin:0 auto;padding:16px}
.sidebar{position:sticky;top:62px;height:calc(100vh - 62px);overflow-y:auto;padding:8px}
.sidebar::-webkit-scrollbar{width:8px}
.sidebar::-webkit-scrollbar-thumb{background:transparent;border-radius:999px}
.sidebar:hover::-webkit-scrollbar-thumb{background:#ccd0d5}
.sidebar-item,.sponsored,.contact{display:flex;align-items:center;gap:12px;padding:8px;border-radius:8px;cursor:pointer;font-size:15px;font-weight:500}
.sidebar-item:hover,.contact:hover,.sponsored:hover{background:#e4e6eb}
.sidebar-item.active{background:#e4e6eb}
.sidebar-item i{font-size:20px;width:36px;height:36px;display:grid;place-items:center}
.sidebar-sep{height:1px;background:var(--border);margin:12px 8px}
.sidebar-title{font-size:17px;font-weight:600;color:var(--muted);padding:8px;display:flex;justify-content:space-between;align-items:center}
.sidebar-footer{font-size:12px;color:var(--muted);padding:12px 8px;line-height:1.5}
.sponsored img{width:110px;height:110px;object-fit:cover;border-radius:8px}
.sponsored small{color:var(--muted);font-size:12px;display:block}
.contact{position:relative}
.contact img{width:32px;height:32px;border-radius:50%;object-fit:cover}
.contact .online{width:9px;height:9px;background:#31a24c;border:2px solid #fff;border-radius:50%;position:absolute;left:24px;bottom:6px}
.contact-actions{display:flex;gap:12px;color:var(--muted);font-size:14px}

/* Feed */
.feed{max-width:680px;margin:0 auto;width:100%;display:flex;flex-direction:column;gap:16px}
.view{display:none;flex-direction:column;gap:16px}
.view.active{display:flex}
.view-header{padding:16px}
.view-header h2{font-size:20px}
.tabs{display:flex;gap:8px;margin-top:12px}
.tabs span{padding:8px 12px;border-radius:8px;font-weight:600;font-size:14px;color:var(--muted);cursor:pointer;background:var(--bg)}
.tabs span.active{background:#e7f3ff;color:var(--blue)}
.stories{display:flex;gap:8px;overflow-x:auto;scrollbar-width:none}
.stories::-webkit-scrollbar{display:none}
.story{min-width:140px;height:198px;border-radius:10px;background-size:cover;background-position:center;position:relative;cursor:pointer;overflow:hidden;box-shadow:0 1px 2px rgba(0,0,0,.2);flex-shrink:0;display:flex;align-items:flex-end;padding:10px}
.story::after{content:"";position:absolute;inset:0;background:linear-gradient(to top, rgba(0,0,0,.55), transparent 60%)}
.story span{position:relative;z-index:1;color:#fff;font-size:13px;font-weight:600}
.story-avatar{position:absolute;top:10px;left:10px;z-index:1;width:36px;height:36px;border-radius:50%;border:4px solid var(--blue);overflow:hidden}
.story-avatar img{width:100%;height:100%;object-fit:cover}
.create-story{background:#fff !important;display:flex;flex-direction:column;align-items:stretch;padding:0;justify-content:flex-start}
.create-story img{width:100%;height:148px;object-fit:cover}
.create-story span{color:var(--text);text-align:center;padding:14px 6px 10px;font-size:13px}
.story-create-btn{width:32px;height:32px;background:var(--blue);color:#fff;border-radius:50%;display:grid;place-items:center;border:4px solid #fff;align-self:center;margin-top:-16px;z-index:2}
.create-post{padding:12px 16px}
.create-post-top{display:flex;gap:10px;align-items:center}
.create-post-top button{flex:1;text-align:left;background:var(--bg);border:none;border-radius:999px;padding:11px 14px;color:var(--muted);font-size:17px;cursor:pointer}
.create-post-top button:hover{background:#e4e6eb}
.create-post-actions{display:flex;justify-content:space-between;margin-top:12px;padding-top:12px;border-top:1px solid var(--border)}
.create-post-actions button{flex:1;display:flex;align-items:center;justify-content:center;gap:8px;background:transparent;border:none;padding:8px;border-radius:8px;font-weight:600;color:var(--muted);cursor:pointer;font-size:15px}
.create-post-actions button:hover{background:var(--hover)}
.post{padding:0}
.post-head{display:flex;gap:10px;padding:12px 16px;align-items:center}
.post-head>div{flex:1}
.post-author{font-weight:600;font-size:15px}
.verified{color:var(--blue);font-size:13px}
.post-time{font-size:12px;color:var(--muted)}
.more-btn{width:36px;height:36px;border-radius:50%;border:none;background:transparent;display:grid;place-items:center;cursor:pointer;color:var(--muted)}
.more-btn:hover{background:var(--hover)}
.post-text{padding:0 16px 12px;font-size:15px;line-height:1.4;white-space:pre-wrap}
.post-img{width:100%;max-height:700px;object-fit:cover;display:block;background:#e4e6eb;cursor:pointer}
.post-link-preview{display:flex;flex-direction:column;border:1px solid var(--border);margin:0 16px 8px;border-radius:8px;overflow:hidden}
.post-link-preview img{width:100%;height:260px;object-fit:cover}
.post-link-preview div{padding:10px 12px;background:#f0f2f5}
.post-stats{display:flex;justify-content:space-between;padding:10px 16px;color:var(--muted);font-size:14px;border-bottom:1px solid var(--border);margin:0 16px}
.like-bubble{width:18px;height:18px;background:var(--blue);color:#fff;border-radius:50%;display:inline-grid;place-items:center;font-size:10px;border:2px solid #fff}
.like-bubble.heart{background:#f3425f}
.post-actions{display:flex;padding:4px 16px}
.post-actions button{flex:1;display:flex;align-items:center;justify-content:center;gap:8px;padding:8px;border:none;background:transparent;border-radius:6px;font-weight:600;color:var(--muted);cursor:pointer;font-size:15px}
.post-actions button:hover{background:var(--hover)}
.post-actions .liked{color:var(--blue)}
.comments{padding:8px 16px 12px;display:flex;flex-direction:column;gap:10px}
.comments.hidden{display:none}
.comment{display:flex;gap:8px;align-items:flex-start}
.comment-bubble{background:var(--bg);padding:8px 12px;border-radius:18px;font-size:14px;line-height:1.3;max-width:85%}
.comment-input-row{display:flex;gap:8px;align-items:center}
.commentInput{flex:1;background:var(--bg);border:none;border-radius:999px;padding:9px 14px;outline:none;font-size:14px}
.sendComment{width:36px;height:36px;border-radius:50%;border:none;background:var(--blue);color:#fff;display:grid;place-items:center;cursor:pointer}

/* Friends */
.friends-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:12px}
.friend-card{padding:0;overflow:hidden;text-align:left}
.friend-card img{width:100%;height:180px;object-fit:cover}
.friend-card .info{padding:10px}
.friend-card h4{font-size:15px}
.friend-card small{color:var(--muted);font-size:13px}
.friend-card .actions{display:flex;gap:8px;padding:0 10px 10px}
.friend-card .actions button{flex:1;padding:8px;border-radius:8px;border:none;font-weight:600;cursor:pointer}
.btn-accept{background:var(--blue);color:#fff}
.btn-decline{background:#e4e6eb}
.friend-card.added{opacity:.6}

/* Watch */
.watch-grid{display:grid;gap:12px}
.watch-card{display:flex;gap:12px;padding:12px}
.watch-card video, .watch-card img{width:200px;height:120px;border-radius:8px;object-fit:cover;background:#000;flex-shrink:0}
.watch-card h4{font-size:15px;margin-bottom:4px}
.watch-card p{font-size:13px;color:var(--muted)}

/* Marketplace */
.market-filters{display:flex;gap:8px;margin-top:10px;flex-wrap:wrap}
.market-filters span{padding:6px 12px;border-radius:999px;background:var(--bg);font-size:14px;font-weight:600;cursor:pointer}
.market-filters span.active{background:var(--blue);color:#fff}
.market-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:12px}
.market-card{overflow:hidden;cursor:pointer}
.market-card img{width:100%;height:200px;object-fit:cover}
.market-card .info{padding:10px}
.market-card .price{font-weight:700;font-size:16px}
.market-card .title{font-size:14px}
.market-card small{color:var(--muted)}

/* Groups */
.groups-grid{display:grid;gap:12px}
.group-card{display:flex;gap:14px;padding:12px;align-items:center}
.group-card img{width:80px;height:80px;border-radius:12px;object-fit:cover}
.group-card h4{font-size:16px}
.group-card p{font-size:13px;color:var(--muted)}
.group-card button{margin-left:auto;padding:8px 16px;border-radius:8px;border:none;font-weight:600;cursor:pointer}
.btn-join{background:var(--blue);color:#fff}
.btn-joined{background:#e4e6eb}

/* Profile */
.profile-cover{padding:0;overflow:visible}
.cover{height:350px;background-size:cover;background-position:center;border-radius:8px 8px 0 0}
.profile-info{display:flex;gap:16px;padding:16px;align-items:flex-end;flex-wrap:wrap}
.profile-avatar{width:168px;height:168px;border-radius:50%;border:4px solid #fff;margin-top:-60px;object-fit:cover}
.profile-info h2{font-size:32px}
.profile-info>div{flex:1}
.friend-avatars{display:flex;margin-top:6px}
.friend-avatars img{width:32px;height:32px;border-radius:50%;border:2px solid #fff;margin-left:-8px}
.friend-avatars img:first-child{margin-left:0}
.profile-actions{display:flex;gap:8px}
.profile-tabs{display:flex;gap:4px;padding:0 16px;border-top:1px solid var(--border)}
.profile-tabs span{padding:16px 8px;font-weight:600;color:var(--muted);cursor:pointer;border-bottom:3px solid transparent;font-size:15px}
.profile-tabs span.active{color:var(--blue);border-bottom-color:var(--blue)}
.profile-layout{display:grid;grid-template-columns:360px 1fr;gap:16px}
.pad{padding:16px}
.pad h3{display:flex;justify-content:space-between;align-items:center;margin-bottom:12px}
.pad h3 a{font-size:14px;color:var(--blue);font-weight:400}
.info-list{display:flex;flex-direction:column;gap:10px;margin-top:12px;font-size:14px}
.info-list i{width:20px;color:var(--muted)}
.photo-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:4px}
.photo-grid img{width:100%;height:110px;object-fit:cover;border-radius:4px}
.friends-mini{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}
.friends-mini div{font-size:12px}
.friends-mini img{width:100%;height:100px;object-fit:cover;border-radius:8px}

/* Modal */
.modal{position:fixed;inset:0;background:rgba(255,255,255,.7);backdrop-filter:blur(2px);display:grid;place-items:center;z-index:200;padding:16px}
.modal.hidden{display:none}
.modal-content{width:100%;max-width:500px;overflow:hidden}
.modal-head{display:flex;align-items:center;justify-content:center;position:relative;padding:16px;border-bottom:1px solid var(--border)}
.modal-head h3{font-size:20px}
.modal-head button{position:absolute;right:12px;width:36px;height:36px;border-radius:50%;border:none;background:#e4e6eb;display:grid;place-items:center;cursor:pointer;font-size:18px}
.modal-user{display:flex;gap:10px;padding:16px 16px 0;align-items:center}
.privacy-pill{background:#e4e6eb;border-radius:6px;padding:4px 8px;font-size:12px;font-weight:600;display:inline-flex;align-items:center;gap:6px;margin-top:4px}
.modal-content textarea{width:calc(100% - 32px);margin:16px;border:none;outline:none;font-size:22px;resize:none;min-height:110px;font-family:inherit}
.modal-content textarea::placeholder{color:var(--muted)}
#postImageUrl,#sellTitle,#sellPrice,#sellImage,#sellCategory{width:calc(100% - 32px);margin:0 16px 8px;border:1px solid var(--border);border-radius:8px;padding:10px 12px;outline:none;font-size:14px}
.add-to-post{margin:0 16px 12px;border:1px solid var(--border);border-radius:8px;padding:10px 12px;display:flex;justify-content:space-between;align-items:center;font-size:14px}
.add-to-post span{display:flex;gap:12px;font-size:18px;cursor:pointer}
#toast{position:fixed;bottom:20px;left:50%;transform:translateX(-50%);background:#333;color:#fff;padding:10px 18px;border-radius:999px;font-size:14px;display:none;z-index:300}

/* Chat windows */
#chatWindows{position:fixed;bottom:0;right:80px;display:flex;gap:12px;align-items:flex-end;z-index:120;pointer-events:none}
.chat-window{width:328px;height:400px;background:var(--card);border-radius:12px 12px 0 0;box-shadow:0 4px 20px rgba(0,0,0,.2);display:flex;flex-direction:column;pointer-events:auto;overflow:hidden}
.chat-head{display:flex;align-items:center;gap:10px;padding:10px;border-bottom:1px solid var(--border);font-weight:600}
.chat-head img{width:32px;height:32px;border-radius:50%}
.chat-head button{margin-left:auto;background:transparent;border:none;width:32px;height:32px;border-radius:50%;display:grid;place-items:center;cursor:pointer;color:var(--muted)}
.chat-head button:hover{background:var(--hover)}
.chat-messages{flex:1;padding:10px;display:flex;flex-direction:column;gap:8px;overflow-y:auto;background:#fff}
.bubble{max-width:70%;padding:8px 12px;border-radius:18px;font-size:14px;line-height:1.3}
.bubble.me{align-self:flex-end;background:var(--blue);color:#fff;border-bottom-right-radius:4px}
.bubble.them{align-self:flex-start;background:var(--bg);border-bottom-left-radius:4px}
.chat-input{display:flex;gap:8px;padding:8px;border-top:1px solid var(--border)}
.chat-input input{flex:1;border:none;background:var(--bg);border-radius:999px;padding:8px 12px;outline:none}

/* Responsive */
@media (max-width:1100px){
  .layout{grid-template-columns:280px 1fr}
  .right-sidebar{display:none}
  .profile-layout{grid-template-columns:1fr}
  #chatWindows{display:none}
  #loginScreen{flex-direction:column;gap:20px}
}
@media (max-width:760px){
  .layout{grid-template-columns:1fr;padding:8px}
  .left-sidebar{display:none}
  .topbar-center{display:none}
  .search-box{min-width:0;max-width:180px}
  .friends-grid,.market-grid{grid-template-columns:1fr}
  .cover{height:200px}
  .profile-avatar{width:120px;height:120px}
}
